summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-20 19:27:24 (UTC)
committer zautrix <zautrix>2004-09-20 19:27:24 (UTC)
commited49c55dac215ac2ed9286ebfc36e5a19417f0bb (patch) (unidiff)
tree79f933ed5d4a9a9df524dbd71d41d12dde007401
parent138be6cfa921cd8a07fa0b18046d955e7d2dbd6e (diff)
downloadkdepimpi-ed49c55dac215ac2ed9286ebfc36e5a19417f0bb.zip
kdepimpi-ed49c55dac215ac2ed9286ebfc36e5a19417f0bb.tar.gz
kdepimpi-ed49c55dac215ac2ed9286ebfc36e5a19417f0bb.tar.bz2
more DTM sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp5
-rw-r--r--kaddressbook/kabcore.cpp29
-rw-r--r--kaddressbook/kabcore.h7
3 files changed, 34 insertions, 7 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 17b9ba2..adb451f 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,770 +1,773 @@
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 41
42#include <kglobal.h> 42#include <kglobal.h>
43#include <klocale.h> 43#include <klocale.h>
44#include <kdebug.h> 44#include <kdebug.h>
45#include <libkcal/syncdefines.h> 45#include <libkcal/syncdefines.h>
46#include "addressbook.h" 46#include "addressbook.h"
47#include "resource.h" 47#include "resource.h"
48 48
49//US #include "addressbook.moc" 49//US #include "addressbook.moc"
50 50
51using namespace KABC; 51using namespace KABC;
52 52
53struct AddressBook::AddressBookData 53struct AddressBook::AddressBookData
54{ 54{
55 Addressee::List mAddressees; 55 Addressee::List mAddressees;
56 Addressee::List mRemovedAddressees; 56 Addressee::List mRemovedAddressees;
57 Field::List mAllFields; 57 Field::List mAllFields;
58 KConfig *mConfig; 58 KConfig *mConfig;
59 KRES::Manager<Resource> *mManager; 59 KRES::Manager<Resource> *mManager;
60//US ErrorHandler *mErrorHandler; 60//US ErrorHandler *mErrorHandler;
61}; 61};
62 62
63struct AddressBook::Iterator::IteratorData 63struct AddressBook::Iterator::IteratorData
64{ 64{
65 Addressee::List::Iterator mIt; 65 Addressee::List::Iterator mIt;
66}; 66};
67 67
68struct AddressBook::ConstIterator::ConstIteratorData 68struct AddressBook::ConstIterator::ConstIteratorData
69{ 69{
70 Addressee::List::ConstIterator mIt; 70 Addressee::List::ConstIterator mIt;
71}; 71};
72 72
73AddressBook::Iterator::Iterator() 73AddressBook::Iterator::Iterator()
74{ 74{
75 d = new IteratorData; 75 d = new IteratorData;
76} 76}
77 77
78AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 78AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
79{ 79{
80 d = new IteratorData; 80 d = new IteratorData;
81 d->mIt = i.d->mIt; 81 d->mIt = i.d->mIt;
82} 82}
83 83
84AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 84AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
85{ 85{
86 if( this == &i ) return *this; // guard against self assignment 86 if( this == &i ) return *this; // guard against self assignment
87 delete d; // delete the old data the Iterator was completely constructed before 87 delete d; // delete the old data the Iterator was completely constructed before
88 d = new IteratorData; 88 d = new IteratorData;
89 d->mIt = i.d->mIt; 89 d->mIt = i.d->mIt;
90 return *this; 90 return *this;
91} 91}
92 92
93AddressBook::Iterator::~Iterator() 93AddressBook::Iterator::~Iterator()
94{ 94{
95 delete d; 95 delete d;
96} 96}
97 97
98const Addressee &AddressBook::Iterator::operator*() const 98const Addressee &AddressBook::Iterator::operator*() const
99{ 99{
100 return *(d->mIt); 100 return *(d->mIt);
101} 101}
102 102
103Addressee &AddressBook::Iterator::operator*() 103Addressee &AddressBook::Iterator::operator*()
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
113AddressBook::Iterator &AddressBook::Iterator::operator++() 113AddressBook::Iterator &AddressBook::Iterator::operator++()
114{ 114{
115 (d->mIt)++; 115 (d->mIt)++;
116 return *this; 116 return *this;
117} 117}
118 118
119AddressBook::Iterator &AddressBook::Iterator::operator++(int) 119AddressBook::Iterator &AddressBook::Iterator::operator++(int)
120{ 120{
121 (d->mIt)++; 121 (d->mIt)++;
122 return *this; 122 return *this;
123} 123}
124 124
125AddressBook::Iterator &AddressBook::Iterator::operator--() 125AddressBook::Iterator &AddressBook::Iterator::operator--()
126{ 126{
127 (d->mIt)--; 127 (d->mIt)--;
128 return *this; 128 return *this;
129} 129}
130 130
131AddressBook::Iterator &AddressBook::Iterator::operator--(int) 131AddressBook::Iterator &AddressBook::Iterator::operator--(int)
132{ 132{
133 (d->mIt)--; 133 (d->mIt)--;
134 return *this; 134 return *this;
135} 135}
136 136
137bool AddressBook::Iterator::operator==( const Iterator &it ) 137bool AddressBook::Iterator::operator==( const Iterator &it )
138{ 138{
139 return ( d->mIt == it.d->mIt ); 139 return ( d->mIt == it.d->mIt );
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
147 147
148AddressBook::ConstIterator::ConstIterator() 148AddressBook::ConstIterator::ConstIterator()
149{ 149{
150 d = new ConstIteratorData; 150 d = new ConstIteratorData;
151} 151}
152 152
153AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 153AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
154{ 154{
155 d = new ConstIteratorData; 155 d = new ConstIteratorData;
156 d->mIt = i.d->mIt; 156 d->mIt = i.d->mIt;
157} 157}
158 158
159AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 159AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
160{ 160{
161 if( this == &i ) return *this; // guard for self assignment 161 if( this == &i ) return *this; // guard for self assignment
162 delete d; // delete the old data because the Iterator was really constructed before 162 delete d; // delete the old data because the Iterator was really constructed before
163 d = new ConstIteratorData; 163 d = new ConstIteratorData;
164 d->mIt = i.d->mIt; 164 d->mIt = i.d->mIt;
165 return *this; 165 return *this;
166} 166}
167 167
168AddressBook::ConstIterator::~ConstIterator() 168AddressBook::ConstIterator::~ConstIterator()
169{ 169{
170 delete d; 170 delete d;
171} 171}
172 172
173const Addressee &AddressBook::ConstIterator::operator*() const 173const Addressee &AddressBook::ConstIterator::operator*() const
174{ 174{
175 return *(d->mIt); 175 return *(d->mIt);
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
183AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 183AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
184{ 184{
185 (d->mIt)++; 185 (d->mIt)++;
186 return *this; 186 return *this;
187} 187}
188 188
189AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 189AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
190{ 190{
191 (d->mIt)++; 191 (d->mIt)++;
192 return *this; 192 return *this;
193} 193}
194 194
195AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 195AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
196{ 196{
197 (d->mIt)--; 197 (d->mIt)--;
198 return *this; 198 return *this;
199} 199}
200 200
201AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 201AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
202{ 202{
203 (d->mIt)--; 203 (d->mIt)--;
204 return *this; 204 return *this;
205} 205}
206 206
207bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 207bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
208{ 208{
209 return ( d->mIt == it.d->mIt ); 209 return ( d->mIt == it.d->mIt );
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
217 217
218AddressBook::AddressBook() 218AddressBook::AddressBook()
219{ 219{
220 init(0, "contact"); 220 init(0, "contact");
221} 221}
222 222
223AddressBook::AddressBook( const QString &config ) 223AddressBook::AddressBook( const QString &config )
224{ 224{
225 init(config, "contact"); 225 init(config, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config, const QString &family ) 228AddressBook::AddressBook( const QString &config, const QString &family )
229{ 229{
230 init(config, family); 230 init(config, family);
231 231
232} 232}
233 233
234// the default family is "contact" 234// the default family is "contact"
235void AddressBook::init(const QString &config, const QString &family ) 235void AddressBook::init(const QString &config, const QString &family )
236{ 236{
237 blockLSEchange = false; 237 blockLSEchange = false;
238 d = new AddressBookData; 238 d = new AddressBookData;
239 QString fami = family; 239 QString fami = family;
240 qDebug("new ab "); 240 qDebug("new ab ");
241 if (config != 0) { 241 if (config != 0) {
242 qDebug("config != 0 "); 242 qDebug("config != 0 ");
243 if ( family == "syncContact" ) { 243 if ( family == "syncContact" ) {
244 qDebug("creating sync config "); 244 qDebug("creating sync config ");
245 fami = "contact"; 245 fami = "contact";
246 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 246 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
247 con->setGroup( "General" ); 247 con->setGroup( "General" );
248 con->writeEntry( "ResourceKeys", QString("sync") ); 248 con->writeEntry( "ResourceKeys", QString("sync") );
249 con->writeEntry( "Standard", QString("sync") ); 249 con->writeEntry( "Standard", QString("sync") );
250 con->setGroup( "Resource_sync" ); 250 con->setGroup( "Resource_sync" );
251 con->writeEntry( "FileName", config ); 251 con->writeEntry( "FileName", config );
252 con->writeEntry( "FileFormat", QString("vcard") ); 252 con->writeEntry( "FileFormat", QString("vcard") );
253 con->writeEntry( "ResourceIdentifier", QString("sync") ); 253 con->writeEntry( "ResourceIdentifier", QString("sync") );
254 con->writeEntry( "ResourceName", QString("sync_res") ); 254 con->writeEntry( "ResourceName", QString("sync_res") );
255 if ( config.right(4) == ".xml" ) 255 if ( config.right(4) == ".xml" )
256 con->writeEntry( "ResourceType", QString("qtopia") ); 256 con->writeEntry( "ResourceType", QString("qtopia") );
257 else 257 else if ( config == "sharp" ) {
258 con->writeEntry( "ResourceType", QString("sharp") );
259 } else {
258 con->writeEntry( "ResourceType", QString("file") ); 260 con->writeEntry( "ResourceType", QString("file") );
261 }
259 //con->sync(); 262 //con->sync();
260 d->mConfig = con; 263 d->mConfig = con;
261 } 264 }
262 else 265 else
263 d->mConfig = new KConfig( locateLocal("config", config) ); 266 d->mConfig = new KConfig( locateLocal("config", config) );
264// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 267// qDebug("AddressBook::init 1 config=%s",config.latin1() );
265 } 268 }
266 else { 269 else {
267 d->mConfig = 0; 270 d->mConfig = 0;
268// qDebug("AddressBook::init 1 config=0"); 271// qDebug("AddressBook::init 1 config=0");
269 } 272 }
270 273
271//US d->mErrorHandler = 0; 274//US d->mErrorHandler = 0;
272 d->mManager = new KRES::Manager<Resource>( fami, false ); 275 d->mManager = new KRES::Manager<Resource>( fami, false );
273 d->mManager->readConfig( d->mConfig ); 276 d->mManager->readConfig( d->mConfig );
274 if ( family == "syncContact" ) { 277 if ( family == "syncContact" ) {
275 KRES::Manager<Resource> *manager = d->mManager; 278 KRES::Manager<Resource> *manager = d->mManager;
276 KRES::Manager<Resource>::ActiveIterator it; 279 KRES::Manager<Resource>::ActiveIterator it;
277 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 280 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
278 (*it)->setAddressBook( this ); 281 (*it)->setAddressBook( this );
279 if ( !(*it)->open() ) 282 if ( !(*it)->open() )
280 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 283 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
281 } 284 }
282 Resource *res = standardResource(); 285 Resource *res = standardResource();
283 if ( !res ) { 286 if ( !res ) {
284 qDebug("ERROR: no standard resource"); 287 qDebug("ERROR: no standard resource");
285 res = manager->createResource( "file" ); 288 res = manager->createResource( "file" );
286 if ( res ) 289 if ( res )
287 { 290 {
288 addResource( res ); 291 addResource( res );
289 } 292 }
290 else 293 else
291 qDebug(" No resource available!!!"); 294 qDebug(" No resource available!!!");
292 } 295 }
293 setStandardResource( res ); 296 setStandardResource( res );
294 manager->writeConfig(); 297 manager->writeConfig();
295 } 298 }
296 addCustomField( i18n( "Department" ), KABC::Field::Organization, 299 addCustomField( i18n( "Department" ), KABC::Field::Organization,
297 "X-Department", "KADDRESSBOOK" ); 300 "X-Department", "KADDRESSBOOK" );
298 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 301 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
299 "X-Profession", "KADDRESSBOOK" ); 302 "X-Profession", "KADDRESSBOOK" );
300 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 303 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
301 "X-AssistantsName", "KADDRESSBOOK" ); 304 "X-AssistantsName", "KADDRESSBOOK" );
302 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 305 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
303 "X-ManagersName", "KADDRESSBOOK" ); 306 "X-ManagersName", "KADDRESSBOOK" );
304 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 307 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
305 "X-SpousesName", "KADDRESSBOOK" ); 308 "X-SpousesName", "KADDRESSBOOK" );
306 addCustomField( i18n( "Office" ), KABC::Field::Personal, 309 addCustomField( i18n( "Office" ), KABC::Field::Personal,
307 "X-Office", "KADDRESSBOOK" ); 310 "X-Office", "KADDRESSBOOK" );
308 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 311 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
309 "X-IMAddress", "KADDRESSBOOK" ); 312 "X-IMAddress", "KADDRESSBOOK" );
310 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 313 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
311 "X-Anniversary", "KADDRESSBOOK" ); 314 "X-Anniversary", "KADDRESSBOOK" );
312 315
313 //US added this field to become compatible with Opie/qtopia addressbook 316 //US added this field to become compatible with Opie/qtopia addressbook
314 // values can be "female" or "male" or "". An empty field represents undefined. 317 // values can be "female" or "male" or "". An empty field represents undefined.
315 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 318 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
316 "X-Gender", "KADDRESSBOOK" ); 319 "X-Gender", "KADDRESSBOOK" );
317 addCustomField( i18n( "Children" ), KABC::Field::Personal, 320 addCustomField( i18n( "Children" ), KABC::Field::Personal,
318 "X-Children", "KADDRESSBOOK" ); 321 "X-Children", "KADDRESSBOOK" );
319 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 322 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
320 "X-FreeBusyUrl", "KADDRESSBOOK" ); 323 "X-FreeBusyUrl", "KADDRESSBOOK" );
321 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 324 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
322 "X-ExternalID", "KADDRESSBOOK" ); 325 "X-ExternalID", "KADDRESSBOOK" );
323} 326}
324 327
325AddressBook::~AddressBook() 328AddressBook::~AddressBook()
326{ 329{
327 delete d->mConfig; d->mConfig = 0; 330 delete d->mConfig; d->mConfig = 0;
328 delete d->mManager; d->mManager = 0; 331 delete d->mManager; d->mManager = 0;
329//US delete d->mErrorHandler; d->mErrorHandler = 0; 332//US delete d->mErrorHandler; d->mErrorHandler = 0;
330 delete d; d = 0; 333 delete d; d = 0;
331} 334}
332 335
333bool AddressBook::load() 336bool AddressBook::load()
334{ 337{
335 338
336 339
337 clear(); 340 clear();
338 341
339 KRES::Manager<Resource>::ActiveIterator it; 342 KRES::Manager<Resource>::ActiveIterator it;
340 bool ok = true; 343 bool ok = true;
341 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 344 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
342 if ( !(*it)->load() ) { 345 if ( !(*it)->load() ) {
343 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 346 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
344 ok = false; 347 ok = false;
345 } 348 }
346 349
347 // mark all addressees as unchanged 350 // mark all addressees as unchanged
348 Addressee::List::Iterator addrIt; 351 Addressee::List::Iterator addrIt;
349 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 352 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
350 (*addrIt).setChanged( false ); 353 (*addrIt).setChanged( false );
351 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 354 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
352 if ( !id.isEmpty() ) { 355 if ( !id.isEmpty() ) {
353 //qDebug("setId aa %s ", id.latin1()); 356 //qDebug("setId aa %s ", id.latin1());
354 (*addrIt).setIDStr(id ); 357 (*addrIt).setIDStr(id );
355 } 358 }
356 } 359 }
357 blockLSEchange = true; 360 blockLSEchange = true;
358 return ok; 361 return ok;
359} 362}
360 363
361bool AddressBook::save( Ticket *ticket ) 364bool AddressBook::save( Ticket *ticket )
362{ 365{
363 kdDebug(5700) << "AddressBook::save()"<< endl; 366 kdDebug(5700) << "AddressBook::save()"<< endl;
364 367
365 if ( ticket->resource() ) { 368 if ( ticket->resource() ) {
366 deleteRemovedAddressees(); 369 deleteRemovedAddressees();
367 return ticket->resource()->save( ticket ); 370 return ticket->resource()->save( ticket );
368 } 371 }
369 372
370 return false; 373 return false;
371} 374}
372bool AddressBook::saveAB() 375bool AddressBook::saveAB()
373{ 376{
374 bool ok = true; 377 bool ok = true;
375 378
376 deleteRemovedAddressees(); 379 deleteRemovedAddressees();
377 Iterator ait; 380 Iterator ait;
378 for ( ait = begin(); ait != end(); ++ait ) { 381 for ( ait = begin(); ait != end(); ++ait ) {
379 if ( !(*ait).IDStr().isEmpty() ) { 382 if ( !(*ait).IDStr().isEmpty() ) {
380 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 383 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
381 } 384 }
382 } 385 }
383 KRES::Manager<Resource>::ActiveIterator it; 386 KRES::Manager<Resource>::ActiveIterator it;
384 KRES::Manager<Resource> *manager = d->mManager; 387 KRES::Manager<Resource> *manager = d->mManager;
385 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 388 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
386 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 389 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
387 Ticket *ticket = requestSaveTicket( *it ); 390 Ticket *ticket = requestSaveTicket( *it );
388// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 391// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
389 if ( !ticket ) { 392 if ( !ticket ) {
390 error( i18n( "Unable to save to resource '%1'. It is locked." ) 393 error( i18n( "Unable to save to resource '%1'. It is locked." )
391 .arg( (*it)->resourceName() ) ); 394 .arg( (*it)->resourceName() ) );
392 return false; 395 return false;
393 } 396 }
394 397
395 //if ( !save( ticket ) ) 398 //if ( !save( ticket ) )
396 if ( ticket->resource() ) { 399 if ( ticket->resource() ) {
397 if ( ! ticket->resource()->save( ticket ) ) 400 if ( ! ticket->resource()->save( ticket ) )
398 ok = false; 401 ok = false;
399 } else 402 } else
400 ok = false; 403 ok = false;
401 404
402 } 405 }
403 } 406 }
404 return ok; 407 return ok;
405} 408}
406 409
407AddressBook::Iterator AddressBook::begin() 410AddressBook::Iterator AddressBook::begin()
408{ 411{
409 Iterator it = Iterator(); 412 Iterator it = Iterator();
410 it.d->mIt = d->mAddressees.begin(); 413 it.d->mIt = d->mAddressees.begin();
411 return it; 414 return it;
412} 415}
413 416
414AddressBook::ConstIterator AddressBook::begin() const 417AddressBook::ConstIterator AddressBook::begin() const
415{ 418{
416 ConstIterator it = ConstIterator(); 419 ConstIterator it = ConstIterator();
417 it.d->mIt = d->mAddressees.begin(); 420 it.d->mIt = d->mAddressees.begin();
418 return it; 421 return it;
419} 422}
420 423
421AddressBook::Iterator AddressBook::end() 424AddressBook::Iterator AddressBook::end()
422{ 425{
423 Iterator it = Iterator(); 426 Iterator it = Iterator();
424 it.d->mIt = d->mAddressees.end(); 427 it.d->mIt = d->mAddressees.end();
425 return it; 428 return it;
426} 429}
427 430
428AddressBook::ConstIterator AddressBook::end() const 431AddressBook::ConstIterator AddressBook::end() const
429{ 432{
430 ConstIterator it = ConstIterator(); 433 ConstIterator it = ConstIterator();
431 it.d->mIt = d->mAddressees.end(); 434 it.d->mIt = d->mAddressees.end();
432 return it; 435 return it;
433} 436}
434 437
435void AddressBook::clear() 438void AddressBook::clear()
436{ 439{
437 d->mAddressees.clear(); 440 d->mAddressees.clear();
438} 441}
439 442
440Ticket *AddressBook::requestSaveTicket( Resource *resource ) 443Ticket *AddressBook::requestSaveTicket( Resource *resource )
441{ 444{
442 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 445 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
443 446
444 if ( !resource ) 447 if ( !resource )
445 { 448 {
446 qDebug("AddressBook::requestSaveTicket no resource" ); 449 qDebug("AddressBook::requestSaveTicket no resource" );
447 resource = standardResource(); 450 resource = standardResource();
448 } 451 }
449 452
450 KRES::Manager<Resource>::ActiveIterator it; 453 KRES::Manager<Resource>::ActiveIterator it;
451 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 454 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
452 if ( (*it) == resource ) { 455 if ( (*it) == resource ) {
453 if ( (*it)->readOnly() || !(*it)->isOpen() ) 456 if ( (*it)->readOnly() || !(*it)->isOpen() )
454 return 0; 457 return 0;
455 else 458 else
456 return (*it)->requestSaveTicket(); 459 return (*it)->requestSaveTicket();
457 } 460 }
458 } 461 }
459 462
460 return 0; 463 return 0;
461} 464}
462 465
463void AddressBook::insertAddressee( const Addressee &a, bool setRev ) 466void AddressBook::insertAddressee( const Addressee &a, bool setRev )
464{ 467{
465 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 468 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
466 //qDebug("block insert "); 469 //qDebug("block insert ");
467 return; 470 return;
468 } 471 }
469 //qDebug("inserting.... %s ",a.uid().latin1() ); 472 //qDebug("inserting.... %s ",a.uid().latin1() );
470 bool found = false; 473 bool found = false;
471 Addressee::List::Iterator it; 474 Addressee::List::Iterator it;
472 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 475 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
473 if ( a.uid() == (*it).uid() ) { 476 if ( a.uid() == (*it).uid() ) {
474 477
475 bool changed = false; 478 bool changed = false;
476 Addressee addr = a; 479 Addressee addr = a;
477 if ( addr != (*it) ) 480 if ( addr != (*it) )
478 changed = true; 481 changed = true;
479 482
480 (*it) = a; 483 (*it) = a;
481 if ( (*it).resource() == 0 ) 484 if ( (*it).resource() == 0 )
482 (*it).setResource( standardResource() ); 485 (*it).setResource( standardResource() );
483 486
484 if ( changed ) { 487 if ( changed ) {
485 if ( setRev ) { 488 if ( setRev ) {
486 489
487 // get rid of micro seconds 490 // get rid of micro seconds
488 QDateTime dt = QDateTime::currentDateTime(); 491 QDateTime dt = QDateTime::currentDateTime();
489 QTime t = dt.time(); 492 QTime t = dt.time();
490 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 493 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
491 (*it).setRevision( dt ); 494 (*it).setRevision( dt );
492 } 495 }
493 (*it).setChanged( true ); 496 (*it).setChanged( true );
494 } 497 }
495 498
496 found = true; 499 found = true;
497 } else { 500 } else {
498 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 501 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
499 QString name = (*it).uid().mid( 19 ); 502 QString name = (*it).uid().mid( 19 );
500 Addressee b = a; 503 Addressee b = a;
501 QString id = b.getID( name ); 504 QString id = b.getID( name );
502 if ( ! id.isEmpty() ) { 505 if ( ! id.isEmpty() ) {
503 QString des = (*it).note(); 506 QString des = (*it).note();
504 int startN; 507 int startN;
505 if( (startN = des.find( id ) ) >= 0 ) { 508 if( (startN = des.find( id ) ) >= 0 ) {
506 int endN = des.find( ",", startN+1 ); 509 int endN = des.find( ",", startN+1 );
507 des = des.left( startN ) + des.mid( endN+1 ); 510 des = des.left( startN ) + des.mid( endN+1 );
508 (*it).setNote( des ); 511 (*it).setNote( des );
509 } 512 }
510 } 513 }
511 } 514 }
512 } 515 }
513 } 516 }
514 if ( found ) 517 if ( found )
515 return; 518 return;
516 d->mAddressees.append( a ); 519 d->mAddressees.append( a );
517 Addressee& addr = d->mAddressees.last(); 520 Addressee& addr = d->mAddressees.last();
518 if ( addr.resource() == 0 ) 521 if ( addr.resource() == 0 )
519 addr.setResource( standardResource() ); 522 addr.setResource( standardResource() );
520 523
521 addr.setChanged( true ); 524 addr.setChanged( true );
522} 525}
523 526
524void AddressBook::removeAddressee( const Addressee &a ) 527void AddressBook::removeAddressee( const Addressee &a )
525{ 528{
526 Iterator it; 529 Iterator it;
527 Iterator it2; 530 Iterator it2;
528 bool found = false; 531 bool found = false;
529 for ( it = begin(); it != end(); ++it ) { 532 for ( it = begin(); it != end(); ++it ) {
530 if ( a.uid() == (*it).uid() ) { 533 if ( a.uid() == (*it).uid() ) {
531 found = true; 534 found = true;
532 it2 = it; 535 it2 = it;
533 } else { 536 } else {
534 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 537 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
535 QString name = (*it).uid().mid( 19 ); 538 QString name = (*it).uid().mid( 19 );
536 Addressee b = a; 539 Addressee b = a;
537 QString id = b.getID( name ); 540 QString id = b.getID( name );
538 if ( ! id.isEmpty() ) { 541 if ( ! id.isEmpty() ) {
539 QString des = (*it).note(); 542 QString des = (*it).note();
540 if( des.find( id ) < 0 ) { 543 if( des.find( id ) < 0 ) {
541 des += id + ","; 544 des += id + ",";
542 (*it).setNote( des ); 545 (*it).setNote( des );
543 } 546 }
544 } 547 }
545 } 548 }
546 549
547 } 550 }
548 } 551 }
549 552
550 if ( found ) 553 if ( found )
551 removeAddressee( it2 ); 554 removeAddressee( it2 );
552 555
553} 556}
554 557
555void AddressBook::removeSyncAddressees( bool removeDeleted ) 558void AddressBook::removeSyncAddressees( bool removeDeleted )
556{ 559{
557 Iterator it = begin(); 560 Iterator it = begin();
558 Iterator it2 ; 561 Iterator it2 ;
559 QDateTime dt ( QDate( 2004,1,1) ); 562 QDateTime dt ( QDate( 2004,1,1) );
560 while ( it != end() ) { 563 while ( it != end() ) {
561 (*it).setRevision( dt ); 564 (*it).setRevision( dt );
562 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 565 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
563 (*it).setIDStr(""); 566 (*it).setIDStr("");
564 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 567 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
565 it2 = it; 568 it2 = it;
566 //qDebug("removing %s ",(*it).uid().latin1() ); 569 //qDebug("removing %s ",(*it).uid().latin1() );
567 ++it; 570 ++it;
568 removeAddressee( it2 ); 571 removeAddressee( it2 );
569 } else { 572 } else {
570 //qDebug("skipping %s ",(*it).uid().latin1() ); 573 //qDebug("skipping %s ",(*it).uid().latin1() );
571 ++it; 574 ++it;
572 } 575 }
573 } 576 }
574 deleteRemovedAddressees(); 577 deleteRemovedAddressees();
575} 578}
576 579
577void AddressBook::removeAddressee( const Iterator &it ) 580void AddressBook::removeAddressee( const Iterator &it )
578{ 581{
579 d->mRemovedAddressees.append( (*it) ); 582 d->mRemovedAddressees.append( (*it) );
580 d->mAddressees.remove( it.d->mIt ); 583 d->mAddressees.remove( it.d->mIt );
581} 584}
582 585
583AddressBook::Iterator AddressBook::find( const Addressee &a ) 586AddressBook::Iterator AddressBook::find( const Addressee &a )
584{ 587{
585 Iterator it; 588 Iterator it;
586 for ( it = begin(); it != end(); ++it ) { 589 for ( it = begin(); it != end(); ++it ) {
587 if ( a.uid() == (*it).uid() ) { 590 if ( a.uid() == (*it).uid() ) {
588 return it; 591 return it;
589 } 592 }
590 } 593 }
591 return end(); 594 return end();
592} 595}
593 596
594Addressee AddressBook::findByUid( const QString &uid ) 597Addressee AddressBook::findByUid( const QString &uid )
595{ 598{
596 Iterator it; 599 Iterator it;
597 for ( it = begin(); it != end(); ++it ) { 600 for ( it = begin(); it != end(); ++it ) {
598 if ( uid == (*it).uid() ) { 601 if ( uid == (*it).uid() ) {
599 return *it; 602 return *it;
600 } 603 }
601 } 604 }
602 return Addressee(); 605 return Addressee();
603} 606}
604void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) 607void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
605{ 608{
606 qDebug("AddressBook::preExternSync "); 609 qDebug("AddressBook::preExternSync ");
607 AddressBook::Iterator it; 610 AddressBook::Iterator it;
608 for ( it = begin(); it != end(); ++it ) { 611 for ( it = begin(); it != end(); ++it ) {
609 (*it).setID( csd, (*it).externalUID() ); 612 (*it).setID( csd, (*it).externalUID() );
610 (*it).computeCsum( csd ); 613 (*it).computeCsum( csd );
611 } 614 }
612 mergeAB( aBook ,csd ); 615 mergeAB( aBook ,csd );
613} 616}
614void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 617void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
615{ 618{
616 qDebug("AddressBook::postExternSync "); 619 qDebug("AddressBook::postExternSync ");
617 AddressBook::Iterator it; 620 AddressBook::Iterator it;
618 for ( it = begin(); it != end(); ++it ) { 621 for ( it = begin(); it != end(); ++it ) {
619 qDebug("check uid %s ", (*it).uid().latin1() ); 622 qDebug("check uid %s ", (*it).uid().latin1() );
620 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 623 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
621 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 624 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
622 Addressee ad = aBook->findByUid( ( (*it).uid() )); 625 Addressee ad = aBook->findByUid( ( (*it).uid() ));
623 if ( ad.isEmpty() ) { 626 if ( ad.isEmpty() ) {
624 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 627 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
625 } else { 628 } else {
626 (*it).computeCsum( csd ); 629 (*it).computeCsum( csd );
627 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 630 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
628 ad.setID( csd, (*it).externalUID() ); 631 ad.setID( csd, (*it).externalUID() );
629 ad.setCsum( csd, (*it).getCsum( csd ) ); 632 ad.setCsum( csd, (*it).getCsum( csd ) );
630 aBook->insertAddressee( ad ); 633 aBook->insertAddressee( ad );
631 } 634 }
632 } 635 }
633 } 636 }
634} 637}
635 638
636bool AddressBook::containsExternalUid( const QString& uid ) 639bool AddressBook::containsExternalUid( const QString& uid )
637{ 640{
638 Iterator it; 641 Iterator it;
639 for ( it = begin(); it != end(); ++it ) { 642 for ( it = begin(); it != end(); ++it ) {
640 if ( uid == (*it).externalUID( ) ) 643 if ( uid == (*it).externalUID( ) )
641 return true; 644 return true;
642 } 645 }
643 return false; 646 return false;
644} 647}
645Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 648Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
646{ 649{
647 Iterator it; 650 Iterator it;
648 for ( it = begin(); it != end(); ++it ) { 651 for ( it = begin(); it != end(); ++it ) {
649 if ( uid == (*it).getID( profile ) ) 652 if ( uid == (*it).getID( profile ) )
650 return (*it); 653 return (*it);
651 } 654 }
652 return Addressee(); 655 return Addressee();
653} 656}
654void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) 657void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
655{ 658{
656 Iterator it; 659 Iterator it;
657 Addressee ad; 660 Addressee ad;
658 for ( it = begin(); it != end(); ++it ) { 661 for ( it = begin(); it != end(); ++it ) {
659 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 662 ad = aBook->findByExternUid( (*it).externalUID(), profile );
660 if ( !ad.isEmpty() ) { 663 if ( !ad.isEmpty() ) {
661 (*it).mergeContact( ad ); 664 (*it).mergeContact( ad );
662 } 665 }
663 } 666 }
664#if 0 667#if 0
665 // test only 668 // test only
666 for ( it = begin(); it != end(); ++it ) { 669 for ( it = begin(); it != end(); ++it ) {
667 670
668 qDebug("uid %s ", (*it).uid().latin1()); 671 qDebug("uid %s ", (*it).uid().latin1());
669 } 672 }
670#endif 673#endif
671} 674}
672 675
673#if 0 676#if 0
674Addressee::List AddressBook::getExternLastSyncAddressees() 677Addressee::List AddressBook::getExternLastSyncAddressees()
675{ 678{
676 Addressee::List results; 679 Addressee::List results;
677 680
678 Iterator it; 681 Iterator it;
679 for ( it = begin(); it != end(); ++it ) { 682 for ( it = begin(); it != end(); ++it ) {
680 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 683 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
681 if ( (*it).familyName().left(4) == "!E: " ) 684 if ( (*it).familyName().left(4) == "!E: " )
682 results.append( *it ); 685 results.append( *it );
683 } 686 }
684 } 687 }
685 688
686 return results; 689 return results;
687} 690}
688#endif 691#endif
689void AddressBook::resetTempSyncStat() 692void AddressBook::resetTempSyncStat()
690{ 693{
691 Iterator it; 694 Iterator it;
692 for ( it = begin(); it != end(); ++it ) { 695 for ( it = begin(); it != end(); ++it ) {
693 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 696 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
694 } 697 }
695 698
696} 699}
697 700
698QStringList AddressBook:: uidList() 701QStringList AddressBook:: uidList()
699{ 702{
700 QStringList results; 703 QStringList results;
701 Iterator it; 704 Iterator it;
702 for ( it = begin(); it != end(); ++it ) { 705 for ( it = begin(); it != end(); ++it ) {
703 results.append( (*it).uid() ); 706 results.append( (*it).uid() );
704 } 707 }
705 return results; 708 return results;
706} 709}
707 710
708 711
709Addressee::List AddressBook::allAddressees() 712Addressee::List AddressBook::allAddressees()
710{ 713{
711 return d->mAddressees; 714 return d->mAddressees;
712 715
713} 716}
714 717
715Addressee::List AddressBook::findByName( const QString &name ) 718Addressee::List AddressBook::findByName( const QString &name )
716{ 719{
717 Addressee::List results; 720 Addressee::List results;
718 721
719 Iterator it; 722 Iterator it;
720 for ( it = begin(); it != end(); ++it ) { 723 for ( it = begin(); it != end(); ++it ) {
721 if ( name == (*it).realName() ) { 724 if ( name == (*it).realName() ) {
722 results.append( *it ); 725 results.append( *it );
723 } 726 }
724 } 727 }
725 728
726 return results; 729 return results;
727} 730}
728 731
729Addressee::List AddressBook::findByEmail( const QString &email ) 732Addressee::List AddressBook::findByEmail( const QString &email )
730{ 733{
731 Addressee::List results; 734 Addressee::List results;
732 QStringList mailList; 735 QStringList mailList;
733 736
734 Iterator it; 737 Iterator it;
735 for ( it = begin(); it != end(); ++it ) { 738 for ( it = begin(); it != end(); ++it ) {
736 mailList = (*it).emails(); 739 mailList = (*it).emails();
737 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 740 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
738 if ( email == (*ite) ) { 741 if ( email == (*ite) ) {
739 results.append( *it ); 742 results.append( *it );
740 } 743 }
741 } 744 }
742 } 745 }
743 746
744 return results; 747 return results;
745} 748}
746 749
747Addressee::List AddressBook::findByCategory( const QString &category ) 750Addressee::List AddressBook::findByCategory( const QString &category )
748{ 751{
749 Addressee::List results; 752 Addressee::List results;
750 753
751 Iterator it; 754 Iterator it;
752 for ( it = begin(); it != end(); ++it ) { 755 for ( it = begin(); it != end(); ++it ) {
753 if ( (*it).hasCategory( category) ) { 756 if ( (*it).hasCategory( category) ) {
754 results.append( *it ); 757 results.append( *it );
755 } 758 }
756 } 759 }
757 760
758 return results; 761 return results;
759} 762}
760 763
761void AddressBook::dump() const 764void AddressBook::dump() const
762{ 765{
763 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 766 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
764 767
765 ConstIterator it; 768 ConstIterator it;
766 for( it = begin(); it != end(); ++it ) { 769 for( it = begin(); it != end(); ++it ) {
767 (*it).dump(); 770 (*it).dump();
768 } 771 }
769 772
770 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 773 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index f8683e7..c1ead9d 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2517,528 +2517,551 @@ QString KABCore::getPassword( )
2517} 2517}
2518#include <libkcal/syncdefines.h> 2518#include <libkcal/syncdefines.h>
2519 2519
2520KABC::Addressee KABCore::getLastSyncAddressee() 2520KABC::Addressee KABCore::getLastSyncAddressee()
2521{ 2521{
2522 Addressee lse; 2522 Addressee lse;
2523 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2523 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2524 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2524 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2525 if (lse.isEmpty()) { 2525 if (lse.isEmpty()) {
2526 qDebug("Creating new last-syncAddressee "); 2526 qDebug("Creating new last-syncAddressee ");
2527 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2527 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2528 QString sum = ""; 2528 QString sum = "";
2529 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2529 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2530 sum = "E: "; 2530 sum = "E: ";
2531 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2531 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2532 lse.setRevision( mLastAddressbookSync ); 2532 lse.setRevision( mLastAddressbookSync );
2533 lse.setCategories( i18n("SyncEvent") ); 2533 lse.setCategories( i18n("SyncEvent") );
2534 mAddressBook->insertAddressee( lse ); 2534 mAddressBook->insertAddressee( lse );
2535 } 2535 }
2536 return lse; 2536 return lse;
2537} 2537}
2538int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2538int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2539{ 2539{
2540 2540
2541 //void setZaurusId(int id); 2541 //void setZaurusId(int id);
2542 // int zaurusId() const; 2542 // int zaurusId() const;
2543 // void setZaurusUid(int id); 2543 // void setZaurusUid(int id);
2544 // int zaurusUid() const; 2544 // int zaurusUid() const;
2545 // void setZaurusStat(int id); 2545 // void setZaurusStat(int id);
2546 // int zaurusStat() const; 2546 // int zaurusStat() const;
2547 // 0 equal 2547 // 0 equal
2548 // 1 take local 2548 // 1 take local
2549 // 2 take remote 2549 // 2 take remote
2550 // 3 cancel 2550 // 3 cancel
2551 QDateTime lastSync = mLastAddressbookSync; 2551 QDateTime lastSync = mLastAddressbookSync;
2552 QDateTime localMod = local->revision(); 2552 QDateTime localMod = local->revision();
2553 QDateTime remoteMod = remote->revision(); 2553 QDateTime remoteMod = remote->revision();
2554 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2554 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2555 bool remCh, locCh; 2555 bool remCh, locCh;
2556 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2556 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2557 2557
2558 qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2558 qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2559 locCh = ( localMod > mLastAddressbookSync ); 2559 locCh = ( localMod > mLastAddressbookSync );
2560 if ( !remCh && ! locCh ) { 2560 if ( !remCh && ! locCh ) {
2561 qDebug("both not changed "); 2561 qDebug("both not changed ");
2562 lastSync = localMod.addDays(1); 2562 lastSync = localMod.addDays(1);
2563 if ( mode <= SYNC_PREF_ASK ) 2563 if ( mode <= SYNC_PREF_ASK )
2564 return 0; 2564 return 0;
2565 } else { 2565 } else {
2566 if ( locCh ) { 2566 if ( locCh ) {
2567 qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2567 qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2568 lastSync = localMod.addDays( -1 ); 2568 lastSync = localMod.addDays( -1 );
2569 if ( !remCh ) 2569 if ( !remCh )
2570 remoteMod =( lastSync.addDays( -1 ) ); 2570 remoteMod =( lastSync.addDays( -1 ) );
2571 } else { 2571 } else {
2572 //qDebug(" not loc changed "); 2572 //qDebug(" not loc changed ");
2573 lastSync = localMod.addDays( 1 ); 2573 lastSync = localMod.addDays( 1 );
2574 if ( remCh ) 2574 if ( remCh )
2575 remoteMod =( lastSync.addDays( 1 ) ); 2575 remoteMod =( lastSync.addDays( 1 ) );
2576 2576
2577 } 2577 }
2578 } 2578 }
2579 full = true; 2579 full = true;
2580 if ( mode < SYNC_PREF_ASK ) 2580 if ( mode < SYNC_PREF_ASK )
2581 mode = SYNC_PREF_ASK; 2581 mode = SYNC_PREF_ASK;
2582 } else { 2582 } else {
2583 if ( localMod == remoteMod ) 2583 if ( localMod == remoteMod )
2584 return 0; 2584 return 0;
2585 2585
2586 } 2586 }
2587 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2587 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2588 2588
2589 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2589 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2590 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2590 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2591 //full = true; //debug only 2591 //full = true; //debug only
2592 if ( full ) { 2592 if ( full ) {
2593 bool equ = ( (*local) == (*remote) ); 2593 bool equ = ( (*local) == (*remote) );
2594 if ( equ ) { 2594 if ( equ ) {
2595 //qDebug("equal "); 2595 //qDebug("equal ");
2596 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2596 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2597 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2597 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2598 } 2598 }
2599 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2599 if ( mode < SYNC_PREF_FORCE_LOCAL )
2600 return 0; 2600 return 0;
2601 2601
2602 }//else //debug only 2602 }//else //debug only
2603 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2603 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2604 } 2604 }
2605 int result; 2605 int result;
2606 bool localIsNew; 2606 bool localIsNew;
2607 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2607 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2608 2608
2609 if ( full && mode < SYNC_PREF_NEWEST ) 2609 if ( full && mode < SYNC_PREF_NEWEST )
2610 mode = SYNC_PREF_ASK; 2610 mode = SYNC_PREF_ASK;
2611 2611
2612 switch( mode ) { 2612 switch( mode ) {
2613 case SYNC_PREF_LOCAL: 2613 case SYNC_PREF_LOCAL:
2614 if ( lastSync > remoteMod ) 2614 if ( lastSync > remoteMod )
2615 return 1; 2615 return 1;
2616 if ( lastSync > localMod ) 2616 if ( lastSync > localMod )
2617 return 2; 2617 return 2;
2618 return 1; 2618 return 1;
2619 break; 2619 break;
2620 case SYNC_PREF_REMOTE: 2620 case SYNC_PREF_REMOTE:
2621 if ( lastSync > remoteMod ) 2621 if ( lastSync > remoteMod )
2622 return 1; 2622 return 1;
2623 if ( lastSync > localMod ) 2623 if ( lastSync > localMod )
2624 return 2; 2624 return 2;
2625 return 2; 2625 return 2;
2626 break; 2626 break;
2627 case SYNC_PREF_NEWEST: 2627 case SYNC_PREF_NEWEST:
2628 if ( localMod > remoteMod ) 2628 if ( localMod > remoteMod )
2629 return 1; 2629 return 1;
2630 else 2630 else
2631 return 2; 2631 return 2;
2632 break; 2632 break;
2633 case SYNC_PREF_ASK: 2633 case SYNC_PREF_ASK:
2634 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2634 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2635 if ( lastSync > remoteMod ) 2635 if ( lastSync > remoteMod )
2636 return 1; 2636 return 1;
2637 if ( lastSync > localMod ) 2637 if ( lastSync > localMod )
2638 return 2; 2638 return 2;
2639 localIsNew = localMod >= remoteMod; 2639 localIsNew = localMod >= remoteMod;
2640 //qDebug("conflict! ************************************** "); 2640 //qDebug("conflict! ************************************** ");
2641 { 2641 {
2642 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2642 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2643 result = acd.executeD(localIsNew); 2643 result = acd.executeD(localIsNew);
2644 return result; 2644 return result;
2645 } 2645 }
2646 break; 2646 break;
2647 case SYNC_PREF_FORCE_LOCAL: 2647 case SYNC_PREF_FORCE_LOCAL:
2648 return 1; 2648 return 1;
2649 break; 2649 break;
2650 case SYNC_PREF_FORCE_REMOTE: 2650 case SYNC_PREF_FORCE_REMOTE:
2651 return 2; 2651 return 2;
2652 break; 2652 break;
2653 2653
2654 default: 2654 default:
2655 // SYNC_PREF_TAKE_BOTH not implemented 2655 // SYNC_PREF_TAKE_BOTH not implemented
2656 break; 2656 break;
2657 } 2657 }
2658 return 0; 2658 return 0;
2659} 2659}
2660bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2660bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2661{ 2661{
2662 bool syncOK = true; 2662 bool syncOK = true;
2663 int addedAddressee = 0; 2663 int addedAddressee = 0;
2664 int addedAddresseeR = 0; 2664 int addedAddresseeR = 0;
2665 int deletedAddresseeR = 0; 2665 int deletedAddresseeR = 0;
2666 int deletedAddresseeL = 0; 2666 int deletedAddresseeL = 0;
2667 int changedLocal = 0; 2667 int changedLocal = 0;
2668 int changedRemote = 0; 2668 int changedRemote = 0;
2669 //QPtrList<Addressee> el = local->rawAddressees(); 2669 //QPtrList<Addressee> el = local->rawAddressees();
2670 Addressee addresseeR; 2670 Addressee addresseeR;
2671 QString uid; 2671 QString uid;
2672 int take; 2672 int take;
2673 Addressee addresseeL; 2673 Addressee addresseeL;
2674 Addressee addresseeRSync; 2674 Addressee addresseeRSync;
2675 Addressee addresseeLSync; 2675 Addressee addresseeLSync;
2676 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2676 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2677 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2677 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2678 bool fullDateRange = false; 2678 bool fullDateRange = false;
2679 local->resetTempSyncStat(); 2679 local->resetTempSyncStat();
2680 mLastAddressbookSync = QDateTime::currentDateTime(); 2680 mLastAddressbookSync = QDateTime::currentDateTime();
2681 QDateTime modifiedCalendar = mLastAddressbookSync;; 2681 QDateTime modifiedCalendar = mLastAddressbookSync;;
2682 addresseeLSync = getLastSyncAddressee(); 2682 addresseeLSync = getLastSyncAddressee();
2683 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2683 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2684 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2684 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2685 if ( !addresseeR.isEmpty() ) { 2685 if ( !addresseeR.isEmpty() ) {
2686 addresseeRSync = addresseeR; 2686 addresseeRSync = addresseeR;
2687 remote->removeAddressee(addresseeR ); 2687 remote->removeAddressee(addresseeR );
2688 2688
2689 } else { 2689 } else {
2690 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2690 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2691 addresseeRSync = addresseeLSync ; 2691 addresseeRSync = addresseeLSync ;
2692 } else { 2692 } else {
2693 qDebug("FULLDATE 1"); 2693 qDebug("FULLDATE 1");
2694 fullDateRange = true; 2694 fullDateRange = true;
2695 Addressee newAdd; 2695 Addressee newAdd;
2696 addresseeRSync = newAdd; 2696 addresseeRSync = newAdd;
2697 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2697 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2698 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2698 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2699 addresseeRSync.setRevision( mLastAddressbookSync ); 2699 addresseeRSync.setRevision( mLastAddressbookSync );
2700 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2700 addresseeRSync.setCategories( i18n("SyncAddressee") );
2701 } 2701 }
2702 } 2702 }
2703 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2703 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2704 qDebug("FULLDATE 2"); 2704 qDebug("FULLDATE 2");
2705 fullDateRange = true; 2705 fullDateRange = true;
2706 } 2706 }
2707 if ( ! fullDateRange ) { 2707 if ( ! fullDateRange ) {
2708 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2708 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2709 2709
2710 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2710 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2711 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2711 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2712 fullDateRange = true; 2712 fullDateRange = true;
2713 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2713 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2714 } 2714 }
2715 } 2715 }
2716 // fullDateRange = true; // debug only! 2716 // fullDateRange = true; // debug only!
2717 if ( fullDateRange ) 2717 if ( fullDateRange )
2718 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2718 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2719 else 2719 else
2720 mLastAddressbookSync = addresseeLSync.revision(); 2720 mLastAddressbookSync = addresseeLSync.revision();
2721 // for resyncing if own file has changed 2721 // for resyncing if own file has changed
2722 // PENDING fixme later when implemented 2722 // PENDING fixme later when implemented
2723#if 0 2723#if 0
2724 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2724 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2725 mLastAddressbookSync = loadedFileVersion; 2725 mLastAddressbookSync = loadedFileVersion;
2726 qDebug("setting mLastAddressbookSync "); 2726 qDebug("setting mLastAddressbookSync ");
2727 } 2727 }
2728#endif 2728#endif
2729 2729
2730 //qDebug("*************************** "); 2730 //qDebug("*************************** ");
2731 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2731 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2732 QStringList er = remote->uidList(); 2732 QStringList er = remote->uidList();
2733 Addressee inR ;//= er.first(); 2733 Addressee inR ;//= er.first();
2734 Addressee inL; 2734 Addressee inL;
2735 QProgressBar bar( er.count(),0 ); 2735 QProgressBar bar( er.count(),0 );
2736 bar.setCaption (i18n("Syncing - close to abort!") ); 2736 bar.setCaption (i18n("Syncing - close to abort!") );
2737 2737
2738 int w = 300; 2738 int w = 300;
2739 if ( QApplication::desktop()->width() < 320 ) 2739 if ( QApplication::desktop()->width() < 320 )
2740 w = 220; 2740 w = 220;
2741 int h = bar.sizeHint().height() ; 2741 int h = bar.sizeHint().height() ;
2742 int dw = QApplication::desktop()->width(); 2742 int dw = QApplication::desktop()->width();
2743 int dh = QApplication::desktop()->height(); 2743 int dh = QApplication::desktop()->height();
2744 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2744 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2745 bar.show(); 2745 bar.show();
2746 int modulo = (er.count()/10)+1; 2746 int modulo = (er.count()/10)+1;
2747 int incCounter = 0; 2747 int incCounter = 0;
2748 while ( incCounter < er.count()) { 2748 while ( incCounter < er.count()) {
2749 if ( ! bar.isVisible() ) 2749 if ( ! bar.isVisible() )
2750 return false; 2750 return false;
2751 if ( incCounter % modulo == 0 ) 2751 if ( incCounter % modulo == 0 )
2752 bar.setProgress( incCounter ); 2752 bar.setProgress( incCounter );
2753 uid = er[ incCounter ]; 2753 uid = er[ incCounter ];
2754 bool skipIncidence = false; 2754 bool skipIncidence = false;
2755 if ( uid.left(19) == QString("last-syncAddressee-") ) 2755 if ( uid.left(19) == QString("last-syncAddressee-") )
2756 skipIncidence = true; 2756 skipIncidence = true;
2757 QString idS,OidS; 2757 QString idS,OidS;
2758 qApp->processEvents(); 2758 qApp->processEvents();
2759 if ( !skipIncidence ) { 2759 if ( !skipIncidence ) {
2760 inL = local->findByUid( uid ); 2760 inL = local->findByUid( uid );
2761 inR = remote->findByUid( uid ); 2761 inR = remote->findByUid( uid );
2762 //inL.setResource( 0 ); 2762 //inL.setResource( 0 );
2763 //inR.setResource( 0 ); 2763 //inR.setResource( 0 );
2764 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2764 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2765 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2765 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2766 //qDebug("take %d %s ", take, inL.summary().latin1()); 2766 //qDebug("take %d %s ", take, inL.summary().latin1());
2767 if ( take == 3 ) 2767 if ( take == 3 )
2768 return false; 2768 return false;
2769 if ( take == 1 ) {// take local 2769 if ( take == 1 ) {// take local
2770 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2770 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2771 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2771 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2772 local->insertAddressee( inL, false ); 2772 local->insertAddressee( inL, false );
2773 idS = inR.externalUID(); 2773 idS = inR.externalUID();
2774 OidS = inR.originalExternalUID(); 2774 OidS = inR.originalExternalUID();
2775 } 2775 }
2776 else 2776 else
2777 idS = inR.IDStr(); 2777 idS = inR.IDStr();
2778 remote->removeAddressee( inR ); 2778 remote->removeAddressee( inR );
2779 inR = inL; 2779 inR = inL;
2780 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2780 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2781 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2781 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2782 inR.setOriginalExternalUID( OidS ); 2782 inR.setOriginalExternalUID( OidS );
2783 inR.setExternalUID( idS ); 2783 inR.setExternalUID( idS );
2784 } else { 2784 } else {
2785 inR.setIDStr( idS ); 2785 inR.setIDStr( idS );
2786 } 2786 }
2787 inR.setResource( 0 ); 2787 inR.setResource( 0 );
2788 remote->insertAddressee( inR , false); 2788 remote->insertAddressee( inR , false);
2789 ++changedRemote; 2789 ++changedRemote;
2790 } else { // take == 2 take remote 2790 } else { // take == 2 take remote
2791 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2791 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2792 if ( inR.revision().date().year() < 2004 ) 2792 if ( inR.revision().date().year() < 2004 )
2793 inR.setRevision( modifiedCalendar ); 2793 inR.setRevision( modifiedCalendar );
2794 } 2794 }
2795 idS = inL.IDStr(); 2795 idS = inL.IDStr();
2796 local->removeAddressee( inL ); 2796 local->removeAddressee( inL );
2797 inL = inR; 2797 inL = inR;
2798 inL.setIDStr( idS ); 2798 inL.setIDStr( idS );
2799 inL.setResource( 0 ); 2799 inL.setResource( 0 );
2800 local->insertAddressee( inL , false ); 2800 local->insertAddressee( inL , false );
2801 ++changedLocal; 2801 ++changedLocal;
2802 } 2802 }
2803 } 2803 }
2804 } else { // no conflict 2804 } else { // no conflict
2805 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2805 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2806 QString des = addresseeLSync.note(); 2806 QString des = addresseeLSync.note();
2807 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2807 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2808 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2808 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2809 remote->insertAddressee( inR, false ); 2809 remote->insertAddressee( inR, false );
2810 ++deletedAddresseeR; 2810 ++deletedAddresseeR;
2811 } else { 2811 } else {
2812 inR.setRevision( modifiedCalendar ); 2812 inR.setRevision( modifiedCalendar );
2813 remote->insertAddressee( inR, false ); 2813 remote->insertAddressee( inR, false );
2814 inL = inR; 2814 inL = inR;
2815 inL.setResource( 0 ); 2815 inL.setResource( 0 );
2816 local->insertAddressee( inL , false); 2816 local->insertAddressee( inL , false);
2817 ++addedAddressee; 2817 ++addedAddressee;
2818 } 2818 }
2819 } else { 2819 } else {
2820 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2820 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2821 inR.setRevision( modifiedCalendar ); 2821 inR.setRevision( modifiedCalendar );
2822 remote->insertAddressee( inR, false ); 2822 remote->insertAddressee( inR, false );
2823 inR.setResource( 0 ); 2823 inR.setResource( 0 );
2824 local->insertAddressee( inR, false ); 2824 local->insertAddressee( inR, false );
2825 ++addedAddressee; 2825 ++addedAddressee;
2826 } else { 2826 } else {
2827 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2827 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2828 remote->removeAddressee( inR ); 2828 remote->removeAddressee( inR );
2829 ++deletedAddresseeR; 2829 ++deletedAddresseeR;
2830 } 2830 }
2831 } 2831 }
2832 } 2832 }
2833 } 2833 }
2834 ++incCounter; 2834 ++incCounter;
2835 } 2835 }
2836 er.clear(); 2836 er.clear();
2837 QStringList el = local->uidList(); 2837 QStringList el = local->uidList();
2838 modulo = (el.count()/10)+1; 2838 modulo = (el.count()/10)+1;
2839 bar.setCaption (i18n("Add / remove addressees") ); 2839 bar.setCaption (i18n("Add / remove addressees") );
2840 bar.setTotalSteps ( el.count() ) ; 2840 bar.setTotalSteps ( el.count() ) ;
2841 bar.show(); 2841 bar.show();
2842 incCounter = 0; 2842 incCounter = 0;
2843 while ( incCounter < el.count()) { 2843 while ( incCounter < el.count()) {
2844 qApp->processEvents(); 2844 qApp->processEvents();
2845 if ( ! bar.isVisible() ) 2845 if ( ! bar.isVisible() )
2846 return false; 2846 return false;
2847 if ( incCounter % modulo == 0 ) 2847 if ( incCounter % modulo == 0 )
2848 bar.setProgress( incCounter ); 2848 bar.setProgress( incCounter );
2849 uid = el[ incCounter ]; 2849 uid = el[ incCounter ];
2850 bool skipIncidence = false; 2850 bool skipIncidence = false;
2851 if ( uid.left(19) == QString("last-syncAddressee-") ) 2851 if ( uid.left(19) == QString("last-syncAddressee-") )
2852 skipIncidence = true; 2852 skipIncidence = true;
2853 if ( !skipIncidence ) { 2853 if ( !skipIncidence ) {
2854 inL = local->findByUid( uid ); 2854 inL = local->findByUid( uid );
2855 inR = remote->findByUid( uid ); 2855 inR = remote->findByUid( uid );
2856 if ( inR.isEmpty() ) { 2856 if ( inR.isEmpty() ) {
2857 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2857 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2858 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2858 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2859 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2859 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2860 local->removeAddressee( inL ); 2860 local->removeAddressee( inL );
2861 ++deletedAddresseeL; 2861 ++deletedAddresseeL;
2862 } else { 2862 } else {
2863 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2863 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2864 inL.removeID(mCurrentSyncDevice ); 2864 inL.removeID(mCurrentSyncDevice );
2865 ++addedAddresseeR; 2865 ++addedAddresseeR;
2866 inL.setRevision( modifiedCalendar ); 2866 inL.setRevision( modifiedCalendar );
2867 local->insertAddressee( inL, false ); 2867 local->insertAddressee( inL, false );
2868 inR = inL; 2868 inR = inL;
2869 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2869 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2870 inR.setResource( 0 ); 2870 inR.setResource( 0 );
2871 remote->insertAddressee( inR, false ); 2871 remote->insertAddressee( inR, false );
2872 } 2872 }
2873 } 2873 }
2874 } else { 2874 } else {
2875 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2875 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2876 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2876 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2877 local->removeAddressee( inL ); 2877 local->removeAddressee( inL );
2878 ++deletedAddresseeL; 2878 ++deletedAddresseeL;
2879 } else { 2879 } else {
2880 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2880 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2881 ++addedAddresseeR; 2881 ++addedAddresseeR;
2882 inL.setRevision( modifiedCalendar ); 2882 inL.setRevision( modifiedCalendar );
2883 local->insertAddressee( inL, false ); 2883 local->insertAddressee( inL, false );
2884 inR = inL; 2884 inR = inL;
2885 inR.setResource( 0 ); 2885 inR.setResource( 0 );
2886 remote->insertAddressee( inR, false ); 2886 remote->insertAddressee( inR, false );
2887 } 2887 }
2888 } 2888 }
2889 } 2889 }
2890 } 2890 }
2891 } 2891 }
2892 ++incCounter; 2892 ++incCounter;
2893 } 2893 }
2894 el.clear(); 2894 el.clear();
2895 bar.hide(); 2895 bar.hide();
2896 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2896 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2897 // get rid of micro seconds 2897 // get rid of micro seconds
2898 QTime t = mLastAddressbookSync.time(); 2898 QTime t = mLastAddressbookSync.time();
2899 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2899 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2900 addresseeLSync.setRevision( mLastAddressbookSync ); 2900 addresseeLSync.setRevision( mLastAddressbookSync );
2901 addresseeRSync.setRevision( mLastAddressbookSync ); 2901 addresseeRSync.setRevision( mLastAddressbookSync );
2902 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2902 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2903 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2903 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2904 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2904 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2905 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2905 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2906 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2906 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2907 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2907 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2908 addresseeRSync.setNote( "" ) ; 2908 addresseeRSync.setNote( "" ) ;
2909 addresseeLSync.setNote( "" ); 2909 addresseeLSync.setNote( "" );
2910 2910
2911 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2911 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2912 remote->insertAddressee( addresseeRSync, false ); 2912 remote->insertAddressee( addresseeRSync, false );
2913 local->insertAddressee( addresseeLSync, false ); 2913 local->insertAddressee( addresseeLSync, false );
2914 QString mes; 2914 QString mes;
2915 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2915 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2916 if ( KABPrefs::instance()->mShowSyncSummary ) { 2916 if ( KABPrefs::instance()->mShowSyncSummary ) {
2917 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2917 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2918 } 2918 }
2919 qDebug( mes ); 2919 qDebug( mes );
2920 return syncOK; 2920 return syncOK;
2921} 2921}
2922 2922
2923bool KABCore::syncAB(QString filename, int mode) 2923bool KABCore::syncAB(QString filename, int mode)
2924{ 2924{
2925 2925
2926 //pending prepare addresseeview for output 2926 //pending prepare addresseeview for output
2927 //pending detect, if remote file has REV field. if not switch to external sync 2927 //pending detect, if remote file has REV field. if not switch to external sync
2928 mGlobalSyncMode = SYNC_MODE_NORMAL; 2928 mGlobalSyncMode = SYNC_MODE_NORMAL;
2929 AddressBook abLocal(filename,"syncContact"); 2929 AddressBook abLocal(filename,"syncContact");
2930 bool syncOK = false; 2930 bool syncOK = false;
2931 if ( abLocal.load() ) { 2931 if ( abLocal.load() ) {
2932 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2932 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2933 bool external = false; 2933 bool external = false;
2934 bool isXML = false; 2934 bool isXML = false;
2935 if ( filename.right(4) == ".xml") { 2935 if ( filename.right(4) == ".xml") {
2936 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2936 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2937 isXML = true; 2937 isXML = true;
2938 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2938 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2939 } else { 2939 } else {
2940 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2940 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2941 if ( ! lse.isEmpty() ) { 2941 if ( ! lse.isEmpty() ) {
2942 if ( lse.familyName().left(4) == "!E: " ) 2942 if ( lse.familyName().left(4) == "!E: " )
2943 external = true; 2943 external = true;
2944 } else { 2944 } else {
2945 bool found = false; 2945 bool found = false;
2946 AddressBook::Iterator it; 2946 AddressBook::Iterator it;
2947 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2947 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2948 if ( (*it).revision().date().year() > 2003 ) { 2948 if ( (*it).revision().date().year() > 2003 ) {
2949 found = true; 2949 found = true;
2950 break; 2950 break;
2951 } 2951 }
2952 } 2952 }
2953 external = ! found; 2953 external = ! found;
2954 } 2954 }
2955 2955
2956 if ( external ) { 2956 if ( external ) {
2957 qDebug("Setting vcf mode to external "); 2957 qDebug("Setting vcf mode to external ");
2958 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2958 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2959 AddressBook::Iterator it; 2959 AddressBook::Iterator it;
2960 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2960 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2961 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2961 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2962 (*it).computeCsum( mCurrentSyncDevice ); 2962 (*it).computeCsum( mCurrentSyncDevice );
2963 } 2963 }
2964 } 2964 }
2965 } 2965 }
2966 //AddressBook::Iterator it; 2966 //AddressBook::Iterator it;
2967 //QStringList vcards; 2967 //QStringList vcards;
2968 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2968 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2969 // qDebug("Name %s ", (*it).familyName().latin1()); 2969 // qDebug("Name %s ", (*it).familyName().latin1());
2970 //} 2970 //}
2971 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2971 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2972 if ( syncOK ) { 2972 if ( syncOK ) {
2973 if ( KABPrefs::instance()->mWriteBackFile ) 2973 if ( KABPrefs::instance()->mWriteBackFile )
2974 { 2974 {
2975 if ( external ) 2975 if ( external )
2976 abLocal.removeSyncAddressees( !isXML); 2976 abLocal.removeSyncAddressees( !isXML);
2977 qDebug("Saving remote AB "); 2977 qDebug("Saving remote AB ");
2978 abLocal.saveAB(); 2978 abLocal.saveAB();
2979 if ( isXML ) { 2979 if ( isXML ) {
2980 // afterwrite processing 2980 // afterwrite processing
2981 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2981 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2982 } 2982 }
2983 } 2983 }
2984 } 2984 }
2985 setModified(); 2985 setModified();
2986 2986
2987 } 2987 }
2988 if ( syncOK ) 2988 if ( syncOK )
2989 mViewManager->refreshView(); 2989 mViewManager->refreshView();
2990 return syncOK; 2990 return syncOK;
2991#if 0 2991#if 0
2992 2992
2993 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2993 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2994 getEventViewerDialog()->setSyncMode( true ); 2994 getEventViewerDialog()->setSyncMode( true );
2995 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2995 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2996 getEventViewerDialog()->setSyncMode( false ); 2996 getEventViewerDialog()->setSyncMode( false );
2997 if ( syncOK ) { 2997 if ( syncOK ) {
2998 if ( KOPrefs::instance()->mWriteBackFile ) 2998 if ( KOPrefs::instance()->mWriteBackFile )
2999 { 2999 {
3000 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3000 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3001 storage->save(); 3001 storage->save();
3002 } 3002 }
3003 } 3003 }
3004 setModified(); 3004 setModified();
3005 } 3005 }
3006 3006
3007#endif 3007#endif
3008} 3008}
3009 3009
3010void KABCore::confSync() 3010void KABCore::confSync()
3011{ 3011{
3012 static KSyncPrefsDialog* sp = 0; 3012 static KSyncPrefsDialog* sp = 0;
3013 if ( ! sp ) { 3013 if ( ! sp ) {
3014 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 3014 sp = new KSyncPrefsDialog( this, "syncprefs", true );
3015 } 3015 }
3016 sp->usrReadConfig(); 3016 sp->usrReadConfig();
3017#ifndef DESKTOP_VERSION 3017#ifndef DESKTOP_VERSION
3018 sp->showMaximized(); 3018 sp->showMaximized();
3019#else 3019#else
3020 sp->show(); 3020 sp->show();
3021#endif 3021#endif
3022 sp->exec(); 3022 sp->exec();
3023 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 3023 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
3024 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 3024 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
3025 fillSyncMenu(); 3025 fillSyncMenu();
3026} 3026}
3027void KABCore::syncSharp() 3027void KABCore::syncSharp()
3028{ 3028{
3029 if ( ! syncExternal("sharp") )
3030 qDebug("ERROR sync sharp ");;
3031}
3032bool KABCore::syncExternal(QString resource)
3033{
3029 if ( mModified ) 3034 if ( mModified )
3030 save(); 3035 save();
3031 qDebug("pending syncSharp() "); 3036 if ( KABPrefs::instance()->mAskForPreferences )
3032 //mView->syncSharp(); 3037 edit_sync_options();
3033 setModified(); 3038 qDebug("syncSharp() ");
3039 AddressBook abLocal( resource,"syncContact");
3040 bool syncOK = false;
3041 if ( abLocal.load() ) {
3042 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3043 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3044 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
3045 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs );
3046 if ( syncOK ) {
3047 if ( KABPrefs::instance()->mWriteBackFile ) {
3048 abLocal.saveAB();
3049 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
3050 }
3051 }
3052 setModified();
3053 }
3054 if ( syncOK )
3055 mViewManager->refreshView();
3056 return syncOK;
3034 3057
3035} 3058}
3036void KABCore::syncPhone() 3059void KABCore::syncPhone()
3037{ 3060{
3038 if ( mModified ) 3061 if ( mModified )
3039 save(); 3062 save();
3040 qDebug("pending syncPhone(); "); 3063 qDebug("pending syncPhone(); ");
3041 //mView->syncPhone(); 3064 //mView->syncPhone();
3042 setModified(); 3065 setModified();
3043 3066
3044} 3067}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index f01f306..e89bf41 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,484 +1,485 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32 32
33#include <qwidget.h> 33#include <qwidget.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35 35
36namespace KABC { 36namespace KABC {
37class AddressBook; 37class AddressBook;
38} 38}
39 39
40#ifndef KAB_EMBEDDED 40#ifndef KAB_EMBEDDED
41class KAboutData; 41class KAboutData;
42class KConfig; 42class KConfig;
43 43
44class KAddressBookService; 44class KAddressBookService;
45class LDAPSearchDialog; 45class LDAPSearchDialog;
46#else //KAB_EMBEDDED 46#else //KAB_EMBEDDED
47class KAddressBookMain; 47class KAddressBookMain;
48//US class QAction; 48//US class QAction;
49#endif //KAB_EMBEDDED 49#endif //KAB_EMBEDDED
50class KCMultiDialog; 50class KCMultiDialog;
51class KXMLGUIClient; 51class KXMLGUIClient;
52class ExtensionManager; 52class ExtensionManager;
53class XXPortManager; 53class XXPortManager;
54class JumpButtonBar; 54class JumpButtonBar;
55class IncSearchWidget; 55class IncSearchWidget;
56class KDGanttMinimizeSplitter; 56class KDGanttMinimizeSplitter;
57class KAction; 57class KAction;
58class KActionCollection; 58class KActionCollection;
59class KToggleAction; 59class KToggleAction;
60class KSyncProfile; 60class KSyncProfile;
61 61
62class QAction; 62class QAction;
63class QMenuBar; 63class QMenuBar;
64class QSplitter; 64class QSplitter;
65class ViewContainer; 65class ViewContainer;
66class ViewManager; 66class ViewManager;
67class AddresseeEditorDialog; 67class AddresseeEditorDialog;
68class Ir; 68class Ir;
69 69
70class KABCore : public QWidget 70class KABCore : public QWidget
71{ 71{
72 Q_OBJECT 72 Q_OBJECT
73 73
74 public: 74 public:
75 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 75 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
76 76
77 77
78 ~KABCore(); 78 ~KABCore();
79 79
80 80
81#ifdef KAB_EMBEDDED 81#ifdef KAB_EMBEDDED
82 //US added functionality 82 //US added functionality
83 QPopupMenu* getViewMenu() {return viewMenu;} 83 QPopupMenu* getViewMenu() {return viewMenu;}
84 QPopupMenu* getFilterMenu() {return filterMenu;} 84 QPopupMenu* getFilterMenu() {return filterMenu;}
85 QPopupMenu* getSettingsMenu() {return settingsMenu;} 85 QPopupMenu* getSettingsMenu() {return settingsMenu;}
86 void addActionsManually(); 86 void addActionsManually();
87#endif //KAB_EMBEDDED 87#endif //KAB_EMBEDDED
88 /** 88 /**
89 Restores the global settings. 89 Restores the global settings.
90 */ 90 */
91 void restoreSettings(); 91 void restoreSettings();
92 92
93 /** 93 /**
94 Saves the global settings. 94 Saves the global settings.
95 */ 95 */
96 void saveSettings(); 96 void saveSettings();
97 97
98 /** 98 /**
99 Returns a pointer to the StdAddressBook of the application. 99 Returns a pointer to the StdAddressBook of the application.
100 */ 100 */
101 KABC::AddressBook *addressBook() const; 101 KABC::AddressBook *addressBook() const;
102 102
103 /** 103 /**
104 Returns a pointer to the KConfig object of the application. 104 Returns a pointer to the KConfig object of the application.
105 */ 105 */
106 static KConfig *config(); 106 static KConfig *config();
107 107
108 /** 108 /**
109 Returns a pointer to the global KActionCollection object. So 109 Returns a pointer to the global KActionCollection object. So
110 other classes can register their actions easily. 110 other classes can register their actions easily.
111 */ 111 */
112 KActionCollection *actionCollection() const; 112 KActionCollection *actionCollection() const;
113 113
114 /** 114 /**
115 Returns the current search field of the Incremental Search Widget. 115 Returns the current search field of the Incremental Search Widget.
116 */ 116 */
117 KABC::Field *currentSearchField() const; 117 KABC::Field *currentSearchField() const;
118 118
119 /** 119 /**
120 Returns the uid list of the currently selected contacts. 120 Returns the uid list of the currently selected contacts.
121 */ 121 */
122 QStringList selectedUIDs() const; 122 QStringList selectedUIDs() const;
123 123
124 /** 124 /**
125 Displays the ResourceSelectDialog and returns the selected 125 Displays the ResourceSelectDialog and returns the selected
126 resource or a null pointer if no resource was selected by 126 resource or a null pointer if no resource was selected by
127 the user. 127 the user.
128 */ 128 */
129 KABC::Resource *requestResource( QWidget *parent ); 129 KABC::Resource *requestResource( QWidget *parent );
130 130
131#ifndef KAB_EMBEDDED 131#ifndef KAB_EMBEDDED
132 static KAboutData *createAboutData(); 132 static KAboutData *createAboutData();
133#endif //KAB_EMBEDDED 133#endif //KAB_EMBEDDED
134 134
135#ifdef KAB_EMBEDDED 135#ifdef KAB_EMBEDDED
136 inline QPopupMenu* getImportMenu() { return ImportMenu;} 136 inline QPopupMenu* getImportMenu() { return ImportMenu;}
137 inline QPopupMenu* getExportMenu() { return ExportMenu;} 137 inline QPopupMenu* getExportMenu() { return ExportMenu;}
138#endif //KAB_EMBEDDED 138#endif //KAB_EMBEDDED
139 139
140 public slots: 140 public slots:
141#ifdef KAB_EMBEDDED 141#ifdef KAB_EMBEDDED
142 void createAboutData(); 142 void createAboutData();
143#endif //KAB_EMBEDDED 143#endif //KAB_EMBEDDED
144 144
145 void statusMessage(QString, int time = 0 ); 145 void statusMessage(QString, int time = 0 );
146 void showLicence(); 146 void showLicence();
147 void faq(); 147 void faq();
148 148
149 /** 149 /**
150 Is called whenever a contact is selected in the view. 150 Is called whenever a contact is selected in the view.
151 */ 151 */
152 void setContactSelected( const QString &uid ); 152 void setContactSelected( const QString &uid );
153 153
154 /** 154 /**
155 Opens the preferred mail composer with all selected contacts as 155 Opens the preferred mail composer with all selected contacts as
156 arguments. 156 arguments.
157 */ 157 */
158 void sendMail(); 158 void sendMail();
159 159
160 /** 160 /**
161 Opens the preferred mail composer with the given contacts as 161 Opens the preferred mail composer with the given contacts as
162 arguments. 162 arguments.
163 */ 163 */
164 void sendMail( const QString& email ); 164 void sendMail( const QString& email );
165 165
166 166
167 void mailVCard(); 167 void mailVCard();
168 void mailVCard(const QStringList& uids); 168 void mailVCard(const QStringList& uids);
169 169
170 /** 170 /**
171 Beams the "WhoAmI contact. 171 Beams the "WhoAmI contact.
172 */ 172 */
173 void beamMySelf(); 173 void beamMySelf();
174 174
175 void beamVCard(); 175 void beamVCard();
176 void beamVCard(const QStringList& uids); 176 void beamVCard(const QStringList& uids);
177 void beamDone( Ir *ir ); 177 void beamDone( Ir *ir );
178 178
179 179
180 /** 180 /**
181 Starts the preferred web browser with the given URL as argument. 181 Starts the preferred web browser with the given URL as argument.
182 */ 182 */
183 void browse( const QString& url ); 183 void browse( const QString& url );
184 184
185 /** 185 /**
186 Select all contacts in the view. 186 Select all contacts in the view.
187 */ 187 */
188 void selectAllContacts(); 188 void selectAllContacts();
189 189
190 /** 190 /**
191 Deletes all selected contacts from the address book. 191 Deletes all selected contacts from the address book.
192 */ 192 */
193 void deleteContacts(); 193 void deleteContacts();
194 194
195 /** 195 /**
196 Deletes given contacts from the address book. 196 Deletes given contacts from the address book.
197 197
198 @param uids The uids of the contacts, which shall be deleted. 198 @param uids The uids of the contacts, which shall be deleted.
199 */ 199 */
200 void deleteContacts( const QStringList &uids ); 200 void deleteContacts( const QStringList &uids );
201 201
202 /** 202 /**
203 Copys the selected contacts into clipboard for later pasting. 203 Copys the selected contacts into clipboard for later pasting.
204 */ 204 */
205 void copyContacts(); 205 void copyContacts();
206 206
207 /** 207 /**
208 Cuts the selected contacts and stores them for later pasting. 208 Cuts the selected contacts and stores them for later pasting.
209 */ 209 */
210 void cutContacts(); 210 void cutContacts();
211 211
212 /** 212 /**
213 Paste contacts from clipboard into the address book. 213 Paste contacts from clipboard into the address book.
214 */ 214 */
215 void pasteContacts(); 215 void pasteContacts();
216 216
217 /** 217 /**
218 Paste given contacts into the address book. 218 Paste given contacts into the address book.
219 219
220 @param list The list of addressee, which shall be pasted. 220 @param list The list of addressee, which shall be pasted.
221 */ 221 */
222 void pasteContacts( KABC::Addressee::List &list ); 222 void pasteContacts( KABC::Addressee::List &list );
223 223
224 /** 224 /**
225 Sets the whoAmI contact, that is used by many other programs to 225 Sets the whoAmI contact, that is used by many other programs to
226 get personal information about the current user. 226 get personal information about the current user.
227 */ 227 */
228 void setWhoAmI(); 228 void setWhoAmI();
229 229
230 /** 230 /**
231 Displays the category dialog and applies the result to all 231 Displays the category dialog and applies the result to all
232 selected contacts. 232 selected contacts.
233 */ 233 */
234 void setCategories(); 234 void setCategories();
235 235
236 /** 236 /**
237 Sets the field list of the Incremental Search Widget. 237 Sets the field list of the Incremental Search Widget.
238 */ 238 */
239 void setSearchFields( const KABC::Field::List &fields ); 239 void setSearchFields( const KABC::Field::List &fields );
240 240
241 /** 241 /**
242 Search with the current search field for a contact, that matches 242 Search with the current search field for a contact, that matches
243 the given text, and selects it in the view. 243 the given text, and selects it in the view.
244 */ 244 */
245 void incrementalSearch( const QString& text ); 245 void incrementalSearch( const QString& text );
246 246
247 /** 247 /**
248 Marks the address book as modified. 248 Marks the address book as modified.
249 */ 249 */
250 void setModified(); 250 void setModified();
251 /** 251 /**
252 Marks the address book as modified without refreshing the view. 252 Marks the address book as modified without refreshing the view.
253 */ 253 */
254 void setModifiedWOrefresh(); 254 void setModifiedWOrefresh();
255 255
256 /** 256 /**
257 Marks the address book as modified concerning the argument. 257 Marks the address book as modified concerning the argument.
258 */ 258 */
259 void setModified( bool modified ); 259 void setModified( bool modified );
260 260
261 /** 261 /**
262 Returns whether the address book is modified. 262 Returns whether the address book is modified.
263 */ 263 */
264 bool modified() const; 264 bool modified() const;
265 265
266 /** 266 /**
267 Called whenever an contact is modified in the contact editor 267 Called whenever an contact is modified in the contact editor
268 dialog or the quick edit. 268 dialog or the quick edit.
269 */ 269 */
270 void contactModified( const KABC::Addressee &addr ); 270 void contactModified( const KABC::Addressee &addr );
271 271
272 /** 272 /**
273 DCOP METHODS. 273 DCOP METHODS.
274 */ 274 */
275 void addEmail( QString addr ); 275 void addEmail( QString addr );
276 void importVCard( const KURL& url, bool showPreview ); 276 void importVCard( const KURL& url, bool showPreview );
277 void importVCard( const QString& vCard, bool showPreview ); 277 void importVCard( const QString& vCard, bool showPreview );
278 void newContact(); 278 void newContact();
279 QString getNameByPhone( const QString& phone ); 279 QString getNameByPhone( const QString& phone );
280 /** 280 /**
281 END DCOP METHODS 281 END DCOP METHODS
282 */ 282 */
283 283
284 /** 284 /**
285 Saves the contents of the AddressBook back to disk. 285 Saves the contents of the AddressBook back to disk.
286 */ 286 */
287 void save(); 287 void save();
288 288
289 /** 289 /**
290 Undos the last command using the undo stack. 290 Undos the last command using the undo stack.
291 */ 291 */
292 void undo(); 292 void undo();
293 293
294 /** 294 /**
295 Redos the last command that was undone, using the redo stack. 295 Redos the last command that was undone, using the redo stack.
296 */ 296 */
297 void redo(); 297 void redo();
298 298
299 /** 299 /**
300 Shows the edit dialog for the given uid. If the uid is QString::null, 300 Shows the edit dialog for the given uid. If the uid is QString::null,
301 the method will try to find a selected addressee in the view. 301 the method will try to find a selected addressee in the view.
302 */ 302 */
303 void editContact( const QString &uid /*US = QString::null*/ ); 303 void editContact( const QString &uid /*US = QString::null*/ );
304//US added a second method without defaultparameter 304//US added a second method without defaultparameter
305 void editContact2(); 305 void editContact2();
306 306
307 /** 307 /**
308 Shows or edits the detail view for the given uid. If the uid is QString::null, 308 Shows or edits the detail view for the given uid. If the uid is QString::null,
309 the method will try to find a selected addressee in the view. 309 the method will try to find a selected addressee in the view.
310 */ 310 */
311 void executeContact( const QString &uid /*US = QString::null*/ ); 311 void executeContact( const QString &uid /*US = QString::null*/ );
312 312
313 /** 313 /**
314 Launches the configuration dialog. 314 Launches the configuration dialog.
315 */ 315 */
316 void openConfigDialog(); 316 void openConfigDialog();
317 317
318 /** 318 /**
319 Launches the ldap search dialog. 319 Launches the ldap search dialog.
320 */ 320 */
321 void openLDAPDialog(); 321 void openLDAPDialog();
322 322
323 /** 323 /**
324 Creates a KAddressBookPrinter, which will display the print 324 Creates a KAddressBookPrinter, which will display the print
325 dialog and do the printing. 325 dialog and do the printing.
326 */ 326 */
327 void print(); 327 void print();
328 328
329 /** 329 /**
330 Registers a new GUI client, so plugins can register its actions. 330 Registers a new GUI client, so plugins can register its actions.
331 */ 331 */
332 void addGUIClient( KXMLGUIClient *client ); 332 void addGUIClient( KXMLGUIClient *client );
333 333
334 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 334 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
335 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 335 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
336 336
337 337
338 signals: 338 signals:
339 void contactSelected( const QString &name ); 339 void contactSelected( const QString &name );
340 void contactSelected( const QPixmap &pixmap ); 340 void contactSelected( const QPixmap &pixmap );
341 public slots: 341 public slots:
342 void setDetailsVisible( bool visible ); 342 void setDetailsVisible( bool visible );
343 void setDetailsToState(); 343 void setDetailsToState();
344 void slotSyncMenu( int ); 344 void slotSyncMenu( int );
345 private slots: 345 private slots:
346 void setJumpButtonBarVisible( bool visible ); 346 void setJumpButtonBarVisible( bool visible );
347 void importFromOL(); 347 void importFromOL();
348 void extensionModified( const KABC::Addressee::List &list ); 348 void extensionModified( const KABC::Addressee::List &list );
349 void extensionChanged( int id ); 349 void extensionChanged( int id );
350 void clipboardDataChanged(); 350 void clipboardDataChanged();
351 void updateActionMenu(); 351 void updateActionMenu();
352 void configureKeyBindings(); 352 void configureKeyBindings();
353 void removeVoice(); 353 void removeVoice();
354#ifdef KAB_EMBEDDED 354#ifdef KAB_EMBEDDED
355 void configureResources(); 355 void configureResources();
356#endif //KAB_EMBEDDED 356#endif //KAB_EMBEDDED
357 357
358 void slotEditorDestroyed( const QString &uid ); 358 void slotEditorDestroyed( const QString &uid );
359 void configurationChanged(); 359 void configurationChanged();
360 void addressBookChanged(); 360 void addressBookChanged();
361 361
362 private: 362 private:
363 void initGUI(); 363 void initGUI();
364 void initActions(); 364 void initActions();
365 365
366 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 366 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
367 const char *name = 0 ); 367 const char *name = 0 );
368 368
369 KXMLGUIClient *mGUIClient; 369 KXMLGUIClient *mGUIClient;
370 370
371 KABC::AddressBook *mAddressBook; 371 KABC::AddressBook *mAddressBook;
372 372
373 ViewManager *mViewManager; 373 ViewManager *mViewManager;
374 // QSplitter *mDetailsSplitter; 374 // QSplitter *mDetailsSplitter;
375 KDGanttMinimizeSplitter *mExtensionBarSplitter; 375 KDGanttMinimizeSplitter *mExtensionBarSplitter;
376 ViewContainer *mDetails; 376 ViewContainer *mDetails;
377 KDGanttMinimizeSplitter* mMiniSplitter; 377 KDGanttMinimizeSplitter* mMiniSplitter;
378 XXPortManager *mXXPortManager; 378 XXPortManager *mXXPortManager;
379 JumpButtonBar *mJumpButtonBar; 379 JumpButtonBar *mJumpButtonBar;
380 IncSearchWidget *mIncSearchWidget; 380 IncSearchWidget *mIncSearchWidget;
381 ExtensionManager *mExtensionManager; 381 ExtensionManager *mExtensionManager;
382 382
383 KCMultiDialog *mConfigureDialog; 383 KCMultiDialog *mConfigureDialog;
384 384
385#ifndef KAB_EMBEDDED 385#ifndef KAB_EMBEDDED
386 LDAPSearchDialog *mLdapSearchDialog; 386 LDAPSearchDialog *mLdapSearchDialog;
387#endif //KAB_EMBEDDED 387#endif //KAB_EMBEDDED
388 // QDict<AddresseeEditorDialog> mEditorDict; 388 // QDict<AddresseeEditorDialog> mEditorDict;
389 AddresseeEditorDialog *mEditorDialog; 389 AddresseeEditorDialog *mEditorDialog;
390 bool mReadWrite; 390 bool mReadWrite;
391 bool mModified; 391 bool mModified;
392 bool mIsPart; 392 bool mIsPart;
393 bool mMultipleViewsAtOnce; 393 bool mMultipleViewsAtOnce;
394 394
395 395
396 //US file menu 396 //US file menu
397 KAction *mActionMail; 397 KAction *mActionMail;
398 KAction *mActionBeam; 398 KAction *mActionBeam;
399 KAction* mActionPrint; 399 KAction* mActionPrint;
400 KAction* mActionNewContact; 400 KAction* mActionNewContact;
401 KAction *mActionSave; 401 KAction *mActionSave;
402 KAction *mActionEditAddressee; 402 KAction *mActionEditAddressee;
403 KAction *mActionMailVCard; 403 KAction *mActionMailVCard;
404 KAction *mActionBeamVCard; 404 KAction *mActionBeamVCard;
405 405
406 KAction *mActionQuit; 406 KAction *mActionQuit;
407 407
408 //US edit menu 408 //US edit menu
409 KAction *mActionCopy; 409 KAction *mActionCopy;
410 KAction *mActionCut; 410 KAction *mActionCut;
411 KAction *mActionPaste; 411 KAction *mActionPaste;
412 KAction *mActionSelectAll; 412 KAction *mActionSelectAll;
413 KAction *mActionUndo; 413 KAction *mActionUndo;
414 KAction *mActionRedo; 414 KAction *mActionRedo;
415 KAction *mActionDelete; 415 KAction *mActionDelete;
416 416
417 //US settings menu 417 //US settings menu
418 KAction *mActionConfigResources; 418 KAction *mActionConfigResources;
419 KAction *mActionConfigKAddressbook; 419 KAction *mActionConfigKAddressbook;
420 KAction *mActionConfigShortcuts; 420 KAction *mActionConfigShortcuts;
421 KAction *mActionConfigureToolbars; 421 KAction *mActionConfigureToolbars;
422 KAction *mActionKeyBindings; 422 KAction *mActionKeyBindings;
423 KToggleAction *mActionJumpBar; 423 KToggleAction *mActionJumpBar;
424 KToggleAction *mActionDetails; 424 KToggleAction *mActionDetails;
425 KAction *mActionWhoAmI; 425 KAction *mActionWhoAmI;
426 KAction *mActionCategories; 426 KAction *mActionCategories;
427 KAction *mActionAboutKAddressbook; 427 KAction *mActionAboutKAddressbook;
428 KAction *mActionLicence; 428 KAction *mActionLicence;
429 KAction *mActionFaq; 429 KAction *mActionFaq;
430 430
431 KAction *mActionDeleteView; 431 KAction *mActionDeleteView;
432 432
433 QPopupMenu *viewMenu; 433 QPopupMenu *viewMenu;
434 QPopupMenu *filterMenu; 434 QPopupMenu *filterMenu;
435 QPopupMenu *settingsMenu; 435 QPopupMenu *settingsMenu;
436 QPopupMenu *changeMenu; 436 QPopupMenu *changeMenu;
437//US QAction *mActionSave; 437//US QAction *mActionSave;
438 QPopupMenu *ImportMenu; 438 QPopupMenu *ImportMenu;
439 QPopupMenu *ExportMenu; 439 QPopupMenu *ExportMenu;
440 //LR additional methods 440 //LR additional methods
441 KAction *mActionRemoveVoice; 441 KAction *mActionRemoveVoice;
442 KAction * mActionImportOL; 442 KAction * mActionImportOL;
443 443
444#ifndef KAB_EMBEDDED 444#ifndef KAB_EMBEDDED
445 KAddressBookService *mAddressBookService; 445 KAddressBookService *mAddressBookService;
446#endif //KAB_EMBEDDED 446#endif //KAB_EMBEDDED
447 447
448 class KABCorePrivate; 448 class KABCorePrivate;
449 KABCorePrivate *d; 449 KABCorePrivate *d;
450 bool mBlockSaveFlag; 450 bool mBlockSaveFlag;
451 451
452#ifdef KAB_EMBEDDED 452#ifdef KAB_EMBEDDED
453 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 453 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
454#endif //KAB_EMBEDDED 454#endif //KAB_EMBEDDED
455 // LR ******************************* 455 // LR *******************************
456 // sync stuff! 456 // sync stuff!
457 QPopupMenu *syncMenu; 457 QPopupMenu *syncMenu;
458 void fillSyncMenu(); 458 void fillSyncMenu();
459 QString mCurrentSyncDevice; 459 QString mCurrentSyncDevice;
460 QString mCurrentSyncName; 460 QString mCurrentSyncName;
461 void quickSyncLocalFile(); 461 void quickSyncLocalFile();
462 bool syncWithFile( QString fn , bool quick ); 462 bool syncWithFile( QString fn , bool quick );
463 void KABCore::syncLocalFile(); 463 void syncLocalFile();
464 void KABCore::syncPhone(); 464 void syncPhone();
465 void KABCore::syncSharp(); 465 void syncSharp();
466 bool syncExternal(QString);
466 void multiSync( bool askforPrefs ); 467 void multiSync( bool askforPrefs );
467 int mCurrentSyncProfile ; 468 int mCurrentSyncProfile ;
468 void syncRemote( KSyncProfile* prof, bool ask = true); 469 void syncRemote( KSyncProfile* prof, bool ask = true);
469 void edit_sync_options(); 470 void edit_sync_options();
470 bool syncAB(QString filename, int mode); 471 bool syncAB(QString filename, int mode);
471 int ringSync(); 472 int ringSync();
472 QString getPassword( ); 473 QString getPassword( );
473 int mGlobalSyncMode; 474 int mGlobalSyncMode;
474 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 475 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
475 KABC::Addressee getLastSyncAddressee(); 476 KABC::Addressee getLastSyncAddressee();
476 QDateTime mLastAddressbookSync; 477 QDateTime mLastAddressbookSync;
477 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 478 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
478 public slots: 479 public slots:
479 void confSync(); 480 void confSync();
480 // ********************* 481 // *********************
481 482
482}; 483};
483 484
484#endif 485#endif