Fix bug 734773 - Allow getting a calendar by id. r=mmecca
authorPhilipp Kewisch <mozilla@kewis.ch>
Mon, 12 Mar 2012 09:52:09 +0100
changeset 11063 d5c44c6980e4f211f6c465a929d2e93e892a50af
parent 11062 eb1745fc8a71656250c074a9ba88067482b18534
child 11064 ba06afbb5121723325afa002abecb722e97065ca
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmmecca
bugs734773
Fix bug 734773 - Allow getting a calendar by id. r=mmecca
calendar/base/public/calICalendarManager.idl
calendar/base/src/calCalendarManager.js
--- a/calendar/base/public/calICalendarManager.idl
+++ b/calendar/base/public/calICalendarManager.idl
@@ -70,16 +70,19 @@ interface calICalendarManager : nsISuppo
   void registerCalendar(in calICalendar aCalendar);
 
   /* unregister a calendar */
   void unregisterCalendar(in calICalendar aCalendar);
 
   /* delete a calendar for good */
   void deleteCalendar(in calICalendar aCalendar);
 
+  /* get a calendar by its id */
+  calICalendar getCalendarById(in AUTF8String aId);
+
   /* return a list of all calendars currently registered */
   void getCalendars(out PRUint32 count,
                     [array, size_is(count), retval] out calICalendar aCalendars);
 
 
   /* XXX private, don't use:
          will vanish as soon as providers will directly read/write from moz prefs
   */
--- a/calendar/base/src/calCalendarManager.js
+++ b/calendar/base/src/calCalendarManager.js
@@ -792,16 +792,24 @@ calCalendarManager.prototype = {
             try {
                 calendar.deleteCalendar(calendar, null);
             } catch (e) {
                 Components.utils.reportError("error purging calendar: " + e);
             }
         }
     },
 
+    getCalendarById: function cmgr_getCalendarById(aId) {
+        if (aId in this.mCache) {
+            return this.mCache[aId];
+        } else {
+            return null;
+        }
+    },
+
     getCalendars: function cmgr_getCalendars(count) {
         this.assureCache();
         var calendars = [];
         for each (var calendar in this.mCache) {
             calendars.push(calendar);
         }
         count.value = calendars.length;
         return calendars;