summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp42
-rw-r--r--kabc/addressbook.h4
-rw-r--r--kaddressbook/kabcore.cpp6
-rw-r--r--kaddressbook/kabcore.h2
-rw-r--r--libkdepim/ksyncmanager.cpp4
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
@@ -470,78 +470,102 @@ bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
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}
486int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) 486int 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}
521void AddressBook::setUntagged(bool setNonSyncTagged) // = false) 535void 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}
534void AddressBook::removeUntagged() 558void 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 }
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 4a0d0a3..e6daa5e 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -135,34 +135,34 @@ class AddressBook : public QObject
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();
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 5d377bf..7d8586a 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1924,33 +1924,33 @@ void KABCore::initGUI()
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());
@@ -3447,39 +3447,39 @@ bool KABCore::syncPhone()
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}
3463void KABCore::getFile( bool success ) 3463void 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}
3475void KABCore::syncFileRequest(const QString & resource) 3475void 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);
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 2d1505f..e69cb60 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -343,33 +343,33 @@ class KABCore : public QWidget, public KSyncInterface
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();
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index e615cbe..7197b30 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -428,34 +428,34 @@ void KSyncManager::enableQuick( bool ask )
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}
449void KSyncManager::displayErrorPort() 449void 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}
453void KSyncManager::syncLocalFile() 453void 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):