libkcal

scheduler.h

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 <tqstring.h>
00025 #include <tqptrlist.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     TQString error() { return mError; }
00076 
00080     static TQString statusName( Status status );
00081 
00082   private:
00083     IncidenceBase *mIncidence;
00084     int mMethod;
00085     Status mStatus;
00086     TQString 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 TQString &recipients ) = 0;
00121     virtual bool performTransaction( IncidenceBase *incidence,
00122                                      Method method ) = 0;
00128     virtual bool performTransaction( IncidenceBase *incidence, Method method,
00129                                      const TQString &recipients ) = 0;
00133     virtual TQPtrList<ScheduleMessage> retrieveTransactions() = 0;
00134 
00142     bool acceptTransaction( IncidenceBase *, Method method,
00143                             ScheduleMessage::Status status,
00144                             const TQString& attendee = TQString::null );
00145 
00149     static TQString methodName( Method );
00153     static TQString translatedMethodName( Method );
00154 
00155     virtual bool deleteTransaction( IncidenceBase *incidence );
00156 
00160     virtual TQString freeBusyDir() = 0;
00161 
00165     void setFreeBusyCache( FreeBusyCache * );
00169     FreeBusyCache *freeBusyCache() const;
00170 
00171   protected:
00172     bool acceptPublish( IncidenceBase *, ScheduleMessage::Status status,
00173                         Method method );
00174     bool acceptRequest( IncidenceBase *, ScheduleMessage::Status status,
00175                         const TQString & attendee );
00176     bool acceptAdd( IncidenceBase *, ScheduleMessage::Status status );
00177     KDE_DEPRECATED bool acceptCancel( IncidenceBase *, ScheduleMessage::Status status );
00178     bool acceptCancel( IncidenceBase *, ScheduleMessage::Status status,
00179                        const TQString & attendee );
00180     bool acceptDeclineCounter( IncidenceBase *,
00181                                ScheduleMessage::Status status );
00182     bool acceptReply( IncidenceBase *, ScheduleMessage::Status status,
00183                       Method method );
00184     bool acceptRefresh( IncidenceBase *, ScheduleMessage::Status status );
00185     bool acceptCounter( IncidenceBase *, ScheduleMessage::Status status );
00186     bool acceptFreeBusy( IncidenceBase *, Method method );
00187 
00188     Calendar *mCalendar;
00189     ICalFormat *mFormat;
00190 
00191   private:
00192     class Private;
00193     Private *d;
00194 };
00195 
00196 }
00197 
00198 #endif