summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorniko <niko>2012-10-17 20:03:26 (GMT)
committerniko <niko>2012-10-17 20:03:26 (GMT)
commitb7eb7d9eb8ce505cf40b7539650ff82e6565bd87 (patch)
treeda0499b19b7955a2011a9a73371cfcdd88dd3876
parenta1fe7cf420e90204a8a8303775b71fcb228ff797 (diff)
downloadsynckolab-b7eb7d9eb8ce505cf40b7539650ff82e6565bd87.tar.gz
fix ordering of elements
-rw-r--r--src/chrome/content/synckolab/addressbookTools.js126
-rw-r--r--test/synckolab/parser/kolab3/xml/contact.complex.mime.xml65
-rw-r--r--test/synckolab/parser/kolab3/xml/contact.simple.mime.xml9
-rw-r--r--test/synckolab/parser/kolab3/xml/contact.test.mime.xml11
-rw-r--r--test/synckolab/parser/kolab3/xml/contact.test2.mime.xml5
5 files changed, 118 insertions, 98 deletions
diff --git a/src/chrome/content/synckolab/addressbookTools.js b/src/chrome/content/synckolab/addressbookTools.js
index 0128173..979288f 100644
--- a/src/chrome/content/synckolab/addressbookTools.js
+++ b/src/chrome/content/synckolab/addressbookTools.js
@@ -1556,6 +1556,7 @@ synckolab.addressbookTools.card2Kolab3 = function (card, skipHeader, fields) {
xml += "<vcard>\n";
xml += " <uid><uri>" + synckolab.tools.text.encode4XML(this.getUID(card)) + "</uri></uid>\n";
+ xml += " <x-kolab-version><text>3.0dev1</text></x-kolab-version>\n";
xml += " <prodid><text>SyncKolab " + synckolab.config.version + ", Kolab resource</text></prodid>\n";
xml += " <rev><timestamp>" + synckolab.tools.text.calDateTime2String(new Date(this.getCardProperty(card, "LastModifiedDate")*1000), false, true) + "Z</timestamp></rev>\n";
xml += " <kind><text>individual</text></kind>\n";
@@ -1564,34 +1565,68 @@ synckolab.addressbookTools.card2Kolab3 = function (card, skipHeader, fields) {
//xml += synckolab.tools.text.nodeWithContent("categories", this.getCardProperty(card, "Category"), false);
//xml += " <sensitivity>public</sensitivity>\n";
- xml += this.getXmlProperty(card, "Notes", "note", "text");
-
if (this.haveCardProperty(card, "FirstName") || this.haveCardProperty(card, "LastName") || this.haveCardProperty(card, "DisplayName") || this.haveCardProperty(card, "NickName")) {
- xml += " <n>\n";
- xml += this.getXmlProperty(card, "FirstName", "given");
- xml += this.getXmlProperty(card, "LastName", "surname");
- xml += " </n>\n";
-
+ // first fn
if (this.haveCardProperty(card, "DisplayName")) {
xml += synckolab.tools.text.nodeContainerWithContent("fn", "text", this.getCardProperty(card, "DisplayName"));
} else if (this.haveCardProperty(card, "FirstName") || this.haveCardProperty(card, "LastName")) {
displayName = this.getCardProperty(card, "FirstName") + " " + this.getCardProperty(card, "LastName");
xml += synckolab.tools.text.nodeContainerWithContent("fn", "text", displayName);
}
-
+
+ // then name
+ xml += " <n>\n";
+ xml += this.getXmlProperty(card, "LastName", "surname");
+ xml += this.getXmlProperty(card, "FirstName", "given");
+ /* also available in kolab3:
+ <additional/>
+ <prefix/>
+ <suffix/>
+ */
+ xml += " </n>\n";
+
}
- xml += synckolab.tools.text.nodeWithContent("organization", this.getCardProperty(card, "Company"), false);
+
+ xml += this.getXmlProperty(card, "Notes", "note", "text");
+ xml += this.getXmlProperty(card, "JobTitle", "title", "text");
xml += this.getXmlProperty(card, "WebPage1", "url", "uri");
xml += this.getXmlProperty(card, "WebPage2", "url", "uri");
- xml += this.getXmlProperty(card, "AimScreenName", "impp", "uri");
+
//xml += synckolab.tools.text.nodeWithContent("department", this.getCardProperty(card, "Department"), false);
//" <office-location>zuhaus</office-location>\n";
//" <profession>programmierer</profession>\n";
- xml += this.getXmlProperty(card, "JobTitle", "title", "text");
- xml += this.getXmlProperty(card, "NickName", "nickname", "text");
+ xml += synckolab.tools.text.nodeWithContent("organization", this.getCardProperty(card, "Company"), false);
+
+
+ if (this.haveCardProperty(card, "HomeAddress") || this.haveCardProperty(card, "HomeAddress2") || this.haveCardProperty(card, "HomeCity") || this.haveCardProperty(card, "HomeState") || this.haveCardProperty(card, "HomeZipCode") || this.haveCardProperty(card, "HomeCountry")) {
+ xml += " <adr>\n";
+ xml += " <parameters><type><text>home</text></type></parameters>\n";
+ xml += this.getXmlProperty(card, "HomeAddress", "street");
+ xml += this.getXmlProperty(card, "HomeAddress2", "street2");
+ xml += this.getXmlProperty(card, "HomeCity", "locality");
+ xml += this.getXmlProperty(card, "HomeState", "region");
+ xml += this.getXmlProperty(card, "HomeZipCode", "code");
+ xml += this.getXmlProperty(card, "HomeCountry", "country");
+ xml += " </adr>\n";
+ }
+
+ if (this.haveCardProperty(card, "WorkAddress") || this.haveCardProperty(card, "WorkAddress2") || this.haveCardProperty(card, "WorkCity") || this.haveCardProperty(card, "WorkState") || this.haveCardProperty(card, "WorkZipCode") || this.haveCardProperty(card, "WorkCountry")) {
+ xml += " <adr>\n";
+ xml += " <parameters><type><text>work</text></type></parameters>\n";
+ xml += this.getXmlProperty(card, "WorkAddress", "street");
+ xml += this.getXmlProperty(card, "WorkAddress2", "street2");
+ xml += this.getXmlProperty(card, "WorkCity", "locality");
+ xml += this.getXmlProperty(card, "WorkState", "region");
+ xml += this.getXmlProperty(card, "WorkZipCode", "code");
+ xml += this.getXmlProperty(card, "WorkCountry", "country");
+ xml += " </adr>\n";
+ }
+
+ xml += this.getXmlProperty(card, "NickName", "nickname", "text");
+
var adate;
if (this.haveCardProperty(card, "BirthYear") && this.haveCardProperty(card, "BirthMonth") && this.haveCardProperty(card, "BirthDay")) {
adate = this.getCardProperty(card, "BirthYear") + this.getCardProperty(card, "BirthMonth") + this.getCardProperty(card, "BirthDay");
@@ -1602,7 +1637,27 @@ synckolab.addressbookTools.card2Kolab3 = function (card, skipHeader, fields) {
adate = this.getCardProperty(card, "AnniversaryYear") + "-" + this.getCardProperty(card, "AnniversaryMonth") + "-" + this.getCardProperty(card, "AnniversaryDay");
xml += " <anniversary>" + synckolab.tools.text.nodeWithContent("date-time", adate, false) + "</anniversary>\n";
}
+
+ // TODO photo name = photo - base64-Encoded
+ /*
+ xml += synckolab.tools.text.nodeWithContent("picture", this.getCardProperty(card, "PhotoName"), false);
+
+ // we can probably ignore that
+ var ptype = this.getCardProperty(card, "PhotoType");
+ if (ptype === "web" || ptype === "file") {
+ * kolab:
+ * 1. read the file: FILENAME = this.getCardProperty(card, "PhotoName")
+ * found in ~profil/Photos/FILENAME
+ * 2. create an attachment name FILENAME with the content (base64 encoded)
+ *
+ xml += synckolab.tools.text.nodeWithContent("picture-uri", this.getCardProperty(card, "PhotoURI"), false); // we can distinguish between file: and http: anyways
+ }
+ */
+ xml += this.getXmlProperty(card, "AimScreenName", "impp", "uri");
+
+ //xml += synckolab.tools.text.nodeWithContent("preferred-address", this.getCardProperty(card, "DefaultAddress"), false); @deprecated
+ // phone
if (this.haveCardProperty(card, "HomePhone")) {
xml += " <tel>\n";
xml += " <parameters><type><text>home</text></type></parameters>\n";
@@ -1633,7 +1688,7 @@ synckolab.addressbookTools.card2Kolab3 = function (card, skipHeader, fields) {
xml += " <text>" + this.getCardProperty(card, "PagerNumber") + "</text>\n";
xml += " </tel>\n";
}
-
+ // email
if (this.haveCardProperty(card, "PrimaryEmail")) {
xml += " <email>\n";
xml += " <parameters><pref><integer>1</integer></pref></parameters>\n";
@@ -1648,7 +1703,8 @@ synckolab.addressbookTools.card2Kolab3 = function (card, skipHeader, fields) {
xml += " <text>" + synckolab.tools.text.encode4XML(this.getCardProperty(card, "SecondEmail")) + "</text>\n";
xml += " </email>\n";
}
-
+ // custom fields are last
+
// if the mail format is set...
if (this.getCardProperty(card, "PreferMailFormat") && this.getCardProperty(card, "PreferMailFormat") !== synckolab.addressbookTools.MAIL_FORMAT_UNKNOWN) {
if (Number(this.getCardProperty(card, "PreferMailFormat")) === this.MAIL_FORMAT_PLAINTEXT) {
@@ -1657,48 +1713,6 @@ synckolab.addressbookTools.card2Kolab3 = function (card, skipHeader, fields) {
xml += "<x-custom><identifier>X-PreferMailFormat</identifier><value>html</value></x-custom>\n";
}
}
-
- if (this.haveCardProperty(card, "HomeAddress") || this.haveCardProperty(card, "HomeAddress2") || this.haveCardProperty(card, "HomeCity") || this.haveCardProperty(card, "HomeState") || this.haveCardProperty(card, "HomeZipCode") || this.haveCardProperty(card, "HomeCountry")) {
- xml += " <adr>\n";
- xml += " <parameters><type><text>home</text></type></parameters>\n";
- xml += this.getXmlProperty(card, "HomeAddress", "street");
- xml += this.getXmlProperty(card, "HomeAddress2", "street2");
- xml += this.getXmlProperty(card, "HomeCity", "locality");
- xml += this.getXmlProperty(card, "HomeState", "region");
- xml += this.getXmlProperty(card, "HomeZipCode", "code");
- xml += this.getXmlProperty(card, "HomeCountry", "country");
- xml += " </adr>\n";
- }
-
- if (this.haveCardProperty(card, "WorkAddress") || this.haveCardProperty(card, "WorkAddress2") || this.haveCardProperty(card, "WorkCity") || this.haveCardProperty(card, "WorkState") || this.haveCardProperty(card, "WorkZipCode") || this.haveCardProperty(card, "WorkCountry")) {
- xml += " <adr>\n";
- xml += " <parameters><type><text>work</text></type></parameters>\n";
- xml += this.getXmlProperty(card, "WorkAddress", "street");
- xml += this.getXmlProperty(card, "WorkAddress2", "street2");
- xml += this.getXmlProperty(card, "WorkCity", "locality");
- xml += this.getXmlProperty(card, "WorkState", "region");
- xml += this.getXmlProperty(card, "WorkZipCode", "code");
- xml += this.getXmlProperty(card, "WorkCountry", "country");
- xml += " </adr>\n";
- }
-
- // TODO photo name = photo - base64-Encoded
- /*
- xml += synckolab.tools.text.nodeWithContent("picture", this.getCardProperty(card, "PhotoName"), false);
-
- // we can probably ignore that
- var ptype = this.getCardProperty(card, "PhotoType");
- if (ptype === "web" || ptype === "file") {
- * kolab:
- * 1. read the file: FILENAME = this.getCardProperty(card, "PhotoName")
- * found in ~profil/Photos/FILENAME
- * 2. create an attachment name FILENAME with the content (base64 encoded)
- *
- xml += synckolab.tools.text.nodeWithContent("picture-uri", this.getCardProperty(card, "PhotoURI"), false); // we can distinguish between file: and http: anyways
- }
- */
-
- //xml += synckolab.tools.text.nodeWithContent("preferred-address", this.getCardProperty(card, "DefaultAddress"), false); @deprecated
if (this.getCardProperty(card, "Custom1")) {
xml += " <x-custom><identifier>X-Custom1</identifier><value>"+this.getCardProperty(card, "Custom1")+"</value></x-custom>\n";
diff --git a/test/synckolab/parser/kolab3/xml/contact.complex.mime.xml b/test/synckolab/parser/kolab3/xml/contact.complex.mime.xml
index d621e31..a03f02b 100644
--- a/test/synckolab/parser/kolab3/xml/contact.complex.mime.xml
+++ b/test/synckolab/parser/kolab3/xml/contact.complex.mime.xml
@@ -2,38 +2,54 @@
<vcards xmlns="urn:ietf:params:xml:ns:vcard-4.0">
<vcard>
<uid><uri>urn:uuid:Huu5X7hfYy</uri></uid>
+ <x-kolab-version><text>3.0dev1</text></x-kolab-version>
<prodid><text>SyncKolab 3.0.0, Kolab resource</text></prodid>
<rev><timestamp>19700101T000000ZZ</timestamp></rev>
<kind>
<text>individual</text>
</kind>
- <note>
- <text>Notes</text>
- </note>
+ <fn><text>Displayname</text></fn>
<n>
- <given>Lastname</given>
<surname>Firstname</surname>
+ <given>Lastname</given>
</n>
- <fn><text>Displayname</text></fn>
+ <note>
+ <text>Notes</text>
+ </note>
+ <title>
+ <text>Title</text>
+ </title>
<url>
<uri>www.homepage.org</uri>
</url>
<url>
<uri>www.blog.test</uri>
</url>
- <impp>
- <uri>messaging</uri>
- </impp>
- <title>
- <text>Title</text>
- </title>
+ <adr>
+ <parameters><type><text>home</text></type></parameters>
+ <street>Home Street</street>
+ <locality>Home Locality</locality>
+ <region>Home Region</region>
+ <code>Home Postal Code</code>
+ <country>Gabon</country>
+ </adr>
+ <adr>
+ <parameters><type><text>work</text></type></parameters>
+ <street>Work Street</street>
+ <locality>Work Locality</locality>
+ <region>Work Region</region>
+ <code>Work Postal Code</code>
+ <country>Azerbaijan</country>
+ </adr>
<nickname>
<text>Nickname</text>
</nickname>
- <bday> <date-time>2043</date-time>
-</bday>
- <anniversary> <date-time>2009-7-28</date-time>
-</anniversary>
+ <bday>
+ <date-time>2043</date-time>
+ </bday>
+ <anniversary>
+ <date-time>2009-7-28</date-time>
+ </anniversary>
<tel>
<parameters><type><text>home</text></type></parameters>
<text>+4930-homephone</text>
@@ -50,6 +66,9 @@
<parameters><type><text>cell</text></type></parameters>
<text>+4930-mobile</text>
</tel>
+ <impp>
+ <uri>messaging</uri>
+ </impp>
<email>
<parameters><pref><integer>1</integer></pref></parameters>
<text>first@email.org</text>
@@ -57,22 +76,6 @@
<email>
<text>second@email.org</text>
</email>
- <adr>
- <parameters><type><text>home</text></type></parameters>
- <street>Home Street</street>
- <locality>Home Locality</locality>
- <region>Home Region</region>
- <code>Home Postal Code</code>
- <country>Gabon</country>
- </adr>
- <adr>
- <parameters><type><text>work</text></type></parameters>
- <street>Work Street</street>
- <locality>Work Locality</locality>
- <region>Work Region</region>
- <code>Work Postal Code</code>
- <country>Azerbaijan</country>
- </adr>
<x-custom><identifier>X-AllowRemoteContent</identifier><value>true</value></x-custom>
</vcard>
</vcards> \ No newline at end of file
diff --git a/test/synckolab/parser/kolab3/xml/contact.simple.mime.xml b/test/synckolab/parser/kolab3/xml/contact.simple.mime.xml
index 232951c..36fe656 100644
--- a/test/synckolab/parser/kolab3/xml/contact.simple.mime.xml
+++ b/test/synckolab/parser/kolab3/xml/contact.simple.mime.xml
@@ -2,16 +2,17 @@
<vcards xmlns="urn:ietf:params:xml:ns:vcard-4.0">
<vcard>
<uid><uri>urn:uuid:4xuyC0cyjV</uri></uid>
+ <x-kolab-version><text>3.0dev1</text></x-kolab-version>
<prodid><text>SyncKolab 3.0.0, Kolab resource</text></prodid>
<rev><timestamp>19700101T000000ZZ</timestamp></rev>
- <kind>
+ <kind>
<text>individual</text>
- </kind>
+ </kind>
+ <fn><text>Volker Krause</text></fn>
<n>
- <given>Krause</given>
<surname>Volker</surname>
+ <given>Krause</given>
</n>
- <fn><text>Volker Krause</text></fn>
<email>
<parameters><pref><integer>1</integer></pref></parameters>
<text>vkrause@kde.org</text>
diff --git a/test/synckolab/parser/kolab3/xml/contact.test.mime.xml b/test/synckolab/parser/kolab3/xml/contact.test.mime.xml
index 45269a7..9c5370d 100644
--- a/test/synckolab/parser/kolab3/xml/contact.test.mime.xml
+++ b/test/synckolab/parser/kolab3/xml/contact.test.mime.xml
@@ -2,21 +2,22 @@
<vcards xmlns="urn:ietf:params:xml:ns:vcard-4.0">
<vcard>
<uid><uri>urn:uuid:e79e08cc-0f02-11e2-9e3c-000476ed9009</uri></uid>
+ <x-kolab-version><text>3.0dev1</text></x-kolab-version>
<prodid><text>SyncKolab 3.0.0, Kolab resource</text></prodid>
<rev><timestamp>19700101T000000ZZ</timestamp></rev>
<kind>
<text>individual</text>
</kind>
+ <fn><text>firstname lastname</text></fn>
+ <n>
+ <surname>firstname</surname>
+ <given>lastname</given>
+ </n>
<note>
<text>multi line
notes
with empty</text>
</note>
- <n>
- <given>lastname</given>
- <surname>firstname</surname>
- </n>
- <fn><text>firstname lastname</text></fn>
<bday> <date-time>2042</date-time>
</bday>
<tel>
diff --git a/test/synckolab/parser/kolab3/xml/contact.test2.mime.xml b/test/synckolab/parser/kolab3/xml/contact.test2.mime.xml
index 0831cb8..5a92b9b 100644
--- a/test/synckolab/parser/kolab3/xml/contact.test2.mime.xml
+++ b/test/synckolab/parser/kolab3/xml/contact.test2.mime.xml
@@ -2,16 +2,17 @@
<vcards xmlns="urn:ietf:params:xml:ns:vcard-4.0">
<vcard>
<uid><uri>urn: uuid:ebf6fdc2-1149-11e2-841b-000476ed9009</uri></uid>
+ <x-kolab-version><text>3.0dev1</text></x-kolab-version>
<prodid><text>SyncKolab 3.0.0, Kolab resource</text></prodid>
<rev><timestamp>19700101T000000ZZ</timestamp></rev>
<kind>
<text>individual</text>
</kind>
+ <fn><text>Hans Wurst</text></fn>
<n>
- <given>Wurst</given>
<surname>Hans</surname>
+ <given>Wurst</given>
</n>
- <fn><text>Hans Wurst</text></fn>
<tel>
<parameters><type><text>home</text></type></parameters>
<text>+49123456789</text>