summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-12-02 09:42:53 (UTC)
committer zautrix <zautrix>2005-12-02 09:42:53 (UTC)
commita75d2c26aba6cffae8c3f61e173940240042427b (patch) (side-by-side diff)
tree68f4b61c150bc263a98c78fdf8671bbbc17cdaf8
parent64be8d64fc26d1025a24150d065197ba5d608f3d (diff)
downloadkdepimpi-a75d2c26aba6cffae8c3f61e173940240042427b.zip
kdepimpi-a75d2c26aba6cffae8c3f61e173940240042427b.tar.gz
kdepimpi-a75d2c26aba6cffae8c3f61e173940240042427b.tar.bz2
more sync
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
@@ -480,17 +480,17 @@ bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
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;
@@ -500,38 +500,62 @@ int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool remo
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;
- for ( ait = begin(); ait != end(); ++ait ) {
- if ( setNonSyncTagged ) {
- if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) {
+ 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 );
- } else
- (*ait).setTagged( false );
+ }
}
}
void AddressBook::removeUntagged()
{
Iterator ait;
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
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
@@ -1934,13 +1934,13 @@ void KABCore::initGUI()
*/
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
@@ -3457,19 +3457,19 @@ bool KABCore::syncPhone()
}
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)
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
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();
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 )
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"));