summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-18 08:25:05 (UTC)
committer zautrix <zautrix>2004-09-18 08:25:05 (UTC)
commit983b010853dfadfec3638e2afd90e522985f67fb (patch) (unidiff)
treeb691b7664b9f6f23d0d92a0e05bf3e8cbcf2df67
parentdf03bd8c7ff6a738dd386001679542ae4b493a07 (diff)
downloadkdepimpi-983b010853dfadfec3638e2afd90e522985f67fb.zip
kdepimpi-983b010853dfadfec3638e2afd90e522985f67fb.tar.gz
kdepimpi-983b010853dfadfec3638e2afd90e522985f67fb.tar.bz2
more AB syncing
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp101
-rw-r--r--kabc/addressbook.h1
-rw-r--r--kaddressbook/kabcore.cpp95
-rw-r--r--kaddressbook/kabcore.h5
4 files changed, 186 insertions, 16 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 47d298a..70eda1b 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -141,248 +141,345 @@ bool AddressBook::Iterator::operator==( const Iterator &it )
141bool AddressBook::Iterator::operator!=( const Iterator &it ) 141bool AddressBook::Iterator::operator!=( const Iterator &it )
142{ 142{
143 return ( d->mIt != it.d->mIt ); 143 return ( d->mIt != it.d->mIt );
144} 144}
145 145
146 146
147AddressBook::ConstIterator::ConstIterator() 147AddressBook::ConstIterator::ConstIterator()
148{ 148{
149 d = new ConstIteratorData; 149 d = new ConstIteratorData;
150} 150}
151 151
152AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 152AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
153{ 153{
154 d = new ConstIteratorData; 154 d = new ConstIteratorData;
155 d->mIt = i.d->mIt; 155 d->mIt = i.d->mIt;
156} 156}
157 157
158AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 158AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
159{ 159{
160 if( this == &i ) return *this; // guard for self assignment 160 if( this == &i ) return *this; // guard for self assignment
161 delete d; // delete the old data because the Iterator was really constructed before 161 delete d; // delete the old data because the Iterator was really constructed before
162 d = new ConstIteratorData; 162 d = new ConstIteratorData;
163 d->mIt = i.d->mIt; 163 d->mIt = i.d->mIt;
164 return *this; 164 return *this;
165} 165}
166 166
167AddressBook::ConstIterator::~ConstIterator() 167AddressBook::ConstIterator::~ConstIterator()
168{ 168{
169 delete d; 169 delete d;
170} 170}
171 171
172const Addressee &AddressBook::ConstIterator::operator*() const 172const Addressee &AddressBook::ConstIterator::operator*() const
173{ 173{
174 return *(d->mIt); 174 return *(d->mIt);
175} 175}
176 176
177const Addressee* AddressBook::ConstIterator::operator->() const 177const Addressee* AddressBook::ConstIterator::operator->() const
178{ 178{
179 return &(*(d->mIt)); 179 return &(*(d->mIt));
180} 180}
181 181
182AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 182AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
183{ 183{
184 (d->mIt)++; 184 (d->mIt)++;
185 return *this; 185 return *this;
186} 186}
187 187
188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
189{ 189{
190 (d->mIt)++; 190 (d->mIt)++;
191 return *this; 191 return *this;
192} 192}
193 193
194AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 194AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
195{ 195{
196 (d->mIt)--; 196 (d->mIt)--;
197 return *this; 197 return *this;
198} 198}
199 199
200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
201{ 201{
202 (d->mIt)--; 202 (d->mIt)--;
203 return *this; 203 return *this;
204} 204}
205 205
206bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 206bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
207{ 207{
208 return ( d->mIt == it.d->mIt ); 208 return ( d->mIt == it.d->mIt );
209} 209}
210 210
211bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 211bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
212{ 212{
213 return ( d->mIt != it.d->mIt ); 213 return ( d->mIt != it.d->mIt );
214} 214}
215 215
216 216
217AddressBook::AddressBook() 217AddressBook::AddressBook()
218{ 218{
219 init(0, "contact"); 219 init(0, "contact");
220} 220}
221 221
222AddressBook::AddressBook( const QString &config ) 222AddressBook::AddressBook( const QString &config )
223{ 223{
224 init(config, "contact"); 224 init(config, "contact");
225} 225}
226 226
227AddressBook::AddressBook( const QString &config, const QString &family ) 227AddressBook::AddressBook( const QString &config, const QString &family )
228{ 228{
229 init(config, family); 229 init(config, family);
230 230
231} 231}
232 232
233// the default family is "contact" 233// the default family is "contact"
234void AddressBook::init(const QString &config, const QString &family ) 234void AddressBook::init(const QString &config, const QString &family )
235{ 235{
236 d = new AddressBookData; 236 d = new AddressBookData;
237 QString fami = family;
238 qDebug("new ab ");
237 if (config != 0) { 239 if (config != 0) {
240 qDebug("config != 0 ");
241 if ( family == "syncContact" ) {
242 qDebug("creating sync config ");
243 fami = "contact";
244 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
245 con->setGroup( "General" );
246 con->writeEntry( "ResourceKeys", QString("sync") );
247 con->writeEntry( "Standard", QString("sync") );
248 con->setGroup( "Resource_sync" );
249 con->writeEntry( "FileFormat", QString("vcard") );
250 con->writeEntry( "FileName", config );
251 con->writeEntry( "ResourceIdentifier", QString("sync") );
252 con->writeEntry( "ResourceName", QString("sync_res") );
253 con->writeEntry( "ResourceType", QString("file") );
254 //con->sync();
255 d->mConfig = con;
256 }
257 else
238 d->mConfig = new KConfig( locateLocal("config", config) ); 258 d->mConfig = new KConfig( locateLocal("config", config) );
239// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 259// qDebug("AddressBook::init 1 config=%s",config.latin1() );
240 } 260 }
241 else { 261 else {
242 d->mConfig = 0; 262 d->mConfig = 0;
243// qDebug("AddressBook::init 1 config=0"); 263// qDebug("AddressBook::init 1 config=0");
244 } 264 }
245 265
246//US d->mErrorHandler = 0; 266//US d->mErrorHandler = 0;
247 d->mManager = new KRES::Manager<Resource>( family, false ); 267 d->mManager = new KRES::Manager<Resource>( fami, false );
248 d->mManager->readConfig( d->mConfig ); 268 d->mManager->readConfig( d->mConfig );
269 if ( family == "syncContact" ) {
270 KRES::Manager<Resource> *manager = d->mManager;
271 KRES::Manager<Resource>::ActiveIterator it;
272 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
273 (*it)->setAddressBook( this );
274 if ( !(*it)->open() )
275 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
276 }
277 Resource *res = standardResource();
278 if ( !res ) {
279 qDebug("ERROR: no standard resource");
280 res = manager->createResource( "file" );
281 if ( res )
282 {
283 addResource( res );
284 }
285 else
286 qDebug(" No resource available!!!");
287 }
288 setStandardResource( res );
289 manager->writeConfig();
290 }
291 addCustomField( i18n( "Department" ), KABC::Field::Organization,
292 "X-Department", "KADDRESSBOOK" );
293 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
294 "X-Profession", "KADDRESSBOOK" );
295 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
296 "X-AssistantsName", "KADDRESSBOOK" );
297 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
298 "X-ManagersName", "KADDRESSBOOK" );
299 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
300 "X-SpousesName", "KADDRESSBOOK" );
301 addCustomField( i18n( "Office" ), KABC::Field::Personal,
302 "X-Office", "KADDRESSBOOK" );
303 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
304 "X-IMAddress", "KADDRESSBOOK" );
305 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
306 "X-Anniversary", "KADDRESSBOOK" );
307
308 //US added this field to become compatible with Opie/qtopia addressbook
309 // values can be "female" or "male" or "". An empty field represents undefined.
310 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
311 "X-Gender", "KADDRESSBOOK" );
312 addCustomField( i18n( "Children" ), KABC::Field::Personal,
313 "X-Children", "KADDRESSBOOK" );
314 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
315 "X-FreeBusyUrl", "KADDRESSBOOK" );
316 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
317 "X-ExternalID", "KADDRESSBOOK" );
249} 318}
250 319
251AddressBook::~AddressBook() 320AddressBook::~AddressBook()
252{ 321{
253 delete d->mConfig; d->mConfig = 0; 322 delete d->mConfig; d->mConfig = 0;
254 delete d->mManager; d->mManager = 0; 323 delete d->mManager; d->mManager = 0;
255//US delete d->mErrorHandler; d->mErrorHandler = 0; 324//US delete d->mErrorHandler; d->mErrorHandler = 0;
256 delete d; d = 0; 325 delete d; d = 0;
257} 326}
258 327
259bool AddressBook::load() 328bool AddressBook::load()
260{ 329{
261 330
262 331
263 clear(); 332 clear();
264 333
265 KRES::Manager<Resource>::ActiveIterator it; 334 KRES::Manager<Resource>::ActiveIterator it;
266 bool ok = true; 335 bool ok = true;
267 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 336 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
268 if ( !(*it)->load() ) { 337 if ( !(*it)->load() ) {
269 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 338 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
270 ok = false; 339 ok = false;
271 } 340 }
272 341
273 // mark all addressees as unchanged 342 // mark all addressees as unchanged
274 Addressee::List::Iterator addrIt; 343 Addressee::List::Iterator addrIt;
275 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) 344 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt )
276 (*addrIt).setChanged( false ); 345 (*addrIt).setChanged( false );
277 346
278 return ok; 347 return ok;
279} 348}
280 349
281bool AddressBook::save( Ticket *ticket ) 350bool AddressBook::save( Ticket *ticket )
282{ 351{
283 kdDebug(5700) << "AddressBook::save()"<< endl; 352 kdDebug(5700) << "AddressBook::save()"<< endl;
284 353
285 if ( ticket->resource() ) { 354 if ( ticket->resource() ) {
286 deleteRemovedAddressees(); 355 deleteRemovedAddressees();
287
288 return ticket->resource()->save( ticket ); 356 return ticket->resource()->save( ticket );
289 } 357 }
290 358
291 return false; 359 return false;
292} 360}
361bool AddressBook::saveAB()
362{
363 bool ok = true;
364
365 deleteRemovedAddressees();
366
367 KRES::Manager<Resource>::ActiveIterator it;
368 KRES::Manager<Resource> *manager = d->mManager;
369 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
370 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
371 Ticket *ticket = requestSaveTicket( *it );
372// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
373 if ( !ticket ) {
374 error( i18n( "Unable to save to resource '%1'. It is locked." )
375 .arg( (*it)->resourceName() ) );
376 return false;
377 }
378
379 //if ( !save( ticket ) )
380 if ( ticket->resource() ) {
381 if ( ! ticket->resource()->save( ticket ) )
382 ok = false;
383 } else
384 ok = false;
385
386 }
387 }
388 return ok;
389}
293 390
294AddressBook::Iterator AddressBook::begin() 391AddressBook::Iterator AddressBook::begin()
295{ 392{
296 Iterator it = Iterator(); 393 Iterator it = Iterator();
297 it.d->mIt = d->mAddressees.begin(); 394 it.d->mIt = d->mAddressees.begin();
298 return it; 395 return it;
299} 396}
300 397
301AddressBook::ConstIterator AddressBook::begin() const 398AddressBook::ConstIterator AddressBook::begin() const
302{ 399{
303 ConstIterator it = ConstIterator(); 400 ConstIterator it = ConstIterator();
304 it.d->mIt = d->mAddressees.begin(); 401 it.d->mIt = d->mAddressees.begin();
305 return it; 402 return it;
306} 403}
307 404
308AddressBook::Iterator AddressBook::end() 405AddressBook::Iterator AddressBook::end()
309{ 406{
310 Iterator it = Iterator(); 407 Iterator it = Iterator();
311 it.d->mIt = d->mAddressees.end(); 408 it.d->mIt = d->mAddressees.end();
312 return it; 409 return it;
313} 410}
314 411
315AddressBook::ConstIterator AddressBook::end() const 412AddressBook::ConstIterator AddressBook::end() const
316{ 413{
317 ConstIterator it = ConstIterator(); 414 ConstIterator it = ConstIterator();
318 it.d->mIt = d->mAddressees.end(); 415 it.d->mIt = d->mAddressees.end();
319 return it; 416 return it;
320} 417}
321 418
322void AddressBook::clear() 419void AddressBook::clear()
323{ 420{
324 d->mAddressees.clear(); 421 d->mAddressees.clear();
325} 422}
326 423
327Ticket *AddressBook::requestSaveTicket( Resource *resource ) 424Ticket *AddressBook::requestSaveTicket( Resource *resource )
328{ 425{
329 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 426 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
330 427
331 if ( !resource ) 428 if ( !resource )
332 { 429 {
333 qDebug("AddressBook::requestSaveTicket no resource" ); 430 qDebug("AddressBook::requestSaveTicket no resource" );
334 resource = standardResource(); 431 resource = standardResource();
335 } 432 }
336 433
337 KRES::Manager<Resource>::ActiveIterator it; 434 KRES::Manager<Resource>::ActiveIterator it;
338 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 435 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
339 if ( (*it) == resource ) { 436 if ( (*it) == resource ) {
340 if ( (*it)->readOnly() || !(*it)->isOpen() ) 437 if ( (*it)->readOnly() || !(*it)->isOpen() )
341 return 0; 438 return 0;
342 else 439 else
343 return (*it)->requestSaveTicket(); 440 return (*it)->requestSaveTicket();
344 } 441 }
345 } 442 }
346 443
347 return 0; 444 return 0;
348} 445}
349 446
350void AddressBook::insertAddressee( const Addressee &a ) 447void AddressBook::insertAddressee( const Addressee &a )
351{ 448{
352 Addressee::List::Iterator it; 449 Addressee::List::Iterator it;
353 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 450 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
354 if ( a.uid() == (*it).uid() ) { 451 if ( a.uid() == (*it).uid() ) {
355 bool changed = false; 452 bool changed = false;
356 Addressee addr = a; 453 Addressee addr = a;
357 if ( addr != (*it) ) 454 if ( addr != (*it) )
358 changed = true; 455 changed = true;
359 456
360 (*it) = a; 457 (*it) = a;
361 if ( (*it).resource() == 0 ) 458 if ( (*it).resource() == 0 )
362 (*it).setResource( standardResource() ); 459 (*it).setResource( standardResource() );
363 460
364 if ( changed ) { 461 if ( changed ) {
365 (*it).setRevision( QDateTime::currentDateTime() ); 462 (*it).setRevision( QDateTime::currentDateTime() );
366 (*it).setChanged( true ); 463 (*it).setChanged( true );
367 } 464 }
368 465
369 return; 466 return;
370 } 467 }
371 } 468 }
372 d->mAddressees.append( a ); 469 d->mAddressees.append( a );
373 Addressee& addr = d->mAddressees.last(); 470 Addressee& addr = d->mAddressees.last();
374 if ( addr.resource() == 0 ) 471 if ( addr.resource() == 0 )
375 addr.setResource( standardResource() ); 472 addr.setResource( standardResource() );
376 473
377 addr.setChanged( true ); 474 addr.setChanged( true );
378} 475}
379 476
380void AddressBook::removeAddressee( const Addressee &a ) 477void AddressBook::removeAddressee( const Addressee &a )
381{ 478{
382 Iterator it; 479 Iterator it;
383 for ( it = begin(); it != end(); ++it ) { 480 for ( it = begin(); it != end(); ++it ) {
384 if ( a.uid() == (*it).uid() ) { 481 if ( a.uid() == (*it).uid() ) {
385 removeAddressee( it ); 482 removeAddressee( it );
386 return; 483 return;
387 } 484 }
388 } 485 }
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index f89d7da..e43de31 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -48,192 +48,193 @@ class Ticket;
48 This class provides access to a collection of address book entries. 48 This class provides access to a collection of address book entries.
49*/ 49*/
50class AddressBook : public QObject 50class AddressBook : public QObject
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54 friend QDataStream &operator<<( QDataStream &, const AddressBook & ); 54 friend QDataStream &operator<<( QDataStream &, const AddressBook & );
55 friend QDataStream &operator>>( QDataStream &, AddressBook & ); 55 friend QDataStream &operator>>( QDataStream &, AddressBook & );
56 friend class StdAddressBook; 56 friend class StdAddressBook;
57 57
58 public: 58 public:
59 /** 59 /**
60 @short Address Book Iterator 60 @short Address Book Iterator
61 61
62 This class provides an iterator for address book entries. 62 This class provides an iterator for address book entries.
63 */ 63 */
64 class Iterator 64 class Iterator
65 { 65 {
66 public: 66 public:
67 Iterator(); 67 Iterator();
68 Iterator( const Iterator & ); 68 Iterator( const Iterator & );
69 ~Iterator(); 69 ~Iterator();
70 70
71 Iterator &operator=( const Iterator & ); 71 Iterator &operator=( const Iterator & );
72 const Addressee &operator*() const; 72 const Addressee &operator*() const;
73 Addressee &operator*(); 73 Addressee &operator*();
74 Addressee* operator->(); 74 Addressee* operator->();
75 Iterator &operator++(); 75 Iterator &operator++();
76 Iterator &operator++(int); 76 Iterator &operator++(int);
77 Iterator &operator--(); 77 Iterator &operator--();
78 Iterator &operator--(int); 78 Iterator &operator--(int);
79 bool operator==( const Iterator &it ); 79 bool operator==( const Iterator &it );
80 bool operator!=( const Iterator &it ); 80 bool operator!=( const Iterator &it );
81 81
82 struct IteratorData; 82 struct IteratorData;
83 IteratorData *d; 83 IteratorData *d;
84 }; 84 };
85 85
86 /** 86 /**
87 @short Address Book Const Iterator 87 @short Address Book Const Iterator
88 88
89 This class provides a const iterator for address book entries. 89 This class provides a const iterator for address book entries.
90 */ 90 */
91 class ConstIterator 91 class ConstIterator
92 { 92 {
93 public: 93 public:
94 ConstIterator(); 94 ConstIterator();
95 ConstIterator( const ConstIterator & ); 95 ConstIterator( const ConstIterator & );
96 ~ConstIterator(); 96 ~ConstIterator();
97 97
98 ConstIterator &operator=( const ConstIterator & ); 98 ConstIterator &operator=( const ConstIterator & );
99 const Addressee &operator*() const; 99 const Addressee &operator*() const;
100 const Addressee* operator->() const; 100 const Addressee* operator->() const;
101 ConstIterator &operator++(); 101 ConstIterator &operator++();
102 ConstIterator &operator++(int); 102 ConstIterator &operator++(int);
103 ConstIterator &operator--(); 103 ConstIterator &operator--();
104 ConstIterator &operator--(int); 104 ConstIterator &operator--(int);
105 bool operator==( const ConstIterator &it ); 105 bool operator==( const ConstIterator &it );
106 bool operator!=( const ConstIterator &it ); 106 bool operator!=( const ConstIterator &it );
107 107
108 struct ConstIteratorData; 108 struct ConstIteratorData;
109 ConstIteratorData *d; 109 ConstIteratorData *d;
110 }; 110 };
111 111
112 /** 112 /**
113 Constructs a address book object. 113 Constructs a address book object.
114 114
115 @param format File format class. 115 @param format File format class.
116 */ 116 */
117 AddressBook(); 117 AddressBook();
118 AddressBook( const QString &config ); 118 AddressBook( const QString &config );
119 AddressBook( const QString &config, const QString &family ); 119 AddressBook( const QString &config, const QString &family );
120 virtual ~AddressBook(); 120 virtual ~AddressBook();
121 121
122 /** 122 /**
123 Requests a ticket for saving the addressbook. Calling this function locks 123 Requests a ticket for saving the addressbook. Calling this function locks
124 the addressbook for all other processes. If the address book is already 124 the addressbook for all other processes. If the address book is already
125 locked the function returns 0. You need the returned @ref Ticket object 125 locked the function returns 0. You need the returned @ref Ticket object
126 for calling the @ref save() function. 126 for calling the @ref save() function.
127 127
128 @see save() 128 @see save()
129 */ 129 */
130 Ticket *requestSaveTicket( Resource *resource=0 ); 130 Ticket *requestSaveTicket( Resource *resource=0 );
131 131
132 /** 132 /**
133 Load address book from file. 133 Load address book from file.
134 */ 134 */
135 bool load(); 135 bool load();
136 136
137 /** 137 /**
138 Save address book. The address book is saved to the file, the Ticket 138 Save address book. The address book is saved to the file, the Ticket
139 object has been requested for by @ref requestSaveTicket(). 139 object has been requested for by @ref requestSaveTicket().
140 140
141 @param ticket a ticket object returned by @ref requestSaveTicket() 141 @param ticket a ticket object returned by @ref requestSaveTicket()
142 */ 142 */
143 bool save( Ticket *ticket ); 143 bool save( Ticket *ticket );
144 bool saveAB( );
144 145
145 /** 146 /**
146 Returns a iterator for first entry of address book. 147 Returns a iterator for first entry of address book.
147 */ 148 */
148 Iterator begin(); 149 Iterator begin();
149 150
150 /** 151 /**
151 Returns a const iterator for first entry of address book. 152 Returns a const iterator for first entry of address book.
152 */ 153 */
153 ConstIterator begin() const; 154 ConstIterator begin() const;
154 155
155 /** 156 /**
156 Returns a iterator for first entry of address book. 157 Returns a iterator for first entry of address book.
157 */ 158 */
158 Iterator end(); 159 Iterator end();
159 160
160 /** 161 /**
161 Returns a const iterator for first entry of address book. 162 Returns a const iterator for first entry of address book.
162 */ 163 */
163 ConstIterator end() const; 164 ConstIterator end() const;
164 165
165 /** 166 /**
166 Removes all entries from address book. 167 Removes all entries from address book.
167 */ 168 */
168 void clear(); 169 void clear();
169 170
170 /** 171 /**
171 Insert an Addressee object into address book. If an object with the same 172 Insert an Addressee object into address book. If an object with the same
172 unique id already exists in the address book it it replaced by the new 173 unique id already exists in the address book it it replaced by the new
173 one. If not the new object is appended to the address book. 174 one. If not the new object is appended to the address book.
174 */ 175 */
175 void insertAddressee( const Addressee & ); 176 void insertAddressee( const Addressee & );
176 177
177 /** 178 /**
178 Removes entry from the address book. 179 Removes entry from the address book.
179 */ 180 */
180 void removeAddressee( const Addressee & ); 181 void removeAddressee( const Addressee & );
181 182
182 /** 183 /**
183 This is like @ref removeAddressee() just above, with the difference that 184 This is like @ref removeAddressee() just above, with the difference that
184 the first element is a iterator, returned by @ref begin(). 185 the first element is a iterator, returned by @ref begin().
185 */ 186 */
186 void removeAddressee( const Iterator & ); 187 void removeAddressee( const Iterator & );
187 188
188 /** 189 /**
189 Find the specified entry in address book. Returns end(), if the entry 190 Find the specified entry in address book. Returns end(), if the entry
190 couldn't be found. 191 couldn't be found.
191 */ 192 */
192 Iterator find( const Addressee & ); 193 Iterator find( const Addressee & );
193 194
194 /** 195 /**
195 Find the entry specified by an unique id. Returns an empty Addressee 196 Find the entry specified by an unique id. Returns an empty Addressee
196 object, if the address book does not contain an entry with this id. 197 object, if the address book does not contain an entry with this id.
197 */ 198 */
198 Addressee findByUid( const QString & ); 199 Addressee findByUid( const QString & );
199 200
200 201
201 /** 202 /**
202 Returns a list of all addressees in the address book. This list can 203 Returns a list of all addressees in the address book. This list can
203 be sorted with @ref KABC::AddresseeList for example. 204 be sorted with @ref KABC::AddresseeList for example.
204 */ 205 */
205 Addressee::List allAddressees(); 206 Addressee::List allAddressees();
206 207
207 /** 208 /**
208 Find all entries with the specified name in the address book. Returns 209 Find all entries with the specified name in the address book. Returns
209 an empty list, if no entries could be found. 210 an empty list, if no entries could be found.
210 */ 211 */
211 Addressee::List findByName( const QString & ); 212 Addressee::List findByName( const QString & );
212 213
213 /** 214 /**
214 Find all entries with the specified email address in the address book. 215 Find all entries with the specified email address in the address book.
215 Returns an empty list, if no entries could be found. 216 Returns an empty list, if no entries could be found.
216 */ 217 */
217 Addressee::List findByEmail( const QString & ); 218 Addressee::List findByEmail( const QString & );
218 219
219 /** 220 /**
220 Find all entries wich have the specified category in the address book. 221 Find all entries wich have the specified category in the address book.
221 Returns an empty list, if no entries could be found. 222 Returns an empty list, if no entries could be found.
222 */ 223 */
223 Addressee::List findByCategory( const QString & ); 224 Addressee::List findByCategory( const QString & );
224 225
225 /** 226 /**
226 Return a string identifying this addressbook. 227 Return a string identifying this addressbook.
227 */ 228 */
228 virtual QString identifier(); 229 virtual QString identifier();
229 230
230 /** 231 /**
231 Used for debug output. 232 Used for debug output.
232 */ 233 */
233 void dump() const; 234 void dump() const;
234 235
235 void emitAddressBookLocked() { emit addressBookLocked( this ); } 236 void emitAddressBookLocked() { emit addressBookLocked( this ); }
236 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 237 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
237 void emitAddressBookChanged() { emit addressBookChanged( this ); } 238 void emitAddressBookChanged() { emit addressBookChanged( this ); }
238 239
239 /** 240 /**
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 49c3b19..e912941 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -55,249 +55,252 @@ $Id$
55#include <kmessagebox.h> 55#include <kmessagebox.h>
56#include <kprinter.h> 56#include <kprinter.h>
57#include <kprotocolinfo.h> 57#include <kprotocolinfo.h>
58#include <kresources/selectdialog.h> 58#include <kresources/selectdialog.h>
59#include <kstandarddirs.h> 59#include <kstandarddirs.h>
60#include <ktempfile.h> 60#include <ktempfile.h>
61#include <kxmlguiclient.h> 61#include <kxmlguiclient.h>
62#include <kaboutdata.h> 62#include <kaboutdata.h>
63#include <libkdepim/categoryselectdialog.h> 63#include <libkdepim/categoryselectdialog.h>
64 64
65#include "addresseeutil.h" 65#include "addresseeutil.h"
66#include "addresseeeditordialog.h" 66#include "addresseeeditordialog.h"
67#include "extensionmanager.h" 67#include "extensionmanager.h"
68#include "kstdaction.h" 68#include "kstdaction.h"
69#include "kaddressbookservice.h" 69#include "kaddressbookservice.h"
70#include "ldapsearchdialog.h" 70#include "ldapsearchdialog.h"
71#include "printing/printingwizard.h" 71#include "printing/printingwizard.h"
72#else // KAB_EMBEDDED 72#else // KAB_EMBEDDED
73 73
74#include <kapplication.h> 74#include <kapplication.h>
75#include "KDGanttMinimizeSplitter.h" 75#include "KDGanttMinimizeSplitter.h"
76#include "kaddressbookmain.h" 76#include "kaddressbookmain.h"
77#include "kactioncollection.h" 77#include "kactioncollection.h"
78#include "addresseedialog.h" 78#include "addresseedialog.h"
79//US 79//US
80#include <addresseeview.h> 80#include <addresseeview.h>
81 81
82#include <qapp.h> 82#include <qapp.h>
83#include <qmenubar.h> 83#include <qmenubar.h>
84//#include <qtoolbar.h> 84//#include <qtoolbar.h>
85#include <qmessagebox.h> 85#include <qmessagebox.h>
86#include <kdebug.h> 86#include <kdebug.h>
87#include <kiconloader.h> // needed for SmallIcon 87#include <kiconloader.h> // needed for SmallIcon
88#include <kresources/kcmkresources.h> 88#include <kresources/kcmkresources.h>
89#include <ktoolbar.h> 89#include <ktoolbar.h>
90 90
91 91
92//#include <qlabel.h> 92//#include <qlabel.h>
93 93
94 94
95#ifndef DESKTOP_VERSION 95#ifndef DESKTOP_VERSION
96#include <qpe/ir.h> 96#include <qpe/ir.h>
97#include <qpe/qpemenubar.h> 97#include <qpe/qpemenubar.h>
98#include <qtopia/qcopenvelope_qws.h> 98#include <qtopia/qcopenvelope_qws.h>
99#else 99#else
100 100
101#include <qmenubar.h> 101#include <qmenubar.h>
102#endif 102#endif
103 103
104#endif // KAB_EMBEDDED 104#endif // KAB_EMBEDDED
105#include "kcmconfigs/kcmkabconfig.h" 105#include "kcmconfigs/kcmkabconfig.h"
106#include "kcmconfigs/kcmkdepimconfig.h" 106#include "kcmconfigs/kcmkdepimconfig.h"
107#include "kpimglobalprefs.h" 107#include "kpimglobalprefs.h"
108#include "externalapphandler.h" 108#include "externalapphandler.h"
109 109
110 110
111#include <kresources/selectdialog.h> 111#include <kresources/selectdialog.h>
112#include <kmessagebox.h> 112#include <kmessagebox.h>
113 113
114#include <picture.h> 114#include <picture.h>
115#include <resource.h> 115#include <resource.h>
116 116
117//US#include <qsplitter.h> 117//US#include <qsplitter.h>
118#include <qmap.h> 118#include <qmap.h>
119#include <qdir.h> 119#include <qdir.h>
120#include <qfile.h> 120#include <qfile.h>
121#include <qvbox.h> 121#include <qvbox.h>
122#include <qlayout.h> 122#include <qlayout.h>
123#include <qclipboard.h> 123#include <qclipboard.h>
124#include <qtextstream.h> 124#include <qtextstream.h>
125 125
126#include <libkdepim/categoryselectdialog.h> 126#include <libkdepim/categoryselectdialog.h>
127#include <kabc/vcardconverter.h> 127#include <kabc/vcardconverter.h>
128 128
129 129
130#include "addresseeutil.h" 130#include "addresseeutil.h"
131#include "undocmds.h" 131#include "undocmds.h"
132#include "addresseeeditordialog.h" 132#include "addresseeeditordialog.h"
133#include "viewmanager.h" 133#include "viewmanager.h"
134#include "details/detailsviewcontainer.h" 134#include "details/detailsviewcontainer.h"
135#include "kabprefs.h" 135#include "kabprefs.h"
136#include "xxportmanager.h" 136#include "xxportmanager.h"
137#include "incsearchwidget.h" 137#include "incsearchwidget.h"
138#include "jumpbuttonbar.h" 138#include "jumpbuttonbar.h"
139#include "extensionmanager.h" 139#include "extensionmanager.h"
140#include "addresseeconfig.h" 140#include "addresseeconfig.h"
141#include <kcmultidialog.h> 141#include <kcmultidialog.h>
142 142
143#ifdef _WIN32_ 143#ifdef _WIN32_
144 144
145#include "kaimportoldialog.h" 145#include "kaimportoldialog.h"
146#else 146#else
147#include <unistd.h> 147#include <unistd.h>
148#endif 148#endif
149// sync includes 149// sync includes
150#include <libkdepim/ksyncprofile.h> 150#include <libkdepim/ksyncprofile.h>
151#include <libkdepim/ksyncprefsdialog.h>
151 152
152 153
153bool pasteWithNewUid = true; 154bool pasteWithNewUid = true;
154 155
155#ifdef KAB_EMBEDDED 156#ifdef KAB_EMBEDDED
156KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 157KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
157 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 158 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
158 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 159 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
159 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 160 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
160#else //KAB_EMBEDDED 161#else //KAB_EMBEDDED
161KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 162KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
162 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 163 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
163 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 164 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
164 mReadWrite( readWrite ), mModified( false ) 165 mReadWrite( readWrite ), mModified( false )
165#endif //KAB_EMBEDDED 166#endif //KAB_EMBEDDED
166{ 167{
167 168
168 mBlockSaveFlag = false; 169 mBlockSaveFlag = false;
169 mExtensionBarSplitter = 0; 170 mExtensionBarSplitter = 0;
170 mIsPart = !parent->inherits( "KAddressBookMain" ); 171 mIsPart = !parent->inherits( "KAddressBookMain" );
171 172
172 mAddressBook = KABC::StdAddressBook::self(); 173 mAddressBook = KABC::StdAddressBook::self();
173 KABC::StdAddressBook::setAutomaticSave( false ); 174 KABC::StdAddressBook::setAutomaticSave( false );
174 175
175#ifndef KAB_EMBEDDED 176#ifndef KAB_EMBEDDED
176 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 177 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
177#endif //KAB_EMBEDDED 178#endif //KAB_EMBEDDED
178 179
179 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 180 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
180 SLOT( addressBookChanged() ) ); 181 SLOT( addressBookChanged() ) );
181 182
183#if 0
184 // LP moved to addressbook init method
182 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 185 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
183 "X-Department", "KADDRESSBOOK" ); 186 "X-Department", "KADDRESSBOOK" );
184 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 187 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
185 "X-Profession", "KADDRESSBOOK" ); 188 "X-Profession", "KADDRESSBOOK" );
186 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 189 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
187 "X-AssistantsName", "KADDRESSBOOK" ); 190 "X-AssistantsName", "KADDRESSBOOK" );
188 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 191 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
189 "X-ManagersName", "KADDRESSBOOK" ); 192 "X-ManagersName", "KADDRESSBOOK" );
190 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 193 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
191 "X-SpousesName", "KADDRESSBOOK" ); 194 "X-SpousesName", "KADDRESSBOOK" );
192 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 195 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
193 "X-Office", "KADDRESSBOOK" ); 196 "X-Office", "KADDRESSBOOK" );
194 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 197 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
195 "X-IMAddress", "KADDRESSBOOK" ); 198 "X-IMAddress", "KADDRESSBOOK" );
196 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 199 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
197 "X-Anniversary", "KADDRESSBOOK" ); 200 "X-Anniversary", "KADDRESSBOOK" );
198 201
199 //US added this field to become compatible with Opie/qtopia addressbook 202 //US added this field to become compatible with Opie/qtopia addressbook
200 // values can be "female" or "male" or "". An empty field represents undefined. 203 // values can be "female" or "male" or "". An empty field represents undefined.
201 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 204 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
202 "X-Gender", "KADDRESSBOOK" ); 205 "X-Gender", "KADDRESSBOOK" );
203 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 206 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
204 "X-Children", "KADDRESSBOOK" ); 207 "X-Children", "KADDRESSBOOK" );
205 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 208 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
206 "X-FreeBusyUrl", "KADDRESSBOOK" ); 209 "X-FreeBusyUrl", "KADDRESSBOOK" );
207 210#endif
208 initGUI(); 211 initGUI();
209 212
210 mIncSearchWidget->setFocus(); 213 mIncSearchWidget->setFocus();
211 214
212 215
213 connect( mViewManager, SIGNAL( selected( const QString& ) ), 216 connect( mViewManager, SIGNAL( selected( const QString& ) ),
214 SLOT( setContactSelected( const QString& ) ) ); 217 SLOT( setContactSelected( const QString& ) ) );
215 connect( mViewManager, SIGNAL( executed( const QString& ) ), 218 connect( mViewManager, SIGNAL( executed( const QString& ) ),
216 SLOT( executeContact( const QString& ) ) ); 219 SLOT( executeContact( const QString& ) ) );
217 220
218 connect( mViewManager, SIGNAL( deleteRequest( ) ), 221 connect( mViewManager, SIGNAL( deleteRequest( ) ),
219 SLOT( deleteContacts( ) ) ); 222 SLOT( deleteContacts( ) ) );
220 connect( mViewManager, SIGNAL( modified() ), 223 connect( mViewManager, SIGNAL( modified() ),
221 SLOT( setModified() ) ); 224 SLOT( setModified() ) );
222 225
223 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 226 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
224 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 227 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
225 228
226 connect( mXXPortManager, SIGNAL( modified() ), 229 connect( mXXPortManager, SIGNAL( modified() ),
227 SLOT( setModified() ) ); 230 SLOT( setModified() ) );
228 231
229 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 232 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
230 SLOT( incrementalSearch( const QString& ) ) ); 233 SLOT( incrementalSearch( const QString& ) ) );
231 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 234 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
232 mJumpButtonBar, SLOT( recreateButtons() ) ); 235 mJumpButtonBar, SLOT( recreateButtons() ) );
233 236
234 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 237 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
235 SLOT( sendMail( const QString& ) ) ); 238 SLOT( sendMail( const QString& ) ) );
236 239
237 240
238 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 241 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
239 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 242 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
240 243
241 244
242#ifndef KAB_EMBEDDED 245#ifndef KAB_EMBEDDED
243 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 246 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
244 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 247 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
245 248
246 connect( mDetails, SIGNAL( browse( const QString& ) ), 249 connect( mDetails, SIGNAL( browse( const QString& ) ),
247 SLOT( browse( const QString& ) ) ); 250 SLOT( browse( const QString& ) ) );
248 251
249 252
250 mAddressBookService = new KAddressBookService( this ); 253 mAddressBookService = new KAddressBookService( this );
251 254
252#endif //KAB_EMBEDDED 255#endif //KAB_EMBEDDED
253 mEditorDialog = 0; 256 mEditorDialog = 0;
254 createAddresseeEditorDialog( this ); 257 createAddresseeEditorDialog( this );
255 setModified( false ); 258 setModified( false );
256} 259}
257 260
258KABCore::~KABCore() 261KABCore::~KABCore()
259{ 262{
260 // save(); 263 // save();
261 //saveSettings(); 264 //saveSettings();
262 //KABPrefs::instance()->writeConfig(); 265 //KABPrefs::instance()->writeConfig();
263 delete AddresseeConfig::instance(); 266 delete AddresseeConfig::instance();
264 mAddressBook = 0; 267 mAddressBook = 0;
265 KABC::StdAddressBook::close(); 268 KABC::StdAddressBook::close();
266} 269}
267 270
268void KABCore::restoreSettings() 271void KABCore::restoreSettings()
269{ 272{
270 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 273 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
271 274
272 bool state; 275 bool state;
273 276
274 if (mMultipleViewsAtOnce) 277 if (mMultipleViewsAtOnce)
275 state = KABPrefs::instance()->mDetailsPageVisible; 278 state = KABPrefs::instance()->mDetailsPageVisible;
276 else 279 else
277 state = false; 280 state = false;
278 281
279 mActionDetails->setChecked( state ); 282 mActionDetails->setChecked( state );
280 setDetailsVisible( state ); 283 setDetailsVisible( state );
281 284
282 state = KABPrefs::instance()->mJumpButtonBarVisible; 285 state = KABPrefs::instance()->mJumpButtonBarVisible;
283 286
284 mActionJumpBar->setChecked( state ); 287 mActionJumpBar->setChecked( state );
285 setJumpButtonBarVisible( state ); 288 setJumpButtonBarVisible( state );
286/*US 289/*US
287 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 290 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
288 if ( splitterSize.count() == 0 ) { 291 if ( splitterSize.count() == 0 ) {
289 splitterSize.append( width() / 2 ); 292 splitterSize.append( width() / 2 );
290 splitterSize.append( width() / 2 ); 293 splitterSize.append( width() / 2 );
291 } 294 }
292 mMiniSplitter->setSizes( splitterSize ); 295 mMiniSplitter->setSizes( splitterSize );
293 if ( mExtensionBarSplitter ) { 296 if ( mExtensionBarSplitter ) {
294 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 297 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
295 if ( splitterSize.count() == 0 ) { 298 if ( splitterSize.count() == 0 ) {
296 splitterSize.append( width() / 2 ); 299 splitterSize.append( width() / 2 );
297 splitterSize.append( width() / 2 ); 300 splitterSize.append( width() / 2 );
298 } 301 }
299 mExtensionBarSplitter->setSizes( splitterSize ); 302 mExtensionBarSplitter->setSizes( splitterSize );
300 303
301 } 304 }
302*/ 305*/
303 mViewManager->restoreSettings(); 306 mViewManager->restoreSettings();
@@ -2102,442 +2105,508 @@ void KABCore::faq()
2102 2105
2103 2106
2104void KABCore::fillSyncMenu() 2107void KABCore::fillSyncMenu()
2105{ 2108{
2106 if ( syncMenu->count() ) 2109 if ( syncMenu->count() )
2107 syncMenu->clear(); 2110 syncMenu->clear();
2108 syncMenu->insertItem( i18n("Configure..."), 0 ); 2111 syncMenu->insertItem( i18n("Configure..."), 0 );
2109 syncMenu->insertSeparator(); 2112 syncMenu->insertSeparator();
2110 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 2113 syncMenu->insertItem( i18n("Multiple sync"), 1 );
2111 syncMenu->insertSeparator(); 2114 syncMenu->insertSeparator();
2112 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2115 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2113 config.setGroup("General"); 2116 config.setGroup("General");
2114 QStringList prof = config.readListEntry("SyncProfileNames"); 2117 QStringList prof = config.readListEntry("SyncProfileNames");
2115 KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 2118 KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
2116 if ( prof.count() < 3 ) { 2119 if ( prof.count() < 3 ) {
2117 prof.clear(); 2120 prof.clear();
2118 prof << i18n("Sharp_DTM"); 2121 prof << i18n("Sharp_DTM");
2119 prof << i18n("Local_file"); 2122 prof << i18n("Local_file");
2120 prof << i18n("Last_file"); 2123 prof << i18n("Last_file");
2121 KSyncProfile* temp = new KSyncProfile (); 2124 KSyncProfile* temp = new KSyncProfile ();
2122 temp->setName( prof[0] ); 2125 temp->setName( prof[0] );
2123 temp->writeConfig(&config); 2126 temp->writeConfig(&config);
2124 temp->setName( prof[1] ); 2127 temp->setName( prof[1] );
2125 temp->writeConfig(&config); 2128 temp->writeConfig(&config);
2126 temp->setName( prof[2] ); 2129 temp->setName( prof[2] );
2127 temp->writeConfig(&config); 2130 temp->writeConfig(&config);
2128 config.setGroup("General"); 2131 config.setGroup("General");
2129 config.writeEntry("SyncProfileNames",prof); 2132 config.writeEntry("SyncProfileNames",prof);
2130 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 2133 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
2131 config.sync(); 2134 config.sync();
2132 delete temp; 2135 delete temp;
2133 } 2136 }
2134 KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 2137 KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
2135 KABPrefs::instance()->mSyncProfileNames = prof; 2138 KABPrefs::instance()->mSyncProfileNames = prof;
2136 int i; 2139 int i;
2137 for ( i = 0; i < prof.count(); ++i ) { 2140 for ( i = 0; i < prof.count(); ++i ) {
2138 2141
2139 syncMenu->insertItem( prof[i], 1000+i ); 2142 syncMenu->insertItem( prof[i], 1000+i );
2140 if ( i == 2 ) 2143 if ( i == 2 )
2141 syncMenu->insertSeparator(); 2144 syncMenu->insertSeparator();
2142 } 2145 }
2143 QDir app_dir; 2146 QDir app_dir;
2144 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 2147 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
2145 syncMenu->setItemEnabled( false , 1000 ); 2148 syncMenu->setItemEnabled( false , 1000 );
2146 } 2149 }
2147 //probaly useless 2150 //probaly useless
2148 //mView->setupExternSyncProfiles(); 2151 //mView->setupExternSyncProfiles();
2149} 2152}
2150void KABCore::slotSyncMenu( int action ) 2153void KABCore::slotSyncMenu( int action )
2151{ 2154{
2152 //qDebug("syncaction %d ", action); 2155 //qDebug("syncaction %d ", action);
2153 if ( action == 0 ) { 2156 if ( action == 0 ) {
2154 2157
2155 // seems to be a Qt2 event handling bug 2158 // seems to be a Qt2 event handling bug
2156 // syncmenu.clear causes a segfault at first time 2159 // syncmenu.clear causes a segfault at first time
2157 // when we call it after the main event loop, it is ok 2160 // when we call it after the main event loop, it is ok
2158 // same behaviour when calling OM/Pi via QCOP for the first time 2161 // same behaviour when calling OM/Pi via QCOP for the first time
2159 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 2162 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
2160 //confSync(); 2163 //confSync();
2161 2164
2162 return; 2165 return;
2163 } 2166 }
2164 if ( action == 1 ) { 2167 if ( action == 1 ) {
2165 multiSync( true ); 2168 multiSync( true );
2166 return; 2169 return;
2167 } 2170 }
2168 2171
2169 if (mBlockSaveFlag) 2172 if (mBlockSaveFlag)
2170 return; 2173 return;
2171 mBlockSaveFlag = true; 2174 mBlockSaveFlag = true;
2172 mCurrentSyncProfile = action - 1000 ; 2175 mCurrentSyncProfile = action - 1000 ;
2173 mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; 2176 mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ;
2174 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; 2177 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ;
2175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2178 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2176 KSyncProfile* temp = new KSyncProfile (); 2179 KSyncProfile* temp = new KSyncProfile ();
2177 temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2180 temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2178 temp->readConfig(&config); 2181 temp->readConfig(&config);
2179 KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2182 KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2180 KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 2183 KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2181 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2184 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2182 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2185 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2183 KABPrefs::instance()->mWriteBackInFuture = 0; 2186 KABPrefs::instance()->mWriteBackInFuture = 0;
2184 if ( temp->getWriteBackFuture() ) 2187 if ( temp->getWriteBackFuture() )
2185 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2188 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2186 KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 2189 KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2187 if ( action == 1000 ) { 2190 if ( action == 1000 ) {
2188 syncSharp(); 2191 syncSharp();
2189 2192
2190 } else if ( action == 1001 ) { 2193 } else if ( action == 1001 ) {
2191 syncLocalFile(); 2194 syncLocalFile();
2192 2195
2193 } else if ( action == 1002 ) { 2196 } else if ( action == 1002 ) {
2194 quickSyncLocalFile(); 2197 quickSyncLocalFile();
2195 2198
2196 } else if ( action >= 1003 ) { 2199 } else if ( action >= 1003 ) {
2197 if ( temp->getIsLocalFileSync() ) { 2200 if ( temp->getIsLocalFileSync() ) {
2198 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 2201 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
2199 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 2202 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
2200 } else { 2203 } else {
2201 if ( temp->getIsPhoneSync() ) { 2204 if ( temp->getIsPhoneSync() ) {
2202 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 2205 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
2203 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 2206 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
2204 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 2207 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
2205 syncPhone(); 2208 syncPhone();
2206 } else 2209 } else
2207 syncRemote( temp ); 2210 syncRemote( temp );
2208 2211
2209 } 2212 }
2210 } 2213 }
2211 delete temp; 2214 delete temp;
2212 mBlockSaveFlag = false; 2215 mBlockSaveFlag = false;
2213} 2216}
2214 2217
2215void KABCore::syncLocalFile() 2218void KABCore::syncLocalFile()
2216{ 2219{
2217 2220
2218 QString fn =KABPrefs::instance()->mLastSyncedLocalFile; 2221 QString fn =KABPrefs::instance()->mLastSyncedLocalFile;
2219 2222
2220 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2223 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2221 if ( fn == "" ) 2224 if ( fn == "" )
2222 return; 2225 return;
2223 if ( syncWithFile( fn, false ) ) { 2226 if ( syncWithFile( fn, false ) ) {
2224 qDebug("syncLocalFile() successful "); 2227 qDebug("syncLocalFile() successful ");
2225 } 2228 }
2226 2229
2227} 2230}
2228bool KABCore::syncWithFile( QString fn , bool quick ) 2231bool KABCore::syncWithFile( QString fn , bool quick )
2229{ 2232{
2230 bool ret = false; 2233 bool ret = false;
2231 QFileInfo info; 2234 QFileInfo info;
2232 info.setFile( fn ); 2235 info.setFile( fn );
2233 QString mess; 2236 QString mess;
2234 bool loadbup = true; 2237 bool loadbup = true;
2235 if ( !info. exists() ) { 2238 if ( !info. exists() ) {
2236 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2239 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2237 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2240 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2238 mess ); 2241 mess );
2239 return ret; 2242 return ret;
2240 } 2243 }
2241 int result = 0; 2244 int result = 0;
2242 if ( !quick ) { 2245 if ( !quick ) {
2243 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2246 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2244 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2247 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2245 mess, 2248 mess,
2246 i18n("Sync"), i18n("Cancel"), 0, 2249 i18n("Sync"), i18n("Cancel"), 0,
2247 0, 1 ); 2250 0, 1 );
2248 if ( result ) 2251 if ( result )
2249 return false; 2252 return false;
2250 } 2253 }
2251 if ( KABPrefs::instance()->mAskForPreferences ) 2254 if ( KABPrefs::instance()->mAskForPreferences )
2252 edit_sync_options(); 2255 edit_sync_options();
2253 if ( result == 0 ) { 2256 if ( result == 0 ) {
2254 //qDebug("Now sycing ... "); 2257 //qDebug("Now sycing ... ");
2255 if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) 2258 if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) )
2256 setCaption( i18n("Synchronization successful") ); 2259 setCaption( i18n("Synchronization successful") );
2257 else 2260 else
2258 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 2261 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2259 if ( ! quick ) 2262 if ( ! quick )
2260 KABPrefs::instance()->mLastSyncedLocalFile = fn; 2263 KABPrefs::instance()->mLastSyncedLocalFile = fn;
2261 setModified(); 2264 setModified();
2262 } 2265 }
2263 return ret; 2266 return ret;
2264} 2267}
2265void KABCore::quickSyncLocalFile() 2268void KABCore::quickSyncLocalFile()
2266{ 2269{
2267 2270
2268 if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { 2271 if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2269 qDebug("quick syncLocalFile() successful "); 2272 qDebug("quick syncLocalFile() successful ");
2270 2273
2271 } 2274 }
2272} 2275}
2273void KABCore::multiSync( bool askforPrefs ) 2276void KABCore::multiSync( bool askforPrefs )
2274{ 2277{
2275 if (mBlockSaveFlag) 2278 if (mBlockSaveFlag)
2276 return; 2279 return;
2277 mBlockSaveFlag = true; 2280 mBlockSaveFlag = true;
2278 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 2281 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
2279 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2282 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2280 question, 2283 question,
2281 i18n("Yes"), i18n("No"), 2284 i18n("Yes"), i18n("No"),
2282 0, 0 ) != 0 ) { 2285 0, 0 ) != 0 ) {
2283 mBlockSaveFlag = false; 2286 mBlockSaveFlag = false;
2284 setCaption(i18n("Aborted! Nothing synced!")); 2287 setCaption(i18n("Aborted! Nothing synced!"));
2285 return; 2288 return;
2286 } 2289 }
2287 mCurrentSyncDevice = i18n("Multiple profiles") ; 2290 mCurrentSyncDevice = i18n("Multiple profiles") ;
2288 KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; 2291 KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs;
2289 if ( askforPrefs ) { 2292 if ( askforPrefs ) {
2290 edit_sync_options(); 2293 edit_sync_options();
2291 KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; 2294 KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs;
2292 } 2295 }
2293 setCaption(i18n("Multiple sync started.") ); 2296 setCaption(i18n("Multiple sync started.") );
2294 qApp->processEvents(); 2297 qApp->processEvents();
2295 int num = ringSync() ; 2298 int num = ringSync() ;
2296 if ( num > 1 ) 2299 if ( num > 1 )
2297 ringSync(); 2300 ringSync();
2298 mBlockSaveFlag = false; 2301 mBlockSaveFlag = false;
2299 if ( num ) 2302 if ( num )
2300 save(); 2303 save();
2301 if ( num ) 2304 if ( num )
2302 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 2305 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
2303 else 2306 else
2304 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 2307 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
2305 return; 2308 return;
2306} 2309}
2307int KABCore::ringSync() 2310int KABCore::ringSync()
2308{ 2311{
2309 int syncedProfiles = 0; 2312 int syncedProfiles = 0;
2310 int i; 2313 int i;
2311 QTime timer; 2314 QTime timer;
2312 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2315 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2313 QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; 2316 QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames;
2314 KSyncProfile* temp = new KSyncProfile (); 2317 KSyncProfile* temp = new KSyncProfile ();
2315 KABPrefs::instance()->mAskForPreferences = false; 2318 KABPrefs::instance()->mAskForPreferences = false;
2316 for ( i = 0; i < syncProfileNames.count(); ++i ) { 2319 for ( i = 0; i < syncProfileNames.count(); ++i ) {
2317 mCurrentSyncProfile = i; 2320 mCurrentSyncProfile = i;
2318 temp->setName(syncProfileNames[mCurrentSyncProfile]); 2321 temp->setName(syncProfileNames[mCurrentSyncProfile]);
2319 temp->readConfig(&config); 2322 temp->readConfig(&config);
2320 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 2323 if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) {
2321 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 2324 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
2322 ++syncedProfiles; 2325 ++syncedProfiles;
2323 // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2326 // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2324 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2327 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2325 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2328 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2326 KABPrefs::instance()->mWriteBackInFuture = 0; 2329 KABPrefs::instance()->mWriteBackInFuture = 0;
2327 if ( temp->getWriteBackFuture() ) 2330 if ( temp->getWriteBackFuture() )
2328 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2331 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2329 KABPrefs::instance()->mShowSyncSummary = false; 2332 KABPrefs::instance()->mShowSyncSummary = false;
2330 mCurrentSyncDevice = syncProfileNames[i] ; 2333 mCurrentSyncDevice = syncProfileNames[i] ;
2331 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; 2334 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName;
2332 if ( i == 0 ) { 2335 if ( i == 0 ) {
2333 syncSharp(); 2336 syncSharp();
2334 } else { 2337 } else {
2335 if ( temp->getIsLocalFileSync() ) { 2338 if ( temp->getIsLocalFileSync() ) {
2336 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 2339 if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) )
2337 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 2340 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
2338 } else { 2341 } else {
2339 if ( temp->getIsPhoneSync() ) { 2342 if ( temp->getIsPhoneSync() ) {
2340 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 2343 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
2341 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 2344 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
2342 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 2345 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
2343 syncPhone(); 2346 syncPhone();
2344 } else 2347 } else
2345 syncRemote( temp, false ); 2348 syncRemote( temp, false );
2346 2349
2347 } 2350 }
2348 } 2351 }
2349 timer.start(); 2352 timer.start();
2350 setCaption(i18n("Multiple sync in progress ... please wait!") ); 2353 setCaption(i18n("Multiple sync in progress ... please wait!") );
2351 while ( timer.elapsed () < 2000 ) { 2354 while ( timer.elapsed () < 2000 ) {
2352 qApp->processEvents(); 2355 qApp->processEvents();
2353#ifndef _WIN32_ 2356#ifndef _WIN32_
2354 sleep (1); 2357 sleep (1);
2355#endif 2358#endif
2356 } 2359 }
2357 2360
2358 } 2361 }
2359 2362
2360 } 2363 }
2361 delete temp; 2364 delete temp;
2362 return syncedProfiles; 2365 return syncedProfiles;
2363} 2366}
2364 2367
2365void KABCore::syncRemote( KSyncProfile* prof, bool ask) 2368void KABCore::syncRemote( KSyncProfile* prof, bool ask)
2366{ 2369{
2367 QString question; 2370 QString question;
2368 if ( ask ) { 2371 if ( ask ) {
2369 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 2372 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2370 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2373 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2371 question, 2374 question,
2372 i18n("Yes"), i18n("No"), 2375 i18n("Yes"), i18n("No"),
2373 0, 0 ) != 0 ) 2376 0, 0 ) != 0 )
2374 return; 2377 return;
2375 } 2378 }
2376 QString command = prof->getPreSyncCommand(); 2379 QString command = prof->getPreSyncCommandAB();
2377 int fi; 2380 int fi;
2378 if ( (fi = command.find("$PWD$")) > 0 ) { 2381 if ( (fi = command.find("$PWD$")) > 0 ) {
2379 QString pwd = getPassword(); 2382 QString pwd = getPassword();
2380 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2383 command = command.left( fi )+ pwd + command.mid( fi+5 );
2381 2384
2382 } 2385 }
2383 int maxlen = 30; 2386 int maxlen = 30;
2384 if ( QApplication::desktop()->width() > 320 ) 2387 if ( QApplication::desktop()->width() > 320 )
2385 maxlen += 25; 2388 maxlen += 25;
2386 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2389 setCaption ( i18n( "Copy remote file to local machine..." ) );
2387 int fileSize = 0; 2390 int fileSize = 0;
2388 int result = system ( command ); 2391 int result = system ( command );
2389 // 0 : okay 2392 // 0 : okay
2390 // 256: no such file or dir 2393 // 256: no such file or dir
2391 // 2394 //
2392 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2395 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2393 if ( result != 0 ) { 2396 if ( result != 0 ) {
2394 int len = maxlen; 2397 int len = maxlen;
2395 while ( len < command.length() ) { 2398 while ( len < command.length() ) {
2396 command.insert( len , "\n" ); 2399 command.insert( len , "\n" );
2397 len += maxlen +2; 2400 len += maxlen +2;
2398 } 2401 }
2399 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2402 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2400 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2403 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2401 question, 2404 question,
2402 i18n("Okay!")) ; 2405 i18n("Okay!")) ;
2403 setCaption ("KO/Pi"); 2406 setCaption ("KO/Pi");
2404 return; 2407 return;
2405 } 2408 }
2406 setCaption ( i18n( "Copying succeed." ) ); 2409 setCaption ( i18n( "Copying succeed." ) );
2407 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 2410 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2408 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 2411 if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) {
2409// Event* e = mView->getLastSyncEvent(); 2412// Event* e = mView->getLastSyncEvent();
2410// e->setReadOnly( false ); 2413// e->setReadOnly( false );
2411// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2414// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2412// e->setReadOnly( true ); 2415// e->setReadOnly( true );
2413 if ( KABPrefs::instance()->mWriteBackFile ) { 2416 if ( KABPrefs::instance()->mWriteBackFile ) {
2414 command = prof->getPostSyncCommand(); 2417 command = prof->getPostSyncCommandAB();
2415 int fi; 2418 int fi;
2416 if ( (fi = command.find("$PWD$")) > 0 ) { 2419 if ( (fi = command.find("$PWD$")) > 0 ) {
2417 QString pwd = getPassword(); 2420 QString pwd = getPassword();
2418 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2421 command = command.left( fi )+ pwd + command.mid( fi+5 );
2419 2422
2420 } 2423 }
2421 setCaption ( i18n( "Writing back file ..." ) ); 2424 setCaption ( i18n( "Writing back file ..." ) );
2422 result = system ( command ); 2425 result = system ( command );
2423 qDebug("KO: Writing back file result: %d ", result); 2426 qDebug("KO: Writing back file result: %d ", result);
2424 if ( result != 0 ) { 2427 if ( result != 0 ) {
2425 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 2428 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2426 return; 2429 return;
2427 } else { 2430 } else {
2428 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2431 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2429 } 2432 }
2430 } 2433 }
2431 } 2434 }
2432 return; 2435 return;
2433} 2436}
2434#include <qpushbutton.h> 2437#include <qpushbutton.h>
2435#include <qradiobutton.h> 2438#include <qradiobutton.h>
2436#include <qbuttongroup.h> 2439#include <qbuttongroup.h>
2437void KABCore::edit_sync_options() 2440void KABCore::edit_sync_options()
2438{ 2441{
2439 //mDialogManager->showSyncOptions(); 2442 //mDialogManager->showSyncOptions();
2440 //KABPrefs::instance()->mSyncAlgoPrefs 2443 //KABPrefs::instance()->mSyncAlgoPrefs
2441 QDialog dia( this, "dia", true ); 2444 QDialog dia( this, "dia", true );
2442 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 2445 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2443 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 2446 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2444 QVBoxLayout lay ( &dia ); 2447 QVBoxLayout lay ( &dia );
2445 lay.setSpacing( 2 ); 2448 lay.setSpacing( 2 );
2446 lay.setMargin( 3 ); 2449 lay.setMargin( 3 );
2447 lay.addWidget(&gr); 2450 lay.addWidget(&gr);
2448 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 2451 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2449 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 2452 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2450 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 2453 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2451 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 2454 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2452 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 2455 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2453 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 2456 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2454 //QRadioButton both( i18n("Take both on conflict"), &gr ); 2457 //QRadioButton both( i18n("Take both on conflict"), &gr );
2455 QPushButton pb ( "OK", &dia); 2458 QPushButton pb ( "OK", &dia);
2456 lay.addWidget( &pb ); 2459 lay.addWidget( &pb );
2457 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2460 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2458 switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { 2461 switch ( KABPrefs::instance()->mSyncAlgoPrefs ) {
2459 case 0: 2462 case 0:
2460 loc.setChecked( true); 2463 loc.setChecked( true);
2461 break; 2464 break;
2462 case 1: 2465 case 1:
2463 rem.setChecked( true ); 2466 rem.setChecked( true );
2464 break; 2467 break;
2465 case 2: 2468 case 2:
2466 newest.setChecked( true); 2469 newest.setChecked( true);
2467 break; 2470 break;
2468 case 3: 2471 case 3:
2469 ask.setChecked( true); 2472 ask.setChecked( true);
2470 break; 2473 break;
2471 case 4: 2474 case 4:
2472 f_loc.setChecked( true); 2475 f_loc.setChecked( true);
2473 break; 2476 break;
2474 case 5: 2477 case 5:
2475 f_rem.setChecked( true); 2478 f_rem.setChecked( true);
2476 break; 2479 break;
2477 case 6: 2480 case 6:
2478 // both.setChecked( true); 2481 // both.setChecked( true);
2479 break; 2482 break;
2480 default: 2483 default:
2481 break; 2484 break;
2482 } 2485 }
2483 if ( dia.exec() ) { 2486 if ( dia.exec() ) {
2484 KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2487 KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2485 } 2488 }
2486 2489
2487 2490
2488} 2491}
2489QString KABCore::getPassword( ) 2492QString KABCore::getPassword( )
2490{ 2493{
2491 QString retfile = ""; 2494 QString retfile = "";
2492 QDialog dia ( this, "input-dialog", true ); 2495 QDialog dia ( this, "input-dialog", true );
2493 QLineEdit lab ( &dia ); 2496 QLineEdit lab ( &dia );
2494 lab.setEchoMode( QLineEdit::Password ); 2497 lab.setEchoMode( QLineEdit::Password );
2495 QVBoxLayout lay( &dia ); 2498 QVBoxLayout lay( &dia );
2496 lay.setMargin(7); 2499 lay.setMargin(7);
2497 lay.setSpacing(7); 2500 lay.setSpacing(7);
2498 lay.addWidget( &lab); 2501 lay.addWidget( &lab);
2499 dia.setFixedSize( 230,50 ); 2502 dia.setFixedSize( 230,50 );
2500 dia.setCaption( i18n("Enter password") ); 2503 dia.setCaption( i18n("Enter password") );
2501 QPushButton pb ( "OK", &dia); 2504 QPushButton pb ( "OK", &dia);
2502 lay.addWidget( &pb ); 2505 lay.addWidget( &pb );
2503 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2506 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2504 dia.show(); 2507 dia.show();
2505 int res = dia.exec(); 2508 int res = dia.exec();
2506 if ( res ) 2509 if ( res )
2507 retfile = lab.text(); 2510 retfile = lab.text();
2508 dia.hide(); 2511 dia.hide();
2509 qApp->processEvents(); 2512 qApp->processEvents();
2510 return retfile; 2513 return retfile;
2511 2514
2512} 2515}
2516bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2517{
2513 2518
2519}
2514bool KABCore::syncAB(QString filename, int mode) 2520bool KABCore::syncAB(QString filename, int mode)
2515{ 2521{
2516 2522
2523
2524
2525 mGlobalSyncMode = SYNC_MODE_NORMAL;
2526 AddressBook abLocal(filename,"syncContact");
2527 bool syncOK = false;
2528 if ( abLocal.load() ) {
2529 qDebug("AB loaded %s mode %d",filename.latin1(), mode );
2530 AddressBook::Iterator it;
2531 QStringList vcards;
2532 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2533 qDebug("Name %s ", (*it).familyName().latin1());
2534 }
2535 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2536 if ( syncOK ) {
2537 if ( KABPrefs::instance()->mWriteBackFile )
2538 {
2539 abLocal.saveAB();
2540 }
2541 }
2542 setModified();
2543
2544 }
2545 if ( syncOK )
2546 ;//updateView();
2547 return syncOK;
2548#if 0
2549 mGlobalSyncMode = SYNC_MODE_NORMAL;
2550 CalendarLocal* calendar = new CalendarLocal();
2551 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2552 FileStorage* storage = new FileStorage( calendar );
2553 bool syncOK = false;
2554 storage->setFileName( filename );
2555 // qDebug("loading ... ");
2556 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2557 getEventViewerDialog()->setSyncMode( true );
2558 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2559 getEventViewerDialog()->setSyncMode( false );
2560 if ( syncOK ) {
2561 if ( KOPrefs::instance()->mWriteBackFile )
2562 {
2563 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2564 storage->save();
2565 }
2566 }
2567 setModified();
2568 }
2569 delete storage;
2570 delete calendar;
2571 if ( syncOK )
2572 updateView();
2573 return syncOK;
2574#endif
2517} 2575}
2518 2576
2519 2577
2520void KABCore::confSync() 2578void KABCore::confSync()
2521{ 2579{
2522 //mView->confSync(); 2580 static KSyncPrefsDialog* sp = 0;
2523 qDebug("pending KABCore::confSync() "); 2581 if ( ! sp ) {
2582 sp = new KSyncPrefsDialog( this, "syncprefs", true );
2583 }
2584 sp->usrReadConfig();
2585#ifndef DESKTOP_VERSION
2586 sp->showMaximized();
2587#else
2588 sp->show();
2589#endif
2590 sp->exec();
2591 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
2592 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
2524 fillSyncMenu(); 2593 fillSyncMenu();
2525} 2594}
2526void KABCore::syncSharp() 2595void KABCore::syncSharp()
2527{ 2596{
2528 if ( mModified ) 2597 if ( mModified )
2529 save(); 2598 save();
2530 qDebug("pending syncSharp() "); 2599 qDebug("pending syncSharp() ");
2531 //mView->syncSharp(); 2600 //mView->syncSharp();
2532 mModified = true ; 2601 setModified();
2533 2602
2534} 2603}
2535void KABCore::syncPhone() 2604void KABCore::syncPhone()
2536{ 2605{
2537 if ( mModified ) 2606 if ( mModified )
2538 save(); 2607 save();
2539 qDebug("pending syncPhone(); "); 2608 qDebug("pending syncPhone(); ");
2540 //mView->syncPhone(); 2609 //mView->syncPhone();
2541 setModified(); 2610 setModified();
2542 2611
2543} 2612}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 10ce8f4..4487a8a 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -363,116 +363,119 @@ class KABCore : public QWidget
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 void confSync();
460 QString mCurrentSyncDevice; 459 QString mCurrentSyncDevice;
461 QString mCurrentSyncName; 460 QString mCurrentSyncName;
462 void quickSyncLocalFile(); 461 void quickSyncLocalFile();
463 bool syncWithFile( QString fn , bool quick ); 462 bool syncWithFile( QString fn , bool quick );
464 void KABCore::syncLocalFile(); 463 void KABCore::syncLocalFile();
465 void KABCore::syncPhone(); 464 void KABCore::syncPhone();
466 void KABCore::syncSharp(); 465 void KABCore::syncSharp();
467 void multiSync( bool askforPrefs ); 466 void multiSync( bool askforPrefs );
468 int mCurrentSyncProfile ; 467 int mCurrentSyncProfile ;
469 void syncRemote( KSyncProfile* prof, bool ask = true); 468 void syncRemote( KSyncProfile* prof, bool ask = true);
470 void edit_sync_options(); 469 void edit_sync_options();
471 bool syncAB(QString filename, int mode); 470 bool syncAB(QString filename, int mode);
472 int ringSync(); 471 int ringSync();
473 QString getPassword( ); 472 QString getPassword( );
473 int mGlobalSyncMode;
474 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
475 public slots:
476 void confSync();
474 // ********************* 477 // *********************
475 478
476}; 479};
477 480
478#endif 481#endif