Fix bug 463407 - eMail notification dialog on attendee side after first minor event change is wrong. r=philipp
authorDaniel Boelzle [:dbo] <daniel.boelzle@sun.com>
Mon, 10 Nov 2008 12:38:25 +0100
changeset 1052 af90017a839bc0dd19f509bcd6e4f5ac65e72329
parent 1051 b9c5089c11dc565252f83d68c72d94499d23b6ec
child 1053 3c377a3fb7de1843724f28695264f55902af91c4
push id788
push userdaniel.boelzle@sun.com
push dateMon, 10 Nov 2008 11:39:15 +0000
treeherdercomm-central@af90017a839b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp
bugs463407
Fix bug 463407 - eMail notification dialog on attendee side after first minor event change is wrong. r=philipp
calendar/base/modules/calItipUtils.jsm
calendar/base/modules/calUtils.jsm
calendar/lightning/content/imip-bar.js
--- a/calendar/base/modules/calItipUtils.jsm
+++ b/calendar/base/modules/calItipUtils.jsm
@@ -53,17 +53,17 @@ cal.itip = {
     /**
      * Gets the sequence/revision number, either of the passed item or
      * the last received one of an attendee; see
      * <http://tools.ietf.org/html/draft-desruisseaux-caldav-sched-04#section-7.1>.
      */
      getSequence: function cal_itip_getSequence(item) {
         let seq = null;
 
-        if (item instanceof Components.interfaces.calIAttendee) {
+        if (cal.calInstanceOf(item, Components.interfaces.calIAttendee)) {
             seq = item.getProperty("RECEIVED-SEQUENCE");
         } else if (item) {
             // Unless the below is standardized, we store the last original
             // REQUEST/PUBLISH SEQUENCE in X-MOZ-RECEIVED-SEQUENCE to test against it
             // when updates come in:
             seq = item.getProperty("X-MOZ-RECEIVED-SEQUENCE");
             if (seq === null) {
                 seq = item.getProperty("SEQUENCE");
@@ -87,17 +87,17 @@ cal.itip = {
     /**
      * Gets the stamp date-time, either of the passed item or
      * the last received one of an attendee; see
      * <http://tools.ietf.org/html/draft-desruisseaux-caldav-sched-04#section-7.2>.
      */
     getStamp: function cal_itip_getStamp(item) {
         let dtstamp = null;
 
-        if (item instanceof Components.interfaces.calIAttendee) {
+        if (cal.calInstanceOf(item, Components.interfaces.calIAttendee)) {
             let st = item.getProperty("RECEIVED-DTSTAMP");
             if (st) {
                 dtstamp = cal.createDateTime(st);
             }
         } else if (item) {
             // Unless the below is standardized, we store the last original
             // REQUEST/PUBLISH DTSTAMP in X-MOZ-RECEIVED-DTSTAMP to test against it
             // when updates come in:
@@ -263,36 +263,36 @@ cal.itip = {
         }
 
         // Check to see if some part of the item was updated, if so, re-send REQUEST
         if (!aOriginalItem || aItem.generation != aOriginalItem.generation) { // REQUEST
             let requestItem = aItem.clone();
 
             // check whether it's a simple UPDATE (no SEQUENCE change) or real (RE)REQUEST,
             // in case of time or location/description change.
-            let isUpdate = (aOriginalItem && (cal.itip.getSequence(aItem) == cal.itip.getSequence(aOriginalItem)));
+            let isMinorUpdate = (aOriginalItem && (cal.itip.getSequence(aItem) == cal.itip.getSequence(aOriginalItem)));
 
             if (!requestItem.organizer) {
                 let organizer = createAttendee();
                 organizer.id = requestItem.calendar.getProperty("organizerId");
                 organizer.commonName = requestItem.calendar.getProperty("organizerCN");
                 organizer.role = "REQ-PARTICIPANT";
                 organizer.participationStatus = "ACCEPTED";
                 organizer.isOrganizer = true;
                 requestItem.organizer = organizer;
             }
 
             // Fix up our attendees for invitations using some good defaults
             let recipients = [];
             let itemAtt = requestItem.getAttendees({});
-            if (!isUpdate) {
+            if (!isMinorUpdate) {
                 requestItem.removeAllAttendees();
             }
             for each (let attendee in itemAtt) {
-                if (!isUpdate) {
+                if (!isMinorUpdate) {
                     attendee = attendee.clone();
                     attendee.role = "REQ-PARTICIPANT";
                     attendee.participationStatus = "NEEDS-ACTION";
                     attendee.rsvp = "TRUE";
                     requestItem.addAttendee(attendee);
                 }
                 recipients.push(attendee);
             }
@@ -388,23 +388,23 @@ cal.itip = {
 
 /** local to this module file
  * Sets the received info either on the passed attendee or item object.
  *
  * @param item either  calIAttendee or calIItemBase
  * @param itipItemItem received iTIP item
  */
 function setReceivedInfo(item, itipItemItem) {
-    item.setProperty((item instanceof Components.interfaces.calIAttendee) ? "RECEIVED-SEQUENCE"
-                                                                          : "X-MOZ-RECEIVED-SEQUENCE",
+    item.setProperty(cal.calInstanceOf(item, Components.interfaces.calIAttendee) ? "RECEIVED-SEQUENCE"
+                                                                                 : "X-MOZ-RECEIVED-SEQUENCE",
                      String(cal.itip.getSequence(itipItemItem)));
     let dtstamp = cal.itip.getStamp(itipItemItem);
     if (dtstamp) {
-        item.setProperty((item instanceof Components.interfaces.calIAttendee) ? "RECEIVED-DTSTAMP"
-                                                                              : "X-MOZ-RECEIVED-DTSTAMP",
+        item.setProperty(cal.calInstanceOf(item, Components.interfaces.calIAttendee) ? "RECEIVED-DTSTAMP"
+                                                                                     : "X-MOZ-RECEIVED-DTSTAMP",
                          dtstamp.getInTimezone(cal.UTC()).icalString);
     }
 }
 
 /** local to this module file
  * Creates an organizer calIAttendee object based on the calendar's configured organizer id.
  *
  * @return calIAttendee object
@@ -611,19 +611,21 @@ ItipFindItemListener.prototype = {
                                             att = createOrganizer(newItem.calendar);
                                             if (att) {
                                                 att.isOrganizer = false;
                                                 newItem.addAttendee(att);
                                             }
                                         }
                                         if (att) {
                                             let action = function(opListener, partStat) {
-                                                if (partStat) {
-                                                    att.participationStatus = partStat;
+                                                if (!partStat) { // keep PARTSTAT
+                                                    let att_ = cal.getInvitedAttendee(item);
+                                                    partStat = (att_ ? att_.participationStatus : "NEEDS-ACTION");
                                                 }
+                                                att.participationStatus = partStat;
                                                 return newItem.calendar.modifyItem(
                                                     newItem, item, new ItipOpListener(opListener, item));
                                             };
                                             let isMinorUpdate = (cal.itip.getSequence(newItem) ==
                                                                  cal.itip.getSequence(item));
                                             actionMethod = (isMinorUpdate ? method + ":UPDATE-MINOR"
                                                                           : method + ":UPDATE");
                                             operations.push(action);
--- a/calendar/base/modules/calUtils.jsm
+++ b/calendar/base/modules/calUtils.jsm
@@ -125,21 +125,25 @@ let cal = {
             isInvitation = calendar.isInvitation(aItem);
         }
         return isInvitation;
     },
 
     /**
      * Shortcut function to check whether an item is an invitation copy and
      * has a participation status of either NEEDS-ACTION or TENTATIVE.
+     *
+     * @param aItem either calIAttendee or calIItemBase 
      */
     isOpenInvitation: function cal_isOpenInvitation(aItem) {
-        let att = cal.getInvitedAttendee(aItem);
-        if (att) {
-            switch (att.participationStatus) {
+        if (!cal.calInstanceOf(aItem, Components.interfaces.calIAttendee)) {
+            aItem = cal.getInvitedAttendee(aItem);
+        }
+        if (aItem) {
+            switch (aItem.participationStatus) {
                 case "NEEDS-ACTION":
                 case "TENTATIVE":
                     return true;
             }
         }
         return false;
     },
 
--- a/calendar/lightning/content/imip-bar.js
+++ b/calendar/lightning/content/imip-bar.js
@@ -240,16 +240,18 @@ addEventListener("messagepane-unloaded",
 
 var gItipItem = null;
 var gActionFunc = null;
 
 function ltnExecAction(partStat) {
     switch (gActionFunc.method) {
         // methods that don't require the calendar chooser:
         case "REFRESH":
+        case "REQUEST:UPDATE":
+        case "REQUEST:UPDATE-MINOR":
         case "PUBLISH:UPDATE":
         case "REPLY":
         case "CANCEL":
             break;
         default: {
             let cal = ltnGetTargetCalendar(gItipItem);
             if (!cal) {
                 return true; // cancelled