-rw-r--r-- | kabc/addressbook.cpp | 32 | ||||
-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, 36 insertions, 12 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index e04f4b1..bdc2762 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -478,64 +478,88 @@ bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) } else { qDebug("Error open temp file "); return false; } return true; } -int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) +int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld, QString resource ) { if ( removeOld ) - setUntagged( true ); + setUntagged( true, resource ); KABC::Addressee::List list; QFile file( fileName ); file.open( IO_ReadOnly ); QByteArray rawData = file.readAll(); file.close(); QString data; if ( replaceLabel ) { data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); data.replace ( QRegExp("LABEL") , "ADR" ); data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); } else data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); KABC::VCardTool tool; list = tool.parseVCards( data ); KABC::Addressee::List::Iterator it; + + Resource * setRes = 0; + if ( !resource.isEmpty() ) { + KRES::Manager<Resource>::ActiveIterator it; + KRES::Manager<Resource> *manager = d->mManager; + for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { + qDebug("SaveAB::checking resource..." ); + if ( (*it)->name() == resource ) { + setRes = (*it); + qDebug("Inserting imported contacs to resource %s", resource.latin1()); + break; + } + } + } for ( it = list.begin(); it != list.end(); ++it ) { QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); if ( !id.isEmpty() ) (*it).setIDStr(id ); - (*it).setResource( 0 ); + (*it).setResource( setRes ); if ( replaceLabel ) (*it).removeVoice(); if ( removeOld ) (*it).setTagged( true ); insertAddressee( (*it), false, true ); } if ( removeOld ) removeUntagged(); return list.count(); } -void AddressBook::setUntagged(bool setNonSyncTagged) // = false) +void AddressBook::setUntagged(bool setNonSyncTagged, QString resource) // = false , "") { Iterator ait; + if ( !resource.isEmpty() ) { + for ( ait = begin(); ait != end(); ++ait ) { + if ( (*ait).resource() && (*ait).resource()->name() == resource ) { + (*ait).setTagged( false ); + } + else + (*ait).setTagged( true ); + } + } else { for ( ait = begin(); ait != end(); ++ait ) { if ( setNonSyncTagged ) { if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { (*ait).setTagged( true ); } else (*ait).setTagged( false ); } else (*ait).setTagged( false ); } } +} void AddressBook::removeUntagged() { Iterator ait; bool todelete = false; Iterator todel; for ( ait = begin(); ait != end(); ++ait ) { if ( todelete ) removeAddressee( todel ); diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 4a0d0a3..e6daa5e 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h @@ -143,18 +143,18 @@ class AddressBook : public QObject bool save( Ticket *ticket ); bool saveAB( ); bool saveABphone( QString fileName ); void smplifyAddressees(); void removeSyncInfo( QString syncProfile); void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); void export2File( QString fileName, QString resourceName = "" ); bool export2PhoneFormat( QStringList uids ,QString fileName ); - int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); - void setUntagged( bool setNonSyncTagged = false ); + int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false, QString resource = "" ); + void setUntagged( bool setNonSyncTagged = false, QString resource = "" ); void removeUntagged(); void findNewExtIds( QString fileName, QString currentSyncDevice ); /** Returns a iterator for first entry of address book. */ Iterator begin(); /** diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 5d377bf..7d8586a 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -1932,17 +1932,17 @@ void KABCore::initGUI() topLayout->addWidget( mDetails ); #endif //KAB_NOSPLITTER */ syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); syncManager->setBlockSave(false); connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); - connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); + connect(syncManager , SIGNAL( getFile( bool ,const QString &)), this, SLOT(getFile( bool ,const QString &) ) ); QString sync_file = sentSyncFile(); //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); syncManager->setDefaultFileName( sync_file ); //connect(syncManager , SIGNAL( ), this, SLOT( ) ); #endif //KAB_EMBEDDED initActions(); @@ -3455,23 +3455,23 @@ bool KABCore::syncPhone() } setModified(); } abLocal.removeResources(); if ( syncOK ) mViewManager->refreshView(); return syncOK; } -void KABCore::getFile( bool success ) +void KABCore::getFile( bool success ,const QString & resource) { if ( ! success ) { message( i18n("Error receiving file. Nothing changed!") ); return; } - int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); + int count = mAddressBook->importFromFile( sentSyncFile() , false, true ,resource); if ( count ) setModified( true ); message( i18n("Pi-Sync successful!") ); mViewManager->refreshView(); } void KABCore::syncFileRequest(const QString & resource) { if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 2d1505f..e69cb60 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -351,17 +351,17 @@ class KABCore : public QWidget, public KSyncInterface signals: void contactSelected( const QString &name ); void contactSelected( const QPixmap &pixmap ); public slots: void loadDataAfterStart(); void recieve(QString cmsg ); - void getFile( bool success ); + void getFile( bool success,const QString & ); void syncFileRequest(const QString &); void setDetailsVisible( bool visible ); void setDetailsToState(); void saveSettings(); private slots: void updateToolBar(); diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index e615cbe..7197b30 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -436,18 +436,18 @@ void KSyncManager::enableQuick( bool ask ) delete mServerSocket; mServerSocket = 0; return; } mPrefs->mPassiveSyncAutoStart = autoStart; if ( changed ) { mPrefs->writeConfig(); } - connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); - connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); + //connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); + //connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); } void KSyncManager::displayErrorPort() { 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")); } void KSyncManager::syncLocalFile() |