00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef FREEBUSYMANAGER_H
00037 #define FREEBUSYMANAGER_H
00038
00039 #include <kurl.h>
00040 #include <libkcal/icalformat.h>
00041 #include <libkcal/freebusycache.h>
00042 #include <tqstring.h>
00043 #include <tqobject.h>
00044
00045 namespace TDEIO { class Job; }
00046 namespace KCal {
00047 class Calendar;
00048 class FreeBusy;
00049 }
00050 class FreeBusyManager;
00051
00055 class FreeBusyDownloadJob : public TQObject
00056 {
00057 Q_OBJECT
00058
00059 public:
00060 FreeBusyDownloadJob( const TQString &email, const KURL &url,
00061 FreeBusyManager *manager, const char *name = 0 );
00062
00063 virtual ~FreeBusyDownloadJob();
00064
00065 protected slots:
00066 void slotResult( TDEIO::Job * );
00067 void slotData( TDEIO::Job *, const TQByteArray &data );
00068
00069 signals:
00070 void freeBusyDownloaded( KCal::FreeBusy *, const TQString& email );
00071 void freeBusyDownloadError( const TQString& email );
00072
00073 private:
00074 FreeBusyManager *mManager;
00075 TQString mEmail;
00076
00077 TQCString mFreeBusyData;
00078 };
00079
00080 class FreeBusyManager : public TQObject, public KCal::FreeBusyCache
00081 {
00082 Q_OBJECT
00083
00084 public:
00085 FreeBusyManager( TQObject *parent, const char *name );
00086
00087 void setCalendar( KCal::Calendar * );
00088
00090 void publishFreeBusy();
00091
00100 bool retrieveFreeBusy( const TQString &email, bool forceDownload );
00101
00102 void cancelRetrieval();
00103
00104 KCal::FreeBusy *iCalToFreeBusy( const TQCString &data );
00105
00109 KCal::FreeBusy *loadFreeBusy( const TQString &email );
00113 bool saveFreeBusy( KCal::FreeBusy *freebusy, const KCal::Person &person );
00114
00115
00119 KURL freeBusyUrl( const TQString &email );
00120
00124 TQString freeBusyDir();
00125
00130 void setBrokenUrl( bool isBroken );
00131
00132 public slots:
00133
00134 void slotPerhapsUploadFB();
00135
00136 signals:
00140 void freeBusyRetrieved( KCal::FreeBusy *, const TQString &email );
00141
00142 protected:
00143 void timerEvent( TQTimerEvent* );
00144
00148 TQString ownerFreeBusyAsString();
00149
00153 KCal::FreeBusy *ownerFreeBusy();
00154
00158 TQString freeBusyToIcal( KCal::FreeBusy * );
00159
00160 protected slots:
00161 bool processRetrieveQueue();
00162
00163 private slots:
00164 void slotUploadFreeBusyResult( TDEIO::Job * );
00165 void slotFreeBusyDownloadError( const TQString& email );
00166
00167 private:
00168 KCal::Calendar *mCalendar;
00169 KCal::ICalFormat mFormat;
00170
00171 TQStringList mRetrieveQueue;
00172
00173
00174 TQDateTime mNextUploadTime;
00175 int mTimerID;
00176 bool mUploadingFreeBusy;
00177 bool mBrokenUrl;
00178 };
00179
00180 #endif