summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp35
-rw-r--r--kabc/addressbook.h2
-rw-r--r--kaddressbook/kabcore.cpp146
-rw-r--r--microkde/kresources/configdialog.cpp5
-rw-r--r--microkde/kresources/configdialog.h1
-rw-r--r--microkde/kresources/resource.cpp14
-rw-r--r--microkde/kresources/resource.h2
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
@@ -371,59 +371,64 @@ bool AddressBook::save( Ticket *ticket )
if ( ticket->resource() ) {
deleteRemovedAddressees();
return ticket->resource()->save( ticket );
}
return false;
}
+// exports all Addressees, which are syncable
void AddressBook::export2File( QString fileName )
{
QFile outFile( fileName );
if ( !outFile.open( IO_WriteOnly ) ) {
QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
KMessageBox::error( 0, text.arg( fileName ) );
return ;
}
QTextStream t( &outFile );
t.setEncoding( QTextStream::UnicodeUTF8 );
Iterator it;
KABC::VCardConverter::Version version;
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";
}
t << "\r\n\r\n";
outFile.close();
}
// if QStringList uids is empty, all are exported
bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
{
KABC::VCardConverter converter;
QString datastream;
Iterator it;
bool all = uids.isEmpty();
for ( it = begin(); it != end(); ++it ) {
// for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
if ( ! all ) {
if ( ! ( uids.contains((*it).uid() ) ))
continue;
- }
+ }
KABC::Addressee a = ( *it );
if ( a.isEmpty() )
continue;
+ if ( all && a.resource() && !a.resource()->includeInSync() )
+ continue;
a.simplifyEmails();
a.simplifyPhoneNumbers();
a.simplifyPhoneNumberTypes();
a.simplifyAddresses();
QString vcard;
QString vcardnew;
converter.addresseeToVCard( a, vcard );
@@ -471,17 +476,17 @@ bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
}
return true;
}
void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld )
{
if ( removeOld )
- setUntagged();
+ setUntagged( true );
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 );
@@ -501,21 +506,27 @@ void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool rem
(*it).removeVoice();
if ( removeOld )
(*it).setTagged( true );
insertAddressee( (*it), false, true );
}
if ( removeOld )
removeUntagged();
}
-void AddressBook::setUntagged()
+void AddressBook::setUntagged(bool setNonSyncTagged) // = false)
{
Iterator ait;
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 );
}
}
void AddressBook::removeUntagged()
{
Iterator ait;
bool todelete = false;
Iterator todel;
for ( ait = begin(); ait != end(); ++ait ) {
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index a6bf451..23bba02 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -143,17 +143,17 @@ class AddressBook : public QObject
bool save( Ticket *ticket );
bool saveAB( );
bool saveABphone( QString fileName );
void smplifyAddressees();
void preparePhoneSync( QString currentSyncDevice, bool isPreSync );
void export2File( QString fileName );
bool export2PhoneFormat( QStringList uids ,QString fileName );
void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false );
- void setUntagged();
+ void setUntagged( bool setNonSyncTagged = false );
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 ea34be2..47ed858 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2546,58 +2546,60 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
QString idS,OidS;
qApp->processEvents();
if ( !skipIncidence ) {
inL = local->findByUid( uid );
inR = remote->findByUid( uid );
//inL.setResource( 0 );
//inR.setResource( 0 );
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;
}
}
} else { // no conflict
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
QString des = addresseeLSync.note();
if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
remote->insertAddressee( inR, false );
@@ -2640,48 +2642,50 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
if ( incCounter % modulo == 0 )
syncManager->showProgressBar(incCounter);
uid = el[ incCounter ];
bool skipIncidence = false;
if ( uid.left(19) == QString("last-syncAddressee-") )
skipIncidence = true;
if ( !skipIncidence ) {
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 );
+ }
}
}
}
}
}
++incCounter;
}
el.clear();
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
@@ -70,18 +70,22 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
generalGroupBox->layout()->setSpacing( spacingHint() );
generalGroupBox->setTitle( i18n( "General Settings" ) );
new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox );
mName = new KLineEdit( generalGroupBox );
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() );
}
mName->setText( mResource->resourceName() );
mainLayout->addWidget( generalGroupBox );
QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
resourceGroupBox->layout()->setSpacing( spacingHint());
@@ -215,16 +219,17 @@ void ConfigDialog::accept()
if ( mName->text().isEmpty() ) {
KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) );
return;
}
mResource->setResourceName( mName->text() );
if (!mResource->isSyncable())
mResource->setReadOnly( mReadOnly->isChecked() );
+ mResource->setIncludeInSync( mIncludeInSync->isChecked() );
if ( mConfigWidget ) {
// First save generic information
// Also save setting of specific resource type
mConfigWidget->saveSettings( mResource );
}
if ( mSyncWidget_Settings )
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
@@ -53,15 +53,16 @@ class ConfigDialog : public KDialogBase
ConfigWidget *mConfigWidget;
SyncWidget *mSyncWidget_Settings;
SyncWidget *mSyncWidget_Conflicts;
SyncWidget *mSyncWidget_Remote;
Resource* mResource;
KLineEdit *mName;
QCheckBox *mReadOnly;
+ QCheckBox *mIncludeInSync;
//US add a persistent readonly flag. We need that for opie and qtopia addressbooks.
bool mPersistentReadOnly;
};
}
#endif
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
@@ -34,16 +34,17 @@ class Resource::ResourcePrivate
public:
#ifdef QT_THREAD_SUPPORT
QMutex mMutex;
#endif
int mOpenCount;
QString mType;
QString mIdentifier;
bool mReadOnly;
+ bool mIncludeInSync;
QString mName;
bool mActive;
bool mIsOpen;
};
Resource::Resource( const KConfig* config )
: QObject( 0, "" ), d( new ResourcePrivate )
{
@@ -58,40 +59,41 @@ Resource::Resource( const KConfig* config )
// such that group info not available on win32 plugins
// to fix that, it would be a looooot of work
if ( !cfg->tempGroup().isEmpty() )
cfg->setGroup( cfg->tempGroup() );
#endif
d->mType = cfg->readEntry( "ResourceType" );
d->mName = cfg->readEntry( "ResourceName" );
d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false );
+ d->mIncludeInSync = cfg->readBoolEntry( "ResourceIncludeInSync", true );;
d->mActive = cfg->readBoolEntry( "ResourceIsActive", true );
d->mIdentifier = cfg->readEntry( "ResourceIdentifier" );
} else {
d->mType = "type";
d->mName = "resource-name";
d->mReadOnly = false;
+ d->mIncludeInSync = true;
d->mActive = true;
d->mIdentifier = KApplication::randomString( 10 );
}
}
Resource::~Resource()
{
delete d;
d = 0;
}
void Resource::writeConfig( KConfig* config )
{
-
-
config->writeEntry( "ResourceType", d->mType );
config->writeEntry( "ResourceName", d->mName );
config->writeEntry( "ResourceIsReadOnly", d->mReadOnly );
+ config->writeEntry( "ResourceIncludeInSync", d->mIncludeInSync );
config->writeEntry( "ResourceIsActive", d->mActive );
config->writeEntry( "ResourceIdentifier", d->mIdentifier );
}
bool Resource::open()
{
d->mIsOpen = true;
#ifdef QT_THREAD_SUPPORT
@@ -144,16 +146,24 @@ void Resource::setType( const QString& type )
d->mType = type;
}
QString Resource::type() const
{
return d->mType;
}
+void Resource::setIncludeInSync( bool value )
+{
+ d->mIncludeInSync = value;
+}
+bool Resource::includeInSync() const
+{
+ return d->mIncludeInSync;
+}
void Resource::setReadOnly( bool value )
{
d->mReadOnly = value;
}
bool Resource::readOnly() const
{
return d->mReadOnly;
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
@@ -305,16 +305,18 @@ class Resource : public QObject
*/
virtual void setReadOnly( bool value );
/**
* Returns, if the resource is read-only.
*/
virtual bool readOnly() const;
+ void setIncludeInSync( bool value );
+ bool includeInSync() const;
/**
* Set the name of resource.You can override this method,
* but also remember to call Resource::setResourceName().
*/
virtual void setResourceName( const QString &name );
/**
* Returns the name of resource.