--- /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
+ *\r
+ * Contributor(s):\r
+ * Copyright(c) Airbus Defence and Space 2014 - All rights reserved\r
+ * ***** END LICENSE BLOCK ***** */\r
+/**\r
+ * Object to manage user preference for Ximfmail\r
+ */\r
+var ximfPref = ximfPref || {};\r
+ximfPref = {\r
+ log : function (sMessage, sFileName, iLineNumber) {\r
+ var trace = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);\r
+ if (sFileName) {\r
+ trace.logStringMessage("[controler-ximfmail] " + sMessage + "\nfile : " + sFileName + "\nline : " + sFileName);\r
+ } else {\r
+ trace.logStringMessage("[controler-ximfmail] " + sMessage);\r
+ }\r
+ },\r
+ get : function (idIdentity, key) {\r
+ var prefValue = undefined;\r
+ try {\r
+ var ximfmailPrefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("mail.identity." + idIdentity + ".");\r
+ if(ximfmailPrefBranch.prefHasUserValue(key)) {\r
+ prefValue = ximfmailPrefBranch.getCharPref(key);\r
+ }\r
+ } catch (ex) {\r
+ this.log(ex, Error().fileName, ex.lineNumber);\r
+ }\r
+ return prefValue;\r
+ },\r
+ set : function (idIdentity, key, value) {\r
+ try{\r
+ var prefSvc = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);\r
+ var ximfmailPrefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("mail.identity." + idIdentity + ".");\r
+ ximfmailPrefBranch.setCharPref(key,value);\r
+ prefSvc.savePrefFile(null);\r
+ this.log("set pref " + key + " of " + idIdentity + " to " + value);\r
+ }catch(ex){\r
+ this.log(ex, Error().fileName, ex.lineNumber);\r
+ }\r
+ },\r
+ getBool : function (idIdentity, key) {\r
+ var prefValue = undefined;\r
+ try {\r
+ var ximfmailPrefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("mail.identity." + idIdentity + ".");\r
+ if(ximfmailPrefBranch.prefHasUserValue(key)) {\r
+ prefValue = ximfmailPrefBranch.getBoolPref(key);\r
+ }\r
+ } catch (ex) {\r
+ this.log(ex, Error().fileName, ex.lineNumber);\r
+ }\r
+ return prefValue;\r
+ },\r
+ setBool: function (idIdentity, key, value) {\r
+ try{\r
+ var prefSvc = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);\r
+ var ximfmailPrefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("mail.identity." + idIdentity + ".");\r
+ ximfmailPrefBranch.setBoolPref(key, value);\r
+ prefSvc.savePrefFile(null);\r
+ this.log("set pref " + key + " of " + idIdentity + " to " + value);\r
+ }catch(ex){\r
+ this.log(ex, Error().fileName, ex.lineNumber);\r
+ }\r
+ },\r
+ isXimfAccountOn : function (identity) {\r
+ if (identity.getBoolAttribute("ximfmail_on")) {\r
+ return true;\r
+ } else {\r
+ return false;\r
+ }\r
+ },\r
+ reset : function (idIdentity,key) {\r
+ try{\r
+ var prefSvc = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);\r
+ var ximfmailPrefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("mail.identity." + idIdentity + ".");\r
+ ximfmailPrefBranch.ClearUserPref(key);\r
+ prefSvc.savePrefFile(null);\r
+ }catch(ex){\r
+ this.log(ex, Error().fileName, ex.lineNumber);\r
+ }\r
+ }\r
+};\r
+/**\r
+ * set value to reference attribute of xul element\r
+ * used for RDF resource\r
+ * idElement : id of xul element\r
+ * refValue : value of ref attribute\r
+ */\r
+function AddRdfDataSce2domList(idElement,refValue) {\r
+ var list = document.getElementById(idElement);\r
+ list.database.AddDataSource(XimfCatalog.getInstance().getDSCatalog());\r
+ list.setAttribute("ref",refValue);\r
+ list.builder.rebuild();\r
+}
\ No newline at end of file