libkcal

scheduler.h

Go to the documentation of this file.
00001 /*
00002     This file is part of libkcal.
00003 
00004     Copyright (c) 2001-2003 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 #ifndef KCAL_SCHEDULER_H
00022 #define KCAL_SCHEDULER_H
00023 
00024 #include <qstring.h>
00025 #include <qptrlist.h>
00026 
00027 #include "libkcal_export.h"
00028 
00029 namespace KCal {
00030 
00031 class IncidenceBase;
00032 class Event;
00033 class Calendar;
00034 class ICalFormat;
00035 class FreeBusyCache;
00036 
00044 class ScheduleMessage
00045 {
00046   public:
00050     enum Status { PublishNew, PublishUpdate, Obsolete, RequestNew,
00051                   RequestUpdate, Unknown };
00052   
00057     ScheduleMessage( IncidenceBase *, int method, Status status );
00058     ~ScheduleMessage() {};
00059     
00063     IncidenceBase *event() { return mIncidence; }
00067     int method() { return mMethod; }
00071     Status status() { return mStatus; }
00075     QString error() { return mError; }
00076 
00080     static QString statusName( Status status );
00081 
00082   private:
00083     IncidenceBase *mIncidence;
00084     int mMethod;
00085     Status mStatus;
00086     QString mError;
00087 
00088     class Private;
00089     Private *d;
00090 };
00091 
00097 class LIBKCAL_EXPORT Scheduler
00098 {
00099   public:
00103     enum Method { Publish,Request,Refresh,Cancel,Add,Reply,Counter,
00104                   Declinecounter,NoMethod };
00105   
00109     Scheduler( Calendar *calendar );
00110     virtual ~Scheduler();
00111     
00115     virtual bool publish( IncidenceBase *incidence,
00116                           const QString &recipients ) = 0;
00121     virtual bool performTransaction( IncidenceBase *incidence,
00122                                      Method method ) = 0;
00128     virtual bool performTransaction( IncidenceBase *incidence, Method method,
00129                                      const QString &recipients ) = 0;
00133     virtual QPtrList<ScheduleMessage> retrieveTransactions() = 0;
00134 
00141     bool acceptTransaction( IncidenceBase *, Method method,
00142                             ScheduleMessage::Status status );
00143 
00147     static QString methodName( Method );
00151     static QString translatedMethodName( Method );
00152 
00153     virtual bool deleteTransaction( IncidenceBase *incidence );
00154     
00158     virtual QString freeBusyDir() = 0;
00159 
00163     void setFreeBusyCache( FreeBusyCache * );
00167     FreeBusyCache *freeBusyCache() const;
00168 
00169   protected:
00170     bool acceptPublish( IncidenceBase *, ScheduleMessage::Status status,
00171                         Method method );
00172     bool acceptRequest( IncidenceBase *, ScheduleMessage::Status status );
00173     bool acceptAdd( IncidenceBase *, ScheduleMessage::Status status );
00174     bool acceptCancel( IncidenceBase *, ScheduleMessage::Status status );
00175     bool acceptDeclineCounter( IncidenceBase *,
00176                                ScheduleMessage::Status status );
00177     bool acceptReply( IncidenceBase *, ScheduleMessage::Status status,
00178                       Method method );
00179     bool acceptRefresh( IncidenceBase *, ScheduleMessage::Status status );
00180     bool acceptCounter( IncidenceBase *, ScheduleMessage::Status status );
00181     bool acceptFreeBusy( IncidenceBase *, Method method );
00182 
00183     Calendar *mCalendar;
00184     ICalFormat *mFormat;
00185 
00186   private:
00187     class Private;
00188     Private *d;
00189 };
00190 
00191 }
00192 
00193 #endif