Fix bug 491118 - reminder for non-dismissed events fire again after hibernation (double/twice in alarm popup) (regression). r=mschroeder
authorPhilipp Kewisch <mozilla@kewis.ch>
Sat, 18 Jun 2011 16:11:09 +0200
changeset 7972 e1d20d0e6d15cc0fefe95341df3a8378777050ba
parent 7971 cb831258d4e0875d8c2117d7d3609f1a2856289a
child 7973 ba753763c17af1373d3b7eac6c5c526429b1c5e4
push id50
push usermozilla@kewis.ch
push dateTue, 19 Jul 2011 20:04:29 +0000
treeherdercomm-beta@aee08b4d6cf3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmschroeder
bugs491118
Fix bug 491118 - reminder for non-dismissed events fire again after hibernation (double/twice in alarm popup) (regression). r=mschroeder
calendar/base/public/calIAlarmService.idl
calendar/base/src/calAlarmMonitor.js
calendar/base/src/calAlarmService.js
calendar/base/src/calItemModule.manifest
--- a/calendar/base/public/calIAlarmService.idl
+++ b/calendar/base/public/calIAlarmService.idl
@@ -85,16 +85,22 @@ interface calIAlarmService : nsISupports
    * calendar registration and unregistration, and setup a timer to
    * maintain that list and fire alarms.
    *
    * @note Will throw NS_ERROR_NOT_INITIALIZED if you have not previously set
    *       the timezone attribute.
    */
   void startup();
 
+  /**
+   * Shuts down the alarm service, canceling all timers and removing all
+   * alarms.
+   */
+  void shutdown();
+
   /* add and remove observers that will be notified when an
      alarm has gone off.  It is up to the application to display
      the alarm.
   */
   void addObserver(in calIAlarmServiceObserver observer);
   void removeObserver(in calIAlarmServiceObserver observer);
 
   /**
--- a/calendar/base/src/calAlarmMonitor.js
+++ b/calendar/base/src/calAlarmMonitor.js
@@ -68,16 +68,17 @@ calAlarmMonitor.prototype = {
 
     /**
      * nsIClassInfo
      */
     getInterfaces: function cAM_getInterfaces(aCount) {
         let ifaces = [
             Components.interfaces.nsISupports,
             Components.interfaces.nsIObserver,
+            Components.interfaces.nsIClassInfo,
             Components.interfaces.calIAlarmServiceObserver
         ];
         aCount.value = ifaces.length;
         return ifaces;
     },
 
     getHelperForLanguage: function cAM_getHelperForLanguage(aLanguage) {
         return null;
--- a/calendar/base/src/calAlarmService.js
+++ b/calendar/base/src/calAlarmService.js
@@ -322,39 +322,34 @@ calAlarmService.prototype = {
         timerCallback.notify();
 
         this.mUpdateTimer = newTimerWithCallback(timerCallback, kHoursBetweenUpdates * 3600000, true);
 
         this.mStarted = true;
     },
 
     shutdown: function cAS_shutdown() {
+        if (!this.mStarted) {
+            return;
+        }
+
         /* tell people that we're no longer running */
         let notifier = Components.classes["@mozilla.org/embedcomp/appstartup-notifier;1"]
                                  .getService(Components.interfaces.nsIObserver);
         notifier.observe(null, "alarm-service-shutdown", null);
 
         if (this.mUpdateTimer) {
             this.mUpdateTimer.cancel();
             this.mUpdateTimer = null;
         }
 
         let calmgr = cal.getCalendarManager();
         calmgr.removeObserver(this.calendarManagerObserver);
 
-        for each (let calendarItemMap in this.mTimerMap) {
-            for each (let alarmMap in calendarItemMap) {
-                for each (let timer in alarmMap) {
-                    timer.cancel();
-                }
-            }
-        }
-
-        this.mTimerMap = {};
-
+        // Stop observing all calendars. This will also clear the timers.
         for each (let calendar in calmgr.getCalendars({})) {
             this.unobserveCalendar(calendar);
         }
 
         this.mRangeEnd = null;
 
         let observerSvc = Components.classes["@mozilla.org/observer-service;1"]
                           .getService(Components.interfaces.nsIObserverService);
--- a/calendar/base/src/calItemModule.manifest
+++ b/calendar/base/src/calItemModule.manifest
@@ -1,18 +1,18 @@
 component {b8db7c7f-c168-4e11-becb-f26c1c4f5f8f} calItemModule.js
 contract @mozilla.org/calendar/alarm;1 {b8db7c7f-c168-4e11-becb-f26c1c4f5f8f}
 
 component {7a9200dd-6a64-4fff-a798-c5802186e2cc} calItemModule.js
 contract @mozilla.org/calendar/alarm-service;1 {7a9200dd-6a64-4fff-a798-c5802186e2cc}
 
 component {4b7ae030-ed79-11d9-8cd6-0800200c9a66} calItemModule.js
 contract @mozilla.org/calendar/alarm-monitor;1 {4b7ae030-ed79-11d9-8cd6-0800200c9a66}
-category alarm-service-startup calendar-alarm-monitor @mozilla.org/calendar/alarm-monitor;1
-category alarm-service-shutdown calendar-alarm-monitor @mozilla.org/calendar/alarm-monitor;1
+category alarm-service-startup calendar-alarm-monitor service,@mozilla.org/calendar/alarm-monitor;1
+category alarm-service-shutdown calendar-alarm-monitor service,@mozilla.org/calendar/alarm-monitor;1
 
 component {5c8dcaa3-170c-4a73-8142-d531156f664d} calItemModule.js
 contract @mozilla.org/calendar/attendee;1 {5c8dcaa3-170c-4a73-8142-d531156f664d}
 
 component {5f76b352-ab75-4c2b-82c9-9206dbbf8571} calItemModule.js
 contract @mozilla.org/calendar/attachment;1 {5f76b352-ab75-4c2b-82c9-9206dbbf8571}
 
 component {f42585e7-e736-4600-985d-9624c1c51992} calItemModule.js