freebusymanager.h
00001 /* 00002 This file is part of the Groupware/KOrganizer integration. 00003 00004 Requires the TQt and KDE widget libraries, available at no cost at 00005 http://www.trolltech.com and http://www.kde.org respectively 00006 00007 Copyright (c) 2002-2004 Klarälvdalens Datakonsult AB 00008 <info@klaralvdalens-datakonsult.se> 00009 00010 This program is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU General Public License as published by 00012 the Free Software Foundation; either version 2 of the License, or 00013 (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00023 MA 02110-1301, USA. 00024 00025 In addition, as a special exception, the copyright holders give 00026 permission to link the code of this program with any edition of 00027 the TQt library by Trolltech AS, Norway (or with modified versions 00028 of TQt that use the same license as TQt), and distribute linked 00029 combinations including the two. You must obey the GNU General 00030 Public License in all respects for all of the code used other than 00031 TQt. If you modify this file, you may extend this exception to 00032 your version of the file, but you are not obligated to do so. If 00033 you do not wish to do so, delete this exception statement from 00034 your version. 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 // bool saveFreeBusy( KCal::FreeBusy *, const TQString &email ); 00115 00119 KURL freeBusyUrl( const TQString &email ); 00120 00124 TQString freeBusyDir(); 00125 00130 void setBrokenUrl( bool isBroken ); 00131 00132 public slots: 00133 // When something changed in the calendar, we get this called 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 // Free/Busy uploading 00174 TQDateTime mNextUploadTime; 00175 int mTimerID; 00176 bool mUploadingFreeBusy; 00177 bool mBrokenUrl; 00178 }; 00179 00180 #endif