korganizer

freebusymanager.h
1/*
2 This file is part of the Groupware/KOrganizer integration.
3
4 Requires the TQt and KDE widget libraries, available at no cost at
5 http://www.trolltech.com and http://www.kde.org respectively
6
7 Copyright (c) 2002-2004 Klarälvdalens Datakonsult AB
8 <info@klaralvdalens-datakonsult.se>
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 MA 02110-1301, USA.
24
25 In addition, as a special exception, the copyright holders give
26 permission to link the code of this program with any edition of
27 the TQt library by Trolltech AS, Norway (or with modified versions
28 of TQt that use the same license as TQt), and distribute linked
29 combinations including the two. You must obey the GNU General
30 Public License in all respects for all of the code used other than
31 TQt. If you modify this file, you may extend this exception to
32 your version of the file, but you are not obligated to do so. If
33 you do not wish to do so, delete this exception statement from
34 your version.
35*/
36#ifndef FREEBUSYMANAGER_H
37#define FREEBUSYMANAGER_H
38
39#include <kurl.h>
40#include <libkcal/icalformat.h>
41#include <libkcal/freebusycache.h>
42#include <tqstring.h>
43#include <tqobject.h>
44
45namespace TDEIO { class Job; }
46namespace KCal {
47class Calendar;
48class FreeBusy;
49}
50class FreeBusyManager;
51
55class FreeBusyDownloadJob : public TQObject
56{
57 TQ_OBJECT
58
59 public:
60 FreeBusyDownloadJob( const TQString &email, const KURL &url,
61 FreeBusyManager *manager, const char *name = 0 );
62
63 virtual ~FreeBusyDownloadJob();
64
65 protected slots:
66 void slotResult( TDEIO::Job * );
67 void slotData( TDEIO::Job *, const TQByteArray &data );
68
69 signals:
70 void freeBusyDownloaded( KCal::FreeBusy *, const TQString& email );
71 void freeBusyDownloadError( const TQString& email );
72
73 private:
74 FreeBusyManager *mManager;
75 TQString mEmail;
76
77 TQCString mFreeBusyData;
78};
79
80class FreeBusyManager : public TQObject, public KCal::FreeBusyCache
81{
82 TQ_OBJECT
83
84 public:
85 FreeBusyManager( TQObject *parent, const char *name );
86
87 void setCalendar( KCal::Calendar * );
88
90 void publishFreeBusy();
91
100 bool retrieveFreeBusy( const TQString &email, bool forceDownload );
101
102 void cancelRetrieval();
103
104 KCal::FreeBusy *iCalToFreeBusy( const TQCString &data );
105
109 KCal::FreeBusy *loadFreeBusy( const TQString &email );
113 bool saveFreeBusy( KCal::FreeBusy *freebusy, const KCal::Person &person );
114// bool saveFreeBusy( KCal::FreeBusy *, const TQString &email );
115
119 KURL freeBusyUrl( const TQString &email );
120
124 TQString freeBusyDir();
125
130 void setBrokenUrl( bool isBroken );
131
132 public slots:
133 // When something changed in the calendar, we get this called
134 void slotPerhapsUploadFB();
135
136 signals:
140 void freeBusyRetrieved( KCal::FreeBusy *, const TQString &email );
141
142 protected:
143 void timerEvent( TQTimerEvent* );
144
148 TQString ownerFreeBusyAsString();
149
153 KCal::FreeBusy *ownerFreeBusy();
154
158 TQString freeBusyToIcal( KCal::FreeBusy * );
159
160 protected slots:
161 bool processRetrieveQueue();
162
163 private slots:
164 void slotUploadFreeBusyResult( TDEIO::Job * );
165 void slotFreeBusyDownloadError( const TQString& email );
166
167 private:
168 KCal::Calendar *mCalendar;
169 KCal::ICalFormat mFormat;
170
171 TQStringList mRetrieveQueue;
172
173 // Free/Busy uploading
174 TQDateTime mNextUploadTime;
175 int mTimerID;
176 bool mUploadingFreeBusy;
177 bool mBrokenUrl;
178};
179
180#endif
Class for downloading FreeBusy Lists.