author | zautrix <zautrix> | 2004-10-09 16:58:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-09 16:58:08 (UTC) |
commit | 59ed933d6c43ecb0ddd3dec53cc289ee8aa68482 (patch) (unidiff) | |
tree | 8b1cbcf9c420e7dffd1e1293bcfa69e8e821f3fa /kabc/addressbook.cpp | |
parent | b80a099d9432bdc3d4eea778b1813b82b2680ecf (diff) | |
download | kdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.zip kdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.tar.gz kdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.tar.bz2 |
fixed sync bug
-rw-r--r-- | kabc/addressbook.cpp | 72 |
1 files changed, 46 insertions, 26 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 1050f55..ff05f7e 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,1004 +1,1024 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | /*US | 28 | /*US |
29 | 29 | ||
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | #include <kinstance.h> | 35 | #include <kinstance.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | #include "errorhandler.h" | 38 | #include "errorhandler.h" |
39 | */ | 39 | */ |
40 | #include <qptrlist.h> | 40 | #include <qptrlist.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | 44 | ||
45 | #include <kglobal.h> | 45 | #include <kglobal.h> |
46 | #include <klocale.h> | 46 | #include <klocale.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kdebug.h> | 48 | #include <kdebug.h> |
49 | #include <libkcal/syncdefines.h> | 49 | #include <libkcal/syncdefines.h> |
50 | #include "addressbook.h" | 50 | #include "addressbook.h" |
51 | #include "resource.h" | 51 | #include "resource.h" |
52 | #include "vcardconverter.h" | 52 | #include "vcardconverter.h" |
53 | #include "vcardparser/vcardtool.h" | 53 | #include "vcardparser/vcardtool.h" |
54 | 54 | ||
55 | //US #include "addressbook.moc" | 55 | //US #include "addressbook.moc" |
56 | 56 | ||
57 | using namespace KABC; | 57 | using namespace KABC; |
58 | 58 | ||
59 | struct AddressBook::AddressBookData | 59 | struct AddressBook::AddressBookData |
60 | { | 60 | { |
61 | Addressee::List mAddressees; | 61 | Addressee::List mAddressees; |
62 | Addressee::List mRemovedAddressees; | 62 | Addressee::List mRemovedAddressees; |
63 | Field::List mAllFields; | 63 | Field::List mAllFields; |
64 | KConfig *mConfig; | 64 | KConfig *mConfig; |
65 | KRES::Manager<Resource> *mManager; | 65 | KRES::Manager<Resource> *mManager; |
66 | //US ErrorHandler *mErrorHandler; | 66 | //US ErrorHandler *mErrorHandler; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | struct AddressBook::Iterator::IteratorData | 69 | struct AddressBook::Iterator::IteratorData |
70 | { | 70 | { |
71 | Addressee::List::Iterator mIt; | 71 | Addressee::List::Iterator mIt; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | struct AddressBook::ConstIterator::ConstIteratorData | 74 | struct AddressBook::ConstIterator::ConstIteratorData |
75 | { | 75 | { |
76 | Addressee::List::ConstIterator mIt; | 76 | Addressee::List::ConstIterator mIt; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | AddressBook::Iterator::Iterator() | 79 | AddressBook::Iterator::Iterator() |
80 | { | 80 | { |
81 | d = new IteratorData; | 81 | d = new IteratorData; |
82 | } | 82 | } |
83 | 83 | ||
84 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 84 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
85 | { | 85 | { |
86 | d = new IteratorData; | 86 | d = new IteratorData; |
87 | d->mIt = i.d->mIt; | 87 | d->mIt = i.d->mIt; |
88 | } | 88 | } |
89 | 89 | ||
90 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 90 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
91 | { | 91 | { |
92 | if( this == &i ) return *this; // guard against self assignment | 92 | if( this == &i ) return *this; // guard against self assignment |
93 | delete d; // delete the old data the Iterator was completely constructed before | 93 | delete d; // delete the old data the Iterator was completely constructed before |
94 | d = new IteratorData; | 94 | d = new IteratorData; |
95 | d->mIt = i.d->mIt; | 95 | d->mIt = i.d->mIt; |
96 | return *this; | 96 | return *this; |
97 | } | 97 | } |
98 | 98 | ||
99 | AddressBook::Iterator::~Iterator() | 99 | AddressBook::Iterator::~Iterator() |
100 | { | 100 | { |
101 | delete d; | 101 | delete d; |
102 | } | 102 | } |
103 | 103 | ||
104 | const Addressee &AddressBook::Iterator::operator*() const | 104 | const Addressee &AddressBook::Iterator::operator*() const |
105 | { | 105 | { |
106 | return *(d->mIt); | 106 | return *(d->mIt); |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee &AddressBook::Iterator::operator*() | 109 | Addressee &AddressBook::Iterator::operator*() |
110 | { | 110 | { |
111 | return *(d->mIt); | 111 | return *(d->mIt); |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee *AddressBook::Iterator::operator->() | 114 | Addressee *AddressBook::Iterator::operator->() |
115 | { | 115 | { |
116 | return &(*(d->mIt)); | 116 | return &(*(d->mIt)); |
117 | } | 117 | } |
118 | 118 | ||
119 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 119 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
120 | { | 120 | { |
121 | (d->mIt)++; | 121 | (d->mIt)++; |
122 | return *this; | 122 | return *this; |
123 | } | 123 | } |
124 | 124 | ||
125 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 125 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
126 | { | 126 | { |
127 | (d->mIt)++; | 127 | (d->mIt)++; |
128 | return *this; | 128 | return *this; |
129 | } | 129 | } |
130 | 130 | ||
131 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 131 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
132 | { | 132 | { |
133 | (d->mIt)--; | 133 | (d->mIt)--; |
134 | return *this; | 134 | return *this; |
135 | } | 135 | } |
136 | 136 | ||
137 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 137 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
138 | { | 138 | { |
139 | (d->mIt)--; | 139 | (d->mIt)--; |
140 | return *this; | 140 | return *this; |
141 | } | 141 | } |
142 | 142 | ||
143 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 143 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
144 | { | 144 | { |
145 | return ( d->mIt == it.d->mIt ); | 145 | return ( d->mIt == it.d->mIt ); |
146 | } | 146 | } |
147 | 147 | ||
148 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 148 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
149 | { | 149 | { |
150 | return ( d->mIt != it.d->mIt ); | 150 | return ( d->mIt != it.d->mIt ); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | AddressBook::ConstIterator::ConstIterator() | 154 | AddressBook::ConstIterator::ConstIterator() |
155 | { | 155 | { |
156 | d = new ConstIteratorData; | 156 | d = new ConstIteratorData; |
157 | } | 157 | } |
158 | 158 | ||
159 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 159 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
160 | { | 160 | { |
161 | d = new ConstIteratorData; | 161 | d = new ConstIteratorData; |
162 | d->mIt = i.d->mIt; | 162 | d->mIt = i.d->mIt; |
163 | } | 163 | } |
164 | 164 | ||
165 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 165 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
166 | { | 166 | { |
167 | if( this == &i ) return *this; // guard for self assignment | 167 | if( this == &i ) return *this; // guard for self assignment |
168 | delete d; // delete the old data because the Iterator was really constructed before | 168 | delete d; // delete the old data because the Iterator was really constructed before |
169 | d = new ConstIteratorData; | 169 | d = new ConstIteratorData; |
170 | d->mIt = i.d->mIt; | 170 | d->mIt = i.d->mIt; |
171 | return *this; | 171 | return *this; |
172 | } | 172 | } |
173 | 173 | ||
174 | AddressBook::ConstIterator::~ConstIterator() | 174 | AddressBook::ConstIterator::~ConstIterator() |
175 | { | 175 | { |
176 | delete d; | 176 | delete d; |
177 | } | 177 | } |
178 | 178 | ||
179 | const Addressee &AddressBook::ConstIterator::operator*() const | 179 | const Addressee &AddressBook::ConstIterator::operator*() const |
180 | { | 180 | { |
181 | return *(d->mIt); | 181 | return *(d->mIt); |
182 | } | 182 | } |
183 | 183 | ||
184 | const Addressee* AddressBook::ConstIterator::operator->() const | 184 | const Addressee* AddressBook::ConstIterator::operator->() const |
185 | { | 185 | { |
186 | return &(*(d->mIt)); | 186 | return &(*(d->mIt)); |
187 | } | 187 | } |
188 | 188 | ||
189 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 189 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
190 | { | 190 | { |
191 | (d->mIt)++; | 191 | (d->mIt)++; |
192 | return *this; | 192 | return *this; |
193 | } | 193 | } |
194 | 194 | ||
195 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 195 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
196 | { | 196 | { |
197 | (d->mIt)++; | 197 | (d->mIt)++; |
198 | return *this; | 198 | return *this; |
199 | } | 199 | } |
200 | 200 | ||
201 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 201 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
202 | { | 202 | { |
203 | (d->mIt)--; | 203 | (d->mIt)--; |
204 | return *this; | 204 | return *this; |
205 | } | 205 | } |
206 | 206 | ||
207 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 207 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
208 | { | 208 | { |
209 | (d->mIt)--; | 209 | (d->mIt)--; |
210 | return *this; | 210 | return *this; |
211 | } | 211 | } |
212 | 212 | ||
213 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 213 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
214 | { | 214 | { |
215 | return ( d->mIt == it.d->mIt ); | 215 | return ( d->mIt == it.d->mIt ); |
216 | } | 216 | } |
217 | 217 | ||
218 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 218 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
219 | { | 219 | { |
220 | return ( d->mIt != it.d->mIt ); | 220 | return ( d->mIt != it.d->mIt ); |
221 | } | 221 | } |
222 | 222 | ||
223 | 223 | ||
224 | AddressBook::AddressBook() | 224 | AddressBook::AddressBook() |
225 | { | 225 | { |
226 | init(0, "contact"); | 226 | init(0, "contact"); |
227 | } | 227 | } |
228 | 228 | ||
229 | AddressBook::AddressBook( const QString &config ) | 229 | AddressBook::AddressBook( const QString &config ) |
230 | { | 230 | { |
231 | init(config, "contact"); | 231 | init(config, "contact"); |
232 | } | 232 | } |
233 | 233 | ||
234 | AddressBook::AddressBook( const QString &config, const QString &family ) | 234 | AddressBook::AddressBook( const QString &config, const QString &family ) |
235 | { | 235 | { |
236 | init(config, family); | 236 | init(config, family); |
237 | 237 | ||
238 | } | 238 | } |
239 | 239 | ||
240 | // the default family is "contact" | 240 | // the default family is "contact" |
241 | void AddressBook::init(const QString &config, const QString &family ) | 241 | void AddressBook::init(const QString &config, const QString &family ) |
242 | { | 242 | { |
243 | blockLSEchange = false; | 243 | blockLSEchange = false; |
244 | d = new AddressBookData; | 244 | d = new AddressBookData; |
245 | QString fami = family; | 245 | QString fami = family; |
246 | if (config != 0) { | 246 | if (config != 0) { |
247 | if ( family == "syncContact" ) { | 247 | if ( family == "syncContact" ) { |
248 | qDebug("creating sync config "); | 248 | qDebug("creating sync config "); |
249 | fami = "contact"; | 249 | fami = "contact"; |
250 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 250 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
251 | con->setGroup( "General" ); | 251 | con->setGroup( "General" ); |
252 | con->writeEntry( "ResourceKeys", QString("sync") ); | 252 | con->writeEntry( "ResourceKeys", QString("sync") ); |
253 | con->writeEntry( "Standard", QString("sync") ); | 253 | con->writeEntry( "Standard", QString("sync") ); |
254 | con->setGroup( "Resource_sync" ); | 254 | con->setGroup( "Resource_sync" ); |
255 | con->writeEntry( "FileName", config ); | 255 | con->writeEntry( "FileName", config ); |
256 | con->writeEntry( "FileFormat", QString("vcard") ); | 256 | con->writeEntry( "FileFormat", QString("vcard") ); |
257 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 257 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
258 | con->writeEntry( "ResourceName", QString("sync_res") ); | 258 | con->writeEntry( "ResourceName", QString("sync_res") ); |
259 | if ( config.right(4) == ".xml" ) | 259 | if ( config.right(4) == ".xml" ) |
260 | con->writeEntry( "ResourceType", QString("qtopia") ); | 260 | con->writeEntry( "ResourceType", QString("qtopia") ); |
261 | else if ( config == "sharp" ) { | 261 | else if ( config == "sharp" ) { |
262 | con->writeEntry( "ResourceType", QString("sharp") ); | 262 | con->writeEntry( "ResourceType", QString("sharp") ); |
263 | } else { | 263 | } else { |
264 | con->writeEntry( "ResourceType", QString("file") ); | 264 | con->writeEntry( "ResourceType", QString("file") ); |
265 | } | 265 | } |
266 | //con->sync(); | 266 | //con->sync(); |
267 | d->mConfig = con; | 267 | d->mConfig = con; |
268 | } | 268 | } |
269 | else | 269 | else |
270 | d->mConfig = new KConfig( locateLocal("config", config) ); | 270 | d->mConfig = new KConfig( locateLocal("config", config) ); |
271 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 271 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
272 | } | 272 | } |
273 | else { | 273 | else { |
274 | d->mConfig = 0; | 274 | d->mConfig = 0; |
275 | // qDebug("AddressBook::init 1 config=0"); | 275 | // qDebug("AddressBook::init 1 config=0"); |
276 | } | 276 | } |
277 | 277 | ||
278 | //US d->mErrorHandler = 0; | 278 | //US d->mErrorHandler = 0; |
279 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 279 | d->mManager = new KRES::Manager<Resource>( fami, false ); |
280 | d->mManager->readConfig( d->mConfig ); | 280 | d->mManager->readConfig( d->mConfig ); |
281 | if ( family == "syncContact" ) { | 281 | if ( family == "syncContact" ) { |
282 | KRES::Manager<Resource> *manager = d->mManager; | 282 | KRES::Manager<Resource> *manager = d->mManager; |
283 | KRES::Manager<Resource>::ActiveIterator it; | 283 | KRES::Manager<Resource>::ActiveIterator it; |
284 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 284 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
285 | (*it)->setAddressBook( this ); | 285 | (*it)->setAddressBook( this ); |
286 | if ( !(*it)->open() ) | 286 | if ( !(*it)->open() ) |
287 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 287 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
288 | } | 288 | } |
289 | Resource *res = standardResource(); | 289 | Resource *res = standardResource(); |
290 | if ( !res ) { | 290 | if ( !res ) { |
291 | qDebug("ERROR: no standard resource"); | 291 | qDebug("ERROR: no standard resource"); |
292 | res = manager->createResource( "file" ); | 292 | res = manager->createResource( "file" ); |
293 | if ( res ) | 293 | if ( res ) |
294 | { | 294 | { |
295 | addResource( res ); | 295 | addResource( res ); |
296 | } | 296 | } |
297 | else | 297 | else |
298 | qDebug(" No resource available!!!"); | 298 | qDebug(" No resource available!!!"); |
299 | } | 299 | } |
300 | setStandardResource( res ); | 300 | setStandardResource( res ); |
301 | manager->writeConfig(); | 301 | manager->writeConfig(); |
302 | } | 302 | } |
303 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 303 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
304 | "X-Department", "KADDRESSBOOK" ); | 304 | "X-Department", "KADDRESSBOOK" ); |
305 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 305 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
306 | "X-Profession", "KADDRESSBOOK" ); | 306 | "X-Profession", "KADDRESSBOOK" ); |
307 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 307 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
308 | "X-AssistantsName", "KADDRESSBOOK" ); | 308 | "X-AssistantsName", "KADDRESSBOOK" ); |
309 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 309 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
310 | "X-ManagersName", "KADDRESSBOOK" ); | 310 | "X-ManagersName", "KADDRESSBOOK" ); |
311 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 311 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
312 | "X-SpousesName", "KADDRESSBOOK" ); | 312 | "X-SpousesName", "KADDRESSBOOK" ); |
313 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 313 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
314 | "X-Office", "KADDRESSBOOK" ); | 314 | "X-Office", "KADDRESSBOOK" ); |
315 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 315 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
316 | "X-IMAddress", "KADDRESSBOOK" ); | 316 | "X-IMAddress", "KADDRESSBOOK" ); |
317 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 317 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
318 | "X-Anniversary", "KADDRESSBOOK" ); | 318 | "X-Anniversary", "KADDRESSBOOK" ); |
319 | 319 | ||
320 | //US added this field to become compatible with Opie/qtopia addressbook | 320 | //US added this field to become compatible with Opie/qtopia addressbook |
321 | // values can be "female" or "male" or "". An empty field represents undefined. | 321 | // values can be "female" or "male" or "". An empty field represents undefined. |
322 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 322 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
323 | "X-Gender", "KADDRESSBOOK" ); | 323 | "X-Gender", "KADDRESSBOOK" ); |
324 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 324 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
325 | "X-Children", "KADDRESSBOOK" ); | 325 | "X-Children", "KADDRESSBOOK" ); |
326 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 326 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
327 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 327 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
328 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 328 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
329 | "X-ExternalID", "KADDRESSBOOK" ); | 329 | "X-ExternalID", "KADDRESSBOOK" ); |
330 | } | 330 | } |
331 | 331 | ||
332 | AddressBook::~AddressBook() | 332 | AddressBook::~AddressBook() |
333 | { | 333 | { |
334 | delete d->mConfig; d->mConfig = 0; | 334 | delete d->mConfig; d->mConfig = 0; |
335 | delete d->mManager; d->mManager = 0; | 335 | delete d->mManager; d->mManager = 0; |
336 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 336 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
337 | delete d; d = 0; | 337 | delete d; d = 0; |
338 | } | 338 | } |
339 | 339 | ||
340 | bool AddressBook::load() | 340 | bool AddressBook::load() |
341 | { | 341 | { |
342 | 342 | ||
343 | 343 | ||
344 | clear(); | 344 | clear(); |
345 | 345 | ||
346 | KRES::Manager<Resource>::ActiveIterator it; | 346 | KRES::Manager<Resource>::ActiveIterator it; |
347 | bool ok = true; | 347 | bool ok = true; |
348 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 348 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
349 | if ( !(*it)->load() ) { | 349 | if ( !(*it)->load() ) { |
350 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 350 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
351 | ok = false; | 351 | ok = false; |
352 | } | 352 | } |
353 | 353 | ||
354 | // mark all addressees as unchanged | 354 | // mark all addressees as unchanged |
355 | Addressee::List::Iterator addrIt; | 355 | Addressee::List::Iterator addrIt; |
356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
357 | (*addrIt).setChanged( false ); | 357 | (*addrIt).setChanged( false ); |
358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
359 | if ( !id.isEmpty() ) { | 359 | if ( !id.isEmpty() ) { |
360 | //qDebug("setId aa %s ", id.latin1()); | 360 | //qDebug("setId aa %s ", id.latin1()); |
361 | (*addrIt).setIDStr(id ); | 361 | (*addrIt).setIDStr(id ); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | blockLSEchange = true; | 364 | blockLSEchange = true; |
365 | return ok; | 365 | return ok; |
366 | } | 366 | } |
367 | 367 | ||
368 | bool AddressBook::save( Ticket *ticket ) | 368 | bool AddressBook::save( Ticket *ticket ) |
369 | { | 369 | { |
370 | kdDebug(5700) << "AddressBook::save()"<< endl; | 370 | kdDebug(5700) << "AddressBook::save()"<< endl; |
371 | 371 | ||
372 | if ( ticket->resource() ) { | 372 | if ( ticket->resource() ) { |
373 | deleteRemovedAddressees(); | 373 | deleteRemovedAddressees(); |
374 | return ticket->resource()->save( ticket ); | 374 | return ticket->resource()->save( ticket ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return false; | 377 | return false; |
378 | } | 378 | } |
379 | void AddressBook::export2File( QString fileName ) | 379 | void AddressBook::export2File( QString fileName ) |
380 | { | 380 | { |
381 | 381 | ||
382 | QFile outFile( fileName ); | 382 | QFile outFile( fileName ); |
383 | if ( !outFile.open( IO_WriteOnly ) ) { | 383 | if ( !outFile.open( IO_WriteOnly ) ) { |
384 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 384 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
385 | KMessageBox::error( 0, text.arg( fileName ) ); | 385 | KMessageBox::error( 0, text.arg( fileName ) ); |
386 | return ; | 386 | return ; |
387 | } | 387 | } |
388 | QTextStream t( &outFile ); | 388 | QTextStream t( &outFile ); |
389 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 389 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
390 | Iterator it; | 390 | Iterator it; |
391 | KABC::VCardConverter::Version version; | 391 | KABC::VCardConverter::Version version; |
392 | version = KABC::VCardConverter::v3_0; | 392 | version = KABC::VCardConverter::v3_0; |
393 | for ( it = begin(); it != end(); ++it ) { | 393 | for ( it = begin(); it != end(); ++it ) { |
394 | if ( !(*it).IDStr().isEmpty() ) { | 394 | if ( !(*it).IDStr().isEmpty() ) { |
395 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 395 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
396 | } | 396 | } |
397 | KABC::VCardConverter converter; | 397 | KABC::VCardConverter converter; |
398 | QString vcard; | 398 | QString vcard; |
399 | //Resource *resource() const; | 399 | //Resource *resource() const; |
400 | converter.addresseeToVCard( *it, vcard, version ); | 400 | converter.addresseeToVCard( *it, vcard, version ); |
401 | t << vcard << "\r\n"; | 401 | t << vcard << "\r\n"; |
402 | } | 402 | } |
403 | t << "\r\n\r\n"; | 403 | t << "\r\n\r\n"; |
404 | outFile.close(); | 404 | outFile.close(); |
405 | } | 405 | } |
406 | void AddressBook::importFromFile( QString fileName, bool replaceLabel ) | 406 | void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) |
407 | { | 407 | { |
408 | 408 | ||
409 | KABC::Addressee::List list; | 409 | if ( removeOld ) |
410 | QFile file( fileName ); | 410 | setUntagged(); |
411 | 411 | KABC::Addressee::List list; | |
412 | file.open( IO_ReadOnly ); | 412 | QFile file( fileName ); |
413 | QByteArray rawData = file.readAll(); | 413 | file.open( IO_ReadOnly ); |
414 | file.close(); | 414 | QByteArray rawData = file.readAll(); |
415 | QString data; | 415 | file.close(); |
416 | if ( replaceLabel ) { | 416 | QString data; |
417 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 417 | if ( replaceLabel ) { |
418 | data.replace ( QRegExp("LABEL") , "ADR" ); | 418 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
419 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 419 | data.replace ( QRegExp("LABEL") , "ADR" ); |
420 | } else | 420 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
421 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 421 | } else |
422 | KABC::VCardTool tool; | 422 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
423 | list = tool.parseVCards( data ); | 423 | KABC::VCardTool tool; |
424 | KABC::Addressee::List::Iterator it; | 424 | list = tool.parseVCards( data ); |
425 | for ( it = list.begin(); it != list.end(); ++it ) { | 425 | KABC::Addressee::List::Iterator it; |
426 | (*it).setResource( 0 ); | 426 | for ( it = list.begin(); it != list.end(); ++it ) { |
427 | if ( replaceLabel ) | 427 | (*it).setResource( 0 ); |
428 | (*it).removeVoice(); | 428 | if ( replaceLabel ) |
429 | insertAddressee( (*it), false, true ); | 429 | (*it).removeVoice(); |
430 | if ( removeOld ) | ||
431 | (*it).setTagged( true ); | ||
432 | insertAddressee( (*it), false, true ); | ||
433 | } | ||
434 | if ( removeOld ) | ||
435 | removeUntagged(); | ||
436 | } | ||
437 | void AddressBook::setUntagged() | ||
438 | { | ||
439 | Iterator ait; | ||
440 | for ( ait = begin(); ait != end(); ++ait ) { | ||
441 | (*ait).setTagged( false ); | ||
442 | } | ||
443 | } | ||
444 | void AddressBook::removeUntagged() | ||
445 | { | ||
446 | Iterator ait; | ||
447 | for ( ait = begin(); ait != end(); ++ait ) { | ||
448 | if (!(*ait).tagged()) | ||
449 | removeAddressee( ait ); | ||
430 | } | 450 | } |
431 | 451 | ||
452 | deleteRemovedAddressees(); | ||
432 | } | 453 | } |
433 | |||
434 | bool AddressBook::saveAB() | 454 | bool AddressBook::saveAB() |
435 | { | 455 | { |
436 | bool ok = true; | 456 | bool ok = true; |
437 | 457 | ||
438 | deleteRemovedAddressees(); | 458 | deleteRemovedAddressees(); |
439 | Iterator ait; | 459 | Iterator ait; |
440 | for ( ait = begin(); ait != end(); ++ait ) { | 460 | for ( ait = begin(); ait != end(); ++ait ) { |
441 | if ( !(*ait).IDStr().isEmpty() ) { | 461 | if ( !(*ait).IDStr().isEmpty() ) { |
442 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 462 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
443 | } | 463 | } |
444 | } | 464 | } |
445 | KRES::Manager<Resource>::ActiveIterator it; | 465 | KRES::Manager<Resource>::ActiveIterator it; |
446 | KRES::Manager<Resource> *manager = d->mManager; | 466 | KRES::Manager<Resource> *manager = d->mManager; |
447 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 467 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
448 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 468 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
449 | Ticket *ticket = requestSaveTicket( *it ); | 469 | Ticket *ticket = requestSaveTicket( *it ); |
450 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 470 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
451 | if ( !ticket ) { | 471 | if ( !ticket ) { |
452 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 472 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
453 | .arg( (*it)->resourceName() ) ); | 473 | .arg( (*it)->resourceName() ) ); |
454 | return false; | 474 | return false; |
455 | } | 475 | } |
456 | 476 | ||
457 | //if ( !save( ticket ) ) | 477 | //if ( !save( ticket ) ) |
458 | if ( ticket->resource() ) { | 478 | if ( ticket->resource() ) { |
459 | if ( ! ticket->resource()->save( ticket ) ) | 479 | if ( ! ticket->resource()->save( ticket ) ) |
460 | ok = false; | 480 | ok = false; |
461 | } else | 481 | } else |
462 | ok = false; | 482 | ok = false; |
463 | 483 | ||
464 | } | 484 | } |
465 | } | 485 | } |
466 | return ok; | 486 | return ok; |
467 | } | 487 | } |
468 | 488 | ||
469 | AddressBook::Iterator AddressBook::begin() | 489 | AddressBook::Iterator AddressBook::begin() |
470 | { | 490 | { |
471 | Iterator it = Iterator(); | 491 | Iterator it = Iterator(); |
472 | it.d->mIt = d->mAddressees.begin(); | 492 | it.d->mIt = d->mAddressees.begin(); |
473 | return it; | 493 | return it; |
474 | } | 494 | } |
475 | 495 | ||
476 | AddressBook::ConstIterator AddressBook::begin() const | 496 | AddressBook::ConstIterator AddressBook::begin() const |
477 | { | 497 | { |
478 | ConstIterator it = ConstIterator(); | 498 | ConstIterator it = ConstIterator(); |
479 | it.d->mIt = d->mAddressees.begin(); | 499 | it.d->mIt = d->mAddressees.begin(); |
480 | return it; | 500 | return it; |
481 | } | 501 | } |
482 | 502 | ||
483 | AddressBook::Iterator AddressBook::end() | 503 | AddressBook::Iterator AddressBook::end() |
484 | { | 504 | { |
485 | Iterator it = Iterator(); | 505 | Iterator it = Iterator(); |
486 | it.d->mIt = d->mAddressees.end(); | 506 | it.d->mIt = d->mAddressees.end(); |
487 | return it; | 507 | return it; |
488 | } | 508 | } |
489 | 509 | ||
490 | AddressBook::ConstIterator AddressBook::end() const | 510 | AddressBook::ConstIterator AddressBook::end() const |
491 | { | 511 | { |
492 | ConstIterator it = ConstIterator(); | 512 | ConstIterator it = ConstIterator(); |
493 | it.d->mIt = d->mAddressees.end(); | 513 | it.d->mIt = d->mAddressees.end(); |
494 | return it; | 514 | return it; |
495 | } | 515 | } |
496 | 516 | ||
497 | void AddressBook::clear() | 517 | void AddressBook::clear() |
498 | { | 518 | { |
499 | d->mAddressees.clear(); | 519 | d->mAddressees.clear(); |
500 | } | 520 | } |
501 | 521 | ||
502 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 522 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
503 | { | 523 | { |
504 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 524 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
505 | 525 | ||
506 | if ( !resource ) | 526 | if ( !resource ) |
507 | { | 527 | { |
508 | qDebug("AddressBook::requestSaveTicket no resource" ); | 528 | qDebug("AddressBook::requestSaveTicket no resource" ); |
509 | resource = standardResource(); | 529 | resource = standardResource(); |
510 | } | 530 | } |
511 | 531 | ||
512 | KRES::Manager<Resource>::ActiveIterator it; | 532 | KRES::Manager<Resource>::ActiveIterator it; |
513 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 533 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
514 | if ( (*it) == resource ) { | 534 | if ( (*it) == resource ) { |
515 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 535 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
516 | return 0; | 536 | return 0; |
517 | else | 537 | else |
518 | return (*it)->requestSaveTicket(); | 538 | return (*it)->requestSaveTicket(); |
519 | } | 539 | } |
520 | } | 540 | } |
521 | 541 | ||
522 | return 0; | 542 | return 0; |
523 | } | 543 | } |
524 | 544 | ||
525 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 545 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) |
526 | { | 546 | { |
527 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 547 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
528 | //qDebug("block insert "); | 548 | //qDebug("block insert "); |
529 | return; | 549 | return; |
530 | } | 550 | } |
531 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 551 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
532 | bool found = false; | 552 | bool found = false; |
533 | Addressee::List::Iterator it; | 553 | Addressee::List::Iterator it; |
534 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 554 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
535 | if ( a.uid() == (*it).uid() ) { | 555 | if ( a.uid() == (*it).uid() ) { |
536 | 556 | ||
537 | bool changed = false; | 557 | bool changed = false; |
538 | Addressee addr = a; | 558 | Addressee addr = a; |
539 | if ( addr != (*it) ) | 559 | if ( addr != (*it) ) |
540 | changed = true; | 560 | changed = true; |
541 | 561 | ||
542 | if ( takeResource ) { | 562 | if ( takeResource ) { |
543 | Resource * res = (*it).resource(); | 563 | Resource * res = (*it).resource(); |
544 | (*it) = a; | 564 | (*it) = a; |
545 | (*it).setResource( res ); | 565 | (*it).setResource( res ); |
546 | } else { | 566 | } else { |
547 | (*it) = a; | 567 | (*it) = a; |
548 | if ( (*it).resource() == 0 ) | 568 | if ( (*it).resource() == 0 ) |
549 | (*it).setResource( standardResource() ); | 569 | (*it).setResource( standardResource() ); |
550 | } | 570 | } |
551 | if ( changed ) { | 571 | if ( changed ) { |
552 | if ( setRev ) { | 572 | if ( setRev ) { |
553 | 573 | ||
554 | // get rid of micro seconds | 574 | // get rid of micro seconds |
555 | QDateTime dt = QDateTime::currentDateTime(); | 575 | QDateTime dt = QDateTime::currentDateTime(); |
556 | QTime t = dt.time(); | 576 | QTime t = dt.time(); |
557 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 577 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
558 | (*it).setRevision( dt ); | 578 | (*it).setRevision( dt ); |
559 | } | 579 | } |
560 | (*it).setChanged( true ); | 580 | (*it).setChanged( true ); |
561 | } | 581 | } |
562 | 582 | ||
563 | found = true; | 583 | found = true; |
564 | } else { | 584 | } else { |
565 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 585 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
566 | QString name = (*it).uid().mid( 19 ); | 586 | QString name = (*it).uid().mid( 19 ); |
567 | Addressee b = a; | 587 | Addressee b = a; |
568 | QString id = b.getID( name ); | 588 | QString id = b.getID( name ); |
569 | if ( ! id.isEmpty() ) { | 589 | if ( ! id.isEmpty() ) { |
570 | QString des = (*it).note(); | 590 | QString des = (*it).note(); |
571 | int startN; | 591 | int startN; |
572 | if( (startN = des.find( id ) ) >= 0 ) { | 592 | if( (startN = des.find( id ) ) >= 0 ) { |
573 | int endN = des.find( ",", startN+1 ); | 593 | int endN = des.find( ",", startN+1 ); |
574 | des = des.left( startN ) + des.mid( endN+1 ); | 594 | des = des.left( startN ) + des.mid( endN+1 ); |
575 | (*it).setNote( des ); | 595 | (*it).setNote( des ); |
576 | } | 596 | } |
577 | } | 597 | } |
578 | } | 598 | } |
579 | } | 599 | } |
580 | } | 600 | } |
581 | if ( found ) | 601 | if ( found ) |
582 | return; | 602 | return; |
583 | d->mAddressees.append( a ); | 603 | d->mAddressees.append( a ); |
584 | Addressee& addr = d->mAddressees.last(); | 604 | Addressee& addr = d->mAddressees.last(); |
585 | if ( addr.resource() == 0 ) | 605 | if ( addr.resource() == 0 ) |
586 | addr.setResource( standardResource() ); | 606 | addr.setResource( standardResource() ); |
587 | 607 | ||
588 | addr.setChanged( true ); | 608 | addr.setChanged( true ); |
589 | } | 609 | } |
590 | 610 | ||
591 | void AddressBook::removeAddressee( const Addressee &a ) | 611 | void AddressBook::removeAddressee( const Addressee &a ) |
592 | { | 612 | { |
593 | Iterator it; | 613 | Iterator it; |
594 | Iterator it2; | 614 | Iterator it2; |
595 | bool found = false; | 615 | bool found = false; |
596 | for ( it = begin(); it != end(); ++it ) { | 616 | for ( it = begin(); it != end(); ++it ) { |
597 | if ( a.uid() == (*it).uid() ) { | 617 | if ( a.uid() == (*it).uid() ) { |
598 | found = true; | 618 | found = true; |
599 | it2 = it; | 619 | it2 = it; |
600 | } else { | 620 | } else { |
601 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 621 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
602 | QString name = (*it).uid().mid( 19 ); | 622 | QString name = (*it).uid().mid( 19 ); |
603 | Addressee b = a; | 623 | Addressee b = a; |
604 | QString id = b.getID( name ); | 624 | QString id = b.getID( name ); |
605 | if ( ! id.isEmpty() ) { | 625 | if ( ! id.isEmpty() ) { |
606 | QString des = (*it).note(); | 626 | QString des = (*it).note(); |
607 | if( des.find( id ) < 0 ) { | 627 | if( des.find( id ) < 0 ) { |
608 | des += id + ","; | 628 | des += id + ","; |
609 | (*it).setNote( des ); | 629 | (*it).setNote( des ); |
610 | } | 630 | } |
611 | } | 631 | } |
612 | } | 632 | } |
613 | 633 | ||
614 | } | 634 | } |
615 | } | 635 | } |
616 | 636 | ||
617 | if ( found ) | 637 | if ( found ) |
618 | removeAddressee( it2 ); | 638 | removeAddressee( it2 ); |
619 | 639 | ||
620 | } | 640 | } |
621 | 641 | ||
622 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 642 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
623 | { | 643 | { |
624 | Iterator it = begin(); | 644 | Iterator it = begin(); |
625 | Iterator it2 ; | 645 | Iterator it2 ; |
626 | QDateTime dt ( QDate( 2004,1,1) ); | 646 | QDateTime dt ( QDate( 2004,1,1) ); |
627 | while ( it != end() ) { | 647 | while ( it != end() ) { |
628 | (*it).setRevision( dt ); | 648 | (*it).setRevision( dt ); |
629 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 649 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
630 | (*it).setIDStr(""); | 650 | (*it).setIDStr(""); |
631 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 651 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
632 | it2 = it; | 652 | it2 = it; |
633 | //qDebug("removing %s ",(*it).uid().latin1() ); | 653 | //qDebug("removing %s ",(*it).uid().latin1() ); |
634 | ++it; | 654 | ++it; |
635 | removeAddressee( it2 ); | 655 | removeAddressee( it2 ); |
636 | } else { | 656 | } else { |
637 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 657 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
638 | ++it; | 658 | ++it; |
639 | } | 659 | } |
640 | } | 660 | } |
641 | deleteRemovedAddressees(); | 661 | deleteRemovedAddressees(); |
642 | } | 662 | } |
643 | 663 | ||
644 | void AddressBook::removeAddressee( const Iterator &it ) | 664 | void AddressBook::removeAddressee( const Iterator &it ) |
645 | { | 665 | { |
646 | d->mRemovedAddressees.append( (*it) ); | 666 | d->mRemovedAddressees.append( (*it) ); |
647 | d->mAddressees.remove( it.d->mIt ); | 667 | d->mAddressees.remove( it.d->mIt ); |
648 | } | 668 | } |
649 | 669 | ||
650 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 670 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
651 | { | 671 | { |
652 | Iterator it; | 672 | Iterator it; |
653 | for ( it = begin(); it != end(); ++it ) { | 673 | for ( it = begin(); it != end(); ++it ) { |
654 | if ( a.uid() == (*it).uid() ) { | 674 | if ( a.uid() == (*it).uid() ) { |
655 | return it; | 675 | return it; |
656 | } | 676 | } |
657 | } | 677 | } |
658 | return end(); | 678 | return end(); |
659 | } | 679 | } |
660 | 680 | ||
661 | Addressee AddressBook::findByUid( const QString &uid ) | 681 | Addressee AddressBook::findByUid( const QString &uid ) |
662 | { | 682 | { |
663 | Iterator it; | 683 | Iterator it; |
664 | for ( it = begin(); it != end(); ++it ) { | 684 | for ( it = begin(); it != end(); ++it ) { |
665 | if ( uid == (*it).uid() ) { | 685 | if ( uid == (*it).uid() ) { |
666 | return *it; | 686 | return *it; |
667 | } | 687 | } |
668 | } | 688 | } |
669 | return Addressee(); | 689 | return Addressee(); |
670 | } | 690 | } |
671 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) | 691 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) |
672 | { | 692 | { |
673 | //qDebug("AddressBook::preExternSync "); | 693 | //qDebug("AddressBook::preExternSync "); |
674 | AddressBook::Iterator it; | 694 | AddressBook::Iterator it; |
675 | for ( it = begin(); it != end(); ++it ) { | 695 | for ( it = begin(); it != end(); ++it ) { |
676 | (*it).setID( csd, (*it).externalUID() ); | 696 | (*it).setID( csd, (*it).externalUID() ); |
677 | (*it).computeCsum( csd ); | 697 | (*it).computeCsum( csd ); |
678 | } | 698 | } |
679 | mergeAB( aBook ,csd ); | 699 | mergeAB( aBook ,csd ); |
680 | } | 700 | } |
681 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 701 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) |
682 | { | 702 | { |
683 | //qDebug("AddressBook::postExternSync "); | 703 | //qDebug("AddressBook::postExternSync "); |
684 | AddressBook::Iterator it; | 704 | AddressBook::Iterator it; |
685 | for ( it = begin(); it != end(); ++it ) { | 705 | for ( it = begin(); it != end(); ++it ) { |
686 | // qDebug("check uid %s ", (*it).uid().latin1() ); | 706 | // qDebug("check uid %s ", (*it).uid().latin1() ); |
687 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 707 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
688 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 708 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { |
689 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 709 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
690 | if ( ad.isEmpty() ) { | 710 | if ( ad.isEmpty() ) { |
691 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 711 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
692 | } else { | 712 | } else { |
693 | (*it).computeCsum( csd ); | 713 | (*it).computeCsum( csd ); |
694 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 714 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
695 | ad.setID( csd, (*it).externalUID() ); | 715 | ad.setID( csd, (*it).externalUID() ); |
696 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 716 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
697 | aBook->insertAddressee( ad ); | 717 | aBook->insertAddressee( ad ); |
698 | } | 718 | } |
699 | } | 719 | } |
700 | } | 720 | } |
701 | } | 721 | } |
702 | 722 | ||
703 | bool AddressBook::containsExternalUid( const QString& uid ) | 723 | bool AddressBook::containsExternalUid( const QString& uid ) |
704 | { | 724 | { |
705 | Iterator it; | 725 | Iterator it; |
706 | for ( it = begin(); it != end(); ++it ) { | 726 | for ( it = begin(); it != end(); ++it ) { |
707 | if ( uid == (*it).externalUID( ) ) | 727 | if ( uid == (*it).externalUID( ) ) |
708 | return true; | 728 | return true; |
709 | } | 729 | } |
710 | return false; | 730 | return false; |
711 | } | 731 | } |
712 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 732 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) |
713 | { | 733 | { |
714 | Iterator it; | 734 | Iterator it; |
715 | for ( it = begin(); it != end(); ++it ) { | 735 | for ( it = begin(); it != end(); ++it ) { |
716 | if ( uid == (*it).getID( profile ) ) | 736 | if ( uid == (*it).getID( profile ) ) |
717 | return (*it); | 737 | return (*it); |
718 | } | 738 | } |
719 | return Addressee(); | 739 | return Addressee(); |
720 | } | 740 | } |
721 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) | 741 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) |
722 | { | 742 | { |
723 | Iterator it; | 743 | Iterator it; |
724 | Addressee ad; | 744 | Addressee ad; |
725 | for ( it = begin(); it != end(); ++it ) { | 745 | for ( it = begin(); it != end(); ++it ) { |
726 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 746 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
727 | if ( !ad.isEmpty() ) { | 747 | if ( !ad.isEmpty() ) { |
728 | (*it).mergeContact( ad ); | 748 | (*it).mergeContact( ad ); |
729 | } | 749 | } |
730 | } | 750 | } |
731 | #if 0 | 751 | #if 0 |
732 | // test only | 752 | // test only |
733 | for ( it = begin(); it != end(); ++it ) { | 753 | for ( it = begin(); it != end(); ++it ) { |
734 | 754 | ||
735 | qDebug("uid %s ", (*it).uid().latin1()); | 755 | qDebug("uid %s ", (*it).uid().latin1()); |
736 | } | 756 | } |
737 | #endif | 757 | #endif |
738 | } | 758 | } |
739 | 759 | ||
740 | #if 0 | 760 | #if 0 |
741 | Addressee::List AddressBook::getExternLastSyncAddressees() | 761 | Addressee::List AddressBook::getExternLastSyncAddressees() |
742 | { | 762 | { |
743 | Addressee::List results; | 763 | Addressee::List results; |
744 | 764 | ||
745 | Iterator it; | 765 | Iterator it; |
746 | for ( it = begin(); it != end(); ++it ) { | 766 | for ( it = begin(); it != end(); ++it ) { |
747 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 767 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
748 | if ( (*it).familyName().left(4) == "!E: " ) | 768 | if ( (*it).familyName().left(4) == "!E: " ) |
749 | results.append( *it ); | 769 | results.append( *it ); |
750 | } | 770 | } |
751 | } | 771 | } |
752 | 772 | ||
753 | return results; | 773 | return results; |
754 | } | 774 | } |
755 | #endif | 775 | #endif |
756 | void AddressBook::resetTempSyncStat() | 776 | void AddressBook::resetTempSyncStat() |
757 | { | 777 | { |
758 | Iterator it; | 778 | Iterator it; |
759 | for ( it = begin(); it != end(); ++it ) { | 779 | for ( it = begin(); it != end(); ++it ) { |
760 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 780 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
761 | } | 781 | } |
762 | 782 | ||
763 | } | 783 | } |
764 | 784 | ||
765 | QStringList AddressBook:: uidList() | 785 | QStringList AddressBook:: uidList() |
766 | { | 786 | { |
767 | QStringList results; | 787 | QStringList results; |
768 | Iterator it; | 788 | Iterator it; |
769 | for ( it = begin(); it != end(); ++it ) { | 789 | for ( it = begin(); it != end(); ++it ) { |
770 | results.append( (*it).uid() ); | 790 | results.append( (*it).uid() ); |
771 | } | 791 | } |
772 | return results; | 792 | return results; |
773 | } | 793 | } |
774 | 794 | ||
775 | 795 | ||
776 | Addressee::List AddressBook::allAddressees() | 796 | Addressee::List AddressBook::allAddressees() |
777 | { | 797 | { |
778 | return d->mAddressees; | 798 | return d->mAddressees; |
779 | 799 | ||
780 | } | 800 | } |
781 | 801 | ||
782 | Addressee::List AddressBook::findByName( const QString &name ) | 802 | Addressee::List AddressBook::findByName( const QString &name ) |
783 | { | 803 | { |
784 | Addressee::List results; | 804 | Addressee::List results; |
785 | 805 | ||
786 | Iterator it; | 806 | Iterator it; |
787 | for ( it = begin(); it != end(); ++it ) { | 807 | for ( it = begin(); it != end(); ++it ) { |
788 | if ( name == (*it).realName() ) { | 808 | if ( name == (*it).realName() ) { |
789 | results.append( *it ); | 809 | results.append( *it ); |
790 | } | 810 | } |
791 | } | 811 | } |
792 | 812 | ||
793 | return results; | 813 | return results; |
794 | } | 814 | } |
795 | 815 | ||
796 | Addressee::List AddressBook::findByEmail( const QString &email ) | 816 | Addressee::List AddressBook::findByEmail( const QString &email ) |
797 | { | 817 | { |
798 | Addressee::List results; | 818 | Addressee::List results; |
799 | QStringList mailList; | 819 | QStringList mailList; |
800 | 820 | ||
801 | Iterator it; | 821 | Iterator it; |
802 | for ( it = begin(); it != end(); ++it ) { | 822 | for ( it = begin(); it != end(); ++it ) { |
803 | mailList = (*it).emails(); | 823 | mailList = (*it).emails(); |
804 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 824 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
805 | if ( email == (*ite) ) { | 825 | if ( email == (*ite) ) { |
806 | results.append( *it ); | 826 | results.append( *it ); |
807 | } | 827 | } |
808 | } | 828 | } |
809 | } | 829 | } |
810 | 830 | ||
811 | return results; | 831 | return results; |
812 | } | 832 | } |
813 | 833 | ||
814 | Addressee::List AddressBook::findByCategory( const QString &category ) | 834 | Addressee::List AddressBook::findByCategory( const QString &category ) |
815 | { | 835 | { |
816 | Addressee::List results; | 836 | Addressee::List results; |
817 | 837 | ||
818 | Iterator it; | 838 | Iterator it; |
819 | for ( it = begin(); it != end(); ++it ) { | 839 | for ( it = begin(); it != end(); ++it ) { |
820 | if ( (*it).hasCategory( category) ) { | 840 | if ( (*it).hasCategory( category) ) { |
821 | results.append( *it ); | 841 | results.append( *it ); |
822 | } | 842 | } |
823 | } | 843 | } |
824 | 844 | ||
825 | return results; | 845 | return results; |
826 | } | 846 | } |
827 | 847 | ||
828 | void AddressBook::dump() const | 848 | void AddressBook::dump() const |
829 | { | 849 | { |
830 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 850 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
831 | 851 | ||
832 | ConstIterator it; | 852 | ConstIterator it; |
833 | for( it = begin(); it != end(); ++it ) { | 853 | for( it = begin(); it != end(); ++it ) { |
834 | (*it).dump(); | 854 | (*it).dump(); |
835 | } | 855 | } |
836 | 856 | ||
837 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 857 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
838 | } | 858 | } |
839 | 859 | ||
840 | QString AddressBook::identifier() | 860 | QString AddressBook::identifier() |
841 | { | 861 | { |
842 | QStringList identifier; | 862 | QStringList identifier; |
843 | 863 | ||
844 | 864 | ||
845 | KRES::Manager<Resource>::ActiveIterator it; | 865 | KRES::Manager<Resource>::ActiveIterator it; |
846 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 866 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
847 | if ( !(*it)->identifier().isEmpty() ) | 867 | if ( !(*it)->identifier().isEmpty() ) |
848 | identifier.append( (*it)->identifier() ); | 868 | identifier.append( (*it)->identifier() ); |
849 | } | 869 | } |
850 | 870 | ||
851 | return identifier.join( ":" ); | 871 | return identifier.join( ":" ); |
852 | } | 872 | } |
853 | 873 | ||
854 | Field::List AddressBook::fields( int category ) | 874 | Field::List AddressBook::fields( int category ) |
855 | { | 875 | { |
856 | if ( d->mAllFields.isEmpty() ) { | 876 | if ( d->mAllFields.isEmpty() ) { |
857 | d->mAllFields = Field::allFields(); | 877 | d->mAllFields = Field::allFields(); |
858 | } | 878 | } |
859 | 879 | ||
860 | if ( category == Field::All ) return d->mAllFields; | 880 | if ( category == Field::All ) return d->mAllFields; |
861 | 881 | ||
862 | Field::List result; | 882 | Field::List result; |
863 | Field::List::ConstIterator it; | 883 | Field::List::ConstIterator it; |
864 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 884 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
865 | if ( (*it)->category() & category ) result.append( *it ); | 885 | if ( (*it)->category() & category ) result.append( *it ); |
866 | } | 886 | } |
867 | 887 | ||
868 | return result; | 888 | return result; |
869 | } | 889 | } |
870 | 890 | ||
871 | bool AddressBook::addCustomField( const QString &label, int category, | 891 | bool AddressBook::addCustomField( const QString &label, int category, |
872 | const QString &key, const QString &app ) | 892 | const QString &key, const QString &app ) |
873 | { | 893 | { |
874 | if ( d->mAllFields.isEmpty() ) { | 894 | if ( d->mAllFields.isEmpty() ) { |
875 | d->mAllFields = Field::allFields(); | 895 | d->mAllFields = Field::allFields(); |
876 | } | 896 | } |
877 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 897 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
878 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 898 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
879 | 899 | ||
880 | QString k = key.isNull() ? label : key; | 900 | QString k = key.isNull() ? label : key; |
881 | 901 | ||
882 | Field *field = Field::createCustomField( label, category, k, a ); | 902 | Field *field = Field::createCustomField( label, category, k, a ); |
883 | 903 | ||
884 | if ( !field ) return false; | 904 | if ( !field ) return false; |
885 | 905 | ||
886 | d->mAllFields.append( field ); | 906 | d->mAllFields.append( field ); |
887 | 907 | ||
888 | return true; | 908 | return true; |
889 | } | 909 | } |
890 | 910 | ||
891 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 911 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
892 | { | 912 | { |
893 | if (!ab.d) return s; | 913 | if (!ab.d) return s; |
894 | 914 | ||
895 | return s << ab.d->mAddressees; | 915 | return s << ab.d->mAddressees; |
896 | } | 916 | } |
897 | 917 | ||
898 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 918 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
899 | { | 919 | { |
900 | if (!ab.d) return s; | 920 | if (!ab.d) return s; |
901 | 921 | ||
902 | s >> ab.d->mAddressees; | 922 | s >> ab.d->mAddressees; |
903 | 923 | ||
904 | return s; | 924 | return s; |
905 | } | 925 | } |
906 | 926 | ||
907 | bool AddressBook::addResource( Resource *resource ) | 927 | bool AddressBook::addResource( Resource *resource ) |
908 | { | 928 | { |
909 | if ( !resource->open() ) { | 929 | if ( !resource->open() ) { |
910 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 930 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
911 | return false; | 931 | return false; |
912 | } | 932 | } |
913 | 933 | ||
914 | resource->setAddressBook( this ); | 934 | resource->setAddressBook( this ); |
915 | 935 | ||
916 | d->mManager->add( resource ); | 936 | d->mManager->add( resource ); |
917 | return true; | 937 | return true; |
918 | } | 938 | } |
919 | 939 | ||
920 | bool AddressBook::removeResource( Resource *resource ) | 940 | bool AddressBook::removeResource( Resource *resource ) |
921 | { | 941 | { |
922 | resource->close(); | 942 | resource->close(); |
923 | 943 | ||
924 | if ( resource == standardResource() ) | 944 | if ( resource == standardResource() ) |
925 | d->mManager->setStandardResource( 0 ); | 945 | d->mManager->setStandardResource( 0 ); |
926 | 946 | ||
927 | resource->setAddressBook( 0 ); | 947 | resource->setAddressBook( 0 ); |
928 | 948 | ||
929 | d->mManager->remove( resource ); | 949 | d->mManager->remove( resource ); |
930 | return true; | 950 | return true; |
931 | } | 951 | } |
932 | 952 | ||
933 | QPtrList<Resource> AddressBook::resources() | 953 | QPtrList<Resource> AddressBook::resources() |
934 | { | 954 | { |
935 | QPtrList<Resource> list; | 955 | QPtrList<Resource> list; |
936 | 956 | ||
937 | // qDebug("AddressBook::resources() 1"); | 957 | // qDebug("AddressBook::resources() 1"); |
938 | 958 | ||
939 | KRES::Manager<Resource>::ActiveIterator it; | 959 | KRES::Manager<Resource>::ActiveIterator it; |
940 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 960 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
941 | list.append( *it ); | 961 | list.append( *it ); |
942 | 962 | ||
943 | return list; | 963 | return list; |
944 | } | 964 | } |
945 | 965 | ||
946 | /*US | 966 | /*US |
947 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 967 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
948 | { | 968 | { |
949 | delete d->mErrorHandler; | 969 | delete d->mErrorHandler; |
950 | d->mErrorHandler = handler; | 970 | d->mErrorHandler = handler; |
951 | } | 971 | } |
952 | */ | 972 | */ |
953 | 973 | ||
954 | void AddressBook::error( const QString& msg ) | 974 | void AddressBook::error( const QString& msg ) |
955 | { | 975 | { |
956 | /*US | 976 | /*US |
957 | if ( !d->mErrorHandler ) // create default error handler | 977 | if ( !d->mErrorHandler ) // create default error handler |
958 | d->mErrorHandler = new ConsoleErrorHandler; | 978 | d->mErrorHandler = new ConsoleErrorHandler; |
959 | 979 | ||
960 | if ( d->mErrorHandler ) | 980 | if ( d->mErrorHandler ) |
961 | d->mErrorHandler->error( msg ); | 981 | d->mErrorHandler->error( msg ); |
962 | else | 982 | else |
963 | kdError(5700) << "no error handler defined" << endl; | 983 | kdError(5700) << "no error handler defined" << endl; |
964 | */ | 984 | */ |
965 | kdDebug(5700) << "msg" << endl; | 985 | kdDebug(5700) << "msg" << endl; |
966 | qDebug(msg); | 986 | qDebug(msg); |
967 | } | 987 | } |
968 | 988 | ||
969 | void AddressBook::deleteRemovedAddressees() | 989 | void AddressBook::deleteRemovedAddressees() |
970 | { | 990 | { |
971 | Addressee::List::Iterator it; | 991 | Addressee::List::Iterator it; |
972 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 992 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
973 | Resource *resource = (*it).resource(); | 993 | Resource *resource = (*it).resource(); |
974 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 994 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
975 | resource->removeAddressee( *it ); | 995 | resource->removeAddressee( *it ); |
976 | } | 996 | } |
977 | 997 | ||
978 | d->mRemovedAddressees.clear(); | 998 | d->mRemovedAddressees.clear(); |
979 | } | 999 | } |
980 | 1000 | ||
981 | void AddressBook::setStandardResource( Resource *resource ) | 1001 | void AddressBook::setStandardResource( Resource *resource ) |
982 | { | 1002 | { |
983 | // qDebug("AddressBook::setStandardResource 1"); | 1003 | // qDebug("AddressBook::setStandardResource 1"); |
984 | d->mManager->setStandardResource( resource ); | 1004 | d->mManager->setStandardResource( resource ); |
985 | } | 1005 | } |
986 | 1006 | ||
987 | Resource *AddressBook::standardResource() | 1007 | Resource *AddressBook::standardResource() |
988 | { | 1008 | { |
989 | return d->mManager->standardResource(); | 1009 | return d->mManager->standardResource(); |
990 | } | 1010 | } |
991 | 1011 | ||
992 | KRES::Manager<Resource> *AddressBook::resourceManager() | 1012 | KRES::Manager<Resource> *AddressBook::resourceManager() |
993 | { | 1013 | { |
994 | return d->mManager; | 1014 | return d->mManager; |
995 | } | 1015 | } |
996 | 1016 | ||
997 | void AddressBook::cleanUp() | 1017 | void AddressBook::cleanUp() |
998 | { | 1018 | { |
999 | KRES::Manager<Resource>::ActiveIterator it; | 1019 | KRES::Manager<Resource>::ActiveIterator it; |
1000 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1020 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1001 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 1021 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
1002 | (*it)->cleanUp(); | 1022 | (*it)->cleanUp(); |
1003 | } | 1023 | } |
1004 | } | 1024 | } |