--- /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
+// global variables\r
+var gCurrentIdentity=null;\r
+var gPreviousIdentity=null;\r
+var gComposeMsgByMenuitem=false;\r
+var gXimfThreadTree = null;\r
+\r
+var gConsole = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);\r
+var gXBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(null);\r
+\r
+var gChromeXslMsgCompose = "chrome://theme_ximfmail/content/messengerCompose-ximfmail.xsl";\r
+var gChromeXslTreeRcv = "chrome://theme_ximfmail/content/threadTree-ximfmail.xsl";\r
+\r
+\r
+/*\r
+ * init ximfmail on main panel\r
+ */\r
+$(document).ready(function(){\r
+ // init ximfmail operations\r
+ CreateXimfmailCatalog(); \r
+ gXimfThreadTree = new XimfThreadTree();\r
+ var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);\r
+ observerService.addObserver(XimfThreadTreeDBViewObserver, "MsgCreateDBView", false); \r
+\r
+ OnSelectfolderPane();\r
+\r
+ // event manager\r
+ $("#folderTree").select(OnSelectfolderPane);\r
+ //optional-for technical informations $("#threadTree").select(OnSelectMsg);\r
+ //opening message event\r
+ $("#threadTree").dblclick(OnOpenMsg); \r
+ $("#cmd_openMessage").bind("command",OnOpenMsg);\r
+ $("#key_openMessage").bind("command",OnOpenMsg);\r
+ $("#threadTree").keypress(OnOpenMsgWithKey); \r
+ //\r
+ $("#threadTree").click(UpdateThreadPane);\r
+ $("#button-newmsg").mousedown(OnSelectfolderPane); // load instances \r
+ $("#button-newmsg").bind('command', OnComposeDefaultMsg); // use default instance \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
+ \r
+ // Security Labels compatibility (RFC2634)\r
+ try{CreateSecurityLabelXml()}catch(e){}\r
+});\r
+\r
+\r
+/*\r
+ * save state of custom columns\r
+ */\r
+function UpdateThreadPane(){\r
+ if(gXimfThreadTree){ \r
+ gXimfThreadTree.saveColumnToHide();\r
+ }\r
+}\r
+\r
+ \r
+\r
+/*\r
+ * \r
+ */\r
+function OnOpenMsgWithKey(evt){ if(evt.keyCode == 13){OnOpenMsg();}}\r
+function OnOpenMsg(){\r
+ if(!gCurrentIdentity) return false; \r
+ if (IsXimfailActivated(gCurrentIdentity)){ \r
+ pref.setBoolPref("mailnews.headers.showXimfmail",true); \r
+ // flag on new open message requested\r
+ try{ \r
+ if(!pref.getBoolPref(PREF_MSGWINDOW_REFRESH)){\r
+ pref.setBoolPref(PREF_MSGWINDOW_REFRESH,true); \r
+ }else{\r
+ pref.setBoolPref(PREF_MSGWINDOW_REFRESH,false); \r
+ }\r
+ }catch(e){pref.setBoolPref(PREF_MSGWINDOW_REFRESH,true);}\r
+ }else{\r
+ pref.setBoolPref("mailnews.headers.showXimfmail",false); \r
+ }\r
+ return true; \r
+}\r
+\r
+/*\r
+ * \r
+ */\r
+function OnSelectMsg(){\r
+ try{\r
+ if(!gCurrentIdentity) return false; \r
+ if (IsXimfailActivated(gCurrentIdentity)){ \r
+ pref.setBoolPref("mailnews.headers.showXimfmail",true); \r
+ }else{\r
+ pref.setBoolPref("mailnews.headers.showXimfmail",false); \r
+ }\r
+ }catch(error){\r
+ gConsole.logStringMessage("ximfmail error - on select message : " + error);\r
+ }\r
+}\r
+\r
+/*\r
+ * define instance ximf to use\r
+ */ \r
+function OnCommandComposeMsgXimfmail(event){\r
+ gComposeMsgByMenuitem=true; \r
+ var pathXmlXimf = event.currentTarget.getAttribute("value"); \r
+ gXBranch.setCharPref("ximfmail.composeMsg.instance",pathXmlXimf); \r
+ var prefXsmtpCompatibility = GetXimfmailPref(gCurrentIdentity.key, "ximfmail_xsmtp_compatibility");\r
+ if(prefXsmtpCompatibility == "true"){ \r
+ gXBranch.setCharPref("ximfmail.composeMsg.xsmtp_on","true");\r
+ } \r
+}\r
+\r
+/*\r
+ * contexte compte utilisateur selectionné\r
+ */ \r
+function OnSelectfolderPane(){\r
+ try{\r
+ GetCurrentUser();\r
+ \r
+ if(!gCurrentIdentity){\r
+ gConsole.logStringMessage("[ximfmail - OnSelectfolderPane ] gCurrentIdentity invalid");\r
+ return;\r
+ } \r
+ \r
+ // custom-panel update\r
+ var title = GetXimfmailPref(gCurrentIdentity.key, "ximfmail_theme_name"); \r
+ $("#title-custom").attr("value",title); \r
+ \r
+ // load context of currentUser \r
+ var refRdf = GetXimfmailPref(gCurrentIdentity.key,"ximfmail_theme_ref"); \r
+ \r
+ ChangeRefAttrRdfElement("menupopup-newmsg", refRdf);\r
+ \r
+ // mailpanel instance : to display received/send messages\r
+ var mailInstance = GetXimfmailPref(gCurrentIdentity.key, "ximfmail_instance_mail_panel_ref");\r
+ gXBranch.setCharPref("mailnews.instance.mailpanel",mailInstance);\r
+ var mailTheme = GetXimfmailPref(gCurrentIdentity.key, "ximfmail_theme_ref");\r
+ gXBranch.setCharPref("mailnews.theme.mailpanel",mailTheme);\r
+\r
+ // is ximfail context used \r
+ if (IsXimfailActivated(gCurrentIdentity)){ \r
+ pref.setBoolPref("mailnews.headers.showXimfmail",true);\r
+ $("#menupopup-newmsg").attr("datasources","chrome://theme_ximfmail/content/ximfCatalog.rdf");\r
+ $("#ximfmail-custom-panel").attr("hidden","false"); \r
+ }else{\r
+ pref.setBoolPref("mailnews.headers.showXimfmail",false);\r
+ $("#menupopup-newmsg").attr("datasources","");\r
+ $("#ximfmail-custom-panel").attr("hidden","true"); \r
+ }\r
+ \r
+ // load custom tree\r
+ if( gPreviousIdentity != gCurrentIdentity){ \r
+ gPreviousIdentity = gCurrentIdentity;\r
+ if(gXimfThreadTree){ \r
+ gXimfThreadTree.createThreadTree();\r
+ gXimfThreadTree.addCustomColumnHandler();\r
+ }\r
+ } \r
+ }catch(e){\r
+ gConsole.logStringMessage("[ximfmail - OnSelectfolderPane ] \n " + e + "\nfile : " + Error().fileName+"\nline : "+Error().lineNumber); \r
+\r
+ }\r
+}\r
+\r
+/*\r
+ * \r
+ */ \r
+function OnComposeDefaultMsg(evt){\r
+ //alert("OnComposeDefaultMsg")\r
+ if(!gComposeMsgByMenuitem){\r
+ //alert("OnComposeInstanceMsg : " + $("#menupopup-newmsg").attr("ref"));\r
+ //var prefCompose = GetXimfmailPref(gCurrentIdentity.key, "ximfmail_instance_compose_ref");\r
+ \r
+ var idButton = evt.currentTarget.id;\r
+ var prefKey = ""; \r
+ if(idButton == "button-newmsg") prefKey = "ximfmail_instance_compose_ref";\r
+ if(idButton == "button-reply") prefKey = "ximfmail_instance_answer_ref";\r
+ if(idButton == "button-replyall") prefKey = "ximfmail_instance_answer_ref";\r
+ if(idButton == "button-forward") prefKey = "ximfmail_instance_forward_ref";\r
+ \r
+ if (IsXimfailActivated(gCurrentIdentity)){ \r
+ gXBranch.setCharPref("ximfmail.composeMsg.instance",GetXimfmailPref(gCurrentIdentity.key, prefKey));\r
+ }else{\r
+ gXBranch.setCharPref("ximfmail.composeMsg.instance",""); \r
+ } \r
+ }\r
+ gComposeMsgByMenuitem=false; \r
+}\r
+\r
+/*\r
+ * nom du compte utilisateur en cours d'utilisation\r
+ */\r
+ function GetCurrentUser() { \r
+ var folder=GetFirstSelectedMsgFolder();\r
+ var identity = null; \r
+ var server;\r
+ \r
+ try {\r
+ if (folder){\r
+ // Get the incoming server associated with this uri.\r
+ server = folder.server; \r
+ identity = getIdentityForServer(server);\r
+ } \r
+ }catch (ex){\r
+ gConsole.logStringMessage("ximfmail error - failed to get an identity to pre-select: " + error);\r
+ return "";\r
+ }\r
+ if(identity){\r
+ gCurrentIdentity=identity;\r
+ var prefName="mail.identity."+identity.key+".useremail";\r
+ try{\r
+ if(gXBranch.prefHasUserValue( prefName ))\r
+ return gXBranch.getCharPref(prefName); \r
+ }catch(exp){ \r
+ gConsole.logStringMessage("ximfmail error - failed to get the prefence account type : " + error);\r
+ }\r
+ } \r
+}\r