author | zautrix <zautrix> | 2005-12-02 09:42:53 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-12-02 09:42:53 (UTC) |
commit | a75d2c26aba6cffae8c3f61e173940240042427b (patch) (unidiff) | |
tree | 68f4b61c150bc263a98c78fdf8671bbbc17cdaf8 | |
parent | 64be8d64fc26d1025a24150d065197ba5d608f3d (diff) | |
download | kdepimpi-a75d2c26aba6cffae8c3f61e173940240042427b.zip kdepimpi-a75d2c26aba6cffae8c3f61e173940240042427b.tar.gz kdepimpi-a75d2c26aba6cffae8c3f61e173940240042427b.tar.bz2 |
more sync
-rw-r--r-- | kabc/addressbook.cpp | 42 | ||||
-rw-r--r-- | kabc/addressbook.h | 4 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 6 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 2 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 4 |
5 files changed, 41 insertions, 17 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index e04f4b1..bdc2762 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -230,558 +230,582 @@ AddressBook::AddressBook() | |||
230 | AddressBook::AddressBook( const QString &config ) | 230 | AddressBook::AddressBook( const QString &config ) |
231 | { | 231 | { |
232 | init(config, "contact"); | 232 | init(config, "contact"); |
233 | } | 233 | } |
234 | 234 | ||
235 | AddressBook::AddressBook( const QString &config, const QString &family ) | 235 | AddressBook::AddressBook( const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | init(config, family); | 237 | init(config, family); |
238 | 238 | ||
239 | } | 239 | } |
240 | 240 | ||
241 | // the default family is "contact" | 241 | // the default family is "contact" |
242 | void AddressBook::init(const QString &config, const QString &family ) | 242 | void AddressBook::init(const QString &config, const QString &family ) |
243 | { | 243 | { |
244 | blockLSEchange = false; | 244 | blockLSEchange = false; |
245 | d = new AddressBookData; | 245 | d = new AddressBookData; |
246 | QString fami = family; | 246 | QString fami = family; |
247 | if (config != 0) { | 247 | if (config != 0) { |
248 | if ( family == "syncContact" ) { | 248 | if ( family == "syncContact" ) { |
249 | qDebug("creating sync config "); | 249 | qDebug("creating sync config "); |
250 | fami = "contact"; | 250 | fami = "contact"; |
251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
252 | con->setGroup( "General" ); | 252 | con->setGroup( "General" ); |
253 | con->writeEntry( "ResourceKeys", QString("sync") ); | 253 | con->writeEntry( "ResourceKeys", QString("sync") ); |
254 | con->writeEntry( "Standard", QString("sync") ); | 254 | con->writeEntry( "Standard", QString("sync") ); |
255 | con->setGroup( "Resource_sync" ); | 255 | con->setGroup( "Resource_sync" ); |
256 | con->writeEntry( "FileName", config ); | 256 | con->writeEntry( "FileName", config ); |
257 | con->writeEntry( "FileFormat", QString("vcard") ); | 257 | con->writeEntry( "FileFormat", QString("vcard") ); |
258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
259 | con->writeEntry( "ResourceName", QString("sync_res") ); | 259 | con->writeEntry( "ResourceName", QString("sync_res") ); |
260 | if ( config.right(4) == ".xml" ) | 260 | if ( config.right(4) == ".xml" ) |
261 | con->writeEntry( "ResourceType", QString("qtopia") ); | 261 | con->writeEntry( "ResourceType", QString("qtopia") ); |
262 | else if ( config == "sharp" ) { | 262 | else if ( config == "sharp" ) { |
263 | con->writeEntry( "ResourceType", QString("sharp") ); | 263 | con->writeEntry( "ResourceType", QString("sharp") ); |
264 | } else { | 264 | } else { |
265 | con->writeEntry( "ResourceType", QString("file") ); | 265 | con->writeEntry( "ResourceType", QString("file") ); |
266 | } | 266 | } |
267 | //con->sync(); | 267 | //con->sync(); |
268 | d->mConfig = con; | 268 | d->mConfig = con; |
269 | } | 269 | } |
270 | else | 270 | else |
271 | d->mConfig = new KConfig( locateLocal("config", config) ); | 271 | d->mConfig = new KConfig( locateLocal("config", config) ); |
272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
273 | } | 273 | } |
274 | else { | 274 | else { |
275 | d->mConfig = 0; | 275 | d->mConfig = 0; |
276 | // qDebug("AddressBook::init 1 config=0"); | 276 | // qDebug("AddressBook::init 1 config=0"); |
277 | } | 277 | } |
278 | 278 | ||
279 | //US d->mErrorHandler = 0; | 279 | //US d->mErrorHandler = 0; |
280 | d->mManager = new KRES::Manager<Resource>( fami ); | 280 | d->mManager = new KRES::Manager<Resource>( fami ); |
281 | d->mManager->readConfig( d->mConfig ); | 281 | d->mManager->readConfig( d->mConfig ); |
282 | if ( family == "syncContact" ) { | 282 | if ( family == "syncContact" ) { |
283 | KRES::Manager<Resource> *manager = d->mManager; | 283 | KRES::Manager<Resource> *manager = d->mManager; |
284 | KRES::Manager<Resource>::ActiveIterator it; | 284 | KRES::Manager<Resource>::ActiveIterator it; |
285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
286 | (*it)->setAddressBook( this ); | 286 | (*it)->setAddressBook( this ); |
287 | if ( !(*it)->open() ) | 287 | if ( !(*it)->open() ) |
288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
289 | } | 289 | } |
290 | Resource *res = standardResource(); | 290 | Resource *res = standardResource(); |
291 | if ( !res ) { | 291 | if ( !res ) { |
292 | qDebug("ERROR: no standard resource"); | 292 | qDebug("ERROR: no standard resource"); |
293 | res = manager->createResource( "file" ); | 293 | res = manager->createResource( "file" ); |
294 | if ( res ) | 294 | if ( res ) |
295 | { | 295 | { |
296 | addResource( res ); | 296 | addResource( res ); |
297 | } | 297 | } |
298 | else | 298 | else |
299 | qDebug(" No resource available!!!"); | 299 | qDebug(" No resource available!!!"); |
300 | } | 300 | } |
301 | setStandardResource( res ); | 301 | setStandardResource( res ); |
302 | manager->writeConfig(); | 302 | manager->writeConfig(); |
303 | } | 303 | } |
304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
305 | "X-Department", "KADDRESSBOOK" ); | 305 | "X-Department", "KADDRESSBOOK" ); |
306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
307 | "X-Profession", "KADDRESSBOOK" ); | 307 | "X-Profession", "KADDRESSBOOK" ); |
308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
309 | "X-AssistantsName", "KADDRESSBOOK" ); | 309 | "X-AssistantsName", "KADDRESSBOOK" ); |
310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
311 | "X-ManagersName", "KADDRESSBOOK" ); | 311 | "X-ManagersName", "KADDRESSBOOK" ); |
312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
313 | "X-SpousesName", "KADDRESSBOOK" ); | 313 | "X-SpousesName", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
315 | "X-Office", "KADDRESSBOOK" ); | 315 | "X-Office", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
317 | "X-IMAddress", "KADDRESSBOOK" ); | 317 | "X-IMAddress", "KADDRESSBOOK" ); |
318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
319 | "X-Anniversary", "KADDRESSBOOK" ); | 319 | "X-Anniversary", "KADDRESSBOOK" ); |
320 | 320 | ||
321 | //US added this field to become compatible with Opie/qtopia addressbook | 321 | //US added this field to become compatible with Opie/qtopia addressbook |
322 | // values can be "female" or "male" or "". An empty field represents undefined. | 322 | // values can be "female" or "male" or "". An empty field represents undefined. |
323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
324 | "X-Gender", "KADDRESSBOOK" ); | 324 | "X-Gender", "KADDRESSBOOK" ); |
325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
326 | "X-Children", "KADDRESSBOOK" ); | 326 | "X-Children", "KADDRESSBOOK" ); |
327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
330 | "X-ExternalID", "KADDRESSBOOK" ); | 330 | "X-ExternalID", "KADDRESSBOOK" ); |
331 | } | 331 | } |
332 | 332 | ||
333 | AddressBook::~AddressBook() | 333 | AddressBook::~AddressBook() |
334 | { | 334 | { |
335 | delete d->mConfig; d->mConfig = 0; | 335 | delete d->mConfig; d->mConfig = 0; |
336 | delete d->mManager; d->mManager = 0; | 336 | delete d->mManager; d->mManager = 0; |
337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
338 | delete d; d = 0; | 338 | delete d; d = 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | bool AddressBook::load() | 341 | bool AddressBook::load() |
342 | { | 342 | { |
343 | 343 | ||
344 | clear(); | 344 | clear(); |
345 | KRES::Manager<Resource>::ActiveIterator it; | 345 | KRES::Manager<Resource>::ActiveIterator it; |
346 | bool ok = true; | 346 | bool ok = true; |
347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
348 | if ( !(*it)->load() ) { | 348 | if ( !(*it)->load() ) { |
349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
350 | ok = false; | 350 | ok = false; |
351 | } else { | 351 | } else { |
352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); | 352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); |
353 | } | 353 | } |
354 | // mark all addressees as unchanged | 354 | // mark all addressees as unchanged |
355 | Addressee::List::Iterator addrIt; | 355 | Addressee::List::Iterator addrIt; |
356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
357 | (*addrIt).setChanged( false ); | 357 | (*addrIt).setChanged( false ); |
358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
359 | if ( !id.isEmpty() ) { | 359 | if ( !id.isEmpty() ) { |
360 | //qDebug("setId aa %s ", id.latin1()); | 360 | //qDebug("setId aa %s ", id.latin1()); |
361 | (*addrIt).setIDStr(id ); | 361 | (*addrIt).setIDStr(id ); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | blockLSEchange = true; | 364 | blockLSEchange = true; |
365 | return ok; | 365 | return ok; |
366 | } | 366 | } |
367 | 367 | ||
368 | bool AddressBook::save( Ticket *ticket ) | 368 | bool AddressBook::save( Ticket *ticket ) |
369 | { | 369 | { |
370 | kdDebug(5700) << "AddressBook::save()"<< endl; | 370 | kdDebug(5700) << "AddressBook::save()"<< endl; |
371 | 371 | ||
372 | if ( ticket->resource() ) { | 372 | if ( ticket->resource() ) { |
373 | deleteRemovedAddressees(); | 373 | deleteRemovedAddressees(); |
374 | return ticket->resource()->save( ticket ); | 374 | return ticket->resource()->save( ticket ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return false; | 377 | return false; |
378 | } | 378 | } |
379 | // exports all Addressees, which are syncable | 379 | // exports all Addressees, which are syncable |
380 | void AddressBook::export2File( QString fileName, QString resourceName ) | 380 | void AddressBook::export2File( QString fileName, QString resourceName ) |
381 | { | 381 | { |
382 | 382 | ||
383 | QFile outFile( fileName ); | 383 | QFile outFile( fileName ); |
384 | if ( !outFile.open( IO_WriteOnly ) ) { | 384 | if ( !outFile.open( IO_WriteOnly ) ) { |
385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
386 | KMessageBox::error( 0, text.arg( fileName ) ); | 386 | KMessageBox::error( 0, text.arg( fileName ) ); |
387 | return ; | 387 | return ; |
388 | } | 388 | } |
389 | QTextStream t( &outFile ); | 389 | QTextStream t( &outFile ); |
390 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 390 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
391 | Iterator it; | 391 | Iterator it; |
392 | KABC::VCardConverter::Version version; | 392 | KABC::VCardConverter::Version version; |
393 | version = KABC::VCardConverter::v3_0; | 393 | version = KABC::VCardConverter::v3_0; |
394 | for ( it = begin(); it != end(); ++it ) { | 394 | for ( it = begin(); it != end(); ++it ) { |
395 | if ( (*it).resource() ) { | 395 | if ( (*it).resource() ) { |
396 | bool include = (*it).resource()->includeInSync(); | 396 | bool include = (*it).resource()->includeInSync(); |
397 | if ( !resourceName.isEmpty() ) | 397 | if ( !resourceName.isEmpty() ) |
398 | include = (resourceName == (*it).resource()->name() ); | 398 | include = (resourceName == (*it).resource()->name() ); |
399 | if ( include ) { | 399 | if ( include ) { |
400 | qDebug(QString ("Exporting resource %1 to file %2").arg( (*it).resource()->name() ).arg( fileName ) ); | 400 | qDebug(QString ("Exporting resource %1 to file %2").arg( (*it).resource()->name() ).arg( fileName ) ); |
401 | if ( !(*it).IDStr().isEmpty() ) { | 401 | if ( !(*it).IDStr().isEmpty() ) { |
402 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 402 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
403 | } | 403 | } |
404 | KABC::VCardConverter converter; | 404 | KABC::VCardConverter converter; |
405 | QString vcard; | 405 | QString vcard; |
406 | //Resource *resource() const; | 406 | //Resource *resource() const; |
407 | converter.addresseeToVCard( *it, vcard, version ); | 407 | converter.addresseeToVCard( *it, vcard, version ); |
408 | t << vcard << "\r\n"; | 408 | t << vcard << "\r\n"; |
409 | } | 409 | } |
410 | } | 410 | } |
411 | } | 411 | } |
412 | t << "\r\n\r\n"; | 412 | t << "\r\n\r\n"; |
413 | outFile.close(); | 413 | outFile.close(); |
414 | } | 414 | } |
415 | // if QStringList uids is empty, all are exported | 415 | // if QStringList uids is empty, all are exported |
416 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | 416 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) |
417 | { | 417 | { |
418 | KABC::VCardConverter converter; | 418 | KABC::VCardConverter converter; |
419 | QString datastream; | 419 | QString datastream; |
420 | Iterator it; | 420 | Iterator it; |
421 | bool all = uids.isEmpty(); | 421 | bool all = uids.isEmpty(); |
422 | for ( it = begin(); it != end(); ++it ) { | 422 | for ( it = begin(); it != end(); ++it ) { |
423 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 423 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
424 | if ( ! all ) { | 424 | if ( ! all ) { |
425 | if ( ! ( uids.contains((*it).uid() ) )) | 425 | if ( ! ( uids.contains((*it).uid() ) )) |
426 | continue; | 426 | continue; |
427 | } | 427 | } |
428 | KABC::Addressee a = ( *it ); | 428 | KABC::Addressee a = ( *it ); |
429 | if ( a.isEmpty() ) | 429 | if ( a.isEmpty() ) |
430 | continue; | 430 | continue; |
431 | if ( all && a.resource() && !a.resource()->includeInSync() ) | 431 | if ( all && a.resource() && !a.resource()->includeInSync() ) |
432 | continue; | 432 | continue; |
433 | a.simplifyEmails(); | 433 | a.simplifyEmails(); |
434 | a.simplifyPhoneNumbers(); | 434 | a.simplifyPhoneNumbers(); |
435 | a.simplifyPhoneNumberTypes(); | 435 | a.simplifyPhoneNumberTypes(); |
436 | a.simplifyAddresses(); | 436 | a.simplifyAddresses(); |
437 | 437 | ||
438 | QString vcard; | 438 | QString vcard; |
439 | QString vcardnew; | 439 | QString vcardnew; |
440 | converter.addresseeToVCard( a, vcard ); | 440 | converter.addresseeToVCard( a, vcard ); |
441 | int start = 0; | 441 | int start = 0; |
442 | int next; | 442 | int next; |
443 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 443 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
444 | int semi = vcard.find(";", next); | 444 | int semi = vcard.find(";", next); |
445 | int dopp = vcard.find(":", next); | 445 | int dopp = vcard.find(":", next); |
446 | int sep; | 446 | int sep; |
447 | if ( semi < dopp && semi >= 0 ) | 447 | if ( semi < dopp && semi >= 0 ) |
448 | sep = semi ; | 448 | sep = semi ; |
449 | else | 449 | else |
450 | sep = dopp; | 450 | sep = dopp; |
451 | vcardnew +=vcard.mid( start, next - start); | 451 | vcardnew +=vcard.mid( start, next - start); |
452 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); | 452 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); |
453 | start = sep; | 453 | start = sep; |
454 | } | 454 | } |
455 | vcardnew += vcard.mid( start,vcard.length() ); | 455 | vcardnew += vcard.mid( start,vcard.length() ); |
456 | vcard = ""; | 456 | vcard = ""; |
457 | start = 0; | 457 | start = 0; |
458 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { | 458 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { |
459 | int sep = vcardnew.find(":", next); | 459 | int sep = vcardnew.find(":", next); |
460 | vcard +=vcardnew.mid( start, next - start+3); | 460 | vcard +=vcardnew.mid( start, next - start+3); |
461 | start = sep; | 461 | start = sep; |
462 | } | 462 | } |
463 | vcard += vcardnew.mid( start,vcardnew.length() ); | 463 | vcard += vcardnew.mid( start,vcardnew.length() ); |
464 | vcard.replace ( QRegExp(";;;") , "" ); | 464 | vcard.replace ( QRegExp(";;;") , "" ); |
465 | vcard.replace ( QRegExp(";;") , "" ); | 465 | vcard.replace ( QRegExp(";;") , "" ); |
466 | datastream += vcard; | 466 | datastream += vcard; |
467 | 467 | ||
468 | } | 468 | } |
469 | 469 | ||
470 | QFile outFile(fileName); | 470 | QFile outFile(fileName); |
471 | if ( outFile.open(IO_WriteOnly) ) { | 471 | if ( outFile.open(IO_WriteOnly) ) { |
472 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 472 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
473 | QTextStream t( &outFile ); // use a text stream | 473 | QTextStream t( &outFile ); // use a text stream |
474 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 474 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
475 | t <<datastream; | 475 | t <<datastream; |
476 | t << "\r\n\r\n"; | 476 | t << "\r\n\r\n"; |
477 | outFile.close(); | 477 | outFile.close(); |
478 | 478 | ||
479 | } else { | 479 | } else { |
480 | qDebug("Error open temp file "); | 480 | qDebug("Error open temp file "); |
481 | return false; | 481 | return false; |
482 | } | 482 | } |
483 | return true; | 483 | return true; |
484 | 484 | ||
485 | } | 485 | } |
486 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) | 486 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld, QString resource ) |
487 | { | 487 | { |
488 | 488 | ||
489 | if ( removeOld ) | 489 | if ( removeOld ) |
490 | setUntagged( true ); | 490 | setUntagged( true, resource ); |
491 | KABC::Addressee::List list; | 491 | KABC::Addressee::List list; |
492 | QFile file( fileName ); | 492 | QFile file( fileName ); |
493 | file.open( IO_ReadOnly ); | 493 | file.open( IO_ReadOnly ); |
494 | QByteArray rawData = file.readAll(); | 494 | QByteArray rawData = file.readAll(); |
495 | file.close(); | 495 | file.close(); |
496 | QString data; | 496 | QString data; |
497 | if ( replaceLabel ) { | 497 | if ( replaceLabel ) { |
498 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 498 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
499 | data.replace ( QRegExp("LABEL") , "ADR" ); | 499 | data.replace ( QRegExp("LABEL") , "ADR" ); |
500 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 500 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
501 | } else | 501 | } else |
502 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 502 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
503 | KABC::VCardTool tool; | 503 | KABC::VCardTool tool; |
504 | list = tool.parseVCards( data ); | 504 | list = tool.parseVCards( data ); |
505 | KABC::Addressee::List::Iterator it; | 505 | KABC::Addressee::List::Iterator it; |
506 | |||
507 | Resource * setRes = 0; | ||
508 | if ( !resource.isEmpty() ) { | ||
509 | KRES::Manager<Resource>::ActiveIterator it; | ||
510 | KRES::Manager<Resource> *manager = d->mManager; | ||
511 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | ||
512 | qDebug("SaveAB::checking resource..." ); | ||
513 | if ( (*it)->name() == resource ) { | ||
514 | setRes = (*it); | ||
515 | qDebug("Inserting imported contacs to resource %s", resource.latin1()); | ||
516 | break; | ||
517 | } | ||
518 | } | ||
519 | } | ||
506 | for ( it = list.begin(); it != list.end(); ++it ) { | 520 | for ( it = list.begin(); it != list.end(); ++it ) { |
507 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 521 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
508 | if ( !id.isEmpty() ) | 522 | if ( !id.isEmpty() ) |
509 | (*it).setIDStr(id ); | 523 | (*it).setIDStr(id ); |
510 | (*it).setResource( 0 ); | 524 | (*it).setResource( setRes ); |
511 | if ( replaceLabel ) | 525 | if ( replaceLabel ) |
512 | (*it).removeVoice(); | 526 | (*it).removeVoice(); |
513 | if ( removeOld ) | 527 | if ( removeOld ) |
514 | (*it).setTagged( true ); | 528 | (*it).setTagged( true ); |
515 | insertAddressee( (*it), false, true ); | 529 | insertAddressee( (*it), false, true ); |
516 | } | 530 | } |
517 | if ( removeOld ) | 531 | if ( removeOld ) |
518 | removeUntagged(); | 532 | removeUntagged(); |
519 | return list.count(); | 533 | return list.count(); |
520 | } | 534 | } |
521 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) | 535 | void AddressBook::setUntagged(bool setNonSyncTagged, QString resource) // = false , "") |
522 | { | 536 | { |
523 | Iterator ait; | 537 | Iterator ait; |
524 | for ( ait = begin(); ait != end(); ++ait ) { | 538 | if ( !resource.isEmpty() ) { |
525 | if ( setNonSyncTagged ) { | 539 | for ( ait = begin(); ait != end(); ++ait ) { |
526 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { | 540 | if ( (*ait).resource() && (*ait).resource()->name() == resource ) { |
541 | (*ait).setTagged( false ); | ||
542 | } | ||
543 | else | ||
527 | (*ait).setTagged( true ); | 544 | (*ait).setTagged( true ); |
545 | } | ||
546 | } else { | ||
547 | for ( ait = begin(); ait != end(); ++ait ) { | ||
548 | if ( setNonSyncTagged ) { | ||
549 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { | ||
550 | (*ait).setTagged( true ); | ||
551 | } else | ||
552 | (*ait).setTagged( false ); | ||
528 | } else | 553 | } else |
529 | (*ait).setTagged( false ); | 554 | (*ait).setTagged( false ); |
530 | } else | 555 | } |
531 | (*ait).setTagged( false ); | ||
532 | } | 556 | } |
533 | } | 557 | } |
534 | void AddressBook::removeUntagged() | 558 | void AddressBook::removeUntagged() |
535 | { | 559 | { |
536 | Iterator ait; | 560 | Iterator ait; |
537 | bool todelete = false; | 561 | bool todelete = false; |
538 | Iterator todel; | 562 | Iterator todel; |
539 | for ( ait = begin(); ait != end(); ++ait ) { | 563 | for ( ait = begin(); ait != end(); ++ait ) { |
540 | if ( todelete ) | 564 | if ( todelete ) |
541 | removeAddressee( todel ); | 565 | removeAddressee( todel ); |
542 | if (!(*ait).tagged()) { | 566 | if (!(*ait).tagged()) { |
543 | todelete = true; | 567 | todelete = true; |
544 | todel = ait; | 568 | todel = ait; |
545 | } else | 569 | } else |
546 | todelete = false; | 570 | todelete = false; |
547 | } | 571 | } |
548 | if ( todelete ) | 572 | if ( todelete ) |
549 | removeAddressee( todel ); | 573 | removeAddressee( todel ); |
550 | deleteRemovedAddressees(); | 574 | deleteRemovedAddressees(); |
551 | } | 575 | } |
552 | void AddressBook::smplifyAddressees() | 576 | void AddressBook::smplifyAddressees() |
553 | { | 577 | { |
554 | Iterator ait; | 578 | Iterator ait; |
555 | for ( ait = begin(); ait != end(); ++ait ) { | 579 | for ( ait = begin(); ait != end(); ++ait ) { |
556 | (*ait).simplifyEmails(); | 580 | (*ait).simplifyEmails(); |
557 | (*ait).simplifyPhoneNumbers(); | 581 | (*ait).simplifyPhoneNumbers(); |
558 | (*ait).simplifyPhoneNumberTypes(); | 582 | (*ait).simplifyPhoneNumberTypes(); |
559 | (*ait).simplifyAddresses(); | 583 | (*ait).simplifyAddresses(); |
560 | } | 584 | } |
561 | } | 585 | } |
562 | void AddressBook::removeSyncInfo( QString syncProfile) | 586 | void AddressBook::removeSyncInfo( QString syncProfile) |
563 | { | 587 | { |
564 | Iterator ait; | 588 | Iterator ait; |
565 | for ( ait = begin(); ait != end(); ++ait ) { | 589 | for ( ait = begin(); ait != end(); ++ait ) { |
566 | (*ait).removeID( syncProfile ); | 590 | (*ait).removeID( syncProfile ); |
567 | } | 591 | } |
568 | if ( syncProfile.isEmpty() ) { | 592 | if ( syncProfile.isEmpty() ) { |
569 | Iterator it = begin(); | 593 | Iterator it = begin(); |
570 | Iterator it2 ; | 594 | Iterator it2 ; |
571 | while ( it != end() ) { | 595 | while ( it != end() ) { |
572 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 596 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
573 | it2 = it; | 597 | it2 = it; |
574 | //qDebug("removing %s ",(*it).uid().latin1() ); | 598 | //qDebug("removing %s ",(*it).uid().latin1() ); |
575 | ++it; | 599 | ++it; |
576 | removeAddressee( it2 ); | 600 | removeAddressee( it2 ); |
577 | } else { | 601 | } else { |
578 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 602 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
579 | ++it; | 603 | ++it; |
580 | } | 604 | } |
581 | } | 605 | } |
582 | } else { | 606 | } else { |
583 | Addressee lse; | 607 | Addressee lse; |
584 | lse = findByUid( "last-syncAddressee-"+ syncProfile ); | 608 | lse = findByUid( "last-syncAddressee-"+ syncProfile ); |
585 | if ( ! lse.isEmpty() ) | 609 | if ( ! lse.isEmpty() ) |
586 | removeAddressee( lse ); | 610 | removeAddressee( lse ); |
587 | } | 611 | } |
588 | 612 | ||
589 | } | 613 | } |
590 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) | 614 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) |
591 | { | 615 | { |
592 | Iterator ait; | 616 | Iterator ait; |
593 | for ( ait = begin(); ait != end(); ++ait ) { | 617 | for ( ait = begin(); ait != end(); ++ait ) { |
594 | QString id = (*ait).IDStr(); | 618 | QString id = (*ait).IDStr(); |
595 | (*ait).setIDStr( ":"); | 619 | (*ait).setIDStr( ":"); |
596 | (*ait).setExternalUID( id ); | 620 | (*ait).setExternalUID( id ); |
597 | (*ait).setOriginalExternalUID( id ); | 621 | (*ait).setOriginalExternalUID( id ); |
598 | if ( isPreSync ) | 622 | if ( isPreSync ) |
599 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 623 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
600 | else { | 624 | else { |
601 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 625 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
602 | (*ait).setID( currentSyncDevice,id ); | 626 | (*ait).setID( currentSyncDevice,id ); |
603 | 627 | ||
604 | } | 628 | } |
605 | } | 629 | } |
606 | } | 630 | } |
607 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) | 631 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) |
608 | { | 632 | { |
609 | 633 | ||
610 | setUntagged(); | 634 | setUntagged(); |
611 | KABC::Addressee::List list; | 635 | KABC::Addressee::List list; |
612 | QFile file( fileName ); | 636 | QFile file( fileName ); |
613 | file.open( IO_ReadOnly ); | 637 | file.open( IO_ReadOnly ); |
614 | QByteArray rawData = file.readAll(); | 638 | QByteArray rawData = file.readAll(); |
615 | file.close(); | 639 | file.close(); |
616 | QString data; | 640 | QString data; |
617 | 641 | ||
618 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 642 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
619 | KABC::VCardTool tool; | 643 | KABC::VCardTool tool; |
620 | list = tool.parseVCards( data ); | 644 | list = tool.parseVCards( data ); |
621 | KABC::Addressee::List::Iterator it; | 645 | KABC::Addressee::List::Iterator it; |
622 | for ( it = list.begin(); it != list.end(); ++it ) { | 646 | for ( it = list.begin(); it != list.end(); ++it ) { |
623 | Iterator ait; | 647 | Iterator ait; |
624 | for ( ait = begin(); ait != end(); ++ait ) { | 648 | for ( ait = begin(); ait != end(); ++ait ) { |
625 | if ( !(*ait).tagged() ) { | 649 | if ( !(*ait).tagged() ) { |
626 | if ( (*ait).containsAdr(*it)) { | 650 | if ( (*ait).containsAdr(*it)) { |
627 | (*ait).setTagged(true); | 651 | (*ait).setTagged(true); |
628 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 652 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
629 | (*it).setIDStr( ":"); | 653 | (*it).setIDStr( ":"); |
630 | (*it).setID( currentSyncDevice,id ); | 654 | (*it).setID( currentSyncDevice,id ); |
631 | (*it).setExternalUID( id ); | 655 | (*it).setExternalUID( id ); |
632 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 656 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
633 | (*it).setUid( ( (*ait).uid() )); | 657 | (*it).setUid( ( (*ait).uid() )); |
634 | break; | 658 | break; |
635 | } | 659 | } |
636 | } | 660 | } |
637 | 661 | ||
638 | } | 662 | } |
639 | if ( ait == end() ) | 663 | if ( ait == end() ) |
640 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); | 664 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); |
641 | } | 665 | } |
642 | clear(); | 666 | clear(); |
643 | for ( it = list.begin(); it != list.end(); ++it ) { | 667 | for ( it = list.begin(); it != list.end(); ++it ) { |
644 | insertAddressee( (*it) ); | 668 | insertAddressee( (*it) ); |
645 | } | 669 | } |
646 | } | 670 | } |
647 | 671 | ||
648 | bool AddressBook::saveABphone( QString fileName ) | 672 | bool AddressBook::saveABphone( QString fileName ) |
649 | { | 673 | { |
650 | //smplifyAddressees(); | 674 | //smplifyAddressees(); |
651 | qDebug("saveABphone:: saving AB... "); | 675 | qDebug("saveABphone:: saving AB... "); |
652 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) | 676 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) |
653 | return false; | 677 | return false; |
654 | qDebug("saveABphone:: writing to phone... "); | 678 | qDebug("saveABphone:: writing to phone... "); |
655 | if ( !PhoneAccess::writeToPhone( fileName) ) { | 679 | if ( !PhoneAccess::writeToPhone( fileName) ) { |
656 | return false; | 680 | return false; |
657 | } | 681 | } |
658 | qDebug("saveABphone:: re-reading from phone... "); | 682 | qDebug("saveABphone:: re-reading from phone... "); |
659 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 683 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
660 | return false; | 684 | return false; |
661 | } | 685 | } |
662 | return true; | 686 | return true; |
663 | } | 687 | } |
664 | bool AddressBook::saveAB() | 688 | bool AddressBook::saveAB() |
665 | { | 689 | { |
666 | bool ok = true; | 690 | bool ok = true; |
667 | 691 | ||
668 | deleteRemovedAddressees(); | 692 | deleteRemovedAddressees(); |
669 | Iterator ait; | 693 | Iterator ait; |
670 | for ( ait = begin(); ait != end(); ++ait ) { | 694 | for ( ait = begin(); ait != end(); ++ait ) { |
671 | if ( !(*ait).IDStr().isEmpty() ) { | 695 | if ( !(*ait).IDStr().isEmpty() ) { |
672 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 696 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
673 | } | 697 | } |
674 | } | 698 | } |
675 | KRES::Manager<Resource>::ActiveIterator it; | 699 | KRES::Manager<Resource>::ActiveIterator it; |
676 | KRES::Manager<Resource> *manager = d->mManager; | 700 | KRES::Manager<Resource> *manager = d->mManager; |
677 | qDebug("SaveAB::saving..." ); | 701 | qDebug("SaveAB::saving..." ); |
678 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 702 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
679 | qDebug("SaveAB::checking resource..." ); | 703 | qDebug("SaveAB::checking resource..." ); |
680 | if ( (*it)->readOnly() ) | 704 | if ( (*it)->readOnly() ) |
681 | qDebug("SaveAB::resource is readonly." ); | 705 | qDebug("SaveAB::resource is readonly." ); |
682 | if ( (*it)->isOpen() ) | 706 | if ( (*it)->isOpen() ) |
683 | qDebug("SaveAB::resource is open" ); | 707 | qDebug("SaveAB::resource is open" ); |
684 | 708 | ||
685 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 709 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
686 | Ticket *ticket = requestSaveTicket( *it ); | 710 | Ticket *ticket = requestSaveTicket( *it ); |
687 | qDebug("SaveAB::StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 711 | qDebug("SaveAB::StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
688 | if ( !ticket ) { | 712 | if ( !ticket ) { |
689 | qDebug( i18n( "SaveAB::Unable to save to resource '%1'. It is locked." ) | 713 | qDebug( i18n( "SaveAB::Unable to save to resource '%1'. It is locked." ) |
690 | .arg( (*it)->resourceName() ) ); | 714 | .arg( (*it)->resourceName() ) ); |
691 | return false; | 715 | return false; |
692 | } | 716 | } |
693 | 717 | ||
694 | //if ( !save( ticket ) ) | 718 | //if ( !save( ticket ) ) |
695 | if ( ticket->resource() ) { | 719 | if ( ticket->resource() ) { |
696 | QString name = ticket->resource()->resourceName(); | 720 | QString name = ticket->resource()->resourceName(); |
697 | if ( ! ticket->resource()->save( ticket ) ) | 721 | if ( ! ticket->resource()->save( ticket ) ) |
698 | ok = false; | 722 | ok = false; |
699 | else | 723 | else |
700 | qDebug("SaveAB::resource saved '%s'", name.latin1() ); | 724 | qDebug("SaveAB::resource saved '%s'", name.latin1() ); |
701 | 725 | ||
702 | } else | 726 | } else |
703 | ok = false; | 727 | ok = false; |
704 | 728 | ||
705 | } | 729 | } |
706 | } | 730 | } |
707 | return ok; | 731 | return ok; |
708 | } | 732 | } |
709 | 733 | ||
710 | AddressBook::Iterator AddressBook::begin() | 734 | AddressBook::Iterator AddressBook::begin() |
711 | { | 735 | { |
712 | Iterator it = Iterator(); | 736 | Iterator it = Iterator(); |
713 | it.d->mIt = d->mAddressees.begin(); | 737 | it.d->mIt = d->mAddressees.begin(); |
714 | return it; | 738 | return it; |
715 | } | 739 | } |
716 | 740 | ||
717 | AddressBook::ConstIterator AddressBook::begin() const | 741 | AddressBook::ConstIterator AddressBook::begin() const |
718 | { | 742 | { |
719 | ConstIterator it = ConstIterator(); | 743 | ConstIterator it = ConstIterator(); |
720 | it.d->mIt = d->mAddressees.begin(); | 744 | it.d->mIt = d->mAddressees.begin(); |
721 | return it; | 745 | return it; |
722 | } | 746 | } |
723 | 747 | ||
724 | AddressBook::Iterator AddressBook::end() | 748 | AddressBook::Iterator AddressBook::end() |
725 | { | 749 | { |
726 | Iterator it = Iterator(); | 750 | Iterator it = Iterator(); |
727 | it.d->mIt = d->mAddressees.end(); | 751 | it.d->mIt = d->mAddressees.end(); |
728 | return it; | 752 | return it; |
729 | } | 753 | } |
730 | 754 | ||
731 | AddressBook::ConstIterator AddressBook::end() const | 755 | AddressBook::ConstIterator AddressBook::end() const |
732 | { | 756 | { |
733 | ConstIterator it = ConstIterator(); | 757 | ConstIterator it = ConstIterator(); |
734 | it.d->mIt = d->mAddressees.end(); | 758 | it.d->mIt = d->mAddressees.end(); |
735 | return it; | 759 | return it; |
736 | } | 760 | } |
737 | 761 | ||
738 | void AddressBook::clear() | 762 | void AddressBook::clear() |
739 | { | 763 | { |
740 | d->mAddressees.clear(); | 764 | d->mAddressees.clear(); |
741 | } | 765 | } |
742 | 766 | ||
743 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 767 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
744 | { | 768 | { |
745 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 769 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
746 | 770 | ||
747 | if ( !resource ) | 771 | if ( !resource ) |
748 | { | 772 | { |
749 | qDebug("AddressBook::requestSaveTicket no resource" ); | 773 | qDebug("AddressBook::requestSaveTicket no resource" ); |
750 | resource = standardResource(); | 774 | resource = standardResource(); |
751 | } | 775 | } |
752 | 776 | ||
753 | KRES::Manager<Resource>::ActiveIterator it; | 777 | KRES::Manager<Resource>::ActiveIterator it; |
754 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 778 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
755 | if ( (*it) == resource ) { | 779 | if ( (*it) == resource ) { |
756 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 780 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
757 | return 0; | 781 | return 0; |
758 | else | 782 | else |
759 | return (*it)->requestSaveTicket(); | 783 | return (*it)->requestSaveTicket(); |
760 | } | 784 | } |
761 | } | 785 | } |
762 | 786 | ||
763 | return 0; | 787 | return 0; |
764 | } | 788 | } |
765 | //void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 789 | //void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
766 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 790 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) |
767 | { | 791 | { |
768 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 792 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
769 | //qDebug("block insert "); | 793 | //qDebug("block insert "); |
770 | return; | 794 | return; |
771 | } | 795 | } |
772 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 796 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
773 | bool found = false; | 797 | bool found = false; |
774 | Addressee::List::Iterator it; | 798 | Addressee::List::Iterator it; |
775 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 799 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
776 | if ( a.uid() == (*it).uid() ) { | 800 | if ( a.uid() == (*it).uid() ) { |
777 | 801 | ||
778 | bool changed = false; | 802 | bool changed = false; |
779 | Addressee addr = a; | 803 | Addressee addr = a; |
780 | if ( addr != (*it) ) | 804 | if ( addr != (*it) ) |
781 | changed = true; | 805 | changed = true; |
782 | 806 | ||
783 | if ( takeResource ) { | 807 | if ( takeResource ) { |
784 | Resource * res = (*it).resource(); | 808 | Resource * res = (*it).resource(); |
785 | (*it) = a; | 809 | (*it) = a; |
786 | (*it).setResource( res ); | 810 | (*it).setResource( res ); |
787 | } else { | 811 | } else { |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 4a0d0a3..e6daa5e 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,350 +1,350 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_ADDRESSBOOK_H | 28 | #ifndef KABC_ADDRESSBOOK_H |
29 | #define KABC_ADDRESSBOOK_H | 29 | #define KABC_ADDRESSBOOK_H |
30 | 30 | ||
31 | #include <qobject.h> | 31 | #include <qobject.h> |
32 | 32 | ||
33 | #include <kresources/manager.h> | 33 | #include <kresources/manager.h> |
34 | #include <qptrlist.h> | 34 | #include <qptrlist.h> |
35 | 35 | ||
36 | #include "addressee.h" | 36 | #include "addressee.h" |
37 | #include "field.h" | 37 | #include "field.h" |
38 | 38 | ||
39 | namespace KABC { | 39 | namespace KABC { |
40 | 40 | ||
41 | class ErrorHandler; | 41 | class ErrorHandler; |
42 | class Resource; | 42 | class Resource; |
43 | class Ticket; | 43 | class Ticket; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | @short Address Book | 46 | @short Address Book |
47 | 47 | ||
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 | */ |
50 | class AddressBook : public QObject | 50 | class 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 | bool saveAB( ); |
145 | bool saveABphone( QString fileName ); | 145 | bool saveABphone( QString fileName ); |
146 | void smplifyAddressees(); | 146 | void smplifyAddressees(); |
147 | void removeSyncInfo( QString syncProfile); | 147 | void removeSyncInfo( QString syncProfile); |
148 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); | 148 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); |
149 | void export2File( QString fileName, QString resourceName = "" ); | 149 | void export2File( QString fileName, QString resourceName = "" ); |
150 | bool export2PhoneFormat( QStringList uids ,QString fileName ); | 150 | bool export2PhoneFormat( QStringList uids ,QString fileName ); |
151 | int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); | 151 | int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false, QString resource = "" ); |
152 | void setUntagged( bool setNonSyncTagged = false ); | 152 | void setUntagged( bool setNonSyncTagged = false, QString resource = "" ); |
153 | void removeUntagged(); | 153 | void removeUntagged(); |
154 | void findNewExtIds( QString fileName, QString currentSyncDevice ); | 154 | void findNewExtIds( QString fileName, QString currentSyncDevice ); |
155 | /** | 155 | /** |
156 | Returns a iterator for first entry of address book. | 156 | Returns a iterator for first entry of address book. |
157 | */ | 157 | */ |
158 | Iterator begin(); | 158 | Iterator begin(); |
159 | 159 | ||
160 | /** | 160 | /** |
161 | Returns a const iterator for first entry of address book. | 161 | Returns a const iterator for first entry of address book. |
162 | */ | 162 | */ |
163 | ConstIterator begin() const; | 163 | ConstIterator begin() const; |
164 | 164 | ||
165 | /** | 165 | /** |
166 | Returns a iterator for first entry of address book. | 166 | Returns a iterator for first entry of address book. |
167 | */ | 167 | */ |
168 | Iterator end(); | 168 | Iterator end(); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | Returns a const iterator for first entry of address book. | 171 | Returns a const iterator for first entry of address book. |
172 | */ | 172 | */ |
173 | ConstIterator end() const; | 173 | ConstIterator end() const; |
174 | 174 | ||
175 | /** | 175 | /** |
176 | Removes all entries from address book. | 176 | Removes all entries from address book. |
177 | */ | 177 | */ |
178 | void clear(); | 178 | void clear(); |
179 | 179 | ||
180 | /** | 180 | /** |
181 | Insert an Addressee object into address book. If an object with the same | 181 | Insert an Addressee object into address book. If an object with the same |
182 | unique id already exists in the address book it it replaced by the new | 182 | unique id already exists in the address book it it replaced by the new |
183 | one. If not the new object is appended to the address book. | 183 | one. If not the new object is appended to the address book. |
184 | */ | 184 | */ |
185 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 185 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
186 | 186 | ||
187 | /** | 187 | /** |
188 | Removes entry from the address book. | 188 | Removes entry from the address book. |
189 | */ | 189 | */ |
190 | void removeAddressee( const Addressee & ); | 190 | void removeAddressee( const Addressee & ); |
191 | 191 | ||
192 | /** | 192 | /** |
193 | This is like @ref removeAddressee() just above, with the difference that | 193 | This is like @ref removeAddressee() just above, with the difference that |
194 | the first element is a iterator, returned by @ref begin(). | 194 | the first element is a iterator, returned by @ref begin(). |
195 | */ | 195 | */ |
196 | void removeAddressee( const Iterator & ); | 196 | void removeAddressee( const Iterator & ); |
197 | 197 | ||
198 | /** | 198 | /** |
199 | Find the specified entry in address book. Returns end(), if the entry | 199 | Find the specified entry in address book. Returns end(), if the entry |
200 | couldn't be found. | 200 | couldn't be found. |
201 | */ | 201 | */ |
202 | Iterator find( const Addressee & ); | 202 | Iterator find( const Addressee & ); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | Find the entry specified by an unique id. Returns an empty Addressee | 205 | Find the entry specified by an unique id. Returns an empty Addressee |
206 | object, if the address book does not contain an entry with this id. | 206 | object, if the address book does not contain an entry with this id. |
207 | */ | 207 | */ |
208 | Addressee findByUid( const QString & ); | 208 | Addressee findByUid( const QString & ); |
209 | 209 | ||
210 | 210 | ||
211 | /** | 211 | /** |
212 | Returns a list of all addressees in the address book. This list can | 212 | Returns a list of all addressees in the address book. This list can |
213 | be sorted with @ref KABC::AddresseeList for example. | 213 | be sorted with @ref KABC::AddresseeList for example. |
214 | */ | 214 | */ |
215 | Addressee::List allAddressees(); | 215 | Addressee::List allAddressees(); |
216 | 216 | ||
217 | /** | 217 | /** |
218 | Find all entries with the specified name in the address book. Returns | 218 | Find all entries with the specified name in the address book. Returns |
219 | an empty list, if no entries could be found. | 219 | an empty list, if no entries could be found. |
220 | */ | 220 | */ |
221 | Addressee::List findByName( const QString & ); | 221 | Addressee::List findByName( const QString & ); |
222 | 222 | ||
223 | /** | 223 | /** |
224 | Find all entries with the specified email address in the address book. | 224 | Find all entries with the specified email address in the address book. |
225 | Returns an empty list, if no entries could be found. | 225 | Returns an empty list, if no entries could be found. |
226 | */ | 226 | */ |
227 | Addressee::List findByEmail( const QString & ); | 227 | Addressee::List findByEmail( const QString & ); |
228 | 228 | ||
229 | /** | 229 | /** |
230 | Find all entries wich have the specified category in the address book. | 230 | Find all entries wich have the specified category in the address book. |
231 | Returns an empty list, if no entries could be found. | 231 | Returns an empty list, if no entries could be found. |
232 | */ | 232 | */ |
233 | Addressee::List findByCategory( const QString & ); | 233 | Addressee::List findByCategory( const QString & ); |
234 | 234 | ||
235 | /** | 235 | /** |
236 | Return a string identifying this addressbook. | 236 | Return a string identifying this addressbook. |
237 | */ | 237 | */ |
238 | virtual QString identifier(); | 238 | virtual QString identifier(); |
239 | 239 | ||
240 | /** | 240 | /** |
241 | Used for debug output. | 241 | Used for debug output. |
242 | */ | 242 | */ |
243 | void dump() const; | 243 | void dump() const; |
244 | 244 | ||
245 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 245 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
246 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 246 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
247 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 247 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
248 | 248 | ||
249 | /** | 249 | /** |
250 | Return list of all Fields known to the address book which are associated | 250 | Return list of all Fields known to the address book which are associated |
251 | with the given field category. | 251 | with the given field category. |
252 | */ | 252 | */ |
253 | Field::List fields( int category = Field::All ); | 253 | Field::List fields( int category = Field::All ); |
254 | 254 | ||
255 | /** | 255 | /** |
256 | Add custom field to address book. | 256 | Add custom field to address book. |
257 | 257 | ||
258 | @param label User visible label of the field. | 258 | @param label User visible label of the field. |
259 | @param category Ored list of field categories. | 259 | @param category Ored list of field categories. |
260 | @param key Identifier used as key for reading and writing the field. | 260 | @param key Identifier used as key for reading and writing the field. |
261 | @param app String used as application key for reading and writing | 261 | @param app String used as application key for reading and writing |
262 | the field. | 262 | the field. |
263 | */ | 263 | */ |
264 | bool addCustomField( const QString &label, int category = Field::All, | 264 | bool addCustomField( const QString &label, int category = Field::All, |
265 | const QString &key = QString::null, | 265 | const QString &key = QString::null, |
266 | const QString &app = QString::null ); | 266 | const QString &app = QString::null ); |
267 | 267 | ||
268 | 268 | ||
269 | /** | 269 | /** |
270 | Add address book resource. | 270 | Add address book resource. |
271 | */ | 271 | */ |
272 | bool addResource( Resource * ); | 272 | bool addResource( Resource * ); |
273 | 273 | ||
274 | /** | 274 | /** |
275 | Remove address book resource. | 275 | Remove address book resource. |
276 | */ | 276 | */ |
277 | void removeResources(); | 277 | void removeResources(); |
278 | bool removeResource( Resource * ); | 278 | bool removeResource( Resource * ); |
279 | 279 | ||
280 | /** | 280 | /** |
281 | Return pointer list of all resources. | 281 | Return pointer list of all resources. |
282 | */ | 282 | */ |
283 | QPtrList<Resource> resources(); | 283 | QPtrList<Resource> resources(); |
284 | 284 | ||
285 | /** | 285 | /** |
286 | Set the @p ErrorHandler, that is used by @ref error() to | 286 | Set the @p ErrorHandler, that is used by @ref error() to |
287 | provide gui-independend error messages. | 287 | provide gui-independend error messages. |
288 | */ | 288 | */ |
289 | void setErrorHandler( ErrorHandler * ); | 289 | void setErrorHandler( ErrorHandler * ); |
290 | 290 | ||
291 | /** | 291 | /** |
292 | Shows gui independend error messages. | 292 | Shows gui independend error messages. |
293 | */ | 293 | */ |
294 | void error( const QString& ); | 294 | void error( const QString& ); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | Query all resources to clean up their lock files | 297 | Query all resources to clean up their lock files |
298 | */ | 298 | */ |
299 | void cleanUp(); | 299 | void cleanUp(); |
300 | 300 | ||
301 | // sync stuff | 301 | // sync stuff |
302 | //Addressee::List getExternLastSyncAddressees(); | 302 | //Addressee::List getExternLastSyncAddressees(); |
303 | void resetTempSyncStat(); | 303 | void resetTempSyncStat(); |
304 | QStringList uidList(); | 304 | QStringList uidList(); |
305 | void removeSyncAddressees( bool removeDeleted = false ); | 305 | void removeSyncAddressees( bool removeDeleted = false ); |
306 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); | 306 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); |
307 | const Addressee findByExternUid( const QString& uid , const QString& profile ) const; | 307 | const Addressee findByExternUid( const QString& uid , const QString& profile ) const; |
308 | bool containsExternalUid( const QString& uid ); | 308 | bool containsExternalUid( const QString& uid ); |
309 | 309 | ||
310 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); | 310 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); |
311 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); | 311 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); |
312 | signals: | 312 | signals: |
313 | /** | 313 | /** |
314 | Emitted, when the address book has changed on disk. | 314 | Emitted, when the address book has changed on disk. |
315 | */ | 315 | */ |
316 | void addressBookChanged( AddressBook * ); | 316 | void addressBookChanged( AddressBook * ); |
317 | 317 | ||
318 | /** | 318 | /** |
319 | Emitted, when the address book has been locked for writing. | 319 | Emitted, when the address book has been locked for writing. |
320 | */ | 320 | */ |
321 | void addressBookLocked( AddressBook * ); | 321 | void addressBookLocked( AddressBook * ); |
322 | 322 | ||
323 | /** | 323 | /** |
324 | Emitted, when the address book has been unlocked. | 324 | Emitted, when the address book has been unlocked. |
325 | */ | 325 | */ |
326 | void addressBookUnlocked( AddressBook * ); | 326 | void addressBookUnlocked( AddressBook * ); |
327 | 327 | ||
328 | protected: | 328 | protected: |
329 | void deleteRemovedAddressees(); | 329 | void deleteRemovedAddressees(); |
330 | void setStandardResource( Resource * ); | 330 | void setStandardResource( Resource * ); |
331 | Resource *standardResource(); | 331 | Resource *standardResource(); |
332 | KRES::Manager<Resource> *resourceManager(); | 332 | KRES::Manager<Resource> *resourceManager(); |
333 | 333 | ||
334 | void init(const QString &config, const QString &family); | 334 | void init(const QString &config, const QString &family); |
335 | 335 | ||
336 | private: | 336 | private: |
337 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 337 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
338 | 338 | ||
339 | 339 | ||
340 | struct AddressBookData; | 340 | struct AddressBookData; |
341 | AddressBookData *d; | 341 | AddressBookData *d; |
342 | bool blockLSEchange; | 342 | bool blockLSEchange; |
343 | }; | 343 | }; |
344 | 344 | ||
345 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 345 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
346 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 346 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
347 | 347 | ||
348 | } | 348 | } |
349 | 349 | ||
350 | #endif | 350 | #endif |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 5d377bf..7d8586a 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1684,513 +1684,513 @@ void KABCore::openConfigDialog() | |||
1684 | kabcfg, SLOT( save() ) ); | 1684 | kabcfg, SLOT( save() ) ); |
1685 | connect( ConfigureDialog, SIGNAL( acceptClicked() ), | 1685 | connect( ConfigureDialog, SIGNAL( acceptClicked() ), |
1686 | this, SLOT( configurationChanged() ) ); | 1686 | this, SLOT( configurationChanged() ) ); |
1687 | connect( ConfigureDialog, SIGNAL( acceptClicked() ), | 1687 | connect( ConfigureDialog, SIGNAL( acceptClicked() ), |
1688 | kabcfg, SLOT( save() ) ); | 1688 | kabcfg, SLOT( save() ) ); |
1689 | connect( ConfigureDialog, SIGNAL( defaultClicked() ), | 1689 | connect( ConfigureDialog, SIGNAL( defaultClicked() ), |
1690 | kabcfg, SLOT( defaults() ) ); | 1690 | kabcfg, SLOT( defaults() ) ); |
1691 | saveSettings(); | 1691 | saveSettings(); |
1692 | kabcfg->load(); | 1692 | kabcfg->load(); |
1693 | #ifndef DESKTOP_VERSION | 1693 | #ifndef DESKTOP_VERSION |
1694 | if ( QApplication::desktop()->height() <= 480 ) | 1694 | if ( QApplication::desktop()->height() <= 480 ) |
1695 | ConfigureDialog->hideButtons(); | 1695 | ConfigureDialog->hideButtons(); |
1696 | ConfigureDialog->showMaximized(); | 1696 | ConfigureDialog->showMaximized(); |
1697 | #endif | 1697 | #endif |
1698 | if ( ConfigureDialog->exec() ) | 1698 | if ( ConfigureDialog->exec() ) |
1699 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1699 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1700 | delete ConfigureDialog; | 1700 | delete ConfigureDialog; |
1701 | } | 1701 | } |
1702 | 1702 | ||
1703 | void KABCore::openLDAPDialog() | 1703 | void KABCore::openLDAPDialog() |
1704 | { | 1704 | { |
1705 | #ifndef KAB_EMBEDDED | 1705 | #ifndef KAB_EMBEDDED |
1706 | if ( !mLdapSearchDialog ) { | 1706 | if ( !mLdapSearchDialog ) { |
1707 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1707 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1708 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1708 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1709 | SLOT( refreshView() ) ); | 1709 | SLOT( refreshView() ) ); |
1710 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1710 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1711 | SLOT( setModified() ) ); | 1711 | SLOT( setModified() ) ); |
1712 | } else | 1712 | } else |
1713 | mLdapSearchDialog->restoreSettings(); | 1713 | mLdapSearchDialog->restoreSettings(); |
1714 | 1714 | ||
1715 | if ( mLdapSearchDialog->isOK() ) | 1715 | if ( mLdapSearchDialog->isOK() ) |
1716 | mLdapSearchDialog->exec(); | 1716 | mLdapSearchDialog->exec(); |
1717 | #else //KAB_EMBEDDED | 1717 | #else //KAB_EMBEDDED |
1718 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1718 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1719 | #endif //KAB_EMBEDDED | 1719 | #endif //KAB_EMBEDDED |
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | void KABCore::print() | 1722 | void KABCore::print() |
1723 | { | 1723 | { |
1724 | #ifndef KAB_EMBEDDED | 1724 | #ifndef KAB_EMBEDDED |
1725 | KPrinter printer; | 1725 | KPrinter printer; |
1726 | if ( !printer.setup( this ) ) | 1726 | if ( !printer.setup( this ) ) |
1727 | return; | 1727 | return; |
1728 | 1728 | ||
1729 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1729 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1730 | mViewManager->selectedUids(), this ); | 1730 | mViewManager->selectedUids(), this ); |
1731 | 1731 | ||
1732 | wizard.exec(); | 1732 | wizard.exec(); |
1733 | #else //KAB_EMBEDDED | 1733 | #else //KAB_EMBEDDED |
1734 | qDebug("KABCore::print() finsih method"); | 1734 | qDebug("KABCore::print() finsih method"); |
1735 | #endif //KAB_EMBEDDED | 1735 | #endif //KAB_EMBEDDED |
1736 | 1736 | ||
1737 | } | 1737 | } |
1738 | 1738 | ||
1739 | 1739 | ||
1740 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1740 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1741 | { | 1741 | { |
1742 | if ( mGUIClient ) | 1742 | if ( mGUIClient ) |
1743 | mGUIClient->insertChildClient( client ); | 1743 | mGUIClient->insertChildClient( client ); |
1744 | else | 1744 | else |
1745 | KMessageBox::error( this, "no KXMLGUICLient"); | 1745 | KMessageBox::error( this, "no KXMLGUICLient"); |
1746 | } | 1746 | } |
1747 | 1747 | ||
1748 | 1748 | ||
1749 | void KABCore::configurationChanged() | 1749 | void KABCore::configurationChanged() |
1750 | { | 1750 | { |
1751 | mExtensionManager->reconfigure(); | 1751 | mExtensionManager->reconfigure(); |
1752 | } | 1752 | } |
1753 | 1753 | ||
1754 | void KABCore::addressBookChanged() | 1754 | void KABCore::addressBookChanged() |
1755 | { | 1755 | { |
1756 | /*US | 1756 | /*US |
1757 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1757 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1758 | while ( it.current() ) { | 1758 | while ( it.current() ) { |
1759 | if ( it.current()->dirty() ) { | 1759 | if ( it.current()->dirty() ) { |
1760 | QString text = i18n( "Data has been changed externally. Unsaved " | 1760 | QString text = i18n( "Data has been changed externally. Unsaved " |
1761 | "changes will be lost." ); | 1761 | "changes will be lost." ); |
1762 | KMessageBox::information( this, text ); | 1762 | KMessageBox::information( this, text ); |
1763 | } | 1763 | } |
1764 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1764 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1765 | ++it; | 1765 | ++it; |
1766 | } | 1766 | } |
1767 | */ | 1767 | */ |
1768 | if (mEditorDialog) | 1768 | if (mEditorDialog) |
1769 | { | 1769 | { |
1770 | if (mEditorDialog->dirty()) | 1770 | if (mEditorDialog->dirty()) |
1771 | { | 1771 | { |
1772 | QString text = i18n( "Data has been changed externally. Unsaved " | 1772 | QString text = i18n( "Data has been changed externally. Unsaved " |
1773 | "changes will be lost." ); | 1773 | "changes will be lost." ); |
1774 | KMessageBox::information( this, text ); | 1774 | KMessageBox::information( this, text ); |
1775 | } | 1775 | } |
1776 | QString currentuid = mEditorDialog->addressee().uid(); | 1776 | QString currentuid = mEditorDialog->addressee().uid(); |
1777 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1777 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1778 | } | 1778 | } |
1779 | mViewManager->refreshView(); | 1779 | mViewManager->refreshView(); |
1780 | 1780 | ||
1781 | 1781 | ||
1782 | } | 1782 | } |
1783 | 1783 | ||
1784 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1784 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1785 | const char *name ) | 1785 | const char *name ) |
1786 | { | 1786 | { |
1787 | 1787 | ||
1788 | if ( mEditorDialog == 0 ) { | 1788 | if ( mEditorDialog == 0 ) { |
1789 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1789 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1790 | name ? name : "editorDialog" ); | 1790 | name ? name : "editorDialog" ); |
1791 | 1791 | ||
1792 | 1792 | ||
1793 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1793 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1794 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1794 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1795 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1795 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1796 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1796 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1797 | } | 1797 | } |
1798 | 1798 | ||
1799 | return mEditorDialog; | 1799 | return mEditorDialog; |
1800 | } | 1800 | } |
1801 | 1801 | ||
1802 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1802 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1803 | { | 1803 | { |
1804 | //mEditorDict.remove( uid ); | 1804 | //mEditorDict.remove( uid ); |
1805 | } | 1805 | } |
1806 | 1806 | ||
1807 | void KABCore::initGUI() | 1807 | void KABCore::initGUI() |
1808 | { | 1808 | { |
1809 | #ifndef KAB_EMBEDDED | 1809 | #ifndef KAB_EMBEDDED |
1810 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1810 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1811 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1811 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1812 | 1812 | ||
1813 | mExtensionBarSplitter = new QSplitter( this ); | 1813 | mExtensionBarSplitter = new QSplitter( this ); |
1814 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1814 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1815 | 1815 | ||
1816 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1816 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1817 | 1817 | ||
1818 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1818 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1819 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1819 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1820 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1820 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1821 | SLOT( incrementalSearch( const QString& ) ) ); | 1821 | SLOT( incrementalSearch( const QString& ) ) ); |
1822 | 1822 | ||
1823 | mViewManager = new ViewManager( this, viewSpace ); | 1823 | mViewManager = new ViewManager( this, viewSpace ); |
1824 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1824 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1825 | 1825 | ||
1826 | mDetails = new ViewContainer( mDetailsSplitter ); | 1826 | mDetails = new ViewContainer( mDetailsSplitter ); |
1827 | 1827 | ||
1828 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1828 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1829 | 1829 | ||
1830 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1830 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1831 | 1831 | ||
1832 | topLayout->addWidget( mExtensionBarSplitter ); | 1832 | topLayout->addWidget( mExtensionBarSplitter ); |
1833 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1833 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1834 | topLayout->addWidget( mJumpButtonBar ); | 1834 | topLayout->addWidget( mJumpButtonBar ); |
1835 | //topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1835 | //topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1836 | 1836 | ||
1837 | mXXPortManager = new XXPortManager( this, this ); | 1837 | mXXPortManager = new XXPortManager( this, this ); |
1838 | 1838 | ||
1839 | #else //KAB_EMBEDDED | 1839 | #else //KAB_EMBEDDED |
1840 | //US initialize viewMenu before settingup viewmanager. | 1840 | //US initialize viewMenu before settingup viewmanager. |
1841 | // Viewmanager needs this menu to plugin submenues. | 1841 | // Viewmanager needs this menu to plugin submenues. |
1842 | viewMenu = new QPopupMenu( this ); | 1842 | viewMenu = new QPopupMenu( this ); |
1843 | settingsMenu = new QPopupMenu( this ); | 1843 | settingsMenu = new QPopupMenu( this ); |
1844 | //filterMenu = new QPopupMenu( this ); | 1844 | //filterMenu = new QPopupMenu( this ); |
1845 | ImportMenu = new QPopupMenu( this ); | 1845 | ImportMenu = new QPopupMenu( this ); |
1846 | ExportMenu = new QPopupMenu( this ); | 1846 | ExportMenu = new QPopupMenu( this ); |
1847 | syncMenu = new QPopupMenu( this ); | 1847 | syncMenu = new QPopupMenu( this ); |
1848 | changeMenu= new QPopupMenu( this ); | 1848 | changeMenu= new QPopupMenu( this ); |
1849 | beamMenu= new QPopupMenu( this ); | 1849 | beamMenu= new QPopupMenu( this ); |
1850 | 1850 | ||
1851 | //US since we have no splitter for the embedded system, setup | 1851 | //US since we have no splitter for the embedded system, setup |
1852 | // a layout with two frames. One left and one right. | 1852 | // a layout with two frames. One left and one right. |
1853 | 1853 | ||
1854 | QBoxLayout *topLayout; | 1854 | QBoxLayout *topLayout; |
1855 | 1855 | ||
1856 | // = new QHBoxLayout( this ); | 1856 | // = new QHBoxLayout( this ); |
1857 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1857 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1858 | 1858 | ||
1859 | // QWidget *mainBox = new QWidget( this ); | 1859 | // QWidget *mainBox = new QWidget( this ); |
1860 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1860 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1861 | 1861 | ||
1862 | #ifdef DESKTOP_VERSION | 1862 | #ifdef DESKTOP_VERSION |
1863 | topLayout = new QHBoxLayout( this ); | 1863 | topLayout = new QHBoxLayout( this ); |
1864 | 1864 | ||
1865 | 1865 | ||
1866 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1866 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1867 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1867 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1868 | 1868 | ||
1869 | topLayout->addWidget(mMiniSplitter ); | 1869 | topLayout->addWidget(mMiniSplitter ); |
1870 | 1870 | ||
1871 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1871 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1872 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1872 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1873 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1873 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1874 | mDetails = new ViewContainer( mMiniSplitter ); | 1874 | mDetails = new ViewContainer( mMiniSplitter ); |
1875 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1875 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1876 | #else | 1876 | #else |
1877 | if ( QApplication::desktop()->width() > 480 ) { | 1877 | if ( QApplication::desktop()->width() > 480 ) { |
1878 | topLayout = new QHBoxLayout( this ); | 1878 | topLayout = new QHBoxLayout( this ); |
1879 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1879 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1880 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1880 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1881 | } else { | 1881 | } else { |
1882 | 1882 | ||
1883 | topLayout = new QHBoxLayout( this ); | 1883 | topLayout = new QHBoxLayout( this ); |
1884 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1884 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1885 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1885 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1886 | } | 1886 | } |
1887 | 1887 | ||
1888 | topLayout->addWidget(mMiniSplitter ); | 1888 | topLayout->addWidget(mMiniSplitter ); |
1889 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1889 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1890 | mDetails = new ViewContainer( mMiniSplitter ); | 1890 | mDetails = new ViewContainer( mMiniSplitter ); |
1891 | 1891 | ||
1892 | 1892 | ||
1893 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1893 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1894 | #endif | 1894 | #endif |
1895 | //eh->hide(); | 1895 | //eh->hide(); |
1896 | // topLayout->addWidget(mExtensionManager ); | 1896 | // topLayout->addWidget(mExtensionManager ); |
1897 | 1897 | ||
1898 | 1898 | ||
1899 | /*US | 1899 | /*US |
1900 | #ifndef KAB_NOSPLITTER | 1900 | #ifndef KAB_NOSPLITTER |
1901 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1901 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1902 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1902 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1903 | topLayout->setSpacing( 10 ); | 1903 | topLayout->setSpacing( 10 ); |
1904 | 1904 | ||
1905 | mDetailsSplitter = new QSplitter( this ); | 1905 | mDetailsSplitter = new QSplitter( this ); |
1906 | 1906 | ||
1907 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1907 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1908 | 1908 | ||
1909 | mViewManager = new ViewManager( this, viewSpace ); | 1909 | mViewManager = new ViewManager( this, viewSpace ); |
1910 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1910 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1911 | 1911 | ||
1912 | mDetails = new ViewContainer( mDetailsSplitter ); | 1912 | mDetails = new ViewContainer( mDetailsSplitter ); |
1913 | 1913 | ||
1914 | topLayout->addWidget( mDetailsSplitter ); | 1914 | topLayout->addWidget( mDetailsSplitter ); |
1915 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1915 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1916 | #else //KAB_NOSPLITTER | 1916 | #else //KAB_NOSPLITTER |
1917 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1917 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1918 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1918 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1919 | topLayout->setSpacing( 10 ); | 1919 | topLayout->setSpacing( 10 ); |
1920 | 1920 | ||
1921 | // mDetailsSplitter = new QSplitter( this ); | 1921 | // mDetailsSplitter = new QSplitter( this ); |
1922 | 1922 | ||
1923 | QVBox *viewSpace = new QVBox( this ); | 1923 | QVBox *viewSpace = new QVBox( this ); |
1924 | 1924 | ||
1925 | mViewManager = new ViewManager( this, viewSpace ); | 1925 | mViewManager = new ViewManager( this, viewSpace ); |
1926 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1926 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1927 | 1927 | ||
1928 | mDetails = new ViewContainer( this ); | 1928 | mDetails = new ViewContainer( this ); |
1929 | 1929 | ||
1930 | topLayout->addWidget( viewSpace ); | 1930 | topLayout->addWidget( viewSpace ); |
1931 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1931 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1932 | topLayout->addWidget( mDetails ); | 1932 | topLayout->addWidget( mDetails ); |
1933 | #endif //KAB_NOSPLITTER | 1933 | #endif //KAB_NOSPLITTER |
1934 | */ | 1934 | */ |
1935 | 1935 | ||
1936 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1936 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1937 | syncManager->setBlockSave(false); | 1937 | syncManager->setBlockSave(false); |
1938 | 1938 | ||
1939 | connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); | 1939 | connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); |
1940 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1940 | connect(syncManager , SIGNAL( getFile( bool ,const QString &)), this, SLOT(getFile( bool ,const QString &) ) ); |
1941 | QString sync_file = sentSyncFile(); | 1941 | QString sync_file = sentSyncFile(); |
1942 | //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); | 1942 | //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); |
1943 | syncManager->setDefaultFileName( sync_file ); | 1943 | syncManager->setDefaultFileName( sync_file ); |
1944 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1944 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1945 | 1945 | ||
1946 | #endif //KAB_EMBEDDED | 1946 | #endif //KAB_EMBEDDED |
1947 | initActions(); | 1947 | initActions(); |
1948 | 1948 | ||
1949 | #ifdef KAB_EMBEDDED | 1949 | #ifdef KAB_EMBEDDED |
1950 | addActionsManually(); | 1950 | addActionsManually(); |
1951 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1951 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1952 | mXXPortManager = new XXPortManager( this, this ); | 1952 | mXXPortManager = new XXPortManager( this, this ); |
1953 | 1953 | ||
1954 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1954 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1955 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1955 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1956 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1956 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1957 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1957 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1958 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1958 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1959 | // mIncSearchWidget->hide(); | 1959 | // mIncSearchWidget->hide(); |
1960 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1960 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1961 | SLOT( incrementalSearch( const QString& ) ) ); | 1961 | SLOT( incrementalSearch( const QString& ) ) ); |
1962 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1962 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1963 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1963 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1964 | 1964 | ||
1965 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1965 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1966 | 1966 | ||
1967 | topLayout->addWidget( mJumpButtonBar ); | 1967 | topLayout->addWidget( mJumpButtonBar ); |
1968 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1968 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1969 | 1969 | ||
1970 | // mMainWindow->getIconToolBar()->raise(); | 1970 | // mMainWindow->getIconToolBar()->raise(); |
1971 | 1971 | ||
1972 | #endif //KAB_EMBEDDED | 1972 | #endif //KAB_EMBEDDED |
1973 | 1973 | ||
1974 | } | 1974 | } |
1975 | void KABCore::initActions() | 1975 | void KABCore::initActions() |
1976 | { | 1976 | { |
1977 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1977 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1978 | 1978 | ||
1979 | #ifndef KAB_EMBEDDED | 1979 | #ifndef KAB_EMBEDDED |
1980 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1980 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1981 | SLOT( clipboardDataChanged() ) ); | 1981 | SLOT( clipboardDataChanged() ) ); |
1982 | #endif //KAB_EMBEDDED | 1982 | #endif //KAB_EMBEDDED |
1983 | 1983 | ||
1984 | // file menu | 1984 | // file menu |
1985 | 1985 | ||
1986 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1986 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1987 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1987 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1988 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, | 1988 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, |
1989 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); | 1989 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); |
1990 | 1990 | ||
1991 | 1991 | ||
1992 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, | 1992 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, |
1993 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); | 1993 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); |
1994 | 1994 | ||
1995 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1995 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1996 | SLOT( save() ), actionCollection(), "file_sync" ); | 1996 | SLOT( save() ), actionCollection(), "file_sync" ); |
1997 | 1997 | ||
1998 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1998 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1999 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1999 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
2000 | 2000 | ||
2001 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 2001 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
2002 | this, SLOT( mailVCard() ), | 2002 | this, SLOT( mailVCard() ), |
2003 | actionCollection(), "file_mail_vcard"); | 2003 | actionCollection(), "file_mail_vcard"); |
2004 | 2004 | ||
2005 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 2005 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
2006 | SLOT( export2phone() ), actionCollection(), | 2006 | SLOT( export2phone() ), actionCollection(), |
2007 | "kaddressbook_ex2phone" ); | 2007 | "kaddressbook_ex2phone" ); |
2008 | 2008 | ||
2009 | mActionBeamVCard = 0; | 2009 | mActionBeamVCard = 0; |
2010 | mActionBeam = 0; | 2010 | mActionBeam = 0; |
2011 | 2011 | ||
2012 | #ifndef DESKTOP_VERSION | 2012 | #ifndef DESKTOP_VERSION |
2013 | if ( Ir::supported() ) { | 2013 | if ( Ir::supported() ) { |
2014 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 2014 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
2015 | SLOT( beamVCard() ), actionCollection(), | 2015 | SLOT( beamVCard() ), actionCollection(), |
2016 | "kaddressbook_beam_vcard" ); | 2016 | "kaddressbook_beam_vcard" ); |
2017 | 2017 | ||
2018 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 2018 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
2019 | SLOT( beamMySelf() ), actionCollection(), | 2019 | SLOT( beamMySelf() ), actionCollection(), |
2020 | "kaddressbook_beam_myself" ); | 2020 | "kaddressbook_beam_myself" ); |
2021 | } | 2021 | } |
2022 | #endif | 2022 | #endif |
2023 | 2023 | ||
2024 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 2024 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
2025 | this, SLOT( editContact2() ), | 2025 | this, SLOT( editContact2() ), |
2026 | actionCollection(), "file_properties" ); | 2026 | actionCollection(), "file_properties" ); |
2027 | 2027 | ||
2028 | #ifdef KAB_EMBEDDED | 2028 | #ifdef KAB_EMBEDDED |
2029 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 2029 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
2030 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 2030 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
2031 | mMainWindow, SLOT( exit() ), | 2031 | mMainWindow, SLOT( exit() ), |
2032 | actionCollection(), "quit" ); | 2032 | actionCollection(), "quit" ); |
2033 | #endif //KAB_EMBEDDED | 2033 | #endif //KAB_EMBEDDED |
2034 | 2034 | ||
2035 | // edit menu | 2035 | // edit menu |
2036 | if ( mIsPart ) { | 2036 | if ( mIsPart ) { |
2037 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 2037 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
2038 | SLOT( copyContacts() ), actionCollection(), | 2038 | SLOT( copyContacts() ), actionCollection(), |
2039 | "kaddressbook_copy" ); | 2039 | "kaddressbook_copy" ); |
2040 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 2040 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
2041 | SLOT( cutContacts() ), actionCollection(), | 2041 | SLOT( cutContacts() ), actionCollection(), |
2042 | "kaddressbook_cut" ); | 2042 | "kaddressbook_cut" ); |
2043 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 2043 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
2044 | SLOT( pasteContacts() ), actionCollection(), | 2044 | SLOT( pasteContacts() ), actionCollection(), |
2045 | "kaddressbook_paste" ); | 2045 | "kaddressbook_paste" ); |
2046 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 2046 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
2047 | SLOT( selectAllContacts() ), actionCollection(), | 2047 | SLOT( selectAllContacts() ), actionCollection(), |
2048 | "kaddressbook_select_all" ); | 2048 | "kaddressbook_select_all" ); |
2049 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 2049 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
2050 | SLOT( undo() ), actionCollection(), | 2050 | SLOT( undo() ), actionCollection(), |
2051 | "kaddressbook_undo" ); | 2051 | "kaddressbook_undo" ); |
2052 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 2052 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
2053 | this, SLOT( redo() ), actionCollection(), | 2053 | this, SLOT( redo() ), actionCollection(), |
2054 | "kaddressbook_redo" ); | 2054 | "kaddressbook_redo" ); |
2055 | } else { | 2055 | } else { |
2056 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 2056 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
2057 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 2057 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
2058 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 2058 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
2059 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 2059 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
2060 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 2060 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
2061 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 2061 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
2062 | } | 2062 | } |
2063 | 2063 | ||
2064 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 2064 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
2065 | Key_Delete, this, SLOT( deleteContacts() ), | 2065 | Key_Delete, this, SLOT( deleteContacts() ), |
2066 | actionCollection(), "edit_delete" ); | 2066 | actionCollection(), "edit_delete" ); |
2067 | 2067 | ||
2068 | mActionUndo->setEnabled( false ); | 2068 | mActionUndo->setEnabled( false ); |
2069 | mActionRedo->setEnabled( false ); | 2069 | mActionRedo->setEnabled( false ); |
2070 | 2070 | ||
2071 | // settings menu | 2071 | // settings menu |
2072 | #ifdef KAB_EMBEDDED | 2072 | #ifdef KAB_EMBEDDED |
2073 | //US special menuentry to configure the addressbook resources. On KDE | 2073 | //US special menuentry to configure the addressbook resources. On KDE |
2074 | // you do that through the control center !!! | 2074 | // you do that through the control center !!! |
2075 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 2075 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
2076 | SLOT( configureResources() ), actionCollection(), | 2076 | SLOT( configureResources() ), actionCollection(), |
2077 | "kaddressbook_configure_resources" ); | 2077 | "kaddressbook_configure_resources" ); |
2078 | #endif //KAB_EMBEDDED | 2078 | #endif //KAB_EMBEDDED |
2079 | 2079 | ||
2080 | if ( mIsPart ) { | 2080 | if ( mIsPart ) { |
2081 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 2081 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
2082 | SLOT( openConfigDialog() ), actionCollection(), | 2082 | SLOT( openConfigDialog() ), actionCollection(), |
2083 | "kaddressbook_configure" ); | 2083 | "kaddressbook_configure" ); |
2084 | 2084 | ||
2085 | //US not implemented yet | 2085 | //US not implemented yet |
2086 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 2086 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
2087 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 2087 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
2088 | // "kaddressbook_configure_shortcuts" ); | 2088 | // "kaddressbook_configure_shortcuts" ); |
2089 | #ifdef KAB_EMBEDDED | 2089 | #ifdef KAB_EMBEDDED |
2090 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 2090 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
2091 | mActionConfigureToolbars->setEnabled( false ); | 2091 | mActionConfigureToolbars->setEnabled( false ); |
2092 | #endif //KAB_EMBEDDED | 2092 | #endif //KAB_EMBEDDED |
2093 | 2093 | ||
2094 | } else { | 2094 | } else { |
2095 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, | 2095 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, |
2096 | SLOT( openConfigDialog() ), actionCollection(), | 2096 | SLOT( openConfigDialog() ), actionCollection(), |
2097 | "kaddressbook_configure" ); | 2097 | "kaddressbook_configure" ); |
2098 | mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, | 2098 | mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, |
2099 | SLOT( openConfigGlobalDialog() ), actionCollection(), | 2099 | SLOT( openConfigGlobalDialog() ), actionCollection(), |
2100 | "kaddressbook_configure" ); | 2100 | "kaddressbook_configure" ); |
2101 | } | 2101 | } |
2102 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 2102 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
2103 | actionCollection(), "options_show_jump_bar" ); | 2103 | actionCollection(), "options_show_jump_bar" ); |
2104 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); | 2104 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); |
2105 | 2105 | ||
2106 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 2106 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
2107 | actionCollection(), "options_show_details" ); | 2107 | actionCollection(), "options_show_details" ); |
2108 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 2108 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
2109 | 2109 | ||
2110 | 2110 | ||
2111 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 2111 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
2112 | SLOT( toggleBeamReceive() ), actionCollection(), | 2112 | SLOT( toggleBeamReceive() ), actionCollection(), |
2113 | "kaddressbook_beam_rec" ); | 2113 | "kaddressbook_beam_rec" ); |
2114 | 2114 | ||
2115 | 2115 | ||
2116 | // misc | 2116 | // misc |
2117 | // only enable LDAP lookup if we can handle the protocol | 2117 | // only enable LDAP lookup if we can handle the protocol |
2118 | #ifndef KAB_EMBEDDED | 2118 | #ifndef KAB_EMBEDDED |
2119 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 2119 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
2120 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 2120 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
2121 | this, SLOT( openLDAPDialog() ), actionCollection(), | 2121 | this, SLOT( openLDAPDialog() ), actionCollection(), |
2122 | "ldap_lookup" ); | 2122 | "ldap_lookup" ); |
2123 | } | 2123 | } |
2124 | #else //KAB_EMBEDDED | 2124 | #else //KAB_EMBEDDED |
2125 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 2125 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
2126 | #endif //KAB_EMBEDDED | 2126 | #endif //KAB_EMBEDDED |
2127 | 2127 | ||
2128 | 2128 | ||
2129 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 2129 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
2130 | SLOT( setWhoAmI() ), actionCollection(), | 2130 | SLOT( setWhoAmI() ), actionCollection(), |
2131 | "set_personal" ); | 2131 | "set_personal" ); |
2132 | 2132 | ||
2133 | 2133 | ||
2134 | mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, | 2134 | mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, |
2135 | SLOT( setCategories() ), actionCollection(), | 2135 | SLOT( setCategories() ), actionCollection(), |
2136 | "edit_set_categories" ); | 2136 | "edit_set_categories" ); |
2137 | mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, | 2137 | mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, |
2138 | SLOT( editCategories() ), actionCollection(), | 2138 | SLOT( editCategories() ), actionCollection(), |
2139 | "edit__categories" ); | 2139 | "edit__categories" ); |
2140 | 2140 | ||
2141 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 2141 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
2142 | SLOT( removeVoice() ), actionCollection(), | 2142 | SLOT( removeVoice() ), actionCollection(), |
2143 | "remove_voice" ); | 2143 | "remove_voice" ); |
2144 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, | 2144 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, |
2145 | SLOT( setFormattedName() ), actionCollection(), | 2145 | SLOT( setFormattedName() ), actionCollection(), |
2146 | "set_formatted" ); | 2146 | "set_formatted" ); |
2147 | 2147 | ||
2148 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2148 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
2149 | SLOT( manageCategories() ), actionCollection(), | 2149 | SLOT( manageCategories() ), actionCollection(), |
2150 | "remove_voice" ); | 2150 | "remove_voice" ); |
2151 | 2151 | ||
2152 | 2152 | ||
2153 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2153 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2154 | SLOT( importFromOL() ), actionCollection(), | 2154 | SLOT( importFromOL() ), actionCollection(), |
2155 | "import_OL" ); | 2155 | "import_OL" ); |
2156 | #ifdef KAB_EMBEDDED | 2156 | #ifdef KAB_EMBEDDED |
2157 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2157 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2158 | this, SLOT( showLicence() ), actionCollection(), | 2158 | this, SLOT( showLicence() ), actionCollection(), |
2159 | "licence_about_data" ); | 2159 | "licence_about_data" ); |
2160 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2160 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2161 | this, SLOT( faq() ), actionCollection(), | 2161 | this, SLOT( faq() ), actionCollection(), |
2162 | "faq_about_data" ); | 2162 | "faq_about_data" ); |
2163 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2163 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2164 | this, SLOT( whatsnew() ), actionCollection(), | 2164 | this, SLOT( whatsnew() ), actionCollection(), |
2165 | "wn" ); | 2165 | "wn" ); |
2166 | 2166 | ||
2167 | 2167 | ||
2168 | 2168 | ||
2169 | mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, | 2169 | mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, |
2170 | this, SLOT( storagehowto() ), actionCollection(), | 2170 | this, SLOT( storagehowto() ), actionCollection(), |
2171 | "storage" ); | 2171 | "storage" ); |
2172 | 2172 | ||
2173 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2173 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2174 | this, SLOT( synchowto() ), actionCollection(), | 2174 | this, SLOT( synchowto() ), actionCollection(), |
2175 | "sync" ); | 2175 | "sync" ); |
2176 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2176 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2177 | this, SLOT( kdesynchowto() ), actionCollection(), | 2177 | this, SLOT( kdesynchowto() ), actionCollection(), |
2178 | "kdesync" ); | 2178 | "kdesync" ); |
2179 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2179 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2180 | this, SLOT( multisynchowto() ), actionCollection(), | 2180 | this, SLOT( multisynchowto() ), actionCollection(), |
2181 | "multisync" ); | 2181 | "multisync" ); |
2182 | 2182 | ||
2183 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2183 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2184 | this, SLOT( createAboutData() ), actionCollection(), | 2184 | this, SLOT( createAboutData() ), actionCollection(), |
2185 | "kaddressbook_about_data" ); | 2185 | "kaddressbook_about_data" ); |
2186 | #endif //KAB_EMBEDDED | 2186 | #endif //KAB_EMBEDDED |
2187 | 2187 | ||
2188 | clipboardDataChanged(); | 2188 | clipboardDataChanged(); |
2189 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2189 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2190 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2190 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2191 | } | 2191 | } |
2192 | 2192 | ||
2193 | //US we need this function, to plug all actions into the correct menues. | 2193 | //US we need this function, to plug all actions into the correct menues. |
2194 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2194 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2195 | void KABCore::addActionsManually() | 2195 | void KABCore::addActionsManually() |
2196 | { | 2196 | { |
@@ -3207,294 +3207,294 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
3207 | modulo = (el.count()/10)+1; | 3207 | modulo = (el.count()/10)+1; |
3208 | 3208 | ||
3209 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3209 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3210 | incCounter = 0; | 3210 | incCounter = 0; |
3211 | while ( incCounter < el.count()) { | 3211 | while ( incCounter < el.count()) { |
3212 | qApp->processEvents(); | 3212 | qApp->processEvents(); |
3213 | if (syncManager->isProgressBarCanceled()) | 3213 | if (syncManager->isProgressBarCanceled()) |
3214 | return false; | 3214 | return false; |
3215 | if ( incCounter % modulo == 0 ) | 3215 | if ( incCounter % modulo == 0 ) |
3216 | syncManager->showProgressBar(incCounter); | 3216 | syncManager->showProgressBar(incCounter); |
3217 | uid = el[ incCounter ]; | 3217 | uid = el[ incCounter ]; |
3218 | bool skipIncidence = false; | 3218 | bool skipIncidence = false; |
3219 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3219 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3220 | skipIncidence = true; | 3220 | skipIncidence = true; |
3221 | if ( !skipIncidence ) { | 3221 | if ( !skipIncidence ) { |
3222 | inL = local->findByUid( uid ); | 3222 | inL = local->findByUid( uid ); |
3223 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3223 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3224 | inR = remote->findByUid( uid ); | 3224 | inR = remote->findByUid( uid ); |
3225 | if ( inR.isEmpty() ){ | 3225 | if ( inR.isEmpty() ){ |
3226 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { | 3226 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { |
3227 | // no conflict ********** add or delete local | 3227 | // no conflict ********** add or delete local |
3228 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3228 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3229 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3229 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3230 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3230 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3231 | local->removeAddressee( inL ); | 3231 | local->removeAddressee( inL ); |
3232 | ++deletedAddresseeL; | 3232 | ++deletedAddresseeL; |
3233 | } else { | 3233 | } else { |
3234 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3234 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3235 | inL.removeID(mCurrentSyncDevice ); | 3235 | inL.removeID(mCurrentSyncDevice ); |
3236 | ++addedAddresseeR; | 3236 | ++addedAddresseeR; |
3237 | inL.setRevision( modifiedCalendar ); | 3237 | inL.setRevision( modifiedCalendar ); |
3238 | local->insertAddressee( inL, false ); | 3238 | local->insertAddressee( inL, false ); |
3239 | inR = inL; | 3239 | inR = inL; |
3240 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3240 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3241 | inR.setResource( 0 ); | 3241 | inR.setResource( 0 ); |
3242 | remote->insertAddressee( inR, false ); | 3242 | remote->insertAddressee( inR, false ); |
3243 | } | 3243 | } |
3244 | } | 3244 | } |
3245 | } else { | 3245 | } else { |
3246 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3246 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3247 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3247 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3248 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3248 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3249 | local->removeAddressee( inL ); | 3249 | local->removeAddressee( inL ); |
3250 | ++deletedAddresseeL; | 3250 | ++deletedAddresseeL; |
3251 | } else { | 3251 | } else { |
3252 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3252 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3253 | ++addedAddresseeR; | 3253 | ++addedAddresseeR; |
3254 | inL.setRevision( modifiedCalendar ); | 3254 | inL.setRevision( modifiedCalendar ); |
3255 | local->insertAddressee( inL, false ); | 3255 | local->insertAddressee( inL, false ); |
3256 | inR = inL; | 3256 | inR = inL; |
3257 | inR.setIDStr( ":" ); | 3257 | inR.setIDStr( ":" ); |
3258 | inR.setResource( 0 ); | 3258 | inR.setResource( 0 ); |
3259 | remote->insertAddressee( inR, false ); | 3259 | remote->insertAddressee( inR, false ); |
3260 | } | 3260 | } |
3261 | } | 3261 | } |
3262 | } | 3262 | } |
3263 | } else { | 3263 | } else { |
3264 | ++filteredOUT; | 3264 | ++filteredOUT; |
3265 | } | 3265 | } |
3266 | } | 3266 | } |
3267 | } | 3267 | } |
3268 | } | 3268 | } |
3269 | ++incCounter; | 3269 | ++incCounter; |
3270 | } | 3270 | } |
3271 | el.clear(); | 3271 | el.clear(); |
3272 | syncManager->hideProgressBar(); | 3272 | syncManager->hideProgressBar(); |
3273 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3273 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3274 | // get rid of micro seconds | 3274 | // get rid of micro seconds |
3275 | QTime t = mLastAddressbookSync.time(); | 3275 | QTime t = mLastAddressbookSync.time(); |
3276 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3276 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3277 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3277 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3278 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3278 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3279 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3279 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3280 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3280 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3281 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3281 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3282 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3282 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3283 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3283 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3284 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3284 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3285 | addresseeRSync.setNote( "" ) ; | 3285 | addresseeRSync.setNote( "" ) ; |
3286 | addresseeLSync.setNote( "" ); | 3286 | addresseeLSync.setNote( "" ); |
3287 | 3287 | ||
3288 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3288 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3289 | remote->insertAddressee( addresseeRSync, false ); | 3289 | remote->insertAddressee( addresseeRSync, false ); |
3290 | local->insertAddressee( addresseeLSync, false ); | 3290 | local->insertAddressee( addresseeLSync, false ); |
3291 | QString mes; | 3291 | QString mes; |
3292 | 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); | 3292 | 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); |
3293 | qDebug( mes ); | 3293 | qDebug( mes ); |
3294 | mes = i18n("Local addressbook changed!\n") +mes; | 3294 | mes = i18n("Local addressbook changed!\n") +mes; |
3295 | if ( syncManager->mShowSyncSummary ) { | 3295 | if ( syncManager->mShowSyncSummary ) { |
3296 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3296 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3297 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3297 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3298 | qDebug("KA: WB cancelled "); | 3298 | qDebug("KA: WB cancelled "); |
3299 | syncManager->mWriteBackFile = false; | 3299 | syncManager->mWriteBackFile = false; |
3300 | return syncOK; | 3300 | return syncOK; |
3301 | } | 3301 | } |
3302 | } | 3302 | } |
3303 | return syncOK; | 3303 | return syncOK; |
3304 | } | 3304 | } |
3305 | 3305 | ||
3306 | 3306 | ||
3307 | //this is a overwritten callbackmethods from the syncinterface | 3307 | //this is a overwritten callbackmethods from the syncinterface |
3308 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource) | 3308 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
3309 | { | 3309 | { |
3310 | 3310 | ||
3311 | //pending prepare addresseeview for output | 3311 | //pending prepare addresseeview for output |
3312 | //pending detect, if remote file has REV field. if not switch to external sync | 3312 | //pending detect, if remote file has REV field. if not switch to external sync |
3313 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3313 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3314 | if ( manager != syncManager ) | 3314 | if ( manager != syncManager ) |
3315 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3315 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3316 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3316 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3317 | 3317 | ||
3318 | AddressBook abLocal(filename,"syncContact"); | 3318 | AddressBook abLocal(filename,"syncContact"); |
3319 | bool syncOK = false; | 3319 | bool syncOK = false; |
3320 | if ( abLocal.load() ) { | 3320 | if ( abLocal.load() ) { |
3321 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3321 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3322 | bool external = false; | 3322 | bool external = false; |
3323 | bool isXML = false; | 3323 | bool isXML = false; |
3324 | if ( filename.right(4) == ".xml") { | 3324 | if ( filename.right(4) == ".xml") { |
3325 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3325 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3326 | isXML = true; | 3326 | isXML = true; |
3327 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3327 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3328 | } else { | 3328 | } else { |
3329 | external = !manager->mIsKapiFile; | 3329 | external = !manager->mIsKapiFile; |
3330 | if ( external ) { | 3330 | if ( external ) { |
3331 | qDebug("KA: Sync::Setting vcf mode to external "); | 3331 | qDebug("KA: Sync::Setting vcf mode to external "); |
3332 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3332 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3333 | AddressBook::Iterator it; | 3333 | AddressBook::Iterator it; |
3334 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3334 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3335 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3335 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3336 | (*it).computeCsum( mCurrentSyncDevice ); | 3336 | (*it).computeCsum( mCurrentSyncDevice ); |
3337 | } | 3337 | } |
3338 | } | 3338 | } |
3339 | } | 3339 | } |
3340 | //AddressBook::Iterator it; | 3340 | //AddressBook::Iterator it; |
3341 | //QStringList vcards; | 3341 | //QStringList vcards; |
3342 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3342 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3343 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3343 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3344 | //} | 3344 | //} |
3345 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3345 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3346 | syncManager->hideProgressBar(); | 3346 | syncManager->hideProgressBar(); |
3347 | if ( syncOK ) { | 3347 | if ( syncOK ) { |
3348 | if ( syncManager->mWriteBackFile ) | 3348 | if ( syncManager->mWriteBackFile ) |
3349 | { | 3349 | { |
3350 | if ( external ) | 3350 | if ( external ) |
3351 | abLocal.removeSyncAddressees( !isXML); | 3351 | abLocal.removeSyncAddressees( !isXML); |
3352 | qDebug("KA: Sync::Saving remote AB "); | 3352 | qDebug("KA: Sync::Saving remote AB "); |
3353 | if ( ! abLocal.saveAB()) | 3353 | if ( ! abLocal.saveAB()) |
3354 | qDebug("KA: sync::Error writing back AB to file "); | 3354 | qDebug("KA: sync::Error writing back AB to file "); |
3355 | if ( external ) { | 3355 | if ( external ) { |
3356 | // afterwrite processing | 3356 | // afterwrite processing |
3357 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3357 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3358 | } | 3358 | } |
3359 | } | 3359 | } |
3360 | } | 3360 | } |
3361 | setModified(); | 3361 | setModified(); |
3362 | 3362 | ||
3363 | } | 3363 | } |
3364 | abLocal.removeResources(); | 3364 | abLocal.removeResources(); |
3365 | if ( syncOK ) | 3365 | if ( syncOK ) |
3366 | mViewManager->refreshView(); | 3366 | mViewManager->refreshView(); |
3367 | return syncOK; | 3367 | return syncOK; |
3368 | 3368 | ||
3369 | } | 3369 | } |
3370 | void KABCore::removeSyncInfo( QString syncProfile) | 3370 | void KABCore::removeSyncInfo( QString syncProfile) |
3371 | { | 3371 | { |
3372 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3372 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3373 | mAddressBook->removeSyncInfo( syncProfile ); | 3373 | mAddressBook->removeSyncInfo( syncProfile ); |
3374 | setModified(); | 3374 | setModified(); |
3375 | } | 3375 | } |
3376 | 3376 | ||
3377 | 3377 | ||
3378 | //this is a overwritten callbackmethods from the syncinterface | 3378 | //this is a overwritten callbackmethods from the syncinterface |
3379 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3379 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3380 | { | 3380 | { |
3381 | if ( resource == "phone" ) | 3381 | if ( resource == "phone" ) |
3382 | return syncPhone(); | 3382 | return syncPhone(); |
3383 | disableBR( true ); | 3383 | disableBR( true ); |
3384 | if ( manager != syncManager ) | 3384 | if ( manager != syncManager ) |
3385 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3385 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3386 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3386 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3387 | 3387 | ||
3388 | AddressBook abLocal( resource,"syncContact"); | 3388 | AddressBook abLocal( resource,"syncContact"); |
3389 | bool syncOK = false; | 3389 | bool syncOK = false; |
3390 | message(i18n("Loading DTM address data..."), false); | 3390 | message(i18n("Loading DTM address data..."), false); |
3391 | if ( abLocal.load() ) { | 3391 | if ( abLocal.load() ) { |
3392 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3392 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3393 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3393 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3394 | message(i18n("Sync preprocessing..."),false); | 3394 | message(i18n("Sync preprocessing..."),false); |
3395 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3395 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3396 | message(i18n("Synchronizing..."),false); | 3396 | message(i18n("Synchronizing..."),false); |
3397 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3397 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3398 | syncManager->hideProgressBar(); | 3398 | syncManager->hideProgressBar(); |
3399 | if ( syncOK ) { | 3399 | if ( syncOK ) { |
3400 | if ( syncManager->mWriteBackFile ) { | 3400 | if ( syncManager->mWriteBackFile ) { |
3401 | abLocal.removeSyncAddressees( false ); | 3401 | abLocal.removeSyncAddressees( false ); |
3402 | message(i18n("Saving DTM address data..."),false); | 3402 | message(i18n("Saving DTM address data..."),false); |
3403 | abLocal.saveAB(); | 3403 | abLocal.saveAB(); |
3404 | message(i18n("Sync postprocessing..."),false); | 3404 | message(i18n("Sync postprocessing..."),false); |
3405 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3405 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3406 | } | 3406 | } |
3407 | } else | 3407 | } else |
3408 | message( i18n("Sync cancelled or failed.") ); | 3408 | message( i18n("Sync cancelled or failed.") ); |
3409 | setModified(); | 3409 | setModified(); |
3410 | } | 3410 | } |
3411 | abLocal.removeResources(); | 3411 | abLocal.removeResources(); |
3412 | if ( syncOK ) { | 3412 | if ( syncOK ) { |
3413 | mViewManager->refreshView(); | 3413 | mViewManager->refreshView(); |
3414 | message(i18n("DTM syncing finished.")); | 3414 | message(i18n("DTM syncing finished.")); |
3415 | } | 3415 | } |
3416 | disableBR( false ); | 3416 | disableBR( false ); |
3417 | return syncOK; | 3417 | return syncOK; |
3418 | 3418 | ||
3419 | } | 3419 | } |
3420 | void KABCore::message( QString m, bool startTimer) | 3420 | void KABCore::message( QString m, bool startTimer) |
3421 | { | 3421 | { |
3422 | topLevelWidget()->setCaption( m ); | 3422 | topLevelWidget()->setCaption( m ); |
3423 | qApp->processEvents(); | 3423 | qApp->processEvents(); |
3424 | if ( startTimer ) | 3424 | if ( startTimer ) |
3425 | mMessageTimer->start( 15000, true ); | 3425 | mMessageTimer->start( 15000, true ); |
3426 | else | 3426 | else |
3427 | mMessageTimer->stop(); | 3427 | mMessageTimer->stop(); |
3428 | } | 3428 | } |
3429 | bool KABCore::syncPhone() | 3429 | bool KABCore::syncPhone() |
3430 | { | 3430 | { |
3431 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3431 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3432 | QString fileName = getPhoneFile(); | 3432 | QString fileName = getPhoneFile(); |
3433 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3433 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3434 | message(i18n("Phone access failed!")); | 3434 | message(i18n("Phone access failed!")); |
3435 | return false; | 3435 | return false; |
3436 | } | 3436 | } |
3437 | AddressBook abLocal( fileName,"syncContact"); | 3437 | AddressBook abLocal( fileName,"syncContact"); |
3438 | bool syncOK = false; | 3438 | bool syncOK = false; |
3439 | { | 3439 | { |
3440 | abLocal.importFromFile( fileName ); | 3440 | abLocal.importFromFile( fileName ); |
3441 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3441 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3442 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3442 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3443 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3443 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3444 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3444 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3445 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3445 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3446 | syncManager->hideProgressBar(); | 3446 | syncManager->hideProgressBar(); |
3447 | if ( syncOK ) { | 3447 | if ( syncOK ) { |
3448 | if ( syncManager->mWriteBackFile ) { | 3448 | if ( syncManager->mWriteBackFile ) { |
3449 | abLocal.removeSyncAddressees( true ); | 3449 | abLocal.removeSyncAddressees( true ); |
3450 | abLocal.saveABphone( fileName ); | 3450 | abLocal.saveABphone( fileName ); |
3451 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3451 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3452 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3452 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3453 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3453 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3454 | } | 3454 | } |
3455 | } | 3455 | } |
3456 | setModified(); | 3456 | setModified(); |
3457 | } | 3457 | } |
3458 | abLocal.removeResources(); | 3458 | abLocal.removeResources(); |
3459 | if ( syncOK ) | 3459 | if ( syncOK ) |
3460 | mViewManager->refreshView(); | 3460 | mViewManager->refreshView(); |
3461 | return syncOK; | 3461 | return syncOK; |
3462 | } | 3462 | } |
3463 | void KABCore::getFile( bool success ) | 3463 | void KABCore::getFile( bool success ,const QString & resource) |
3464 | { | 3464 | { |
3465 | if ( ! success ) { | 3465 | if ( ! success ) { |
3466 | message( i18n("Error receiving file. Nothing changed!") ); | 3466 | message( i18n("Error receiving file. Nothing changed!") ); |
3467 | return; | 3467 | return; |
3468 | } | 3468 | } |
3469 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3469 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ,resource); |
3470 | if ( count ) | 3470 | if ( count ) |
3471 | setModified( true ); | 3471 | setModified( true ); |
3472 | message( i18n("Pi-Sync successful!") ); | 3472 | message( i18n("Pi-Sync successful!") ); |
3473 | mViewManager->refreshView(); | 3473 | mViewManager->refreshView(); |
3474 | } | 3474 | } |
3475 | void KABCore::syncFileRequest(const QString & resource) | 3475 | void KABCore::syncFileRequest(const QString & resource) |
3476 | { | 3476 | { |
3477 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3477 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3478 | syncManager->slotSyncMenu( 999 ); | 3478 | syncManager->slotSyncMenu( 999 ); |
3479 | } | 3479 | } |
3480 | 3480 | ||
3481 | if ( resource == "ALL" ) { | 3481 | if ( resource == "ALL" ) { |
3482 | mAddressBook->export2File( sentSyncFile() ); | 3482 | mAddressBook->export2File( sentSyncFile() ); |
3483 | } | 3483 | } |
3484 | else | 3484 | else |
3485 | mAddressBook->export2File( sentSyncFile(), resource); | 3485 | mAddressBook->export2File( sentSyncFile(), resource); |
3486 | } | 3486 | } |
3487 | QString KABCore::sentSyncFile() | 3487 | QString KABCore::sentSyncFile() |
3488 | { | 3488 | { |
3489 | #ifdef DESKTOP_VERSION | 3489 | #ifdef DESKTOP_VERSION |
3490 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3490 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3491 | #else | 3491 | #else |
3492 | return QString( "/tmp/copysyncab.vcf" ); | 3492 | return QString( "/tmp/copysyncab.vcf" ); |
3493 | #endif | 3493 | #endif |
3494 | } | 3494 | } |
3495 | 3495 | ||
3496 | void KABCore::setCaptionBack() | 3496 | void KABCore::setCaptionBack() |
3497 | { | 3497 | { |
3498 | mMessageTimer->stop(); | 3498 | mMessageTimer->stop(); |
3499 | topLevelWidget()->setCaption( i18n("KA/Pi") ); | 3499 | topLevelWidget()->setCaption( i18n("KA/Pi") ); |
3500 | } | 3500 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 2d1505f..e69cb60 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -103,433 +103,433 @@ class KABCore : public QWidget, public KSyncInterface | |||
103 | KABC::AddressBook *addressBook() const; | 103 | KABC::AddressBook *addressBook() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Returns a pointer to the KConfig object of the application. | 106 | Returns a pointer to the KConfig object of the application. |
107 | */ | 107 | */ |
108 | static KConfig *config(); | 108 | static KConfig *config(); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | Returns a pointer to the global KActionCollection object. So | 111 | Returns a pointer to the global KActionCollection object. So |
112 | other classes can register their actions easily. | 112 | other classes can register their actions easily. |
113 | */ | 113 | */ |
114 | KActionCollection *actionCollection() const; | 114 | KActionCollection *actionCollection() const; |
115 | 115 | ||
116 | /** | 116 | /** |
117 | Returns the current search field of the Incremental Search Widget. | 117 | Returns the current search field of the Incremental Search Widget. |
118 | */ | 118 | */ |
119 | KABC::Field *currentSearchField() const; | 119 | KABC::Field *currentSearchField() const; |
120 | 120 | ||
121 | /** | 121 | /** |
122 | Returns the uid list of the currently selected contacts. | 122 | Returns the uid list of the currently selected contacts. |
123 | */ | 123 | */ |
124 | QStringList selectedUIDs() const; | 124 | QStringList selectedUIDs() const; |
125 | 125 | ||
126 | /** | 126 | /** |
127 | Displays the ResourceSelectDialog and returns the selected | 127 | Displays the ResourceSelectDialog and returns the selected |
128 | resource or a null pointer if no resource was selected by | 128 | resource or a null pointer if no resource was selected by |
129 | the user. | 129 | the user. |
130 | */ | 130 | */ |
131 | KABC::Resource *requestResource( QWidget *parent ); | 131 | KABC::Resource *requestResource( QWidget *parent ); |
132 | 132 | ||
133 | #ifndef KAB_EMBEDDED | 133 | #ifndef KAB_EMBEDDED |
134 | static KAboutData *createAboutData(); | 134 | static KAboutData *createAboutData(); |
135 | #endif //KAB_EMBEDDED | 135 | #endif //KAB_EMBEDDED |
136 | 136 | ||
137 | #ifdef KAB_EMBEDDED | 137 | #ifdef KAB_EMBEDDED |
138 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 138 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
139 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 139 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
140 | #endif //KAB_EMBEDDED | 140 | #endif //KAB_EMBEDDED |
141 | 141 | ||
142 | public slots: | 142 | public slots: |
143 | #ifdef KAB_EMBEDDED | 143 | #ifdef KAB_EMBEDDED |
144 | void createAboutData(); | 144 | void createAboutData(); |
145 | #endif //KAB_EMBEDDED | 145 | #endif //KAB_EMBEDDED |
146 | void setDetailsToggle(); | 146 | void setDetailsToggle(); |
147 | 147 | ||
148 | void showLicence(); | 148 | void showLicence(); |
149 | void faq(); | 149 | void faq(); |
150 | void whatsnew() ; | 150 | void whatsnew() ; |
151 | void synchowto() ; | 151 | void synchowto() ; |
152 | void storagehowto() ; | 152 | void storagehowto() ; |
153 | void multisynchowto() ; | 153 | void multisynchowto() ; |
154 | void kdesynchowto() ; | 154 | void kdesynchowto() ; |
155 | void writeToPhone(); | 155 | void writeToPhone(); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Is called whenever a contact is selected in the view. | 158 | Is called whenever a contact is selected in the view. |
159 | */ | 159 | */ |
160 | void setContactSelected( const QString &uid ); | 160 | void setContactSelected( const QString &uid ); |
161 | 161 | ||
162 | /** | 162 | /** |
163 | Opens the preferred mail composer with all selected contacts as | 163 | Opens the preferred mail composer with all selected contacts as |
164 | arguments. | 164 | arguments. |
165 | */ | 165 | */ |
166 | void sendMail(); | 166 | void sendMail(); |
167 | 167 | ||
168 | /** | 168 | /** |
169 | Opens the preferred mail composer with the given contacts as | 169 | Opens the preferred mail composer with the given contacts as |
170 | arguments. | 170 | arguments. |
171 | */ | 171 | */ |
172 | void sendMail( const QString& email ); | 172 | void sendMail( const QString& email ); |
173 | 173 | ||
174 | 174 | ||
175 | void mailVCard(); | 175 | void mailVCard(); |
176 | void mailVCard(const QStringList& uids); | 176 | void mailVCard(const QStringList& uids); |
177 | 177 | ||
178 | /** | 178 | /** |
179 | Beams the "WhoAmI contact. | 179 | Beams the "WhoAmI contact. |
180 | */ | 180 | */ |
181 | void beamMySelf(); | 181 | void beamMySelf(); |
182 | 182 | ||
183 | void beamVCard(); | 183 | void beamVCard(); |
184 | void export2phone(); | 184 | void export2phone(); |
185 | void beamVCard(const QStringList& uids); | 185 | void beamVCard(const QStringList& uids); |
186 | void beamDone( Ir *ir ); | 186 | void beamDone( Ir *ir ); |
187 | 187 | ||
188 | 188 | ||
189 | /** | 189 | /** |
190 | Starts the preferred web browser with the given URL as argument. | 190 | Starts the preferred web browser with the given URL as argument. |
191 | */ | 191 | */ |
192 | void browse( const QString& url ); | 192 | void browse( const QString& url ); |
193 | 193 | ||
194 | /** | 194 | /** |
195 | Select all contacts in the view. | 195 | Select all contacts in the view. |
196 | */ | 196 | */ |
197 | void selectAllContacts(); | 197 | void selectAllContacts(); |
198 | 198 | ||
199 | /** | 199 | /** |
200 | Deletes all selected contacts from the address book. | 200 | Deletes all selected contacts from the address book. |
201 | */ | 201 | */ |
202 | void deleteContacts(); | 202 | void deleteContacts(); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | Deletes given contacts from the address book. | 205 | Deletes given contacts from the address book. |
206 | 206 | ||
207 | @param uids The uids of the contacts, which shall be deleted. | 207 | @param uids The uids of the contacts, which shall be deleted. |
208 | */ | 208 | */ |
209 | void deleteContacts( const QStringList &uids ); | 209 | void deleteContacts( const QStringList &uids ); |
210 | 210 | ||
211 | /** | 211 | /** |
212 | Copys the selected contacts into clipboard for later pasting. | 212 | Copys the selected contacts into clipboard for later pasting. |
213 | */ | 213 | */ |
214 | void copyContacts(); | 214 | void copyContacts(); |
215 | 215 | ||
216 | /** | 216 | /** |
217 | Cuts the selected contacts and stores them for later pasting. | 217 | Cuts the selected contacts and stores them for later pasting. |
218 | */ | 218 | */ |
219 | void cutContacts(); | 219 | void cutContacts(); |
220 | 220 | ||
221 | /** | 221 | /** |
222 | Paste contacts from clipboard into the address book. | 222 | Paste contacts from clipboard into the address book. |
223 | */ | 223 | */ |
224 | void pasteContacts(); | 224 | void pasteContacts(); |
225 | 225 | ||
226 | /** | 226 | /** |
227 | Paste given contacts into the address book. | 227 | Paste given contacts into the address book. |
228 | 228 | ||
229 | @param list The list of addressee, which shall be pasted. | 229 | @param list The list of addressee, which shall be pasted. |
230 | */ | 230 | */ |
231 | void pasteContacts( KABC::Addressee::List &list ); | 231 | void pasteContacts( KABC::Addressee::List &list ); |
232 | 232 | ||
233 | /** | 233 | /** |
234 | Sets the whoAmI contact, that is used by many other programs to | 234 | Sets the whoAmI contact, that is used by many other programs to |
235 | get personal information about the current user. | 235 | get personal information about the current user. |
236 | */ | 236 | */ |
237 | void setWhoAmI(); | 237 | void setWhoAmI(); |
238 | 238 | ||
239 | /** | 239 | /** |
240 | Displays the category dialog and applies the result to all | 240 | Displays the category dialog and applies the result to all |
241 | selected contacts. | 241 | selected contacts. |
242 | */ | 242 | */ |
243 | void setCategories(); | 243 | void setCategories(); |
244 | void manageCategories(); | 244 | void manageCategories(); |
245 | void editCategories(); | 245 | void editCategories(); |
246 | 246 | ||
247 | /** | 247 | /** |
248 | Sets the field list of the Incremental Search Widget. | 248 | Sets the field list of the Incremental Search Widget. |
249 | */ | 249 | */ |
250 | void setSearchFields( const KABC::Field::List &fields ); | 250 | void setSearchFields( const KABC::Field::List &fields ); |
251 | 251 | ||
252 | /** | 252 | /** |
253 | Search with the current search field for a contact, that matches | 253 | Search with the current search field for a contact, that matches |
254 | the given text, and selects it in the view. | 254 | the given text, and selects it in the view. |
255 | */ | 255 | */ |
256 | void incrementalSearch( const QString& text ); | 256 | void incrementalSearch( const QString& text ); |
257 | void incrementalSearchJump( const QString& text ); | 257 | void incrementalSearchJump( const QString& text ); |
258 | 258 | ||
259 | /** | 259 | /** |
260 | Marks the address book as modified. | 260 | Marks the address book as modified. |
261 | */ | 261 | */ |
262 | void setModified(); | 262 | void setModified(); |
263 | /** | 263 | /** |
264 | Marks the address book as modified without refreshing the view. | 264 | Marks the address book as modified without refreshing the view. |
265 | */ | 265 | */ |
266 | void setModifiedWOrefresh(); | 266 | void setModifiedWOrefresh(); |
267 | 267 | ||
268 | /** | 268 | /** |
269 | Marks the address book as modified concerning the argument. | 269 | Marks the address book as modified concerning the argument. |
270 | */ | 270 | */ |
271 | void setModified( bool modified ); | 271 | void setModified( bool modified ); |
272 | 272 | ||
273 | /** | 273 | /** |
274 | Returns whether the address book is modified. | 274 | Returns whether the address book is modified. |
275 | */ | 275 | */ |
276 | bool modified() const; | 276 | bool modified() const; |
277 | 277 | ||
278 | /** | 278 | /** |
279 | Called whenever an contact is modified in the contact editor | 279 | Called whenever an contact is modified in the contact editor |
280 | dialog or the quick edit. | 280 | dialog or the quick edit. |
281 | */ | 281 | */ |
282 | void contactModified( const KABC::Addressee &addr ); | 282 | void contactModified( const KABC::Addressee &addr ); |
283 | void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); | 283 | void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); |
284 | 284 | ||
285 | /** | 285 | /** |
286 | DCOP METHODS. | 286 | DCOP METHODS. |
287 | */ | 287 | */ |
288 | void addEmail( QString addr ); | 288 | void addEmail( QString addr ); |
289 | void importVCard( const KURL& url, bool showPreview ); | 289 | void importVCard( const KURL& url, bool showPreview ); |
290 | void importVCard( const QString& vCard, bool showPreview ); | 290 | void importVCard( const QString& vCard, bool showPreview ); |
291 | void newContact(); | 291 | void newContact(); |
292 | QString getNameByPhone( const QString& phone ); | 292 | QString getNameByPhone( const QString& phone ); |
293 | /** | 293 | /** |
294 | END DCOP METHODS | 294 | END DCOP METHODS |
295 | */ | 295 | */ |
296 | 296 | ||
297 | /** | 297 | /** |
298 | Saves the contents of the AddressBook back to disk. | 298 | Saves the contents of the AddressBook back to disk. |
299 | */ | 299 | */ |
300 | void save(); | 300 | void save(); |
301 | 301 | ||
302 | /** | 302 | /** |
303 | Undos the last command using the undo stack. | 303 | Undos the last command using the undo stack. |
304 | */ | 304 | */ |
305 | void undo(); | 305 | void undo(); |
306 | 306 | ||
307 | /** | 307 | /** |
308 | Redos the last command that was undone, using the redo stack. | 308 | Redos the last command that was undone, using the redo stack. |
309 | */ | 309 | */ |
310 | void redo(); | 310 | void redo(); |
311 | 311 | ||
312 | /** | 312 | /** |
313 | Shows the edit dialog for the given uid. If the uid is QString::null, | 313 | Shows the edit dialog for the given uid. If the uid is QString::null, |
314 | the method will try to find a selected addressee in the view. | 314 | the method will try to find a selected addressee in the view. |
315 | */ | 315 | */ |
316 | void editContact( const QString &uid /*US = QString::null*/ ); | 316 | void editContact( const QString &uid /*US = QString::null*/ ); |
317 | //US added a second method without defaultparameter | 317 | //US added a second method without defaultparameter |
318 | void editContact2(); | 318 | void editContact2(); |
319 | 319 | ||
320 | /** | 320 | /** |
321 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 321 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
322 | the method will try to find a selected addressee in the view. | 322 | the method will try to find a selected addressee in the view. |
323 | */ | 323 | */ |
324 | void executeContact( const QString &uid /*US = QString::null*/ ); | 324 | void executeContact( const QString &uid /*US = QString::null*/ ); |
325 | 325 | ||
326 | /** | 326 | /** |
327 | Launches the configuration dialog. | 327 | Launches the configuration dialog. |
328 | */ | 328 | */ |
329 | void openConfigDialog(); | 329 | void openConfigDialog(); |
330 | void openConfigGlobalDialog(); | 330 | void openConfigGlobalDialog(); |
331 | 331 | ||
332 | /** | 332 | /** |
333 | Launches the ldap search dialog. | 333 | Launches the ldap search dialog. |
334 | */ | 334 | */ |
335 | void openLDAPDialog(); | 335 | void openLDAPDialog(); |
336 | 336 | ||
337 | /** | 337 | /** |
338 | Creates a KAddressBookPrinter, which will display the print | 338 | Creates a KAddressBookPrinter, which will display the print |
339 | dialog and do the printing. | 339 | dialog and do the printing. |
340 | */ | 340 | */ |
341 | void print(); | 341 | void print(); |
342 | 342 | ||
343 | /** | 343 | /** |
344 | Registers a new GUI client, so plugins can register its actions. | 344 | Registers a new GUI client, so plugins can register its actions. |
345 | */ | 345 | */ |
346 | void addGUIClient( KXMLGUIClient *client ); | 346 | void addGUIClient( KXMLGUIClient *client ); |
347 | 347 | ||
348 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 348 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
349 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 349 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
350 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 350 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
351 | 351 | ||
352 | 352 | ||
353 | signals: | 353 | signals: |
354 | void contactSelected( const QString &name ); | 354 | void contactSelected( const QString &name ); |
355 | void contactSelected( const QPixmap &pixmap ); | 355 | void contactSelected( const QPixmap &pixmap ); |
356 | public slots: | 356 | public slots: |
357 | void loadDataAfterStart(); | 357 | void loadDataAfterStart(); |
358 | void recieve(QString cmsg ); | 358 | void recieve(QString cmsg ); |
359 | void getFile( bool success ); | 359 | void getFile( bool success,const QString & ); |
360 | void syncFileRequest(const QString &); | 360 | void syncFileRequest(const QString &); |
361 | void setDetailsVisible( bool visible ); | 361 | void setDetailsVisible( bool visible ); |
362 | void setDetailsToState(); | 362 | void setDetailsToState(); |
363 | 363 | ||
364 | void saveSettings(); | 364 | void saveSettings(); |
365 | 365 | ||
366 | private slots: | 366 | private slots: |
367 | void updateToolBar(); | 367 | void updateToolBar(); |
368 | void updateMainWindow(); | 368 | void updateMainWindow(); |
369 | void receive( const QCString& cmsg, const QByteArray& data ); | 369 | void receive( const QCString& cmsg, const QByteArray& data ); |
370 | void receiveStart( const QCString& cmsg, const QByteArray& data ); | 370 | void receiveStart( const QCString& cmsg, const QByteArray& data ); |
371 | void toggleBeamReceive( ); | 371 | void toggleBeamReceive( ); |
372 | void disableBR(bool); | 372 | void disableBR(bool); |
373 | void setJumpButtonBarVisible( bool visible ); | 373 | void setJumpButtonBarVisible( bool visible ); |
374 | void setJumpButtonBar( bool visible ); | 374 | void setJumpButtonBar( bool visible ); |
375 | void setCaptionBack(); | 375 | void setCaptionBack(); |
376 | void resizeAndCallContactdialog(); | 376 | void resizeAndCallContactdialog(); |
377 | void callContactdialog(); | 377 | void callContactdialog(); |
378 | void doRingSync(); | 378 | void doRingSync(); |
379 | 379 | ||
380 | void importFromOL(); | 380 | void importFromOL(); |
381 | void extensionModified( const KABC::Addressee::List &list ); | 381 | void extensionModified( const KABC::Addressee::List &list ); |
382 | void extensionChanged( int id ); | 382 | void extensionChanged( int id ); |
383 | void clipboardDataChanged(); | 383 | void clipboardDataChanged(); |
384 | void updateActionMenu(); | 384 | void updateActionMenu(); |
385 | void configureKeyBindings(); | 385 | void configureKeyBindings(); |
386 | void removeVoice(); | 386 | void removeVoice(); |
387 | void setFormattedName(); | 387 | void setFormattedName(); |
388 | #ifdef KAB_EMBEDDED | 388 | #ifdef KAB_EMBEDDED |
389 | void configureResources(); | 389 | void configureResources(); |
390 | #endif //KAB_EMBEDDED | 390 | #endif //KAB_EMBEDDED |
391 | 391 | ||
392 | void slotEditorDestroyed( const QString &uid ); | 392 | void slotEditorDestroyed( const QString &uid ); |
393 | void configurationChanged(); | 393 | void configurationChanged(); |
394 | void addressBookChanged(); | 394 | void addressBookChanged(); |
395 | 395 | ||
396 | private: | 396 | private: |
397 | QCString mCStringMess; | 397 | QCString mCStringMess; |
398 | QByteArray mByteData; | 398 | QByteArray mByteData; |
399 | QString mEmailSourceChannel; | 399 | QString mEmailSourceChannel; |
400 | QString mEmailSourceUID; | 400 | QString mEmailSourceUID; |
401 | void resizeEvent(QResizeEvent* e ); | 401 | void resizeEvent(QResizeEvent* e ); |
402 | bool mBRdisabled; | 402 | bool mBRdisabled; |
403 | #ifndef DESKTOP_VERSION | 403 | #ifndef DESKTOP_VERSION |
404 | QCopChannel* infrared; | 404 | QCopChannel* infrared; |
405 | #endif | 405 | #endif |
406 | QTimer *mMessageTimer; | 406 | QTimer *mMessageTimer; |
407 | void initGUI(); | 407 | void initGUI(); |
408 | void initActions(); | 408 | void initActions(); |
409 | QString getPhoneFile(); | 409 | QString getPhoneFile(); |
410 | 410 | ||
411 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 411 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
412 | const char *name = 0 ); | 412 | const char *name = 0 ); |
413 | 413 | ||
414 | KXMLGUIClient *mGUIClient; | 414 | KXMLGUIClient *mGUIClient; |
415 | 415 | ||
416 | KABC::AddressBook *mAddressBook; | 416 | KABC::AddressBook *mAddressBook; |
417 | 417 | ||
418 | ViewManager *mViewManager; | 418 | ViewManager *mViewManager; |
419 | // QSplitter *mDetailsSplitter; | 419 | // QSplitter *mDetailsSplitter; |
420 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 420 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
421 | ViewContainer *mDetails; | 421 | ViewContainer *mDetails; |
422 | KDGanttMinimizeSplitter* mMiniSplitter; | 422 | KDGanttMinimizeSplitter* mMiniSplitter; |
423 | XXPortManager *mXXPortManager; | 423 | XXPortManager *mXXPortManager; |
424 | JumpButtonBar *mJumpButtonBar; | 424 | JumpButtonBar *mJumpButtonBar; |
425 | IncSearchWidget *mIncSearchWidget; | 425 | IncSearchWidget *mIncSearchWidget; |
426 | ExtensionManager *mExtensionManager; | 426 | ExtensionManager *mExtensionManager; |
427 | 427 | ||
428 | KCMultiDialog *mConfigureDialog; | 428 | KCMultiDialog *mConfigureDialog; |
429 | 429 | ||
430 | #ifndef KAB_EMBEDDED | 430 | #ifndef KAB_EMBEDDED |
431 | LDAPSearchDialog *mLdapSearchDialog; | 431 | LDAPSearchDialog *mLdapSearchDialog; |
432 | #endif //KAB_EMBEDDED | 432 | #endif //KAB_EMBEDDED |
433 | // QDict<AddresseeEditorDialog> mEditorDict; | 433 | // QDict<AddresseeEditorDialog> mEditorDict; |
434 | AddresseeEditorDialog *mEditorDialog; | 434 | AddresseeEditorDialog *mEditorDialog; |
435 | bool mReadWrite; | 435 | bool mReadWrite; |
436 | bool mModified; | 436 | bool mModified; |
437 | bool mIsPart; | 437 | bool mIsPart; |
438 | bool mMultipleViewsAtOnce; | 438 | bool mMultipleViewsAtOnce; |
439 | 439 | ||
440 | 440 | ||
441 | //US file menu | 441 | //US file menu |
442 | KAction *mActionMail; | 442 | KAction *mActionMail; |
443 | KAction *mActionBeam; | 443 | KAction *mActionBeam; |
444 | KToggleAction *mActionBR; | 444 | KToggleAction *mActionBR; |
445 | KAction *mActionExport2phone; | 445 | KAction *mActionExport2phone; |
446 | KAction* mActionPrint; | 446 | KAction* mActionPrint; |
447 | KAction* mActionPrintDetails; | 447 | KAction* mActionPrintDetails; |
448 | KAction* mActionNewContact; | 448 | KAction* mActionNewContact; |
449 | KAction *mActionSave; | 449 | KAction *mActionSave; |
450 | KAction *mActionEditAddressee; | 450 | KAction *mActionEditAddressee; |
451 | KAction *mActionMailVCard; | 451 | KAction *mActionMailVCard; |
452 | KAction *mActionBeamVCard; | 452 | KAction *mActionBeamVCard; |
453 | 453 | ||
454 | KAction *mActionQuit; | 454 | KAction *mActionQuit; |
455 | 455 | ||
456 | //US edit menu | 456 | //US edit menu |
457 | KAction *mActionCopy; | 457 | KAction *mActionCopy; |
458 | KAction *mActionCut; | 458 | KAction *mActionCut; |
459 | KAction *mActionPaste; | 459 | KAction *mActionPaste; |
460 | KAction *mActionSelectAll; | 460 | KAction *mActionSelectAll; |
461 | KAction *mActionUndo; | 461 | KAction *mActionUndo; |
462 | KAction *mActionRedo; | 462 | KAction *mActionRedo; |
463 | KAction *mActionDelete; | 463 | KAction *mActionDelete; |
464 | 464 | ||
465 | //US settings menu | 465 | //US settings menu |
466 | KAction *mActionConfigResources; | 466 | KAction *mActionConfigResources; |
467 | KAction *mActionConfigGlobal; | 467 | KAction *mActionConfigGlobal; |
468 | KAction *mActionConfigKAddressbook; | 468 | KAction *mActionConfigKAddressbook; |
469 | KAction *mActionConfigShortcuts; | 469 | KAction *mActionConfigShortcuts; |
470 | KAction *mActionConfigureToolbars; | 470 | KAction *mActionConfigureToolbars; |
471 | KAction *mActionKeyBindings; | 471 | KAction *mActionKeyBindings; |
472 | KToggleAction *mActionJumpBar; | 472 | KToggleAction *mActionJumpBar; |
473 | KToggleAction *mActionDetails; | 473 | KToggleAction *mActionDetails; |
474 | KAction *mActionWhoAmI; | 474 | KAction *mActionWhoAmI; |
475 | KAction *mActionCategories; | 475 | KAction *mActionCategories; |
476 | KAction *mActionEditCategories; | 476 | KAction *mActionEditCategories; |
477 | KAction *mActionManageCategories; | 477 | KAction *mActionManageCategories; |
478 | KAction *mActionAboutKAddressbook; | 478 | KAction *mActionAboutKAddressbook; |
479 | KAction *mActionLicence; | 479 | KAction *mActionLicence; |
480 | KAction *mActionFaq; | 480 | KAction *mActionFaq; |
481 | KAction *mActionWN; | 481 | KAction *mActionWN; |
482 | KAction *mActionSyncHowto; | 482 | KAction *mActionSyncHowto; |
483 | KAction *mActionStorageHowto; | 483 | KAction *mActionStorageHowto; |
484 | KAction *mActionKdeSyncHowto; | 484 | KAction *mActionKdeSyncHowto; |
485 | KAction *mActionMultiSyncHowto; | 485 | KAction *mActionMultiSyncHowto; |
486 | 486 | ||
487 | KAction *mActionDeleteView; | 487 | KAction *mActionDeleteView; |
488 | 488 | ||
489 | QPopupMenu *viewMenu; | 489 | QPopupMenu *viewMenu; |
490 | QPopupMenu *filterMenu; | 490 | QPopupMenu *filterMenu; |
491 | QPopupMenu *settingsMenu; | 491 | QPopupMenu *settingsMenu; |
492 | QPopupMenu *changeMenu; | 492 | QPopupMenu *changeMenu; |
493 | QPopupMenu *beamMenu; | 493 | QPopupMenu *beamMenu; |
494 | //US QAction *mActionSave; | 494 | //US QAction *mActionSave; |
495 | QPopupMenu *ImportMenu; | 495 | QPopupMenu *ImportMenu; |
496 | QPopupMenu *ExportMenu; | 496 | QPopupMenu *ExportMenu; |
497 | //LR additional methods | 497 | //LR additional methods |
498 | KAction *mActionRemoveVoice; | 498 | KAction *mActionRemoveVoice; |
499 | KAction *mActionSetFormattedName; | 499 | KAction *mActionSetFormattedName; |
500 | KAction * mActionImportOL; | 500 | KAction * mActionImportOL; |
501 | 501 | ||
502 | #ifndef KAB_EMBEDDED | 502 | #ifndef KAB_EMBEDDED |
503 | KAddressBookService *mAddressBookService; | 503 | KAddressBookService *mAddressBookService; |
504 | #endif //KAB_EMBEDDED | 504 | #endif //KAB_EMBEDDED |
505 | 505 | ||
506 | class KABCorePrivate; | 506 | class KABCorePrivate; |
507 | KABCorePrivate *d; | 507 | KABCorePrivate *d; |
508 | //US bool mBlockSaveFlag; | 508 | //US bool mBlockSaveFlag; |
509 | 509 | ||
510 | #ifdef KAB_EMBEDDED | 510 | #ifdef KAB_EMBEDDED |
511 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 511 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
512 | #endif //KAB_EMBEDDED | 512 | #endif //KAB_EMBEDDED |
513 | 513 | ||
514 | //this are the overwritten callbackmethods from the syncinterface | 514 | //this are the overwritten callbackmethods from the syncinterface |
515 | virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); | 515 | virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); |
516 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 516 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
517 | virtual void removeSyncInfo( QString syncProfile); | 517 | virtual void removeSyncInfo( QString syncProfile); |
518 | bool syncPhone(); | 518 | bool syncPhone(); |
519 | void message( QString m , bool startTimer = true); | 519 | void message( QString m , bool startTimer = true); |
520 | 520 | ||
521 | // LR ******************************* | 521 | // LR ******************************* |
522 | // sync stuff! | 522 | // sync stuff! |
523 | QString sentSyncFile(); | 523 | QString sentSyncFile(); |
524 | QPopupMenu *syncMenu; | 524 | QPopupMenu *syncMenu; |
525 | KSyncManager* syncManager; | 525 | KSyncManager* syncManager; |
526 | int mGlobalSyncMode; | 526 | int mGlobalSyncMode; |
527 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 527 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
528 | KABC::Addressee getLastSyncAddressee(); | 528 | KABC::Addressee getLastSyncAddressee(); |
529 | QDateTime mLastAddressbookSync; | 529 | QDateTime mLastAddressbookSync; |
530 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 530 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
531 | // ********************* | 531 | // ********************* |
532 | 532 | ||
533 | }; | 533 | }; |
534 | 534 | ||
535 | #endif | 535 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index e615cbe..7197b30 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -188,514 +188,514 @@ void KSyncManager::slotClearMenu( int action ) | |||
188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
189 | 189 | ||
190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
191 | 0, 1 ); | 191 | 0, 1 ); |
192 | if ( result ) | 192 | if ( result ) |
193 | return; | 193 | return; |
194 | mImplementation->removeSyncInfo( syncDevice ); | 194 | mImplementation->removeSyncInfo( syncDevice ); |
195 | } | 195 | } |
196 | void KSyncManager::slotSyncMenu( int action ) | 196 | void KSyncManager::slotSyncMenu( int action ) |
197 | { | 197 | { |
198 | qDebug("KSM::syncaction %d ", action); | 198 | qDebug("KSM::syncaction %d ", action); |
199 | mCurrentResourceLocal = ""; | 199 | mCurrentResourceLocal = ""; |
200 | emit multiResourceSyncStart( false ); | 200 | emit multiResourceSyncStart( false ); |
201 | if ( action == 5000 ) | 201 | if ( action == 5000 ) |
202 | return; | 202 | return; |
203 | mSyncWithDesktop = false; | 203 | mSyncWithDesktop = false; |
204 | if ( action == 0 ) { | 204 | if ( action == 0 ) { |
205 | 205 | ||
206 | // seems to be a Qt2 event handling bug | 206 | // seems to be a Qt2 event handling bug |
207 | // syncmenu.clear causes a segfault at first time | 207 | // syncmenu.clear causes a segfault at first time |
208 | // when we call it after the main event loop, it is ok | 208 | // when we call it after the main event loop, it is ok |
209 | // same behaviour when calling OM/Pi via QCOP for the first time | 209 | // same behaviour when calling OM/Pi via QCOP for the first time |
210 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 210 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
211 | //confSync(); | 211 | //confSync(); |
212 | 212 | ||
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | if ( action == 1 ) { | 215 | if ( action == 1 ) { |
216 | multiSync( true ); | 216 | multiSync( true ); |
217 | return; | 217 | return; |
218 | } | 218 | } |
219 | if ( action == 2 ) { | 219 | if ( action == 2 ) { |
220 | enableQuick(); | 220 | enableQuick(); |
221 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 221 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
222 | return; | 222 | return; |
223 | } | 223 | } |
224 | if ( action == 3 ) { | 224 | if ( action == 3 ) { |
225 | delete mServerSocket; | 225 | delete mServerSocket; |
226 | mServerSocket = 0; | 226 | mServerSocket = 0; |
227 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 227 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
228 | return; | 228 | return; |
229 | } | 229 | } |
230 | 230 | ||
231 | if (blockSave()) | 231 | if (blockSave()) |
232 | return; | 232 | return; |
233 | 233 | ||
234 | setBlockSave(true); | 234 | setBlockSave(true); |
235 | bool silent = false; | 235 | bool silent = false; |
236 | if ( action == 999 ) { | 236 | if ( action == 999 ) { |
237 | //special mode for silent syncing | 237 | //special mode for silent syncing |
238 | action = 1000; | 238 | action = 1000; |
239 | silent = true; | 239 | silent = true; |
240 | } | 240 | } |
241 | 241 | ||
242 | mCurrentSyncProfile = action - 1000 ; | 242 | mCurrentSyncProfile = action - 1000 ; |
243 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 243 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
244 | mCurrentSyncName = mLocalMachineName ; | 244 | mCurrentSyncName = mLocalMachineName ; |
245 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 245 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
246 | KSyncProfile* temp = new KSyncProfile (); | 246 | KSyncProfile* temp = new KSyncProfile (); |
247 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 247 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
248 | temp->readConfig(&config); | 248 | temp->readConfig(&config); |
249 | if (silent) { | 249 | if (silent) { |
250 | mAskForPreferences = false; | 250 | mAskForPreferences = false; |
251 | mShowSyncSummary = false; | 251 | mShowSyncSummary = false; |
252 | mWriteBackFile = true; | 252 | mWriteBackFile = true; |
253 | mSyncAlgoPrefs = 2;// take newest | 253 | mSyncAlgoPrefs = 2;// take newest |
254 | } | 254 | } |
255 | else { | 255 | else { |
256 | mAskForPreferences = temp->getAskForPreferences(); | 256 | mAskForPreferences = temp->getAskForPreferences(); |
257 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 257 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
258 | mWriteBackFile = temp->getWriteBackFile(); | 258 | mWriteBackFile = temp->getWriteBackFile(); |
259 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 259 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
260 | } | 260 | } |
261 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 261 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
262 | mIsKapiFile = temp->getIsKapiFile(); | 262 | mIsKapiFile = temp->getIsKapiFile(); |
263 | mWriteBackInFuture = 0; | 263 | mWriteBackInFuture = 0; |
264 | if ( temp->getWriteBackFuture() ) { | 264 | if ( temp->getWriteBackFuture() ) { |
265 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 265 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
266 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 266 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
267 | } | 267 | } |
268 | mFilterInCal = temp->getFilterInCal(); | 268 | mFilterInCal = temp->getFilterInCal(); |
269 | mFilterOutCal = temp->getFilterOutCal(); | 269 | mFilterOutCal = temp->getFilterOutCal(); |
270 | mFilterInAB = temp->getFilterInAB(); | 270 | mFilterInAB = temp->getFilterInAB(); |
271 | mFilterOutAB = temp->getFilterOutAB(); | 271 | mFilterOutAB = temp->getFilterOutAB(); |
272 | 272 | ||
273 | if ( action == 1000 ) { | 273 | if ( action == 1000 ) { |
274 | mIsKapiFile = false; | 274 | mIsKapiFile = false; |
275 | #ifdef DESKTOP_VERSION | 275 | #ifdef DESKTOP_VERSION |
276 | syncKDE(); | 276 | syncKDE(); |
277 | #else | 277 | #else |
278 | syncSharp(); | 278 | syncSharp(); |
279 | #endif | 279 | #endif |
280 | 280 | ||
281 | } else if ( action == 1001 ) { | 281 | } else if ( action == 1001 ) { |
282 | syncLocalFile(); | 282 | syncLocalFile(); |
283 | 283 | ||
284 | } else if ( action == 1002 ) { | 284 | } else if ( action == 1002 ) { |
285 | mWriteBackFile = false; | 285 | mWriteBackFile = false; |
286 | mAskForPreferences = false; | 286 | mAskForPreferences = false; |
287 | mShowSyncSummary = false; | 287 | mShowSyncSummary = false; |
288 | mSyncAlgoPrefs = 3; | 288 | mSyncAlgoPrefs = 3; |
289 | quickSyncLocalFile(); | 289 | quickSyncLocalFile(); |
290 | 290 | ||
291 | } else if ( action >= 1003 ) { | 291 | } else if ( action >= 1003 ) { |
292 | if ( temp->getIsLocalFileSync() ) { | 292 | if ( temp->getIsLocalFileSync() ) { |
293 | switch(mTargetApp) | 293 | switch(mTargetApp) |
294 | { | 294 | { |
295 | case (KAPI): | 295 | case (KAPI): |
296 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 296 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
297 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 297 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
298 | break; | 298 | break; |
299 | case (KOPI): | 299 | case (KOPI): |
300 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 300 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
301 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 301 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
302 | break; | 302 | break; |
303 | case (PWMPI): | 303 | case (PWMPI): |
304 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 304 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
305 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 305 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
306 | break; | 306 | break; |
307 | default: | 307 | default: |
308 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 308 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
309 | break; | 309 | break; |
310 | 310 | ||
311 | } | 311 | } |
312 | } else { | 312 | } else { |
313 | if ( temp->getIsPhoneSync() ) { | 313 | if ( temp->getIsPhoneSync() ) { |
314 | mPhoneDevice = temp->getPhoneDevice( ) ; | 314 | mPhoneDevice = temp->getPhoneDevice( ) ; |
315 | mPhoneConnection = temp->getPhoneConnection( ); | 315 | mPhoneConnection = temp->getPhoneConnection( ); |
316 | mPhoneModel = temp->getPhoneModel( ); | 316 | mPhoneModel = temp->getPhoneModel( ); |
317 | syncPhone(); | 317 | syncPhone(); |
318 | } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { | 318 | } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { |
319 | mSpecificResources.clear(); | 319 | mSpecificResources.clear(); |
320 | if ( mTargetApp == KAPI ) { | 320 | if ( mTargetApp == KAPI ) { |
321 | if ( temp->getIsPiSyncSpec() ) | 321 | if ( temp->getIsPiSyncSpec() ) |
322 | mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); | 322 | mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); |
323 | mPassWordPiSync = temp->getRemotePwAB(); | 323 | mPassWordPiSync = temp->getRemotePwAB(); |
324 | mActiveSyncPort = temp->getRemotePortAB(); | 324 | mActiveSyncPort = temp->getRemotePortAB(); |
325 | mActiveSyncIP = temp->getRemoteIPAB(); | 325 | mActiveSyncIP = temp->getRemoteIPAB(); |
326 | } else if ( mTargetApp == KOPI ) { | 326 | } else if ( mTargetApp == KOPI ) { |
327 | if ( temp->getIsPiSyncSpec() ) | 327 | if ( temp->getIsPiSyncSpec() ) |
328 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); | 328 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); |
329 | mPassWordPiSync = temp->getRemotePw(); | 329 | mPassWordPiSync = temp->getRemotePw(); |
330 | mActiveSyncPort = temp->getRemotePort(); | 330 | mActiveSyncPort = temp->getRemotePort(); |
331 | mActiveSyncIP = temp->getRemoteIP(); | 331 | mActiveSyncIP = temp->getRemoteIP(); |
332 | } else { | 332 | } else { |
333 | mPassWordPiSync = temp->getRemotePwPWM(); | 333 | mPassWordPiSync = temp->getRemotePwPWM(); |
334 | mActiveSyncPort = temp->getRemotePortPWM(); | 334 | mActiveSyncPort = temp->getRemotePortPWM(); |
335 | mActiveSyncIP = temp->getRemoteIPPWM(); | 335 | mActiveSyncIP = temp->getRemoteIPPWM(); |
336 | } | 336 | } |
337 | syncPi(); | 337 | syncPi(); |
338 | while ( !mPisyncFinished ) { | 338 | while ( !mPisyncFinished ) { |
339 | //qDebug("waiting "); | 339 | //qDebug("waiting "); |
340 | qApp->processEvents(); | 340 | qApp->processEvents(); |
341 | } | 341 | } |
342 | } else | 342 | } else |
343 | syncRemote( temp ); | 343 | syncRemote( temp ); |
344 | 344 | ||
345 | } | 345 | } |
346 | } | 346 | } |
347 | delete temp; | 347 | delete temp; |
348 | setBlockSave(false); | 348 | setBlockSave(false); |
349 | } | 349 | } |
350 | 350 | ||
351 | void KSyncManager::enableQuick( bool ask ) | 351 | void KSyncManager::enableQuick( bool ask ) |
352 | { | 352 | { |
353 | bool autoStart; | 353 | bool autoStart; |
354 | bool changed = false; | 354 | bool changed = false; |
355 | if ( ask ) { | 355 | if ( ask ) { |
356 | QDialog dia ( 0, "input-dialog", true ); | 356 | QDialog dia ( 0, "input-dialog", true ); |
357 | QLineEdit lab ( &dia ); | 357 | QLineEdit lab ( &dia ); |
358 | QVBoxLayout lay( &dia ); | 358 | QVBoxLayout lay( &dia ); |
359 | lab.setText( mPrefs->mPassiveSyncPort ); | 359 | lab.setText( mPrefs->mPassiveSyncPort ); |
360 | lay.setMargin(7); | 360 | lay.setMargin(7); |
361 | lay.setSpacing(7); | 361 | lay.setSpacing(7); |
362 | int po = 9197+mTargetApp; | 362 | int po = 9197+mTargetApp; |
363 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); | 363 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); |
364 | lay.addWidget( &label); | 364 | lay.addWidget( &label); |
365 | lay.addWidget( &lab); | 365 | lay.addWidget( &lab); |
366 | 366 | ||
367 | QLineEdit lepw ( &dia ); | 367 | QLineEdit lepw ( &dia ); |
368 | lepw.setText( mPrefs->mPassiveSyncPw ); | 368 | lepw.setText( mPrefs->mPassiveSyncPw ); |
369 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 369 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
370 | lay.addWidget( &label2); | 370 | lay.addWidget( &label2); |
371 | lay.addWidget( &lepw); | 371 | lay.addWidget( &lepw); |
372 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 372 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
373 | lay.addWidget( &autostart); | 373 | lay.addWidget( &autostart); |
374 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 374 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
375 | #ifdef DESKTOP_VERSION | 375 | #ifdef DESKTOP_VERSION |
376 | #ifdef _WIN32_ | 376 | #ifdef _WIN32_ |
377 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 377 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
378 | syncdesktop.hide();// not implemented! | 378 | syncdesktop.hide();// not implemented! |
379 | #else | 379 | #else |
380 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 380 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
381 | #endif | 381 | #endif |
382 | lay.addWidget( &syncdesktop); | 382 | lay.addWidget( &syncdesktop); |
383 | #else | 383 | #else |
384 | mPrefs->mPassiveSyncWithDesktop = false; | 384 | mPrefs->mPassiveSyncWithDesktop = false; |
385 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 385 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
386 | syncdesktop.hide(); | 386 | syncdesktop.hide(); |
387 | #endif | 387 | #endif |
388 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 388 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
389 | 389 | ||
390 | QPushButton pb ( "OK", &dia); | 390 | QPushButton pb ( "OK", &dia); |
391 | lay.addWidget( &pb ); | 391 | lay.addWidget( &pb ); |
392 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 392 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
393 | dia.resize( 230,120 ); | 393 | dia.resize( 230,120 ); |
394 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 394 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
395 | dia.show(); | 395 | dia.show(); |
396 | #ifndef DESKTOP_VERSION | 396 | #ifndef DESKTOP_VERSION |
397 | int dw = QApplication::desktop()->width(); | 397 | int dw = QApplication::desktop()->width(); |
398 | int dh = QApplication::desktop()->height(); | 398 | int dh = QApplication::desktop()->height(); |
399 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); | 399 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); |
400 | #endif | 400 | #endif |
401 | if ( ! dia.exec() ) | 401 | if ( ! dia.exec() ) |
402 | return; | 402 | return; |
403 | dia.hide(); | 403 | dia.hide(); |
404 | qApp->processEvents(); | 404 | qApp->processEvents(); |
405 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 405 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
406 | changed = true; | 406 | changed = true; |
407 | mPrefs->mPassiveSyncPw = lepw.text(); | 407 | mPrefs->mPassiveSyncPw = lepw.text(); |
408 | } | 408 | } |
409 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 409 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
410 | mPrefs->mPassiveSyncPort = lab.text(); | 410 | mPrefs->mPassiveSyncPort = lab.text(); |
411 | changed = true; | 411 | changed = true; |
412 | } | 412 | } |
413 | autoStart = autostart.isChecked(); | 413 | autoStart = autostart.isChecked(); |
414 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 414 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
415 | changed = true; | 415 | changed = true; |
416 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 416 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
417 | } | 417 | } |
418 | } | 418 | } |
419 | else | 419 | else |
420 | autoStart = mPrefs->mPassiveSyncAutoStart; | 420 | autoStart = mPrefs->mPassiveSyncAutoStart; |
421 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 421 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
422 | changed = true; | 422 | changed = true; |
423 | bool ok; | 423 | bool ok; |
424 | mPrefs->mPassiveSyncAutoStart = false; | 424 | mPrefs->mPassiveSyncAutoStart = false; |
425 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); | 425 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); |
426 | if ( ! ok || port_t > 65535 ) { | 426 | if ( ! ok || port_t > 65535 ) { |
427 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); | 427 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); |
428 | return; | 428 | return; |
429 | } | 429 | } |
430 | Q_UINT16 port = port_t; | 430 | Q_UINT16 port = port_t; |
431 | //qDebug("port %d ", port); | 431 | //qDebug("port %d ", port); |
432 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 432 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
433 | mServerSocket->setFileName( defaultFileName() );//bbb | 433 | mServerSocket->setFileName( defaultFileName() );//bbb |
434 | if ( !mServerSocket->ok() ) { | 434 | if ( !mServerSocket->ok() ) { |
435 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); | 435 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); |
436 | delete mServerSocket; | 436 | delete mServerSocket; |
437 | mServerSocket = 0; | 437 | mServerSocket = 0; |
438 | return; | 438 | return; |
439 | } | 439 | } |
440 | mPrefs->mPassiveSyncAutoStart = autoStart; | 440 | mPrefs->mPassiveSyncAutoStart = autoStart; |
441 | if ( changed ) { | 441 | if ( changed ) { |
442 | mPrefs->writeConfig(); | 442 | mPrefs->writeConfig(); |
443 | } | 443 | } |
444 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 444 | //connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
445 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 445 | //connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
446 | connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); | 446 | connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); |
447 | connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); | 447 | connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); |
448 | } | 448 | } |
449 | void KSyncManager::displayErrorPort() | 449 | void KSyncManager::displayErrorPort() |
450 | { | 450 | { |
451 | KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); | 451 | KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); |
452 | } | 452 | } |
453 | void KSyncManager::syncLocalFile() | 453 | void KSyncManager::syncLocalFile() |
454 | { | 454 | { |
455 | 455 | ||
456 | QString fn =mPrefs->mLastSyncedLocalFile; | 456 | QString fn =mPrefs->mLastSyncedLocalFile; |
457 | QString ext; | 457 | QString ext; |
458 | 458 | ||
459 | switch(mTargetApp) | 459 | switch(mTargetApp) |
460 | { | 460 | { |
461 | case (KAPI): | 461 | case (KAPI): |
462 | ext = "(*.vcf)"; | 462 | ext = "(*.vcf)"; |
463 | break; | 463 | break; |
464 | case (KOPI): | 464 | case (KOPI): |
465 | ext = "(*.ics/*.vcs)"; | 465 | ext = "(*.ics/*.vcs)"; |
466 | break; | 466 | break; |
467 | case (PWMPI): | 467 | case (PWMPI): |
468 | ext = "(*.pwm)"; | 468 | ext = "(*.pwm)"; |
469 | break; | 469 | break; |
470 | default: | 470 | default: |
471 | qDebug("KSM::syncLocalFile: invalid apptype selected"); | 471 | qDebug("KSM::syncLocalFile: invalid apptype selected"); |
472 | break; | 472 | break; |
473 | 473 | ||
474 | } | 474 | } |
475 | 475 | ||
476 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 476 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
477 | if ( fn == "" ) | 477 | if ( fn == "" ) |
478 | return; | 478 | return; |
479 | if ( syncWithFile( fn, false ) ) { | 479 | if ( syncWithFile( fn, false ) ) { |
480 | qDebug("KSM::syncLocalFile() successful "); | 480 | qDebug("KSM::syncLocalFile() successful "); |
481 | } | 481 | } |
482 | 482 | ||
483 | } | 483 | } |
484 | 484 | ||
485 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 485 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
486 | { | 486 | { |
487 | bool ret = false; | 487 | bool ret = false; |
488 | QFileInfo info; | 488 | QFileInfo info; |
489 | info.setFile( fn ); | 489 | info.setFile( fn ); |
490 | QString mess; | 490 | QString mess; |
491 | if ( !info. exists() ) { | 491 | if ( !info. exists() ) { |
492 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 492 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
493 | QMessageBox::warning( mParent, i18n("Warning!"), | 493 | QMessageBox::warning( mParent, i18n("Warning!"), |
494 | mess ); | 494 | mess ); |
495 | return ret; | 495 | return ret; |
496 | } | 496 | } |
497 | int result = 0; | 497 | int result = 0; |
498 | if ( !quick ) { | 498 | if ( !quick ) { |
499 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 499 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
500 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 500 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
501 | mess, | 501 | mess, |
502 | i18n("Sync"), i18n("Cancel"), 0, | 502 | i18n("Sync"), i18n("Cancel"), 0, |
503 | 0, 1 ); | 503 | 0, 1 ); |
504 | if ( result ) | 504 | if ( result ) |
505 | return false; | 505 | return false; |
506 | } | 506 | } |
507 | if ( mAskForPreferences ) | 507 | if ( mAskForPreferences ) |
508 | if ( !edit_sync_options()) { | 508 | if ( !edit_sync_options()) { |
509 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 509 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
510 | return false; | 510 | return false; |
511 | } | 511 | } |
512 | if ( result == 0 ) { | 512 | if ( result == 0 ) { |
513 | //qDebug("Now sycing ... "); | 513 | //qDebug("Now sycing ... "); |
514 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) | 514 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) |
515 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 515 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
516 | else | 516 | else |
517 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 517 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
518 | if ( ! quick ) | 518 | if ( ! quick ) |
519 | mPrefs->mLastSyncedLocalFile = fn; | 519 | mPrefs->mLastSyncedLocalFile = fn; |
520 | } | 520 | } |
521 | return ret; | 521 | return ret; |
522 | } | 522 | } |
523 | 523 | ||
524 | void KSyncManager::quickSyncLocalFile() | 524 | void KSyncManager::quickSyncLocalFile() |
525 | { | 525 | { |
526 | 526 | ||
527 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 527 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
528 | qDebug("KSM::quick syncLocalFile() successful "); | 528 | qDebug("KSM::quick syncLocalFile() successful "); |
529 | 529 | ||
530 | } | 530 | } |
531 | } | 531 | } |
532 | 532 | ||
533 | void KSyncManager::multiSync( bool askforPrefs ) | 533 | void KSyncManager::multiSync( bool askforPrefs ) |
534 | { | 534 | { |
535 | if (blockSave()) | 535 | if (blockSave()) |
536 | return; | 536 | return; |
537 | setBlockSave(true); | 537 | setBlockSave(true); |
538 | mCurrentResourceLocal = ""; | 538 | mCurrentResourceLocal = ""; |
539 | if ( askforPrefs ) { | 539 | if ( askforPrefs ) { |
540 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 540 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
541 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 541 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
542 | question, | 542 | question, |
543 | i18n("Yes"), i18n("No"), | 543 | i18n("Yes"), i18n("No"), |
544 | 0, 0 ) != 0 ) { | 544 | 0, 0 ) != 0 ) { |
545 | setBlockSave(false); | 545 | setBlockSave(false); |
546 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 546 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
547 | return; | 547 | return; |
548 | } | 548 | } |
549 | } | 549 | } |
550 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 550 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
551 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 551 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
552 | if ( askforPrefs ) { | 552 | if ( askforPrefs ) { |
553 | if ( !edit_sync_options()) { | 553 | if ( !edit_sync_options()) { |
554 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 554 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
555 | return; | 555 | return; |
556 | } | 556 | } |
557 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 557 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
558 | } | 558 | } |
559 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 559 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
560 | qApp->processEvents(); | 560 | qApp->processEvents(); |
561 | int num = ringSync() ; | 561 | int num = ringSync() ; |
562 | if ( num > 1 ) | 562 | if ( num > 1 ) |
563 | ringSync(); | 563 | ringSync(); |
564 | setBlockSave(false); | 564 | setBlockSave(false); |
565 | if ( num ) | 565 | if ( num ) |
566 | emit save(); | 566 | emit save(); |
567 | if ( num ) | 567 | if ( num ) |
568 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 568 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
569 | else | 569 | else |
570 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 570 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
571 | return; | 571 | return; |
572 | } | 572 | } |
573 | 573 | ||
574 | int KSyncManager::ringSync() | 574 | int KSyncManager::ringSync() |
575 | { | 575 | { |
576 | emit multiResourceSyncStart( false ); | 576 | emit multiResourceSyncStart( false ); |
577 | int syncedProfiles = 0; | 577 | int syncedProfiles = 0; |
578 | unsigned int i; | 578 | unsigned int i; |
579 | QTime timer; | 579 | QTime timer; |
580 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 580 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
581 | QStringList syncProfileNames = mSyncProfileNames; | 581 | QStringList syncProfileNames = mSyncProfileNames; |
582 | KSyncProfile* temp = new KSyncProfile (); | 582 | KSyncProfile* temp = new KSyncProfile (); |
583 | mAskForPreferences = false; | 583 | mAskForPreferences = false; |
584 | mCurrentResourceLocal = ""; | 584 | mCurrentResourceLocal = ""; |
585 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 585 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
586 | mCurrentSyncProfile = i; | 586 | mCurrentSyncProfile = i; |
587 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 587 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
588 | temp->readConfig(&config); | 588 | temp->readConfig(&config); |
589 | 589 | ||
590 | bool includeInRingSync = false; | 590 | bool includeInRingSync = false; |
591 | switch(mTargetApp) | 591 | switch(mTargetApp) |
592 | { | 592 | { |
593 | case (KAPI): | 593 | case (KAPI): |
594 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 594 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
595 | break; | 595 | break; |
596 | case (KOPI): | 596 | case (KOPI): |
597 | includeInRingSync = temp->getIncludeInRingSync(); | 597 | includeInRingSync = temp->getIncludeInRingSync(); |
598 | break; | 598 | break; |
599 | case (PWMPI): | 599 | case (PWMPI): |
600 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 600 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
601 | break; | 601 | break; |
602 | default: | 602 | default: |
603 | qDebug("KSM::ringSync: invalid apptype selected"); | 603 | qDebug("KSM::ringSync: invalid apptype selected"); |
604 | break; | 604 | break; |
605 | 605 | ||
606 | } | 606 | } |
607 | 607 | ||
608 | 608 | ||
609 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 609 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
610 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 610 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
611 | ++syncedProfiles; | 611 | ++syncedProfiles; |
612 | mSyncWithDesktop = false; | 612 | mSyncWithDesktop = false; |
613 | // mAskForPreferences = temp->getAskForPreferences(); | 613 | // mAskForPreferences = temp->getAskForPreferences(); |
614 | mWriteBackFile = temp->getWriteBackFile(); | 614 | mWriteBackFile = temp->getWriteBackFile(); |
615 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 615 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
616 | mIsKapiFile = temp->getIsKapiFile(); | 616 | mIsKapiFile = temp->getIsKapiFile(); |
617 | mWriteBackInFuture = 0; | 617 | mWriteBackInFuture = 0; |
618 | if ( temp->getWriteBackFuture() ) { | 618 | if ( temp->getWriteBackFuture() ) { |
619 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 619 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
620 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 620 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
621 | } | 621 | } |
622 | mFilterInCal = temp->getFilterInCal(); | 622 | mFilterInCal = temp->getFilterInCal(); |
623 | mFilterOutCal = temp->getFilterOutCal(); | 623 | mFilterOutCal = temp->getFilterOutCal(); |
624 | mFilterInAB = temp->getFilterInAB(); | 624 | mFilterInAB = temp->getFilterInAB(); |
625 | mFilterOutAB = temp->getFilterOutAB(); | 625 | mFilterOutAB = temp->getFilterOutAB(); |
626 | mShowSyncSummary = false; | 626 | mShowSyncSummary = false; |
627 | mCurrentSyncDevice = syncProfileNames[i] ; | 627 | mCurrentSyncDevice = syncProfileNames[i] ; |
628 | mCurrentSyncName = mLocalMachineName; | 628 | mCurrentSyncName = mLocalMachineName; |
629 | if ( i == 0 ) { | 629 | if ( i == 0 ) { |
630 | mIsKapiFile = false; | 630 | mIsKapiFile = false; |
631 | #ifdef DESKTOP_VERSION | 631 | #ifdef DESKTOP_VERSION |
632 | syncKDE(); | 632 | syncKDE(); |
633 | #else | 633 | #else |
634 | syncSharp(); | 634 | syncSharp(); |
635 | #endif | 635 | #endif |
636 | } else { | 636 | } else { |
637 | if ( temp->getIsLocalFileSync() ) { | 637 | if ( temp->getIsLocalFileSync() ) { |
638 | switch(mTargetApp) | 638 | switch(mTargetApp) |
639 | { | 639 | { |
640 | case (KAPI): | 640 | case (KAPI): |
641 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 641 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
642 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 642 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
643 | break; | 643 | break; |
644 | case (KOPI): | 644 | case (KOPI): |
645 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 645 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
646 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 646 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
647 | break; | 647 | break; |
648 | case (PWMPI): | 648 | case (PWMPI): |
649 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 649 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
650 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 650 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
651 | break; | 651 | break; |
652 | default: | 652 | default: |
653 | qDebug("KSM: invalid apptype selected"); | 653 | qDebug("KSM: invalid apptype selected"); |
654 | break; | 654 | break; |
655 | } | 655 | } |
656 | } else { | 656 | } else { |
657 | if ( temp->getIsPhoneSync() ) { | 657 | if ( temp->getIsPhoneSync() ) { |
658 | mPhoneDevice = temp->getPhoneDevice( ) ; | 658 | mPhoneDevice = temp->getPhoneDevice( ) ; |
659 | mPhoneConnection = temp->getPhoneConnection( ); | 659 | mPhoneConnection = temp->getPhoneConnection( ); |
660 | mPhoneModel = temp->getPhoneModel( ); | 660 | mPhoneModel = temp->getPhoneModel( ); |
661 | syncPhone(); | 661 | syncPhone(); |
662 | } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { | 662 | } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { |
663 | mSpecificResources.clear(); | 663 | mSpecificResources.clear(); |
664 | if ( mTargetApp == KAPI ) { | 664 | if ( mTargetApp == KAPI ) { |
665 | if ( temp->getIsPiSyncSpec() ) | 665 | if ( temp->getIsPiSyncSpec() ) |
666 | mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); | 666 | mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); |
667 | mPassWordPiSync = temp->getRemotePwAB(); | 667 | mPassWordPiSync = temp->getRemotePwAB(); |
668 | mActiveSyncPort = temp->getRemotePortAB(); | 668 | mActiveSyncPort = temp->getRemotePortAB(); |
669 | mActiveSyncIP = temp->getRemoteIPAB(); | 669 | mActiveSyncIP = temp->getRemoteIPAB(); |
670 | } else if ( mTargetApp == KOPI ) { | 670 | } else if ( mTargetApp == KOPI ) { |
671 | if ( temp->getIsPiSyncSpec() ) | 671 | if ( temp->getIsPiSyncSpec() ) |
672 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); | 672 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); |
673 | mPassWordPiSync = temp->getRemotePw(); | 673 | mPassWordPiSync = temp->getRemotePw(); |
674 | mActiveSyncPort = temp->getRemotePort(); | 674 | mActiveSyncPort = temp->getRemotePort(); |
675 | mActiveSyncIP = temp->getRemoteIP(); | 675 | mActiveSyncIP = temp->getRemoteIP(); |
676 | } else { | 676 | } else { |
677 | mPassWordPiSync = temp->getRemotePwPWM(); | 677 | mPassWordPiSync = temp->getRemotePwPWM(); |
678 | mActiveSyncPort = temp->getRemotePortPWM(); | 678 | mActiveSyncPort = temp->getRemotePortPWM(); |
679 | mActiveSyncIP = temp->getRemoteIPPWM(); | 679 | mActiveSyncIP = temp->getRemoteIPPWM(); |
680 | } | 680 | } |
681 | syncPi(); | 681 | syncPi(); |
682 | while ( !mPisyncFinished ) { | 682 | while ( !mPisyncFinished ) { |
683 | //qDebug("waiting "); | 683 | //qDebug("waiting "); |
684 | qApp->processEvents(); | 684 | qApp->processEvents(); |
685 | } | 685 | } |
686 | timer.start(); | 686 | timer.start(); |
687 | while ( timer.elapsed () < 2000 ) { | 687 | while ( timer.elapsed () < 2000 ) { |
688 | qApp->processEvents(); | 688 | qApp->processEvents(); |
689 | } | 689 | } |
690 | } else | 690 | } else |
691 | syncRemote( temp, false ); | 691 | syncRemote( temp, false ); |
692 | 692 | ||
693 | } | 693 | } |
694 | } | 694 | } |
695 | timer.start(); | 695 | timer.start(); |
696 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 696 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
697 | while ( timer.elapsed () < 2000 ) { | 697 | while ( timer.elapsed () < 2000 ) { |
698 | qApp->processEvents(); | 698 | qApp->processEvents(); |
699 | #ifndef _WIN32_ | 699 | #ifndef _WIN32_ |
700 | sleep (1); | 700 | sleep (1); |
701 | #endif | 701 | #endif |