Bug 392561 â Need to revise provider error notifications; r=philipp
git-svn-id: svn://10.0.0.236/trunk@252604 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -120,18 +120,19 @@ interface calICalendar : nsISupports
|
||||
*
|
||||
* Currently known properties are:
|
||||
* [boolean] calendar-main-in-composite
|
||||
* [string] name
|
||||
* [boolean] readOnly
|
||||
* [boolean] requiresNetwork If false, the calendar does not require
|
||||
* network access at all. This is mainy used
|
||||
* as a UI hint.
|
||||
* [boolean] suppressAlarms If true, alarms of this calendar are not minded.
|
||||
* [boolean] cache.supported If true, the calendar should to be cached,
|
||||
* [string] name
|
||||
* [boolean] readOnly
|
||||
* [boolean] requiresNetwork If false, the calendar does not require
|
||||
* network access at all. This is mainy used
|
||||
* as a UI hint.
|
||||
* [boolean] suppressAlarms If true, alarms of this calendar are not minded.
|
||||
* [boolean] cache.supported If true, the calendar should to be cached,
|
||||
* e.g. this generally applies to network calendars;
|
||||
* default is true (if not present).
|
||||
* [boolean] cache.enabled If true, the calendar is cached; default is false.
|
||||
* [string] itip.transportType If the provider implements a custom calIItipTransport
|
||||
* this is the "type" used in the contract id.
|
||||
* [boolean] cache.enabled If true, the calendar is cached; default is false.
|
||||
* [string] itip.transportType If the provider implements a custom calIItipTransport
|
||||
* this is the "type" used in the contract id.
|
||||
* [nsresult] currentStatus The current error status of the calendar (transient).
|
||||
*
|
||||
* The following calendar capabilities can be used to inform the UI or backend
|
||||
* that certain features are not supported. If not otherwise mentioned, not
|
||||
|
||||
@@ -98,6 +98,16 @@ interface calIErrors : nsISupports
|
||||
*/
|
||||
const unsigned long STORAGE_UNKNOWN_TIMEZONES_ERROR = ERROR_BASE + 8;
|
||||
|
||||
/**
|
||||
* The calendar could not be accessed for reading.
|
||||
*/
|
||||
const unsigned long READ_FAILED = ERROR_BASE + 9;
|
||||
|
||||
/**
|
||||
* The calendar could not be accessed for modification.
|
||||
*/
|
||||
const unsigned long MODIFICATION_FAILED = ERROR_BASE + 10;
|
||||
|
||||
/* ICS specific errors */
|
||||
const unsigned long ICS_ERROR_BASE = ERROR_BASE + 0x100;
|
||||
|
||||
|
||||
@@ -898,6 +898,13 @@ calMgrCalendarObserver.prototype = {
|
||||
// Error announcer specific functions
|
||||
|
||||
announceError: function(aErrNo, aMessage) {
|
||||
// XXX swallow MODIFICATION_FAILED and READ_FAILED for now unless Berend has finished his work...
|
||||
switch (aErrNo) {
|
||||
case Components.interfaces.calIErrors.READ_FAILED:
|
||||
case Components.interfaces.calIErrors.MODIFICATION_FAILED:
|
||||
return;
|
||||
}
|
||||
|
||||
var paramBlock = Components.classes["@mozilla.org/embedcomp/dialogparam;1"]
|
||||
.createInstance(Components.interfaces.nsIDialogParamBlock);
|
||||
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
||||
|
||||
@@ -55,6 +55,7 @@ calProviderBase.prototype = {
|
||||
this.wrappedJSObject = this;
|
||||
this.mObservers = new calListenerBag(Components.interfaces.calIObserver);
|
||||
this.mProperties = {};
|
||||
this.mProperties.currentStatus = Components.results.NS_OK;
|
||||
},
|
||||
|
||||
get observers() {
|
||||
@@ -148,12 +149,61 @@ calProviderBase.prototype = {
|
||||
this.mObservers.notify("onEndBatch");
|
||||
},
|
||||
|
||||
mTransientProperties: {
|
||||
currentStatus: true
|
||||
},
|
||||
|
||||
notifyOperationComplete: function cPB_notifyOperationComplete(aListener,
|
||||
aStatus,
|
||||
aOperationType,
|
||||
aId,
|
||||
aDetail) {
|
||||
if (aListener) {
|
||||
try {
|
||||
aListener.onOperationComplete(this.superCalendar, aStatus, aOperationType, aId, aDetail);
|
||||
} catch (exc) {
|
||||
ERROR(exc);
|
||||
}
|
||||
}
|
||||
if (aStatus == Components.interfaces.calIErrors.OPERATION_CANCELLED) {
|
||||
return; // cancellation doesn't change current status, no notification
|
||||
}
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
this.setProperty("currentStatus", aStatus);
|
||||
} else {
|
||||
if (aDetail instanceof Components.interfaces.nsIException) {
|
||||
this.notifyError(aDetail); // will set currentStatus
|
||||
} else {
|
||||
this.notifyError(aStatus, aDetail); // will set currentStatus
|
||||
}
|
||||
this.notifyError(aOperationType == Components.interfaces.calIOperationListener.GET
|
||||
? Components.interfaces.calIErrors.READ_FAILED
|
||||
: Components.interfaces.calIErrors.MODIFICATION_FAILED,
|
||||
"");
|
||||
}
|
||||
},
|
||||
|
||||
// for convenience also callable with just an exception
|
||||
notifyError: function cPB_notifyError(aErrNo, aMessage) {
|
||||
if (aErrNo == Components.interfaces.calIErrors.OPERATION_CANCELLED) {
|
||||
return; // cancellation doesn't change current status, no notification
|
||||
}
|
||||
if (aErrNo instanceof Components.interfaces.nsIException) {
|
||||
if (!aMessage) {
|
||||
aMessage = aErrNo.message;
|
||||
}
|
||||
aErrNo = aErrNo.result;
|
||||
}
|
||||
this.setProperty("currentStatus", aErrNo);
|
||||
this.observers.notify("onError", [this.superCalendar, aErrNo, aMessage]);
|
||||
},
|
||||
|
||||
// nsIVariant getProperty(in AUTF8String aName);
|
||||
getProperty: function cPB_getProperty(aName) {
|
||||
var ret = this.mProperties[aName];
|
||||
if (ret === undefined) {
|
||||
ret = null;
|
||||
if (this.id) {
|
||||
if (!this.mTransientProperties[aName] && this.id) {
|
||||
// xxx future: return getPrefSafe("calendars." + this.id + "." + aName, null);
|
||||
ret = getCalendarManager().getCalendarPref_(this, aName);
|
||||
if (ret !== null) {
|
||||
@@ -193,7 +243,7 @@ calProviderBase.prototype = {
|
||||
var oldValue = this.getProperty(aName);
|
||||
if (oldValue != aValue) {
|
||||
this.mProperties[aName] = aValue;
|
||||
if (this.id) {
|
||||
if (!this.mTransientProperties[aName] && this.id) {
|
||||
var v = aValue;
|
||||
// xxx todo: work around value types here unless we save into the prefs...
|
||||
switch (aName) {
|
||||
|
||||
@@ -360,12 +360,11 @@ calDavCalendar.prototype = {
|
||||
}
|
||||
|
||||
if (aItem.id == null) {
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.ADD,
|
||||
aItem.id,
|
||||
"Can't set ID on non-mutable item to addItem");
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.ADD,
|
||||
aItem.id,
|
||||
"Can't set ID on non-mutable item to addItem");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -415,7 +414,7 @@ calDavCalendar.prototype = {
|
||||
}
|
||||
LOG("CalDAV: Unexpected status adding item: " + status);
|
||||
thisCalendar.reportDavError(Components.interfaces.calIErrors.DAV_PUT_ERROR,
|
||||
"itemPutError");
|
||||
"itemPutError", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,22 +465,11 @@ calDavCalendar.prototype = {
|
||||
doModifyItem: function caldavMI(aNewItem, aOldItem, aListener, aIgnoreEtag) {
|
||||
|
||||
if (aNewItem.id == null) {
|
||||
|
||||
// XXXYYY fix to match iface spec
|
||||
// this is definitely an error
|
||||
if (aListener) {
|
||||
try {
|
||||
aListener.onOperationComplete(this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.MODIFY,
|
||||
aItem.id,
|
||||
"ID for modifyItem doesn't exist or is null");
|
||||
} catch (ex) {
|
||||
LOG("CalDAV: modifyItem's onOperationComplete threw an"
|
||||
+ " exception " + ex + "; ignoring");
|
||||
}
|
||||
}
|
||||
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
aItem.id,
|
||||
"ID for modifyItem doesn't exist or is null");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -528,7 +516,7 @@ calDavCalendar.prototype = {
|
||||
}
|
||||
LOG("CalDAV: Unexpected status on modifying item: " + status);
|
||||
thisCalendar.reportDavError(Components.interfaces.calIErrors.DAV_PUT_ERROR,
|
||||
"itemPutError");
|
||||
"itemPutError", true);
|
||||
|
||||
retVal = Components.results.NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -579,12 +567,11 @@ calDavCalendar.prototype = {
|
||||
doDeleteItem: function caldavDDI(aItem, aListener, aIgnoreEtag) {
|
||||
|
||||
if (aItem.id == null) {
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.DELETE,
|
||||
aItem.id,
|
||||
"ID doesn't exist for deleteItem");
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
aItem.id,
|
||||
"ID doesn't exist for deleteItem");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -633,7 +620,7 @@ calDavCalendar.prototype = {
|
||||
} else {
|
||||
LOG("CalDAV: Unexpected status deleting item: " + status);
|
||||
thisCalendar.reportDavError(Components.interfaces.calIErrors.DAV_REMOVE_ERROR,
|
||||
"itemDeleteError");
|
||||
"itemDeleteError", true);
|
||||
retVal = Components.results.NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -682,13 +669,11 @@ calDavCalendar.prototype = {
|
||||
getUpdatedItem: function caldavGUI(aItem, aListener) {
|
||||
|
||||
if (aItem == null) {
|
||||
if (aListener) {
|
||||
aListener.onOperationComplete(this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.GET,
|
||||
null,
|
||||
"passed in null item");
|
||||
}
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
"passed in null item");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -868,7 +853,7 @@ calDavCalendar.prototype = {
|
||||
}
|
||||
}
|
||||
} catch (ex) {
|
||||
thisCalendar.mObservers.notify("onError", [thisCalendar.superCalendar, ex.result, ex.toString()]);
|
||||
thisCalendar.notifyError(ex.result, ex.toString());
|
||||
}
|
||||
subComp = calComp.getNextSubcomponent("ANY");
|
||||
}
|
||||
@@ -1122,7 +1107,7 @@ calDavCalendar.prototype = {
|
||||
}
|
||||
|
||||
etagListener.onOperationComplete = function(aStatusCode, aResource,
|
||||
aOperation, aClosure) {
|
||||
aOperation, aClosure) {
|
||||
aRefreshEvent.queryStatuses.push(aStatusCode);
|
||||
var needsRefresh = false;
|
||||
if (aRefreshEvent.queryStatuses.length == aRefreshEvent.typesCount) {
|
||||
@@ -1136,7 +1121,7 @@ calDavCalendar.prototype = {
|
||||
}
|
||||
if (badFetch) {
|
||||
thisCalendar.reportDavError(Components.interfaces.calIErrors.DAV_REPORT_ERROR,
|
||||
"disabledMode");
|
||||
"disabledMode");
|
||||
return;
|
||||
}
|
||||
// if an item has been deleted from the server, delete it here too
|
||||
@@ -1239,42 +1224,6 @@ calDavCalendar.prototype = {
|
||||
// Helper functions
|
||||
//
|
||||
|
||||
// Unless an error number is in this array, we consider it very bad, set
|
||||
// the calendar to readOnly, and give up.
|
||||
acceptableErrorNums: [],
|
||||
|
||||
onError: function caldav_onError(aCalendar, aErrNo, aMessage) {
|
||||
var errorIsOk = false;
|
||||
for each (num in this.acceptableErrorNums) {
|
||||
if (num == aErrNo) {
|
||||
errorIsOk = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!errorIsOk) {
|
||||
this.mReadOnly = true;
|
||||
this.mDisabled = true;
|
||||
}
|
||||
|
||||
var paramBlock = Components.classes["@mozilla.org/embedcomp/dialogparam;1"]
|
||||
.createInstance(Components.interfaces
|
||||
.nsIDialogParamBlock);
|
||||
paramBlock.SetNumberStrings(3);
|
||||
|
||||
var promptMessage = calGetString("calendar", "disabledMode", [this.name]);
|
||||
paramBlock.SetString(0, promptMessage);
|
||||
var errCode = "0x"+aErrNo.toString(16);
|
||||
paramBlock.SetString(1, errCode);
|
||||
paramBlock.SetString(2, aMessage);
|
||||
var wWatcher = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||
.getService(Components.interfaces.nsIWindowWatcher);
|
||||
wWatcher.openWindow(null,
|
||||
"chrome://calendar/content/calErrorPrompt.xul",
|
||||
"_blank",
|
||||
"chrome,dialog=yes",
|
||||
paramBlock);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks that the calendar URI exists and is a CalDAV calendar
|
||||
*
|
||||
@@ -1402,8 +1351,15 @@ calDavCalendar.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
reportDavError: function caldav_rDE(aErrNo, aMessage) {
|
||||
this.onError(this.superCalendar, aErrNo, calGetString("calendar", aMessage, [this.mUri.spec]));
|
||||
reportDavError: function caldav_rDE(aErrNo, aMessage, modificationError) {
|
||||
this.mReadOnly = true;
|
||||
this.mDisabled = true;
|
||||
this.notifyError(aErrNo,
|
||||
calGetString("calendar", aMessage, [this.mUri.spec]));
|
||||
this.notifyError(modificationError
|
||||
? Components.interfaces.calIErrors.MODIFICATION_FAILED
|
||||
: Components.interfaces.calIErrors.READ_FAILED,
|
||||
"");
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -2018,21 +1974,9 @@ calDavObserver.prototype = {
|
||||
this.mCalendar.observers.notify("onPropertyDeleting", [aCalendar, aName]);
|
||||
},
|
||||
|
||||
// Unless an error number is in this array, we consider it very bad, set
|
||||
// the calendar to readOnly, and give up.
|
||||
acceptableErrorNums: [],
|
||||
|
||||
onError: function(aCalendar, aErrNo, aMessage) {
|
||||
var errorIsOk = false;
|
||||
for each (num in this.acceptableErrorNums) {
|
||||
if (num == aErrNo) {
|
||||
errorIsOk = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!errorIsOk)
|
||||
this.mCalendar.readOnly = true;
|
||||
this.mCalendar.observers.notify("onError", [this.mCalendar.superCalendar, aErrNo, aMessage]);
|
||||
this.mCalendar.readOnly = true;
|
||||
this.mCalendar.notifyError(aErrNo, aMessage);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joey Minta <jminta@gmail.com>
|
||||
* Daniel Boelzle <daniel.boelzle@sun.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@@ -315,16 +316,13 @@ calGoogleCalendar.prototype = {
|
||||
// notify the user. This can come from above or from
|
||||
// mSession.addItem which checks for the editURI
|
||||
this.readOnly = true;
|
||||
this.mObservers.notify("onError", [this.superCalendar, e.result, e.message]);
|
||||
}
|
||||
|
||||
if (aListener != null) {
|
||||
aListener.onOperationComplete(this.superCalendar,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.ADD,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
this.notifyOperationComplete(aListener,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.ADD,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -354,13 +352,11 @@ calGoogleCalendar.prototype = {
|
||||
LOG("Not requesting item modification for " + aOldItem.id +
|
||||
"(" + aOldItem.title + "), relevant fields match");
|
||||
|
||||
if (aListener != null) {
|
||||
aListener.onOperationComplete(this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
aNewItem.id,
|
||||
aNewItem);
|
||||
}
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
aNewItem.id,
|
||||
aNewItem);
|
||||
this.mObservers.notify("onModifyItem", [aNewItem, aOldItem]);
|
||||
return null;
|
||||
}
|
||||
@@ -412,16 +408,13 @@ calGoogleCalendar.prototype = {
|
||||
// notify the user. This can come from above or from
|
||||
// mSession.modifyItem which checks for the editURI
|
||||
this.readOnly = true;
|
||||
this.mObservers.notify("onError", [this.superCalendar, e.result, e.message]);
|
||||
}
|
||||
|
||||
if (aListener != null) {
|
||||
aListener.onOperationComplete(this.superCalendar,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
this.notifyOperationComplete(aListener,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -467,16 +460,13 @@ calGoogleCalendar.prototype = {
|
||||
// notify the user. This can come from above or from
|
||||
// mSession.deleteItem which checks for the editURI
|
||||
this.readOnly = true;
|
||||
this.mObservers.notify("onError", [this.superCalendar, e.result, e.message]);
|
||||
}
|
||||
|
||||
if (aListener != null) {
|
||||
aListener.onOperationComplete(this.superCalendar,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
this.notifyOperationComplete(aListener,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -518,13 +508,11 @@ calGoogleCalendar.prototype = {
|
||||
} catch (e) {
|
||||
LOG("getItem failed before request " + aId + "):\n" + e);
|
||||
|
||||
if (aListener != null) {
|
||||
aListener.onOperationComplete(this.superCalendar,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
this.notifyOperationComplete(aListener,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -547,7 +535,7 @@ calGoogleCalendar.prototype = {
|
||||
|
||||
// check if events are wanted
|
||||
if (!wantEvents && !wantTodos) {
|
||||
// Nothing to do. The onOperationComplete in the catch block
|
||||
// Nothing to do. The notifyOperationComplete in the catch block
|
||||
// below will catch this.
|
||||
throw new Components.Exception("", Components.results.NS_OK);
|
||||
} else if (wantTodos && !wantEvents) {
|
||||
@@ -599,13 +587,11 @@ calGoogleCalendar.prototype = {
|
||||
this.session.asyncItemRequest(request);
|
||||
return request;
|
||||
} catch (e) {
|
||||
if (aListener != null) {
|
||||
aListener.onOperationComplete(this.superCalendar,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
this.notifyOperationComplete(aListener,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -680,29 +666,23 @@ calGoogleCalendar.prototype = {
|
||||
}
|
||||
|
||||
// All operations need to call onOperationComplete
|
||||
if (aOperation.operationListener) {
|
||||
LOG("Deleting item " + aOperation.oldItem.id +
|
||||
" successful");
|
||||
|
||||
aOperation.operationListener.onOperationComplete(this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
aOperation.oldItem.id,
|
||||
aOperation.oldItem);
|
||||
}
|
||||
LOG("Deleting item " + aOperation.oldItem.id + " successful");
|
||||
this.notifyOperationComplete(aOperation.operationListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
aOperation.oldItem.id,
|
||||
aOperation.oldItem);
|
||||
|
||||
// Notify Observers
|
||||
this.mObservers.notify("onDeleteItem", [aOperation.oldItem]);
|
||||
} catch (e) {
|
||||
LOG("Deleting item " + aOperation.oldItem.id + " failed");
|
||||
// Operation failed
|
||||
if (aOperation.operationListener) {
|
||||
aOperation.operationListener.onOperationComplete(this.superCalendar,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
this.notifyOperationComplete(aOperation.operationListener,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -780,11 +760,11 @@ calGoogleCalendar.prototype = {
|
||||
null,
|
||||
1,
|
||||
[item]);
|
||||
aOperation.operationListener.onOperationComplete(this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
item.id,
|
||||
null);
|
||||
this.notifyOperationComplete(aOperation.operationListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
item.id,
|
||||
null);
|
||||
} catch (e) {
|
||||
if (!Components.isSuccessCode(e.result) && e.message != "Item not found") {
|
||||
// Not finding an item isn't a user-important error, it may be a
|
||||
@@ -792,11 +772,11 @@ calGoogleCalendar.prototype = {
|
||||
LOG("Error getting item " + aOperation.itemId + ":\n" + e);
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
aOperation.operationListener.onOperationComplete(this.superCalendar,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
e.message);
|
||||
this.notifyOperationComplete(aOperation.operationListener,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -906,14 +886,14 @@ calGoogleCalendar.prototype = {
|
||||
expandedItems);
|
||||
}
|
||||
// Operation Completed successfully.
|
||||
listener.onOperationComplete(this.superCalendar,
|
||||
this.notifyOperationComplete(listener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
null);
|
||||
} catch (e) {
|
||||
LOG("Error getting items:\n" + e);
|
||||
listener.onOperationComplete(this.superCalendar,
|
||||
this.notifyOperationComplete(listener,
|
||||
e.result,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
@@ -975,14 +955,11 @@ calGoogleCalendar.prototype = {
|
||||
// All operations need to call onOperationComplete
|
||||
// calIGoogleRequest's type corresponds to calIOperationListener's
|
||||
// constants, so we can use them here.
|
||||
if (aOperation.operationListener) {
|
||||
aOperation.operationListener
|
||||
.onOperationComplete(this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aOperation.type,
|
||||
(item ? item.id : null),
|
||||
item);
|
||||
}
|
||||
this.notifyOperationComplete(aOperation.operationListener
|
||||
Components.results.NS_OK,
|
||||
aOperation.type,
|
||||
(item ? item.id : null),
|
||||
item);
|
||||
return item;
|
||||
} catch (e) {
|
||||
LOG("General response failed: " + e);
|
||||
@@ -991,18 +968,14 @@ calGoogleCalendar.prototype = {
|
||||
// The calendar is readonly, make sure this is set and
|
||||
// notify the user.
|
||||
this.readOnly = true;
|
||||
this.mObservers.notify("onError", [this.superCalendar, e.result, e.message]);
|
||||
}
|
||||
|
||||
// Operation failed
|
||||
if (aOperation.operationListener) {
|
||||
aOperation.operationListener
|
||||
.onOperationComplete(this.superCalendar,
|
||||
e.result,
|
||||
aOperation.type,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
this.notifyOperationComplete(aOperation.operationListener
|
||||
e.result,
|
||||
aOperation.type,
|
||||
null,
|
||||
e.message);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
* Dan Mosedale <dan.mosedale@oracle.com>
|
||||
* Joey Minta <jminta@gmail.com>
|
||||
* Philipp Kewisch <mozilla@kewis.ch>
|
||||
* Daniel Boelzle <daniel.boelzle@sun.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@@ -225,6 +226,7 @@ calICSCalendar.prototype = {
|
||||
str = unicodeConverter.convertFromByteArray(result, result.length);
|
||||
} catch(e) {
|
||||
this.mObserver.onError(this.superCalendar, calIErrors.CAL_UTF8_DECODING_FAILED, e.toString());
|
||||
this.mObserver.onError(this.superCalendar, calIErrors.READ_FAILED, "");
|
||||
this.unlock();
|
||||
return;
|
||||
}
|
||||
@@ -256,6 +258,7 @@ calICSCalendar.prototype = {
|
||||
} catch(e) {
|
||||
LOG("Parsing the file failed:"+e);
|
||||
this.mObserver.onError(this.superCalendar, e.result, e.toString());
|
||||
this.mObserver.onError(this.superCalendar, calIErrors.READ_FAILED, "");
|
||||
}
|
||||
this.mObserver.onEndBatch();
|
||||
this.mObserver.onLoad(this);
|
||||
@@ -323,10 +326,10 @@ calICSCalendar.prototype = {
|
||||
if (inLastWindowClosingSurvivalArea) {
|
||||
appStartup.exitLastWindowClosingSurvivalArea();
|
||||
}
|
||||
savedthis.mObserver.onError(
|
||||
this.superCalendar,
|
||||
ex.result, "The calendar could not be saved; there " +
|
||||
"was a failure: 0x" + ex.result.toString(16));
|
||||
savedthis.mObserver.onError(savedthis.superCalendar,
|
||||
ex.result, "The calendar could not be saved; there " +
|
||||
"was a failure: 0x" + ex.result.toString(16));
|
||||
savedthis.mObserver.onError(savedthis.superCalendar, calIErrors.MODIFICATION_FAILED, "");
|
||||
savedthis.unlock();
|
||||
}
|
||||
},
|
||||
@@ -371,18 +374,13 @@ calICSCalendar.prototype = {
|
||||
} catch(e) {
|
||||
}
|
||||
|
||||
if (channel && !channel.requestSucceeded) {
|
||||
ctxt.mObserver.onError(this.superCalendar,
|
||||
channel.requestSucceeded,
|
||||
"Publishing the calendar file failed\n" +
|
||||
"Status code: "+channel.responseStatus+": "+channel.responseStatusText+"\n");
|
||||
}
|
||||
|
||||
else if (!channel && !Components.isSuccessCode(request.status)) {
|
||||
if ((channel && !channel.requestSucceeded) ||
|
||||
(!channel && !Components.isSuccessCode(request.status))) {
|
||||
ctxt.mObserver.onError(this.superCalendar,
|
||||
request.status,
|
||||
"Publishing the calendar file failed\n" +
|
||||
"Status code: "+request.status.toString(16)+"\n");
|
||||
ctxt.mObserver.onError(this.superCalendar, calIErrors.MODIFICATION_FAILED, "");
|
||||
}
|
||||
|
||||
// Allow the hook to grab data of the channel, like the new etag
|
||||
@@ -402,14 +400,14 @@ calICSCalendar.prototype = {
|
||||
},
|
||||
adoptItem: function (aItem, aListener) {
|
||||
if (this.readOnly)
|
||||
throw Components.interfaces.calIErrors.CAL_IS_READONLY;
|
||||
throw calIErrors.CAL_IS_READONLY;
|
||||
this.queue.push({action:'add', item:aItem, listener:aListener});
|
||||
this.processQueue();
|
||||
},
|
||||
|
||||
modifyItem: function (aNewItem, aOldItem, aListener) {
|
||||
if (this.readOnly)
|
||||
throw Components.interfaces.calIErrors.CAL_IS_READONLY;
|
||||
throw calIErrors.CAL_IS_READONLY;
|
||||
this.queue.push({action:'modify', oldItem: aOldItem,
|
||||
newItem: aNewItem, listener:aListener});
|
||||
this.processQueue();
|
||||
@@ -417,7 +415,7 @@ calICSCalendar.prototype = {
|
||||
|
||||
deleteItem: function (aItem, aListener) {
|
||||
if (this.readOnly)
|
||||
throw Components.interfaces.calIErrors.CAL_IS_READONLY;
|
||||
throw calIErrors.CAL_IS_READONLY;
|
||||
this.queue.push({action:'delete', item:aItem, listener:aListener});
|
||||
this.processQueue();
|
||||
},
|
||||
@@ -773,21 +771,9 @@ calICSObserver.prototype = {
|
||||
this.mCalendar.observers.notify("onPropertyDeleting", [aCalendar, aName]);
|
||||
},
|
||||
|
||||
// Unless an error number is in this array, we consider it very bad, set
|
||||
// the calendar to readOnly, and give up.
|
||||
acceptableErrorNums: [],
|
||||
|
||||
onError: function(aCalendar, aErrNo, aMessage) {
|
||||
var errorIsOk = false;
|
||||
for each (num in this.acceptableErrorNums) {
|
||||
if (num == aErrNo) {
|
||||
errorIsOk = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!errorIsOk)
|
||||
this.mCalendar.readOnly = true;
|
||||
this.mCalendar.observers.notify("onError", [this.mCalendar.superCalendar, aErrNo, aMessage]);
|
||||
this.mCalendar.readOnly = true;
|
||||
this.mCalendar.notifyError(aErrNo, aMessage);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -128,12 +128,11 @@ calMemoryCalendar.prototype = {
|
||||
aItem.id = getUUID();
|
||||
|
||||
if (aItem.id == null) {
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.ADD,
|
||||
aItem.id,
|
||||
"Can't set ID on non-mutable item to addItem");
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.ADD,
|
||||
aItem.id,
|
||||
"Can't set ID on non-mutable item to addItem");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -141,15 +140,12 @@ calMemoryCalendar.prototype = {
|
||||
if (this.relaxedMode) {
|
||||
// we possibly want to interact with the user before deleting
|
||||
delete this.mItems[aItem.id];
|
||||
}
|
||||
else {
|
||||
if (aListener) {
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.interfaces.calIErrors.DUPLICATE_ID,
|
||||
aListener.ADD,
|
||||
aItem.id,
|
||||
"ID already exists for addItem");
|
||||
}
|
||||
} else {
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.interfaces.calIErrors.DUPLICATE_ID,
|
||||
Components.interfaces.calIOperationListener.ADD,
|
||||
aItem.id,
|
||||
"ID already exists for addItem");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -160,12 +156,11 @@ calMemoryCalendar.prototype = {
|
||||
this.mItems[aItem.id] = aItem;
|
||||
|
||||
// notify the listener
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aListener.ADD,
|
||||
aItem.id,
|
||||
aItem);
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.ADD,
|
||||
aItem.id,
|
||||
aItem);
|
||||
// notify observers
|
||||
this.mObservers.notify("onAddItem", [aItem]);
|
||||
},
|
||||
@@ -180,13 +175,11 @@ calMemoryCalendar.prototype = {
|
||||
|
||||
var this_ = this;
|
||||
function reportError(errStr, errId) {
|
||||
if (aListener) {
|
||||
aListener.onOperationComplete(this_.superCalendar,
|
||||
errId ? errId : Components.results.NS_ERROR_FAILURE,
|
||||
aListener.MODIFY,
|
||||
aNewItem.id,
|
||||
errStr);
|
||||
}
|
||||
this_.notifyOperationComplete(aListener,
|
||||
errId ? errId : Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
aNewItem.id,
|
||||
errStr);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -238,13 +231,11 @@ calMemoryCalendar.prototype = {
|
||||
modifiedItem.makeImmutable();
|
||||
this.mItems[modifiedItem.id] = modifiedItem;
|
||||
|
||||
if (aListener) {
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aListener.MODIFY,
|
||||
modifiedItem.id,
|
||||
modifiedItem);
|
||||
}
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
modifiedItem.id,
|
||||
modifiedItem);
|
||||
|
||||
// notify observers
|
||||
this.mObservers.notify("onModifyItem", [modifiedItem, aOldItem]);
|
||||
@@ -256,34 +247,31 @@ calMemoryCalendar.prototype = {
|
||||
if (this.readOnly)
|
||||
throw Components.interfaces.calIErrors.CAL_IS_READONLY;
|
||||
if (aItem.id == null || this.mItems[aItem.id] == null) {
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.DELETE,
|
||||
aItem.id,
|
||||
"ID is null or is from different calendar in deleteItem");
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
aItem.id,
|
||||
"ID is null or is from different calendar in deleteItem");
|
||||
return;
|
||||
}
|
||||
|
||||
var oldItem = this.mItems[aItem.id];
|
||||
if (oldItem.generation != aItem.generation) {
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.DELETE,
|
||||
aItem.id,
|
||||
"generation mismatch in deleteItem");
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
aItem.id,
|
||||
"generation mismatch in deleteItem");
|
||||
return;
|
||||
}
|
||||
|
||||
delete this.mItems[aItem.id];
|
||||
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aListener.DELETE,
|
||||
aItem.id,
|
||||
aItem);
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
aItem.id,
|
||||
aItem);
|
||||
// notify observers
|
||||
this.mObservers.notify("onDeleteItem", [oldItem]);
|
||||
},
|
||||
@@ -293,13 +281,12 @@ calMemoryCalendar.prototype = {
|
||||
if (!aListener)
|
||||
return;
|
||||
|
||||
if (aId == null ||
|
||||
this.mItems[aId] == null) {
|
||||
aListener.onOperationComplete(this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.GET,
|
||||
null,
|
||||
"IID doesn't exist for getItem");
|
||||
if (aId == null || this.mItems[aId] == null) {
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
"IID doesn't exist for getItem");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -311,11 +298,11 @@ calMemoryCalendar.prototype = {
|
||||
} else if (item instanceof Components.interfaces.calITodo) {
|
||||
iid = Components.interfaces.calITodo;
|
||||
} else {
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.GET,
|
||||
aId,
|
||||
"Can't deduce item type based on QI");
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
aId,
|
||||
"Can't deduce item type based on QI");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -324,12 +311,11 @@ calMemoryCalendar.prototype = {
|
||||
iid,
|
||||
null, 1, [item]);
|
||||
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aListener.GET,
|
||||
aId,
|
||||
null);
|
||||
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
aId,
|
||||
null);
|
||||
},
|
||||
|
||||
// void getItems( in unsigned long aItemFilter, in unsigned long aCount,
|
||||
@@ -355,11 +341,11 @@ calMemoryCalendar.prototype = {
|
||||
var wantTodos = ((aItemFilter & calICalendar.ITEM_FILTER_TYPE_TODO) != 0);
|
||||
if(!wantEvents && !wantTodos) {
|
||||
// bail.
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.GET,
|
||||
null,
|
||||
"Bad aItemFilter passed to getItems");
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
"Bad aItemFilter passed to getItems");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -424,10 +410,10 @@ calMemoryCalendar.prototype = {
|
||||
itemsFound.length,
|
||||
itemsFound);
|
||||
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aListener.GET,
|
||||
null,
|
||||
null);
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -400,13 +400,11 @@ calStorageCalendar.prototype = {
|
||||
// void adoptItem( in calIItemBase aItem, in calIOperationListener aListener );
|
||||
adoptItem: function (aItem, aListener) {
|
||||
if (this.readOnly) {
|
||||
if (aListener) {
|
||||
aListener.onOperationComplete(this.superCalenddar,
|
||||
Components.interfaces.calIErrors.CAL_IS_READONLY,
|
||||
aListener.ADD,
|
||||
null,
|
||||
"Calendar is readonly");
|
||||
}
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.interfaces.calIErrors.CAL_IS_READONLY,
|
||||
Components.interfaces.calIOperationListener.ADD,
|
||||
null,
|
||||
"Calendar is readonly");
|
||||
return;
|
||||
}
|
||||
// Ensure that we're looking at the base item
|
||||
@@ -426,14 +424,12 @@ calStorageCalendar.prototype = {
|
||||
if (this.relaxedMode) {
|
||||
// we possibly want to interact with the user before deleting
|
||||
this.deleteItemById(aItem.id);
|
||||
}
|
||||
else {
|
||||
if (aListener)
|
||||
aListener.onOperationComplete(this.superCalendar,
|
||||
Components.interfaces.calIErrors.DUPLICATE_ID,
|
||||
aListener.ADD,
|
||||
aItem.id,
|
||||
"ID already exists for addItem");
|
||||
} else {
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.interfaces.calIErrors.DUPLICATE_ID,
|
||||
Components.interfaces.calIOperationListener.ADD,
|
||||
aItem.id,
|
||||
"ID already exists for addItem");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -445,27 +441,24 @@ calStorageCalendar.prototype = {
|
||||
this.flushItem (aItem, null);
|
||||
|
||||
// notify the listener
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aListener.ADD,
|
||||
aItem.id,
|
||||
aItem);
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.ADD,
|
||||
aItem.id,
|
||||
aItem);
|
||||
|
||||
// notify observers
|
||||
this.mObservers.notify("onAddItem", [aItem]);
|
||||
this.observers.notify("onAddItem", [aItem]);
|
||||
},
|
||||
|
||||
// void modifyItem( in calIItemBase aNewItem, in calIItemBase aOldItem, in calIOperationListener aListener );
|
||||
modifyItem: function (aNewItem, aOldItem, aListener) {
|
||||
if (this.readOnly) {
|
||||
if (aListener) {
|
||||
aListener.onOperationComplete(this.superCalenddar,
|
||||
Components.interfaces.calIErrors.CAL_IS_READONLY,
|
||||
aListener.MODIFY,
|
||||
null,
|
||||
"Calendar is readonly");
|
||||
}
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.interfaces.calIErrors.CAL_IS_READONLY,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
null,
|
||||
"Calendar is readonly");
|
||||
return null;
|
||||
}
|
||||
if (!aNewItem) {
|
||||
@@ -474,13 +467,11 @@ calStorageCalendar.prototype = {
|
||||
|
||||
var this_ = this;
|
||||
function reportError(errStr, errId) {
|
||||
if (aListener) {
|
||||
aListener.onOperationComplete(this_.superCalendar,
|
||||
errId ? errId : Components.results.NS_ERROR_FAILURE,
|
||||
aListener.MODIFY,
|
||||
aNewItem.id,
|
||||
errStr);
|
||||
}
|
||||
this_.notifyOperationComplete(aListener,
|
||||
errId ? errId : Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
aNewItem.id,
|
||||
errStr);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -523,29 +514,25 @@ calStorageCalendar.prototype = {
|
||||
modifiedItem.makeImmutable();
|
||||
this.flushItem (modifiedItem, aOldItem);
|
||||
|
||||
if (aListener) {
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aListener.MODIFY,
|
||||
modifiedItem.id,
|
||||
modifiedItem);
|
||||
}
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.MODIFY,
|
||||
modifiedItem.id,
|
||||
modifiedItem);
|
||||
|
||||
// notify observers
|
||||
this.mObservers.notify("onModifyItem", [modifiedItem, aOldItem]);
|
||||
this.observers.notify("onModifyItem", [modifiedItem, aOldItem]);
|
||||
return null;
|
||||
},
|
||||
|
||||
// void deleteItem( in string id, in calIOperationListener aListener );
|
||||
deleteItem: function (aItem, aListener) {
|
||||
if (this.readOnly) {
|
||||
if (aListener) {
|
||||
aListener.onOperationComplete(this.superCalenddar,
|
||||
Components.interfaces.calIErrors.CAL_IS_READONLY,
|
||||
aListener.DELETE,
|
||||
null,
|
||||
"Calendar is readonly");
|
||||
}
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.interfaces.calIErrors.CAL_IS_READONLY,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
null,
|
||||
"Calendar is readonly");
|
||||
return;
|
||||
}
|
||||
if (aItem.parentItem != aItem) {
|
||||
@@ -556,26 +543,24 @@ calStorageCalendar.prototype = {
|
||||
}
|
||||
|
||||
if (aItem.id == null) {
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.DELETE,
|
||||
null,
|
||||
"ID is null for deleteItem");
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
null,
|
||||
"ID is null for deleteItem");
|
||||
return;
|
||||
}
|
||||
|
||||
this.deleteItemById(aItem.id);
|
||||
|
||||
if (aListener)
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aListener.DELETE,
|
||||
aItem.id,
|
||||
aItem);
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.DELETE,
|
||||
aItem.id,
|
||||
aItem);
|
||||
|
||||
// notify observers
|
||||
this.mObservers.notify("onDeleteItem", [aItem]);
|
||||
this.observers.notify("onDeleteItem", [aItem]);
|
||||
},
|
||||
|
||||
// void getItem( in string id, in calIOperationListener aListener );
|
||||
@@ -585,11 +570,11 @@ calStorageCalendar.prototype = {
|
||||
|
||||
var item = this.getItemById (aId);
|
||||
if (!item) {
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.GET,
|
||||
aId,
|
||||
"ID doesn't exist for getItem");
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
aId,
|
||||
"ID doesn't exist for getItem");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -599,11 +584,11 @@ calStorageCalendar.prototype = {
|
||||
else if (item instanceof Components.interfaces.calITodo)
|
||||
item_iid = Components.interfaces.calITodo;
|
||||
else {
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
aListener.GET,
|
||||
aId,
|
||||
"Can't deduce item type based on QI");
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_ERROR_FAILURE,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
aId,
|
||||
"Can't deduce item type based on QI");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -612,11 +597,11 @@ calStorageCalendar.prototype = {
|
||||
item_iid, null,
|
||||
1, [item]);
|
||||
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aListener.GET,
|
||||
aId,
|
||||
null);
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
aId,
|
||||
null);
|
||||
},
|
||||
|
||||
// void getItems( in unsigned long aItemFilter, in unsigned long aCount,
|
||||
@@ -646,11 +631,11 @@ calStorageCalendar.prototype = {
|
||||
var asOccurrences = ((aItemFilter & kCalICalendar.ITEM_FILTER_CLASS_OCCURRENCES) != 0);
|
||||
if (!wantEvents && !wantTodos) {
|
||||
// nothing to do
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aListener.GET,
|
||||
null,
|
||||
null);
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -732,11 +717,11 @@ calStorageCalendar.prototype = {
|
||||
queueItems(null);
|
||||
|
||||
// send operation complete
|
||||
aListener.onOperationComplete (self.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aListener.GET,
|
||||
null,
|
||||
null);
|
||||
self.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
null);
|
||||
|
||||
// tell caller we're done
|
||||
return true;
|
||||
@@ -827,11 +812,11 @@ calStorageCalendar.prototype = {
|
||||
queueItems(null);
|
||||
|
||||
// and finish
|
||||
aListener.onOperationComplete (this.superCalendar,
|
||||
Components.results.NS_OK,
|
||||
aListener.GET,
|
||||
null,
|
||||
null);
|
||||
this.notifyOperationComplete(aListener,
|
||||
Components.results.NS_OK,
|
||||
Components.interfaces.calIOperationListener.GET,
|
||||
null,
|
||||
null);
|
||||
|
||||
//var profEndTime = Date.now();
|
||||
//dump ("++++ getItems took: " + (profEndTime - profStartTime) + " ms\n");
|
||||
|
||||
@@ -58,11 +58,10 @@ calWcapCalendar.prototype = {
|
||||
}
|
||||
return str;
|
||||
},
|
||||
notifyError_: function calWcapCalendar_notifyError_(err, context, suppressOnError) {
|
||||
var msg;
|
||||
|
||||
notifyError_: function calWcapCalendar_notifyError_(err, msg, context, suppressOnError) {
|
||||
var rc = getResultCode(err);
|
||||
switch (rc) {
|
||||
case calIErrors.OPERATION_CANCELLED:
|
||||
case calIWcapErrors.WCAP_COMPONENT_NOT_FOUND:
|
||||
case NS_ERROR_OFFLINE:
|
||||
return;
|
||||
@@ -80,14 +79,15 @@ calWcapCalendar.prototype = {
|
||||
break;
|
||||
}
|
||||
if (!suppressOnError) {
|
||||
this.notifyObservers("onError",
|
||||
err instanceof Components.interfaces.nsIException
|
||||
? [this.superCalendar, err.result, err.message]
|
||||
: [this.superCalendar, (isNaN(err) ? -1 : err), msg]);
|
||||
this.__proto__.__proto__.notifyError.apply(
|
||||
this,
|
||||
err instanceof Components.interfaces.nsIException
|
||||
? [err.result, err.message]
|
||||
: [(isNaN(err) ? Components.results.NS_ERROR_FAILURE : err), msg]);
|
||||
}
|
||||
},
|
||||
notifyError: function calWcapCalendar_notifyError(err, suppressOnError) {
|
||||
this.notifyError_(err, this, suppressOnError);
|
||||
notifyError: function calWcapCalendar_notifyError(err, msg, suppressOnError) {
|
||||
this.notifyError_(err, msg, this, suppressOnError);
|
||||
},
|
||||
|
||||
// calICalendarProvider:
|
||||
|
||||
@@ -114,7 +114,8 @@ function calWcapCalendar_getRecurrenceParams(item, out_rrules, out_rdates, out_e
|
||||
out_rdates.value.push(getIcalUTC(ensureDateTime(rItem.date)));
|
||||
}
|
||||
} else {
|
||||
this.notifyError("don\'t know how to handle this recurrence item: " + rItem.valueAsIcalString);
|
||||
this.notifyError(NS_ERROR_UNEXPECTED,
|
||||
"don\'t know how to handle this recurrence item: " + rItem.valueAsIcalString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -605,7 +606,8 @@ function calWcapCalendar_storeItem(bAddItem, item, oldItem, request) {
|
||||
throw new Components.Exception("empty VCALENDAR returned!");
|
||||
}
|
||||
if (items.length > 1) {
|
||||
this_.notifyError("unexpected number of items: " + items.length);
|
||||
this_.notifyError(NS_ERROR_UNEXPECTED,
|
||||
"unexpected number of items: " + items.length);
|
||||
}
|
||||
var newItem = items[0];
|
||||
this_.tunnelXProps(newItem, item);
|
||||
@@ -662,16 +664,12 @@ function calWcapCalendar_adoptItem(item, listener) {
|
||||
var this_ = this;
|
||||
var request = new calWcapRequest(
|
||||
function adoptItem_resp(request, err, newItem) {
|
||||
if (listener) {
|
||||
listener.onOperationComplete(this_.superCalendar,
|
||||
getResultCode(err),
|
||||
calIOperationListener.ADD,
|
||||
err ? item.id : newItem.id,
|
||||
err ? err : newItem);
|
||||
}
|
||||
if (err) {
|
||||
this_.notifyError(err);
|
||||
} else {
|
||||
this_.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.ADD,
|
||||
err ? item.id : newItem.id,
|
||||
err ? err : newItem);
|
||||
if (!err) {
|
||||
this_.notifyObservers("onAddItem", [newItem]);
|
||||
}
|
||||
},
|
||||
@@ -698,14 +696,11 @@ function calWcapCalendar_modifyItem(newItem, oldItem, listener) {
|
||||
var this_ = this;
|
||||
var request = new calWcapRequest(
|
||||
function modifyItem_resp(request, err, item) {
|
||||
if (listener) {
|
||||
listener.onOperationComplete(this_.superCalendar, getResultCode(err),
|
||||
calIOperationListener.MODIFY,
|
||||
newItem.id, err ? err : item);
|
||||
}
|
||||
if (err) {
|
||||
this_.notifyError(err);
|
||||
} else {
|
||||
this_.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.MODIFY,
|
||||
newItem.id, err ? err : item);
|
||||
if (!err) {
|
||||
this_.notifyObservers("onModifyItem", [item, oldItem]);
|
||||
}
|
||||
},
|
||||
@@ -784,15 +779,11 @@ function calWcapCalendar_deleteItem(item, listener) {
|
||||
var request = new calWcapRequest(
|
||||
function deleteItem_resp(request, err) {
|
||||
// xxx todo: need to notify about each deleted item if multiple?
|
||||
if (listener) {
|
||||
listener.onOperationComplete(
|
||||
this_.superCalendar, getResultCode(err),
|
||||
calIOperationListener.DELETE,
|
||||
item.id, err ? err : item);
|
||||
}
|
||||
if (err) {
|
||||
this_.notifyError(err);
|
||||
} else {
|
||||
this_.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.DELETE,
|
||||
item.id, err ? err : item);
|
||||
if (!err) {
|
||||
this_.notifyObservers("onDeleteItem", [item]);
|
||||
}
|
||||
},
|
||||
@@ -1069,15 +1060,11 @@ function calWcapCalendar_getItem(id, listener) {
|
||||
var this_ = this;
|
||||
var request = new calWcapRequest(
|
||||
function getItem_resp(request, err, item) {
|
||||
if (listener) {
|
||||
listener.onOperationComplete(this_.superCalendar, getResultCode(err),
|
||||
calIOperationListener.GET,
|
||||
item ? item.id : null,
|
||||
err || item);
|
||||
}
|
||||
if (err) {
|
||||
this_.notifyError(err);
|
||||
}
|
||||
this_.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.GET,
|
||||
item ? item.id : null,
|
||||
err || item);
|
||||
},
|
||||
log("getItem() call: id=" + id, this));
|
||||
|
||||
@@ -1095,7 +1082,8 @@ function calWcapCalendar_getItem(id, listener) {
|
||||
throw new Components.Exception("no such item!");
|
||||
}
|
||||
if (items.length > 1) {
|
||||
this_.notifyError("unexpected number of items: " + items.length);
|
||||
this_.notifyError(NS_ERROR_UNEXPECTED,
|
||||
"unexpected number of items: " + items.length);
|
||||
}
|
||||
if (listener) {
|
||||
listener.onGetResult(this_.superCalendar, NS_OK,
|
||||
@@ -1178,21 +1166,11 @@ function calWcapCalendar_getItems(itemFilter, maxResults, rangeStart, rangeEnd,
|
||||
var request = new calWcapRequest(
|
||||
function getItems_resp(request, err, data) {
|
||||
log("getItems() complete: " + errorToString(err), this_);
|
||||
var rc = getResultCode(err);
|
||||
if (err) {
|
||||
if (listener) {
|
||||
listener.onOperationComplete(this_.superCalendar, rc,
|
||||
calIOperationListener.GET,
|
||||
null, err);
|
||||
}
|
||||
this_.notifyError(err, request.suppressOnError);
|
||||
} else {
|
||||
if (listener) {
|
||||
listener.onOperationComplete(this_.superCalendar, rc,
|
||||
calIOperationListener.GET,
|
||||
null, null);
|
||||
}
|
||||
}
|
||||
this_.notifyOperationComplete(listener,
|
||||
getResultCode(err),
|
||||
calIOperationListener.GET,
|
||||
null,
|
||||
err);
|
||||
},
|
||||
log("getItems():\n\titemFilter=0x" + itemFilter.toString(0x10) +
|
||||
",\n\tmaxResults=" + maxResults +
|
||||
@@ -1414,9 +1392,8 @@ function calWcapCalendar_syncChangesTo_(destCal, itemFilter, dtFrom, listener) {
|
||||
opListener.onResult(request, null);
|
||||
}
|
||||
}
|
||||
this_.notifyError(err, request.suppressOnError);
|
||||
this_.notifyError(err, null, request.suppressOnError);
|
||||
} else {
|
||||
|
||||
log("SYNC succeeded.", this_);
|
||||
if (listener) {
|
||||
var opListener = null;
|
||||
@@ -1430,6 +1407,7 @@ function calWcapCalendar_syncChangesTo_(destCal, itemFilter, dtFrom, listener) {
|
||||
opListener.onResult(request, now);
|
||||
}
|
||||
}
|
||||
this_.setProperty("currentStatus", Components.results.NS_OK);
|
||||
}
|
||||
},
|
||||
log("syncChangesTo():\n\titemFilter=0x" + itemFilter.toString(0x10) +
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
// constants:
|
||||
const NS_OK = Components.results.NS_OK;
|
||||
const NS_ERROR_UNEXPECTED = Components.results.NS_ERROR_UNEXPECTED;
|
||||
const nsIException = Components.interfaces.nsIException;
|
||||
const nsISupports = Components.interfaces.nsISupports;
|
||||
const calIWcapSession = Components.interfaces.calIWcapSession;
|
||||
|
||||
@@ -114,7 +114,7 @@ calWcapSession.prototype = {
|
||||
},
|
||||
notifyError: function calWcapSession_notifyError(err, suppressOnError) {
|
||||
if (this.defaultCalendar) {
|
||||
this.defaultCalendar.notifyError_(err, this, suppressOnError);
|
||||
this.defaultCalendar.notifyError_(err, null, this, suppressOnError);
|
||||
} else {
|
||||
logError("no default calendar!", this);
|
||||
logError(err, this);
|
||||
|
||||
@@ -164,7 +164,7 @@ function logWarning(err, context) {
|
||||
|
||||
function logError(err, context) {
|
||||
var msg = errorToString(err);
|
||||
Components.utils.reportError(log("error: " + msg + "\nstack:\n" + STACK(), context, true));
|
||||
Components.utils.reportError(log("error: " + msg + "\nstack:\n" + STACK(10), context, true));
|
||||
debugger;
|
||||
return msg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user