/usr/share/xul-ext/ubufox/modules/PluginProviderPFS.jsm is in xul-ext-ubufox 2.0.2-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Plugin Finder Service.
*
* The Initial Developer of the Original Code is
* IBM Corporation.
* Portions created by the IBM Corporation are Copyright (C) 2004-2005
* IBM Corporation. All Rights Reserved.
*
* Contributor(s):
* Doron Rosenberg <doronr@us.ibm.com>
* Alexander Sack <asac@jwsdot.com> - Canonical Ltd.
* Chris Coulson <chris.coulson@canonical.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const Cu = Components.utils;
const Cc = Components.classes;
const Ci = Components.interfaces;
const nsIHttpProtocolHandler = Ci.nsIHttpProtocolHandler;
const nsIXULChromeRegistry = Ci.nsIXULChromeRegistry;
const nsIRDFService = Ci.nsIRDFService;
const nsIRDFRemoteDataSource = Ci.nsIRDFRemoteDataSource;
const nsIRDFXMLSink = Ci.nsIRDFXMLSink;
const nsIRDFDataSource = Ci.nsIRDFDataSource;
const nsIRDFContainer = Ci.nsIRDFContainer;
const nsIRDFResource = Ci.nsIRDFResource;
const nsIRDFLiteral = Ci.nsIRDFLiteral;
const PFS_NS = "http://www.mozilla.org/2004/pfs-rdf#";
var EXPORTED_SYMBOLS = [ ];
Cu.import("resource://ubufox/PluginFinder.jsm");
Cu.import("resource://gre/modules/Services.jsm");
["LOG", "WARN", "ERROR"].forEach(function(aName) {
this.__defineGetter__(aName, function() {
Components.utils.import("resource://gre/modules/AddonLogging.jsm");
LogManager.getLogger("ubufox.pluginprovider.pfs", this);
return this[aName];
});
}, this);
function getPluginInfoRequestObserver(aMimeType, aListener) {
this.mimetype = aMimeType;
this.listener = aListener;
}
getPluginInfoRequestObserver.prototype = {
onBeginLoad: function(aSink) {},
onInterrupt: function(aSink) {},
onResume: function(aSink) {},
onEndLoad: function(aSink) {
aSink.removeXMLSinkObserver(this);
let ds = aSink.QueryInterface(nsIRDFDataSource);
PluginProviderPFS.onDataSourceLoaded(ds, this.mimetype, this.listener);
},
onError: function(aSink, aStatus, aErrorMsg) {
aSink.removeXMLSinkObserver(this);
PluginProviderPFS.onDataSourceError(aStatus.toString(), this.mimetype, this.listener);
}
};
var PluginProviderPFS = {
get pfsURI() {
return Services.prefs.getCharPref("pfs.datasource.url");
//return "http://localhost/~chr1s/cgi-bin/plugin-finder.py?mimetype=%PLUGIN_MIMETYPE%&appID=%APP_ID%&appVersion=%APP_VERSION%&clientOS=%CLIENT_OS%&chromeLocale=%CHROME_LOCALE%&distributionID=%DIST_ID%";
},
get clientOS() {
if (!this._clientOS) {
this._clientOS = Cc["@mozilla.org/network/protocol;1?name=http"]
.getService(nsIHttpProtocolHandler).oscpu;
}
return this._clientOS;
},
get chromeLocale() {
if (!this._chromeLocale) {
this._chromeLocale = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(nsIXULChromeRegistry)
.getSelectedLocale("global");
}
return this._chromeLocale;
},
get distID() {
if (!this._distID) {
this._distID = Services.prefs.getCharPref("extensions.ubufox.release");
}
return this._distID;
},
get rdfService() {
if (!this._rdfService) {
this._rdfService = Cc["@mozilla.org/rdf/rdf-service;1"].getService(nsIRDFService);
}
return this._rdfService;
},
getPluginInfo: function PPPFS_getPluginInfo(aMimeType, aListener) {
LOG("Handling getPluginInfo for " + aMimeType);
let uri = this.pfsURI;
uri = uri.replace(/%PLUGIN_MIMETYPE%/g, encodeURIComponent(aMimeType));
uri = uri.replace(/%APP_ID%/g, Services.appinfo.ID);
uri = uri.replace(/%APP_VERSION%/g, Services.appinfo.platformBuildID);
uri = uri.replace(/%APP_RELEASE%/g, Services.appinfo.version);
uri = uri.replace(/%CLIENT_OS%/g, this.clientOS);
uri = uri.replace(/%CHROME_LOCALE%/g, this.chromeLocale);
uri = uri.replace(/%DIST_ID%/g, this.distID);
LOG("uri = " + uri);
let ds = this.rdfService.GetDataSource(uri);
let rds = ds.QueryInterface(nsIRDFRemoteDataSource);
if (rds.loaded) {
this.onDataSourceLoaded(ds, aMimeType, aListener);
} else {
let sink = ds.QueryInterface(nsIRDFXMLSink);
sink.addXMLSinkObserver(new getPluginInfoRequestObserver(aMimeType, aListener));
}
},
onDataSourceLoaded: function PPPFS_onDataSourceLoaded(aDataSource, aMimeType, aListener) {
let container = Cc["@mozilla.org/rdf/container;1"].createInstance(nsIRDFContainer);
let resultRes = this.rdfService.GetResource("urn:mozilla:plugin-results:" + aMimeType);
let pluginList = aDataSource.GetTarget(resultRes, this.rdfService.GetResource(PFS_NS+"plugins"), true);
var pluginInfos = [];
try {
container.Init(aDataSource, pluginList);
let children = container.GetElements();
// get the first item
while(children.hasMoreElements()) {
let target;
let child = children.getNext();
if (child instanceof nsIRDFResource) {
let name = this.rdfService.GetResource("http://www.mozilla.org/2004/pfs-rdf#updates");
target = aDataSource.GetTarget(child, name, true);
}
try {
container.Init(aDataSource, target);
var target2 = null;
let children2 = container.GetElements();
while (children2.hasMoreElements()) {
let child2 = children2.getNext();
if (child2 instanceof nsIRDFResource) {
target2 = child2;
}
var rdfs = this.rdfService;
function getPFSValueFromRDF(aValue) {
var rv = null;
var myTarget = aDataSource.GetTarget(target2, rdfs.GetResource(PFS_NS + aValue), true);
if (myTarget) {
rv = myTarget.QueryInterface(nsIRDFLiteral).Value;
}
return rv;
}
function getPFSBoolFromRDF(aValue) {
return getPFSValueFromRDF(aValue) == "true" ? true : false
}
let pid = getPFSValueFromRDF("guid");
if (pid == -1) {
continue;
}
let pluginInfo = {
name: getPFSValueFromRDF("name"),
pid: pid,
version: getPFSValueFromRDF("version"),
IconUrl: getPFSValueFromRDF("IconUrl"),
desc: getPFSValueFromRDF("description"),
homepage: getPFSValueFromRDF("homepage"),
licenseURL: getPFSValueFromRDF("licenseURL"),
needsRestart: getPFSBoolFromRDF("needsRestart"),
requestedMimeType: aMimeType
};
let XPILocation = getPFSValueFromRDF("XPILocation");
let installerLocation = getPFSValueFromRDF("InstallerLocation");
let manualInstallationURL = getPFSValueFromRDF("manualInstallationURL");
if (installerLocation) {
pluginInfo.location = installerLocation;
pluginInfo.hash = getPFSValueFromRDF("InstallerHash");
pluginInfo.type = "external";
} else if (XPILocation) {
pluginInfo.location = XPILocation;
let uri = Services.io.newURI(XPILocation, null, null);
if (uri.scheme = "apt") {
pluginInfo.type = "apt";
} else {
pluginInfo.type = "xpi";
pluginInfo.hash = getPFSValueFromRDF("XPIHash");
}
} else if (manualInstallationURL) {
pluginInfo.location = manualInstallationURL;
pluginInfo.type = "manual";
} else {
WARN("Plugin info contains no source information");
continue;
}
// no license provided, make it accepted
pluginInfo.licenseAccepted = pluginInfo.licenseURL ? false : true;
pluginInfos.push(pluginInfo);
}
} catch (ex) {
Cu.reportError(ex);
}
}
} catch (ex) {
Cu.reportError(ex);
}
aListener.pluginInfoReceived(pluginInfos);
},
onDataSourceError: function PPPFS_onDatasourceError(aError, aMimeType, aListener) {
ERROR(aError + " whilst handling request for mimetype " + aMimeType);
aListener.providerErrorReceived(aError);
}
};
var PluginProviderIface = {
getPluginInfo: function PFI_getPluginInfo(aMimeType, aListener) {
PluginProviderPFS.getPluginInfo(aMimeType, aListener);
}
};
PluginFinder.registerProvider(PluginProviderIface);
|