Bug 1436491 - Move category related functions into calCategoryUtils.jsm - automatic changes. r=MakeMyDay
authorPhilipp Kewisch <mozilla@kewis.ch>
Wed, 07 Feb 2018 20:57:00 +0100
changeset 31102 79de47fa45edc4bb9dc0de474dc6bdb8e7cf2d6f
parent 31101 3de68de8bf72c03fefe20521619c0a78c07b07a5
child 31103 38e20522425aa554091b8204c62a5402099035ab
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersMakeMyDay
bugs1436491
Bug 1436491 - Move category related functions into calCategoryUtils.jsm - automatic changes. r=MakeMyDay MozReview-Commit-ID: FiYS1ZtzkE7
calendar/base/content/preferences/categories.js
calendar/base/content/widgets/calendar-widgets.xml
calendar/import-export/calOutlookCSVImportExport.js
calendar/lightning/content/lightning-item-iframe.js
calendar/providers/gdata/modules/gdataUtils.jsm
calendar/providers/storage/calStorageCalendar.js
--- a/calendar/base/content/preferences/categories.js
+++ b/calendar/base/content/preferences/categories.js
@@ -42,21 +42,21 @@ var gCategoriesPane = {
         if (!("backupPrefList" in parent)) {
             parent.backupPrefList = [];
         }
 
         let categories = document.getElementById("calendar.categories.names").value;
 
         // If no categories are configured load a default set from properties file
         if (!categories) {
-            categories = cal.setupDefaultCategories();
+            categories = cal.category.setupDefaultCategories();
             document.getElementById("calendar.categories.names").value = categories;
         }
 
-        gCategoryList = cal.categoriesStringToArray(categories);
+        gCategoryList = cal.category.stringToArray(categories);
 
         this.updateCategoryList();
 
         this.mCategoryDialog = "chrome://calendar/content/preferences/editCategory.xul";
 
         // Workaround for Bug 1151440 - the HTML color picker won't work
         // in linux when opened from modal dialog
         this.mWinProp = "centerscreen, chrome, resizable=no";
@@ -73,17 +73,17 @@ var gCategoriesPane = {
     /**
      * Updates the listbox containing the categories from the categories saved
      * in preferences.
      */
 
     updatePrefs: function() {
         cal.sortArrayByLocaleCollator(gCategoryList);
         document.getElementById("calendar.categories.names").value =
-            cal.categoriesArrayToString(gCategoryList);
+            cal.category.arrayToString(gCategoryList);
     },
 
     updateCategoryList: function() {
         this.updatePrefs();
         let listbox = document.getElementById("categorieslist");
 
         listbox.clearSelection();
         this.updateButtons();
--- a/calendar/base/content/widgets/calendar-widgets.xml
+++ b/calendar/base/content/widgets/calendar-widgets.xml
@@ -179,17 +179,17 @@
             categoryListbox.ensureElementIsVisible(item);
         ]]></body>
       </method>
 
       <method name="loadItem">
         <parameter name="aItem"/>
         <body><![CDATA[
             let categoryListbox = document.getAnonymousElementByAttribute(this, "anonid", "categories-listbox");
-            let categoryList = cal.getPrefCategoriesArray();
+            let categoryList = cal.category.fromPrefs();
 
             cal.sortArrayByLocaleCollator(categoryList);
 
             removeChildren(categoryListbox);
 
             for (let cat of categoryList) {
                 // First insert all categories from the prefs
                 let item = categoryListbox.appendItem(cat, cat);
--- a/calendar/import-export/calOutlookCSVImportExport.js
+++ b/calendar/import-export/calOutlookCSVImportExport.js
@@ -338,17 +338,17 @@ calOutlookCSVImporter.prototype = {
                     txt = this.parseTextField(eventFields[args.descriptionIndex]);
                     if (txt) {
                         event.setProperty("DESCRIPTION", txt);
                     }
                 }
                 if ("categoriesIndex" in args) {
                     txt = this.parseTextField(eventFields[args.categoriesIndex]);
                     if (txt) {
-                        let categories = cal.categoriesStringToArray(txt);
+                        let categories = cal.category.stringToArray(txt);
                         event.setCategories(categories.length, categories);
                     }
                 }
                 if ("locationIndex" in args) {
                     txt = this.parseTextField(eventFields[args.locationIndex]);
                     if (txt) {
                         event.setProperty("LOCATION", txt);
                     }
@@ -473,17 +473,17 @@ calOutlookCSVExporter.prototype = {
             let alarmDate;
             let alarms = item.getAlarms({});
             if (alarms.length) {
                 alarmDate = cal.alarms.calculateAlarmDate(item, alarms[0]);
             }
             line.push(alarmDate ? localeEn.valueTrue : localeEn.valueFalse);
             line.push(alarmDate ? dateString(alarmDate) : "");
             line.push(alarmDate ? timeString(alarmDate) : "");
-            line.push(txtString(cal.categoriesArrayToString(item.getCategories({})))); // xxx todo: what's the correct way to encode ',' in csv?, how are multi-values expressed?
+            line.push(txtString(cal.category.arrayToString(item.getCategories({})))); // xxx todo: what's the correct way to encode ',' in csv?, how are multi-values expressed?
             line.push(txtString(item.getProperty("DESCRIPTION")));
             line.push(txtString(item.getProperty("LOCATION")));
             line.push(item.privacy == "PRIVATE" ? localeEn.valueTrue : localeEn.valueFalse);
 
             line = line.map(value => `"${String(value).replace(/"/g, '""')}"`);
             str = line.join(",") + exportLineEnding;
 
             let converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
--- a/calendar/lightning/content/lightning-item-iframe.js
+++ b/calendar/lightning/content/lightning-item-iframe.js
@@ -590,17 +590,17 @@ function loadDialog(aItem) {
         if (indexToSelect > -1) {
             calendarList.selectedIndex = indexToSelect;
         }
     }
 
     // Categories
     if (gNewItemUI) {
         // XXX more to do here with localization, see loadCategories.
-        itemProps.initialCategoriesList = cal.sortArrayByLocaleCollator(cal.getPrefCategoriesArray());
+        itemProps.initialCategoriesList = cal.sortArrayByLocaleCollator(cal.category.fromPrefs());
         itemProps.initialCategories = aItem.getCategories({});
 
         // just to demo capsules component
         itemProps.initialCategories = ["Some", "Demo", "Categories"];
     } else {
         loadCategories(aItem);
     }
 
--- a/calendar/providers/gdata/modules/gdataUtils.jsm
+++ b/calendar/providers/gdata/modules/gdataUtils.jsm
@@ -330,17 +330,17 @@ function EventToJSON(aItem, aOfflineStor
                                        Components.results.NS_ERROR_LOSS_OF_SIGNIFICANT_DATA);
     } else if (status == "none") {
         status = null;
     }
     setIf(itemData, "status", status);
 
     // Google does not support categories natively, but allows us to store data
     // as an "extendedProperty", so we do here
-    let categories = cal.categoriesArrayToString(aItem.getCategories({}));
+    let categories = cal.category.arrayToString(aItem.getCategories({}));
     addExtendedProperty("X-MOZ-CATEGORIES", categories);
 
     // Only parse attendees if they are enabled, due to bug 407961
     if (Preferences.get("calendar.google.enableAttendees", false)) {
         let createAttendee = function(attendee) {
             const statusMap = {
                 "NEEDS-ACTION": "needsAction",
                 "DECLINED": "declined",
@@ -817,17 +817,17 @@ function JSONToEvent(aEntry, aCalendar, 
                     item.setProperty("X-MOZ-SNOOZE-TIME-" + rid, snoozeObj[rid]);
                 }
             }
         }
 
         // Google does not support categories natively, but allows us to store
         // data as an "extendedProperty", and here it's going to be retrieved
         // again
-        let categories = cal.categoriesStringToArray(sharedProps["X-MOZ-CATEGORIES"]);
+        let categories = cal.category.stringToArray(sharedProps["X-MOZ-CATEGORIES"]);
         item.setCategories(categories.length, categories);
 
         // updated (This must be set last!)
         if (aEntry.updated) {
             let updated = cal.fromRFC3339(aEntry.updated, calendarZone).getInTimezone(cal.dtz.UTC);
             item.setProperty("DTSTAMP", updated);
             item.setProperty("LAST-MODIFIED", updated);
         }
--- a/calendar/providers/storage/calStorageCalendar.js
+++ b/calendar/providers/storage/calStorageCalendar.js
@@ -1725,17 +1725,17 @@ calStorageCalendar.prototype = {
                 while (selectItem.executeStep()) {
                     let row = selectItem.row;
                     let name = row.key;
                     switch (name) {
                         case "DURATION":
                             // for events DTEND/DUE is enforced by calEvent/calTodo, so suppress DURATION:
                             break;
                         case "CATEGORIES": {
-                            let cats = cal.categoriesStringToArray(row.value);
+                            let cats = cal.category.stringToArray(row.value);
                             item.setCategories(cats.length, cats);
                             break;
                         }
                         default:
                             item.setProperty(name, row.value);
                             break;
                     }
                 }
@@ -2159,17 +2159,17 @@ calStorageCalendar.prototype = {
                 continue;
             }
             this.writeProperty(item, prop.name, prop.value);
         }
 
         let cats = item.getCategories({});
         if (cats.length > 0) {
             ret = CAL_ITEM_FLAG.HAS_PROPERTIES;
-            this.writeProperty(item, "CATEGORIES", cal.categoriesArrayToString(cats));
+            this.writeProperty(item, "CATEGORIES", cal.category.arrayToString(cats));
         }
 
         return ret;
     },
 
     writeRecurrence: function(item, olditem) {
         let flags = 0;