libkcal

dummyscheduler.cpp
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22//
23// DummyScheduler - iMIP implementation of iTIP methods
24//
25
26#include <tqfile.h>
27#include <tqtextstream.h>
28
29#include <kdebug.h>
30#include <tdestandarddirs.h>
31
32#include "event.h"
33#include "icalformat.h"
34
35#include "dummyscheduler.h"
36
37using namespace KCal;
38
39DummyScheduler::DummyScheduler(Calendar *calendar)
40 : Scheduler(calendar)
41{
42}
43
44DummyScheduler::~DummyScheduler()
45{
46}
47
48bool DummyScheduler::publish (IncidenceBase *incidence,const TQString &/*recipients*/)
49{
50 TQString messageText = mFormat->createScheduleMessage(incidence,
51 Scheduler::Publish);
52
53 return saveMessage(messageText);
54}
55
56bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method,const TQString &/*recipients*/)
57{
58 TQString messageText = mFormat->createScheduleMessage(incidence,method);
59
60 return saveMessage(messageText);
61}
62
63bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method)
64{
65 TQString messageText = mFormat->createScheduleMessage(incidence,method);
66
67 return saveMessage(messageText);
68}
69
70bool DummyScheduler::saveMessage(const TQString &message)
71{
72 TQFile f("dummyscheduler.store");
73 if (f.open(IO_WriteOnly | IO_Append)) {
74 TQTextStream t(&f);
75 t << message << endl;
76 f.close();
77 return true;
78 } else {
79 return false;
80 }
81}
82
83TQPtrList<ScheduleMessage> DummyScheduler::retrieveTransactions()
84{
85 TQPtrList<ScheduleMessage> messageList;
86
87 TQFile f("dummyscheduler.store");
88 if (!f.open(IO_ReadOnly)) {
89 kdDebug(5800) << "DummyScheduler::retrieveTransactions(): Can't open file"
90 << endl;
91 } else {
92 TQTextStream t(&f);
93 TQString messageString;
94 TQString messageLine = t.readLine();
95 while (!messageLine.isNull()) {
96// kdDebug(5800) << "++++++++" << messageLine << endl;
97 messageString += messageLine + "\n";
98 if (messageLine.find("END:VCALENDAR") >= 0) {
99 kdDebug(5800) << "---------------" << messageString << endl;
100 ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar,
101 messageString);
102 kdDebug(5800) << "--Parsed" << endl;
103 if (message) {
104 messageList.append(message);
105 } else {
106 TQString errorMessage;
107 if (mFormat->exception()) {
108 errorMessage = mFormat->exception()->message();
109 }
110 kdDebug(5800) << "DummyScheduler::retrieveTransactions() Error parsing "
111 "message: " << errorMessage << endl;
112 }
113 messageString="";
114 }
115 messageLine = t.readLine();
116 }
117 f.close();
118 }
119
120 return messageList;
121}
122
123TQString DummyScheduler::freeBusyDir()
124{
125 // the dummy scheduler should never handle freebusy stuff - so it's hardcoded
126 return TQString("");
127}
This is the main "calendar" object class.
Definition: calendar.h:171
This class provides the base class common to all calendar components.
Definition: incidencebase.h:46
This class provides an encapsulation of a scheduling message.
Definition: scheduler.h:45
This class provides an encapsulation of iTIP transactions.
Definition: scheduler.h:98
Namespace KCal is for global classes, objects and/or functions in libkcal.
Definition: alarm.h:38