1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/*
This file is part of tdepim.
Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef TDEABC_RESOURCEGROUPWISE_H
#define TDEABC_RESOURCEGROUPWISE_H
#include "soap/groupwiseserver.h"
#include <tdeabcresourcecached.h>
#include <kdemacros.h>
#include <libtdepim/progressmanager.h>
#include <tdeio/job.h>
class TDEConfig;
class GroupwiseServer;
namespace TDEABC {
class GroupwisePrefs;
class KDE_EXPORT ResourceGroupwise : public ResourceCached
{
friend class ResourceGroupwiseConfig;
TQ_OBJECT
public:
ResourceGroupwise( const TDEConfig * );
ResourceGroupwise( const KURL &url,
const TQString &user, const TQString &password,
const TQStringList &readAddressBooks,
const TQString &writeAddressBook );
~ResourceGroupwise();
void readConfig( const TDEConfig * );
void writeConfig( TDEConfig * );
void readAddressBooks();
void writeAddressBooks();
void retrieveAddressBooks();
GroupwisePrefs *prefs() const { return mPrefs; }
GroupWise::AddressBook::List addressBooks() const { return mAddressBooks; }
bool doOpen();
void doClose();
Ticket *requestSaveTicket();
void releaseSaveTicket( Ticket* );
bool load();
bool asyncLoad();
bool save( Ticket * );
bool asyncSave( Ticket * );
enum SABState { Error, Stale, InSync, RefreshNeeded };
/**
* Clears the cached data, in memory and on disk
*/
void clearCache();
protected:
enum ResourceState { Start, FetchingSAB, SABUptodate, FetchingUAB, Uptodate };
enum BookType { System, User };
enum AccessMode { Fetch, Update };
void init();
void initGroupwise();
/* STATE CHANGING METHODS */
/**
* Begin asynchronously fetching the system address book , replacing the cached copy
*/
void fetchAddressBooks( const BookType booktype );
/**
* Asynchronously update the system address book
*/
void updateSystemAddressBook();
/**
* Wrap up the load sequence
*/
void loadCompleted();
/** HELPER METHODS **/
/**
* Check to see if a local download of the SAB already exists
*/
SABState systemAddressBookState();
/**
* Check if the resource is configured to download the SAB
*/
bool shouldFetchSystemAddressBook();
/**
* Check if the resource is configured to download personal address
* books
*/
bool shouldFetchUserAddressBooks();
/**
* Create a URL for a single addressbook access.
* To fetch an address book completely, use mode = Fetch
* To just update an addressbook, use mode = Update and give the ast sequence number already held
* If Update is given without a sequence number, the mode falls back to Fetch
*/
KURL createAccessUrl( BookType bookType, AccessMode mode, unsigned long lastSequenceNumber = 0, unsigned long lastPORebuildTime = 0 );
/**
* Persist the last known delta info. Call after the SAB is up to date.
*/
void storeDeltaInfo();
/**
* Check if the application which has loaded this resource is whitelisted
* to load the System Address Book (time-consuming)
*/
bool appIsWhiteListedForSAB();
private slots:
/** STATE CHANGING SLOTS **/
void fetchSABResult( TDEIO::Job * );
void fetchUABResult( TDEIO::Job * );
void updateSABResult( TDEIO::Job * );
/** DATA PROCESSING SLOTS **/
void slotReadJobData( TDEIO::Job *, const TQByteArray & );
void slotUpdateJobData( TDEIO::Job *, const TQByteArray & );
/** HELPER TQT_SLOT **/
void slotJobPercent( TDEIO::Job *job, unsigned long percent );
void cancelLoad();
private:
GroupwisePrefs *mPrefs;
GroupWise::AddressBook::List mAddressBooks;
GroupwiseServer *mServer;
TDEIO::TransferJob *mJob;
KPIM::ProgressItem *mProgress;
KPIM::ProgressItem *mSABProgress;
KPIM::ProgressItem *mUABProgress;
TQString mJobData;
ResourceState mState;
unsigned long mServerFirstSequence, mServerLastSequence, mServerLastPORebuildTime;
bool mLimitedMode;
};
}
#endif
|