From b7f072d00cd9e43aea331c95ef26a5bf28e6c9b8 Mon Sep 17 00:00:00 2001 From: Nicolas VIVIEN Date: Mon, 30 Mar 2009 10:25:41 +0200 Subject: [PATCH] Near perfect... - Fix a little bug in the decoded vcard photo. - Catch the errors to avoid a "slow-sync" --- opensync-plugin-0.4x/src/vcard.cc | 32 +++++++++++++++++++------------- opensync-plugin-0.4x/src/vevent.cc | 22 ++++++++++++++-------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/opensync-plugin-0.4x/src/vcard.cc b/opensync-plugin-0.4x/src/vcard.cc index 3632c71a..604137d4 100644 --- a/opensync-plugin-0.4x/src/vcard.cc +++ b/opensync-plugin-0.4x/src/vcard.cc @@ -421,18 +421,18 @@ const Barry::Contact& vCard::ToBarry(const char *vcard, uint32_t RecordId) vAttr photo = GetAttrObj("PHOTO"); if (photo.Get()) { std::string sencoding = photo.GetAllParams("ENCODING"); - + ToLower(sencoding); const char *encoding = sencoding.c_str(); - if (!strstr(encoding, "b")) { - photo.Get()->encoding = VF_ENCODING_BASE64; + if (strstr(encoding, "quoted-printable")) { + photo.Get()->encoding = VF_ENCODING_QP; con.Image = photo.GetDecodedValue(); } - else if (!strstr(encoding, "quoted-printable")) { - photo.Get()->encoding = VF_ENCODING_QP; + else if (strstr(encoding, "b")) { + photo.Get()->encoding = VF_ENCODING_BASE64; con.Image = photo.GetDecodedValue(); } @@ -606,15 +606,21 @@ bool VCardConverter::CommitRecordData(BarryEnvironment *env, unsigned int dbId, Barry::RecordBuilder builder(convert); - if( add ) { - trace.log("adding record"); - env->m_pDesktop->AddRecord(dbId, builder); + try { + if( add ) { + trace.log("adding record"); + env->m_pDesktop->AddRecord(dbId, builder); + } + else { + trace.log("setting record"); + env->m_pDesktop->SetRecord(dbId, StateIndex, builder); + trace.log("clearing dirty flag"); + env->m_pDesktop->ClearDirty(dbId, StateIndex); + } } - else { - trace.log("setting record"); - env->m_pDesktop->SetRecord(dbId, StateIndex, builder); - trace.log("clearing dirty flag"); - env->m_pDesktop->ClearDirty(dbId, StateIndex); + catch (Barry::Error &e ) { + trace.logf("ERROR: VCardConverter::CommitRecordData - Format error"); + return false; } return true; diff --git a/opensync-plugin-0.4x/src/vevent.cc b/opensync-plugin-0.4x/src/vevent.cc index fffccc88..3ec225d5 100644 --- a/opensync-plugin-0.4x/src/vevent.cc +++ b/opensync-plugin-0.4x/src/vevent.cc @@ -565,15 +565,21 @@ bool VEventConverter::CommitRecordData(BarryEnvironment *env, unsigned int dbId, Barry::RecordBuilder builder(convert); - if( add ) { - trace.log("adding record"); - env->m_pDesktop->AddRecord(dbId, builder); + try { + if( add ) { + trace.log("adding record"); + env->m_pDesktop->AddRecord(dbId, builder); + } + else { + trace.log("setting record"); + env->m_pDesktop->SetRecord(dbId, StateIndex, builder); + trace.log("clearing dirty flag"); + env->m_pDesktop->ClearDirty(dbId, StateIndex); + } } - else { - trace.log("setting record"); - env->m_pDesktop->SetRecord(dbId, StateIndex, builder); - trace.log("clearing dirty flag"); - env->m_pDesktop->ClearDirty(dbId, StateIndex); + catch (Barry::Error &e ) { + trace.logf("ERROR: VEventConverter::CommitRecordData - Format error"); + return false; } return true; -- 2.11.4.GIT