Fix bug 751923 - Failure during event creation [Exception 'TypeError: aItem.calendar.isInvitation is not a function' in calProviderUtils.jsm] (regression). r=mmecca
authorPhilipp Kewisch <mozilla@kewis.ch>
Fri, 18 May 2012 15:34:17 +0700
changeset 10208 4a12eafd0b08f5739b15599351729e17428e894e
parent 10207 d8c08657b36534b0f9d153900a513ece02c320d3
child 10209 920018c90abcb7f84ea2f35c4353e9efaef7530f
push id7738
push usermozilla@kewis.ch
push dateFri, 18 May 2012 08:35:11 +0000
treeherdercomm-central@4a12eafd0b08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmmecca
bugs751923
Fix bug 751923 - Failure during event creation [Exception 'TypeError: aItem.calendar.isInvitation is not a function' in calProviderUtils.jsm] (regression). r=mmecca
calendar/base/content/calendar-view-core.xml
calendar/base/content/dialogs/calendar-invitations-list.xml
calendar/base/modules/calItipUtils.jsm
calendar/itip/calItipEmailTransport.js
calendar/providers/caldav/calDavCalendar.js
--- a/calendar/base/content/calendar-view-core.xml
+++ b/calendar/base/content/calendar-view-core.xml
@@ -94,16 +94,17 @@
           </xul:box>
         </xul:hbox>
       </xul:vbox>
     </content>
 
     <implementation>
       <constructor><![CDATA[
          Components.utils.import("resource://calendar/modules/calAlarmUtils.jsm");
+         Components.utils.import("resource://calendar/modules/calUtils.jsm");
 
          let self = this;
          this.eventNameTextbox.onblur = function onBlur() {
              self.stopEditing(true);
          };
          this.eventNameTextbox.onkeypress = function onKeyPress(event) {
              // save on enter
              if (event.keyCode == 13)
@@ -249,19 +250,18 @@
           if (item.hasProperty("CLASS")) {
               this.setAttribute("itemclass", item.getProperty("CLASS"));
           }
 
           // calendar name
           this.setAttribute("calendar", item.calendar.name.toLowerCase());
 
           // Invitation
-          if (item.calendar instanceof Components.interfaces.calISchedulingSupport &&
-              item.calendar.isInvitation(item)) {
-              this.setAttribute("invitation-status", item.calendar.getInvitedAttendee(item).participationStatus);
+          if (cal.isInvitation(item)) {
+              this.setAttribute("invitation-status", cal.getInvitedAttendee(item).participationStatus);
               this.setAttribute("readonly", "true");
           } else if (!isCalendarWritable(item.calendar)) {
               this.setAttribute("readonly", "true");
           }
         ]]></body>
       </method>
 
       <method name="startEditing">
--- a/calendar/base/content/dialogs/calendar-invitations-list.xml
+++ b/calendar/base/content/dialogs/calendar-invitations-list.xml
@@ -135,16 +135,17 @@
               this, "anonid", "icon");
           icon.setAttribute("status", val);
           return val;
         ]]></setter>
       </property>
 
       <!-- constructor -->
       <constructor><![CDATA[
+        Components.utils.import("resource://calendar/modules/calUtils.jsm");
         this.mDateFormatter = getDateFormatter();
       ]]></constructor>
 
       <!-- methods -->
       <method name="setCalendarItem">
         <parameter name="aItem"/>
         <body>
           var alldayEventText = "&calendar.invitations.list.alldayevent.text;";
@@ -204,37 +205,34 @@
                     organizerString += org.id.replace(/^mailto:/i, "");
                 }
             }
             organizerLabel.setAttribute("value", organizerString);
 
             let attendeeLabel = document.getAnonymousElementByAttribute(
                 this, "anonid", "attendee");
             let attendeeString = attendeeText;
