libkcal Library API Documentation

dummyscheduler.cpp

00001 /* 00002 This file is part of libkcal. 00003 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 // 00022 // DummyScheduler - iMIP implementation of iTIP methods 00023 // 00024 00025 #include <qfile.h> 00026 #include <qtextstream.h> 00027 00028 #include <kdebug.h> 00029 #include <kstandarddirs.h> 00030 00031 #include "event.h" 00032 #include "icalformat.h" 00033 00034 #include "dummyscheduler.h" 00035 00036 using namespace KCal; 00037 00038 DummyScheduler::DummyScheduler(Calendar *calendar) 00039 : Scheduler(calendar) 00040 { 00041 } 00042 00043 DummyScheduler::~DummyScheduler() 00044 { 00045 } 00046 00047 bool DummyScheduler::publish (IncidenceBase *incidence,const QString &recipients) 00048 { 00049 QString messageText = mFormat->createScheduleMessage(incidence, 00050 Scheduler::Publish); 00051 00052 return saveMessage(messageText); 00053 } 00054 00055 bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method,const QString &recipients) 00056 { 00057 QString messageText = mFormat->createScheduleMessage(incidence,method); 00058 00059 return saveMessage(messageText); 00060 } 00061 00062 bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method) 00063 { 00064 QString messageText = mFormat->createScheduleMessage(incidence,method); 00065 00066 return saveMessage(messageText); 00067 } 00068 00069 bool DummyScheduler::saveMessage(const QString &message) 00070 { 00071 QFile f("dummyscheduler.store"); 00072 if (f.open(IO_WriteOnly | IO_Append)) { 00073 QTextStream t(&f); 00074 t << message << endl; 00075 f.close(); 00076 return true; 00077 } else { 00078 return false; 00079 } 00080 } 00081 00082 QPtrList<ScheduleMessage> DummyScheduler::retrieveTransactions() 00083 { 00084 QPtrList<ScheduleMessage> messageList; 00085 00086 QFile f("dummyscheduler.store"); 00087 if (!f.open(IO_ReadOnly)) { 00088 kdDebug(5800) << "DummyScheduler::retrieveTransactions(): Can't open file" 00089 << endl; 00090 } else { 00091 QTextStream t(&f); 00092 QString messageString; 00093 QString messageLine = t.readLine(); 00094 while (!messageLine.isNull()) { 00095 // kdDebug(5800) << "++++++++" << messageLine << endl; 00096 messageString += messageLine + "\n"; 00097 if (messageLine.find("END:VCALENDAR") >= 0) { 00098 kdDebug(5800) << "---------------" << messageString << endl; 00099 ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar, 00100 messageString); 00101 kdDebug(5800) << "--Parsed" << endl; 00102 if (message) { 00103 messageList.append(message); 00104 } else { 00105 QString errorMessage; 00106 if (mFormat->exception()) { 00107 errorMessage = mFormat->exception()->message(); 00108 } 00109 kdDebug(5800) << "DummyScheduler::retrieveTransactions() Error parsing " 00110 "message: " << errorMessage << endl; 00111 } 00112 messageString=""; 00113 } 00114 messageLine = t.readLine(); 00115 } 00116 f.close(); 00117 } 00118 00119 return messageList; 00120 } 00121 00122 QString DummyScheduler::freeBusyDir() 00123 { 00124 // the dummy scheduler should never handle freebusy stuff - so it's hardcoded 00125 return QString(""); 00126 }
KDE Logo
This file is part of the documentation for libkcal Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:44 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003