--- /dev/null
+/* ***** 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
+ * 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
+ * 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
+ * prior written permission from EADS Defence and Security.\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
+ * in which case the provisions of the GPL or the LGPL are applicable instead\r
+ * of those above. If you wish to allow use of your version of this file only\r
+ * under the terms of either the GPL or the LGPL, and not to allow others to\r
+ * use your version of this file under the terms of the MPL, indicate your\r
+ * decision by deleting the provisions above and replace them with the notice\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
+ * 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
+ * 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
+ * ***** END LICENSE BLOCK ***** */\r
+/**\r
+ * messenger-ov-ximfmail.js\r
+ *\r
+ */\r
+// global variables\r
+var gCurrentIdentity = null;\r
+var gPreviousIdentity = null;\r
+var gComposeMsgByMenuitem = false;\r
+var gConsole = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);\r
+gConsole.logStringMessage("[messenger-ov-ximfmail] file loaded");\r
+/*\r
+ * Get account user settings\r
+ */\r
+function GetCurrentXimfUser() {\r
+ try {\r
+ var folders = GetSelectedMsgFolders();\r
+ var identity = null;\r
+ var server = null;\r
+ var ximfUser = "";\r
+ if (folders.length > 0){\r
+ // Get the incoming server associated with this uri.\r
+ identity = getIdentityForServer(folders[0].server);\r
+ }\r
+ if (!identity) {\r
+ identity = MailServices.accounts.defaultAccount.defaultIdentity;\r
+ }\r
+ if (identity) {\r
+ gCurrentIdentity = identity;\r
+ var prefName="mail.identity."+identity.key+".useremail";\r
+ if (Services.prefs.prefHasUserValue( prefName )) {\r
+ ximfUser = Services.prefs.getCharPref(prefName);\r
+ }\r
+ }\r
+ }catch (ex){\r
+ gConsole.logStringMessage("[messenger-ov-ximfmail - GetCurrentXimfUser] failed to get an identity to pre-select: " + ex);\r
+ }\r
+ return ximfUser;\r
+};\r
+/**\r
+ * Compute DOM user folder with XIMF account user informations\r
+ */\r
+function OnSelectfolderPane() {\r
+ try{\r
+ // get current identity\r
+ GetCurrentXimfUser();\r
+ if (!gCurrentIdentity) {\r
+ gConsole.logStringMessage("[messenger-ov-ximfmail - OnSelectfolderPane ] gCurrentIdentity invalid");\r
+ return;\r
+ }\r
+ // custom-panel update\r
+ var title = ximfPref.get(gCurrentIdentity.key, "ximfmail_theme_name");\r
+ $("#title-custom").attr("value",title);\r
+ // load context of currentUser\r
+ var refRdf = ximfPref.get(gCurrentIdentity.key,"ximfmail_theme_ref");\r
+ AddRdfDataSce2domList("menupopup-newmsg", refRdf);\r
+ // mailpanel instance : to display compose messages\r
+ var mailTheme = ximfPref.get(gCurrentIdentity.key, "ximfmail_theme_ref");\r
+ Services.prefs.setCharPref("mailnews.theme.mailpanel",mailTheme);\r
+ // is ximfail context used\r
+ if (ximfPref.isXimfAccountOn(gCurrentIdentity)) {\r
+ Services.prefs.setBoolPref("mailnews.headers.showXimfmail",true);\r
+ $("#menupopup-newmsg").attr("datasources","chrome://theme_ximfmail/content/ximfCatalog.rdf");\r
+ $("#menupopup-newmsg menuitem").attr("hidden","false");\r
+ $("#ximfmail-custom-panel").removeAttr("collapsed");\r
+ $("#button-newmsg").attr("type","menu-button");\r
+ try {\r
+ // update secure headers settings file with ximf instance\r
+ var currentInstance = ximfPref.get(gCurrentIdentity.key, "ximfmail_instance_compose_ref");\r
+ gConsole.logStringMessage("[messenger-ov-ximfmail - OnSelectfolderPane - UpdateSecureHeadersFileSettings]currentInstance = " + currentInstance );\r
+ UpdateSecureHeadersFileSettings (currentInstance, gCurrentIdentity);\r
+ gConsole.logStringMessage("[messenger-ov-ximfmail - OnSelectfolderPane - UpdateSecureHeadersFileSettings] Succes updating secure headers file settings");\r
+ } catch (e) {\r
+ gConsole.logStringMessage("[messenger-ov-ximfmail - OnSelectfolderPane - UpdateSecureHeadersFileSettings] Problem updating secure headers file settings : " + e);\r
+ }\r
+ } else {\r
+ Services.prefs.setBoolPref("mailnews.headers.showXimfmail",false);\r
+ $("#menupopup-newmsg").attr("datasources","");\r
+ $("#menupopup-newmsg menuitem").attr("hidden","true");\r
+ $("#ximfmail-custom-panel").attr("collapsed","true");\r
+ $("#button-newmsg").attr("type","");\r
+ }\r
+ }catch(e){\r
+ gConsole.logStringMessage("[messenger-ov-ximfmail - OnSelectfolderPane ] " + e + "\nfile : " + Error().fileName+"\nline : "+Error().lineNumber);\r
+ }\r
+}\r
+/**\r
+ * Set/Unset XIMFMAIL flag on opening message\r
+ * @returns {Boolean}\r
+ */\r
+function OnOpenMsg(){\r
+ if (!gCurrentIdentity) {\r
+ return false;\r
+ }\r
+ if (ximfPref.isXimfAccountOn(gCurrentIdentity)){\r
+ Services.prefs.setBoolPref("mailnews.headers.showXimfmail",true);\r
+ // flag on new open message requested\r
+ try{\r
+ if(!Services.prefs.getBoolPref(ximfConst.PREF_MSGWINDOW_REFRESH)){\r
+ Services.prefs.setBoolPref(ximfConst.PREF_MSGWINDOW_REFRESH,true);\r
+ }else{\r
+ Services.prefs.setBoolPref(ximfConst.PREF_MSGWINDOW_REFRESH,false);\r
+ }\r
+ }catch(e){Services.prefs.setBoolPref(ximfConst.PREF_MSGWINDOW_REFRESH,true);}\r
+ }else{\r
+ Services.prefs.setBoolPref("mailnews.headers.showXimfmail",false);\r
+ }\r
+ return true;\r
+}\r
+/**\r
+ * Set/Unset XIMFMAIL flag on selected message\r
+ * @returns {Boolean}\r
+ */\r
+function OnSelectMsg(){\r
+ try{\r
+ if (!gCurrentIdentity) {\r
+ return false;\r
+ }\r
+ if (ximfPref.isXimfAccountOn(gCurrentIdentity)){\r
+ Services.prefs.setBoolPref("mailnews.headers.showXimfmail",true);\r
+ }else{\r
+ Services.prefs.setBoolPref("mailnews.headers.showXimfmail",false);\r
+ }\r
+ }catch(e){\r
+ gConsole.logStringMessage("[messenger-ov-ximfmail - OnSelectMsg ] " + e + "\nfile : " + Error().fileName+"\nline : "+Error().lineNumber);\r
+ }\r
+}\r
+/**\r
+ * Set instance ximf to use on composing message.\r
+ * Called on press new message button.\r
+ */\r
+function OnCommandComposeMsgXimfmail(event){\r
+ gComposeMsgByMenuitem=true;\r
+ var pathXmlXimf = event.currentTarget.getAttribute("value");\r
+ Services.prefs.setCharPref("ximfmail.composeMsg.instance",pathXmlXimf);\r
+ var prefXsmtpCompatibility = ximfPref.get(gCurrentIdentity.key, "ximfmail_xsmtp_compatibility");\r
+ if (prefXsmtpCompatibility === "true") {\r
+ Services.prefs.setCharPref("ximfmail.composeMsg.xsmtp_on", "true");\r
+ }\r
+}\r
+/**\r
+ * Set XIMF instance to use on composing message.\r
+ * @param evt\r
+ */\r
+function OnComposeDefaultMsg(evt){\r
+ if(!gComposeMsgByMenuitem){\r
+ var idButton = evt.currentTarget.id;\r
+ var prefKey = "";\r
+ if (idButton === "button-newmsg") {\r
+ prefKey = "ximfmail_instance_compose_ref";}\r
+ if (idButton === "button-reply") {\r
+ prefKey = "ximfmail_instance_answer_ref";\r
+ }\r
+ if (idButton === "button-replyall") {\r
+ prefKey = "ximfmail_instance_answer_ref";\r
+ }\r
+ if (idButton === "button-forward") {\r
+ prefKey = "ximfmail_instance_forward_ref";\r
+ }\r
+ if (ximfPref.isXimfAccountOn(gCurrentIdentity)) {\r
+ Services.prefs.setCharPref("ximfmail.composeMsg.instance", ximfPref.get(gCurrentIdentity.key, prefKey));\r
+ } else {\r
+ Services.prefs.setCharPref("ximfmail.composeMsg.instance","");\r
+ }\r
+ }\r
+ gComposeMsgByMenuitem=false;\r
+}\r
+/**\r
+ * Update main panel with XIMF environment\r
+ */\r
+$(document).ready(function(){\r
+ // event manager\r
+ $("#folderTree").select(OnSelectfolderPane);\r
+ $("#threadTree").dblclick(OnOpenMsg);\r
+ $("#cmd_openMessage").bind("command",OnOpenMsg);\r
+ $("#key_openMessage").bind("command",OnOpenMsg);\r
+ $("#threadTree").keypress(function(evt){\r
+ if(evt.keyCode === 13){\r
+ OnOpenMsg();\r
+ }\r
+ });\r
+ // load instances\r
+ $("#button-newmsg").mousedown(OnSelectfolderPane);\r
+ // use default instance\r
+ $("#button-newmsg").bind('command', OnComposeDefaultMsg);\r
+ $("#button-reply").mousedown(OnSelectfolderPane);\r
+ $("#button-reply").bind('command', OnComposeDefaultMsg);\r
+ $("#button-replyall").mousedown(OnSelectfolderPane);\r
+ $("#button-replyall").bind('command', OnComposeDefaultMsg);\r
+ $("#button-forward").mousedown(OnSelectfolderPane);\r
+ $("#button-forward").bind('command', OnComposeDefaultMsg);\r
+ $("#threadTree").bind('select', OnSelectMsg);\r
+ // Creating Ximf Custom Columns\r
+ var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);\r
+ observerService.addObserver(XimfThreadTreeDBViewObserver, "MsgCreateDBView", false);\r
+ // switch to current folder\r
+ OnSelectfolderPane();\r
+ try{\r
+ // Security Labels compatibility (RFC2634)\r
+ CreateSecurityLabelXml();\r
+ } catch(e) {\r
+ gConsole.logStringMessage("[messenger-ov-ximfmail] Warning - Security Label compatibility : " + e);\r
+ }\r
+});
\ No newline at end of file