when configured to use ScheduleWorld card3 URI, then switch to sending vCard 3.0 (easier to parse by SW); always dump contacts as vCard 3.0 (avoids quoted-printable in synccompare output)
git-svn-id: https://zeitsenke.de/svn/SyncEvolution/trunk@445 15ad00c4-1369-45f4-8270-35d70d36bdcd
This commit is contained in:
parent
16be53a279
commit
8ed1710889
|
@ -231,9 +231,9 @@ public:
|
|||
if (!ABRecordRemoveValue(m_person, *m_multiProp[multi])) {
|
||||
throwError(string("removing old value ")
|
||||
#ifndef IPHONE
|
||||
+ CFString2Std(*m_multiProp[multi]) + " " +
|
||||
+ CFString2Std(*m_multiProp[multi]) + " "
|
||||
#endif
|
||||
"failed");
|
||||
+ "failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,8 +275,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/** convert person into vCard 2.1 and store it in string */
|
||||
void fromPerson() {
|
||||
/** convert person into vCard 2.1 or 3.0 and store it in string */
|
||||
void fromPerson(bool asVCard30) {
|
||||
string tmp;
|
||||
const unsigned char *text;
|
||||
|
||||
|
@ -288,8 +288,8 @@ public:
|
|||
// m_vobj = VObject();
|
||||
|
||||
m_vobj.addProperty("BEGIN", "VCARD");
|
||||
m_vobj.addProperty("VERSION", "2.1");
|
||||
m_vobj.setVersion("2.1");
|
||||
m_vobj.addProperty("VERSION", asVCard30 ? "3.0" : "2.1");
|
||||
m_vobj.setVersion(asVCard30 ? "3.0" : "2.1");
|
||||
|
||||
// iterate over all person properties and handle them
|
||||
for (int mapindex = 0;
|
||||
|
@ -342,7 +342,7 @@ public:
|
|||
StringBuffer encoded;
|
||||
b64_encode(encoded, (void *)CFDataGetBytePtr(photo), CFDataGetLength(photo));
|
||||
VProperty vprop("PHOTO");
|
||||
vprop.addParameter("ENCODING", "B");
|
||||
vprop.addParameter("ENCODING", asVCard30 ? "B" : "BASE64");
|
||||
vprop.setValue(encoded.c_str());
|
||||
m_vobj.addProperty(&vprop);
|
||||
}
|
||||
|
@ -1165,9 +1165,18 @@ AddressBookSource::AddressBookSource(const string &name,
|
|||
const string &changeId,
|
||||
const string &id,
|
||||
const string &configPath) :
|
||||
EvolutionSyncSource(name, sc, changeId, id)
|
||||
EvolutionSyncSource(name, sc, changeId, id),
|
||||
m_asVCard30(false)
|
||||
{
|
||||
m_modNodeName = configPath + "/changes_" + changeId;
|
||||
|
||||
// hack: when configured to talk with ScheduleWorld "card3" URI then
|
||||
// switch to sending vCard 3.0. A better solution would be to wait for
|
||||
// server SyncCap information, but this is not currently possible (not sent
|
||||
// by SW, not made available to Sync Source (?)).
|
||||
if (sc && sc->getURI() && !strcasecmp(sc->getURI(), "card3")) {
|
||||
setVCard30(true);
|
||||
}
|
||||
}
|
||||
|
||||
AddressBookSource::AddressBookSource(const AddressBookSource &other) :
|
||||
|
@ -1286,13 +1295,13 @@ void AddressBookSource::exportData(ostream &out)
|
|||
CFStringRef descr = CFCopyDescription(person);
|
||||
ref<CFStringRef> cfuid(ABRecordCopyUniqueId(person), "reading UID");
|
||||
string uid(CFString2Std(cfuid));
|
||||
eptr<SyncItem> item(createItem(uid, SYNC_STATE_NONE), "sync item");
|
||||
eptr<SyncItem> item(createItem(uid, SYNC_STATE_NONE, true), "sync item");
|
||||
|
||||
out << (char *)item->getData() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
SyncItem *AddressBookSource::createItem( const string &uid, SyncState state )
|
||||
SyncItem *AddressBookSource::createItem(const string &uid, SyncState state, bool asVCard30)
|
||||
{
|
||||
logItem(uid, "extracting from address book", true);
|
||||
|
||||
|
@ -1308,7 +1317,7 @@ SyncItem *AddressBookSource::createItem( const string &uid, SyncState state )
|
|||
string vcard;
|
||||
try {
|
||||
vCard2ABPerson conv(vcard, person);
|
||||
conv.fromPerson();
|
||||
conv.fromPerson(asVCard30);
|
||||
} catch (const std::exception &ex) {
|
||||
throwError("creating vCard for " + uid + " failed: " + ex.what());
|
||||
}
|
||||
|
|
|
@ -175,6 +175,9 @@ class AddressBookSource : public EvolutionSyncSource
|
|||
AddressBookSource(const AddressBookSource &other);
|
||||
virtual ~AddressBookSource() { close(); }
|
||||
|
||||
void setVCard30(bool asVCard30) { m_asVCard30 = asVCard30; }
|
||||
bool getVCard30() { return m_asVCard30; }
|
||||
|
||||
|
||||
//
|
||||
// implementation of EvolutionSyncSource
|
||||
|
@ -184,11 +187,12 @@ class AddressBookSource : public EvolutionSyncSource
|
|||
virtual void close();
|
||||
virtual void exportData(ostream &out);
|
||||
virtual string fileSuffix() { return "vcf"; }
|
||||
virtual const char *getMimeType() { return "text/x-vcard"; }
|
||||
virtual const char *getMimeVersion() { return "2.1"; }
|
||||
virtual const char *getSupportedTypes() { return "text/x-vcard:2.1"; }
|
||||
virtual const char *getMimeType() { return m_asVCard30 ? "text/vcard" : "text/x-vcard"; }
|
||||
virtual const char *getMimeVersion() { return m_asVCard30 ? "3.0" : "2.1"; }
|
||||
virtual const char *getSupportedTypes() { return m_asVCard30 ? "text/vcard:3.0" : "text/x-vcard:2.1"; }
|
||||
|
||||
virtual SyncItem *createItem( const string &uid, SyncState state );
|
||||
virtual SyncItem *createItem(const string &uid, SyncState state) { return createItem(uid, state, m_asVCard30); }
|
||||
virtual SyncItem *createItem(const string &uid, SyncState state, bool asVCard30);
|
||||
|
||||
//
|
||||
// implementation of SyncSource
|
||||
|
@ -232,6 +236,9 @@ class AddressBookSource : public EvolutionSyncSource
|
|||
|
||||
/** returns absolute modification time or (if that doesn't exist) the creation time */
|
||||
double getModTime(ABRecordRef record);
|
||||
|
||||
/** unless selected otherwise send items as vCard 2.1 */
|
||||
bool m_asVCard30;
|
||||
};
|
||||
|
||||
#endif // ENABLE_EBOOK
|
||||
|
|
|
@ -44,18 +44,18 @@ VObject::~VObject() {
|
|||
}
|
||||
}
|
||||
|
||||
void VObject::set(wchar_t** p, wchar_t* v) {
|
||||
void VObject::set(wchar_t** p, const wchar_t* v) {
|
||||
if (*p) {
|
||||
delete [] *p;
|
||||
}
|
||||
*p = (v) ? wstrdup(v) : NULL;
|
||||
}
|
||||
|
||||
void VObject::setVersion(wchar_t* ver) {
|
||||
void VObject::setVersion(const wchar_t* ver) {
|
||||
set(&version, ver);
|
||||
}
|
||||
|
||||
void VObject::setProdID(wchar_t* prodID) {
|
||||
void VObject::setProdID(const wchar_t* prodID) {
|
||||
set(&productID, prodID);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,14 +12,14 @@ private:
|
|||
char* version;
|
||||
char* productID;
|
||||
ArrayList* properties;
|
||||
void set(char**, char*);
|
||||
void set(char**, const char*);
|
||||
|
||||
public:
|
||||
|
||||
VObject();
|
||||
~VObject();
|
||||
void setVersion (char* ver);
|
||||
void setProdID (char* prodID);
|
||||
void setVersion (const char* ver);
|
||||
void setProdID (const char* prodID);
|
||||
char* getVersion();
|
||||
char* getProdID();
|
||||
void addProperty(VProperty* property);
|
||||
|
|
Loading…
Reference in New Issue