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 
00030 #include "event.h"
00031 #include "icalformat.h"
00032 
00033 #include "dummyscheduler.h"
00034 
00035 using namespace KCal;
00036 
00037 DummyScheduler::DummyScheduler(Calendar *calendar)
00038   : Scheduler(calendar)
00039 {
00040 }
00041 
00042 DummyScheduler::~DummyScheduler()
00043 {
00044 }
00045 
00046 bool DummyScheduler::publish (IncidenceBase *incidence,const QString &recipients)
00047 {
00048   QString messageText = mFormat->createScheduleMessage(incidence,
00049                                                        Scheduler::Publish);
00050 
00051   return saveMessage(messageText);
00052 }
00053 
00054 bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method,const QString &recipients)
00055 {
00056   QString messageText = mFormat->createScheduleMessage(incidence,method);
00057 
00058   return saveMessage(messageText);
00059 }
00060 
00061 bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method)
00062 {
00063   QString messageText = mFormat->createScheduleMessage(incidence,method);
00064 
00065   return saveMessage(messageText);
00066 }
00067 
00068 bool DummyScheduler::saveMessage(const QString &message)
00069 {
00070   QFile f("dummyscheduler.store");
00071   if (f.open(IO_WriteOnly | IO_Append)) {
00072     QTextStream t(&f);
00073     t << message << endl;
00074     f.close();
00075     return true;
00076   } else {
00077     return false;
00078   }
00079 }
00080 
00081 QPtrList<ScheduleMessage> DummyScheduler::retrieveTransactions()
00082 {
00083   QPtrList<ScheduleMessage> messageList;
00084 
00085   QFile f("dummyscheduler.store");
00086   if (!f.open(IO_ReadOnly)) {
00087     kdDebug(5800) << "DummyScheduler::retrieveTransactions(): Can't open file"
00088               << endl;
00089   } else {
00090     QTextStream t(&f);
00091     QString messageString;
00092     QString messageLine = t.readLine();
00093     while (!messageLine.isNull()) {
00094 //      kdDebug(5800) << "++++++++" << messageLine << endl;
00095       messageString += messageLine + "\n";
00096       if (messageLine.find("END:VCALENDAR") >= 0) {
00097         kdDebug(5800) << "---------------" << messageString << endl;
00098         ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar,
00099                                                                  messageString);
00100         kdDebug(5800) << "--Parsed" << endl;
00101         if (message) {
00102           messageList.append(message);
00103         } else {
00104           QString errorMessage;
00105           if (mFormat->exception()) {
00106             errorMessage = mFormat->exception()->message();
00107           }
00108           kdDebug(5800) << "DummyScheduler::retrieveTransactions() Error parsing "
00109                        "message: " << errorMessage << endl;
00110         }
00111         messageString="";
00112       }
00113       messageLine = t.readLine();
00114     }
00115     f.close();
00116   }
00117 
00118   return messageList;
00119 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:03 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001