summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp13
-rw-r--r--kabc/addressee.h2
-rw-r--r--kabc/plugins/qtopia/qtopiaE.pro2
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp7
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.h1
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp78
-rw-r--r--kaddressbook/kabcore.cpp87
-rw-r--r--libkcal/sharpformat.cpp6
-rw-r--r--libkcal/syncdefines.h2
9 files changed, 141 insertions, 57 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 3a2dc5f..fda62f1 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -67,6 +67,7 @@ struct Addressee::AddresseeData : public KShared
QDateTime revision;
QString sortString;
QString externalUID;
+ QString originalExternalUID;
KURL url;
Secrecy secrecy;
Picture logo;
@@ -373,6 +374,18 @@ QString Addressee::externalUID() const
{
return mData->externalUID;
}
+void Addressee::setOriginalExternalUID( const QString &id )
+{
+ if ( id == mData->originalExternalUID ) return;
+ detach();
+ mData->empty = false;
+ mData->originalExternalUID = id;
+}
+
+QString Addressee::originalExternalUID() const
+{
+ return mData->originalExternalUID;
+}
void Addressee::setUid( const QString &id )
{
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 3ba7777..8baa888 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -114,6 +114,8 @@ class Addressee
bool isEmpty() const;
void setExternalUID( const QString &id );
QString externalUID() const;
+ void setOriginalExternalUID( const QString &id );
+ QString originalExternalUID() const;
void mergeContact( const Addressee& ad );
/**
Set unique identifier.
diff --git a/kabc/plugins/qtopia/qtopiaE.pro b/kabc/plugins/qtopia/qtopiaE.pro
index 148da2a..c0aa960 100644
--- a/kabc/plugins/qtopia/qtopiaE.pro
+++ b/kabc/plugins/qtopia/qtopiaE.pro
@@ -3,7 +3,7 @@ CONFIG += qt warn_on
TARGET = microkabc_qtopia
-INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include
+INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include
OBJECTS_DIR = obj/$(PLATFORM)
MOC_DIR = moc/$(PLATFORM)
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index 7d00a3f..de45e63 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -32,6 +32,7 @@ $Id$
#include "qtopiaconverter.h"
#include <qpe/categories.h>
+#include <libkdepim/ksyncprofile.h>
//US #include <qpe/categoryselect.h>
@@ -75,7 +76,10 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a
addr.setAdditionalName( contact.middleName() );
addr.setPrefix( contact.nameTitle() );
addr.setSuffix( contact.suffix() );
+
+ addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
QString exuid = contact.uid().toString();
+ addr.setOriginalExternalUID( exuid );
int ente = exuid.find( "-0000");
if ( exuid.left(1) == "{" )
exuid = exuid.mid(1);
@@ -251,6 +255,9 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a
bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact )
{
+
+
+
// name
contact.setLastName(addr.familyName());
contact.setFirstName(addr.givenName());
diff --git a/kabc/plugins/qtopia/qtopiaconverter.h b/kabc/plugins/qtopia/qtopiaconverter.h
index 8f4c698..012a6e2 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.h
+++ b/kabc/plugins/qtopia/qtopiaconverter.h
@@ -31,6 +31,7 @@ $Id$
#include "addressee.h"
#include <qpe/pim/contact.h>
+#include <qpe/quuid.h>
class Categories;
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 48a9f22..935a1cf 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -52,6 +52,8 @@ $Id$
#include "syncprefwidget.h"
#include "resourceqtopia.h"
+#include <libkdepim/ksyncprofile.h>
+#include <qpe/quuid.h>
using namespace KABC;
extern "C"
@@ -189,38 +191,60 @@ bool ResourceQtopia::load()
bool ResourceQtopia::save( Ticket *ticket )
{
- qDebug("ResourceQtopia::save: %s", fileName().latin1());
-
- mDirWatch.stopScan();
-
- KABC::AddressBook::Iterator it;
- bool res;
-
- for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
- PimContact c;
- KABC::Addressee addressee = (*it);
-
- res = mConverter->addresseeToQtopia( *it, c );
- if (res == true)
- {
- mAccess->addContact(c);
-// if (res == false)
-// qDebug("Unable to append Contact %s", c.fullName().latin1());
+ qDebug("ResourceQtopia::save: %s", fileName().latin1());
+
+ mDirWatch.stopScan();
+
+ KABC::AddressBook::Iterator it;
+ bool res;
+
+ for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
+ //KABC::Addressee addressee = (*it);
+ if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
+ QUuid uid( (*it).originalExternalUID() );
+ bool ok;
+ PimContact c = mAccess->contactForId( uid, &ok );
+ res = mConverter->addresseeToQtopia( *it, c );
+ if (res == true) {
+ if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
+ mAccess->addContact(c);
+ KABC::Addressee addressee;
+ mConverter->qtopiaToAddressee( c, addressee );
+ addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
+ addressBook()->insertAddressee( addressee );
+
+ } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
+ if ( ok )
+ mAccess->removeContact(c);
+ else
+ qDebug("Error revoe contact from qtopia ");
+ } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
+ if ( ok ) {
+ mAccess->updateContact(c);
+ KABC::Addressee addressee;
+ mConverter->qtopiaToAddressee( c, addressee );
+ addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
+ addressBook()->insertAddressee( addressee );
+ }
+ else
+ qDebug("Error update contact from qtopia ");
+
+ }
+
+ } else {
+ qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1());
+ }
+ }
}
- else
- {
- qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
- }
- }
-// mAccess->addressBookUpdated();
+ // mAccess->addressBookUpdated();
- mDirWatch.startScan();
+ mDirWatch.startScan();
- delete ticket;
- unlock( fileName() );
+ delete ticket;
+ unlock( fileName() );
- return true;
+ return true;
}
bool ResourceQtopia::lock( const QString &lockfileName )
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d6482fb..b3d88de 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2752,7 +2752,7 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
bool skipIncidence = false;
if ( uid.left(19) == QString("last-syncAddressee-") )
skipIncidence = true;
- QString idS;
+ QString idS,OidS;
qApp->processEvents();
if ( !skipIncidence ) {
inL = local->findByUid( uid );
@@ -2768,18 +2768,24 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
inL.setCsum( mCurrentSyncDevice, inR.getCsum(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 )
+ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
+ inR.setOriginalExternalUID( OidS );
+ inR.setExternalUID( idS );
+ } else {
inR.setIDStr( idS );
+ }
inR.setResource( 0 );
remote->insertAddressee( inR , false);
++changedRemote;
- } else {
+ } else { // take == 2 take remote
idS = inL.IDStr();
local->removeAddressee( inL );
inL = inR;
@@ -2854,7 +2860,7 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
inL.setRevision( modifiedCalendar );
local->insertAddressee( inL, false );
inR = inL;
- inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
+ inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
inR.setResource( 0 );
remote->insertAddressee( inR, false );
}
@@ -2919,47 +2925,76 @@ bool KABCore::syncAB(QString filename, int mode)
if ( abLocal.load() ) {
qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
bool external = false;
- Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
- if ( ! lse.isEmpty() ) {
- if ( lse.familyName().left(4) == "!E: " )
- external = true;
- } else {
- bool found = false;
- QDateTime dt( QDate( 2004,1,1));
- AddressBook::Iterator it;
- for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
- if ( (*it).revision() != dt ) {
- found = true;
- break;
- }
- }
- external = ! found;
- }
- if ( external ) {
- qDebug("Setting vcf mode to external ");
+ if ( filename.right(4) == ".xml") {
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
AddressBook::Iterator it;
for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
- (*it).setID( mCurrentSyncDevice, (*it).uid() );
+ (*it).setID( mCurrentSyncDevice, (*it).externalUID() );
(*it).computeCsum( mCurrentSyncDevice );
}
+ abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice );
+
+ } else {
+ Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
+ if ( ! lse.isEmpty() ) {
+ if ( lse.familyName().left(4) == "!E: " )
+ external = true;
+ } else {
+ bool found = false;
+ QDateTime dt( QDate( 2004,1,1));
+ AddressBook::Iterator it;
+ for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
+ if ( (*it).revision() != dt ) {
+ found = true;
+ break;
+ }
+ }
+ external = ! found;
+ }
+
+ if ( external ) {
+ qDebug("Setting vcf mode to external ");
+ mGlobalSyncMode = SYNC_MODE_EXTERNAL;
+ AddressBook::Iterator it;
+ for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
+ (*it).setID( mCurrentSyncDevice, (*it).uid() );
+ (*it).computeCsum( mCurrentSyncDevice );
+ }
+ }
}
//AddressBook::Iterator it;
//QStringList vcards;
//for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
// qDebug("Name %s ", (*it).familyName().latin1());
//}
- if ( filename.right(4) == ".xml")
- abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice );
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
if ( syncOK ) {
if ( KABPrefs::instance()->mWriteBackFile )
{
- if ( external )
+ if ( external && filename.right(4) != ".xml")
abLocal.removeDeletedAddressees();
qDebug("Saving remote AB ");
abLocal.saveAB();
+ if ( external && filename.right(4) == ".xml") {
+ // afterwrite processing
+ AddressBook::Iterator it;
+ for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
+ if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
+ (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
+ Addressee ad = mAddressBook->findByUid( ( (*it).uid() ));
+ if ( ad.isEmpty() ) {
+ qDebug("ERROR ad empty ");
+ } else {
+ (*it).computeCsum( mCurrentSyncDevice );
+ if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
+ ad.setID( mCurrentSyncDevice, (*it).externalUID() );
+ ad.setCsum( mCurrentSyncDevice, (*it).getCsum( mCurrentSyncDevice ) );
+ mAddressBook->insertAddressee( ad );
+ }
+ }
+ }
+ }
}
}
setModified();
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index e7fc670..d56eab6 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -546,9 +546,9 @@ bool SharpFormat::save( Calendar *calendar)
fileIn.close();
//command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName;
- qDebug("command ++++++++ ");
- qDebug("%s ",command.latin1());
- qDebug("command -------- ");
+ //qDebug("command ++++++++ ");
+ //qDebug("%s ",command.latin1());
+ //qDebug("command -------- ");
system ( command.utf8() );
QFile file( fileName );
if (!file.open( IO_ReadOnly ) ) {
diff --git a/libkcal/syncdefines.h b/libkcal/syncdefines.h
index 57642ec..704a670 100644
--- a/libkcal/syncdefines.h
+++ b/libkcal/syncdefines.h
@@ -14,9 +14,11 @@
#define SYNC_MODE_EXTERNAL 1
#define SYNC_TEMPSTATE_INITIAL 0
+#define SYNC_TEMPSTATE_ADDED_EXTERNAL -1
#define SYNC_TEMPSTATE_NEW_EXTERNAL -2
#define SYNC_TEMPSTATE_DELETE -3
#define SYNC_TEMPSTATE_NEW_ID -4
+#define SYNC_TEMPSTATE_NEW_CSUM -5
#endif