-rw-r--r-- | kabc/addressbook.cpp | 35 | ||||
-rw-r--r-- | kabc/addressbook.h | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 146 | ||||
-rw-r--r-- | microkde/kresources/configdialog.cpp | 5 | ||||
-rw-r--r-- | microkde/kresources/configdialog.h | 1 | ||||
-rw-r--r-- | microkde/kresources/resource.cpp | 14 | ||||
-rw-r--r-- | microkde/kresources/resource.h | 2 |
7 files changed, 119 insertions, 86 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 8882259..592d78d 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -378,2 +378,3 @@ bool AddressBook::save( Ticket *ticket ) } +// exports all Addressees, which are syncable void AddressBook::export2File( QString fileName ) @@ -392,11 +393,13 @@ void AddressBook::export2File( QString fileName ) version = KABC::VCardConverter::v3_0; - for ( it = begin(); it != end(); ++it ) { - if ( !(*it).IDStr().isEmpty() ) { - (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); + for ( it = begin(); it != end(); ++it ) { + if ( (*it).resource() && (*it).resource()->includeInSync() ) { + if ( !(*it).IDStr().isEmpty() ) { + (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); + } + KABC::VCardConverter converter; + QString vcard; + //Resource *resource() const; + converter.addresseeToVCard( *it, vcard, version ); + t << vcard << "\r\n"; } - KABC::VCardConverter converter; - QString vcard; - //Resource *resource() const; - converter.addresseeToVCard( *it, vcard, version ); - t << vcard << "\r\n"; } @@ -417,3 +420,3 @@ bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) continue; - } + } KABC::Addressee a = ( *it ); @@ -421,2 +424,4 @@ bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) continue; + if ( all && a.resource() && !a.resource()->includeInSync() ) + continue; a.simplifyEmails(); @@ -478,3 +483,3 @@ void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool rem if ( removeOld ) - setUntagged(); + setUntagged( true ); KABC::Addressee::List list; @@ -508,3 +513,3 @@ void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool rem } -void AddressBook::setUntagged() +void AddressBook::setUntagged(bool setNonSyncTagged) // = false) { @@ -512,3 +517,9 @@ void AddressBook::setUntagged() for ( ait = begin(); ait != end(); ++ait ) { - (*ait).setTagged( false ); + if ( setNonSyncTagged ) { + if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { + (*ait).setTagged( true ); + } else + (*ait).setTagged( false ); + } else + (*ait).setTagged( false ); } diff --git a/kabc/addressbook.h b/kabc/addressbook.h index a6bf451..23bba02 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h @@ -150,3 +150,3 @@ class AddressBook : public QObject void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); - void setUntagged(); + void setUntagged( bool setNonSyncTagged = false ); void removeUntagged(); diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index ea34be2..47ed858 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -2553,44 +2553,46 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars - if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { - //qDebug("take %d %s ", take, inL.summary().latin1()); - if ( take == 3 ) - return false; - if ( take == 1 ) {// take local - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { - inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); - inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); - local->insertAddressee( inL, false ); - idS = inR.externalUID(); - OidS = inR.originalExternalUID(); - } - else - idS = inR.IDStr(); - remote->removeAddressee( inR ); - inR = inL; - inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { - inR.setOriginalExternalUID( OidS ); - inR.setExternalUID( idS ); - } else { - inR.setIDStr( idS ); - } - inR.setResource( 0 ); - remote->insertAddressee( inR , false); - ++changedRemote; - } else { // take == 2 take remote - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { - if ( inR.revision().date().year() < 2004 ) - inR.setRevision( modifiedCalendar ); - } - idS = inL.IDStr(); - local->removeAddressee( inL ); - inL = inR; - inL.setIDStr( idS ); - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { - inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); - inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); + if ( !inL.resource() || inL.resource()->includeInSync() ) { + if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { + //qDebug("take %d %s ", take, inL.summary().latin1()); + if ( take == 3 ) + return false; + if ( take == 1 ) {// take local + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); + inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); + local->insertAddressee( inL, false ); + idS = inR.externalUID(); + OidS = inR.originalExternalUID(); + } + else + idS = inR.IDStr(); + remote->removeAddressee( inR ); + inR = inL; + inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + inR.setOriginalExternalUID( OidS ); + inR.setExternalUID( idS ); + } else { + inR.setIDStr( idS ); + } + inR.setResource( 0 ); + remote->insertAddressee( inR , false); + ++changedRemote; + } else { // take == 2 take remote + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + if ( inR.revision().date().year() < 2004 ) + inR.setRevision( modifiedCalendar ); + } + idS = inL.IDStr(); + local->removeAddressee( inL ); + inL = inR; + inL.setIDStr( idS ); + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); + inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); + } + inL.setResource( 0 ); + local->insertAddressee( inL , false ); + ++changedLocal; } - inL.setResource( 0 ); - local->insertAddressee( inL , false ); - ++changedLocal; } @@ -2647,34 +2649,36 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo inL = local->findByUid( uid ); - inR = remote->findByUid( uid ); - if ( inR.isEmpty() ) { - if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { - if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { - // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); - local->removeAddressee( inL ); - ++deletedAddresseeL; - } else { - if ( ! syncManager->mWriteBackExistingOnly ) { - inL.removeID(mCurrentSyncDevice ); - ++addedAddresseeR; - inL.setRevision( modifiedCalendar ); - local->insertAddressee( inL, false ); - inR = inL; - inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); - inR.setResource( 0 ); - remote->insertAddressee( inR, false ); + if ( !inL.resource() || inL.resource()->includeInSync() ) { + inR = remote->findByUid( uid ); + if ( inR.isEmpty() ) { + if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { + if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { + // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); + local->removeAddressee( inL ); + ++deletedAddresseeL; + } else { + if ( ! syncManager->mWriteBackExistingOnly ) { + inL.removeID(mCurrentSyncDevice ); + ++addedAddresseeR; + inL.setRevision( modifiedCalendar ); + local->insertAddressee( inL, false ); + inR = inL; + inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); + inR.setResource( 0 ); + remote->insertAddressee( inR, false ); + } } - } - } else { - if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { - // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); - local->removeAddressee( inL ); - ++deletedAddresseeL; } else { - if ( ! syncManager->mWriteBackExistingOnly ) { - ++addedAddresseeR; - inL.setRevision( modifiedCalendar ); - local->insertAddressee( inL, false ); - inR = inL; - inR.setResource( 0 ); - remote->insertAddressee( inR, false ); + if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { + // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); + local->removeAddressee( inL ); + ++deletedAddresseeL; + } else { + if ( ! syncManager->mWriteBackExistingOnly ) { + ++addedAddresseeR; + inL.setRevision( modifiedCalendar ); + local->insertAddressee( inL, false ); + inR = inL; + inR.setResource( 0 ); + remote->insertAddressee( inR, false ); + } } diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp index f8240f9..030b547 100644 --- a/microkde/kresources/configdialog.cpp +++ b/microkde/kresources/configdialog.cpp @@ -77,4 +77,8 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, if (!mResource->isSyncable()) { + new QLabel("", generalGroupBox ); mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); mReadOnly->setChecked( mResource->readOnly() ); + new QLabel("", generalGroupBox ); + mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox ); + mIncludeInSync->setChecked( mResource->includeInSync() ); } @@ -222,2 +226,3 @@ void ConfigDialog::accept() mResource->setReadOnly( mReadOnly->isChecked() ); + mResource->setIncludeInSync( mIncludeInSync->isChecked() ); diff --git a/microkde/kresources/configdialog.h b/microkde/kresources/configdialog.h index 63cd4e9..ed3ecab 100644 --- a/microkde/kresources/configdialog.h +++ b/microkde/kresources/configdialog.h @@ -60,2 +60,3 @@ class ConfigDialog : public KDialogBase QCheckBox *mReadOnly; + QCheckBox *mIncludeInSync; //US add a persistent readonly flag. We need that for opie and qtopia addressbooks. diff --git a/microkde/kresources/resource.cpp b/microkde/kresources/resource.cpp index 4f69540..f79bcd0 100644 --- a/microkde/kresources/resource.cpp +++ b/microkde/kresources/resource.cpp @@ -41,2 +41,3 @@ class Resource::ResourcePrivate bool mReadOnly; + bool mIncludeInSync; QString mName; @@ -65,2 +66,3 @@ Resource::Resource( const KConfig* config ) d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false ); + d->mIncludeInSync = cfg->readBoolEntry( "ResourceIncludeInSync", true );; d->mActive = cfg->readBoolEntry( "ResourceIsActive", true ); @@ -71,2 +73,3 @@ Resource::Resource( const KConfig* config ) d->mReadOnly = false; + d->mIncludeInSync = true; d->mActive = true; @@ -84,4 +87,2 @@ void Resource::writeConfig( KConfig* config ) { - - config->writeEntry( "ResourceType", d->mType ); @@ -89,2 +90,3 @@ void Resource::writeConfig( KConfig* config ) config->writeEntry( "ResourceIsReadOnly", d->mReadOnly ); + config->writeEntry( "ResourceIncludeInSync", d->mIncludeInSync ); config->writeEntry( "ResourceIsActive", d->mActive ); @@ -151,2 +153,10 @@ QString Resource::type() const +void Resource::setIncludeInSync( bool value ) +{ + d->mIncludeInSync = value; +} +bool Resource::includeInSync() const +{ + return d->mIncludeInSync; +} void Resource::setReadOnly( bool value ) diff --git a/microkde/kresources/resource.h b/microkde/kresources/resource.h index 580b5d1..70b5613 100644 --- a/microkde/kresources/resource.h +++ b/microkde/kresources/resource.h @@ -312,2 +312,4 @@ class Resource : public QObject + void setIncludeInSync( bool value ); + bool includeInSync() const; /** |