Fix bug 672460 - Event invitation not sent out when Outlook compatiblity is checked. r=mschroeder
authorPhilipp Kewisch <mozilla@kewis.ch>
Thu, 21 Jul 2011 13:28:35 +0300
changeset 8346 2c81a6328404ddbac3258dce05a6933532d7b107
parent 8345 207439d394f904745ab555e374ec8a91ef911d87
child 8347 3fb9f6c5653781ecc09dc1d72942f9c03e63fdec
push idunknown
push userunknown
push dateunknown
reviewersmschroeder
bugs672460
Fix bug 672460 - Event invitation not sent out when Outlook compatiblity is checked. r=mschroeder
calendar/base/content/calendar-management.js
calendar/base/content/calendar-multiday-view.xml
calendar/base/content/calendar-ui-utils.js
calendar/base/content/calendar-views.xml
calendar/base/src/calCalendarManager.js
calendar/base/src/calTimezoneService.js
calendar/itip/calItipEmailTransport.js
calendar/providers/gdata/components/calGoogleUtils.js
calendar/providers/gdata/content/gdata-migration.js
calendar/providers/wcap/calWcapSession.js
--- a/calendar/base/content/calendar-management.js
+++ b/calendar/base/content/calendar-management.js
@@ -32,34 +32,36 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+Components.utils.import("resource://calendar/modules/calUtils.jsm");
+
 /**
  * Get this window's currently selected calendar.
  *
  * @return      The currently selected calendar.
  */
 function getSelectedCalendar() {
-    return getCompositeCalendar().defaultCalendar;
+    return cal.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.
  */
 function promptDeleteCalendar(aCalendar) {
-    let calendars = getCalendarManager().getCalendars({});
+    let calendars = cal.getCalendarManager().getCalendars({});
     if (calendars.length <= 1) {
         // If this is the last calendar, don't delete it.
         return;
     }
 
     let promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
                                   .getService(Components.interfaces.nsIPromptService);
     let ok = promptService.confirm(window,
@@ -76,56 +78,56 @@ 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 = getCompositeCalendar();
+    tree.compositeCalendar = cal.getCompositeCalendar();
 
     // Create the home calendar if no calendar exists.
-    let calendars = getCalendarManager().getCalendars({});
+    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 = getCompositeCalendar();
-    let url = makeURL("moz-storage-calendar://");
+    let composite = cal.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
     // fails, the app may not load.
-    if (getPrefSafe("calendar.migrator.enabled", true)) {
+    if (cal.getPrefSafe("calendar.migrator.enabled", true)) {
         try {
             gDataMigrator.checkAndMigrate();
         } catch (e) {
             Components.utils.reportError("Migrator error: " + e);
         }
     }
 
     return homeCalendar;
 }
 
 /**
  * Called to clean up the calendar manager for a window.
  */
 function unloadCalendarManager() {
-    getCompositeCalendar().setStatusObserver(null, null);
+    cal.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/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -2391,24 +2391,24 @@
                    equalsize="always"/>
         </xul:scrollbox>
       </xul:box>
     </content>
 
     <implementation implements="calICalendarView">
       <constructor><![CDATA[
         // get day start/end hour from prefs and set on the view
-        this.setDayStartEndMinutes(getPrefSafe("calendar.view.daystarthour", 8) * 60,
-                                   getPrefSafe("calendar.view.dayendhour", 17) * 60);
+        this.setDayStartEndMinutes(cal.getPrefSafe("calendar.view.daystarthour", 8) * 60,
+                                   cal.getPrefSafe("calendar.view.dayendhour", 17) * 60);
 
         // initially scroll to the day start hour in the view
         this.scrollToMinute(this.mDayStartMin);
 
         // get visible hours from prefs and set on the view
-        let visibleMinutes = getPrefSafe("calendar.view.visiblehours", 9) * 60;
+        let visibleMinutes = cal.getPrefSafe("calendar.view.visiblehours", 9) * 60;
         this.setVisibleMinutes(visibleMinutes);
 
         var self = this;
         // set the flex attribute at the scrollbox-innerbox
         // (this can be removed, after Bug 343555 is fixed)
         let scrollbox = document.getAnonymousElementByAttribute(
                        this, "anonid", "scrollbox");
         document.getAnonymousElementByAttribute(
@@ -2503,18 +2503,18 @@
       <field name="mDayEndMin">0</field>
       <field name="mVisibleMinutes">9*60</field>
       <field name="mClickedTime">null</field>
 
       <method name="flashAlarm">
         <parameter name="aAlarmItem"/>
         <parameter name="aStop"/>
         <body><![CDATA[
-          var showIndicator = getPrefSafe("calendar.alarms.indicator.show", true);
-          var totaltime = getPrefSafe("calendar.alarms.indicator.totaltime", 3600);
+          var showIndicator = cal.getPrefSafe("calendar.alarms.indicator.show", true);
+          var totaltime = cal.getPrefSafe("calendar.alarms.indicator.totaltime", 3600);
 
           if (!aStop && (!showIndicator || totaltime < 1)) {
             // No need to animate if the indicator should not be shown.
             return;
           }
 
           // Helper function to save some duplicate code
           function setFlashingAttribute(aBox) {
@@ -3543,26 +3543,26 @@
           }
           return this.mVisibleMinutes;
         ]]></body>
       </method>
 
       <method name="zoomIn">
         <parameter name="aLevel"/>
         <body><![CDATA[
-          let visibleHours = getPrefSafe("calendar.view.visiblehours", 9);
+          let visibleHours = cal.getPrefSafe("calendar.view.visiblehours", 9);
           visibleHours += (aLevel || 1);
 
           cal.setPref("calendar.view.visiblehours", Math.min(visibleHours, 24));
         ]]></body>
       </method>
       <method name="zoomOut">
         <parameter name="aLevel"/>
         <body><![CDATA[
-          let visibleHours = getPrefSafe("calendar.view.visiblehours", 9);
+          let visibleHours = cal.getPrefSafe("calendar.view.visiblehours", 9);
           visibleHours -= (aLevel || 1);
 
           cal.setPref("calendar.view.visiblehours", Math.max(1, visibleHours));
         ]]></body>
       </method>
       <method name="zoomReset">
         <body><![CDATA[
           cal.setPref("calendar.view.visiblehours", 9);
--- a/calendar/base/content/calendar-ui-utils.js
+++ b/calendar/base/content/calendar-ui-utils.js
@@ -302,17 +302,17 @@ function sortCalendarArray(calendars) {
 * @param aCalendarToUse        The default-calendar
 * @param aOnCommand            A string that is applied to the "oncommand"
 *                                attribute of each menuitem
 * @return                      The index of the calendar that matches the
 *                                default-calendar. By default 0 is returned.
 */
 function appendCalendarItems(aItem, aCalendarMenuParent, aCalendarToUse, aOnCommand) {
     let calendarToUse = aCalendarToUse || aItem.calendar;
-    let calendars = sortCalendarArray(getCalendarManager().getCalendars({}));
+    let calendars = sortCalendarArray(cal.getCalendarManager().getCalendars({}));
     let indexToSelect = 0;
     let index = -1;
     for (let i = 0; i < calendars.length; ++i) {
         let calendar = calendars[i];
         if (calendar.id == calendarToUse.id ||
             (calendar &&
              isCalendarWritable(calendar) &&
              isItemSupported(aItem, calendar))) {
--- a/calendar/base/content/calendar-views.xml
+++ b/calendar/base/content/calendar-views.xml
@@ -120,49 +120,49 @@
                 ]]></body>
             </method>
         </implementation>
     </binding>
 
     <binding id="calendar-multiweek-view" extends="chrome://calendar/content/calendar-month-view.xml#calendar-month-base-view">
         <implementation implements="calICalendarView">
 	        <constructor><![CDATA[
-                this.mWeeksInView = getPrefSafe("calendar.weeks.inview", 4);
+                this.mWeeksInView = cal.getPrefSafe("calendar.weeks.inview", 4);
             ]]></constructor>
 
             <field name="mWeeksInView">4</field>
 
             <property name="weeksInView">
                 <getter><![CDATA[
                     return this.mWeeksInView;
                 ]]></getter>
                 <setter><![CDATA[
                     this.mWeeksInView = val;
-                    setPref("calendar.weeks.inview", Number(val));
+                    cal.setPref("calendar.weeks.inview", Number(val));
                     this.refreshView();
                     return val;
                 ]]></setter>
             </property>
 
             <property name="supportsZoom" readonly="true"
                       onget="return true;"/>
 
             <method name="zoomIn">
               <parameter name="aLevel"/>
               <body><![CDATA[
-                let visibleWeeks = getPrefSafe("calendar.weeks.inview", 4);
+                let visibleWeeks = cal.getPrefSafe("calendar.weeks.inview", 4);
                 visibleWeeks += (aLevel || 1);
 
                 cal.setPref("calendar.weeks.inview", Math.min(visibleWeeks, 6));
               ]]></body>
             </method>
             <method name="zoomOut">
               <parameter name="aLevel"/>
               <body><![CDATA[
-                let visibleWeeks = getPrefSafe("calendar.weeks.inview", 4);
+                let visibleWeeks = cal.getPrefSafe("calendar.weeks.inview", 4);
                 visibleWeeks -= (aLevel || 1);
 
                 cal.setPref("calendar.weeks.inview", Math.max(visibleWeeks, 2));
               ]]></body>
             </method>
             <method name="zoomReset">
               <body><![CDATA[
                 cal.setPref("calendar.view.visiblehours", 4);
@@ -184,17 +184,17 @@
 
                     aDate = aDate.getInTimezone(this.timezone);
 
                     // Get the first date that should be shown.  This is the
                     // start of the week of the day that we're centering around
                     // adjusted for the day the week starts on and the number
                     // of previous weeks we're supposed to display.
                     let d1 = getWeekInfoService().getStartOfWeek(aDate);
-                    d1.day -= (7 * getPrefSafe("calendar.previousweeks.inview", 0));
+                    d1.day -= (7 * cal.getPrefSafe("calendar.previousweeks.inview", 0));
                     // The last day we're supposed to show
                     let d2 = d1.clone();
                     d2.day += ((7 * this.mWeeksInView) - 1);
                     this.setDateRange(d1,d2);
                     this.selectedDay = aDate;
                 ]]></body>
             </method>
             <method name="moveView">
@@ -204,17 +204,17 @@
                         let date = now();
                         this.goToDay(date);
                         this.selectedDay = date;
                     } else {
                         let d1 = this.startDay.clone();
                         let savedSelectedDay = this.selectedDay.clone();
                         // aNumber only corresponds to the number of weeks to move
                         // make sure to compensate for previous weeks in view too
-                        d1.day += 7 * (aNumber + getPrefSafe("calendar.previousweeks.inview", 4));
+                        d1.day += 7 * (aNumber + cal.getPrefSafe("calendar.previousweeks.inview", 4));
                         this.goToDay(d1);
                         savedSelectedDay.day += 7 * aNumber;
                         this.selectedDay = savedSelectedDay;
                     }
                 ]]></body>
             </method>
         </implementation>
     </binding>
--- a/calendar/base/src/calCalendarManager.js
+++ b/calendar/base/src/calCalendarManager.js
@@ -266,17 +266,17 @@ calCalendarManager.prototype = {
                 // been removed. Calendar servers might still want to know what
                 // client is used for access, so add our UA String to each
                 // request.
                 let httpChannel = aSubject.QueryInterface(Components.interfaces.nsIHttpChannel);
                 try {
                     // NOTE: For some reason, this observer call doesn't have
                     // the "cal" namespace defined
                     let ua = httpChannel.getRequestHeader("User-Agent");
-                    let calUAString = getPrefSafe("calendar.useragent.extra");
+                    let calUAString = cal.getPrefSafe("calendar.useragent.extra");
                     if (calUAString && ua.indexOf(calUAString) < 0) {
                         // User-Agent is not a mergeable header. We need to
                         // merge the user agent ourselves.
                         httpChannel.setRequestHeader("User-Agent",
                                                      ua + " " + calUAString,
                                                      false);
                     }
                 } catch (e if e.result == Components.results.NS_ERROR_NOT_AVAILABLE) {
--- a/calendar/base/src/calTimezoneService.js
+++ b/calendar/base/src/calTimezoneService.js
@@ -343,26 +343,26 @@ calTimezoneService.prototype = {
     },
 
     get version() {
         return this.mVersion;
     },
 
     get defaultTimezone() {
         if (!this.mDefaultTimezone) {
-            var prefTzid = getPrefSafe("calendar.timezone.local", null);
+            var prefTzid = cal.getPrefSafe("calendar.timezone.local", null);
             var tzid = prefTzid;
             if (!tzid) {
                 tzid = guessSystemTimezone();
             }
             this.mDefaultTimezone = this.getTimezone(tzid);
             ASSERT(this.mDefaultTimezone, "Timezone not found: " + tzid);
             // Update prefs if necessary:
             if (this.mDefaultTimezone && this.mDefaultTimezone.tzid != prefTzid) {
-                setPref("calendar.timezone.local", this.mDefaultTimezone.tzid);
+                cal.setPref("calendar.timezone.local", this.mDefaultTimezone.tzid);
             }
 
             // We need to observe the timezone preference to update the default
             // timezone if needed.
             this.setupObservers();
         }
         return this.mDefaultTimezone;
     },
--- a/calendar/itip/calItipEmailTransport.js
+++ b/calendar/itip/calItipEmailTransport.js
@@ -240,17 +240,17 @@ calItipEmailTransport.prototype = {
                                                 cal.calGetString("lightning", "imipSendMail.title", null, "lightning"),
                                                 cal.calGetString("lightning", "imipSendMail.text", null, "lightning"),
                                                 cal.calGetString("lightning", "imipSendMail.Outlook2000CompatMode.text", null, "lightning"),
                                                 inoutCheck)) {
                     break;
                 } // else go on with auto sending for now
                 compatMode = (inoutCheck.value ? 1 : 0);
                 if (compatMode != prefCompatMode) {
-                    setPref("calendar.itip.compatSendMode", compatMode);
+                    cal.setPref("calendar.itip.compatSendMode", compatMode);
                 }
             }
             case (Components.interfaces.calIItipItem.AUTO): {
                 cal.LOG("sendXpcomMail: Found AUTO autoResponse type.");
                 let toList = "";
                 for each (let recipient in aToList) {
                     // Strip leading "mailto:" if it exists.
                     let rId = recipient.id.replace(/^mailto:/i, "");
--- a/calendar/providers/gdata/components/calGoogleUtils.js
+++ b/calendar/providers/gdata/components/calGoogleUtils.js
@@ -67,18 +67,18 @@ var gGoogleSandbox;
  * @param aPrefValue    The Preference value
  *
  * @return              The value of aPrefValue
  *
  * @require aCalendar.googleCalendarName
  */
 function setCalendarPref(aCalendar, aPrefName, aPrefType, aPrefValue) {
 
-    setPref("calendar.google.calPrefs." + aCalendar.googleCalendarName + "." +
-            aPrefName, aPrefValue, aPrefType);
+    cal.setPref("calendar.google.calPrefs." + aCalendar.googleCalendarName + "." +
+                aPrefName, aPrefValue, aPrefType);
 
     return aPrefValue;
 }
 
 /**
  * getCalendarPref
  * Helper to get an independant Calendar Preference, since I cannot use the
  * calendar manager because of early initialization Problems.
@@ -86,18 +86,18 @@ function setCalendarPref(aCalendar, aPre
  * @param aCalendar     The calendar to set the pref for
  * @param aPrefName     The preference name
  *
  * @return              The preference value
  *
  * @require aCalendar.googleCalendarName
  */
 function getCalendarPref(aCalendar, aPrefName) {
-    return getPrefSafe("calendar.google.calPrefs." +
-                       aCalendar.googleCalendarName + "."  + aPrefName);
+    return cal.getPrefSafe("calendar.google.calPrefs." +
+                           aCalendar.googleCalendarName + "."  + aPrefName);
 }
 
 /**
  * getFormattedString
  * Returns the string from the properties file, formatted with args
  *
  * @param aBundleName   The .properties file to access
  * @param aStringName   The property to access
@@ -292,17 +292,17 @@ function ItemToXMLEntry(aItem, aAuthorEm
         status = "CONFIRMED";
     }
     entry.gd::eventStatus.@value = kEVENT_SCHEMA + status.toLowerCase();
 
     // gd:where
     entry.gd::where.@valueString = aItem.getProperty("LOCATION") || "";
 
     // gd:who
-    if (getPrefSafe("calendar.google.enableAttendees", false)) {
+    if (cal.getPrefSafe("calendar.google.enableAttendees", false)) {
         // XXX Only parse attendees if they are enabled, due to bug 407961
 
         var attendees = aItem.getAttendees({});
         if (aItem.organizer) {
             // Taking care of the organizer is the same as taking care of any other
             // attendee. Add the organizer to the local attendees list.
             attendees.push(aItem.organizer);
         }
@@ -352,17 +352,17 @@ function ItemToXMLEntry(aItem, aAuthorEm
             }
 
             entry.gd::who += xmlAttendee;
         }
     }
 
     // Don't notify attendees by default. Use a preference in case the user
     // wants this to be turned on.
-    var notify = getPrefSafe("calendar.google.sendEventNotifications", false);
+    var notify = cal.getPrefSafe("calendar.google.sendEventNotifications", false);
     entry.gCal::sendEventNotifications.@value = (notify ? "true" : "false");
 
     // gd:when
     var duration = aItem.endDate.subtractDate(aItem.startDate);
     if (!aItem.recurrenceInfo) {
         // gd:when isn't allowed for recurring items where gd:recurrence is set
         entry.gd::when.@startTime = cal.toRFC3339(aItem.startDate);
         entry.gd::when.@endTime = cal.toRFC3339(aItem.endDate);
@@ -927,17 +927,17 @@ function XMLEntryToItem(aXMLEntry, aTime
                 }
             }
         }
 
         // gd:where
         item.setProperty("LOCATION",
                          aXMLEntry.gd::where.@valueString.toString());
         // gd:who
-        if (getPrefSafe("calendar.google.enableAttendees", false)) {
+        if (cal.getPrefSafe("calendar.google.enableAttendees", false)) {
             // XXX Only parse attendees if they are enabled, due to bug 407961
 
             // This object can easily translate Google's values to our values.
             const attendeeStatusMap = {
                 // role
                 "event.optional": "OPT-PARTICIPANT",
                 "event.required": "REQ-PARTICIPANT",
 
--- a/calendar/providers/gdata/content/gdata-migration.js
+++ b/calendar/providers/gdata/content/gdata-migration.js
@@ -29,22 +29,24 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+Components.utils.import("resource://calendar/modules/calUtils.jsm");
+
 /**
  * Migrate the calendar selected in the wizard from ics to gdata.
  */
 function migrateSelectedCalendars() {
     var listbox = document.getElementById("calendars-listbox");
-    var calmgr = getCalendarManager();
+    var calmgr = cal.getCalendarManager();
 
     for (var i = 0; i < listbox.childNodes.length; i++) {
         var item = listbox.childNodes[i];
         if (item.checked) {
             // Migrate the calendar to a gdata calendar
             var newCal = calmgr.createCalendar("gdata", item.calendar.uri);
             calmgr.unregisterCalendar(item.calendar);
             calmgr.deleteCalendar(item.calendar);
@@ -64,18 +66,18 @@ function migrateSelectedCalendars() {
             newCal.setProperty("calendar-main-default",
                                item.calendar.getProperty("calendar-main-default"));
 
             calmgr.registerCalendar(newCal);
         }
     }
 
     // Only bring up the dialog on the next startup if the user wants us to.
-    setPref("calendar.google.migrate",
-            document.getElementById("showagain-checkbox").checked);
+    cal.setPref("calendar.google.migrate",
+                document.getElementById("showagain-checkbox").checked);
 }
 
 /**
  * Get all calendars that are ics and point to a google calendar
  *
  * @return An array of calendars that are migratable
  */
 function getMigratableCalendars() {
@@ -104,21 +106,21 @@ function gdata_migration_loader() {
         for each (let calendar in sortCalendarArray(getMigratableCalendars())) {
             let item = listbox.appendItem(calendar.name, calendar.id);
             item.setAttribute("type", "checkbox");
             item.calendar = calendar;
         }
 
         // Set up the "always check" field
         document.getElementById("showagain-checkbox").checked =
-            getPrefSafe("calendar.google.migrate", true);
+            cal.getPrefSafe("calendar.google.migrate", true);
     } else {
         // This is not the migration wizard, so it must be a main window. Check
         // if the migration wizard needs to be shown.
-        if (getPrefSafe("calendar.google.migrate", true)) {
+        if (cal.getPrefSafe("calendar.google.migrate", true)) {
             // Check if there are calendars that are worth migrating.
             if (getMigratableCalendars().length > 0) {
                 // Do this after load, so the calendar window appears before the
                 // wizard is opened.
 
                 // XXX Waiting a second gives the views enough time to display
                 // right, at least on my system. The viewloaded event is quite
                 // view specific, so there is no good non-hacked way to do this.
--- a/calendar/providers/wcap/calWcapSession.js
+++ b/calendar/providers/wcap/calWcapSession.js
@@ -128,17 +128,17 @@ function calWcapSession(contextId) {
     this.wrappedJSObject = this;
     this.m_contextId = contextId;
     this.m_loginQueue = [];
 
     // listen for shutdown, being logged out:
     var observerService = Components.classes["@mozilla.org/observer-service;1"]
                                     .getService(Components.interfaces.nsIObserverService);
     observerService.addObserver(this, "quit-application", false /* don't hold weakly */);
-    getCalendarManager().addObserver(this);
+    cal.getCalendarManager().addObserver(this);
 }
 calWcapSession.prototype = {
     getInterfaces: function ci_wcapSession_getInterfaces(count) {
         const ifaces = [calIWcapSession,
                         calIFreeBusyProvider,
                         calICalendarSearchProvider,
                         Components.interfaces.calITimezoneProvider,
                         Components.interfaces.calICalendarManagerObserver,
@@ -321,17 +321,17 @@ calWcapSession.prototype = {
                 if (outUser.value && !outPW.value) { // lookup pw manager
                     log("looking in pw db for: " + this_.uri.spec, this_);
                     cal.auth.passwordManagerGet(outUser.value, outPW, this_.uri.spec, "wcap login");
                 }
 
                 function promptAndLoginLoop_resp(err, sessionId) {
                     if (checkErrorCode(err, calIWcapErrors.WCAP_LOGIN_FAILED)) {
                         log("prompting for [user/]pw...", this_);
-                        if (cal.auth.getCredentials(calGetString("wcap", "loginDialog.label"),
+                        if (cal.auth.getCredentials(cal.calGetString("wcap", "loginDialog.label"),
                                                     this_.sessionUri.hostPort,
                                                     outUser,
                                                     outPW,
                                                     outSavePW,
                                                     this_.credentials.userId != null)) {
                             this_.login(request, promptAndLoginLoop_resp,
                                         outUser.value, outPW.value);
                         } else {
@@ -395,18 +395,18 @@ calWcapSession.prototype = {
                     }
                     log("login succeeded: " + sessionId, this_);
                 } catch (exc) {
                     err = exc;
                     if (checkErrorCode(err, calIWcapErrors.WCAP_LOGIN_FAILED)) {
                         log("error: " + errorToString(exc), this_); // log login failure
                     } else if (getErrorModule(err) == NS_ERROR_MODULE_NETWORK) {
                         // server seems unavailable:
-                        err = new Components.Exception(calGetString("wcap", "accessingServerFailedError.text",
-                                                                    [this_.sessionUri.hostPort]), exc);
+                        err = new Components.Exception(cal.calGetString("wcap", "accessingServerFailedError.text",
+                                                                        [this_.sessionUri.hostPort]), exc);
                     }
                 }
                 respFunc(err, sessionId);
             },
             this_.sessionUri.spec + "login.wcap?fmt-out=text%2Fcalendar&user=" +
             encodeURIComponent(user) + "&password=" + encodeURIComponent(pw),
             false /* no logging */);
     },
@@ -470,18 +470,18 @@ calWcapSession.prototype = {
                             err = exc;
                         }
                     }
                     if (err) {
                         if (checkErrorCode(err, calIErrors.OPERATION_CANCELLED)) {
                             throw err;
                         } else { // soft error; request denied etc.
                                  // map into localized message:
-                            throw new Components.Exception(calGetString("wcap", "accessingServerFailedError.text",
-                                                                        [this_.sessionUri.hostPort]),
+                            throw new Components.Exception(cal.calGetString("wcap", "accessingServerFailedError.text",
+                                                                            [this_.sessionUri.hostPort]),
                                                            calIWcapErrors.WCAP_LOGIN_FAILED);
                         }
                     }
                     var prop = icalRootComp.getFirstProperty("X-NSCP-WCAPVERSION");
                     if (!prop) {
                         throw new Components.Exception("missing X-NSCP-WCAPVERSION!");
                     }
                     var wcapVersion = parseInt(prop.value);
@@ -490,19 +490,19 @@ calWcapSession.prototype = {
                         var vars = [this_.sessionUri.hostPort];
                         prop = icalRootComp.getFirstProperty("PRODID");
                         vars.push(prop ? prop.value : "<unknown>");
                         prop = icalRootComp.getFirstProperty("X-NSCP-SERVERVERSION");
                         vars.push(prop ? prop.value : "<unknown>");
                         vars.push(strVers);
 
                         var prompt = getWindowWatcher().getNewPrompter(null);
-                        var labelText = calGetString("wcap", "insufficientWcapVersionConfirmation.label");
+                        var labelText = cal.calGetString("wcap", "insufficientWcapVersionConfirmation.label");
                         if (!prompt.confirm(labelText,
-                                            calGetString("wcap", "insufficientWcapVersionConfirmation.text", vars))) {
+                                            cal.calGetString("wcap", "insufficientWcapVersionConfirmation.text", vars))) {
                             throw new Components.Exception(labelText, calIWcapErrors.WCAP_LOGIN_FAILED);
                         }
                     }
 
                 } catch (exc) {
                     err = exc;
                 }
                 respFunc(err);
@@ -562,17 +562,17 @@ calWcapSession.prototype = {
 
                         if (hasSubscriptions) {
                             calprops_resp = function(cal) {
                                 if (cal.isDefaultCalendar) {
                                     // tweak name:
                                     cal.setProperty("name", cal.displayName);
                                 } else {
                                     log("registering subscribed calendar: " + cal.calId, this_);
-                                    getCalendarManager().registerCalendar(cal);
+                                    cal.getCalendarManager().registerCalendar(cal);
                                 }
                             }
                             // do only once:
                             defaultCal.setProperty("subscriptions_registered", true);
                         }
                     }
 
                     if (!defaultCal.getProperty("user_id")) { // nail once:
@@ -862,17 +862,17 @@ calWcapSession.prototype = {
             }
         } catch (exc) {
         }
         return null;
     },
 
     getRegisteredCalendars: function calWcapSession_getRegisteredCalendars(asAssocObj) {
         let registeredCalendars = (asAssocObj ? {} : []);
-        let cals = getCalendarManager().getCalendars({});
+        let cals = cal.getCalendarManager().getCalendars({});
         for each (let calendar in cals) {
             calendar = this.belongsTo(calendar);
             if (calendar) {
                 if (asAssocObj) {
                     registeredCalendars[calendar.calId] = calendar;
                 } else {
                     registeredCalendars.push(calendar);
                 }
@@ -1085,17 +1085,17 @@ calWcapSession.prototype = {
 
     // nsIObserver:
     observe: function calWcapSession_observer(subject, topic, data) {
         log("observing: " + topic + ", data: " + data, this);
         if (topic == "quit-application") {
             g_bShutdown = true;
             this.logout(null);
             // xxx todo: valid upon notification?
-            getCalendarManager().removeObserver(this);
+            cal.getCalendarManager().removeObserver(this);
             var observerService = Components.classes["@mozilla.org/observer-service;1"]
                                             .getService(Components.interfaces.nsIObserverService);
             observerService.removeObserver(this, "quit-application");
         }
     },
 
     // calICalendarManagerObserver:
 
@@ -1142,17 +1142,17 @@ calWcapSession.prototype = {
             cal = this.belongsTo(cal);
             if (cal && cal.isDefaultCalendar) {
                 getFreeBusyService().removeProvider(this);
                 getCalendarSearchService().removeProvider(this);
                 var registeredCalendars = this.getRegisteredCalendars();
                 for each (var regCal in registeredCalendars) {
                     try {
                         if (!regCal.isDefaultCalendar) {
-                            getCalendarManager().unregisterCalendar(regCal);
+                            cal.getCalendarManager().unregisterCalendar(regCal);
                         }
                     } catch (exc) {
                         this.notifyError(exc);
                     }
                 }
             }
         } catch (exc) { // never break the listener chain
             this.notifyError(exc);
@@ -1182,31 +1182,31 @@ function confirmInsecureLogin(uri)
     var encodedHost = encodeURIComponent(host);
     var confirmedEntry = confirmInsecureLogin.m_confirmedHttpLogins[encodedHost];
     if (confirmedEntry) {
         bConfirmed = (confirmedEntry == "1");
     } else {
         var prompt = getWindowWatcher().getNewPrompter(null);
         var out_dontAskAgain = { value: false };
         var bConfirmed = prompt.confirmCheck(
-            calGetString("wcap", "noHttpsConfirmation.label"),
-            calGetString("wcap", "noHttpsConfirmation.text", [host]),
-            calGetString("wcap", "noHttpsConfirmation.check.text"),
+            cal.calGetString("wcap", "noHttpsConfirmation.label"),
+            cal.calGetString("wcap", "noHttpsConfirmation.text", [host]),
+            cal.calGetString("wcap", "noHttpsConfirmation.check.text"),
             out_dontAskAgain);
 
         if (out_dontAskAgain.value) {
             // save decision for all running calendars and
             // all future confirmations:
             var confirmedHttpLogins = getPref("calendar.wcap.confirmed_http_logins", "");
             if (confirmedHttpLogins.length > 0) {
                 confirmedHttpLogins += ",";
             }
             confirmedEntry = (bConfirmed ? "1" : "0");
             confirmedHttpLogins += (encodedHost + ":" + confirmedEntry);
-            setPref("calendar.wcap.confirmed_http_logins", confirmedHttpLogins);
+            cal.setPref("calendar.wcap.confirmed_http_logins", confirmedHttpLogins);
             getPref("calendar.wcap.confirmed_http_logins"); // log written entry
             confirmInsecureLogin.m_confirmedHttpLogins[encodedHost] = confirmedEntry;
         }
     }
 
     log("returned: " + bConfirmed, "confirmInsecureLogin(" + host + ")");
     return bConfirmed;
 }