-            let att = aItem.calendar.getInvitedAttendee(aItem);;
+            let att = cal.getInvitedAttendee(aItem);
             if (att) {
                 if (att.commonName && att.commonName.length > 0) {
                     attendeeString += att.commonName;
                 } else if (att.id) {
                     attendeeString += att.id.replace(/^mailto:/i, "");
                 }
             }
             attendeeLabel.setAttribute("value", attendeeString);
             this.setAttribute("itemId", aItem.hashId);
           ]]>
         </body>
       </method>
 
       <method name="getCalendarItemParticipationStatus">
         <parameter name="aItem"/>
         <body><![CDATA[
-          var att;
-          if (calInstanceOf(aItem.calendar, Components.interfaces.calISchedulingSupport)) {
-              att = aItem.calendar.getInvitedAttendee(aItem);
-          }
+          let att = cal.getInvitedAttendee(aItem);
           return (att ? att.participationStatus : null);
         ]]></body>
       </method>
 
       <method name="setCalendarItemParticipationStatus">
         <parameter name="aItem"/>
         <parameter name="aStatus"/>
         <body><![CDATA[
--- a/calendar/base/modules/calItipUtils.jsm
+++ b/calendar/base/modules/calItipUtils.jsm
@@ -583,19 +583,17 @@ cal.itip = {
                         aOpType = Components.interfaces.calIOperationListener.DELETE;
                     }
                 }
             }
         }
 
         let autoResponse = { value: false }; // controls confirm to send email only once
 
-        let invitedAttendee = ((cal.calInstanceOf(aItem.calendar, Components.interfaces.calISchedulingSupport) &&
-                                aItem.calendar.isInvitation(aItem))
-                               ? aItem.calendar.getInvitedAttendee(aItem) : null);
+        let invitedAttendee = cal.isInvitation(aItem) && cal.getInvitedAttendee(aItem);
         if (invitedAttendee) { // actually is an invitation copy, fix attendee list to send REPLY
             /* 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)) {
--- a/calendar/itip/calItipEmailTransport.js
+++ b/calendar/itip/calItipEmailTransport.js
@@ -133,18 +133,17 @@ calItipEmailTransport.prototype = {
                                                 "lightning");
                     aBody = cal.calGetString("lightning",
                                              "itipCancelBody",
                                              [item.organizer ? item.organizer.toString() : "", summary],
                                              "lightning");
                     break;
                 case 'REPLY': {
                     // Get my participation status
-                    let att = (cal.calInstanceOf(aItipItem.targetCalendar, Components.interfaces.calISchedulingSupport)
-                               ? aItipItem.targetCalendar.getInvitedAttendee(item) : null);
+                    let att = cal.getInvitedAttendee(item, aItipItem.targetCalendar);
                     if (!att && aItipItem.identity) {
                         att = item.getAttendeeById("mailto:" + aItipItem.identity);
                     }
                     if (!att) { // should not happen anymore
                         return;
                     }
 
                     // work around BUG 351589, the below just removes RSVP:
--- a/calendar/providers/caldav/calDavCalendar.js
+++ b/calendar/providers/caldav/calDavCalendar.js
@@ -111,16 +111,18 @@ calDavCalendar.prototype = {
     classDescription: "Calendar CalDAV back-end",
 
     getInterfaces: function getInterfaces(count) {
         const ifaces = [Components.interfaces.calICalendarProvider,
                         Components.interfaces.nsIInterfaceRequestor,
                         Components.interfaces.calIFreeBusyProvider,
                         Components.interfaces.nsIChannelEventSink,
                         Components.interfaces.calIItipTransport,
+                        Components.interfaces.calISchedulingSupport,
+                        Components.interfaces.calICalendar,
                         Components.interfaces.calIChangeLog,
                         calICalDavCalendar,
                         Components.interfaces.nsIClassInfo,
                         Components.interfaces.nsISupports];
         count.value = ifaces.length;
         return ifaces;
     },
     getHelperForLanguage: function getHelperForLanguage(language) {