Fix bug 722635 - MODIFICATION_FAILED when writing to the Oracle stbeehive caldav server. r=wsourdeau,a=philipp CLOSED TREE
authorPhilipp Kewisch <mozilla@kewis.ch>
Wed, 01 Feb 2012 22:52:33 +0100
changeset 30727 eeecf7cd201ba045a5ecc3c7b69f89128f9dbf97
parent 30717 b66154e57494c4289ca165ecc52e88a88a7744f8
child 30728 529847e95bd8ff166b99e34046f97042440158f4
child 30732 d77cf4ea22b6442a1c86b6329d34b70101898dac
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswsourdeau, philipp
bugs722635
Fix bug 722635 - MODIFICATION_FAILED when writing to the Oracle stbeehive caldav server. r=wsourdeau,a=philipp CLOSED TREE
calendar/base/content/dialogs/calendar-event-dialog.js
calendar/base/content/dialogs/calendar-summary-dialog.js
calendar/base/modules/calItipUtils.jsm
calendar/base/src/calDefaultACLManager.js
calendar/base/src/calUtils.js
--- a/calendar/base/content/dialogs/calendar-event-dialog.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog.js
@@ -2304,17 +2304,17 @@ function saveItem() {
     // calendar-user-address-set. The organzerID is the owner of the calendar.
     // If it's different, that is because someone is acting on behalf of
     // the organizer.
     if (item.organizer && item.calendar.aclEntry) {
         let userAddresses = item.calendar.aclEntry.getUserAddresses({});
         if (userAddresses.length > 0
             && !cal.attendeeMatchesAddresses(item.organizer, userAddresses)) {
             let organizer = item.organizer.clone();
-            organizer.setProperty("SENT-BY", userAddresses[0]);
+            organizer.setProperty("SENT-BY", "mailto:" + userAddresses[0]);
             item.organizer = organizer;
         }
     }
     return item;
 }
 
 /**
  * Action to take when the user chooses to save. This can happen either by
--- a/calendar/base/content/dialogs/calendar-summary-dialog.js
+++ b/calendar/base/content/dialogs/calendar-summary-dialog.js
@@ -248,17 +248,17 @@ function updateInvitation() {
   var statusElement = document.getElementById("item-participation");
   if (window.attendee) {
       let item = window.arguments[0];
       let aclEntry = item.calendar.aclEntry;
       if (aclEntry) {
           let userAddresses = aclEntry.getUserAddresses({});
           if (userAddresses.length > 0
               && !cal.attendeeMatchesAddresses(window.attendee, userAddresses)) {
-              window.attendee.setProperty("SENT-BY", userAddresses[0]);
+              window.attendee.setProperty("SENT-BY", "mailto:" + userAddresses[0]);
           }
       }
 
       window.attendee.participationStatus = statusElement.value;
   }
 }
 
 /**
--- a/calendar/base/modules/calItipUtils.jsm
+++ b/calendar/base/modules/calItipUtils.jsm
@@ -595,17 +595,17 @@ cal.itip = {
             /* We check if the attendee id matches one of of the
              * userAddresses. If they aren't equal, it means that
              * someone is accepting invitations on behalf of an other user. */
             if (aItem.calendar.aclEntry) {
                 let userAddresses = aItem.calendar.aclEntry.getUserAddresses({});
                 if (userAddresses.length > 0
                     && !cal.attendeeMatchesAddresses(invitedAttendee, userAddresses)) {
                     invitedAttendee = invitedAttendee.clone();
-                    invitedAttendee.setProperty("SENT-BY", userAddresses[0]);
+                    invitedAttendee.setProperty("SENT-BY", "mailto:" + userAddresses[0]);
                 }
             }
 
             if (aItem.organizer) {
                 let origInvitedAttendee = (aOriginalItem && aOriginalItem.getAttendeeById(invitedAttendee.id));
 
                 if (aOpType == Components.interfaces.calIOperationListener.DELETE) {
                     // in case the attendee has just deleted the item, we want to send out a DECLINED REPLY:
--- a/calendar/base/src/calDefaultACLManager.js
+++ b/calendar/base/src/calDefaultACLManager.js
@@ -59,17 +59,17 @@ calDefaultACLManager.prototype = {
         interfaces: [Components.interfaces.calICalendarACLManager],
         flags: Components.interfaces.nsIClassInfo.SINGLETON,
     }),
 
     /* calICalendarACLManager */
     _getCalendarEntryCached: function cDACLM__getCalendarEntryCached(aCalendar) {
         let calUri = aCalendar.uri.spec;
         if (!(calUri in this.mCalendarEntries)) {
-            this.mCalendarEntries[calUri] = new calDefaultCalendarACLEntry(this);
+            this.mCalendarEntries[calUri] = new calDefaultCalendarACLEntry(this, aCalendar);
         }
 
         return this.mCalendarEntries[calUri];
     },
     getCalendarEntry: function cDACLM_getCalendarEntry(aCalendar, aListener) {
         let entry = this._getCalendarEntryCached(aCalendar);
         aListener.onOperationComplete(aCalendar, Components.results.NS_OK,
                                       Components.interfaces.calIOperationListener.GET,
@@ -78,18 +78,19 @@ calDefaultACLManager.prototype = {
     },
     getItemEntry: function cDACLM_getItemEntry(aItem) {
         let calEntry = this._getCalendarEntryCached(aItem.calendar);
         return new calDefaultItemACLEntry(calEntry);
     },
 
 };
 
-function calDefaultCalendarACLEntry(aMgr) {
+function calDefaultCalendarACLEntry(aMgr, aCalendar) {
     this.mACLManager = aMgr;
+    this.mCalendar = aCalendar;
 }
 
 calDefaultCalendarACLEntry.prototype = {
     mACLManager: null,
 
     /* nsISupports */
     QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calICalendarACLEntry]),
 
@@ -106,26 +107,32 @@ calDefaultCalendarACLEntry.prototype = {
     _getIdentities: function calDefaultCalendarACLEntry_getUserAddresses(aCount) {
         let identities = [];
         cal.calIterateEmailIdentities(function (id, ac) { identities.push(id); });
         aCount.value = identities.length;
         return identities;
     },
 
     getUserAddresses: function calDefaultCalendarACLEntry_getUserAddresses(aCount) {
-        let identities = this._getIdentities(aCount);
+        let identities = this.getUserIdentities(aCount);
         let addresses = [ id.email for each (id in identities) ];
         return addresses;
     },
 
     getUserIdentities: function calDefaultCalendarACLEntry_getUserIdentities(aCount) {
-        return this._getIdentities(aCount)
+        let identity = cal.getEmailIdentityOfCalendar(this.mCalendar);
+        if (identity) {
+            aCount.value = 1;
+            return [identity];
+        } else {
+            return this._getIdentities(aCount);
+        }
     },
     getOwnerIdentities: function calDefaultCalendarACLEntry_getOwnerIdentities(aCount) {
-        return this._getIdentities(aCount)
+        return this._getIdentities(aCount);
     },
 
     refresh: function calDefaultCalendarACLEntry_refresh() {
     }
 };
 
 function calDefaultItemACLEntry(aCalendarEntry) {
     this.calendarEntry = aCalendarEntry;
--- a/calendar/base/src/calUtils.js
+++ b/calendar/base/src/calUtils.js
@@ -338,19 +338,19 @@ function userCanModifyItem(aItem) {
  * Check if the attendee object matches one of the addresses in the list. This
  * is useful to determine whether the current user acts as a delegate.
  *
  * @param aAttendee     The reference attendee object
  * @param addresses     The list of addresses
  * @return              True if there is a match
  */
 function attendeeMatchesAddresses(anAttendee, addresses) {
-    let attId = anAttendee.id.toLowerCase();
+    let attId = anAttendee.id.toLowerCase().replace(/^mailto:/, "");
     for each (let address in addresses) {
-        if (attId == address.toLowerCase()) {
+        if (attId == address.toLowerCase().replace(/^mailto:/, "")) {
             return true;
         }
     }
 
     return false;
 }
 
 /**