home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / libkcal / scheduler.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  5.6 KB  |  194 lines

  1. /*
  2.     This file is part of libkcal.
  3.  
  4.     Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.  
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU Library General Public License
  17.     along with this library; see the file COPYING.LIB.  If not, write to
  18.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19.     Boston, MA 02110-1301, USA.
  20. */
  21. #ifndef KCAL_SCHEDULER_H
  22. #define KCAL_SCHEDULER_H
  23.  
  24. #include <qstring.h>
  25. #include <qptrlist.h>
  26.  
  27. #include "libkcal_export.h"
  28.  
  29. namespace KCal {
  30.  
  31. class IncidenceBase;
  32. class Event;
  33. class Calendar;
  34. class ICalFormat;
  35. class FreeBusyCache;
  36.  
  37. /**
  38.   This class provides an encapsulation of a scheduling message. It associates an
  39.   incidence with a method and status information. This class is used by the
  40.   Scheduler class.
  41.  
  42.   @short A Scheduling message
  43. */
  44. class ScheduleMessage
  45. {
  46.   public:
  47.     /**
  48.       Message status.
  49.     */
  50.     enum Status { PublishNew, PublishUpdate, Obsolete, RequestNew,
  51.                   RequestUpdate, Unknown };
  52.   
  53.     /**
  54.       Create a scheduling message with method as defined in Scheduler::Method
  55.       and a status.
  56.     */
  57.     ScheduleMessage( IncidenceBase *, int method, Status status );
  58.     ~ScheduleMessage() {};
  59.     
  60.     /**
  61.       Return event associated with this message.
  62.     */
  63.     IncidenceBase *event() { return mIncidence; }
  64.     /**
  65.       Return iTIP method associated with this message.
  66.     */
  67.     int method() { return mMethod; }
  68.     /**
  69.       Return status of this message.
  70.     */
  71.     Status status() { return mStatus; }
  72.     /**
  73.       Return error message if there is any.
  74.     */
  75.     QString error() { return mError; }
  76.  
  77.     /**
  78.       Return a human-readable name for an iTIP message status.
  79.     */
  80.     static QString statusName( Status status );
  81.  
  82.   private:
  83.     IncidenceBase *mIncidence;
  84.     int mMethod;
  85.     Status mStatus;
  86.     QString mError;
  87.  
  88.     class Private;
  89.     Private *d;
  90. };
  91.  
  92. /**
  93.   This class provides an encapsulation of iTIP transactions. It is an abstract
  94.   base class for inheritance by implementations of the iTIP scheme like iMIP or
  95.   iRIP.
  96. */
  97. class LIBKCAL_EXPORT Scheduler
  98. {
  99.   public:
  100.     /**
  101.       iTIP methods.
  102.     */
  103.     enum Method { Publish,Request,Refresh,Cancel,Add,Reply,Counter,
  104.                   Declinecounter,NoMethod };
  105.   
  106.     /**
  107.       Create scheduler for calendar specified as argument.
  108.     */
  109.     Scheduler( Calendar *calendar );
  110.     virtual ~Scheduler();
  111.     
  112.     /**
  113.       iTIP publish action
  114.     */
  115.     virtual bool publish( IncidenceBase *incidence,
  116.                           const QString &recipients ) = 0;
  117.     /**
  118.       Perform iTIP transaction on incidence. The method is specified as the
  119.       method argument and can be any valid iTIP method.
  120.     */
  121.     virtual bool performTransaction( IncidenceBase *incidence,
  122.                                      Method method ) = 0;
  123.     /**
  124.       Perform iTIP transaction on incidence to specified recipient(s). The 
  125.       method is specified as the method argumanet and can be any valid iTIP 
  126.       method.
  127.     */
  128.     virtual bool performTransaction( IncidenceBase *incidence, Method method,
  129.                                      const QString &recipients ) = 0;
  130.     /**
  131.       Retrieve incoming iTIP transactions.
  132.     */
  133.     virtual QPtrList<ScheduleMessage> retrieveTransactions() = 0;
  134.  
  135.     /**
  136.       Accept transaction. The incidence argument specifies the iCal compoennt
  137.       on which the transaction acts. The status is the result of processing a
  138.       iTIP message with the current calendar and specifies the action to be
  139.       taken for this incidence.
  140.     */
  141.     bool acceptTransaction( IncidenceBase *, Method method,
  142.                             ScheduleMessage::Status status );
  143.  
  144.     /**
  145.       Return a machine-readable name for a iTIP method.
  146.     */
  147.     static QString methodName( Method );
  148.     /**
  149.       Return a translated human-readable name for a iTIP method.
  150.     */
  151.     static QString translatedMethodName( Method );
  152.  
  153.     virtual bool deleteTransaction( IncidenceBase *incidence );
  154.     
  155.     /**
  156.       Returns the directory where the free-busy information is stored.
  157.     */
  158.     virtual QString freeBusyDir() = 0;
  159.  
  160.     /**
  161.       Set free/busy cache used to store free/busy information.
  162.     */
  163.     void setFreeBusyCache( FreeBusyCache * );
  164.     /**
  165.       Return free/busy cache.
  166.     */
  167.     FreeBusyCache *freeBusyCache() const;
  168.  
  169.   protected:
  170.     bool acceptPublish( IncidenceBase *, ScheduleMessage::Status status,
  171.                         Method method );
  172.     bool acceptRequest( IncidenceBase *, ScheduleMessage::Status status );
  173.     bool acceptAdd( IncidenceBase *, ScheduleMessage::Status status );
  174.     bool acceptCancel( IncidenceBase *, ScheduleMessage::Status status );
  175.     bool acceptDeclineCounter( IncidenceBase *,
  176.                                ScheduleMessage::Status status );
  177.     bool acceptReply( IncidenceBase *, ScheduleMessage::Status status,
  178.                       Method method );
  179.     bool acceptRefresh( IncidenceBase *, ScheduleMessage::Status status );
  180.     bool acceptCounter( IncidenceBase *, ScheduleMessage::Status status );
  181.     bool acceptFreeBusy( IncidenceBase *, Method method );
  182.  
  183.     Calendar *mCalendar;
  184.     ICalFormat *mFormat;
  185.  
  186.   private:
  187.     class Private;
  188.     Private *d;
  189. };
  190.  
  191. }
  192.  
  193. #endif
  194.