зеркало из https://github.com/mozilla/gecko-dev.git
170006 - more EM updates - make the update checker work with darin's patch to DefaultSOAPEncoder.
This commit is contained in:
Родитель
c06e8597dd
Коммит
1c2b923fe9
|
@ -1,15 +1,16 @@
|
|||
|
||||
var gUpdateDialog = {
|
||||
_updateType: "",
|
||||
_extensionManager: "",
|
||||
_extensionID: "",
|
||||
_openTime: null,
|
||||
_brandShortName: "",
|
||||
_updateStrings: null,
|
||||
_extensionsToUpdate: [],
|
||||
|
||||
_messages: ["update-start",
|
||||
"update-end",
|
||||
"update-item-network-start",
|
||||
"update-item-network-end",
|
||||
"update-item-processing-start",
|
||||
"update-item-processing-end",
|
||||
_messages: ["update-started",
|
||||
"update-ended",
|
||||
"update-item-started",
|
||||
"update-item-ended",
|
||||
"update-item-error"],
|
||||
|
||||
init: function ()
|
||||
|
@ -23,36 +24,46 @@ var gUpdateDialog = {
|
|||
for (var i = 0; i < this._messages.length; ++i)
|
||||
os.addObserver(this, this._messages[i], false);
|
||||
|
||||
this._openTime = Math.abs(Date.UTC());
|
||||
|
||||
this._brandShortName = document.getElementById("brandStrings").getString("brandShortName");
|
||||
this._updateStrings = document.getElementById("extensionsStrings");
|
||||
|
||||
if (this._updateType == "extensions")
|
||||
this._extensionManager.updateExtension(this._extensionID, window);
|
||||
else if (gUpdateType == "themes")
|
||||
this._extensionManager.updateTheme(this._extensionID);
|
||||
},
|
||||
|
||||
uninit: function ()
|
||||
{
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
for (var i = 0; i < this._messages.length; ++i)
|
||||
os.removeObserver(this, this._messages[i]);
|
||||
},
|
||||
|
||||
observe: function (aSubject, aTopic, aData)
|
||||
{
|
||||
switch (aTopic) {
|
||||
case "update-started":
|
||||
dump("*** update-started: " + aSubject + ", " + aData + "\n");
|
||||
break;
|
||||
case "update-item-started":
|
||||
dump("*** update-item-started: " + aSubject + ", " + aData + "\n");
|
||||
break;
|
||||
case "update-item-ended":
|
||||
dump("*** update-item-ended: " + aSubject + ", " + aData + "\n");
|
||||
this._extensionsToUpdate.push(aSubject);
|
||||
break;
|
||||
case "update-ended":
|
||||
dump("*** update-ended: " + aSubject + ", " + aData + "\n");
|
||||
/*
|
||||
var installObj = { };
|
||||
for (var i = 0; i < aExtensions.length; ++i) {
|
||||
var e = aExtensions[i];
|
||||
var name = ds.getExtensionProperty(e.id, "name");
|
||||
installObj[name + " " + e.version] = e.xpiURL;
|
||||
for (var i = 0; i < this._extensionsToUpdate.length; ++i) {
|
||||
var e = this._extensionsToUpdate[i];
|
||||
installObj[e.name + " " + e.version] = e.xpiURL;
|
||||
}
|
||||
if (trigger.updateEnabled())
|
||||
trigger.install(installObj);
|
||||
break; */
|
||||
if (InstallTrigger.updateEnabled())
|
||||
InstallTrigger.install(installObj);
|
||||
|
||||
document.documentElement.acceptDialog();
|
||||
break;
|
||||
/*
|
||||
case "update-start":
|
||||
dump("*** update-start: " + aSubject + ", " + aData + "\n");
|
||||
|
|
|
@ -49,11 +49,15 @@
|
|||
<dialog id="updateProgress" title="&update.title;"
|
||||
style="width: 30em;"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
buttons="cancel" onload="gUpdateDialog.init();" oncancel="onCancelUpdateCheck();">
|
||||
|
||||
buttons="cancel"
|
||||
onload="gUpdateDialog.init();"
|
||||
onunload="gUpdateDialog.uninit();"
|
||||
oncancel="onCancelUpdateCheck();">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://mozapps/content/extensions/update.js"/>
|
||||
|
||||
<stringbundleset id="updateSet">
|
||||
<stringbundle id="brandStrings" src="chrome://global/locale/brand.properties"/>
|
||||
<stringbundle id="extensionsStrings" src="chrome://mozapps/locale/extensions/extensions.properties"/>
|
||||
</stringbundleset>
|
||||
|
||||
|
|
|
@ -15,4 +15,3 @@ statusConnecting=Connecting to %S, please wait...
|
|||
statusProcessing=Processing data...
|
||||
statusConnectionFailed=Connection to %S failed, skipping...
|
||||
progress=(%S of %S items complete)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!ENTITY update.title "Checking for Updates">
|
||||
<!ENTITY intro.label "&brandShortName; is now checking for updates to:">
|
||||
<!ENTITY intro.label "&brandShortName; is now checking for updates to your extensions...">
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -46,20 +46,15 @@ public class VersionCheck
|
|||
{
|
||||
}
|
||||
|
||||
/*
|
||||
public static void main(String[] args) throws Exception
|
||||
/*
|
||||
public static void main(String[] args)
|
||||
{
|
||||
VersionCheck impl = new VersionCheck();
|
||||
int id = impl.getNewestExtension("{bb8ee064-ccb9-47fc-94ae-ec335af3fe2d}", "3.0", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}", "0.8.0+");
|
||||
System.out.println("result = " + impl.getProperty(id, "xpiurl"));
|
||||
}
|
||||
*/
|
||||
|
||||
protected Connection getConnection() throws Exception
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
return DriverManager.getConnection("jdbc:mysql://localhost/umo_extensions", "root", "");
|
||||
// int id = impl.getNewestExtension("{bb8ee064-ccb9-47fc-94ae-ec335af3fe2d}", "3.0", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}", "0.8.0+");
|
||||
int id = impl.getNewestExtension("{93c4cb22-bf10-40a2-adff-c4c64a38df0c}", "1.5", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}", "0.8.0+");
|
||||
System.out.println("result row = " + id + ", xpiUrl = " + impl.getProperty(id, "xpiurl"));
|
||||
}
|
||||
*/
|
||||
|
||||
public Extension[] getExtensionsToUpdate(Extension[] aExtensions, String aTargetApp, String aTargetAppVersion)
|
||||
{
|
||||
|
@ -67,12 +62,14 @@ public class VersionCheck
|
|||
for (int i = 0; i < aExtensions.length; ++i)
|
||||
{
|
||||
Extension e = aExtensions[i];
|
||||
int id = getNewestExtension(e.getId(), e.getVersion(), aTargetApp, aTargetAppVersion);
|
||||
if (id != -1)
|
||||
int row = getNewestExtension(e.getId(), e.getVersion(), aTargetApp, aTargetAppVersion);
|
||||
if (row != -1)
|
||||
{
|
||||
e.setRow(id);
|
||||
e.setVersion(getProperty(id, "version"));
|
||||
e.setXpiURL(getProperty(id, "xpiurl"));
|
||||
e.setRow(row);
|
||||
e.setId(getProperty(row, "guid"));
|
||||
e.setName(getProperty(row, "name"));
|
||||
e.setVersion(getProperty(row, "version"));
|
||||
e.setXpiURL(getProperty(row, "xpiurl"));
|
||||
results.add(e);
|
||||
}
|
||||
}
|
||||
|
@ -86,32 +83,18 @@ public class VersionCheck
|
|||
String aTargetApp,
|
||||
String aTargetAppVersion)
|
||||
{
|
||||
Extension e = null;
|
||||
|
||||
int id = getNewestExtension(aExtension.getId(), aExtension.getVersion(),
|
||||
aTargetApp, aTargetAppVersion);
|
||||
if (id != -1)
|
||||
{
|
||||
e = new Extension();
|
||||
e.setRow(id);
|
||||
e.setName(getProperty(id, "name"));
|
||||
e.setVersion(getProperty(id, "version"));
|
||||
e.setXpiURL(getProperty(id, "xpiurl"));
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
public Extension getExtension(String aExtensionGUID, String aInstalledVersion, String aTargetApp, String aTargetAppVersion)
|
||||
{
|
||||
int id = getNewestExtension(aExtensionGUID, aInstalledVersion, aTargetApp, aTargetAppVersion);
|
||||
|
||||
Extension e = new Extension();
|
||||
e.setRow(id);
|
||||
e.setId(getProperty(id, "id"));
|
||||
e.setVersion(getProperty(id, "version"));
|
||||
e.setName(getProperty(id, "name"));
|
||||
e.setXpiURL(getProperty(id, "xpiurl"));
|
||||
|
||||
int row = getNewestExtension(aExtension.getId(), aExtension.getVersion(),
|
||||
aTargetApp, aTargetAppVersion);
|
||||
if (row != -1)
|
||||
{
|
||||
e.setRow(row);
|
||||
e.setId(getProperty(row, "guid"));
|
||||
e.setName(getProperty(row, "name"));
|
||||
e.setVersion(getProperty(row, "version"));
|
||||
e.setXpiURL(getProperty(row, "xpiurl"));
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
|
@ -218,5 +201,11 @@ public class VersionCheck
|
|||
{
|
||||
return (new StringTokenizer(aVersionString, ".")).countTokens();
|
||||
}
|
||||
|
||||
protected Connection getConnection() throws Exception
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
return DriverManager.getConnection("jdbc:mysql://localhost/umo_extensions", "root", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,11 +145,11 @@ nsExtensionManager.prototype = {
|
|||
var appVersion = pref.getCharPref(PREF_EM_APP_VERSION);
|
||||
|
||||
var extensions = this._ds.getExtensionList(aExtensionID);
|
||||
var updater = new nsExtensionUpdater2(extensions, appID, appVersion);
|
||||
updater.loadSchema();
|
||||
// var updater = new nsExtensionUpdater2(extensions, appID, appVersion);
|
||||
// updater.loadSchema();
|
||||
|
||||
// var updater = new nsExtensionUpdater(extensions, appID, appVersion);
|
||||
// updater.checkForUpdates();
|
||||
var updater = new nsExtensionUpdater(extensions, appID, appVersion);
|
||||
updater.checkForUpdates();
|
||||
},
|
||||
|
||||
// Themes
|
||||
|
@ -201,112 +201,6 @@ nsExtensionManager.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
function nsExtensionUpdater2(aExtensions,
|
||||
aTargetAppID, aTargetAppVersion)
|
||||
{
|
||||
this._extensions = aExtensions;
|
||||
this._count = aExtensions.length;
|
||||
this._appID = aTargetAppID;
|
||||
this._appVersion = aTargetAppVersion;
|
||||
|
||||
this._os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
}
|
||||
|
||||
nsExtensionUpdater2.prototype = {
|
||||
_extensionSchemaType: null,
|
||||
loadSchema: function ()
|
||||
{
|
||||
function SchemaLoaderListener(aUpdater)
|
||||
{
|
||||
this._updater = aUpdater;
|
||||
}
|
||||
|
||||
SchemaLoaderListener.prototype = {
|
||||
onLoad: function (aSchema)
|
||||
{
|
||||
dump("*** schema loaded = " + aSchema + "\n");
|
||||
var count = aSchema.typeCount;
|
||||
for (var i = 0; i < count; ++i) {
|
||||
var type = aSchema.getTypeByIndex(i);
|
||||
dump("*** schema type = " + type.name + "\n");
|
||||
}
|
||||
|
||||
this._updater._extensionSchemaType = aSchema.getTypeByName("Extension");
|
||||
|
||||
this._updater._schemaLoaded();
|
||||
},
|
||||
|
||||
onError: function (aStatus, aMessage)
|
||||
{
|
||||
dump("*** schema load error " + aStatus + ", msg = " + aMessage + "\n");
|
||||
}
|
||||
};
|
||||
|
||||
var schemaLoader = Components.classes["@mozilla.org/xmlextras/schemas/schemaloader;1"]
|
||||
.createInstance(Components.interfaces.nsISchemaLoader);
|
||||
var schemaLoaderListener = new SchemaLoaderListener(this);
|
||||
schemaLoader.loadAsync("http://www.bengoodger.com/software/mb/umo/types.xsd",
|
||||
schemaLoaderListener);
|
||||
},
|
||||
|
||||
_schemaLoaded: function ()
|
||||
{
|
||||
var call = Components.classes["@mozilla.org/xmlextras/soap/call;1"]
|
||||
.createInstance(Components.interfaces.nsISOAPCall);
|
||||
call.transportURI = "http://localhost:8080/axis/services/VersionCheck";
|
||||
|
||||
for (var i = 0; i < this._extensions.length; ++i) {
|
||||
var e = this._extensions[i];
|
||||
|
||||
var params = [this._createParam("in0", e, this._extensionSchemaType),
|
||||
this._createParam("in1", this._appID, null),
|
||||
this._createParam("in2", this._appVersion, null)];
|
||||
call.encode(0, "getNewestExtension", "urn:VersionCheck", 0, null, params.length, params);
|
||||
var response = call.invoke();
|
||||
dump("*** response = " + response + "\n");
|
||||
var count = { };
|
||||
var params;
|
||||
response.getParameters(false, count, params);
|
||||
dump("*** params = " + count.value + "\n");
|
||||
for (var j = 0; j < count.value; ++j) {
|
||||
var param = params[j];
|
||||
dump("*** param = " + param.name + ", parm = " + param + ", element = " + param.element + ", value = " + param.value + "\n");
|
||||
// var v = param.value.QueryInterface(Components.interfaces.nsIVariant);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_walkKids: function (e)
|
||||
{
|
||||
for (var i = 0; i < e.childNodes.length; ++i) {
|
||||
var kid = e.childNodes[i];
|
||||
dump("<" + kid.nodeName);
|
||||
for (var k = 0; k < kid.attributes.length; ++k)
|
||||
dump(" " + kid.attributes[k] + "=" + kid.getAttribute(kid.attributes[k]));
|
||||
if (kid.hasChildNodes()) {
|
||||
this._walkKids(kid);
|
||||
dump("</" + kid.nodeName);
|
||||
}
|
||||
else
|
||||
dump(">");
|
||||
}
|
||||
},
|
||||
|
||||
_createParam: function (aParamName, aParamValue, aParamSchemaType)
|
||||
{
|
||||
var param = Components.classes["@mozilla.org/xmlextras/soap/parameter;1"]
|
||||
.createInstance(Components.interfaces.nsISOAPParameter);
|
||||
param.name = aParamName;
|
||||
param.namespaceURI = "urn:VersionCheck";
|
||||
if (aParamSchemaType)
|
||||
param.schemaType = aParamSchemaType;
|
||||
param.value = aParamValue;
|
||||
return param;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
function nsExtensionUpdater(aExtensions,
|
||||
aTargetAppID, aTargetAppVersion)
|
||||
{
|
||||
|
@ -324,6 +218,7 @@ nsExtensionUpdater.prototype = {
|
|||
//
|
||||
checkForUpdates: function ()
|
||||
{
|
||||
this._os.notifyObservers(null, "update-started", "");
|
||||
var wspFactory = Components.classes["@mozilla.org/xmlextras/proxy/webserviceproxyfactory;1"]
|
||||
.getService(Components.interfaces.nsIWebServiceProxyFactory);
|
||||
wspFactory.createProxyAsync("http://localhost:8080/axis/services/VersionCheck?wsdl",
|
||||
|
@ -332,20 +227,12 @@ nsExtensionUpdater.prototype = {
|
|||
|
||||
_proxy: null,
|
||||
|
||||
_getExtensionsToUpdate: function ()
|
||||
{
|
||||
this._proxy.getExtensionsToUpdate(this._extensions, this._appID, this._appVersion);
|
||||
},
|
||||
|
||||
_checkForUpdates: function ()
|
||||
{
|
||||
this._os.notifyObservers(null, "update-started", "");
|
||||
//
|
||||
for (var i = 0; i < this._extensions.length; ++i) {
|
||||
var e = this._extensions[i];
|
||||
this._os.notifyObservers(null, "update-item-started", e.name);
|
||||
this._os.notifyObservers(null, "update-item-started", e.name + " " + e.version);
|
||||
this._proxy.getNewestExtension(e, this._appID, this._appVersion);
|
||||
//this._proxy.getExtension(e.id, e.version, this._appID, this._appVersion);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -355,29 +242,26 @@ nsExtensionUpdater.prototype = {
|
|||
{
|
||||
this._proxy = aProxy;
|
||||
this._proxy.setListener(this);
|
||||
// this._getExtensionsToUpdate();
|
||||
this._checkForUpdates();
|
||||
},
|
||||
|
||||
onError: function (aError)
|
||||
onError: function (aStatus, aMessage)
|
||||
{
|
||||
dump("*** onError ERROR = " + aError + "\n");
|
||||
},
|
||||
|
||||
getExtensionsToUpdateCallback: function (aResult)
|
||||
{
|
||||
},
|
||||
|
||||
getExtensionCallback: function (aResult)
|
||||
{
|
||||
dump("*** getExtensionCallback RESULT = " + aResult + "\n");
|
||||
this._os.notifyObservers(aResult, "update-item-error", aMessage);
|
||||
},
|
||||
|
||||
getNewestExtensionCallback: function (aResult)
|
||||
{
|
||||
dump("*** getNewestExtensionCallback RESULT = " + aResult + "\n");
|
||||
|
||||
this._os.notifyObservers(null, "update-item-ended", "goat");
|
||||
var extension = aResult;
|
||||
try {
|
||||
extension.name.toString(); // XXXben This is a lame hack to cause an exception to be
|
||||
// thrown for null values when there is no newer extension
|
||||
// or something else bad happens on the server that we
|
||||
// don't recognize.
|
||||
this._os.notifyObservers(aResult, "update-item-ended", "goat");
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
||||
if (--this._count == 0)
|
||||
this._os.notifyObservers(null, "update-ended", "");
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
// XXXben - this is not used by anything, it's just a backup of some code I did have in nsExtensionManager.js.in
|
||||
|
||||
function nsExtensionUpdater2(aExtensions,
|
||||
aTargetAppID, aTargetAppVersion)
|
||||
{
|
||||
this._extensions = aExtensions;
|
||||
this._count = aExtensions.length;
|
||||
this._appID = aTargetAppID;
|
||||
this._appVersion = aTargetAppVersion;
|
||||
|
||||
this._os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
}
|
||||
|
||||
nsExtensionUpdater2.prototype = {
|
||||
_extensionSchemaType: null,
|
||||
loadSchema: function ()
|
||||
{
|
||||
function SchemaLoaderListener(aUpdater)
|
||||
{
|
||||
this._updater = aUpdater;
|
||||
}
|
||||
|
||||
SchemaLoaderListener.prototype = {
|
||||
onLoad: function (aSchema)
|
||||
{
|
||||
dump("*** schema loaded = " + aSchema + "\n");
|
||||
var count = aSchema.typeCount;
|
||||
for (var i = 0; i < count; ++i) {
|
||||
var type = aSchema.getTypeByIndex(i);
|
||||
dump("*** schema type = " + type.name + "\n");
|
||||
}
|
||||
|
||||
this._updater._extensionSchemaType = aSchema.getTypeByName("Extension");
|
||||
|
||||
this._updater._schemaLoaded();
|
||||
},
|
||||
|
||||
onError: function (aStatus, aMessage)
|
||||
{
|
||||
dump("*** schema load error " + aStatus + ", msg = " + aMessage + "\n");
|
||||
}
|
||||
};
|
||||
|
||||
var schemaLoader = Components.classes["@mozilla.org/xmlextras/schemas/schemaloader;1"]
|
||||
.createInstance(Components.interfaces.nsISchemaLoader);
|
||||
var schemaLoaderListener = new SchemaLoaderListener(this);
|
||||
schemaLoader.loadAsync("http://www.bengoodger.com/software/mb/umo/types.xsd",
|
||||
schemaLoaderListener);
|
||||
},
|
||||
|
||||
_schemaLoaded: function ()
|
||||
{
|
||||
var call = Components.classes["@mozilla.org/xmlextras/soap/call;1"]
|
||||
.createInstance(Components.interfaces.nsISOAPCall);
|
||||
call.transportURI = "http://localhost:8080/axis/services/VersionCheck";
|
||||
|
||||
for (var i = 0; i < this._extensions.length; ++i) {
|
||||
var e = this._extensions[i];
|
||||
|
||||
var params = [this._createParam("in0", e, this._extensionSchemaType),
|
||||
this._createParam("in1", this._appID, null),
|
||||
this._createParam("in2", this._appVersion, null)];
|
||||
call.encode(0, "getNewestExtension", "urn:VersionCheck", 0, null, params.length, params);
|
||||
var response = call.invoke();
|
||||
dump("*** response = " + response + "\n");
|
||||
var count = { };
|
||||
var params;
|
||||
response.getParameters(false, count, params);
|
||||
dump("*** params = " + count.value + "\n");
|
||||
for (var j = 0; j < count.value; ++j) {
|
||||
var param = params[j];
|
||||
dump("*** param = " + param.name + ", parm = " + param + ", element = " + param.element + ", value = " + param.value + "\n");
|
||||
// var v = param.value.QueryInterface(Components.interfaces.nsIVariant);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_walkKids: function (e)
|
||||
{
|
||||
for (var i = 0; i < e.childNodes.length; ++i) {
|
||||
var kid = e.childNodes[i];
|
||||
dump("<" + kid.nodeName);
|
||||
for (var k = 0; k < kid.attributes.length; ++k)
|
||||
dump(" " + kid.attributes[k] + "=" + kid.getAttribute(kid.attributes[k]));
|
||||
if (kid.hasChildNodes()) {
|
||||
this._walkKids(kid);
|
||||
dump("</" + kid.nodeName);
|
||||
}
|
||||
else
|
||||
dump(">");
|
||||
}
|
||||
},
|
||||
|
||||
_createParam: function (aParamName, aParamValue, aParamSchemaType)
|
||||
{
|
||||
var param = Components.classes["@mozilla.org/xmlextras/soap/parameter;1"]
|
||||
.createInstance(Components.interfaces.nsISOAPParameter);
|
||||
param.name = aParamName;
|
||||
param.namespaceURI = "urn:VersionCheck";
|
||||
if (aParamSchemaType)
|
||||
param.schemaType = aParamSchemaType;
|
||||
param.value = aParamValue;
|
||||
return param;
|
||||
},
|
||||
|
||||
};
|
||||
|
Загрузка…
Ссылка в новой задаче