Skip to content

Commit c6836f4

Browse files
committed
1 parent 53d533b commit c6836f4

File tree

1 file changed

+114
-7
lines changed

1 file changed

+114
-7
lines changed

Diff for: interfaces/exchangeCalendar/mivExchangeCalendar.js

+114-7
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ try{
331331
this.mPrefs = null;
332332

333333
this.itemCacheById = {};
334+
this.itemCancelQueue = {};
335+
334336
this.itemCacheByStartDate = {};
335337
this.itemCacheByEndDate = {};
336338
this.recurringMasterCache = {};
@@ -1841,7 +1843,113 @@ calExchangeCalendar.prototype = {
18411843

18421844
return null;
18431845
},
1846+
1847+
deleteItemCancelled: function _deleteItemCancelled(aItem,aListener) {
1848+
if (this.debug) this.logInfo("deleteItemCancelled: "+aItem.title);
1849+
if ((aItem.className) && (!aItem.canDelete)) {
1850+
if (this.debug) this.logInfo("User is not allowed to delete this item.");
1851+
this.notifyOperationComplete(aListener,
1852+
Ci.calIErrors.OPERATION_CANCELLED,
1853+
Ci.calIOperationListener.DELETE,
1854+
aItem.id,
1855+
aItem);
1856+
return null;
1857+
}
1858+
1859+
if (aItem.id == null) {
1860+
if (aListener) {
1861+
this.notifyOperationComplete(aListener,
1862+
Ci.calIErrors.MODIFICATION_FAILED,
1863+
Ci.calIOperationListener.DELETE,
1864+
null,
1865+
"ID is null for deleteItem");
1866+
}
1867+
return;
1868+
}
1869+
1870+
// Check if this item is still in cache
1871+
if ((aItem.id == aItem.parentItem.id) && (!this.itemCacheById[aItem.id]) && (!this.recurringMasterCache[aItem.uid])) {
1872+
if (this.debug) this.logInfo("Item is not in itemCache anymore. Probably not removed from view by Lightning..");
1873+
if (aListener) {
1874+
this.notifyOperationComplete(aListener,
1875+
Cr.NS_OK,
1876+
Ci.calIOperationListener.DELETE,
1877+
aItem.id,
1878+
aItem);
1879+
}
1880+
return;
1881+
}
1882+
1883+
switch (aItem.calendarItemType) {
1884+
case "Single" :
1885+
if (this.debug) this.logInfo("-- Single CalendarItemType");
1886+
this.removeItemFromCache(aItem);
1887+
1888+
var self = this;
1889+
this.addToQueue( erDeleteItemRequest,
1890+
{user: this.user,
1891+
mailbox: this.mailbox,
1892+
folderBase: this.folderBase,
1893+
serverUrl: this.serverUrl,
1894+
item: aItem,
1895+
folderID: this.folderID,
1896+
changeKey: this.changeKey,
1897+
actionStart: Date.now(),
1898+
itemType: "single"},
1899+
function(erDeleteItemRequest) { self.deleteItemOk(erDeleteItemRequest);},
1900+
function(erDeleteItemRequest, aCode, aMsg) { self.deleteItemError(erDeleteItemRequest, aCode, aMsg);},
1901+
aListener);
18441902

1903+
break;
1904+
case "Occurrence" :
1905+
case "Exception" :
1906+
if (this.debug) this.logInfo("-- "+aItem.calendarItemType+" CalendarItemType");
1907+
this.removeItemFromCache(aItem);
1908+
1909+
var self = this;
1910+
this.addToQueue( erGetOccurrenceIndexRequest,
1911+
{user: this.user,
1912+
mailbox: this.mailbox,
1913+
folderBase: this.folderBase,
1914+
serverUrl: this.serverUrl,
1915+
masterItem: aItem,
1916+
item: aItem,
1917+
folderID: this.folderID,
1918+
changeKey: this.changeKey,
1919+
action: "deleteItem",
1920+
itemType: "occurrence",
1921+
whichOccurrence: "occurrence" },//dialogArg.answer},
1922+
function(erGetOccurrenceIndexRequest, aIndex, aMasterId, aMasterChangeKey) { self.getOccurrenceIndexOk(erGetOccurrenceIndexRequest, aIndex, aMasterId, aMasterChangeKey);},
1923+
function(erGetOccurrenceIndexRequest, aCode, aMsg) { self.getOccurrenceIndexError(erGetOccurrenceIndexRequest, aCode, aMsg);},
1924+
aListener);
1925+
1926+
break;
1927+
case "RecurringMaster" :
1928+
if (this.debug) this.logInfo("-- RecurringMaster CalendarItemType");
1929+
this.removeItemFromCache(aItem);
1930+
1931+
var self = this;
1932+
this.addToQueue( erDeleteItemRequest,
1933+
{user: this.user,
1934+
mailbox: this.mailbox,
1935+
folderBase: this.folderBase,
1936+
serverUrl: this.serverUrl,
1937+
item: aItem,
1938+
folderID: this.folderID,
1939+
changeKey: this.changeKey,
1940+
itemType: "master",
1941+
actionStart: Date.now(),
1942+
whichOccurrence: "all_occurrences"},
1943+
function(erDeleteItemRequest) { self.deleteItemOk(erDeleteItemRequest);},
1944+
function(erDeleteItemRequest, aCode, aMsg) { self.deleteItemError(erDeleteItemRequest, aCode, aMsg);},
1945+
aListener);
1946+
break;
1947+
default :
1948+
// TODO: This will happen when the sync to/from EWS has not yet happened.
1949+
if (this.debug) this.logInfo("WARNING: unknown CalendarItemType="+aItem.calendarItemType);
1950+
}
1951+
1952+
},
18451953
// calIOperation deleteItem(in calIItemBase aItem,
18461954
// in calIOperationListener aListener);
18471955
deleteItem: function _deleteItem(aItem, aListener) {
@@ -2054,8 +2162,6 @@ calExchangeCalendar.prototype = {
20542162
function(erDeleteItemRequest, aCode, aMsg) { self.deleteItemError(erDeleteItemRequest, aCode, aMsg);},
20552163
aListener);
20562164
}
2057-
2058-
20592165
},
20602166

20612167
// calIOperation getItem(in string aId, in calIOperationListener aListener);
@@ -2676,14 +2782,15 @@ calExchangeCalendar.prototype = {
26762782
startYearday = 1;
26772783
}
26782784
}
2785+
26792786
for (var itemid in ids) {
26802787
if (this.itemCacheById[itemid]) {
2681-
if (isEvent(this.itemCacheById[itemid])) {
2682-
//dump("\nxxxxx "+this.itemCacheById[itemid].title+":"+ this.deleteCancelledInvitation + ":"+this.itemCacheById[itemid].isCancelled);
2788+
if (isEvent(this.itemCacheById[itemid])) {
26832789
if ( this.deleteCancelledInvitation && this.itemCacheById[itemid].isCancelled )
2684-
{
2685-
if (this.debug) this.logInfo("getItemsFromMemoryCache 2: " + "Found Cancelled Item " + this.itemCacheById[itemid].title + " - going to delete from cache" );
2686-
this.deleteItem(this.itemCacheById[itemid]);
2790+
{
2791+
events.push(this.itemCacheById[itemid]);
2792+
this.deleteItemCancelled(this.itemCacheById[itemid]);
2793+
26872794
}
26882795
else
26892796
{

0 commit comments

Comments
 (0)