[Pkg-mozext-commits] [gcontactsync] 25/88: Issues 9 and 11. Fixed a bug where contacts without e-mail addresses were given types for untyped properties, this requires a one-time update of all affected contacts. Added support for two line street addresses. Updated version to 0.4.0rc

David Prévot taffit at moszumanska.debian.org
Thu Sep 18 20:52:26 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository gcontactsync.

commit 5b4bd66390094fe44fa324629593b31a64c380eb
Author: Josh Geenen <joshgeenen at gmail.com>
Date:   Sun Jan 5 20:39:44 2014 -0600

    Issues 9 and 11. Fixed a bug where contacts without e-mail addresses were given types for untyped properties, this requires a one-time update of all affected contacts.  Added support for two line street addresses.  Updated version to 0.4.0rc
---
 src/content/ContactConverter.js          | 29 ++++++-----
 src/content/MessengerOverlay.js          |  7 ++-
 src/content/Preferences.js               |  3 +-
 src/content/Sync.js                      |  5 +-
 src/content/TBContact.js                 | 36 ++++++++------
 src/content/synonyms.js                  | 84 +++++++++++++++++++-------------
 src/defaults/preferences/gContactSync.js |  4 +-
 src/install.rdf                          |  2 +-
 8 files changed, 99 insertions(+), 71 deletions(-)

diff --git a/src/content/ContactConverter.js b/src/content/ContactConverter.js
index 68f9a52..01fe791 100644
--- a/src/content/ContactConverter.js
+++ b/src/content/ContactConverter.js
@@ -15,7 +15,7 @@
  *
  * The Initial Developer of the Original Code is
  * Josh Geenen <gcontactsync at pirules.org>.
- * Portions created by the Initial Developer are Copyright (C) 2008-2010
+ * Portions created by the Initial Developer are Copyright (C) 2008-2014
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
@@ -145,17 +145,17 @@ com.gContactSync.ContactConverter = {
     // changed to true
     if (com.gContactSync.Preferences.mSyncPrefs.syncAddresses.value) {
       // Home address
-      this.mConverterArr.push(new com.gContactSync.ConverterElement("street",   "HomeAddress", 0, "home"));
-      this.mConverterArr.push(new com.gContactSync.ConverterElement("city",     "HomeCity",    0, "home"));
-      this.mConverterArr.push(new com.gContactSync.ConverterElement("region",   "HomeState",   0, "home"));
-      this.mConverterArr.push(new com.gContactSync.ConverterElement("postcode", "HomeZipCode", 0, "home"));
-      this.mConverterArr.push(new com.gContactSync.ConverterElement("country",  "HomeCountry", 0, "home"));
+      this.mConverterArr.push(new com.gContactSync.ConverterElement("street",   "HomeAddressMult", 0, "home"));
+      this.mConverterArr.push(new com.gContactSync.ConverterElement("city",     "HomeCity",        0, "home"));
+      this.mConverterArr.push(new com.gContactSync.ConverterElement("region",   "HomeState",       0, "home"));
+      this.mConverterArr.push(new com.gContactSync.ConverterElement("postcode", "HomeZipCode",     0, "home"));
+      this.mConverterArr.push(new com.gContactSync.ConverterElement("country",  "HomeCountry",     0, "home"));
       // Work address
-      this.mConverterArr.push(new com.gContactSync.ConverterElement("street",   "WorkAddress", 0, "work"));
-      this.mConverterArr.push(new com.gContactSync.ConverterElement("city",     "WorkCity",    0, "work"));
-      this.mConverterArr.push(new com.gContactSync.ConverterElement("region",   "WorkState",   0, "work"));
-      this.mConverterArr.push(new com.gContactSync.ConverterElement("postcode", "WorkZipCode", 0, "work"));
-      this.mConverterArr.push(new com.gContactSync.ConverterElement("country",  "WorkCountry", 0, "work"));
+      this.mConverterArr.push(new com.gContactSync.ConverterElement("street",   "WorkAddressMult", 0, "work"));
+      this.mConverterArr.push(new com.gContactSync.ConverterElement("city",     "WorkCity",        0, "work"));
+      this.mConverterArr.push(new com.gContactSync.ConverterElement("region",   "WorkState",       0, "work"));
+      this.mConverterArr.push(new com.gContactSync.ConverterElement("postcode", "WorkZipCode",     0, "work"));
+      this.mConverterArr.push(new com.gContactSync.ConverterElement("country",  "WorkCountry",     0, "work"));
     }
     this.mInitialized = true;
   },
