summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show 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.cpp42
-rw-r--r--kaddressbook/kabcore.cpp49
-rw-r--r--libkcal/sharpformat.cpp6
-rw-r--r--libkcal/syncdefines.h2
9 files changed, 104 insertions, 20 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"
@@ -197,19 +199,41 @@ bool ResourceQtopia::save( Ticket *ticket )
bool res;
for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
- PimContact c;
- KABC::Addressee addressee = (*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 (res == true) {
+ if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
mAccess->addContact(c);
-// if (res == false)
-// qDebug("Unable to append Contact %s", c.fullName().latin1());
+ 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("Unable to convert Addressee %s", addressee.formattedName().latin1());
+ qDebug("Error update contact from qtopia ");
+
+ }
+
+ } else {
+ qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1());
+ }
}
}
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,6 +2925,17 @@ bool KABCore::syncAB(QString filename, int mode)
if ( abLocal.load() ) {
qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
bool external = false;
+
+ if ( filename.right(4) == ".xml") {
+ mGlobalSyncMode = SYNC_MODE_EXTERNAL;
+ AddressBook::Iterator it;
+ for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
+ (*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: " )
@@ -2945,21 +2962,39 @@ bool KABCore::syncAB(QString filename, int mode)
(*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