/* ***** 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
var gConsole = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);\r
-\r
var CHROME_XIMFMAIL_TREEDATA = "chrome://theme_ximfmail/content/ximfTreeData.rdf";\r
var gRelativeXimfTreePath = "extensions/{A627B834-BD9F-4b3f-9AF5-347B5A570402}/chrome/content/theme/ximfTreeDataBck.rdf";\r
-\r
/*\r
- * \r
+ *\r
*/\r
function XimfTreeData(){\r
// private:\r
var _rdfService = null;\r
var _rdfCUtils = null;\r
- \r
var _dsCatalog = null;\r
var _rootNode = null;\r
var _urlCatalog = CHROME_XIMFMAIL_TREEDATA;\r
- var _instanceCounter = 0; // instance counter for index RDF file\r
- \r
+ // instance counter for index RDF file\r
+ var _instanceCounter = 0;\r
function init(){\r
try{\r
- if(!_rdfService)\r
+ if (!_rdfService) {\r
_rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);\r
- \r
+ }\r
if(!_dsCatalog){\r
- //_dsCatalog = _rdfService.GetDataSource(CHROME_XIMFMAIL_TREEDATA);\r
- //_dsCatalog.RegisterDataSource(); \r
_dsCatalog = Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].createInstance(Components.interfaces.nsIRDFDataSource);\r
- //_dsCatalog = _rdfService.GetDataSource("rdf:ximfTree"); \r
+\r
}\r
- //_dsCatalog = Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].createInstance(Components.interfaces.nsIRDFDataSource);\r
- \r
- if(!_rdfCUtils)\r
+ if (!_rdfCUtils) {\r
_rdfCUtils = Components.classes["@mozilla.org/rdf/container-utils;1"].getService(Components.interfaces.nsIRDFContainerUtils);\r
+ }\r
}catch(e){\r
- gConsole.logStringMessage("[ximfmail - XimfTreeData.init ] \n " + e + "\nfile : " + e.fileName+"\nline : "+e.lineNumber); \r
+ gConsole.logStringMessage("[ximfmail - XimfTreeData.init ] \n " + e + "\nfile : " + e.fileName+"\nline : "+e.lineNumber);\r
return false;\r
- } \r
+ }\r
return true;\r
}\r
- \r
// public:\r
- if(typeof XimfTreeData.initialized == "undefined"){\r
+ if (typeof XimfTreeData.initialized === "undefined") {\r
/*\r
* read infomations from catalog\r
*/\r
XimfTreeData.prototype.getTarget = function(instance,predicate){\r
- try{\r
+ try {\r
init();\r
var resource = _rdfService.GetResource(instance);\r
var targets = _dsCatalog.ArcLabelsOut(resource);\r
- while (targets.hasMoreElements()){ \r
+ while (targets.hasMoreElements()) {\r
var newpredicate = targets.getNext();\r
- if (newpredicate instanceof Components.interfaces.nsIRDFResource){\r
+ if (newpredicate instanceof Components.interfaces.nsIRDFResource) {\r
var target = _dsCatalog.GetTarget(resource, newpredicate, true);\r
- /*if (target instanceof Components.interfaces.nsIRDFResource){\r
- alert("Resource is: " + target.Value);\r
- }else*/\r
- if (target instanceof Components.interfaces.nsIRDFLiteral){\r
- //alert(newpredicate.Value + " : \n\r" + target.Value);\r
- if(newpredicate.Value == predicate)\r
+ if (target instanceof Components.interfaces.nsIRDFLiteral && newpredicate.Value === predicate) {\r
return target.Value;\r
- }\r
+ }\r
}\r
}\r
- }catch(e){\r
- //alert("[XimfTreeData]error instance loading...." + e);\r
- gConsole.logStringMessage("[ximfmail - XimfTreeData.getTarget ] \n " + e + "\nfile : " + e.fileName+"\nline : "+e.lineNumber); \r
+ } catch(e) {\r
+ gConsole.logStringMessage("[ximfmail - XimfTreeData.getTarget ] \n " + e + "\nfile : " + e.fileName+"\nline : "+e.lineNumber);\r
}\r
};\r
/*\r
try{\r
// create Seq container\r
init();\r
- \r
// create our root nodes\r
- //_rootNode = RDF.GetResource("urn:root"); \r
- //var seqNode = RDF.GetResource("urn:root:seq"); \r
- \r
var seqCatalog = _rdfService.GetResource("http://www.ximfmail.com/catalog");\r
var RDFC_Cat = null;\r
try{\r
- RDFC_Cat = _rdfCUtils.MakeSeq(_dsCatalog, seqCatalog); \r
+ RDFC_Cat = _rdfCUtils.MakeSeq(_dsCatalog, seqCatalog);\r
}catch(e){\r
gConsole.logStringMessage("[ximfmail - XimfTreeData.registerXimfmailProfileNode ] \n " + e + "\nfile : " + Error().fileName+"\nline : "+Error().lineNumber);\r
- } \r
- \r
- //alert("RDFC_Cat count= "+RDFC_Cat.GetCount());\r
- \r
- /* */\r
- var baseTag = domProfile.getElementsByTagName("base"); \r
- if(baseTag.length <= 0) return; \r
- //alert(baseTag[0].getAttribute("name"))\r
- var tname = baseTag[0].getAttribute("name"); \r
+ }\r
+ var baseTag = domProfile.getElementsByTagName("base");\r
+ if (baseTag.length <= 0) {\r
+ return;\r
+ }\r
+ var tname = baseTag[0].getAttribute("name");\r
var baseURI = "http://www.ximfmail.com/catalog/" + tname;\r
- //alert("baseURI = " + baseURI); \r
- //_rdfContainer.AppendElement(_rdfService.GetResource(baseURI));\r
try{\r
- //var RDFC_Cat = Components.classes["@mozilla.org/rdf/container;1"].createInstance(Components.interfaces.nsIRDFContainer);\r
- //RDFC_Cat.Init(_dsCatalog, seqCatalog);\r
RDFC_Cat.AppendElement(_rdfService.GetResource(baseURI));\r
}catch(e){\r
gConsole.logStringMessage("[ximfmail - XimfTreeData.registerXimfmailProfileNode ] \n " + e + "\nfile : " + Error().fileName+"\nline : "+Error().lineNumber);\r
}\r
- \r
_dsCatalog.Assert(_rdfService.GetResource(baseURI),\r
_rdfService.GetResource("http://www.ximfmail.com/RDF#name"),\r
- _rdfService.GetLiteral(tname), true); \r
- \r
- \r
+ _rdfService.GetLiteral(tname), true);\r
_dsCatalog.Assert(_rdfService.GetResource(baseURI),\r
_rdfService.GetResource("http://www.ximfmail.com/RDF#dialogheader"),\r
- _rdfService.GetLiteral(baseURI+"/dialogheader"), true); \r
- \r
+ _rdfService.GetLiteral(baseURI+"/dialogheader"), true);\r
_dsCatalog.Assert(_rdfService.GetResource(baseURI),\r
_rdfService.GetResource("http://www.ximfmail.com/RDF#datas"),\r
_rdfService.GetLiteral(baseURI+"/datas"), true);\r
- \r
// Create dialogheader description\r
- var dlgUri = baseURI + "/dialogheader"; \r
- var seqNode = _rdfService.GetResource(dlgUri); \r
- var RDFC_Dgh = null; \r
+ var dlgUri = baseURI + "/dialogheader";\r
+ var seqNode = _rdfService.GetResource(dlgUri);\r
+ var RDFC_Dgh = null;\r
RDFC_Dgh = _rdfCUtils.MakeSeq(_dsCatalog, seqNode);\r
- //RDFC.Init(_dsCatalog, seqNode);\r
RDFC_Dgh.AppendElement(_rdfService.GetResource(dlgUri));\r
- \r
- var headerTag = baseTag[0].getElementsByTagName("header"); \r
+ var headerTag = baseTag[0].getElementsByTagName("header");\r
// append tiltle element <ximf:title>MCA</ximf:title>\r
- var title = headerTag[0].getElementsByTagName("title"); \r
+ var title = headerTag[0].getElementsByTagName("title");\r
_dsCatalog.Assert(_rdfService.GetResource(dlgUri),\r
_rdfService.GetResource("http://www.ximfmail.com/RDF#title"),\r
_rdfService.GetLiteral(title[0].textContent), true);\r
- \r
// append description element <ximf:descritpion>Mentions et clés d'attribution</ximf:descritpion>\r
var descritpion = headerTag[0].getElementsByTagName("description");\r
_dsCatalog.Assert(_rdfService.GetResource(dlgUri),\r
_rdfService.GetResource("http://www.ximfmail.com/RDF#description"),\r
_rdfService.GetLiteral(descritpion[0].textContent), true);\r
- \r
// append title colonne <ximf:column>clé</ximf:column>\r
var columnTag = headerTag[0].getElementsByTagName("column");\r
for(var x = 0; x < columnTag.length; ++x){\r
// append description element\r
_dsCatalog.Assert(_rdfService.GetResource(dlgUri),\r
_rdfService.GetResource("http://www.ximfmail.com/RDF#column"+x),\r
- _rdfService.GetLiteral(columnTag[x].textContent), true); \r
+ _rdfService.GetLiteral(columnTag[x].textContent), true);\r
}\r
- \r
- \r
- /* */\r
// Create datas descritpion\r
var datasUri = baseURI + "/datas";\r
var seqNode = _rdfService.GetResource(datasUri);\r
- var RDFC_data = null; \r
- try{ \r
+ var RDFC_data = null;\r
+ try{\r
RDFC_data = _rdfCUtils.MakeSeq(_dsCatalog, seqNode);\r
}catch(e){\r
- gConsole.logStringMessage("[ximfmail - XimfTreeData.registerXimfmailProfileNode ] \n " + e + "\nfile : " + Error().fileName+"\nline : "+Error().lineNumber);\r
- } \r
- //_rdfContainer.Init(_dsCatalog, seqNode);\r
- //var RDFC_Dat = Components.classes["@mozilla.org/rdf/container;1"].createInstance(Components.interfaces.nsIRDFContainer);\r
- //try{\r
- // RDFC_Dat.Init(_dsCatalog, seqNode); \r
- //}catch(e){\r
- // gConsole.logStringMessage("[ximfmail - XimfTreeData.registerXimfmailProfileNode ] \n " + e + "\nfile : " + Error().fileName+"\nline : "+Error().lineNumber);\r
- //}\r
- // add datas from xml profile to RDF file \r
- var treeTag = baseTag[0].getElementsByTagName("tree"); \r
+ gConsole.logStringMessage("[ximfmail - XimfTreeData.registerXimfmailProfileNode ] \n " + e + "\nfile : " + Error().fileName+"\nline : "+Error().lineNumber);\r
+ }\r
+ // add datas from xml profile to RDF file\r
+ var treeTag = baseTag[0].getElementsByTagName("tree");\r
var instanceTag = treeTag[0].getElementsByTagName("description");\r
for(var i = 0; i < instanceTag.length; ++i){\r
// append resource element to sequence\r
- var newURI = datasUri + "/data" + i; \r
- //_rdfContainer.AppendElement(_rdfService.GetResource(newURI));\r
+ var newURI = datasUri + "/data" + i;\r
RDFC_data.AppendElement(_rdfService.GetResource(newURI));\r
- \r
var instanceTagData = instanceTag[i].getElementsByTagName("data");\r
for(var j = 0; j < instanceTagData.length; ++j){\r
// append description element\r
_dsCatalog.Assert(_rdfService.GetResource(newURI),\r
_rdfService.GetResource("http://www.ximfmail.com/RDF#column"+j),\r
- _rdfService.GetLiteral(instanceTagData[j].textContent), true); \r
+ _rdfService.GetLiteral(instanceTagData[j].textContent), true);\r
}\r
}\r
- \r
- //_dsCatalog.RegisterDataSource(); \r
- }catch(e){ \r
+ }catch(e){\r
gConsole.logStringMessage("[ximfmail - XimfTreeData.registerXimfmailProfileNode ] \n " + e + "\nfile : " + Error().fileName+"\nline : "+Error().lineNumber);\r
- } \r
- \r
- // save datas to file \r
- /*\r
- _dsCatalog.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);\r
- var rdfXimfTreeDataPath = getFilePathInProfile(gRelativeXimfTreePath); \r
- _dsCatalog.FlushTo("file:///" + rdfXimfTreeDataPath); */ \r
+ }\r
};\r
- \r
XimfTreeData.prototype.getTitleHeader = function(key){\r
var uri = "http://www.ximfmail.com/catalog/"+ key + "/dialogheader";\r
return this.getTarget(uri,"http://www.ximfmail.com/RDF#title");\r
};\r
- \r
XimfTreeData.prototype.getDescriptionHeader = function(key){\r
var uri = "http://www.ximfmail.com/catalog/"+ key + "/dialogheader";\r
return this.getTarget(uri,"http://www.ximfmail.com/RDF#description");\r
};\r
- \r
XimfTreeData.prototype.getTitleColumn = function(key,idx){\r
var uri = "http://www.ximfmail.com/catalog/"+ key + "/dialogheader";\r
return this.getTarget(uri,"http://www.ximfmail.com/RDF#column"+idx);\r
};\r
- \r
XimfTreeData.initialized = true;\r
}\r
}
\ No newline at end of file