korganizer
freebusymanager.h
Go to the documentation of this file.00001 /* 00002 This file is part of the Groupware/KOrganizer integration. 00003 00004 Requires the Qt 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 along 00021 with this program; if not, write to the Free Software Foundation, Inc., 00022 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00023 00024 In addition, as a special exception, the copyright holders give 00025 permission to link the code of this program with any edition of 00026 the Qt library by Trolltech AS, Norway (or with modified versions 00027 of Qt that use the same license as Qt), and distribute linked 00028 combinations including the two. You must obey the GNU General 00029 Public License in all respects for all of the code used other than 00030 Qt. If you modify this file, you may extend this exception to 00031 your version of the file, but you are not obligated to do so. If 00032 you do not wish to do so, delete this exception statement from 00033 your version. 00034 */ 00035 #ifndef FREEBUSYMANAGER_H 00036 #define FREEBUSYMANAGER_H 00037 00038 #include <kcal/icalformat.h> 00039 #include <kcal/freebusycache.h> 00040 00041 #include <KUrl> 00042 00043 #include <QByteArray> 00044 #include <QObject> 00045 #include <QString> 00046 00047 namespace KIO { 00048 class Job; 00049 } 00050 namespace KCal { 00051 class Calendar; 00052 class FreeBusy; 00053 } 00054 class FreeBusyManager; 00055 class KJob; 00056 class QTimerEvent; 00057 00061 class FreeBusyDownloadJob : public QObject 00062 { 00063 Q_OBJECT 00064 public: 00065 FreeBusyDownloadJob( const QString &email, const KUrl &url, 00066 FreeBusyManager *manager ); 00067 00068 virtual ~FreeBusyDownloadJob(); 00069 00070 protected slots: 00071 void slotResult( KJob * ); 00072 void slotData( KIO::Job *, const QByteArray &data ); 00073 00074 signals: 00075 void freeBusyDownloaded( KCal::FreeBusy *, const QString & ); 00076 00077 private: 00078 FreeBusyManager *mManager; 00079 QString mEmail; 00080 00081 QByteArray mFreeBusyData; 00082 }; 00083 00084 class FreeBusyManager : public QObject, public KCal::FreeBusyCache 00085 { 00086 Q_OBJECT 00087 public: 00088 FreeBusyManager( QObject *parent ); 00089 00090 void setCalendar( KCal::Calendar * ); 00091 00093 void publishFreeBusy(); 00094 00104 bool retrieveFreeBusy( const QString &email, bool forceDownload ); 00105 00106 void cancelRetrieval(); 00107 00108 KCal::FreeBusy *iCalToFreeBusy( const QByteArray &data ); 00109 00113 KCal::FreeBusy *loadFreeBusy( const QString &email ); 00117 bool saveFreeBusy( KCal::FreeBusy *freebusy, const KCal::Person &person ); 00118 // bool saveFreeBusy( KCal::FreeBusy *, const QString &email ); 00119 00123 KUrl freeBusyUrl( const QString &email ) const; 00124 00128 QString freeBusyDir(); 00129 00134 void setBrokenUrl( bool isBroken ); 00135 00136 public slots: 00137 // When something changed in the calendar, we get this called 00138 void slotPerhapsUploadFB(); 00139 00140 signals: 00144 void freeBusyRetrieved( KCal::FreeBusy *, const QString &email ); 00145 00146 protected: 00147 void timerEvent( QTimerEvent * ); 00148 00152 QString ownerFreeBusyAsString(); 00153 00157 KCal::FreeBusy *ownerFreeBusy(); 00158 00162 QString freeBusyToIcal( KCal::FreeBusy * ); 00163 00164 protected slots: 00165 bool processRetrieveQueue(); 00166 00167 private slots: 00168 void slotUploadFreeBusyResult( KJob * ); 00169 00170 private: 00171 KCal::Calendar *mCalendar; 00172 KCal::ICalFormat mFormat; 00173 00174 QStringList mRetrieveQueue; 00175 00176 // Free/Busy uploading 00177 QDateTime mNextUploadTime; 00178 int mTimerID; 00179 bool mUploadingFreeBusy; 00180 bool mBrokenUrl; 00181 };\ 00182 00183 #endif
KDE 4.2 API Reference