Fix bug 683988 - Event is accepted even though Cancel is selected on calendar choice popup. r=mmecca,a=philipp CLOSED TREE
authorPhilipp Kewisch <mozilla@kewis.ch>
Sat, 17 Sep 2011 00:55:00 +0200
changeset 8484 ecfbbd3762281e08d29b0de012a666db6b06edf4
parent 8483 fb023863690b904d58cf73f17fc687663d691e37
child 8485 11c4cb2ed3360e53ae604bdb73d424de8cb921fd
push id145
push usermozilla@kewis.ch
push dateMon, 19 Sep 2011 19:34:11 +0000
treeherdercomm-beta@ecfbbd376228 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmmecca, philipp
bugs683988
Fix bug 683988 - Event is accepted even though Cancel is selected on calendar choice popup. r=mmecca,a=philipp CLOSED TREE
calendar/base/modules/calItipUtils.jsm
calendar/lightning/content/imip-bar.js
--- a/calendar/base/modules/calItipUtils.jsm
+++ b/calendar/base/modules/calItipUtils.jsm
@@ -415,36 +415,38 @@ cal.itip = {
      * Scope: iTIP message receiver
      *
      * Prompt for the target calendar, if needed for the given method. This
      * calendar will be set on the passed itip item.
      *
      * @param aMethod       The method to check.
      * @param aItipItem     The itip item to set the target calendar on.
      * @param aWindow       The window to open the dialog on.
+     * @return              True, if a calendar was selected or no selection is
+     *                        needed.
      */
     promptCalendar: function promptCalendar(aMethod, aItipItem, aWindow) {
         let needsCalendar = false;
+        let targetCalendar = null;
         switch (aMethod) {
             // methods that don't require the calendar chooser:
             case "REFRESH":
             case "REQUEST:UPDATE":
             case "REQUEST:UPDATE-MINOR":
             case "PUBLISH:UPDATE":
             case "REPLY":
             case "CANCEL":
                 needsCalendar = false;
                 break;
             default: 
                 needsCalendar = true;
                 break;
         }
 
         if (needsCalendar) {
-            let targetCalendar = null;
             let calendars = cal.getCalendarManager().getCalendars({}).filter(cal.itip.isSchedulingCalendar);
 
             if (aItipItem.receivedMethod == "REQUEST") {
                 // try to further limit down the list to those calendars that
                 // are configured to a matching attendee;
                 let item = aItipItem.getItemList({})[0];
                 let matchingCals = calendars.filter(
                     function(calendar) {
@@ -473,16 +475,18 @@ cal.itip = {
                 aWindow.openDialog("chrome://calendar/content/chooseCalendarDialog.xul",
                                    "_blank", "chrome,titlebar,modal,resizable", args);
             }
 
             if (targetCalendar) {
               aItipItem.targetCalendar = targetCalendar;
             }
         }
+
+        return (!needsCalendar || targetCalendar != null);
     },
 
     /**
      * Scope: iTIP message receiver
      *
      * Checks the passed iTIP item and calls the passed function with options offered.
      *
      * @param itipItem iTIP item
--- a/calendar/lightning/content/imip-bar.js
+++ b/calendar/lightning/content/imip-bar.js
@@ -156,51 +156,51 @@ var ltnImipBar = {
                                            "ltnImipBar.executeAction('" + data[button].actionMethod + "')");
 
                 showElement(buttonElement);
             }
         }
     },
 
     executeAction: function ltnExecAction(partStat) {
-        cal.itip.promptCalendar(ltnImipBar.actionFunc.method, ltnImipBar.itipItem, window);
-
-        // hide the buttons now, to disable pressing them twice...
-        hideElement("imip-button1");
-        hideElement("imip-button2");
-        hideElement("imip-button3");
+        if (cal.itip.promptCalendar(ltnImipBar.actionFunc.method, ltnImipBar.itipItem, window)) {
+            // hide the buttons now, to disable pressing them twice...
+            hideElement("imip-button1");
+            hideElement("imip-button2");
+            hideElement("imip-button3");
 
-        let opListener = {
-            onOperationComplete: function ltnItipActionListener_onOperationComplete(aCalendar,
-                                                                                    aStatus,
-                                                                                    aOperationType,
-                                                                                    aId,
-                                                                                    aDetail) {
-                // For now, we just state the status for the user something very simple
-                let imipBar = document.getElementById("imip-bar");
-                let label = cal.itip.getCompleteText(aStatus, aOperationType);
-                imipBar.setAttribute("label", label);
+            let opListener = {
+                onOperationComplete: function ltnItipActionListener_onOperationComplete(aCalendar,
+                                                                                        aStatus,
+                                                                                        aOperationType,
+                                                                                        aId,
+                                                                                        aDetail) {
+                    // For now, we just state the status for the user something very simple
+                    let imipBar = document.getElementById("imip-bar");
+                    let label = cal.itip.getCompleteText(aStatus, aOperationType);
+                    imipBar.setAttribute("label", label);
 
-                if (!Components.isSuccessCode(aStatus)) {
-                  showError(label);
+                    if (!Components.isSuccessCode(aStatus)) {
+                        showError(label);
+                    }
+                },
+                onGetResult: function ltnItipActionListener_onGetResult(aCalendar,
+                                                                        aStatus,
+                                                                        aItemType,
+                                                                        aDetail,
+                                                                        aCount,
+                                                                        aItems) {
                 }
-            },
-            onGetResult: function ltnItipActionListener_onGetResult(aCalendar,
-                                                                    aStatus,
-                                                                    aItemType,
-                                                                    aDetail,
-                                                                    aCount,
-                                                                    aItems) {
+            };
+
+            try {
+                ltnImipBar.actionFunc(opListener, partStat);
+            } catch (exc) {
+                Components.utils.reportError(exc);
             }
-        };
-
-        try {
-            ltnImipBar.actionFunc(opListener, partStat);
-        } catch (exc) {
-            Components.utils.reportError(exc);
+            return true;
         }
-
-        return true;
+        return false;
     }
 };
 
 addEventListener("messagepane-loaded", ltnImipBar.load, true);
 addEventListener("messagepane-unloaded", ltnImipBar.unload, true);