Fix bug 1186547 - mReadOnly and mDisabled do not reflect readOnly and disabled properties. r=MakeMyDay,a=philipp
authorPhilipp Kewisch <mozilla@kewis.ch>
Wed, 22 Jul 2015 21:00:17 +0200
changeset 22841 c53da8a616fa0edf206fdb45184216ee6699c331
parent 22840 9a718ca3cae10186ae34102d18515a89bf5145fa
child 22842 3638ae3dc946dc1f291f460b322157de31850886
push idunknown
push userunknown
push dateunknown
reviewersMakeMyDay, philipp
bugs1186547
Fix bug 1186547 - mReadOnly and mDisabled do not reflect readOnly and disabled properties. r=MakeMyDay,a=philipp
calendar/providers/caldav/calDavCalendar.js
calendar/providers/caldav/calDavRequestHandlers.js
--- a/calendar/providers/caldav/calDavCalendar.js
+++ b/calendar/providers/caldav/calDavCalendar.js
@@ -50,17 +50,16 @@ function caldavXPathFirst(aNode, aExpr, 
     return cal.xml.evalXPathFirst(aNode, aExpr, caldavNSResolver, aType);
 }
 
 function calDavCalendar() {
     this.initProviderBase();
     this.unmappedProperties = [];
     this.mUriParams = null;
     this.mItemInfoCache = {};
-    this.mDisabled = false;
     this.mCalHomeSet = null;
     this.mInboxUrl = null;
     this.mOutboxUrl = null;
     this.mCalendarUserAddress = null;
     this.mPrincipalUrl = null;
     this.mSenderAddress = null;
     this.mHrefIndex = {};
     this.mAuthScheme = null;
@@ -395,18 +394,16 @@ calDavCalendar.prototype = {
 
     //
     // calICalendar interface
     //
 
     // readonly attribute AUTF8String type;
     get type() { return "caldav"; },
 
-    mDisabled: true,
-
     mCalendarUserAddress: null,
     get calendarUserAddress() {
         return this.mCalendarUserAddress;
     },
 
     mPrincipalUrl: null,
     get principalUrl() {
         return this.mPrincipalUrl;
@@ -1404,17 +1401,17 @@ calDavCalendar.prototype = {
                 return;
             }
 
             if (request.responseStatus == 404) {
                 cal.LOG("CalDAV: Disabling calendar " + thisCalendar.name +
                         " due to 404");
                 notifyListener(Components.results.NS_ERROR_FAILURE);
                 return;
-            } else if (request.responseStatus == 207 && thisCalendar.mDisabled) {
+            } else if (request.responseStatus == 207 && thisCalendar.getProperty("disabled")) {
                 // Looks like the calendar is there again, check its resource
                 // type first.
                 thisCalendar.setupAuthentication(aChangeLogListener);
                 return;
              }
 
             let str = cal.convertByteArray(aResult, aResultLength);
             if (!str) {
@@ -1502,17 +1499,17 @@ calDavCalendar.prototype = {
      * @param aUri                  The uri to request the items from.
      *                                NOTE: This must be the uri without any uri
      *                                     params. They will be appended in this
      *                                     function.
      * @param aChangeLogListener    (optional) The listener to notify for cached
      *                                         calendars.
      */
     getUpdatedItems: function caldav_getUpdatedItems(aUri, aChangeLogListener) {
-        if (this.mDisabled) {
+        if (this.getProperty("disabled")) {
             // check if maybe our calendar has become available
             this.setupAuthentication(aChangeLogListener);
             return;
         }
 
         if (this.mHasWebdavSyncSupport) {
             webDavSync = new webDavSyncHandler(this,aUri,aChangeLogListener);
             webDavSync.doWebDAVSync();
@@ -1877,19 +1874,19 @@ calDavCalendar.prototype = {
                 cal.LOG("CalDAV: " + thisCalendar.name + " points to a DAV resource, but not a CalDAV calendar");
                 thisCalendar.completeCheckServerInfo(aChangeLogListener,
                                                      Components.interfaces.calIErrors.DAV_DAV_NOT_CALDAV);
                 return;
             }
 
             if (resourceType == kDavResourceTypeCalendar) {
                 // If this calendar was previously offline we want to recover
-                if (thisCalendar.mDisabled) {
-                    thisCalendar.mDisabled = false;
-                    thisCalendar.mReadOnly = false;
+                if (thisCalendar.getProperty("disabled")) {
+                    thisCalendar.setProperty("disabled", false);
+                    thisCalendar.readOnly = false;
                 }
                 thisCalendar.setCalHomeSet(true);
                 thisCalendar.checkServerCaps(aChangeLogListener);
             }
 
             // If we get here something must have gone wrong. Abort with a
             // general error to avoid an endless loop.
             thisCalendar.completeCheckServerInfo(aChangeLogListener, Components.results.NS_ERROR_FAILURE);
@@ -2331,18 +2328,18 @@ calDavCalendar.prototype = {
         var localizedMessage;
         var modificationError = mapModification[aErrNo];
 
         if (!message) {
             // Only notify if there is a message for this error
             return;
         }
         localizedMessage = cal.calGetString("calendar", message , [this.mUri.spec]);
-        this.mReadOnly = true;
-        this.mDisabled = true;
+        this.setProperty("disabled", true);
+        this.readOnly = true;
         this.notifyError(aErrNo, localizedMessage);
         this.notifyError(modificationError
                          ? Components.interfaces.calIErrors.MODIFICATION_FAILED
                          : Components.interfaces.calIErrors.READ_FAILED,
                          this.buildDetailedMessage(status, extraInfo));
     },
 
     buildDetailedMessage : function caldav_buildDetailedMessage(status, extraInfo) {
--- a/calendar/providers/caldav/calDavRequestHandlers.js
+++ b/calendar/providers/caldav/calDavRequestHandlers.js
@@ -313,17 +313,17 @@ webDavSyncHandler.prototype = {
     QueryInterface: XPCOMUtils.generateQI([
         Components.interfaces.nsISAXContentHandler,
         Components.interfaces.nsISAXErrorHandler,
         Components.interfaces.nsIRequestObserver,
         Components.interfaces.nsIStreamListener
     ]),
 
     doWebDAVSync: function doWebDAVSync() {
-        if (this.calendar.mDisabled) {
+        if (this.calendar.getProperty("disabled")) {
             // check if maybe our calendar has become available
             this.calendar.setupAuthentication(this.changeLogListener);
             return;
         }
 
 
         let syncTokenString = "<sync-token/>";
         if (this.calendar.mWebdavSyncToken && this.calendar.mWebdavSyncToken.length > 0) {
@@ -685,17 +685,17 @@ multigetSyncHandler.prototype = {
     QueryInterface: XPCOMUtils.generateQI([
         Components.interfaces.nsISAXContentHandler,
         Components.interfaces.nsISAXErrorHandler,
         Components.interfaces.nsIRequestObserver,
         Components.interfaces.nsIStreamListener
     ]),
 
     doMultiGet: function doMultiGet() {
-        if (this.calendar.mDisabled) {
+        if (this.calendar.getProperty("disabled")) {
             // check if maybe our calendar has become available
             this.calendar.setupAuthentication(this.changeLogListener);
             return;
         }
 
         let batchSize = Preferences.get("calendar.caldav.multigetBatchSize", 100);
         let hrefString = "";
         while (this.itemsNeedFetching.length && batchSize > 0) {