added workarounds for FBURL/CALURI and ADR without TYPE
git-svn-id: https://zeitsenke.de/svn/SyncEvolution/trunk@39 15ad00c4-1369-45f4-8270-35d70d36bdcd
This commit is contained in:
parent
1217824251
commit
4b6549c077
2 changed files with 53 additions and 0 deletions
|
@ -25,6 +25,8 @@ using namespace std;
|
|||
#include <common/vocl/VObject.h>
|
||||
#include <common/vocl/VConverter.h>
|
||||
|
||||
const EvolutionContactSource::extensions EvolutionContactSource::m_vcardExtensions;
|
||||
|
||||
EvolutionContactSource::EvolutionContactSource( const string &name,
|
||||
const string &changeId,
|
||||
const string &id,
|
||||
|
@ -268,6 +270,20 @@ SyncItem *EvolutionContactSource::createItem( const string &uid, SyncState state
|
|||
throwError( string( "parsing contact" ) + uid, NULL );
|
||||
}
|
||||
vobj->toNativeEncoding();
|
||||
|
||||
// escape extended properties so that they are preserved
|
||||
// as custom values by the server
|
||||
for (int index = vobj->propertiesCount() - 1;
|
||||
index >= 0;
|
||||
index--) {
|
||||
VProperty *vprop = vobj->getProperty(index);
|
||||
string name = vprop->getName();
|
||||
if (m_vcardExtensions.find(name) != m_vcardExtensions.end()) {
|
||||
name = m_vcardExtensions.prefix + name;
|
||||
vprop->setName(name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
vobj->setVersion("2.1");
|
||||
VProperty *vprop = vobj->getProperty("VERSION");
|
||||
vprop->setValue("2.1");
|
||||
|
@ -302,6 +318,26 @@ string EvolutionContactSource::preparseVCard(SyncItem& item)
|
|||
throwError( string( "parsing contact" ) + item.getKey(), NULL );
|
||||
}
|
||||
vobj->toNativeEncoding();
|
||||
|
||||
// convert our escaped properties back,
|
||||
// extend certain properties so that Evolution can parse them
|
||||
for (int index = vobj->propertiesCount() - 1;
|
||||
index >= 0;
|
||||
index--) {
|
||||
VProperty *vprop = vobj->getProperty(index);
|
||||
string name = vprop->getName();
|
||||
if (name.size() > m_vcardExtensions.prefix.size() &&
|
||||
!name.compare(0, m_vcardExtensions.prefix.size(), m_vcardExtensions.prefix)) {
|
||||
vprop->setName(name.c_str() + m_vcardExtensions.prefix.size());
|
||||
} else if (name == "ADR") {
|
||||
if (!vprop->parameterCount()) {
|
||||
// without a TYPE Evolution 2.0.4 does not parse the entry correctly
|
||||
vprop->addParameter("TYPE", "OTHER");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
vobj->setVersion("3.0");
|
||||
VProperty *vprop = vobj->getProperty("VERSION");
|
||||
vprop->setValue("3.0");
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include <libebook/e-book.h>
|
||||
#include <libebook/e-vcard.h>
|
||||
|
||||
#include <set>
|
||||
|
||||
/**
|
||||
* Implements access to Evolution address books.
|
||||
*/
|
||||
|
@ -79,6 +81,21 @@ class EvolutionContactSource : public EvolutionSyncSource
|
|||
/** the format of vcards that new items are expected to have */
|
||||
const EVCardFormat m_vcardFormat;
|
||||
|
||||
/**
|
||||
* a list of Evolution vcard properties which have to be encoded
|
||||
* as X-SYNCEVOLUTION-* when sending to server in 2.1 and decoded
|
||||
* back when receiving.
|
||||
*/
|
||||
static const class extensions : public set<string> {
|
||||
public:
|
||||
extensions() : prefix("X-SYNCEVOLUTION-") {
|
||||
this->insert("FBURL");
|
||||
this->insert("CALURI");
|
||||
}
|
||||
|
||||
const string prefix;
|
||||
} m_vcardExtensions;
|
||||
|
||||
/** the mime type which corresponds to m_vcardFormat */
|
||||
const char *getMimeType();
|
||||
|
||||
|
|
Loading…
Reference in a new issue