• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KCal Library

dummyscheduler.cpp

00001 /*
00002   This file is part of the kcal library.
00003 
00004   Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Library General Public
00008   License as published by the Free Software Foundation; either
00009   version 2 of the License, or (at your option) any later version.
00010 
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Library General Public License for more details.
00015 
00016   You should have received a copy of the GNU Library General Public License
00017   along with this library; see the file COPYING.LIB.  If not, write to
00018   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019   Boston, MA 02110-1301, USA.
00020 */
00021 
00022 //
00023 // DummyScheduler - iMIP implementation of iTIP methods
00024 //
00025 
00026 #include "dummyscheduler.h"
00027 #include "event.h"
00028 #include "icalformat.h"
00029 
00030 #include <kdebug.h>
00031 #include <kstandarddirs.h>
00032 
00033 #include <QtCore/QFile>
00034 #include <QtCore/QTextStream>
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   Q_UNUSED( recipients );
00050   QString messageText = mFormat->createScheduleMessage( incidence, iTIPPublish );
00051 
00052   return saveMessage( messageText );
00053 }
00054 
00055 bool DummyScheduler::performTransaction( IncidenceBase *incidence,
00056                                          iTIPMethod method,
00057                                          const QString &recipients )
00058 {
00059   Q_UNUSED( recipients );
00060   QString messageText = mFormat->createScheduleMessage( incidence, method );
00061 
00062   return saveMessage( messageText );
00063 }
00064 
00065 bool DummyScheduler::performTransaction( IncidenceBase *incidence, iTIPMethod method )
00066 {
00067   QString messageText = mFormat->createScheduleMessage( incidence, method );
00068 
00069   return saveMessage( messageText );
00070 }
00071 
00072 bool DummyScheduler::saveMessage( const QString &message )
00073 {
00074   QFile f( "dummyscheduler.store" );
00075   if ( f.open( QIODevice::WriteOnly | QIODevice::Append ) ) {
00076     QTextStream t( &f );
00077     t << message << endl;
00078     f.close();
00079     return true;
00080   } else {
00081     return false;
00082   }
00083 }
00084 
00085 QList<ScheduleMessage*> DummyScheduler::retrieveTransactions()
00086 {
00087   QList<ScheduleMessage*> messageList;
00088 
00089   QFile f( "dummyscheduler.store" );
00090   if ( !f.open( QIODevice::ReadOnly ) ) {
00091     kDebug() << "Can't open file";
00092   } else {
00093     QTextStream t( &f );
00094     QString messageString;
00095     QString messageLine = t.readLine();
00096     while ( !messageLine.isNull() ) {
00097       messageString += messageLine + '\n';
00098       if ( messageLine.indexOf( "END:VCALENDAR" ) >= 0 ) {
00099         kDebug() << "---------------" << messageString;
00100         ScheduleMessage *message = mFormat->parseScheduleMessage( mCalendar,
00101                                                                   messageString );
00102         kDebug() << "--Parsed";
00103         if ( message ) {
00104           messageList.append( message );
00105         } else {
00106           QString errorMessage;
00107           if ( mFormat->exception() ) {
00108             errorMessage = mFormat->exception()->message();
00109           }
00110           kDebug() << "Error parsing message:" << errorMessage;
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 }

KCal Library

Skip menu "KCal Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal