Fix bug 486676 - Unnecessary alarm load on startup for all subscribed calendars (regression). r=philipp
authorDaniel Boelzle [:dbo] <mozilla@boelzle.org>
Fri, 03 Apr 2009 18:19:42 +0200
changeset 2337 bfd4b725fcb99f2ee2b93376045dae30aa13f007
parent 2336 e9043983de8ad62a7482f1c0fe543636f0008349
child 2338 809750e4c971fa6c18adb260685cd8c5146e2965
push id1893
push usermozilla@boelzle.org
push dateFri, 03 Apr 2009 16:20:20 +0000
treeherdercomm-central@bfd4b725fcb9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp
bugs486676
Fix bug 486676 - Unnecessary alarm load on startup for all subscribed calendars (regression). r=philipp
calendar/base/modules/calProviderUtils.jsm
calendar/providers/wcap/calWcapCalendar.js
calendar/providers/wcap/calWcapCalendarItems.js
--- a/calendar/base/modules/calProviderUtils.jsm
+++ b/calendar/base/modules/calProviderUtils.jsm
@@ -644,26 +644,24 @@ cal.ProviderBase.prototype = {
                 }
             }
             if ((ret === null) &&
                 !cal.ProviderBase.mTransientProperties[aName] &&
                 !this.transientProperties) {
                 if (this.id) {
                     ret = cal.getCalendarManager().getCalendarPref_(this, aName);
                 }
-                if (ret !== null) {
-                    switch (aName) {
-                        case "suppressAlarms":
-                            if (this.getProperty("capabilities.alarms.popup.supported") === false) {
-                                // If popup alarms are not supported,
-                                // automatically suppress alarms
-                                ret = true;
-                            }
-                            break;
-                    }
+                switch (aName) {
+                    case "suppressAlarms":
+                        if (this.getProperty("capabilities.alarms.popup.supported") === false) {
+                            // If popup alarms are not supported,
+                            // automatically suppress alarms
+                            ret = true;
+                        }
+                        break;
                 }
             }
             this.mProperties[aName] = ret;
         }
 //         cal.LOG("getProperty(\"" + aName + "\"): " + ret);
         return ret;
     },
 
--- a/calendar/providers/wcap/calWcapCalendar.js
+++ b/calendar/providers/wcap/calWcapCalendar.js
@@ -139,21 +139,21 @@ calWcapCalendar.prototype = {
                 return this.ownerId;
             case "organizerCN":
                 return this.getCalendarProperties("X-S1CS-CALPROPS-COMMON-NAME");
             case "itip.disableRevisionChecks":
                 return true;
             case "capabilities.timezones.floating.supported":
             case "capabilities.timezones.UTC.supported":
             case "capabilities.attachments.supported":
+            case "capabilities.alarms.popup.supported": // CS cannot store X-props reliably
+                                                        // (thus writing X-MOZ stamps etc is not possible).
+                                                        // Popup alarms not available no matter what; wtf.
                 return false;
             case "capabilities.alarms.actionValues":
-                // CS cannot store X-props reliably (thus writing X-MOZ stamps
-                // etc is not possible). Popup alarms not available no matter
-                // what.
                 return ["EMAIL"];
             case "capabilities.alarms.maxCount":
                 return 1;
         }
 
         var value = this.__proto__.__proto__.getProperty.apply(this, arguments);
         switch (aName) {
             case "readOnly":
--- a/calendar/providers/wcap/calWcapCalendarItems.js
+++ b/calendar/providers/wcap/calWcapCalendarItems.js
@@ -179,20 +179,19 @@ calWcapCalendar.prototype.encodeRecurren
     // or whether to replace the rrule, ambiguous documentation!!!
     // check with store(with no uid) upon adoptItem() which behaves strange
     // if rchange=0 is set!
 };
 
 calWcapCalendar.prototype.getAlarmParams =
 function calWcapCalendar_getAlarmParams(item) {
     let params = null;
-    // TODO ALARMSUPPORT check if WCAP supports multiple alarms
+    // xxx TODO ALARMSUPPORT check if WCAP supports multiple alarms
     let alarms = item.getAlarms({}).filter(function(x) x.action == "EMAIL");
-    let alarm = alarms[0];
-    // END TODO ALARMSUPPORT
+    let alarm = alarms.length > 0 && alarms[0];
 
     if (alarm) {
         let alarmStart = cal.alarms.calculateAlarmOffset(item, alarm);
         if (alarm.related == alarm.ALARM_RELATED_END) {
             // cs does not support explicit RELATED=END when
             // both start|entry and end|due are written
             let dur = item.duration;
             if (dur) { // both given
@@ -457,29 +456,25 @@ function calWcapCalendar_storeItem(bAddI
             }
         }
 
         var val = item.title;
         if (!oldItem || val != oldItem.title) {
             params += ("&summary=" + encodeURIComponent(val));
         }
 
-        var categories = item.getCategories({});
-        if (categories.length > 0) {
-            function encodeCategories(cats) {
-                cats = cats.concat([]);
-                cats.sort();
-                return cats.join(";");
-            }
-            var catParam = encodeCategories(categories);
-            if (!oldItem || catParam != encodeCategories(oldItem.getCategories({}))) {
-                params += ("&categories=" + catParam);
-            }
-        } else {
-            params += "&categories=";
+        let categories = item.getCategories({});
+        function encodeCategories(cats) {
+            cats = cats.concat([]);
+            cats.sort();
+            return cats.join(";");
+        }
+        let catParam = encodeCategories(categories);
+        if (!oldItem || catParam != encodeCategories(oldItem.getCategories({}))) {
+            params += ("&categories=" + catParam);
         }
 
         val = diffProperty(item, oldItem, "DESCRIPTION");
         if (val !== null) {
             params += ("&desc=" + encodeURIComponent(val));
         }
         val = diffProperty(item, oldItem, "LOCATION");
         if (val !== null) {