|
331 | 331 | this.mPrefs = null;
|
332 | 332 |
|
333 | 333 | this.itemCacheById = {};
|
| 334 | + this.itemCancelQueue = {}; |
| 335 | + |
334 | 336 | this.itemCacheByStartDate = {};
|
335 | 337 | this.itemCacheByEndDate = {};
|
336 | 338 | this.recurringMasterCache = {};
|
@@ -1841,7 +1843,113 @@ calExchangeCalendar.prototype = {
|
1841 | 1843 |
|
1842 | 1844 | return null;
|
1843 | 1845 | },
|
| 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); |
1844 | 1902 |
|
| 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 | + }, |
1845 | 1953 | // calIOperation deleteItem(in calIItemBase aItem,
|
1846 | 1954 | // in calIOperationListener aListener);
|
1847 | 1955 | deleteItem: function _deleteItem(aItem, aListener) {
|
@@ -2054,8 +2162,6 @@ calExchangeCalendar.prototype = {
|
2054 | 2162 | function(erDeleteItemRequest, aCode, aMsg) { self.deleteItemError(erDeleteItemRequest, aCode, aMsg);},
|
2055 | 2163 | aListener);
|
2056 | 2164 | }
|
2057 |
| - |
2058 |
| - |
2059 | 2165 | },
|
2060 | 2166 |
|
2061 | 2167 | // calIOperation getItem(in string aId, in calIOperationListener aListener);
|
@@ -2676,14 +2782,15 @@ calExchangeCalendar.prototype = {
|
2676 | 2782 | startYearday = 1;
|
2677 | 2783 | }
|
2678 | 2784 | }
|
| 2785 | + |
2679 | 2786 | for (var itemid in ids) {
|
2680 | 2787 | 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])) { |
2683 | 2789 | 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 | + |
2687 | 2794 | }
|
2688 | 2795 | else
|
2689 | 2796 | {
|
|
0 commit comments