-
-
-// components defined in this file
+// Le composant définit pour cette extension
const DIVXPROT_HANDLER_CONTRACTID = "@mozilla.org/network/protocol;1?name=divx";
-const DIVXPROT_HANDLER_CID = Components.ID("{65aa548e-1dda-11dc-8314-0800200c9a66}");
+const DIVXPROT_HANDLER_CID = Components.ID("{65aa548e-1dda-11dc-8314-0800200c9a66}");
-// components used in this file
-const NS_IOSERVICE_CID = "{9ac9e770-18bc-11d3-9337-00104ba0fd40}";
-const NS_PREFSERVICE_CONTRACTID = "@mozilla.org/preferences-service;1";
-const URI_CONTRACTID = "@mozilla.org/network/simple-uri;1";
-const NS_WINDOWWATCHER_CONTRACTID = "@mozilla.org/embedcomp/window-watcher;1";
-const STREAMIOCHANNEL_CONTRACTID = "@mozilla.org/network/stream-io-channel;1";
-const kIOSERVICE_CONTRACTID = "@mozilla.org/network/io-service;1";\r
+// Les composants utilisés
+const URI_CONTRACTID = "@mozilla.org/network/simple-uri;1";
+const kIOSERVICE_CONTRACTID = "@mozilla.org/network/io-service;1";\r
-// interfaces used in this file
+// Les interfaces utilisées
const nsIProtocolHandler = Components.interfaces.nsIProtocolHandler;
const nsIURI = Components.interfaces.nsIURI;
const nsISupports = Components.interfaces.nsISupports;
const nsIIOService = Components.interfaces.nsIIOService;
-const nsIPrefService = Components.interfaces.nsIPrefService;
-const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher;
-const nsIChannel = Components.interfaces.nsIChannel;
-
-/***** ProtocolHandler *****/
-function Ten70ProtocolHandler(scheme)
+/**\r
+ * Classe ProtocolHandler.\r
+ */
+function ProtocolHandler(scheme)
{
this.scheme = scheme;
}
-// attribute defaults
-Ten70ProtocolHandler.prototype.defaultPort = -1;
-Ten70ProtocolHandler.prototype.protocolFlags = nsIProtocolHandler.URI_NORELATIVE;
-
-Ten70ProtocolHandler.prototype.allowPort = function(aPort, aScheme)
+// attributs par défaut
+DivxProtocolHandler.prototype.defaultPort = -1;
+DivxProtocolHandler.prototype.protocolFlags = nsIProtocolHandler.URI_NORELATIVE;
+\r
+/**\r
+ * est-ce qu'un port est autorisé.\r
+ */
+DivxProtocolHandler.prototype.allowPort = function(aPort, aScheme)
{
return false;
}
-
-Ten70ProtocolHandler.prototype.newURI = function(aSpec, aCharset, aBaseURI)
+\r
+/**\r
+ * Renvoie le nouvel URI.\r
+ */
+DivxProtocolHandler.prototype.newURI = function(aSpec, aCharset, aBaseURI)
{ \r
var uri = Components.classes[URI_CONTRACTID].createInstance(nsIURI);\r
uri.spec = aSpec;\r
return uri;
-}
-
-Ten70ProtocolHandler.prototype.newChannel = function(aURI)
+}\r
+\r
+/**\r
+ * Renvoie le nouveau channel.\r
+ */
+DivxProtocolHandler.prototype.newChannel = function(aURI)
{\r
var chemin = aURI.spec;\r
\r
var root = "F:/Films/";\r
chemin = chemin.replace("divx://", root)\r
\r
- dump(chemin);\r
- \r
- // create an nsILocalFile for the executable\r
+ //dump(chemin);\r
+ \r
+ // crée un nouveau fichier\r
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);\r
file.initWithPath("C:\\Program Files\\VideoLAN\\VLC\\vlc.exe");\r
\r
- // create an nsIProcess\r
+ // crée un nouveau processus\r
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);\r
process.init(file);\r
\r
- // Run the process.\r
- // If first param is true, calling thread will be blocked until\r
- // called process terminates.\r
- // Second and third params are used to pass command-line arguments\r
- // to the process.\r
+ // lance le processus. false pour ne pas être blockant\r
var args = [chemin, "-f"];\r
process.run(false, args, args.length);\r
- \r
- \r
+ \r
+ // trouver une méthode plus simple pour qu'il ne fasse rien..\r
var ios = Components.classes[kIOSERVICE_CONTRACTID].getService(nsIIOService);\r
-\r
return ios.newChannel("javascript:document.location='" + finalURL + "'", null, null);
}
-
-
-/***** DIVXProtocolHandlerFactory *****/
-
-function Ten70ProtocolHandlerFactory(scheme)
+\r
+/**\r
+ * Classe DivxProtocolHandlerFactory.\r
+ */
+function DivxProtocolHandlerFactory(scheme)
{
this.scheme = scheme;
-}
-
-Ten70ProtocolHandlerFactory.prototype.createInstance = function(outer, iid)
+}\r
+\r
+/**\r
+ * Méthode permettant la création d'objet de type 'DivxProtocolHandler'.\r
+ */
+DivxProtocolHandlerFactory.prototype.createInstance = function(outer, iid)
{
if(outer != null) throw Components.results.NS_ERROR_NO_AGGREGATION;
if(!iid.equals(nsIProtocolHandler) && !iid.equals(nsISupports))
throw Components.results.NS_ERROR_INVALID_ARG;
- return new Ten70ProtocolHandler(this.scheme);
-}
-
-var factory_divx = new Ten70ProtocolHandlerFactory("divx");
-
-/***** DIVXModule *****/
+ return new DivxProtocolHandler(this.scheme);
+}\r
+\r
+// la factory
+var factory_divx = new DivxProtocolHandlerFactory("divx");
+/**\r
+ * Notre module.\r
+ */
var DIVXModule = new Object();
-
+\r
+/**\r
+ * Appelé lors de l'enregistrement du module.\r
+ */
DIVXModule.registerSelf = function(compMgr, fileSpec, location, type)
{
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
- // register protocol handlers
+ // on enregistre le protocole handler
compMgr.registerFactoryLocation(DIVXPROT_HANDLER_CID,
- "DivX",
+ "divx",
DIVXPROT_HANDLER_CONTRACTID,
fileSpec, location, type);
}
-
+\r
+/**\r
+ * Appelé lors du déchargement du module.\r
+ */
DIVXModule.unregisterSelf = function(compMgr, fileSpec, location)
{
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
- // unregister our components
+ // on dés-enregistre notre protocole handler
compMgr.unregisterFactoryLocation(DIVXPROT_HANDLER_CID, fileSpec);
}
-
+\r
+/**\r
+ * Demande la factory pour construire le protocole handler.\r
+ */
DIVXModule.getClassObject = function(compMgr, cid, iid)
{
- if(!iid.equals(Components.interfaces.nsIFactory))
- throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
+ if(!iid.equals(Components.interfaces.nsIFactory))
+ throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
- if(cid.equals(DIVXPROT_HANDLER_CID)) return factory_divx;
+ if(cid.equals(DIVXPROT_HANDLER_CID)) return factory_divx;
- throw Components.results.NS_ERROR_NO_INTERFACE;
+ throw Components.results.NS_ERROR_NO_INTERFACE;
}
-
+\r
+/**\r
+ * Est-ce que le module peut être déchargé ?\r
+ */
DIVXModule.canUnload = function(compMgr)
{
return true;
}
-/***** Entrypoint *****/
-
+/**\r
+ * Le point d'entré, retourne le module.\r
+ */
function NSGetModule(compMgr, fileSpec)
{
return DIVXModule;