| 1 | /* ***** BEGIN LICENSE BLOCK ***** |
|---|
| 2 | This program is free software; you can redistribute it and/or modify |
|---|
| 3 | it under the terms of the GNU General Public License as published by |
|---|
| 4 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 5 | (at your option) any later version. |
|---|
| 6 | |
|---|
| 7 | This program is distributed in the hope that it will be useful, |
|---|
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 10 | GNU General Public License for more details. |
|---|
| 11 | |
|---|
| 12 | You should have received a copy of the GNU General Public License |
|---|
| 13 | along with this program; if not, write to the Free Software |
|---|
| 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 15 | |
|---|
| 16 | The Original Code is the Virtual Identity Extension. |
|---|
| 17 | |
|---|
| 18 | The Initial Developer of the Original Code is Rene Ejury. |
|---|
| 19 | Portions created by the Initial Developer are Copyright (C) 2007 |
|---|
| 20 | the Initial Developer. All Rights Reserved. |
|---|
| 21 | |
|---|
| 22 | Contributor(s): |
|---|
| 23 | * ***** END LICENSE BLOCK ***** */ |
|---|
| 24 | |
|---|
| 25 | Components.utils.import("resource://v_identity/vI_nameSpaceWrapper.js"); |
|---|
| 26 | virtualIdentityExtension.ns(function () { |
|---|
| 27 | with(virtualIdentityExtension.LIB) { |
|---|
| 28 | var smartReply_dialog = { |
|---|
| 29 | Obj_radioGroup: null, |
|---|
| 30 | all_addresses: null, |
|---|
| 31 | parent_object: null, |
|---|
| 32 | |
|---|
| 33 | init: function () { |
|---|
| 34 | smartReply_dialog.Obj_radioGroup = document.getElementById("replySelector.radiogroup"); |
|---|
| 35 | smartReply_dialog.all_addresses = window.arguments[0]; |
|---|
| 36 | smartReply_dialog.parent_object = window.arguments[1]; |
|---|
| 37 | for (var index = 0; index < smartReply_dialog.all_addresses.number; index++) { |
|---|
| 38 | var menuentry = smartReply_dialog.all_addresses.identityDataCollection[index].combinedName; |
|---|
| 39 | |
|---|
| 40 | var id = null; |
|---|
| 41 | var smtp = null; |
|---|
| 42 | |
|---|
| 43 | if (smartReply_dialog.all_addresses.identityDataCollection[index].id) |
|---|
| 44 | id = smartReply_dialog.all_addresses.identityDataCollection[index].id.value; |
|---|
| 45 | if (smartReply_dialog.all_addresses.identityDataCollection[index].smtp) |
|---|
| 46 | smtp = smartReply_dialog.all_addresses.identityDataCollection[index].smtp.value; |
|---|
| 47 | |
|---|
| 48 | let defaultServerTag = Components.classes["@mozilla.org/intl/stringbundle;1"] |
|---|
| 49 | .getService(Components.interfaces.nsIStringBundleService) |
|---|
| 50 | .createBundle("chrome://messenger/locale/messenger.properties") |
|---|
| 51 | .GetStringFromName("defaultServerTag") |
|---|
| 52 | |
|---|
| 53 | menuentry += (id ? " (" + id + "," + (smtp ? smtp : defaultServerTag) + ")" : "") |
|---|
| 54 | smartReply_dialog.add_row(menuentry); |
|---|
| 55 | } |
|---|
| 56 | }, |
|---|
| 57 | |
|---|
| 58 | add_row: function (combinedName) { |
|---|
| 59 | var radio = document.createElement("radio"); |
|---|
| 60 | radio.setAttribute("label", combinedName); |
|---|
| 61 | smartReply_dialog.Obj_radioGroup.appendChild(radio); |
|---|
| 62 | }, |
|---|
| 63 | |
|---|
| 64 | accept: function () { |
|---|
| 65 | /* window.argument[2] stores callback function */ |
|---|
| 66 | window.arguments[2](smartReply_dialog.parent_object, smartReply_dialog.Obj_radioGroup.selectedIndex); |
|---|
| 67 | document.documentElement.acceptDialog(); |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | window.addEventListener("load", smartReply_dialog.init, false); |
|---|
| 71 | vI.smartReply_dialog = smartReply_dialog; |
|---|
| 72 | } |
|---|
| 73 | }); |
|---|