/* ***** BEGIN LICENSE BLOCK *****\r
* Copyright (c) 2008-2009 EADS DEFENCE AND SECURITY - All rights reserved.\r
* ximfmail is under the triple license MPL 1.1/GPL 2.0/LGPL 2.1.\r
- * \r
*\r
- * Redistribution and use, in source and binary forms, with or without modification, \r
+ *\r
+ * Redistribution and use, in source and binary forms, with or without modification,\r
* are permitted provided that the following conditons are met :\r
*\r
- * 1. Redistributions of source code must retain the above copyright notice, \r
- * 2. MPL 1.1/GPL 2.0/LGPL 2.1. license agreements must be attached \r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * 2. MPL 1.1/GPL 2.0/LGPL 2.1. license agreements must be attached\r
* in the redistribution of the source code.\r
- * 3. Neither the names of the copyright holders nor the names of any contributors \r
- * may be used to endorse or promote products derived from this software without specific \r
+ * 3. Neither the names of the copyright holders nor the names of any contributors\r
+ * may be used to endorse or promote products derived from this software without specific\r
* prior written permission from EADS Defence and Security.\r
- * \r
+ *\r
* Alternatively, the contents of this file may be used under the terms of\r
* either of the GNU General Public License Version 2 or later (the "GPL"),\r
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),\r
* and other provisions required by the GPL or the LGPL. If you do not delete\r
* the provisions above, a recipient may use your version of this file under\r
* the terms of any one of the MPL, the GPL or the LGPL.\r
- * \r
+ *\r
* REMINDER :\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND \r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \r
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \r
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \r
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \r
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING \r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\r
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\r
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- * \r
- * EADS Defence and Security - 1 Boulevard Jean Moulin - \r
- * ZAC de la Clef Saint Pierre - 78990 Elancourt - FRANCE (IDDN.FR.001.480012.002.S.P.2008.000.10000) \r
+ *\r
+ * EADS Defence and Security - 1 Boulevard Jean Moulin -\r
+ * ZAC de la Clef Saint Pierre - 78990 Elancourt - FRANCE (IDDN.FR.001.480012.002.S.P.2008.000.10000)\r
+ *\r
+ * Contributor(s):\r
+ * Copyright(c) Airbus Defence and Space 2014 - All rights reserved\r
* ***** END LICENSE BLOCK ***** */\r
- \r
-/* \r
- * global variables\r
- */\r
-var gXimfmailIdentity=null;\r
-\r
-/* \r
- * new theme selection : load instances of theme\r
- */\r
-function onCommandTheme(){ \r
- var themeRef = $("#listTheme").attr("value"); \r
- ChangeRefAttrRdfElement("instanceCompose", themeRef);\r
- InitRDFMenuList("instanceComposeList"); \r
- ChangeRefAttrRdfElement("instanceTreeThread", themeRef);\r
- InitRDFMenuList("instanceTreeThreadList");\r
- ChangeRefAttrRdfElement("instanceMailPanel", themeRef);\r
- InitRDFMenuList("instanceMailPanelList");\r
-};\r
-\r
-\r
-/*\r
- * load pref ximfmail settings\r
- */ \r
-function onInit(aPageId, aServerId){\r
- \r
- if(gXimfmailIdentity == null){\r
- // no account id (local folder)\r
- $("#checkListTheme").attr("checked", "false");\r
- UseXimfmail();\r
- $("#checkListTheme").attr("disabled", "true"); \r
- return; \r
- }\r
- $("#checkListTheme").removeAttr("disabled");\r
- \r
- //get XIMF instances of profile for account\r
- if(!gXimfCatalog) CreateXimfmailCatalog();\r
- var listInstances = document.getElementById("listThemPopup"); \r
- listInstances.database.AddDataSource(gXimfCatalog.getDSCatalog()); \r
- listInstances.builder.rebuild();\r
- \r
- //alert("Informations compte : \r\n\n" + aPageId + "\r\n"+ aServerId + "\r\n" + gXimfIdentity + "\r\n" + gXimfAccount.incomingServer.key);\r
- UpdateRDFListWithPref(gXimfmailIdentity.key,"ximfmail_theme_ref","listTheme");\r
- onCommandTheme();\r
- UpdateRDFListWithPref(gXimfmailIdentity.key,"ximfmail_instance_compose_ref","instanceComposeList");\r
- UpdateRDFListWithPref(gXimfmailIdentity.key,XIMF_PREF_IDENTITY_TREETHREAD_REF,"instanceTreeThreadList");\r
- UpdateRDFListWithPref(gXimfmailIdentity.key,XIMF_PREF_IDENTITY_MAIL_PANEL_REF,"instanceMailPanelList");\r
- \r
- // determine if user uses ximfmail \r
- if(gXimfmailIdentity.getBoolAttribute(XIMF_PREF_IDENTITY_USE_XIMFMAIL)){\r
- $("#checkListTheme").attr("checked", "true");\r
- }else{\r
- $("#checkListTheme").attr("checked", "false");\r
- }\r
- \r
- $("#listTheme").bind('command', onCommandTheme);\r
- $("#checkListTheme").click(UseXimfmail);\r
- UseXimfmail();\r
- \r
- // determine if user wants XSMTP compatibility\r
- $("#xsmtpComptibilityBox").attr("checked", gXimfmailIdentity.getBoolAttribute("ximfmail_xsmtp_compatibility_on"));\r
- //$("#secureHeadersRuleBox").attr("checked", gXimfmailIdentity.getBoolAttribute("ximfmail_secure_header_on"));\r
- //$("#signMsgAlwaysRuleBox").attr("checked", gXimfmailIdentity.getBoolAttribute("ximfmail_sign_message_always_on"));\r
-\r
+// get pref settings\r
+function onPreInit(account, accountValues) {\r
+ XimfmailAccountPage.getInstance().setIdentity(account.defaultIdentity);\r
}\r
-\r
-/*\r
- * \r
- */ \r
-function UseXimfmail(){\r
- //IsDisableXimfmailManager("checkListTheme","isUsingXimfail");\r
- //alert("UseXimfmail " +idCheckElement+" "+idBroadcaster );\r
- if($("#checkListTheme").attr("checked") == "true"){\r
- $("#isUsingXimfail").attr("disabled","false"); \r
- return false; \r
- }else{\r
- $("#isUsingXimfail").attr("disabled","true");\r
- return true;\r
- }\r
+function onInit(aPageId, aServerId) {\r
+ XimfmailAccountPage.getInstance().init();\r
}\r
- \r
-/*\r
- * get pref settings\r
- */\r
-function onPreInit(account, accountValues){\r
- gXimfmailIdentity = account.defaultIdentity;\r
+// save all changes on this page\r
+function onSave() {\r
+ XimfmailAccountPage.getInstance().save();\r
}\r
-\r
-/*\r
- * save all changes on this page\r
+/**\r
+ * Ximfmail settings account page\r
*/\r
-function onSave(){\r
- if(gXimfmailIdentity == null)return;\r
- // save ximfmail selection to preferences\r
- SetXimfmailPref(gXimfmailIdentity.key, "ximfmail_theme_ref", $("#listTheme").attr("value"));\r
- SetXimfmailPref(gXimfmailIdentity.key, "ximfmail_theme_name", $("#listTheme").attr("label"));\r
- SetXimfmailPref(gXimfmailIdentity.key, "ximfmail_instance_compose_ref", $("#instanceComposeList").attr("value")); \r
- gXimfmailIdentity.setCharAttribute(XIMF_PREF_IDENTITY_TREETHREAD_REF,$("#instanceTreeThreadList").attr("value"));\r
- gXimfmailIdentity.setCharAttribute(XIMF_PREF_IDENTITY_MAIL_PANEL_REF,$("#instanceMailPanelList").attr("value"));\r
- \r
- if($("#checkListTheme").attr("checked") == "true"){ \r
- gXimfmailIdentity.setBoolAttribute(XIMF_PREF_IDENTITY_USE_XIMFMAIL,true);\r
- try{CreateSecurityLabelXml()}catch(e){}\r
- }else{ \r
- gXimfmailIdentity.setBoolAttribute(XIMF_PREF_IDENTITY_USE_XIMFMAIL,false);\r
+var XimfmailAccountPage = ( function () {\r
+ var instantiated = null;\r
+ var accountIdentity = null;\r
+ var log = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);\r
+ // enable/disable ximfmail settings\r
+ function toogle(){\r
+ if ($("#checkListTheme").attr("checked") === "true") {\r
+ $("#isUsingXimfail").attr("disabled", "false");\r
+ } else {\r
+ $("#isUsingXimfail").attr("disabled", "true");\r
+ }\r
+ }\r
+ /*\r
+ * init default menulist xul element with first menuitem\r
+ * idMenuList : id of menulist xul element\r
+ */\r
+ function initEntryMenu(idMenuList){\r
+ var itemlist = $("#"+ idMenuList +" > menupopup > menuitem");\r
+ $("#"+idMenuList).attr("value",$(itemlist[0]).attr("value"));\r
+ $("#"+idMenuList).attr("label",$(itemlist[0]).attr("label"));\r
+ }\r
+ /*\r
+ * display user pref value in menulist if exists\r
+ * manage RDF Catalog list in accountWizard, accountManager\r
+ * identity : user identity key\r
+ * idPref : user preference key\r
+ * idList : id of menulist xul element\r
+ */\r
+ function initEntryMenuWithPref(idPref,idList){\r
+ var pref = ximfPref.get(accountIdentity.key,idPref);\r
+ log.logStringMessage("[am-ximfmail - initEntryMenuWithPref] pref : " + pref);\r
+ if (pref) {\r
+ var entry = document.getElementById(idList);\r
+ if(!entry){\r
+ log.logStringMessage("[am-ximfmail - initEntryMenuWithPref] unloaded entry : " + entry);\r
+ return;\r
+ }\r
+ var themeList = entry.menupopup.childNodes;\r
+ for (var i=0; i<themeList.length; ++i) {\r
+ if(themeList[i].localName === "menuitem") {\r
+ var themeListval = themeList[i].value;\r
+ if( pref === themeListval){\r
+ entry.value = themeListval;\r
+ entry.label = themeList[i].label;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
}\r
- \r
- if($("#xsmtpComptibilityBox").attr("checked") == "true"){\r
- gXimfmailIdentity.setBoolAttribute("ximfmail_xsmtp_compatibility_on",true); \r
- }else{\r
- gXimfmailIdentity.setBoolAttribute("ximfmail_xsmtp_compatibility_on",false);\r
- } \r
-}
\ No newline at end of file
+ // load instances of selected theme\r
+ function loadTheme() {\r
+ var themeRef = $("#listTheme").attr("value");\r
+ AddRdfDataSce2domList("instanceCompose", themeRef);\r
+ initEntryMenu("instanceComposeList");\r
+ AddRdfDataSce2domList("instanceTreeThread", themeRef);\r
+ initEntryMenu("instanceTreeThreadList");\r
+ };\r
+ /**\r
+ * Listener on datasources of istance definitions menu\r
+ */\r
+ var treebuilderListener = {\r
+ item: null,\r
+ willRebuild : function(builder) {\r
+ },\r
+ didRebuild : function(builder) {\r
+ // determine if user uses ximfmail\r
+ $("#checkListTheme").attr("checked", "false");\r
+ if (ximfPref.getBool(accountIdentity.key, ximfConst.XIMF_PREF_IDENTITY_USE_XIMFMAIL)) {\r
+ $("#checkListTheme").attr("checked", "true");\r
+ }\r
+ initEntryMenuWithPref("ximfmail_theme_ref","listTheme");\r
+ loadTheme();\r
+ initEntryMenuWithPref("ximfmail_instance_compose_ref","instanceComposeList");\r
+ initEntryMenuWithPref(ximfConst.XIMF_PREF_IDENTITY_TREETHREAD_REF,"instanceTreeThreadList");\r
+ $("#listTheme").bind('command', loadTheme);\r
+ $("#checkListTheme").click(toogle);\r
+ toogle();\r
+ // determine if user wants XSMTP compatibility\r
+ $("#xsmtpComptibilityBox").attr("checked", ximfPref.getBool(accountIdentity.key, "ximfmail_xsmtp_compatibility_on").toString());\r
+ }\r
+ };\r
+ //\r
+ function instantiate() {\r
+ return {\r
+ setIdentity : function (aIdentity) {\r
+ accountIdentity = aIdentity;\r
+ },\r
+ init : function () {\r
+ try {\r
+ if (!accountIdentity) {\r
+ // no account id (local folder)\r
+ $("#checkListTheme").attr("checked", "false");\r
+ toogle();\r
+ $("#checkListTheme").attr("disabled", "true");\r
+ return;\r
+ }\r
+ $("#checkListTheme").removeAttr("disabled");\r
+ //load XIMF instances of profile for account\r
+ XimfCatalogFactory.getIntance(function(instance){\r
+ var listInstances = document.getElementById("listThemPopup");\r
+ listInstances.database.AddDataSource(instance.getDSCatalog());\r
+ listInstances.builder.addListener(treebuilderListener);\r
+ listInstances.builder.rebuild();\r
+ });\r
+ } catch (ex) {\r
+ log.logStringMessage("[am-ximfmail] Error on init settings for account " + accountIdentity.key + " : " + ex);\r
+ }\r
+ },\r
+ save : function () {\r
+ try {\r
+ if (!accountIdentity) {\r
+ return;\r
+ }\r
+ // save ximfmail selection to preferences\r
+ ximfPref.set(accountIdentity.key, "ximfmail_theme_ref", $("#listTheme").attr("value"));\r
+ ximfPref.set(accountIdentity.key, "ximfmail_theme_name", $("#listTheme").attr("label"));\r
+ ximfPref.set(accountIdentity.key, "ximfmail_instance_compose_ref", $("#instanceComposeList").attr("value"));\r
+ ximfPref.set(accountIdentity.key, ximfConst.XIMF_PREF_IDENTITY_TREETHREAD_REF,$("#instanceTreeThreadList").attr("value"));\r
+ if($("#checkListTheme").attr("checked") === "true"){\r
+ ximfPref.setBool(accountIdentity.key, ximfConst.XIMF_PREF_IDENTITY_USE_XIMFMAIL,true);\r
+ try{\r
+ CreateSecurityLabelXml();\r
+ }catch(e){}\r
+ }else{\r
+ ximfPref.setBool(accountIdentity.key, ximfConst.XIMF_PREF_IDENTITY_USE_XIMFMAIL,false);\r
+ }\r
+ if($("#xsmtpComptibilityBox").attr("checked") === "true"){\r
+ ximfPref.setBool(accountIdentity.key, "ximfmail_xsmtp_compatibility_on",true);\r
+ }else{\r
+ ximfPref.setBool(accountIdentity.key, "ximfmail_xsmtp_compatibility_on",false);\r
+ }\r
+ log.logStringMessage("[am-ximfmail] Save settings for account " + accountIdentity.key);\r
+ } catch (ex) {\r
+ log.logStringMessage("[am-ximfmail] Error on saving settings for account " + accountIdentity.key + " : " + ex);\r
+ }\r
+ }\r
+ };\r
+ };\r
+ //\r
+ return {\r
+ getInstance : function(){\r
+ if(!instantiated){\r
+ instantiated = instantiate();\r
+ }\r
+ return instantiated;\r
+ }\r
+ };\r
+})();
\ No newline at end of file