summaryrefslogtreecommitdiffabout
path: root/libkcal/dummyscheduler.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /libkcal/dummyscheduler.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'libkcal/dummyscheduler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/dummyscheduler.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/libkcal/dummyscheduler.cpp b/libkcal/dummyscheduler.cpp
index ae40e6d..73eb3d0 100644
--- a/libkcal/dummyscheduler.cpp
+++ b/libkcal/dummyscheduler.cpp
@@ -1,119 +1,121 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// 21//
22// DummyScheduler - iMIP implementation of iTIP methods 22// DummyScheduler - iMIP implementation of iTIP methods
23// 23//
24 24
25#include <qfile.h> 25#include <qfile.h>
26#include <qtextstream.h> 26#include <q3textstream.h>
27//Added by qt3to4:
28#include <Q3PtrList>
27 29
28#include <kdebug.h> 30#include <kdebug.h>
29 31
30#include "event.h" 32#include "event.h"
31#include "icalformat.h" 33#include "icalformat.h"
32 34
33#include "dummyscheduler.h" 35#include "dummyscheduler.h"
34 36
35using namespace KCal; 37using namespace KCal;
36 38
37DummyScheduler::DummyScheduler(Calendar *calendar) 39DummyScheduler::DummyScheduler(Calendar *calendar)
38 : Scheduler(calendar) 40 : Scheduler(calendar)
39{ 41{
40} 42}
41 43
42DummyScheduler::~DummyScheduler() 44DummyScheduler::~DummyScheduler()
43{ 45{
44} 46}
45 47
46bool DummyScheduler::publish (IncidenceBase *incidence,const QString &recipients) 48bool DummyScheduler::publish (IncidenceBase *incidence,const QString &recipients)
47{ 49{
48 QString messageText = mFormat->createScheduleMessage(incidence, 50 QString messageText = mFormat->createScheduleMessage(incidence,
49 Scheduler::Publish); 51 Scheduler::Publish);
50 52
51 return saveMessage(messageText); 53 return saveMessage(messageText);
52} 54}
53 55
54bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method,const QString &recipients) 56bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method,const QString &recipients)
55{ 57{
56 QString messageText = mFormat->createScheduleMessage(incidence,method); 58 QString messageText = mFormat->createScheduleMessage(incidence,method);
57 59
58 return saveMessage(messageText); 60 return saveMessage(messageText);
59} 61}
60 62
61bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method) 63bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method)
62{ 64{
63 QString messageText = mFormat->createScheduleMessage(incidence,method); 65 QString messageText = mFormat->createScheduleMessage(incidence,method);
64 66
65 return saveMessage(messageText); 67 return saveMessage(messageText);
66} 68}
67 69
68bool DummyScheduler::saveMessage(const QString &message) 70bool DummyScheduler::saveMessage(const QString &message)
69{ 71{
70 QFile f("dummyscheduler.store"); 72 QFile f("dummyscheduler.store");
71 if (f.open(IO_WriteOnly | IO_Append)) { 73 if (f.open(QIODevice::WriteOnly | QIODevice::Append)) {
72 QTextStream t(&f); 74 Q3TextStream t(&f);
73 t << message << endl; 75 t << message << endl;
74 f.close(); 76 f.close();
75 return true; 77 return true;
76 } else { 78 } else {
77 return false; 79 return false;
78 } 80 }
79} 81}
80 82
81QPtrList<ScheduleMessage> DummyScheduler::retrieveTransactions() 83Q3PtrList<ScheduleMessage> DummyScheduler::retrieveTransactions()
82{ 84{
83 QPtrList<ScheduleMessage> messageList; 85 Q3PtrList<ScheduleMessage> messageList;
84 86
85 QFile f("dummyscheduler.store"); 87 QFile f("dummyscheduler.store");
86 if (!f.open(IO_ReadOnly)) { 88 if (!f.open(QIODevice::ReadOnly)) {
87 kdDebug(5800) << "DummyScheduler::retrieveTransactions(): Can't open file" 89 kdDebug(5800) << "DummyScheduler::retrieveTransactions(): Can't open file"
88 << endl; 90 << endl;
89 } else { 91 } else {
90 QTextStream t(&f); 92 Q3TextStream t(&f);
91 QString messageString; 93 QString messageString;
92 QString messageLine = t.readLine(); 94 QString messageLine = t.readLine();
93 while (!messageLine.isNull()) { 95 while (!messageLine.isNull()) {
94// kdDebug(5800) << "++++++++" << messageLine << endl; 96// kdDebug(5800) << "++++++++" << messageLine << endl;
95 messageString += messageLine + "\n"; 97 messageString += messageLine + "\n";
96 if (messageLine.find("END:VCALENDAR") >= 0) { 98 if (messageLine.find("END:VCALENDAR") >= 0) {
97 kdDebug(5800) << "---------------" << messageString << endl; 99 kdDebug(5800) << "---------------" << messageString << endl;
98 ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar, 100 ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar,
99 messageString); 101 messageString);
100 kdDebug(5800) << "--Parsed" << endl; 102 kdDebug(5800) << "--Parsed" << endl;
101 if (message) { 103 if (message) {
102 messageList.append(message); 104 messageList.append(message);
103 } else { 105 } else {
104 QString errorMessage; 106 QString errorMessage;
105 if (mFormat->exception()) { 107 if (mFormat->exception()) {
106 errorMessage = mFormat->exception()->message(); 108 errorMessage = mFormat->exception()->message();
107 } 109 }
108 kdDebug(5800) << "DummyScheduler::retrieveTransactions() Error parsing " 110 kdDebug(5800) << "DummyScheduler::retrieveTransactions() Error parsing "
109 "message: " << errorMessage << endl; 111 "message: " << errorMessage << endl;
110 } 112 }
111 messageString=""; 113 messageString="";
112 } 114 }
113 messageLine = t.readLine(); 115 messageLine = t.readLine();
114 } 116 }
115 f.close(); 117 f.close();
116 } 118 }
117 119
118 return messageList; 120 return messageList;
119} 121}