summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
authorzautrix <zautrix>2004-10-07 20:35:03 (UTC)
committer zautrix <zautrix>2004-10-07 20:35:03 (UTC)
commit4a01915314201cbe2461ce68cdf9c556c687d727 (patch) (unidiff)
treefda84b84c84231de98a91f0aff38a744a092cab2 /kabc/addressbook.cpp
parent0a661f5800b86df385cc23f4c9a8324bd0b50a5c (diff)
downloadkdepimpi-4a01915314201cbe2461ce68cdf9c556c687d727.zip
kdepimpi-4a01915314201cbe2461ce68cdf9c556c687d727.tar.gz
kdepimpi-4a01915314201cbe2461ce68cdf9c556c687d727.tar.bz2
compile fix
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 03a86f9..ed5e9c2 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,813 +1,813 @@
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/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (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 43
44#include <kglobal.h> 44#include <kglobal.h>
45#include <klocale.h>> 45#include <klocale.h>
46#include <kmessagebox.h> 46#include <kmessagebox.h>
47#include <kdebug.h> 47#include <kdebug.h>
48#include <libkcal/syncdefines.h> 48#include <libkcal/syncdefines.h>
49#include "addressbook.h" 49#include "addressbook.h"
50#include "resource.h" 50#include "resource.h"
51#include "vcardconverter.h" 51#include "vcardconverter.h"
52#include "vcardparser/vcardtool.h" 52#include "vcardparser/vcardtool.h"
53 53
54//US #include "addressbook.moc" 54//US #include "addressbook.moc"
55 55
56using namespace KABC; 56using namespace KABC;
57 57
58struct AddressBook::AddressBookData 58struct AddressBook::AddressBookData
59{ 59{
60 Addressee::List mAddressees; 60 Addressee::List mAddressees;
61 Addressee::List mRemovedAddressees; 61 Addressee::List mRemovedAddressees;
62 Field::List mAllFields; 62 Field::List mAllFields;
63 KConfig *mConfig; 63 KConfig *mConfig;
64 KRES::Manager<Resource> *mManager; 64 KRES::Manager<Resource> *mManager;
65//US ErrorHandler *mErrorHandler; 65//US ErrorHandler *mErrorHandler;
66}; 66};
67 67
68struct AddressBook::Iterator::IteratorData 68struct AddressBook::Iterator::IteratorData
69{ 69{
70 Addressee::List::Iterator mIt; 70 Addressee::List::Iterator mIt;
71}; 71};
72 72
73struct AddressBook::ConstIterator::ConstIteratorData 73struct AddressBook::ConstIterator::ConstIteratorData
74{ 74{
75 Addressee::List::ConstIterator mIt; 75 Addressee::List::ConstIterator mIt;
76}; 76};
77 77
78AddressBook::Iterator::Iterator() 78AddressBook::Iterator::Iterator()
79{ 79{
80 d = new IteratorData; 80 d = new IteratorData;
81} 81}
82 82
83AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 83AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
84{ 84{
85 d = new IteratorData; 85 d = new IteratorData;
86 d->mIt = i.d->mIt; 86 d->mIt = i.d->mIt;
87} 87}
88 88
89AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 89AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
90{ 90{
91 if( this == &i ) return *this; // guard against self assignment 91 if( this == &i ) return *this; // guard against self assignment
92 delete d; // delete the old data the Iterator was completely constructed before 92 delete d; // delete the old data the Iterator was completely constructed before
93 d = new IteratorData; 93 d = new IteratorData;
94 d->mIt = i.d->mIt; 94 d->mIt = i.d->mIt;
95 return *this; 95 return *this;
96} 96}
97 97
98AddressBook::Iterator::~Iterator() 98AddressBook::Iterator::~Iterator()
99{ 99{
100 delete d; 100 delete d;
101} 101}
102 102
103const Addressee &AddressBook::Iterator::operator*() const 103const Addressee &AddressBook::Iterator::operator*() const
104{ 104{
105 return *(d->mIt); 105 return *(d->mIt);
106} 106}
107 107
108Addressee &AddressBook::Iterator::operator*() 108Addressee &AddressBook::Iterator::operator*()
109{ 109{
110 return *(d->mIt); 110 return *(d->mIt);
111} 111}
112 112
113Addressee *AddressBook::Iterator::operator->() 113Addressee *AddressBook::Iterator::operator->()
114{ 114{
115 return &(*(d->mIt)); 115 return &(*(d->mIt));
116} 116}
117 117
118AddressBook::Iterator &AddressBook::Iterator::operator++() 118AddressBook::Iterator &AddressBook::Iterator::operator++()
119{ 119{
120 (d->mIt)++; 120 (d->mIt)++;
121 return *this; 121 return *this;
122} 122}
123 123
124AddressBook::Iterator &AddressBook::Iterator::operator++(int) 124AddressBook::Iterator &AddressBook::Iterator::operator++(int)
125{ 125{
126 (d->mIt)++; 126 (d->mIt)++;
127 return *this; 127 return *this;
128} 128}
129 129
130AddressBook::Iterator &AddressBook::Iterator::operator--() 130AddressBook::Iterator &AddressBook::Iterator::operator--()
131{ 131{
132 (d->mIt)--; 132 (d->mIt)--;
133 return *this; 133 return *this;
134} 134}
135 135
136AddressBook::Iterator &AddressBook::Iterator::operator--(int) 136AddressBook::Iterator &AddressBook::Iterator::operator--(int)
137{ 137{
138 (d->mIt)--; 138 (d->mIt)--;
139 return *this; 139 return *this;
140} 140}
141 141
142bool AddressBook::Iterator::operator==( const Iterator &it ) 142bool AddressBook::Iterator::operator==( const Iterator &it )
143{ 143{
144 return ( d->mIt == it.d->mIt ); 144 return ( d->mIt == it.d->mIt );
145} 145}
146 146
147bool AddressBook::Iterator::operator!=( const Iterator &it ) 147bool AddressBook::Iterator::operator!=( const Iterator &it )
148{ 148{
149 return ( d->mIt != it.d->mIt ); 149 return ( d->mIt != it.d->mIt );
150} 150}
151 151
152 152
153AddressBook::ConstIterator::ConstIterator() 153AddressBook::ConstIterator::ConstIterator()
154{ 154{
155 d = new ConstIteratorData; 155 d = new ConstIteratorData;
156} 156}
157 157
158AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 158AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
159{ 159{
160 d = new ConstIteratorData; 160 d = new ConstIteratorData;
161 d->mIt = i.d->mIt; 161 d->mIt = i.d->mIt;
162} 162}
163 163
164AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 164AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
165{ 165{
166 if( this == &i ) return *this; // guard for self assignment 166 if( this == &i ) return *this; // guard for self assignment
167 delete d; // delete the old data because the Iterator was really constructed before 167 delete d; // delete the old data because the Iterator was really constructed before
168 d = new ConstIteratorData; 168 d = new ConstIteratorData;
169 d->mIt = i.d->mIt; 169 d->mIt = i.d->mIt;
170 return *this; 170 return *this;
171} 171}
172 172
173AddressBook::ConstIterator::~ConstIterator() 173AddressBook::ConstIterator::~ConstIterator()
174{ 174{
175 delete d; 175 delete d;
176} 176}
177 177
178const Addressee &AddressBook::ConstIterator::operator*() const 178const Addressee &AddressBook::ConstIterator::operator*() const
179{ 179{
180 return *(d->mIt); 180 return *(d->mIt);
181} 181}
182 182
183const Addressee* AddressBook::ConstIterator::operator->() const 183const Addressee* AddressBook::ConstIterator::operator->() const
184{ 184{
185 return &(*(d->mIt)); 185 return &(*(d->mIt));
186} 186}
187 187
188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
189{ 189{
190 (d->mIt)++; 190 (d->mIt)++;
191 return *this; 191 return *this;
192} 192}
193 193
194AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 194AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
195{ 195{
196 (d->mIt)++; 196 (d->mIt)++;
197 return *this; 197 return *this;
198} 198}
199 199
200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
201{ 201{
202 (d->mIt)--; 202 (d->mIt)--;
203 return *this; 203 return *this;
204} 204}
205 205
206AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 206AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
207{ 207{
208 (d->mIt)--; 208 (d->mIt)--;
209 return *this; 209 return *this;
210} 210}
211 211
212bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 212bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
213{ 213{
214 return ( d->mIt == it.d->mIt ); 214 return ( d->mIt == it.d->mIt );
215} 215}
216 216
217bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 217bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
218{ 218{
219 return ( d->mIt != it.d->mIt ); 219 return ( d->mIt != it.d->mIt );
220} 220}
221 221
222 222
223AddressBook::AddressBook() 223AddressBook::AddressBook()
224{ 224{
225 init(0, "contact"); 225 init(0, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config ) 228AddressBook::AddressBook( const QString &config )
229{ 229{
230 init(config, "contact"); 230 init(config, "contact");
231} 231}
232 232
233AddressBook::AddressBook( const QString &config, const QString &family ) 233AddressBook::AddressBook( const QString &config, const QString &family )
234{ 234{
235 init(config, family); 235 init(config, family);
236 236
237} 237}
238 238
239// the default family is "contact" 239// the default family is "contact"
240void AddressBook::init(const QString &config, const QString &family ) 240void AddressBook::init(const QString &config, const QString &family )
241{ 241{
242 blockLSEchange = false; 242 blockLSEchange = false;
243 d = new AddressBookData; 243 d = new AddressBookData;
244 QString fami = family; 244 QString fami = family;
245 if (config != 0) { 245 if (config != 0) {
246 if ( family == "syncContact" ) { 246 if ( family == "syncContact" ) {
247 qDebug("creating sync config "); 247 qDebug("creating sync config ");
248 fami = "contact"; 248 fami = "contact";
249 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 249 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
250 con->setGroup( "General" ); 250 con->setGroup( "General" );
251 con->writeEntry( "ResourceKeys", QString("sync") ); 251 con->writeEntry( "ResourceKeys", QString("sync") );
252 con->writeEntry( "Standard", QString("sync") ); 252 con->writeEntry( "Standard", QString("sync") );
253 con->setGroup( "Resource_sync" ); 253 con->setGroup( "Resource_sync" );
254 con->writeEntry( "FileName", config ); 254 con->writeEntry( "FileName", config );
255 con->writeEntry( "FileFormat", QString("vcard") ); 255 con->writeEntry( "FileFormat", QString("vcard") );
256 con->writeEntry( "ResourceIdentifier", QString("sync") ); 256 con->writeEntry( "ResourceIdentifier", QString("sync") );
257 con->writeEntry( "ResourceName", QString("sync_res") ); 257 con->writeEntry( "ResourceName", QString("sync_res") );
258 if ( config.right(4) == ".xml" ) 258 if ( config.right(4) == ".xml" )
259 con->writeEntry( "ResourceType", QString("qtopia") ); 259 con->writeEntry( "ResourceType", QString("qtopia") );
260 else if ( config == "sharp" ) { 260 else if ( config == "sharp" ) {
261 con->writeEntry( "ResourceType", QString("sharp") ); 261 con->writeEntry( "ResourceType", QString("sharp") );
262 } else { 262 } else {
263 con->writeEntry( "ResourceType", QString("file") ); 263 con->writeEntry( "ResourceType", QString("file") );
264 } 264 }
265 //con->sync(); 265 //con->sync();
266 d->mConfig = con; 266 d->mConfig = con;
267 } 267 }
268 else 268 else
269 d->mConfig = new KConfig( locateLocal("config", config) ); 269 d->mConfig = new KConfig( locateLocal("config", config) );
270// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 270// qDebug("AddressBook::init 1 config=%s",config.latin1() );
271 } 271 }
272 else { 272 else {
273 d->mConfig = 0; 273 d->mConfig = 0;
274// qDebug("AddressBook::init 1 config=0"); 274// qDebug("AddressBook::init 1 config=0");
275 } 275 }
276 276
277//US d->mErrorHandler = 0; 277//US d->mErrorHandler = 0;
278 d->mManager = new KRES::Manager<Resource>( fami, false ); 278 d->mManager = new KRES::Manager<Resource>( fami, false );
279 d->mManager->readConfig( d->mConfig ); 279 d->mManager->readConfig( d->mConfig );
280 if ( family == "syncContact" ) { 280 if ( family == "syncContact" ) {
281 KRES::Manager<Resource> *manager = d->mManager; 281 KRES::Manager<Resource> *manager = d->mManager;
282 KRES::Manager<Resource>::ActiveIterator it; 282 KRES::Manager<Resource>::ActiveIterator it;
283 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 283 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
284 (*it)->setAddressBook( this ); 284 (*it)->setAddressBook( this );
285 if ( !(*it)->open() ) 285 if ( !(*it)->open() )
286 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 286 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
287 } 287 }
288 Resource *res = standardResource(); 288 Resource *res = standardResource();
289 if ( !res ) { 289 if ( !res ) {
290 qDebug("ERROR: no standard resource"); 290 qDebug("ERROR: no standard resource");
291 res = manager->createResource( "file" ); 291 res = manager->createResource( "file" );
292 if ( res ) 292 if ( res )
293 { 293 {
294 addResource( res ); 294 addResource( res );
295 } 295 }
296 else 296 else
297 qDebug(" No resource available!!!"); 297 qDebug(" No resource available!!!");
298 } 298 }
299 setStandardResource( res ); 299 setStandardResource( res );
300 manager->writeConfig(); 300 manager->writeConfig();
301 } 301 }
302 addCustomField( i18n( "Department" ), KABC::Field::Organization, 302 addCustomField( i18n( "Department" ), KABC::Field::Organization,
303 "X-Department", "KADDRESSBOOK" ); 303 "X-Department", "KADDRESSBOOK" );
304 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 304 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
305 "X-Profession", "KADDRESSBOOK" ); 305 "X-Profession", "KADDRESSBOOK" );
306 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 306 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
307 "X-AssistantsName", "KADDRESSBOOK" ); 307 "X-AssistantsName", "KADDRESSBOOK" );
308 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 308 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
309 "X-ManagersName", "KADDRESSBOOK" ); 309 "X-ManagersName", "KADDRESSBOOK" );
310 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 310 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
311 "X-SpousesName", "KADDRESSBOOK" ); 311 "X-SpousesName", "KADDRESSBOOK" );
312 addCustomField( i18n( "Office" ), KABC::Field::Personal, 312 addCustomField( i18n( "Office" ), KABC::Field::Personal,
313 "X-Office", "KADDRESSBOOK" ); 313 "X-Office", "KADDRESSBOOK" );
314 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 314 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
315 "X-IMAddress", "KADDRESSBOOK" ); 315 "X-IMAddress", "KADDRESSBOOK" );
316 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 316 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
317 "X-Anniversary", "KADDRESSBOOK" ); 317 "X-Anniversary", "KADDRESSBOOK" );
318 318
319 //US added this field to become compatible with Opie/qtopia addressbook 319 //US added this field to become compatible with Opie/qtopia addressbook
320 // values can be "female" or "male" or "". An empty field represents undefined. 320 // values can be "female" or "male" or "". An empty field represents undefined.
321 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 321 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
322 "X-Gender", "KADDRESSBOOK" ); 322 "X-Gender", "KADDRESSBOOK" );
323 addCustomField( i18n( "Children" ), KABC::Field::Personal, 323 addCustomField( i18n( "Children" ), KABC::Field::Personal,
324 "X-Children", "KADDRESSBOOK" ); 324 "X-Children", "KADDRESSBOOK" );
325 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 325 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
326 "X-FreeBusyUrl", "KADDRESSBOOK" ); 326 "X-FreeBusyUrl", "KADDRESSBOOK" );
327 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 327 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
328 "X-ExternalID", "KADDRESSBOOK" ); 328 "X-ExternalID", "KADDRESSBOOK" );
329} 329}
330 330
331AddressBook::~AddressBook() 331AddressBook::~AddressBook()
332{ 332{
333 delete d->mConfig; d->mConfig = 0; 333 delete d->mConfig; d->mConfig = 0;
334 delete d->mManager; d->mManager = 0; 334 delete d->mManager; d->mManager = 0;
335//US delete d->mErrorHandler; d->mErrorHandler = 0; 335//US delete d->mErrorHandler; d->mErrorHandler = 0;
336 delete d; d = 0; 336 delete d; d = 0;
337} 337}
338 338
339bool AddressBook::load() 339bool AddressBook::load()
340{ 340{
341 341
342 342
343 clear(); 343 clear();
344 344
345 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
346 bool ok = true; 346 bool ok = true;
347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
348 if ( !(*it)->load() ) { 348 if ( !(*it)->load() ) {
349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
350 ok = false; 350 ok = false;
351 } 351 }
352 352
353 // mark all addressees as unchanged 353 // mark all addressees as unchanged
354 Addressee::List::Iterator addrIt; 354 Addressee::List::Iterator addrIt;
355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
356 (*addrIt).setChanged( false ); 356 (*addrIt).setChanged( false );
357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
358 if ( !id.isEmpty() ) { 358 if ( !id.isEmpty() ) {
359 //qDebug("setId aa %s ", id.latin1()); 359 //qDebug("setId aa %s ", id.latin1());
360 (*addrIt).setIDStr(id ); 360 (*addrIt).setIDStr(id );
361 } 361 }
362 } 362 }
363 blockLSEchange = true; 363 blockLSEchange = true;
364 return ok; 364 return ok;
365} 365}
366 366
367bool AddressBook::save( Ticket *ticket ) 367bool AddressBook::save( Ticket *ticket )
368{ 368{
369 kdDebug(5700) << "AddressBook::save()"<< endl; 369 kdDebug(5700) << "AddressBook::save()"<< endl;
370 370
371 if ( ticket->resource() ) { 371 if ( ticket->resource() ) {
372 deleteRemovedAddressees(); 372 deleteRemovedAddressees();
373 return ticket->resource()->save( ticket ); 373 return ticket->resource()->save( ticket );
374 } 374 }
375 375
376 return false; 376 return false;
377} 377}
378void AddressBook::export2File( QString fileName ) 378void AddressBook::export2File( QString fileName )
379{ 379{
380 380
381 QFile outFile( fileName ); 381 QFile outFile( fileName );
382 if ( !outFile.open( IO_WriteOnly ) ) { 382 if ( !outFile.open( IO_WriteOnly ) ) {
383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
384 KMessageBox::error( 0, text.arg( fileName ) ); 384 KMessageBox::error( 0, text.arg( fileName ) );
385 return ; 385 return ;
386 } 386 }
387 QTextStream t( &outFile ); 387 QTextStream t( &outFile );
388 t.setEncoding( QTextStream::UnicodeUTF8 ); 388 t.setEncoding( QTextStream::UnicodeUTF8 );
389 Iterator it; 389 Iterator it;
390 KABC::VCardConverter::Version version; 390 KABC::VCardConverter::Version version;
391 version = KABC::VCardConverter::v3_0; 391 version = KABC::VCardConverter::v3_0;
392 for ( it = begin(); it != end(); ++it ) { 392 for ( it = begin(); it != end(); ++it ) {
393 if ( !(*it).IDStr().isEmpty() ) { 393 if ( !(*it).IDStr().isEmpty() ) {
394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
395 } 395 }
396 KABC::VCardConverter converter; 396 KABC::VCardConverter converter;
397 QString vcard; 397 QString vcard;
398 //Resource *resource() const; 398 //Resource *resource() const;
399 converter.addresseeToVCard( *it, vcard, version ); 399 converter.addresseeToVCard( *it, vcard, version );
400 t << vcard << "\r\n"; 400 t << vcard << "\r\n";
401 } 401 }
402 outFile.close(); 402 outFile.close();
403} 403}
404void AddressBook::importFromFile( QString fileName ) 404void AddressBook::importFromFile( QString fileName )
405{ 405{
406 406
407 KABC::Addressee::List list; 407 KABC::Addressee::List list;
408 QFile file( fileName ); 408 QFile file( fileName );
409 409
410 file.open( IO_ReadOnly ); 410 file.open( IO_ReadOnly );
411 QByteArray rawData = file.readAll(); 411 QByteArray rawData = file.readAll();
412 file.close(); 412 file.close();
413 413
414 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 414 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
415 KABC::VCardTool tool; 415 KABC::VCardTool tool;
416 list = tool.parseVCards( data ); 416 list = tool.parseVCards( data );
417 KABC::Addressee::List::Iterator it; 417 KABC::Addressee::List::Iterator it;
418 for ( it = list.begin(); it != list.end(); ++it ) { 418 for ( it = list.begin(); it != list.end(); ++it ) {
419 (*it).setResource( 0 ); 419 (*it).setResource( 0 );
420 insertAddressee( (*it), false, true ); 420 insertAddressee( (*it), false, true );
421 } 421 }
422 422
423} 423}
424 424
425bool AddressBook::saveAB() 425bool AddressBook::saveAB()
426{ 426{
427 bool ok = true; 427 bool ok = true;
428 428
429 deleteRemovedAddressees(); 429 deleteRemovedAddressees();
430 Iterator ait; 430 Iterator ait;
431 for ( ait = begin(); ait != end(); ++ait ) { 431 for ( ait = begin(); ait != end(); ++ait ) {
432 if ( !(*ait).IDStr().isEmpty() ) { 432 if ( !(*ait).IDStr().isEmpty() ) {
433 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 433 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
434 } 434 }
435 } 435 }
436 KRES::Manager<Resource>::ActiveIterator it; 436 KRES::Manager<Resource>::ActiveIterator it;
437 KRES::Manager<Resource> *manager = d->mManager; 437 KRES::Manager<Resource> *manager = d->mManager;
438 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 438 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
439 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 439 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
440 Ticket *ticket = requestSaveTicket( *it ); 440 Ticket *ticket = requestSaveTicket( *it );
441// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 441// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
442 if ( !ticket ) { 442 if ( !ticket ) {
443 error( i18n( "Unable to save to resource '%1'. It is locked." ) 443 error( i18n( "Unable to save to resource '%1'. It is locked." )
444 .arg( (*it)->resourceName() ) ); 444 .arg( (*it)->resourceName() ) );
445 return false; 445 return false;
446 } 446 }
447 447
448 //if ( !save( ticket ) ) 448 //if ( !save( ticket ) )
449 if ( ticket->resource() ) { 449 if ( ticket->resource() ) {
450 if ( ! ticket->resource()->save( ticket ) ) 450 if ( ! ticket->resource()->save( ticket ) )
451 ok = false; 451 ok = false;
452 } else 452 } else
453 ok = false; 453 ok = false;
454 454
455 } 455 }
456 } 456 }
457 return ok; 457 return ok;
458} 458}
459 459
460AddressBook::Iterator AddressBook::begin() 460AddressBook::Iterator AddressBook::begin()
461{ 461{
462 Iterator it = Iterator(); 462 Iterator it = Iterator();
463 it.d->mIt = d->mAddressees.begin(); 463 it.d->mIt = d->mAddressees.begin();
464 return it; 464 return it;
465} 465}
466 466
467AddressBook::ConstIterator AddressBook::begin() const 467AddressBook::ConstIterator AddressBook::begin() const
468{ 468{
469 ConstIterator it = ConstIterator(); 469 ConstIterator it = ConstIterator();
470 it.d->mIt = d->mAddressees.begin(); 470 it.d->mIt = d->mAddressees.begin();
471 return it; 471 return it;
472} 472}
473 473
474AddressBook::Iterator AddressBook::end() 474AddressBook::Iterator AddressBook::end()
475{ 475{
476 Iterator it = Iterator(); 476 Iterator it = Iterator();
477 it.d->mIt = d->mAddressees.end(); 477 it.d->mIt = d->mAddressees.end();
478 return it; 478 return it;
479} 479}
480 480
481AddressBook::ConstIterator AddressBook::end() const 481AddressBook::ConstIterator AddressBook::end() const
482{ 482{
483 ConstIterator it = ConstIterator(); 483 ConstIterator it = ConstIterator();
484 it.d->mIt = d->mAddressees.end(); 484 it.d->mIt = d->mAddressees.end();
485 return it; 485 return it;
486} 486}
487 487
488void AddressBook::clear() 488void AddressBook::clear()
489{ 489{
490 d->mAddressees.clear(); 490 d->mAddressees.clear();
491} 491}
492 492
493Ticket *AddressBook::requestSaveTicket( Resource *resource ) 493Ticket *AddressBook::requestSaveTicket( Resource *resource )
494{ 494{
495 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 495 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
496 496
497 if ( !resource ) 497 if ( !resource )
498 { 498 {
499 qDebug("AddressBook::requestSaveTicket no resource" ); 499 qDebug("AddressBook::requestSaveTicket no resource" );
500 resource = standardResource(); 500 resource = standardResource();
501 } 501 }
502 502
503 KRES::Manager<Resource>::ActiveIterator it; 503 KRES::Manager<Resource>::ActiveIterator it;
504 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 504 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
505 if ( (*it) == resource ) { 505 if ( (*it) == resource ) {
506 if ( (*it)->readOnly() || !(*it)->isOpen() ) 506 if ( (*it)->readOnly() || !(*it)->isOpen() )
507 return 0; 507 return 0;
508 else 508 else
509 return (*it)->requestSaveTicket(); 509 return (*it)->requestSaveTicket();
510 } 510 }
511 } 511 }
512 512
513 return 0; 513 return 0;
514} 514}
515 515
516void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 516void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
517{ 517{
518 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 518 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
519 //qDebug("block insert "); 519 //qDebug("block insert ");
520 return; 520 return;
521 } 521 }
522 //qDebug("inserting.... %s ",a.uid().latin1() ); 522 //qDebug("inserting.... %s ",a.uid().latin1() );
523 bool found = false; 523 bool found = false;
524 Addressee::List::Iterator it; 524 Addressee::List::Iterator it;
525 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 525 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
526 if ( a.uid() == (*it).uid() ) { 526 if ( a.uid() == (*it).uid() ) {
527 527
528 bool changed = false; 528 bool changed = false;
529 Addressee addr = a; 529 Addressee addr = a;
530 if ( addr != (*it) ) 530 if ( addr != (*it) )
531 changed = true; 531 changed = true;
532 532
533 if ( takeResource ) { 533 if ( takeResource ) {
534 Resource * res = (*it).resource(); 534 Resource * res = (*it).resource();
535 (*it) = a; 535 (*it) = a;
536 (*it).setResource( res ); 536 (*it).setResource( res );
537 } else { 537 } else {
538 (*it) = a; 538 (*it) = a;
539 if ( (*it).resource() == 0 ) 539 if ( (*it).resource() == 0 )
540 (*it).setResource( standardResource() ); 540 (*it).setResource( standardResource() );
541 } 541 }
542 if ( changed ) { 542 if ( changed ) {
543 if ( setRev ) { 543 if ( setRev ) {
544 544
545 // get rid of micro seconds 545 // get rid of micro seconds
546 QDateTime dt = QDateTime::currentDateTime(); 546 QDateTime dt = QDateTime::currentDateTime();
547 QTime t = dt.time(); 547 QTime t = dt.time();
548 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 548 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
549 (*it).setRevision( dt ); 549 (*it).setRevision( dt );
550 } 550 }
551 (*it).setChanged( true ); 551 (*it).setChanged( true );
552 } 552 }
553 553
554 found = true; 554 found = true;
555 } else { 555 } else {
556 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 556 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
557 QString name = (*it).uid().mid( 19 ); 557 QString name = (*it).uid().mid( 19 );
558 Addressee b = a; 558 Addressee b = a;
559 QString id = b.getID( name ); 559 QString id = b.getID( name );
560 if ( ! id.isEmpty() ) { 560 if ( ! id.isEmpty() ) {
561 QString des = (*it).note(); 561 QString des = (*it).note();
562 int startN; 562 int startN;
563 if( (startN = des.find( id ) ) >= 0 ) { 563 if( (startN = des.find( id ) ) >= 0 ) {
564 int endN = des.find( ",", startN+1 ); 564 int endN = des.find( ",", startN+1 );
565 des = des.left( startN ) + des.mid( endN+1 ); 565 des = des.left( startN ) + des.mid( endN+1 );
566 (*it).setNote( des ); 566 (*it).setNote( des );
567 } 567 }
568 } 568 }
569 } 569 }
570 } 570 }
571 } 571 }
572 if ( found ) 572 if ( found )
573 return; 573 return;
574 d->mAddressees.append( a ); 574 d->mAddressees.append( a );
575 Addressee& addr = d->mAddressees.last(); 575 Addressee& addr = d->mAddressees.last();
576 if ( addr.resource() == 0 ) 576 if ( addr.resource() == 0 )
577 addr.setResource( standardResource() ); 577 addr.setResource( standardResource() );
578 578
579 addr.setChanged( true ); 579 addr.setChanged( true );
580} 580}
581 581
582void AddressBook::removeAddressee( const Addressee &a ) 582void AddressBook::removeAddressee( const Addressee &a )
583{ 583{
584 Iterator it; 584 Iterator it;
585 Iterator it2; 585 Iterator it2;
586 bool found = false; 586 bool found = false;
587 for ( it = begin(); it != end(); ++it ) { 587 for ( it = begin(); it != end(); ++it ) {
588 if ( a.uid() == (*it).uid() ) { 588 if ( a.uid() == (*it).uid() ) {
589 found = true; 589 found = true;
590 it2 = it; 590 it2 = it;
591 } else { 591 } else {
592 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 592 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
593 QString name = (*it).uid().mid( 19 ); 593 QString name = (*it).uid().mid( 19 );
594 Addressee b = a; 594 Addressee b = a;
595 QString id = b.getID( name ); 595 QString id = b.getID( name );
596 if ( ! id.isEmpty() ) { 596 if ( ! id.isEmpty() ) {
597 QString des = (*it).note(); 597 QString des = (*it).note();
598 if( des.find( id ) < 0 ) { 598 if( des.find( id ) < 0 ) {
599 des += id + ","; 599 des += id + ",";
600 (*it).setNote( des ); 600 (*it).setNote( des );
601 } 601 }
602 } 602 }
603 } 603 }
604 604
605 } 605 }
606 } 606 }
607 607
608 if ( found ) 608 if ( found )
609 removeAddressee( it2 ); 609 removeAddressee( it2 );
610 610
611} 611}
612 612
613void AddressBook::removeSyncAddressees( bool removeDeleted ) 613void AddressBook::removeSyncAddressees( bool removeDeleted )
614{ 614{
615 Iterator it = begin(); 615 Iterator it = begin();
616 Iterator it2 ; 616 Iterator it2 ;
617 QDateTime dt ( QDate( 2004,1,1) ); 617 QDateTime dt ( QDate( 2004,1,1) );
618 while ( it != end() ) { 618 while ( it != end() ) {
619 (*it).setRevision( dt ); 619 (*it).setRevision( dt );
620 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 620 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
621 (*it).setIDStr(""); 621 (*it).setIDStr("");
622 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 622 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
623 it2 = it; 623 it2 = it;
624 //qDebug("removing %s ",(*it).uid().latin1() ); 624 //qDebug("removing %s ",(*it).uid().latin1() );
625 ++it; 625 ++it;
626 removeAddressee( it2 ); 626 removeAddressee( it2 );
627 } else { 627 } else {
628 //qDebug("skipping %s ",(*it).uid().latin1() ); 628 //qDebug("skipping %s ",(*it).uid().latin1() );
629 ++it; 629 ++it;
630 } 630 }
631 } 631 }
632 deleteRemovedAddressees(); 632 deleteRemovedAddressees();
633} 633}
634 634
635void AddressBook::removeAddressee( const Iterator &it ) 635void AddressBook::removeAddressee( const Iterator &it )
636{ 636{
637 d->mRemovedAddressees.append( (*it) ); 637 d->mRemovedAddressees.append( (*it) );
638 d->mAddressees.remove( it.d->mIt ); 638 d->mAddressees.remove( it.d->mIt );
639} 639}
640 640
641AddressBook::Iterator AddressBook::find( const Addressee &a ) 641AddressBook::Iterator AddressBook::find( const Addressee &a )
642{ 642{
643 Iterator it; 643 Iterator it;
644 for ( it = begin(); it != end(); ++it ) { 644 for ( it = begin(); it != end(); ++it ) {
645 if ( a.uid() == (*it).uid() ) { 645 if ( a.uid() == (*it).uid() ) {
646 return it; 646 return it;
647 } 647 }
648 } 648 }
649 return end(); 649 return end();
650} 650}
651 651
652Addressee AddressBook::findByUid( const QString &uid ) 652Addressee AddressBook::findByUid( const QString &uid )
653{ 653{
654 Iterator it; 654 Iterator it;
655 for ( it = begin(); it != end(); ++it ) { 655 for ( it = begin(); it != end(); ++it ) {
656 if ( uid == (*it).uid() ) { 656 if ( uid == (*it).uid() ) {
657 return *it; 657 return *it;
658 } 658 }
659 } 659 }
660 return Addressee(); 660 return Addressee();
661} 661}
662void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) 662void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
663{ 663{
664 //qDebug("AddressBook::preExternSync "); 664 //qDebug("AddressBook::preExternSync ");
665 AddressBook::Iterator it; 665 AddressBook::Iterator it;
666 for ( it = begin(); it != end(); ++it ) { 666 for ( it = begin(); it != end(); ++it ) {
667 (*it).setID( csd, (*it).externalUID() ); 667 (*it).setID( csd, (*it).externalUID() );
668 (*it).computeCsum( csd ); 668 (*it).computeCsum( csd );
669 } 669 }
670 mergeAB( aBook ,csd ); 670 mergeAB( aBook ,csd );
671} 671}
672void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 672void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
673{ 673{
674 //qDebug("AddressBook::postExternSync "); 674 //qDebug("AddressBook::postExternSync ");
675 AddressBook::Iterator it; 675 AddressBook::Iterator it;
676 for ( it = begin(); it != end(); ++it ) { 676 for ( it = begin(); it != end(); ++it ) {
677 // qDebug("check uid %s ", (*it).uid().latin1() ); 677 // qDebug("check uid %s ", (*it).uid().latin1() );
678 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 678 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
679 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 679 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
680 Addressee ad = aBook->findByUid( ( (*it).uid() )); 680 Addressee ad = aBook->findByUid( ( (*it).uid() ));
681 if ( ad.isEmpty() ) { 681 if ( ad.isEmpty() ) {
682 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 682 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
683 } else { 683 } else {
684 (*it).computeCsum( csd ); 684 (*it).computeCsum( csd );
685 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 685 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
686 ad.setID( csd, (*it).externalUID() ); 686 ad.setID( csd, (*it).externalUID() );
687 ad.setCsum( csd, (*it).getCsum( csd ) ); 687 ad.setCsum( csd, (*it).getCsum( csd ) );
688 aBook->insertAddressee( ad ); 688 aBook->insertAddressee( ad );
689 } 689 }
690 } 690 }
691 } 691 }
692} 692}
693 693
694bool AddressBook::containsExternalUid( const QString& uid ) 694bool AddressBook::containsExternalUid( const QString& uid )
695{ 695{
696 Iterator it; 696 Iterator it;
697 for ( it = begin(); it != end(); ++it ) { 697 for ( it = begin(); it != end(); ++it ) {
698 if ( uid == (*it).externalUID( ) ) 698 if ( uid == (*it).externalUID( ) )
699 return true; 699 return true;
700 } 700 }
701 return false; 701 return false;
702} 702}
703Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 703Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
704{ 704{
705 Iterator it; 705 Iterator it;
706 for ( it = begin(); it != end(); ++it ) { 706 for ( it = begin(); it != end(); ++it ) {
707 if ( uid == (*it).getID( profile ) ) 707 if ( uid == (*it).getID( profile ) )
708 return (*it); 708 return (*it);
709 } 709 }
710 return Addressee(); 710 return Addressee();
711} 711}
712void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) 712void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
713{ 713{
714 Iterator it; 714 Iterator it;
715 Addressee ad; 715 Addressee ad;
716 for ( it = begin(); it != end(); ++it ) { 716 for ( it = begin(); it != end(); ++it ) {
717 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 717 ad = aBook->findByExternUid( (*it).externalUID(), profile );
718 if ( !ad.isEmpty() ) { 718 if ( !ad.isEmpty() ) {
719 (*it).mergeContact( ad ); 719 (*it).mergeContact( ad );
720 } 720 }
721 } 721 }
722#if 0 722#if 0
723 // test only 723 // test only
724 for ( it = begin(); it != end(); ++it ) { 724 for ( it = begin(); it != end(); ++it ) {
725 725
726 qDebug("uid %s ", (*it).uid().latin1()); 726 qDebug("uid %s ", (*it).uid().latin1());
727 } 727 }
728#endif 728#endif
729} 729}
730 730
731#if 0 731#if 0
732Addressee::List AddressBook::getExternLastSyncAddressees() 732Addressee::List AddressBook::getExternLastSyncAddressees()
733{ 733{
734 Addressee::List results; 734 Addressee::List results;
735 735
736 Iterator it; 736 Iterator it;
737 for ( it = begin(); it != end(); ++it ) { 737 for ( it = begin(); it != end(); ++it ) {
738 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 738 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
739 if ( (*it).familyName().left(4) == "!E: " ) 739 if ( (*it).familyName().left(4) == "!E: " )
740 results.append( *it ); 740 results.append( *it );
741 } 741 }
742 } 742 }
743 743
744 return results; 744 return results;
745} 745}
746#endif 746#endif
747void AddressBook::resetTempSyncStat() 747void AddressBook::resetTempSyncStat()
748{ 748{
749 Iterator it; 749 Iterator it;
750 for ( it = begin(); it != end(); ++it ) { 750 for ( it = begin(); it != end(); ++it ) {
751 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 751 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
752 } 752 }
753 753
754} 754}
755 755
756QStringList AddressBook:: uidList() 756QStringList AddressBook:: uidList()
757{ 757{
758 QStringList results; 758 QStringList results;
759 Iterator it; 759 Iterator it;
760 for ( it = begin(); it != end(); ++it ) { 760 for ( it = begin(); it != end(); ++it ) {
761 results.append( (*it).uid() ); 761 results.append( (*it).uid() );
762 } 762 }
763 return results; 763 return results;
764} 764}
765 765
766 766
767Addressee::List AddressBook::allAddressees() 767Addressee::List AddressBook::allAddressees()
768{ 768{
769 return d->mAddressees; 769 return d->mAddressees;
770 770
771} 771}
772 772
773Addressee::List AddressBook::findByName( const QString &name ) 773Addressee::List AddressBook::findByName( const QString &name )
774{ 774{
775 Addressee::List results; 775 Addressee::List results;
776 776
777 Iterator it; 777 Iterator it;
778 for ( it = begin(); it != end(); ++it ) { 778 for ( it = begin(); it != end(); ++it ) {
779 if ( name == (*it).realName() ) { 779 if ( name == (*it).realName() ) {
780 results.append( *it ); 780 results.append( *it );
781 } 781 }
782 } 782 }
783 783
784 return results; 784 return results;
785} 785}
786 786
787Addressee::List AddressBook::findByEmail( const QString &email ) 787Addressee::List AddressBook::findByEmail( const QString &email )
788{ 788{
789 Addressee::List results; 789 Addressee::List results;
790 QStringList mailList; 790 QStringList mailList;
791 791
792 Iterator it; 792 Iterator it;
793 for ( it = begin(); it != end(); ++it ) { 793 for ( it = begin(); it != end(); ++it ) {
794 mailList = (*it).emails(); 794 mailList = (*it).emails();
795 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 795 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
796 if ( email == (*ite) ) { 796 if ( email == (*ite) ) {
797 results.append( *it ); 797 results.append( *it );
798 } 798 }
799 } 799 }
800 } 800 }
801 801
802 return results; 802 return results;
803} 803}
804 804
805Addressee::List AddressBook::findByCategory( const QString &category ) 805Addressee::List AddressBook::findByCategory( const QString &category )
806{ 806{
807 Addressee::List results; 807 Addressee::List results;
808 808
809 Iterator it; 809 Iterator it;
810 for ( it = begin(); it != end(); ++it ) { 810 for ( it = begin(); it != end(); ++it ) {
811 if ( (*it).hasCategory( category) ) { 811 if ( (*it).hasCategory( category) ) {
812 results.append( *it ); 812 results.append( *it );
813 } 813 }