-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 | |||
@@ -480,17 +480,17 @@ bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | |||
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; |
@@ -500,38 +500,62 @@ int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool remo | |||
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; |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 4a0d0a3..e6daa5e 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -145,14 +145,14 @@ class AddressBook : public QObject | |||
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(); |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 5d377bf..7d8586a 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1934,13 +1934,13 @@ void KABCore::initGUI() | |||
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 |
@@ -3457,19 +3457,19 @@ bool KABCore::syncPhone() | |||
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) |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 2d1505f..e69cb60 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -353,13 +353,13 @@ class KABCore : public QWidget, public KSyncInterface | |||
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 | ||
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index e615cbe..7197b30 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -438,14 +438,14 @@ void KSyncManager::enableQuick( bool ask ) | |||
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")); |