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 | |||
@@ -474,70 +474,94 @@ bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | |||
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; |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 4a0d0a3..e6daa5e 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -139,26 +139,26 @@ class AddressBook : public QObject | |||
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 | ||
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 5d377bf..7d8586a 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1928,25 +1928,25 @@ void KABCore::initGUI() | |||
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 ); |
@@ -3451,31 +3451,31 @@ bool KABCore::syncPhone() | |||
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" ) { |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 2d1505f..e69cb60 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -347,25 +347,25 @@ class KABCore : public QWidget, public KSyncInterface | |||
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( ); |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index e615cbe..7197b30 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -432,26 +432,26 @@ void KSyncManager::enableQuick( bool ask ) | |||
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; |