@@ -363,13 +363,12 @@ com.gContactSync.ContactConverter = {
       throw "Invalid TBContact (no mAddressBook) sent to " +
             "ContactConverter.cardToAtomXML from " + this.caller;
     }
-    var arr = this.mConverterArr,
-        blankProp = new com.gContactSync.Property("", "");
+    var arr = this.mConverterArr;
     // get the regular properties from the array mConverterArr
     for (var i = 0, length = arr.length; i < length; i++) {
       var obj = arr[i],
           property = aGContact.getValue(obj.elementName, obj.index, obj.type);
-      property = property || blankProp;
+      property = property || new com.gContactSync.Property("", "");
       com.gContactSync.LOGGER.VERBOSE_LOG(obj.tbName + ": '" + property.value +
                                           "', type: '" + property.type + "'");
       // Thunderbird has problems with contacts who do not have an e-mail addr
@@ -377,7 +376,7 @@ com.gContactSync.ContactConverter = {
       // that is hidden from the user
       if (obj.tbName === com.gContactSync.dummyEmailName && !property.value) {
         property.value = com.gContactSync.makeDummyEmail(aGContact);
-        property.type  = "home";
+        property.type  = "other";
       }
       aTBContact.setValue(obj.tbName, property.value);
       // set the type, if it is an attribute with a type
diff --git a/src/content/MessengerOverlay.js b/src/content/MessengerOverlay.js
index 230322b..86f4fb3 100644
--- a/src/content/MessengerOverlay.js
+++ b/src/content/MessengerOverlay.js
@@ -15,7 +15,7 @@
  *
  * The Initial Developer of the Original Code is
  * Josh Geenen <gcontactsync at pirules.org>.
- * Portions created by the Initial Developer are Copyright (C) 2010
+ * Portions created by the Initial Developer are Copyright (C) 2010-2014
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
@@ -91,11 +91,14 @@ com.gContactSync.MessengerOverlay = {
 
     com.gContactSync.Preferences.setSyncPref("synchronizing", false);
 
-    // If moving from 0.3.x or <0.4.0b1 then update the chat names
+    // If moving from 0.3.x or <0.4.0b1 then update the chat names and incorrect types
+    // Otherwise if coming from pre-0.4.0rc1 update the incorrect types
     // The upgrade will take place during the next sync
     if (((lastVersionMajor === 0) && (lastVersionMinor < 4) && (lastVersionMajor > 0)) ||
         ((lastVersionMajor === 0) && (lastVersionMinor === 4) && (lastVersionRelease === 0) && (lastVersionSuffix.length > 0) && (lastVersionSuffix.charAt(0) === "a"))) {
       com.gContactSync.Preferences.setSyncPref("v04UpgradeNeeded", true);
+    } else if ((lastVersionMajor === 0) && (lastVersionMinor === 4) && (lastVersionRelease === 0) && (lastVersionSuffix.length > 0) && ((lastVersionSuffix.charAt(0) === "a") || (lastVersionSuffix.charAt(0) === "b"))) {
+      com.gContactSync.Preferences.setSyncPref("v04RCUpgradeNeeded", true);
     }
     if (com.gContactSync.Preferences.mSyncPrefs.overrideGetCardForEmail.value) {
       try {
diff --git a/src/content/Preferences.js b/src/content/Preferences.js
index 2241d26..0ace4d9 100644
--- a/src/content/Preferences.js
+++ b/src/content/Preferences.js
@@ -15,7 +15,7 @@
  *
  * The Initial Developer of the Original Code is
  * Josh Geenen <gcontactsync at pirules.org>.
- * Portions created by the Initial Developer are Copyright (C) 2008-2011
+ * Portions created by the Initial Developer are Copyright (C) 2008-2014
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
@@ -208,6 +208,7 @@ com.gContactSync.Preferences = {
     newContactPhotoDelay:     new com.gContactSync.Pref("newContactPhotoDelay",      "int", 0),
     remoteActionDelay:        new com.gContactSync.Pref("remoteActionDelay",         "int", 0),
     v04UpgradeNeeded:         new com.gContactSync.Pref("v04UpgradeNeeded",         "bool", false),
+    v04RCUpgradeNeeded:       new com.gContactSync.Pref("v04RCUpgradeNeeded",       "bool", false),
     httpRequestTimeout:       new com.gContactSync.Pref("httpRequestTimeout",        "int", 0)
   },
   /**
diff --git a/src/content/Sync.js b/src/content/Sync.js
index a9862bc..a745376 100644
--- a/src/content/Sync.js
+++ b/src/content/Sync.js
@@ -15,7 +15,7 @@
  *
  * The Initial Developer of the Original Code is
  * Josh Geenen <gcontactsync at pirules.org>.
- * Portions created by the Initial Developer are Copyright (C) 2008-2010
+ * Portions created by the Initial Developer are Copyright (C) 2008-2014
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
@@ -137,7 +137,8 @@ com.gContactSync.Sync = {
     }
 
     // Upgrade checks
-    if (com.gContactSync.Preferences.mSyncPrefs.v04UpgradeNeeded.value) {
+    if (com.gContactSync.Preferences.mSyncPrefs.v04UpgradeNeeded.value ||
+        com.gContactSync.Preferences.mSyncPrefs.v04RCUpgradeNeeded.value) {
       com.gContactSync.version04Upgrade();
     }
 
diff --git a/src/content/TBContact.js b/src/content/TBContact.js
index f638b67..de5c34a 100644
--- a/src/content/TBContact.js
+++ b/src/content/TBContact.js
@@ -15,7 +15,7 @@
  *
  * The Initial Developer of the Original Code is
  * Josh Geenen <gcontactsync at pirules.org>.
- * Portions created by the Initial Developer are Copyright (C) 2009-2011
+ * Portions created by the Initial Developer are Copyright (C) 2009-2014
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
@@ -75,8 +75,9 @@ com.gContactSync.TBContact.prototype = {
    * @returns {string} The value of the attribute, or null if not set.
    */
   getValue: function TBContact_getValue(aAttribute) {
-    if (!aAttribute)
+    if (!aAttribute) {
       throw "Error - invalid attribute sent to TBContact.getValue";
+    }
     if (aAttribute === "LastModifiedDate") {
       var ret = com.gContactSync.GAbManager.getCardValue(this.mContact, aAttribute);
       if (this.mAddressBook.mPrefs && this.mAddressBook.mPrefs.readOnly === "true") {
@@ -87,15 +88,19 @@ com.gContactSync.TBContact.prototype = {
         ret = 1;
       }
       return ret;
-    }
+    } else if (aAttribute === "HomeAddressMult" || aAttribute === "WorkAddressMult") {
+      var type = aAttribute.substring(0, 4);
+      var addr = com.gContactSync.GAbManager.getCardValue(this.mContact, type + "Address");
+      var line2 = com.gContactSync.GAbManager.getCardValue(this.mContact, type + "Address2");
+      if (line2) { addr += "\n" + line2; }
+      return addr;
     // Postbox stores additional e-mail addresses already
-    else if (this.mPostbox && (aAttribute === "ThirdEmail" || aAttribute === "FourthEmail")) {
+    } else if (this.mPostbox && (aAttribute === "ThirdEmail" || aAttribute === "FourthEmail")) {
       var arrLen   = {},
           emailArr = this.mContact.getAdditionalEmailAddresses(arrLen);
       if (aAttribute === "ThirdEmail" && emailArr.length > 0) {
         return emailArr[0];
-      }
-      else if (emailArr.length > 1) {
+      } else if (emailArr.length > 1) {
         return emailArr[1];
       }
       return null;
@@ -130,21 +135,22 @@ com.gContactSync.TBContact.prototype = {
           emailArr = this.mContact.getAdditionalEmailAddresses(arrLen);
       if (aAttribute === "ThirdEmail") {
         emailArr[0] = aValue;
-      }
-      // FourthEmail
-      else if (emailArr.length > 0) {
+      } else if (emailArr.length > 0) {
+        // FourthEmail
         emailArr[1] = aValue;
-      }
-      else {
+      } else {
         emailArr[0] = aValue;
       }
       this.mContact.setAdditionalEmailAddresses(emailArr.length, emailArr);
-    }
-    else {
+    } else if (aAttribute === "HomeAddressMult" || aAttribute === "WorkAddressMult") {
+      var type = aAttribute.substring(0, 4);
+      var values = aValue ? aValue.split("\n") : [aValue, aValue];
+      com.gContactSync.GAbManager.setCardValue(this.mContact, type + "Address", values[0]);
+      com.gContactSync.GAbManager.setCardValue(this.mContact, type + "Address2", values[1]);
+    } else {
       com.gContactSync.GAbManager.setCardValue(this.mContact, aAttribute, aValue);
     }
-    if (aUpdate)
-      return this.update();
+    if (aUpdate) { return this.update(); }
     return false;
   },
   /**
diff --git a/src/content/synonyms.js b/src/content/synonyms.js
index 2eba05e..3569d41 100644
--- a/src/content/synonyms.js
+++ b/src/content/synonyms.js
@@ -15,7 +15,7 @@
  *
  * The Initial Developer of the Original Code is
  * Josh Geenen <gcontactsync at pirules.org>.
- * Portions created by the Initial Developer are Copyright (C) 2008-2011
+ * Portions created by the Initial Developer are Copyright (C) 2008-2014
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
@@ -51,7 +51,7 @@ com.gContactSync.versionMinor   = "4";
 /** The release for the current version of gContactSync (ie 1 in 0.3.1a7) */
 com.gContactSync.versionRelease = "0";
 /** The suffix for the current version of gContactSync (ie a7 for Alpha 7) */
-com.gContactSync.versionSuffix  = "b4";
+com.gContactSync.versionSuffix  = "rc1";
 /** The attribute where the dummy e-mail address is stored */
 com.gContactSync.dummyEmailName = "PrimaryEmail";
 
@@ -607,57 +607,73 @@ com.gContactSync.version04Upgrade = function gCS_version04Upgrade() {
   com.gContactSync.alert(com.gContactSync.StringBundle.getStr("version04UpgradeMessage"));
   com.gContactSync.LOGGER.LOG("***Upgrading Contacts***");
   var propertiesToReplace = ["_AimScreenName", "TalkScreenName", "ICQScreenName", "YahooScreenName", "MSNScreenName", "JabberScreenName"];
+  // Properties that should not have types, but were given types to contacts without an e-mail address.
+  var untypedProperties  = ["_GoogleTalk", "_ICQ", "_Yahoo", "_MSN", "_JabberId", "_Skype", "JobTitle", "Company", "Department",
+                            "JobDescription", "CompanySymbol", "HomeAddress", "HomeCity", "HomeState", "HomeZipCode", "HomeCountry",
+                            "WorkAddress", "WorkCity", "WorkState", "WorkZipCode", "WorkCountry"];
   var abs = com.gContactSync.GAbManager.getAllAddressBooks(2, true);
+  var updateScreenNames = com.gContactSync.Preferences.mSyncPrefs.v04UpgradeNeeded.value;
   // For each AB:
   //  Get all contacts
   //   Get all old screennames and move them to the new fields in TB
+  //   Remove types for untyped properties
   for (var i in abs) {
     if (abs[i] instanceof com.gContactSync.GAddressBook) {
       var contacts = abs[i].getAllContacts();
       com.gContactSync.LOGGER.LOG(abs[i].getName() + ": " + contacts.length);
       for (var j = 0, length = contacts.length; j < length; j++) {
         var contact = contacts[j];
+        var needsUpdate = false;
         com.gContactSync.LOGGER.VERBOSE_LOG("-" + contact.getName());
 
-        var typeToName = {
-          // Google Type  TB Field          TB Val
-          "AIM":         ["_AimScreenName", ""],
-          "GOOGLE_TALK": ["_GoogleTalk",    ""],
-          "YAHOO":       ["_Yahoo",         ""],
-          "SKYPE":       ["_Skype",         ""],
-          "QQ":          ["_QQ",            ""],
-          "MSN":         ["_MSN",           ""],
-          "ICQ":         ["_ICQ",           ""],
-          "JABBER":      ["_JabberId",      ""]
-        };
-
-        // Get all the existing screennames from the old gContactSync fields
-        for (var k = 0, propLength = propertiesToReplace.length; k < propLength; ++k) {
-          var type = contact.getValue(propertiesToReplace[k] + "Type");
-          if (type && typeToName[type] && typeToName[type][1] == "") {
-            typeToName[type][1] = contact.getValue(propertiesToReplace[k]);
-            com.gContactSync.LOGGER.VERBOSE_LOG(" * " + type + ": " + typeToName[type][1]);
+        if (updateScreenNames) {
+          var typeToName = {
+            // Google Type  TB Field          TB Val
+            "AIM":         ["_AimScreenName", ""],
+            "GOOGLE_TALK": ["_GoogleTalk",    ""],
+            "YAHOO":       ["_Yahoo",         ""],
+            "SKYPE":       ["_Skype",         ""],
+            "QQ":          ["_QQ",            ""],
+            "MSN":         ["_MSN",           ""],
+            "ICQ":         ["_ICQ",           ""],
+            "JABBER":      ["_JabberId",      ""]
+          };
+
+          // Get all the existing screennames from the old gContactSync fields
+          for (var k = 0, propLength = propertiesToReplace.length; k < propLength; ++k) {
+            var type = contact.getValue(propertiesToReplace[k] + "Type");
+            if (type && typeToName[type] && typeToName[type][1] == "") {
+              typeToName[type][1] = contact.getValue(propertiesToReplace[k]);
+              com.gContactSync.LOGGER.VERBOSE_LOG(" * " + type + ": " + typeToName[type][1]);
+            }
           }
-        }
 
-        var needsUpdate = false;
-        // Remove the AIM screenname if present, since it is both an old and new field
-        if (contact.getValue("_AimScreenName")) {
-          contact.setValue("_AimScreenName", "");
-          contact.setValue("_AimScreenNameType", "AIM");  // for backwards compatibility
-          needsUpdate = true;
+          // Remove the AIM screenname if present, since it is both an old and new field
+          if (contact.getValue("_AimScreenName")) {
+            contact.setValue("_AimScreenName", "");
+            contact.setValue("_AimScreenNameType", "AIM");  // for backwards compatibility
+            needsUpdate = true;
+          }
+          // Now save any screennames to the new fields in TB
+          for (var prop in typeToName) {
+            if (typeToName[prop][1]) {
+              needsUpdate = true;
+              contact.setValue(typeToName[prop][0], typeToName[prop][1]);
+              com.gContactSync.LOGGER.VERBOSE_LOG(" * " + typeToName[prop][0] + ": " + typeToName[prop][1]);
+            }
+          }
         }
-        // Now save any screennames to the new fields in TB
-        for (var prop in typeToName) {
-          if (typeToName[prop][1]) {
+        // Remove types for untyped properties
+        for (var l = 0, untypedPropLen = untypedProperties.length; l < untypedPropLen; ++l) {
+          if (contact.getValue(untypedProperties[l])) {
             needsUpdate = true;
-            contact.setValue(typeToName[prop][0], typeToName[prop][1]);
-            com.gContactSync.LOGGER.VERBOSE_LOG(" * " + typeToName[prop][0] + ": " + typeToName[prop][1]);
+            contact.setValue(untypedProperties[l], null);
           }
         }
-        if (needsUpdate) contact.update();
+        if (needsUpdate) {contact.update();}
       }
     }
   }
   com.gContactSync.Preferences.setSyncPref("v04UpgradeNeeded", false);
-}
+  com.gContactSync.Preferences.setSyncPref("v04RCUpgradeNeeded", false);
+};
diff --git a/src/defaults/preferences/gContactSync.js b/src/defaults/preferences/gContactSync.js
index 9230009..c10b110 100644
--- a/src/defaults/preferences/gContactSync.js
+++ b/src/defaults/preferences/gContactSync.js
@@ -87,7 +87,9 @@ pref("extensions.gContactSync.newContactPhotoDelay", 2000);
 // delay after adding, deleting, or updating a contact.  Can help mitigate 503 errors.
 pref("extensions.gContactSync.remoteActionDelay", 0);
 // Stores whether an upgrade is required from <0.4.0b1 to version 0.4
-pref("extensions.gContactSync.v04UpgradeNeeded", true);
+pref("extensions.gContactSync.v04UpgradeNeeded", false);
+// Stores whether an upgrade is required from <0.4.0b5 and > 0.3.x to version 0.4
+pref("extensions.gContactSync.v04RCUpgradeNeeded", false);
 // Timeout in ms for HTTP requests, 0 means no timeout.
 pref("extensions.gContactSync.httpRequestTimeout", 0);
 // extended properties to sync
diff --git a/src/install.rdf b/src/install.rdf
index f434771..6b5c975 100644
--- a/src/install.rdf
+++ b/src/install.rdf
@@ -3,7 +3,7 @@
      xmlns:em="http://www.mozilla.org/2004/em-rdf#">
     <Description about="urn:mozilla:install-manifest">
         <em:id>gContactSync at pirules.net</em:id>
-        <em:version>0.4.0b4</em:version>
+        <em:version>0.4.0b5</em:version>
         <em:name>gContactSync</em:name>
         <em:description>Synchronizes Google Contacts with Thunderbird</em:description>
         <em:creator>Josh Geenen</em:creator>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/gcontactsync.git



More information about the Pkg-mozext-commits mailing list