Bustage fix for bug 672460 - Event invitation not sent out when Outlook compatiblity is checked.
authorPhilipp Kewisch <mozilla@kewis.ch>
Wed, 27 Jul 2011 18:35:18 +0200
changeset 8353 6d732f363f2e25dcb4320d4436fda314b88e8aae
parent 8352 b088d2fbc44e18c129a0ae9b5370949b18cafda3
child 8354 60e9603ad9dffdf47168f4916598a22f4447d818
push idunknown
push userunknown
push dateunknown
bugs672460
Bustage fix for bug 672460 - Event invitation not sent out when Outlook compatiblity is checked.
calendar/base/content/calendar-management.js
calendar/base/src/calUtils.js
--- a/calendar/base/content/calendar-management.js
+++ b/calendar/base/content/calendar-management.js
@@ -40,17 +40,17 @@
 Components.utils.import("resource://calendar/modules/calUtils.jsm");
 
 /**
  * Get this window's currently selected calendar.
  *
  * @return      The currently selected calendar.
  */
 function getSelectedCalendar() {
-    return cal.getCompositeCalendar().defaultCalendar;
+    return getCompositeCalendar().defaultCalendar;
 }
 
 /**
  * Deletes the passed calendar, prompting the user if he really wants to do
  * this. If there is only one calendar left, no calendar is removed and the user
  * is not prompted.
  *
  * @param aCalendar     The calendar to delete.
@@ -78,31 +78,31 @@ function promptDeleteCalendar(aCalendar)
 }
 
 /**
  * Called to initialize the calendar manager for a window.
  */
 function loadCalendarManager() {
     // Set up the composite calendar in the calendar list widget.
     let tree = document.getElementById("calendar-list-tree-widget");
-    tree.compositeCalendar = cal.getCompositeCalendar();
+    tree.compositeCalendar = getCompositeCalendar();
 
     // Create the home calendar if no calendar exists.
     let calendars = cal.getCalendarManager().getCalendars({});
     if (!calendars.length) {
         initHomeCalendar();
     }
 }
 
 /**
  * Creates the initial "Home" calendar if no calendar exists.
  */
 function initHomeCalendar() {
     let calMgr = cal.getCalendarManager();
-    let composite = cal.getCompositeCalendar();
+    let composite = getCompositeCalendar();
     let url = cal.makeURL("moz-storage-calendar://");
     let homeCalendar = calMgr.createCalendar("storage", url);
     homeCalendar.name = calGetString("calendar", "homeCalendarName");
     calMgr.registerCalendar(homeCalendar);
     cal.setPref("calendar.list.sortOrder", homeCalendar.id);
     composite.addCalendar(homeCalendar);
 
     // Wrapping this in a try/catch block, as if any of the migration code
@@ -117,17 +117,17 @@ function initHomeCalendar() {
 
     return homeCalendar;
 }
 
 /**
  * Called to clean up the calendar manager for a window.
  */
 function unloadCalendarManager() {
-    cal.getCompositeCalendar().setStatusObserver(null, null);
+    getCompositeCalendar().setStatusObserver(null, null);
 }
 
 /**
  * Updates the sort order preference based on the given event. The event is a
  * "SortOrderChanged" event, emitted from the calendar-list-tree binding. You
  * can also pass in an object like { sortOrder: "Space separated calendar ids" }
  *
  * @param event     The SortOrderChanged event described above.
--- a/calendar/base/src/calUtils.js
+++ b/calendar/base/src/calUtils.js
@@ -1866,16 +1866,25 @@ function binaryInsert(itemArray, item, c
                 comptor(itemArray[Math.min(newIndex, itemArray.length - 1)], item) != 0) {
         // Only add the item if duplicates should not be discarded, or if
         // they should and itemArray[newIndex] == item.
         itemArray.splice(newIndex, 0, item);
     }
     return newIndex;
 }
 
+/**
+ * Gets the cached instance of the composite calendar.
+ *
+ * WARNING: Great care should be taken how this function is called. If it is
+ * called as "cal.getCompositeCalendar()" then it is called through calUtils.jsm
+ * which means there will be one instance per app. If called as
+ * "getCompositeCalendar()" from chrome code, then it will get a window-specific
+ * composite calendar, which is often what is wanted
+ */
 function getCompositeCalendar() {
     if (getCompositeCalendar.mObject === undefined) {
         getCompositeCalendar.mObject = Components.classes["@mozilla.org/calendar/calendar;1?type=composite"]
                                                  .createInstance(Components.interfaces.calICompositeCalendar);
         getCompositeCalendar.mObject.prefPrefix = 'calendar-main';
 
         try {
             if (gCalendarStatusFeedback) {