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