Compare commits
1 Commits
L10N_MERGE
...
src
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
258dc9fead |
@@ -1,57 +0,0 @@
|
||||
# ***** 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 mozilla.org l10n testing.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.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 *****
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = coverage
|
||||
XPI_NAME = coverage
|
||||
#INSTALL_EXTENSION_ID = coverage@l10n.mozilla.com
|
||||
XPI_PKGNAME = coverage-$(EXTENSION_VERSION)
|
||||
EXTENSION_VERSION = 0.5
|
||||
|
||||
USE_EXTENSION_MANIFEST = 1
|
||||
DIST_FILES = install.rdf
|
||||
PREF_JS_EXPORTS = $(srcdir)/coverage-extension-prefs.js
|
||||
|
||||
DEFINES += -DEXTENSION_VERSION=$(EXTENSION_VERSION)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
@@ -1,104 +0,0 @@
|
||||
/* ***** 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 mozilla.org l10n testing.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2066
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <l10n@mozilla.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 ***** */
|
||||
|
||||
/**
|
||||
* Item to close a menu popup
|
||||
*
|
||||
* Used by OpenMenuObj.
|
||||
*/
|
||||
function CloseMenuObj(aPopup) {
|
||||
this.args = [aPopup];
|
||||
}
|
||||
CloseMenuObj.prototype = {
|
||||
args: null,
|
||||
method: function _openMenu(aPopup) {
|
||||
aPopup.hidePopup();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Item to open a menu popup
|
||||
*
|
||||
* Adds a CloseMenuObj item as well as potentially child popups to
|
||||
* Stack
|
||||
*/
|
||||
function OpenMenuObj(aPopup) {
|
||||
this.args = [aPopup];
|
||||
}
|
||||
OpenMenuObj.prototype = {
|
||||
args: null,
|
||||
method: function _openMenu(aPopup) {
|
||||
aPopup.showPopup();
|
||||
Stack.push(new CloseMenuObj(aPopup));
|
||||
for (var i = aPopup.childNodes.length - 1; i>=0; --i) {
|
||||
var c = aPopup.childNodes[i];
|
||||
if (c.nodeName != 'menu' || c.childNodes.length == 0) {
|
||||
continue;
|
||||
}
|
||||
for each (var childpop in c.childNodes) {
|
||||
if (childpop.localName == "menupopup") {
|
||||
Stack.push(new OpenMenuObj(childpop));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Item to kick off menu coverage testing
|
||||
*
|
||||
* Pretty similar to OpenMenuObj, just that it works on the main-menubar
|
||||
* instead of a given popup.
|
||||
*/
|
||||
function RootMenu(aWindow) {
|
||||
this._w = aWindow;
|
||||
};
|
||||
RootMenu.prototype = {
|
||||
args: [],
|
||||
method: function() {
|
||||
var mb = this._w.document.getElementById('main-menubar');
|
||||
for (var i = mb.childNodes.length - 1; i>=0; --i) {
|
||||
var m = mb.childNodes[i];
|
||||
Stack.push(new OpenMenuObj(m.firstChild));
|
||||
}
|
||||
},
|
||||
_w: null
|
||||
};
|
||||
|
||||
toRun.push(new TestDone('MENUS'));
|
||||
toRun.push(new RootMenu(wins[0]));
|
||||
toRun.push(new TestStart('MENUS'));
|
||||
@@ -1,113 +0,0 @@
|
||||
/* ***** 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 mozilla.org l10n testing.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2066
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <l10n@mozilla.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 ***** */
|
||||
|
||||
var SBS = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
|
||||
var bundle = SBS.createBundle("chrome://global/locale/appstrings.properties");
|
||||
|
||||
/**
|
||||
* Item to wait on asynchronous loads
|
||||
*/
|
||||
var loadAction = {
|
||||
isLoaded: false,
|
||||
args: [],
|
||||
method: function() {
|
||||
if (!this.isLoaded) {
|
||||
Stack.push(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
// onLoad handler for the iframe, sibling of loadAction
|
||||
function onFrameLoad(aEvent) {
|
||||
aEvent.stopPropagation();
|
||||
loadAction.isLoaded = true;
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Item to load the next error page
|
||||
*
|
||||
* Uses the loadAction object to wait for asynchronous loading.
|
||||
*/
|
||||
function ErrPageLoad(aFrame, aProperty) {
|
||||
this.args = [aFrame, aProperty.key, aProperty.value];
|
||||
};
|
||||
ErrPageLoad.prototype = {
|
||||
args: null,
|
||||
method: function(aFrame, aErr, aDesc) {
|
||||
loadAction.isLoaded = false;
|
||||
var q = 'e=' + encodeURIComponent(aErr);
|
||||
q += '&u=' + encodeURIComponent('http://foo.bar');
|
||||
// Simple replacement, replace anything that's %s with aURL,
|
||||
// see http://lxr.mozilla.org/mozilla1.8/source/docshell/base/nsDocShell.cpp#2907
|
||||
// on how to do this right. But that requires knowledge on each and
|
||||
// every error, too much work for now.
|
||||
aDesc = aDesc.replace('%S', 'http://foo.bar');
|
||||
q += '&d=' + encodeURIComponent(aDesc);
|
||||
Stack.push(loadAction);
|
||||
aFrame.setAttribute('src', 'about:neterror?' + q);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Item to start the neterror tests
|
||||
*
|
||||
* This item collects all the neterror pages we intend to test
|
||||
* and adds them to the Stack.
|
||||
*/
|
||||
function RootNeterror() {
|
||||
this.args = [];
|
||||
};
|
||||
RootNeterror.prototype = {
|
||||
args: null,
|
||||
method: function(aIFrame) {
|
||||
var frame = document.getElementById('neterror-pane');
|
||||
var nErrors =
|
||||
[err for (err in SimpleGenerator(bundle.getSimpleEnumeration(),
|
||||
Ci.nsIPropertyElement))];
|
||||
nErrors.sort(function(aPl, aPr) {
|
||||
return aPl.key > aPr.key ? 1 :
|
||||
aPl.key < aPr.key ? -1 : 0;
|
||||
});
|
||||
for each (err in nErrors) {
|
||||
Stack.push(new ErrPageLoad(frame, err));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
toRun.push(new TestDone('NETERROR'));
|
||||
toRun.push(new RootNeterror());
|
||||
toRun.push(new TestStart('NETERROR'));
|
||||
@@ -1,138 +0,0 @@
|
||||
/* ***** 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 mozilla.org l10n testing.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2066
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <l10n@mozilla.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 ***** */
|
||||
|
||||
/**
|
||||
* Item to show the next pane in a prefs window
|
||||
*/
|
||||
function ShowPaneObj(aPane, aLoader) {
|
||||
this.args = [aPane, aLoader];
|
||||
}
|
||||
ShowPaneObj.prototype = {
|
||||
args: null,
|
||||
method: function _openMenu(aPane, aLoader) {
|
||||
Stack.push(aLoader);
|
||||
aPane.parentNode.showPane(aPane);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Item to close the preferences window once the tests are done
|
||||
*/
|
||||
function ClosePreferences() {
|
||||
this.args = [];
|
||||
};
|
||||
ClosePreferences.prototype = {
|
||||
args: [],
|
||||
method: function() {
|
||||
var pWin = WM.getMostRecentWindow("Browser:Preferences");
|
||||
if (pWin) {
|
||||
pWin.close();
|
||||
}
|
||||
else {
|
||||
Components.utils.reportError("prefwindow not found, trying again");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Item to wait for a preference pane to load
|
||||
*/
|
||||
function PrefPaneLoader() {
|
||||
};
|
||||
PrefPaneLoader.prototype = {
|
||||
_currentPane: null,
|
||||
args: [],
|
||||
method: function() {
|
||||
if (!this._currentPane) {
|
||||
// The pane we're waiting for hasn't been loaded yet, do me again
|
||||
Stack.push(this);
|
||||
return;
|
||||
}
|
||||
// the pane is loaded, kick off the load of the next one, if available
|
||||
pane = this._currentPane.nextSibling;
|
||||
this._currentPane = null;
|
||||
while (pane) {
|
||||
if (pane.nodeName == 'prefpane') {
|
||||
Stack.push(new ShowPaneObj(pane, this));
|
||||
return;
|
||||
}
|
||||
pane = pane.nextSibling;
|
||||
}
|
||||
},
|
||||
// nsIDOMEventListener
|
||||
handleEvent: function _hv(aEvent) {
|
||||
this._currentPane = aEvent.target;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Item to start the preference dialog tests
|
||||
*
|
||||
* This item expects to have 'paneMain' as the ID of the first pane.
|
||||
* That may be an over-simplification, but it guarantees to load
|
||||
* the panes from left to right, and that all are not loaded yet.
|
||||
* WFM.
|
||||
*/
|
||||
function RootPreference(aWindow) {
|
||||
this.args = [aWindow];
|
||||
};
|
||||
RootPreference.prototype = {
|
||||
args: [],
|
||||
method: function(aWindow) {
|
||||
WM.addListener(this);
|
||||
aWindow.openPreferences('paneMain');
|
||||
},
|
||||
// nsIWindowMediatorListener
|
||||
onWindowTitleChange: function(aWindow, newTitle){},
|
||||
onOpenWindow: function(aWindow) {
|
||||
WM.removeListener(this);
|
||||
// ensure the timer runs in the modal window, too
|
||||
Stack._timer.initWithCallback({notify:function (aTimer) {Stack.pop();}},
|
||||
Stack._time, 1);
|
||||
Stack.push(new ClosePreferences());
|
||||
var ppl = new PrefPaneLoader();
|
||||
aWindow.docShell.QueryInterface(Ci.nsIInterfaceRequestor);
|
||||
var DOMwin = aWindow.docShell.getInterface(Ci.nsIDOMWindow);
|
||||
DOMwin.addEventListener('paneload', ppl, false);
|
||||
Stack.push(ppl);
|
||||
},
|
||||
onCloseWindow: function(aWindow){}
|
||||
};
|
||||
|
||||
toRun.push(new TestDone('PREFERENCES'));
|
||||
toRun.push(new RootPreference(wins[0]));
|
||||
toRun.push(new TestStart('PREFERENCES'));
|
||||
@@ -1,130 +0,0 @@
|
||||
/* ***** 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 mozilla.org l10n testing.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2066
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <l10n@mozilla.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 ***** */
|
||||
|
||||
/**
|
||||
* Basic architecture for UI exposure tests
|
||||
*
|
||||
* Details on http://wiki.mozilla.org/SoftwareTesting:Tools:L10n:Coverage
|
||||
*/
|
||||
|
||||
var Ci = Components.interfaces;
|
||||
var Cc = Components.classes;
|
||||
var Cr = Components.results;
|
||||
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var ds = Cc[NS_DIRECTORY_SERVICE_CONTRACTID].getService(Ci.nsIProperties);
|
||||
const WM = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
|
||||
|
||||
/**
|
||||
* Global Stack object
|
||||
*
|
||||
* This object keeps the tests running with some time for visual inspection.
|
||||
*/
|
||||
var Stack = {
|
||||
_stack: [],
|
||||
_time: 250,
|
||||
_timer: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer),
|
||||
notify: function _notify(aTimer) {
|
||||
this.pop();
|
||||
},
|
||||
push: function _push(aItem) {
|
||||
this._stack.push(aItem);
|
||||
if (this._stack.length == 1) {
|
||||
this._timer.initWithCallback({notify:function (aTimer) {Stack.pop();}},
|
||||
this._time, 1);
|
||||
}
|
||||
},
|
||||
pop: function _pop() {
|
||||
var obj = this._stack.pop();
|
||||
try {
|
||||
obj.method.apply(obj, obj.args);
|
||||
} catch (e) {
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
if (!this._stack.length) {
|
||||
this._timer.cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Add your test set to toRun.
|
||||
* The onload handler will add them to the Stack and kick off the
|
||||
* testing.
|
||||
*/
|
||||
var toRun = [];
|
||||
|
||||
/**
|
||||
* Utility to get array of xpcom objects from a nsISimpleEnumerator
|
||||
* Requires JS1.7
|
||||
*/
|
||||
function SimpleGenerator(enumr, interface) {
|
||||
while (enumr.hasMoreElements()) {
|
||||
yield enumr.getNext().QueryInterface(interface);
|
||||
}
|
||||
}
|
||||
|
||||
var wins = [w for (w in SimpleGenerator(WM.getEnumerator(null), Ci.nsIDOMWindow))];
|
||||
|
||||
/**
|
||||
* Helper items to log start and end of testing to the Error Console
|
||||
*/
|
||||
function MsgBase() {
|
||||
}
|
||||
MsgBase.prototype = {
|
||||
args: [],
|
||||
method: function() {
|
||||
Components.utils.reportError(this._msg);
|
||||
}
|
||||
};
|
||||
function TestStart(aCat) {
|
||||
this._msg = 'TESTING:START:COVERAGE:' + aCat;
|
||||
}
|
||||
TestStart.prototype = new MsgBase;
|
||||
function TestDone(aCat) {
|
||||
this._msg = 'TESTING:DONE:COVERAGE:' + aCat;
|
||||
}
|
||||
TestDone.prototype = new MsgBase;
|
||||
|
||||
/**
|
||||
* onload handler for the entry page.
|
||||
* Copy the toRun items over to the stack and kick things off.
|
||||
*/
|
||||
function onLoad() {
|
||||
for each (var obj in toRun) {
|
||||
Stack.push(obj);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- ***** 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 mozilla.org l10n testing.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Mozilla Foundation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2006
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Axel Hecht <l10n@mozilla.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 LGPL or the GPL. 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 ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<window id="coverage"
|
||||
title="Coverage Tool"
|
||||
onload="return onLoad(event)"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript;version=1.7" src="coverage.js"/>
|
||||
<script type="application/javascript;version=1.7" src="coverage-prefs.js"/>
|
||||
<script type="application/javascript;version=1.7" src="coverage-menu.js"/>
|
||||
<label value="test"/>
|
||||
</window>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- ***** 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 mozilla.org l10n testing.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Mozilla Foundation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2006
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Axel Hecht <l10n@mozilla.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 LGPL or the GPL. 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 ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<window id="neterror-coverage"
|
||||
title="NetError Coverage Tool"
|
||||
onload="return onLoad(event)"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript;version=1.7" src="coverage.js"/>
|
||||
<script type="application/javascript;version=1.7" src="coverage-neterror.js"/>
|
||||
<label value="Neterror page tests"/>
|
||||
<iframe flex="1" onload="return onFrameLoad(event);" id="neterror-pane"/>
|
||||
</window>
|
||||
@@ -1,3 +0,0 @@
|
||||
pref('javascript.options.showInConsole', true);
|
||||
pref('testing.extensions.l10n.coverage', 'chrome://coverage/content/');
|
||||
pref('testing.extensions.l10n.neterror-coverage', 'chrome://coverage/content/neterror-coverage.xul');
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<em:id>coverage@l10n.mozilla.com</em:id>
|
||||
#expand <em:version>__EXTENSION_VERSION__</em:version>
|
||||
<em:type>2</em:type>
|
||||
|
||||
<!-- Target Application this extension can install into,
|
||||
with minimum and maximum supported versions. -->
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>2.0</em:minVersion>
|
||||
<em:maxVersion>2.0.*</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Coverage tester</em:name>
|
||||
<em:description>Triggers lots of UI to see if errors pop up.</em:description>
|
||||
<em:creator>Axel Hecht <l10n@mozilla.com></em:creator>
|
||||
<em:homepageURL>http://wiki.mozilla.org/SoftwareTesting:Tools:L10n:Coverage</em:homepageURL>
|
||||
</Description>
|
||||
</RDF>
|
||||
@@ -1,8 +0,0 @@
|
||||
coverage.jar:
|
||||
% content coverage %content/
|
||||
content/coverage.xul (chrome/content/coverage.xul)
|
||||
content/coverage.js (chrome/content/coverage.js)
|
||||
content/coverage-menu.js (chrome/content/coverage-menu.js)
|
||||
content/coverage-prefs.js (chrome/content/coverage-prefs.js)
|
||||
content/neterror-coverage.xul (chrome/content/neterror-coverage.xul)
|
||||
content/coverage-neterror.js (chrome/content/coverage-neterror.js)
|
||||
@@ -1,57 +0,0 @@
|
||||
# ***** 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 mozilla.org l10n testing.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.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 *****
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = help-helper
|
||||
XPI_NAME = help-helper
|
||||
#INSTALL_EXTENSION_ID = helper@l10n.mozilla.com
|
||||
XPI_PKGNAME = help-helper-$(EXTENSION_VERSION)
|
||||
EXTENSION_VERSION = 0.7
|
||||
|
||||
USE_EXTENSION_MANIFEST = 1
|
||||
DIST_FILES = install.rdf
|
||||
PREF_JS_EXPORTS = $(srcdir)/help-helper-prefs.js
|
||||
|
||||
DEFINES += -DEXTENSION_VERSION=$(EXTENSION_VERSION)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
@@ -1,193 +0,0 @@
|
||||
/* ***** 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 mozilla.org l10n testing.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2066
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <l10n@mozilla.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 ***** */
|
||||
|
||||
// Controller section
|
||||
|
||||
var Ci = Components.interfaces;
|
||||
var Cc = Components.classes;
|
||||
var Cr = Components.results;
|
||||
|
||||
var RDF = Cc['@mozilla.org/rdf/rdf-service;1'].getService(Ci.nsIRDFService);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var AI = Cc['@mozilla.org/xre/app-info;1'].getService(Ci.nsIXULAppInfo);
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
|
||||
prefs = prefs.getBranch("l10n.tests.help.");
|
||||
var prefName = AI.name + '.' + AI.version.substr(0,3); // only take the major version
|
||||
var gData = eval('(' + prefs.getCharPref(prefName) + ')');
|
||||
|
||||
// Table of Contents is the first datasource
|
||||
var toc = ios.newURI(gData.datasources[0].url, null, null);
|
||||
|
||||
function getDS(data) {
|
||||
try {
|
||||
var ds = RDF.GetDataSourceBlocking(data.url);
|
||||
} catch (e) {
|
||||
Components.utils.reportError('failed to load RDF for ' + data.url);
|
||||
}
|
||||
ds.QueryInterface(Ci.rdfIDataSource);
|
||||
return ds;
|
||||
}
|
||||
gData.rdfds = gData.datasources.map(getDS);
|
||||
|
||||
var nc = "http://home.netscape.com/NC-rdf#";
|
||||
var lnk = RDF.GetResource(nc + 'link');
|
||||
|
||||
var toCheck = {};
|
||||
var checkList = [];
|
||||
var isGood;
|
||||
var current = null;
|
||||
var frm, gb = document.documentElement;
|
||||
|
||||
function triplehandler(aBaseURI) {
|
||||
return function(aSubj, aPred, aObj, aTruth) {
|
||||
if (aPred.EqualsNode(lnk)) {
|
||||
aObj.QueryInterface(Ci.nsIRDFLiteral);
|
||||
var target = ios.newURI(aObj.Value, null, aBaseURI);
|
||||
target.QueryInterface(Ci.nsIURL);
|
||||
var ref = target.ref;
|
||||
var base = target.prePath + target.filePath;
|
||||
if (! (base in toCheck)) {
|
||||
toCheck[base] = {};
|
||||
}
|
||||
toCheck[base][ref] = [aSubj, target];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onLoad(event) {
|
||||
//Components.utils.reportError(event.target + ' loaded');
|
||||
if (event.target != document) {
|
||||
return;
|
||||
}
|
||||
document.documentElement.removeAttribute('onload');
|
||||
frm = document.getElementById('frm');
|
||||
frm.addEventListener('load', frmLoad, true);
|
||||
gData.current = -1;
|
||||
runDS();
|
||||
}
|
||||
|
||||
function runDS() {
|
||||
gData.current++;
|
||||
if (gData.datasources.length == gData.current) {
|
||||
postChecks();
|
||||
return;
|
||||
}
|
||||
toCheck = {};
|
||||
checkList = [];
|
||||
isGood = true;
|
||||
var data = gData.datasources[gData.current];
|
||||
Components.utils.reportError('testing ' + data.title);
|
||||
createBox(data.title);
|
||||
var uri = ios.newURI(data.url, null, null);
|
||||
gData.rdfds[gData.current].visitAllTriples(triplehandler(uri));
|
||||
for (key in toCheck) {
|
||||
checkList.push([key, toCheck[key]]);
|
||||
}
|
||||
current = checkList.pop();
|
||||
frm.setAttribute('src', current[0]);
|
||||
}
|
||||
|
||||
function frmLoad(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
//Components.utils.reportError('loaded ' + current[0]);
|
||||
checkIDs(current[1], current[0]);
|
||||
if (checkList.length == 0) {
|
||||
if (isGood) {
|
||||
logMessage('PASS');
|
||||
}
|
||||
runDS();
|
||||
return;
|
||||
}
|
||||
current = checkList.pop();
|
||||
frm.setAttribute('src', current[0]);
|
||||
}
|
||||
|
||||
function checkIDs(refs, url) {
|
||||
if (!frm.contentDocument) {
|
||||
Components.utils.reportError(url + ' not found\n')
|
||||
return;
|
||||
}
|
||||
for (var ref in refs) {
|
||||
if (ref && !frm.contentDocument.getElementById(ref)) {
|
||||
isGood = false;
|
||||
var msg = 'ID "' + ref + '" in ' + url + ' not found';
|
||||
Components.utils.reportError(msg);
|
||||
var d = document.createElement('description');
|
||||
d.setAttribute('value', msg);
|
||||
gb.appendChild(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function postChecks() {
|
||||
if (gData.entrypoints) {
|
||||
createBox('Entry points');
|
||||
Components.utils.reportError('testing entry points');
|
||||
var good = 0; bad = 0;
|
||||
for each (idref in gData.entrypoints) {
|
||||
var r=RDF.GetResource(toc.spec + '#' + idref);
|
||||
if (gData.rdfds[0].GetTarget(r,lnk,true)) {
|
||||
good++;
|
||||
}
|
||||
else {
|
||||
bad++;
|
||||
logMessage('Entrypoint "' + idref + '" not resolved.');
|
||||
}
|
||||
}
|
||||
if (bad == 0) {
|
||||
logMessage('PASS');
|
||||
}
|
||||
}
|
||||
Components.utils.reportError('TESTING:DONE');
|
||||
}
|
||||
|
||||
// View section
|
||||
|
||||
function createBox(aTitle) {
|
||||
gb = document.createElement('groupbox');
|
||||
gb.appendChild(document.createElement('caption'));
|
||||
gb.firstChild.setAttribute('label', aTitle);
|
||||
document.documentElement.appendChild(gb);
|
||||
}
|
||||
|
||||
function logMessage(aMsg) {
|
||||
Components.utils.reportError(aMsg);
|
||||
var d = document.createElement('description');
|
||||
d.setAttribute('value', aMsg);
|
||||
gb.appendChild(d);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- ***** 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 mozilla.org l10n testing.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Mozilla Foundation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2006
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Axel Hecht <l10n@mozilla.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 LGPL or the GPL. 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 ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<window id="help-helper"
|
||||
title="Help Link Checker"
|
||||
onload="return onLoad(event)"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="help-helper.js"/>
|
||||
<iframe id="frm" style="height:0px;"/>
|
||||
</window>
|
||||
@@ -1 +0,0 @@
|
||||
pref("l10n.tests.help.Firefox.2.0", '{entrypoints:["firefox-help", "ieusers", "prefs-advanced-encryption", "prefs-advanced-general", "prefs-advanced-javascript", "prefs-advanced-network", "prefs-advanced-update", "prefs-clear-private-data", "prefs-connection-settings", "prefs-content", "prefs-feeds", "prefs-file-types", "prefs-fonts-and-colors", "prefs-languages", "prefs-main", "prefs-privacy", "prefs-security", "prefs-tabs"], datasources:[{url:"chrome://browser/locale/help/firebird-toc.rdf", title:"Table Of Contents"}, {url:"chrome://browser/locale/help/search-db.rdf", title:"Search"}]}');
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<em:id>helper@l10n.mozilla.com</em:id>
|
||||
#expand <em:version>__EXTENSION_VERSION__</em:version>
|
||||
<em:type>2</em:type>
|
||||
|
||||
<!-- Target Application this extension can install into,
|
||||
with minimum and maximum supported versions. -->
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>2.0b2</em:minVersion>
|
||||
<em:maxVersion>2.0.*</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Help Helper</em:name>
|
||||
<em:description>Finds all links in the help TOC and tries to resolve them.</em:description>
|
||||
<em:creator>Axel Hecht <l10n@mozilla.com></em:creator>
|
||||
<em:homepageURL>http://people.mozilla.com/~axel/l10n/</em:homepageURL>
|
||||
</Description>
|
||||
</RDF>
|
||||
@@ -1,4 +0,0 @@
|
||||
help-helper.jar:
|
||||
% content help-helper %content
|
||||
content/help-helper.xul (chrome/content/help-helper.xul)
|
||||
content/help-helper.js (chrome/content/help-helper.js)
|
||||
@@ -1,303 +0,0 @@
|
||||
# ***** 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 l10n test automation.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.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 *****
|
||||
|
||||
'Mozilla l10n compare locales tool'
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
import logging
|
||||
import Parser
|
||||
import Paths
|
||||
|
||||
class FileCollector:
|
||||
class Iter:
|
||||
def __init__(self, path):
|
||||
self.__base = path
|
||||
def __iter__(self):
|
||||
self.__w = os.walk(self.__base)
|
||||
try:
|
||||
self.__nextDir()
|
||||
except StopIteration:
|
||||
# empty dir, bad, but happens
|
||||
self.__i = [].__iter__()
|
||||
return self
|
||||
def __nextDir(self):
|
||||
self.__t = self.__w.next()
|
||||
try:
|
||||
self.__t[1].remove("CVS")
|
||||
except ValueError:
|
||||
pass
|
||||
self.__t[1].sort()
|
||||
self.__t[2].sort()
|
||||
self.__i = self.__t[2].__iter__()
|
||||
def next(self):
|
||||
try:
|
||||
leaf = self.__i.next()
|
||||
path = self.__t[0] + '/' + leaf
|
||||
key = path[len(self.__base) + 1:]
|
||||
return (key, path)
|
||||
except StopIteration:
|
||||
self.__nextDir()
|
||||
return self.next()
|
||||
print "not expected"
|
||||
raise StopIteration
|
||||
def __init__(self):
|
||||
pass
|
||||
def getFiles(self, mod, locale):
|
||||
fls = {}
|
||||
for leaf, path in self.iterateFiles(mod,locale):
|
||||
fls[leaf] = path
|
||||
return fls
|
||||
def iterateFiles(self, mod, locale):
|
||||
return FileCollector.Iter(Paths.get_base_path(mod, locale))
|
||||
|
||||
def collectFiles(aComparer, apps = None, locales = None):
|
||||
'''
|
||||
returns new files, files to compare, files to remove
|
||||
apps or locales need to be given, apps is a list, locales is a
|
||||
hash mapping applications to languages.
|
||||
If apps is given, it will look up all-locales for all apps for the
|
||||
languages to test.
|
||||
'toolkit' is added to the list of modules, too.
|
||||
'''
|
||||
if not apps and not locales:
|
||||
raise RuntimeError, "collectFiles needs either apps or locales"
|
||||
if apps and locales:
|
||||
raise RuntimeError, "You don't want to give both apps or locales"
|
||||
if locales:
|
||||
apps = locales.keys()
|
||||
# add toolkit, with all of the languages of all apps
|
||||
all = set()
|
||||
for locs in locales.values():
|
||||
all.update(locs)
|
||||
locales['toolkit'] = list(all)
|
||||
else:
|
||||
locales = Paths.allLocales(apps)
|
||||
modules = Paths.Modules(apps)
|
||||
en = FileCollector()
|
||||
l10n = FileCollector()
|
||||
# load filter functions for each app
|
||||
fltrs = []
|
||||
for app in apps:
|
||||
filterpath = 'mozilla/%s/locales/filter.py' % app
|
||||
if not os.path.exists(filterpath):
|
||||
continue
|
||||
l = {}
|
||||
execfile(filterpath, {}, l)
|
||||
if 'test' not in l or not callable(l['test']):
|
||||
logging.debug('%s does not define function "test"' % filterpath)
|
||||
continue
|
||||
fltrs.append(l['test'])
|
||||
|
||||
# define fltr function to be used, calling into the app specific ones
|
||||
# if one of our apps wants us to know about a triple, make it so
|
||||
def fltr(mod, lpath, entity = None):
|
||||
for f in fltrs:
|
||||
keep = True
|
||||
try:
|
||||
keep = f(mod, lpath, entity)
|
||||
except Exception, e:
|
||||
logging.error(str(e))
|
||||
if not keep:
|
||||
return False
|
||||
return True
|
||||
|
||||
for cat in modules.keys():
|
||||
logging.debug(" testing " + cat+ " on " + str(modules))
|
||||
aComparer.notifyLocales(cat, locales[cat])
|
||||
for mod in modules[cat]:
|
||||
en_fls = en.getFiles(mod, 'en-US')
|
||||
for loc in locales[cat]:
|
||||
fls = dict(en_fls) # create copy for modification
|
||||
for l_fl, l_path in l10n.iterateFiles(mod, loc):
|
||||
if fls.has_key(l_fl):
|
||||
# file in both en-US and locale, compare
|
||||
aComparer.compareFile(mod, loc, l_fl)
|
||||
del fls[l_fl]
|
||||
else:
|
||||
if fltr(mod, l_fl):
|
||||
# file in locale, but not in en-US, remove
|
||||
aComparer.removeFile(mod, loc, l_fl)
|
||||
else:
|
||||
logging.debug(" ignoring %s from %s in %s" %
|
||||
(l_fl, loc, mod))
|
||||
# all locale files dealt with, remaining fls need to be added?
|
||||
for lf in fls.keys():
|
||||
if fltr(mod, lf):
|
||||
aComparer.addFile(mod,loc,lf)
|
||||
else:
|
||||
logging.debug(" ignoring %s from %s in %s" %
|
||||
(lf, loc, mod))
|
||||
|
||||
return fltr
|
||||
|
||||
class CompareCollector(object):
|
||||
'collects files to be compared, added, removed'
|
||||
def __init__(self):
|
||||
self.cl = {}
|
||||
self.files = {}
|
||||
self.modules = {}
|
||||
def notifyLocales(self, aModule, aLocaleList):
|
||||
for loc in aLocaleList:
|
||||
if self.modules.has_key(loc):
|
||||
self.modules[loc].append(aModule)
|
||||
else:
|
||||
self.modules[loc] = [aModule]
|
||||
def addFile(self, aModule, aLocale, aLeaf):
|
||||
logging.debug(" add %s for %s in %s" % (aLeaf, aLocale, aModule))
|
||||
if not self.files.has_key(aLocale):
|
||||
self.files[aLocale] = {'missingFiles': [(aModule, aLeaf)],
|
||||
'obsoleteFiles': []}
|
||||
else:
|
||||
self.files[aLocale]['missingFiles'].append((aModule, aLeaf))
|
||||
pass
|
||||
def compareFile(self, aModule, aLocale, aLeaf):
|
||||
if not self.cl.has_key((aModule, aLeaf)):
|
||||
self.cl[(aModule, aLeaf)] = [aLocale]
|
||||
else:
|
||||
self.cl[(aModule, aLeaf)].append(aLocale)
|
||||
pass
|
||||
def removeFile(self, aModule, aLocale, aLeaf):
|
||||
logging.debug(" remove %s from %s in %s" % (aLeaf, aLocale, aModule))
|
||||
if not self.files.has_key(aLocale):
|
||||
self.files[aLocale] = {'obsoleteFiles': [(aModule, aLeaf)],
|
||||
'missingFiles':[]}
|
||||
else:
|
||||
self.files[aLocale]['obsoleteFiles'].append((aModule, aLeaf))
|
||||
pass
|
||||
|
||||
def compare(apps=None, testLocales=None):
|
||||
result = {}
|
||||
c = CompareCollector()
|
||||
fltr = collectFiles(c, apps=apps, locales=testLocales)
|
||||
|
||||
key = re.compile('[kK]ey')
|
||||
for fl, locales in c.cl.iteritems():
|
||||
(mod,path) = fl
|
||||
try:
|
||||
parser = Parser.getParser(path)
|
||||
except UserWarning:
|
||||
logging.warning(" Can't compare " + path + " in " + mod)
|
||||
continue
|
||||
parser.readFile(Paths.get_path(mod, 'en-US', path))
|
||||
logging.debug(" Parsing en-US " + path + " in " + mod)
|
||||
(enList, enMap) = parser.parse()
|
||||
for loc in locales:
|
||||
if not result.has_key(loc):
|
||||
result[loc] = {'missing':[],'obsolete':[],
|
||||
'changed':0,'unchanged':0,'keys':0}
|
||||
enTmp = dict(enMap)
|
||||
parser.readFile(Paths.get_path(mod, loc, path))
|
||||
logging.debug(" Parsing " + loc + " " + path + " in " + mod)
|
||||
(l10nList, l10nMap) = parser.parse()
|
||||
l10nTmp = dict(l10nMap)
|
||||
logging.debug(" Checking existing entities of " + path + " in " + mod)
|
||||
for k,i in l10nMap.items():
|
||||
if not fltr(mod, path, k):
|
||||
if enTmp.has_key(k):
|
||||
del enTmp[k]
|
||||
del l10nTmp[k]
|
||||
continue
|
||||
if not enTmp.has_key(k):
|
||||
result[loc]['obsolete'].append((mod,path,k))
|
||||
continue
|
||||
enVal = enList[enTmp[k]]['val']
|
||||
del enTmp[k]
|
||||
del l10nTmp[k]
|
||||
if key.search(k):
|
||||
result[loc]['keys'] += 1
|
||||
else:
|
||||
if enVal == l10nList[i]['val']:
|
||||
result[loc]['unchanged'] +=1
|
||||
logging.info('%s in %s unchanged' %
|
||||
(k, Paths.get_path(mod, loc, path)))
|
||||
else:
|
||||
result[loc]['changed'] +=1
|
||||
result[loc]['missing'].extend(filter(lambda t: fltr(*t),
|
||||
[(mod,path,k) for k in enTmp.keys()]))
|
||||
for loc,dics in c.files.iteritems():
|
||||
if not result.has_key(loc):
|
||||
result[loc] = dics
|
||||
else:
|
||||
for key, list in dics.iteritems():
|
||||
result[loc][key] = list
|
||||
for loc, mods in c.modules.iteritems():
|
||||
result[loc]['tested'] = mods
|
||||
return result
|
||||
|
||||
# helper class to merge all the lists into more consice
|
||||
# dicts
|
||||
class Separator:
|
||||
def __init__(self, apps):
|
||||
self.components = Paths.Components(apps)
|
||||
pass
|
||||
def getDetails(self, res, locale):
|
||||
dic = {}
|
||||
res[locale]['tested'].sort()
|
||||
self.collectList('missing', res[locale], dic)
|
||||
self.collectList('obsolete', res[locale], dic)
|
||||
return dic
|
||||
def collectList(self, name, res, dic):
|
||||
dic[name] = {}
|
||||
if name not in res:
|
||||
res[name] = []
|
||||
counts = dict([(mod,0) for mod in res['tested']])
|
||||
counts['total'] = len(res[name])
|
||||
for mod, path, key in res[name]:
|
||||
counts[self.components[mod]] +=1
|
||||
if mod not in dic[name]:
|
||||
dic[name][mod] = {path:[key]}
|
||||
continue
|
||||
if path not in dic[name][mod]:
|
||||
dic[name][mod][path] = [key]
|
||||
else:
|
||||
dic[name][mod][path].append(key)
|
||||
res[name] = counts
|
||||
name += 'Files'
|
||||
dic[name] = {}
|
||||
if name not in res:
|
||||
res[name] = []
|
||||
counts = dict([(mod,0) for mod in res['tested']])
|
||||
counts['total'] = len(res[name])
|
||||
for mod, path in res[name]:
|
||||
counts[self.components[mod]] +=1
|
||||
if mod not in dic[name]:
|
||||
dic[name][mod] = [path]
|
||||
else:
|
||||
dic[name][mod].append(path)
|
||||
res[name] = counts
|
||||
@@ -1,179 +0,0 @@
|
||||
# ***** 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 l10n test automation.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.com>
|
||||
# Toshihiro Kura
|
||||
# Tomoya Asai (dynamis)
|
||||
#
|
||||
# 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 *****
|
||||
|
||||
'Mozilla l10n merge tool'
|
||||
|
||||
import os
|
||||
import re
|
||||
import codecs
|
||||
import logging
|
||||
import time
|
||||
import shutil
|
||||
import Parser
|
||||
import Paths
|
||||
from CompareLocales import FileCollector, CompareCollector, collectFiles
|
||||
|
||||
options = {}
|
||||
|
||||
class MergeCollector(CompareCollector):
|
||||
def addFile(self, aModule, aLocale, aLeaf):
|
||||
super(MergeCollector, self).addFile(aModule, aLocale, aLeaf)
|
||||
l_fl = Paths.get_path(aModule, aLocale, aLeaf)
|
||||
if not os.path.isdir(os.path.dirname(l_fl)):
|
||||
os.makedirs(os.path.dirname(l_fl))
|
||||
shutil.copy2(Paths.get_path(aModule, 'en-US', aLeaf), l_fl)
|
||||
pass
|
||||
def removeFile(self, aModule, aLocale, aLeaf):
|
||||
super(MergeCollector, self).removeFile(aModule, aLocale, aLeaf)
|
||||
if options['backup']:
|
||||
os.rename(Paths.get_path(aModule, aLocale, aLeaf), Paths.get_path(aModule, aLocale, aLeaf + '~'))
|
||||
else:
|
||||
os.remove(Paths.get_path(aModule, aLocale, aLeaf))
|
||||
pass
|
||||
|
||||
def merge(apps=None, testLocales=[]):
|
||||
result = {}
|
||||
c = MergeCollector()
|
||||
fltr = collectFiles(c, apps=apps, locales=testLocales)
|
||||
|
||||
key = re.compile('[kK]ey')
|
||||
for fl, locales in c.cl.iteritems():
|
||||
(mod,path) = fl
|
||||
logging.info(" Handling " + path + " in " + mod)
|
||||
try:
|
||||
parser = Parser.getParser(path)
|
||||
except UserWarning:
|
||||
logging.warning(" Can't merge " + path + " in " + mod)
|
||||
continue
|
||||
parser.readFile(Paths.get_path(mod, 'en-US', path))
|
||||
logging.debug(" Parsing en-US " + path + " in " + mod)
|
||||
(enList, enMap) = parser.parse()
|
||||
for loc in locales:
|
||||
if not result.has_key(loc):
|
||||
result[loc] = {'missing':[],'obsolete':[],
|
||||
'changed':0,'unchanged':0,'keys':0}
|
||||
enTmp = dict(enMap)
|
||||
parser.readFile(Paths.get_path(mod, loc, path))
|
||||
logging.debug(" Parsing " + loc + " " + path + " in " + mod)
|
||||
(l10nList, l10nMap) = parser.parse()
|
||||
l10nTmp = dict(l10nMap)
|
||||
logging.debug(" Checking existing entities of " + path + " in " + mod)
|
||||
for k,i in l10nMap.items():
|
||||
if not fltr(mod, path, k):
|
||||
if enTmp.has_key(k):
|
||||
del enTmp[k]
|
||||
del l10nTmp[k]
|
||||
continue
|
||||
if not enTmp.has_key(k):
|
||||
result[loc]['obsolete'].append((mod,path,k))
|
||||
continue
|
||||
enVal = enList[enTmp[k]]['val']
|
||||
del enTmp[k]
|
||||
del l10nTmp[k]
|
||||
if key.search(k):
|
||||
result[loc]['keys'] += 1
|
||||
else:
|
||||
if enVal == l10nList[i]['val']:
|
||||
result[loc]['unchanged'] +=1
|
||||
logging.info('%s in %s unchanged' %
|
||||
(k, Paths.get_path(mod, loc, path)))
|
||||
else:
|
||||
result[loc]['changed'] +=1
|
||||
result[loc]['missing'].extend(filter(lambda t: fltr(*t),
|
||||
[(mod,path,k) for k in enTmp.keys()]))
|
||||
filename = Paths.get_path(mod, loc, path)
|
||||
if not parser.canMerge:
|
||||
if l10nTmp or enTmp:
|
||||
logging.error('not merging ' + path)
|
||||
continue
|
||||
# comment out obsolete entities
|
||||
if l10nTmp != {}:
|
||||
logging.info(" Commenting out obsolete entities...")
|
||||
f = codecs.open(filename, 'w', parser.encoding)
|
||||
daytime = time.asctime()
|
||||
try:
|
||||
f.write(parser.header)
|
||||
if re.search('\\.dtd', filename):
|
||||
for entity in l10nList:
|
||||
if l10nTmp.has_key(entity['key']):
|
||||
if not options['cleanobsolete']:
|
||||
f.write(entity['prespace'] + '<!-- XXX l10n merge: obsolete entity (' + daytime + ') -->\n' + entity['precomment'] + '<!-- ' + entity['def'] + ' -->' + entity['post'])
|
||||
else:
|
||||
f.write(entity['all'])
|
||||
elif re.search('\\.(properties|inc)', filename):
|
||||
for entity in l10nList:
|
||||
if l10nTmp.has_key(entity['key']):
|
||||
if not options['cleanobsolete']:
|
||||
f.write(entity['prespace'] + '# XXX l10n merge: obsolete entity (' + daytime + ')\n' + entity['precomment'] + '#' + entity['def'] + entity['post'])
|
||||
else:
|
||||
f.write(entity['all'])
|
||||
f.write(parser.footer)
|
||||
except UnicodeDecodeError, e:
|
||||
logging.getLogger('locales').error("Can't write file: " + file + ';' + str(e))
|
||||
f.close()
|
||||
# add new entities
|
||||
if enTmp != {}:
|
||||
logging.info(" Adding new entities...")
|
||||
f = codecs.open(filename, 'a', parser.encoding)
|
||||
daytime = time.asctime()
|
||||
try:
|
||||
if re.search('\\.dtd', filename):
|
||||
f.write('\n<!-- XXX l10n merge: new entities (' + daytime + ') -->\n')
|
||||
v = enTmp.values()
|
||||
v.sort()
|
||||
for i in v:
|
||||
f.write(enList[i]['all'])
|
||||
elif re.search('\\.(properties|inc)', filename):
|
||||
f.write('\n# XXX l10n merge: new entities (' + daytime + ')\n')
|
||||
v = enTmp.values()
|
||||
v.sort()
|
||||
for i in v:
|
||||
f.write(enList[i]['all'])
|
||||
except UnicodeDecodeError, e:
|
||||
logging.getLogger('locales').error("Can't write file: " + file + ';' + str(e))
|
||||
f.close()
|
||||
for loc,dics in c.files.iteritems():
|
||||
if not result.has_key(loc):
|
||||
result[loc] = dics
|
||||
else:
|
||||
for key, list in dics.iteritems():
|
||||
result[loc][key] = list
|
||||
for loc, mods in c.modules.iteritems():
|
||||
result[loc]['tested'] = mods
|
||||
return result
|
||||
@@ -1,271 +0,0 @@
|
||||
# ***** 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 l10n test automation.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.com>
|
||||
# Toshihiro Kura
|
||||
# Tomoya Asai (dynamis)
|
||||
# Clint Talbert <ctalbert@mozilla.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 *****
|
||||
|
||||
import re
|
||||
import codecs
|
||||
import logging
|
||||
from HTMLParser import HTMLParser
|
||||
|
||||
__constructors = []
|
||||
|
||||
class Parser:
|
||||
canMerge = True
|
||||
def __init__(self):
|
||||
if not hasattr(self, 'encoding'):
|
||||
self.encoding = 'utf-8';
|
||||
pass
|
||||
def readFile(self, file):
|
||||
f = codecs.open(file, 'r', self.encoding)
|
||||
try:
|
||||
self.contents = f.read()
|
||||
except UnicodeDecodeError, e:
|
||||
logging.getLogger('locales').error("Can't read file: " + file + '; ' + str(e))
|
||||
self.contents = u''
|
||||
f.close()
|
||||
def readContents(self, contents):
|
||||
(self.contents, length) = codecs.getdecoder(self.encoding)(contents)
|
||||
def parse(self):
|
||||
l = []
|
||||
m = {}
|
||||
for e in self:
|
||||
m[e['key']] = len(l)
|
||||
l.append(e)
|
||||
return (l, m)
|
||||
def postProcessValue(self, val):
|
||||
return val
|
||||
def __iter__(self):
|
||||
self.offset = 0
|
||||
self.header = ''
|
||||
self.footer = ''
|
||||
h = self.reHeader.search(self.contents)
|
||||
if h:
|
||||
self.header = h.group()
|
||||
self.offset = h.end()
|
||||
return self
|
||||
def next(self):
|
||||
m = self.reKey.search(self.contents, self.offset)
|
||||
if not m or m.start() != self.offset:
|
||||
t = self.reFooter.search(self.contents, self.offset)
|
||||
if t:
|
||||
self.footer = t.group()
|
||||
self.offset = t.end()
|
||||
raise StopIteration
|
||||
self.offset = m.end()
|
||||
return {'key': m.group(4), 'val': self.postProcessValue(m.group(5)), 'all': m.group(0), 'prespace': m.group(1), 'precomment': m.group(2), 'def': m.group(3), 'post': m.group(6)}
|
||||
|
||||
def getParser(path):
|
||||
for item in __constructors:
|
||||
if re.search(item[0], path):
|
||||
return item[1]
|
||||
raise UserWarning, "Cannot find Parser"
|
||||
|
||||
|
||||
# Subgroups of the match will:
|
||||
# 1: pre white space
|
||||
# 2: pre comments
|
||||
# 3: entity definition
|
||||
# 4: entity key (name)
|
||||
# 5: entity value
|
||||
# 6: post comment (and white space) in the same line (dtd only)
|
||||
# <--[1]
|
||||
# <!-- pre comments --> <--[2]
|
||||
# <!ENTITY key "value"> <!-- comment -->
|
||||
#
|
||||
# <-------[3]---------><------[6]------>
|
||||
|
||||
|
||||
class DTDParser(Parser):
|
||||
def __init__(self):
|
||||
# http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-NameStartChar
|
||||
#":" | [A-Z] | "_" | [a-z] |
|
||||
# [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF]
|
||||
# | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
|
||||
# [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
|
||||
# [#x10000-#xEFFFF]
|
||||
NameStartChar = u':A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF' + \
|
||||
u'\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF'+\
|
||||
u'\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD'
|
||||
# + \U00010000-\U000EFFFF seems to be unsupported in python
|
||||
|
||||
# NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 |
|
||||
# [#x0300-#x036F] | [#x203F-#x2040]
|
||||
NameChar = NameStartChar + ur'\-\.0-9' + u'\xB7\u0300-\u036F\u203F-\u2040'
|
||||
Name = '[' + NameStartChar + '][' + NameChar + ']*'
|
||||
self.reKey = re.compile('(\s*)((?:<!--(?:[^-]+-)*[^-]+-->\s*)*)(<!ENTITY\s+(' + Name + ')\s+(\"[^\"]*\"|\'[^\']*\')\s*>)([ \t]*(?:<!--(?:[^\n-]+-)*[^\n-]+-->[ \t]*)*\n?)?')
|
||||
# allow parameter entity reference only in the header block
|
||||
self.reHeader = re.compile('^(\s*<!ENTITY\s+%\s+' + Name + '\s+SYSTEM\s+(\"[^\"]*\"|\'[^\']*\')\s*>\s*%[\w\.]+;)?(\s*<!--([^-]+-)*[^-]+-->)?')
|
||||
self.reFooter = re.compile('\s*(<!--([^-]+-)*[^-]+-->\s*)*$')
|
||||
Parser.__init__(self)
|
||||
|
||||
class PropertiesParser(Parser):
|
||||
def __init__(self):
|
||||
self.reKey = re.compile('^(\s*)((?:[#!].*\n\s*)*)(([^#!\s\r\n][^=:\r\n]*?)\s*[:=][ \t]*(.*?))([ \t]*$\n?)',re.M)
|
||||
self.reHeader = re.compile('^\s*([#!].*\s*)*')
|
||||
self.reFooter = re.compile('\s*([#!].*\s*)*$')
|
||||
self._post = re.compile('\\\\u([0-9a-fA-F]{4})')
|
||||
Parser.__init__(self)
|
||||
_arg_re = re.compile('%(?:(?P<cn>[0-9]+)\$)?(?P<width>[0-9]+)?(?:.(?P<pres>[0-9]+))?(?P<size>[hL]|(?:ll?))?(?P<type>[dciouxXefgpCSsn])')
|
||||
def postProcessValue(self, val):
|
||||
m = self._post.search(val)
|
||||
if not m:
|
||||
return val
|
||||
while m:
|
||||
uChar = unichr(int(m.group(1), 16))
|
||||
val = val.replace(m.group(), uChar)
|
||||
m = self._post.search(val)
|
||||
return val
|
||||
|
||||
class DefinesParser(Parser):
|
||||
def __init__(self):
|
||||
self.reKey = re.compile('^(\s*)((?:^#(?!define\s).*\s*)*)(#define[ \t]+(\w+)[ \t]+(.*?))([ \t]*$\n?)',re.M)
|
||||
self.reHeader = re.compile('^\s*(#(?!define\s).*\s*)*')
|
||||
self.reFooter = re.compile('\s*(#(?!define\s).*\s*)*$',re.M)
|
||||
Parser.__init__(self)
|
||||
|
||||
DECL, COMMENT, START, END, CONTENT = range(5)
|
||||
|
||||
class BookmarksParser(HTMLParser, Parser):
|
||||
canMerge = False
|
||||
|
||||
class Token(object):
|
||||
_type = None
|
||||
content = ''
|
||||
def __str__(self):
|
||||
return self.content
|
||||
class DeclToken(Token):
|
||||
_type = DECL
|
||||
def __init__(self, decl):
|
||||
self.content = decl
|
||||
pass
|
||||
def __str__(self):
|
||||
return '<!%s>' % self.content
|
||||
pass
|
||||
class CommentToken(Token):
|
||||
_type = COMMENT
|
||||
def __init__(self, comment):
|
||||
self.content = comment
|
||||
pass
|
||||
def __str__(self):
|
||||
return '<!--%s-->' % self.content
|
||||
pass
|
||||
class StartToken(Token):
|
||||
_type = START
|
||||
def __init__(self, tag, attrs, content):
|
||||
self.tag = tag
|
||||
self.attrs = dict(attrs)
|
||||
self.content = content
|
||||
pass
|
||||
pass
|
||||
class EndToken(Token):
|
||||
_type = END
|
||||
def __init__(self, tag):
|
||||
self.tag = tag
|
||||
pass
|
||||
def __str__(self):
|
||||
return '</%s>' % self.tag.upper()
|
||||
pass
|
||||
class ContentToken(Token):
|
||||
_type = CONTENT
|
||||
def __init__(self, content):
|
||||
self.content = content
|
||||
pass
|
||||
pass
|
||||
|
||||
def __init__(self):
|
||||
HTMLParser.__init__(self)
|
||||
Parser.__init__(self)
|
||||
self.tokens = []
|
||||
|
||||
def __iter__(self):
|
||||
self.tokens = []
|
||||
self.feed(self.contents)
|
||||
self.close()
|
||||
tks = self.tokens
|
||||
i = 0
|
||||
k = []
|
||||
for i in xrange(len(tks)):
|
||||
t = tks[i]
|
||||
if t._type == START:
|
||||
k.append(t.tag)
|
||||
for attrname in sorted(t.attrs.keys()):
|
||||
yield dict(key = '.'.join(k) + '.@' + attrname,
|
||||
val = t.attrs[attrname])
|
||||
if i + 1 < len(tks) and tks[i+1]._type == CONTENT:
|
||||
i += 1
|
||||
t = tks[i]
|
||||
v = t.content.strip()
|
||||
if v:
|
||||
yield dict(key = '.'.join(k),
|
||||
val = v)
|
||||
elif t._type == END:
|
||||
k.pop()
|
||||
|
||||
# Called when we hit an end DL tag to reset the folder selections
|
||||
def handle_decl(self, decl):
|
||||
self.tokens.append(self.DeclToken(decl))
|
||||
|
||||
# Called when we hit an end DL tag to reset the folder selections
|
||||
def handle_comment(self, comment):
|
||||
self.tokens.append(self.CommentToken(comment))
|
||||
|
||||
def handle_starttag(self, tag, attrs):
|
||||
self.tokens.append(self.StartToken(tag, attrs, self.get_starttag_text()))
|
||||
|
||||
# Called when text data is encountered
|
||||
def handle_data(self, data):
|
||||
if self.tokens[-1]._type == CONTENT:
|
||||
self.tokens[-1].content += data
|
||||
else:
|
||||
self.tokens.append(self.ContentToken(data))
|
||||
|
||||
def handle_charref(self, data):
|
||||
self.handle_data('&#%s;' % data)
|
||||
|
||||
def handle_entityref(self, data):
|
||||
self.handle_data('&%s;' % data)
|
||||
|
||||
# Called when we hit an end DL tag to reset the folder selections
|
||||
def handle_endtag(self, tag):
|
||||
self.tokens.append(self.EndToken(tag))
|
||||
|
||||
__constructors = [('\\.dtd', DTDParser()),
|
||||
('\\.properties', PropertiesParser()),
|
||||
('\\.inc', DefinesParser()),
|
||||
('bookmarks\\.html', BookmarksParser())]
|
||||
@@ -1,102 +0,0 @@
|
||||
# ***** 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 l10n test automation.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.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 *****
|
||||
|
||||
import os.path
|
||||
from subprocess import *
|
||||
|
||||
|
||||
class Modules(dict):
|
||||
'''
|
||||
Subclass of dict to hold information on which directories belong to a
|
||||
particular app.
|
||||
It expects to have mozilla/client.mk right there from the working dir,
|
||||
and asks that for the LOCALES_foo variables.
|
||||
This only works for toolkit applications, as it's assuming that the
|
||||
apps include toolkit.
|
||||
'''
|
||||
def __init__(self, apps):
|
||||
super(dict, self).__init__()
|
||||
lapps = apps[:]
|
||||
lapps.insert(0, 'toolkit')
|
||||
of = os.popen('make -f mozilla/client.mk ' + \
|
||||
' '.join(['echo-variable-LOCALES_' + app for app in lapps]))
|
||||
|
||||
for val in of.readlines():
|
||||
self[lapps.pop(0)] = val.strip().split()
|
||||
for k,v in self.iteritems():
|
||||
if k == 'toolkit':
|
||||
continue
|
||||
self[k] = [d for d in v if d not in self['toolkit']]
|
||||
|
||||
class Components(dict):
|
||||
'''
|
||||
Subclass of dict to map module dirs to applications. This reverses the
|
||||
mapping you'd get from a Modules class, and it in fact uses one to do
|
||||
its job.
|
||||
'''
|
||||
def __init__(self, apps):
|
||||
modules = Modules(apps)
|
||||
for mod, lst in modules.iteritems():
|
||||
for c in lst:
|
||||
self[c] = mod
|
||||
|
||||
def allLocales(apps):
|
||||
'''
|
||||
Get a locales hash for the given list of applications, mapping
|
||||
applications to the list of languages given by all-locales.
|
||||
Adds a module 'toolkit' holding all languages for all applications, too.
|
||||
'''
|
||||
locales = {}
|
||||
all = set()
|
||||
for app in apps:
|
||||
path = 'mozilla/%s/locales/all-locales' % app
|
||||
locales[app] = [l.strip() for l in open(path)]
|
||||
all.update(locales[app])
|
||||
locales['toolkit'] = list(all)
|
||||
return locales
|
||||
|
||||
def get_base_path(mod, loc):
|
||||
'statics for path patterns and conversion'
|
||||
__l10n = 'l10n/%(loc)s/%(mod)s'
|
||||
__en_US = 'mozilla/%(mod)s/locales/en-US'
|
||||
if loc == 'en-US':
|
||||
return __en_US % {'mod': mod}
|
||||
return __l10n % {'mod': mod, 'loc': loc}
|
||||
|
||||
def get_path(mod, loc, leaf):
|
||||
return get_base_path(mod, loc) + '/' + leaf
|
||||
|
||||
@@ -1,425 +0,0 @@
|
||||
# ***** 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 l10n test automation.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.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 *****
|
||||
|
||||
import logging
|
||||
import Paths
|
||||
import Parser
|
||||
|
||||
class Base:
|
||||
'''Base class for all tests'''
|
||||
def __init__(self):
|
||||
if not hasattr(self, 'leafName'):
|
||||
self.leafName = 'TODO'
|
||||
logging.warning(' ' + self + ' does not have leafName set, writing to TODO')
|
||||
def run(self):
|
||||
'''Run this test for all locales, returns a dictionary with results'''
|
||||
pass
|
||||
def serialize(self, result, saveHandler):
|
||||
'''Serialize the previously generated result, writes the dictionary
|
||||
by default'''
|
||||
return saveHandler(result, self.leafName)
|
||||
pass
|
||||
def failureTest(self, myResult, failureResult):
|
||||
pass
|
||||
|
||||
import CompareLocales
|
||||
class CompareTest(Base):
|
||||
'''Test class to compare locales'''
|
||||
def __init__(self):
|
||||
'''Initializes the test object'''
|
||||
# nothing to be done here
|
||||
pass
|
||||
def run(self):
|
||||
'''Runs CompareLocales.compare()'''
|
||||
return CompareLocales.compare(apps=['browser','mail'])
|
||||
def serialize(self, result, saveHandler):
|
||||
'''Serialize the CompareLocales result by locale into
|
||||
cmp-details-ab-CD
|
||||
and a compacted version into
|
||||
cmp-data
|
||||
|
||||
'''
|
||||
class Separator:
|
||||
def __init__(self):
|
||||
self.leafBase = 'cmp-details-'
|
||||
self.components = Paths.Components(['browser','mail'])
|
||||
def getDetails(self, res, locale):
|
||||
dic = {}
|
||||
res[locale]['tested'].sort()
|
||||
self.collectList('missing', res[locale], dic)
|
||||
self.collectList('obsolete', res[locale], dic)
|
||||
saveHandler(dic, self.leafBase + locale + '.json')
|
||||
def collectList(self, name, res, dic):
|
||||
dic[name] = {}
|
||||
if not res.has_key(name):
|
||||
res[name] = []
|
||||
counts = dict([(mod,0) for mod in res['tested']])
|
||||
counts['total'] = len(res[name])
|
||||
for mod, path, key in res[name]:
|
||||
counts[self.components[mod]] +=1
|
||||
if not dic[name].has_key(mod):
|
||||
dic[name][mod] = {path:[key]}
|
||||
continue
|
||||
if not dic[name][mod].has_key(path):
|
||||
dic[name][mod][path] = [key]
|
||||
else:
|
||||
dic[name][mod][path].append(key)
|
||||
res[name] = counts
|
||||
name += 'Files'
|
||||
dic[name] = {}
|
||||
if not res.has_key(name):
|
||||
res[name] = []
|
||||
counts = dict([(mod,0) for mod in res['tested']])
|
||||
counts['total'] = len(res[name])
|
||||
for mod, path in res[name]:
|
||||
counts[self.components[mod]] +=1
|
||||
if not dic[name].has_key(mod):
|
||||
dic[name][mod] = [path]
|
||||
else:
|
||||
dic[name][mod].append(path)
|
||||
res[name] = counts
|
||||
|
||||
s = Separator()
|
||||
for loc, lResult in result.iteritems():
|
||||
s.getDetails(result, loc)
|
||||
|
||||
saveHandler(result, 'cmp-data.json')
|
||||
|
||||
def failureTest(self, myResult, failureResult):
|
||||
'''signal pass/warn/failure for each locale'''
|
||||
def sumdata(data, part):
|
||||
res = 0
|
||||
for mod in [u'browser', u'toolkit']:
|
||||
res += data[part][mod] + data[part + u'Files'][mod]
|
||||
return res
|
||||
def getState(data):
|
||||
ret = 0
|
||||
if sumdata(data, u'obsolete') > 0:
|
||||
ret |= 1
|
||||
if sumdata(data, u'missing') > 0:
|
||||
ret |= 2
|
||||
return ret
|
||||
for loc, val in myResult.iteritems():
|
||||
if not failureResult.has_key(loc):
|
||||
failureResult[loc] = getState(val)
|
||||
else:
|
||||
failureResult |= getState(val)
|
||||
|
||||
from xml import sax
|
||||
from types import DictType, FunctionType
|
||||
import md5
|
||||
from codecs import utf_8_encode
|
||||
import re
|
||||
import os
|
||||
|
||||
class SearchTest(Base):
|
||||
"""Test class to collect information from search plugins and to
|
||||
verify that they're doing something good.
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
'''Set up the test class with a good leaf name'''
|
||||
self.leafName = 'search-results.json'
|
||||
pass
|
||||
def run(self):
|
||||
'''Collect all data from the MozSearch plugins in both the /cvsroot
|
||||
repository for en-US and the /l10n repository for locales
|
||||
|
||||
'''
|
||||
class DummyHandler(sax.handler.ContentHandler):
|
||||
def startDocument(self):
|
||||
self.md5 = md5.new()
|
||||
self.indent = ''
|
||||
self.engine = {'urls':[]}
|
||||
self.lNames = []
|
||||
self.textField = None
|
||||
self.content = ''
|
||||
return
|
||||
def endDocument(self):
|
||||
self.engine['md5'] = self.md5.hexdigest()
|
||||
return
|
||||
def startElementNS(self, (ns, local), qname, attrs):
|
||||
if self.textField:
|
||||
logging.warning('Found Element, but expected CDATA.')
|
||||
self.indent += ' '
|
||||
if ns != u'http://www.mozilla.org/2006/browser/search/':
|
||||
raise UserWarning, ('bad namespace: ' + ns)
|
||||
self.lNames.append(local)
|
||||
handler = self.getOpenHandler()
|
||||
if handler:
|
||||
handler(self, attrs)
|
||||
self.update(ns+local)
|
||||
for qna in attrs.getQNames():
|
||||
self.update(qna[0] + qna[1] + attrs.getValueByQName(qna))
|
||||
return
|
||||
def endElementNS(self, (ns, local), qname):
|
||||
if self.textField:
|
||||
self.engine[self.textField] = self.content
|
||||
self.textField = None
|
||||
self.content = ''
|
||||
self.lNames.pop()
|
||||
self.indent = self.indent[0:-2]
|
||||
def characters(self, content):
|
||||
self.update(content)
|
||||
if not self.textField:
|
||||
return
|
||||
self.content += content
|
||||
def update(self, content):
|
||||
self.md5.update(utf_8_encode(content)[0])
|
||||
def openURL(self, attrs):
|
||||
entry = {'params':{},
|
||||
'type': attrs.getValueByQName(u'type'),
|
||||
'template': attrs.getValueByQName(u'template')}
|
||||
self.engine['urls'].append(entry)
|
||||
def handleParam(self, attrs):
|
||||
try:
|
||||
self.engine['urls'][-1]['params'][attrs.getValueByQName(u'name')] = attrs.getValueByQName(u'value')
|
||||
except KeyError:
|
||||
raise UserWarning, 'bad param'
|
||||
return
|
||||
def handleMozParam(self, attrs):
|
||||
mp = None
|
||||
try:
|
||||
mp = { 'name': attrs.getValueByQName(u'name'),
|
||||
'condition': attrs.getValueByQName(u'condition'),
|
||||
'trueValue': attrs.getValueByQName(u'trueValue'),
|
||||
'falseValue': attrs.getValueByQName(u'falseValue')}
|
||||
except KeyError:
|
||||
try:
|
||||
mp = {'name': attrs.getValueByQName(u'name'),
|
||||
'condition': attrs.getValueByQName(u'condition'),
|
||||
'pref': attrs.getValueByQName(u'pref')}
|
||||
except KeyError:
|
||||
raise UserWarning, 'bad mozParam'
|
||||
if self.engine['urls'][-1].has_key('MozParams'):
|
||||
self.engine['urls'][-1]['MozParams'].append(mp)
|
||||
else:
|
||||
self.engine['urls'][-1]['MozParams'] = [mp]
|
||||
return
|
||||
def handleShortName(self, attrs):
|
||||
self.textField = 'ShortName'
|
||||
return
|
||||
def handleImage(self, attrs):
|
||||
self.textField = 'Image'
|
||||
return
|
||||
def getOpenHandler(self):
|
||||
return self.getHandler(DummyHandler.openHandlers)
|
||||
def getHandler(self, handlers):
|
||||
for local in self.lNames:
|
||||
if type(handlers) != DictType or not handlers.has_key(local):
|
||||
return
|
||||
handlers = handlers[local]
|
||||
if handlers.has_key('_handler'):
|
||||
return handlers['_handler']
|
||||
return
|
||||
openHandlers = {'SearchPlugin':
|
||||
{'ShortName': {'_handler': handleShortName},
|
||||
'Image': {'_handler': handleImage},
|
||||
'Url':{'_handler': openURL,
|
||||
'Param': {'_handler':handleParam},
|
||||
'MozParam': {'_handler':handleMozParam}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handler = DummyHandler()
|
||||
parser = sax.make_parser()
|
||||
parser.setContentHandler(handler)
|
||||
parser.setFeature(sax.handler.feature_namespaces, True)
|
||||
|
||||
locales = [loc.strip() for loc in open('mozilla/browser/locales/all-locales')]
|
||||
locales.insert(0, 'en-US')
|
||||
sets = {}
|
||||
details = {}
|
||||
|
||||
for loc in locales:
|
||||
l = logging.getLogger('locales.' + loc)
|
||||
try:
|
||||
lst = open(Paths.get_path('browser',loc,'searchplugins/list.txt'),'r')
|
||||
except IOError:
|
||||
l.error("Locale " + loc + " doesn't have search plugins")
|
||||
details[Paths.get_path('browser',loc,'searchplugins/list.txt')] = {
|
||||
'error': 'not found'
|
||||
}
|
||||
continue
|
||||
sets[loc] = {'list': []}
|
||||
regprop = Paths.get_path('browser', loc, 'chrome/browser-region/region.properties')
|
||||
p = Parser.getParser(regprop)
|
||||
p.read(regprop)
|
||||
orders = {}
|
||||
for key, val in p:
|
||||
m = re.match('browser.search.order.([1-9])', key)
|
||||
if m:
|
||||
orders[val.strip()] = int(m.group(1))
|
||||
elif key == 'browser.search.defaultenginename':
|
||||
sets[loc]['default'] = val.strip()
|
||||
sets[loc]['orders'] = orders
|
||||
for fn in lst:
|
||||
name = fn.strip()
|
||||
if len(name) == 0:
|
||||
continue
|
||||
leaf = 'searchplugins/' + name + '.xml'
|
||||
_path = Paths.get_path('browser','en-US', leaf)
|
||||
if not os.access(_path, os.R_OK):
|
||||
_path = Paths.get_path('browser', loc, leaf)
|
||||
l.debug('testing ' + _path)
|
||||
sets[loc]['list'].append(_path)
|
||||
try:
|
||||
parser.parse(_path)
|
||||
except IOError:
|
||||
l.error("can't open " + _path)
|
||||
details[_path] = {'_name': name, 'error': 'not found'}
|
||||
continue
|
||||
except UserWarning, ex:
|
||||
l.error("error in searchplugin " + _path)
|
||||
details[_path] = {'_name': name, 'error': ex.args[0]}
|
||||
continue
|
||||
except sax._exceptions.SAXParseException, ex:
|
||||
l.error("error in searchplugin " + _path)
|
||||
details[_path] = {'_name': name, 'error': ex.args[0]}
|
||||
continue
|
||||
details[_path] = handler.engine
|
||||
details[_path]['_name'] = name
|
||||
|
||||
engines = {'locales': sets,
|
||||
'details': details}
|
||||
return engines
|
||||
def failureTest(self, myResult, failureResult):
|
||||
'''signal pass/warn/failure for each locale
|
||||
Just signaling errors in individual plugins for now.
|
||||
|
||||
'''
|
||||
for loc, val in myResult['locales'].iteritems():
|
||||
l = logging.getLogger('locales.' + loc)
|
||||
# Verify that there are no errors in the engine parsing,
|
||||
# and that there default engine is the first one.
|
||||
if (not val['orders'].has_key(val['default'])) or val['orders'][val['default']] != 1:
|
||||
l.error('Default engine is not first in order in locale ' + loc)
|
||||
if not failureResult.has_key(loc):
|
||||
failureResult[loc] = 2
|
||||
else:
|
||||
failureResult[loc] |= 2
|
||||
for p in val['list']:
|
||||
# no logging, that is already reported above
|
||||
if myResult['details'][p].has_key('error'):
|
||||
if not failureResult.has_key(loc):
|
||||
failureResult[loc] = 2
|
||||
else:
|
||||
failureResult[loc] |= 2
|
||||
|
||||
class RSSReaderTest(Base):
|
||||
"""Test class to collect information about RSS readers and to
|
||||
verify that they might be working.
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
'''Set up the test class with a good leaf name'''
|
||||
self.leafName = 'feed-reader-results.json'
|
||||
pass
|
||||
def run(self):
|
||||
'''Collect the data from browsers region.properties for all locales
|
||||
|
||||
'''
|
||||
locales = [loc.strip() for loc in open('mozilla/browser/locales/all-locales')]
|
||||
uri = re.compile('browser\\.contentHandlers\\.types\\.([0-5])\\.uri')
|
||||
title = re.compile('browser\\.contentHandlers\\.types\\.([0-5])\\.title')
|
||||
res = {}
|
||||
for loc in locales:
|
||||
l = logging.getLogger('locales.' + loc)
|
||||
regprop = Paths.get_path('browser', loc, 'chrome/browser-region/region.properties')
|
||||
p = Parser.getParser(regprop)
|
||||
p.read(regprop)
|
||||
uris = {}
|
||||
titles = {}
|
||||
for key, val in p:
|
||||
m = uri.match(key)
|
||||
if m:
|
||||
o = int(m.group(1))
|
||||
if uris.has_key(o):
|
||||
l.error('Double definition of RSS reader ' + o)
|
||||
uris[o] = val.strip()
|
||||
else:
|
||||
m = title.match(key)
|
||||
if m:
|
||||
o = int(m.group(1))
|
||||
if titles.has_key(o):
|
||||
l.error('Double definition of RSS reader ' + o)
|
||||
titles[o] = val.strip()
|
||||
ind = sorted(uris.keys())
|
||||
if ind != range(len(ind)) or ind != sorted(titles.keys()):
|
||||
l.error('RSS Readers are badly set up')
|
||||
res[loc] = [(titles[o], uris[o]) for o in ind]
|
||||
return res
|
||||
|
||||
class BookmarksTest(Base):
|
||||
"""Test class to collect information about bookmarks and check their
|
||||
structure.
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
'''Set up the test class with a good leaf name'''
|
||||
self.leafName = 'bookmarks-results.json'
|
||||
pass
|
||||
def run(self):
|
||||
'''Collect the data from bookmarks.html for all locales
|
||||
|
||||
'''
|
||||
locales = [loc.strip() for loc in open('mozilla/browser/locales/all-locales')]
|
||||
bm = Parser.BookmarksParser()
|
||||
res = {}
|
||||
for loc in locales:
|
||||
try:
|
||||
bm.read('l10n/%s/browser/profile/bookmarks.html'%loc)
|
||||
res[loc] = bm.getDetails()
|
||||
except Exception, e:
|
||||
logging.getLogger('locale.%s'%loc).error('Bookmarks are busted, %s'%e)
|
||||
return res
|
||||
def failureTest(self, myResult, failureResult):
|
||||
'''signal pass/warn/failure for each locale
|
||||
Just signaling errors for now.
|
||||
|
||||
'''
|
||||
locales = [loc.strip() for loc in open('mozilla/browser/locales/all-locales')]
|
||||
bm = Parser.BookmarksParser()
|
||||
bm.read('mozilla/browser/locales/en-US/profile/bookmarks.html')
|
||||
enUSDetails = bm.getDetails()
|
||||
for loc in locales:
|
||||
if not myResult.has_key(loc):
|
||||
if not failureResult.has_key(loc):
|
||||
failureResult[loc] = 2
|
||||
else:
|
||||
failureResult[loc] |= 2
|
||||
@@ -1,83 +0,0 @@
|
||||
#! python
|
||||
# ***** 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 l10n test automation.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.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 *****
|
||||
|
||||
|
||||
import logging
|
||||
from optparse import OptionParser
|
||||
from pprint import pprint
|
||||
|
||||
from Mozilla import Paths, CompareLocales
|
||||
from Mozilla.CompareLocales import Separator
|
||||
|
||||
usage = 'usage: %prog [options] language1 [language2 ...]'
|
||||
parser = OptionParser(usage=usage)
|
||||
|
||||
parser.add_option('-a', '--application', default='browser',
|
||||
help='compare localizations for the specified application'+
|
||||
' [default: browser]')
|
||||
parser.add_option('-v', '--verbose', action='count', dest='v', default=0,
|
||||
help='Make more noise')
|
||||
parser.add_option('-q', '--quiet', action='count', dest='q', default=0,
|
||||
help='Make more noise')
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
if len(args) == 0:
|
||||
parser.error('At least one language required')
|
||||
|
||||
# log as verbose or quiet as we want, warn by default
|
||||
logging.basicConfig(level=(logging.WARNING - (options.v - options.q)*10))
|
||||
|
||||
# import Paths loaded all-locales for both browser and mail, we overwrite
|
||||
# that with our settings before calling into CompareLocales
|
||||
locales = {options.application: args}
|
||||
|
||||
# actually compare the localizations
|
||||
res = CompareLocales.compare(testLocales=locales)
|
||||
|
||||
s = Separator([options.application])
|
||||
|
||||
# pretty print results for all localizations
|
||||
for loc in args:
|
||||
print(loc + ':')
|
||||
pprint(s.getDetails(res, loc))
|
||||
result = res[loc]
|
||||
pprint(result)
|
||||
rate = result['changed']*100/ \
|
||||
(result['changed'] + result['unchanged'] + \
|
||||
result['missing']['total'])
|
||||
print('%d%% of entries changed' % rate)
|
||||
@@ -1,199 +0,0 @@
|
||||
#! python
|
||||
# ***** 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 l10n test automation.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2007
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.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 *****
|
||||
|
||||
|
||||
import logging
|
||||
import os.path
|
||||
import re
|
||||
from optparse import OptionParser
|
||||
from pprint import pprint
|
||||
from zipfile import ZipFile
|
||||
|
||||
from Mozilla import Parser
|
||||
|
||||
usage = 'usage: %prog [options] language-pack reference-pack'
|
||||
parser = OptionParser(usage=usage)
|
||||
|
||||
parser.add_option('-v', '--verbose', action='count', dest='v', default=0,
|
||||
help='Report more detail')
|
||||
parser.add_option('-q', '--quiet', action='count', dest='q', default=0,
|
||||
help='Report less detail')
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
if len(args) != 2:
|
||||
parser.error('language pack and reference pack required')
|
||||
|
||||
# log as verbose or quiet as we want, warn by default
|
||||
logging.basicConfig(level=(logging.WARNING - (options.v - options.q)*10))
|
||||
|
||||
# we expect two jar files
|
||||
assert args[0].endswith('.jar') and args[1].endswith('.jar') \
|
||||
, "Only jar files supported at the moment"
|
||||
|
||||
l10n_jar = ZipFile(args[0])
|
||||
if l10n_jar.testzip():
|
||||
parser.error('bad language pack: ' + args[0])
|
||||
l10n_locale = os.path.basename(args[0][:-4])
|
||||
|
||||
ref_jar = ZipFile(args[1])
|
||||
if ref_jar.testzip():
|
||||
parser.error('bad language pack: ' + args[1])
|
||||
ref_locale = os.path.basename(args[1][:-4])
|
||||
|
||||
l10n_entries = set(l10n_jar.namelist())
|
||||
ref_entries = set(ref_jar.namelist())
|
||||
|
||||
common_entries = l10n_entries & ref_entries
|
||||
l10n_entries = sorted(l10n_entries - common_entries)
|
||||
ref_entries = sorted(ref_entries - common_entries)
|
||||
common_entries = sorted(common_entries)
|
||||
|
||||
result = {'missing':[],'obsolete':[],
|
||||
'missingFiles':[],'obsoleteFiles':[],
|
||||
'changed':0,'unchanged':0,'keys':0}
|
||||
key = re.compile('[kK]ey')
|
||||
|
||||
# helper function to compare two jar entries
|
||||
|
||||
def compareFiles(l10n_name, ref_name):
|
||||
try:
|
||||
parser = Parser.getParser(ref_name)
|
||||
except UserWarning:
|
||||
logging.warning(" Can't compare " + ref_name)
|
||||
return
|
||||
parser.parse(ref_jar.read(ref_name))
|
||||
enTmp = parser.mapping()
|
||||
parser.parse(l10n_jar.read(l10n_name))
|
||||
for k,v in parser:
|
||||
if k not in enTmp:
|
||||
result['obsolete'].append((l10n_name,k))
|
||||
continue
|
||||
enVal = enTmp[k]
|
||||
del enTmp[k]
|
||||
if key.search(k):
|
||||
result['keys'] += 1
|
||||
else:
|
||||
if enVal == v:
|
||||
result['unchanged'] +=1
|
||||
logging.info('%s in %s unchanged' %
|
||||
(k, name))
|
||||
else:
|
||||
result['changed'] +=1
|
||||
result['missing'] += [(l10n_name,k) for k in enTmp.keys()]
|
||||
|
||||
# compare those entries with identical name
|
||||
|
||||
for name in common_entries:
|
||||
compareFiles(name, name)
|
||||
|
||||
# compare those entries with different name.
|
||||
# if the path matches locale/ab-CD/foo, replace the
|
||||
# language code with @AB_CD@ to compare
|
||||
#
|
||||
# We detect missing and obsolete files here, too.
|
||||
|
||||
l10n_key = ref_key = None
|
||||
while len(l10n_entries) and len(ref_entries):
|
||||
# we need to check the next entry in the tested pack
|
||||
if not l10n_key:
|
||||
l10n_key = l10n_entry = l10n_entries.pop(0)
|
||||
if l10n_key.startswith('locale/' + l10n_locale) and \
|
||||
not l10n_key.endswith('/'):
|
||||
# it's a locale/ab-CD file, but not a directory
|
||||
l10n_key = l10n_key.replace('locale/' + l10n_locale, 'locale/@AB_CD@')
|
||||
else:
|
||||
# directories and non-locale/ab-CD files are assumed to be obsolete
|
||||
l10n_key = None
|
||||
result['obsoleteFiles'].append(l10n_entry)
|
||||
continue
|
||||
# we need to check the next entry in the reference pack
|
||||
if not ref_key:
|
||||
ref_key = ref_entry = ref_entries.pop(0)
|
||||
if ref_key.startswith('locale/' + ref_locale) and \
|
||||
not ref_key.endswith('/'):
|
||||
ref_key = ref_key.replace('locale/' + ref_locale, 'locale/@AB_CD@')
|
||||
else:
|
||||
ref_key = None
|
||||
result['missingFiles'].append(ref_entry)
|
||||
continue
|
||||
# check if we found matching files
|
||||
if l10n_key != ref_key:
|
||||
# not, report missing or obsolete, and skip
|
||||
if l10n_key < ref_key:
|
||||
l10n_key = None
|
||||
result['obsoleteFiles'].append(l10n_entry)
|
||||
else:
|
||||
ref_key = None
|
||||
result['missingFiles'].append(ref_entry)
|
||||
continue
|
||||
compareFiles(l10n_entry, ref_entry)
|
||||
# both entries dealt with, unset keys to pop new ones in both jars
|
||||
l10n_key = ref_key = None
|
||||
|
||||
# remaining files are either missing or obsolete
|
||||
result['missingFiles'] += ref_entries
|
||||
result['obsoleteFiles'] += l10n_entries
|
||||
|
||||
# collapse the arrays to a more consice hash.
|
||||
dic = dict()
|
||||
def collectList(name):
|
||||
dic[name] = {}
|
||||
if name not in result:
|
||||
result[name] = []
|
||||
for path, key in result[name]:
|
||||
if path not in dic[name]:
|
||||
dic[name][path] = [key]
|
||||
else:
|
||||
dic[name][path].append(key)
|
||||
dic[name][path].sort()
|
||||
name += 'Files'
|
||||
dic[name] = []
|
||||
if name not in result:
|
||||
result[name] = []
|
||||
for path in result[name]:
|
||||
dic[name].append(path)
|
||||
|
||||
collectList('missing')
|
||||
collectList('obsolete')
|
||||
|
||||
pprint(dic)
|
||||
|
||||
rate = result['changed']*100/ \
|
||||
(result['changed'] + result['unchanged'] + result['missing'])
|
||||
|
||||
print('%d%% of entries changed' % rate)
|
||||
@@ -1,113 +0,0 @@
|
||||
#! python
|
||||
# ***** 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 l10n test automation.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.com>
|
||||
# Tomoya Asai (dynamis)
|
||||
#
|
||||
# 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 *****
|
||||
|
||||
# ***** BEGIN MEMO BLOCK *****
|
||||
# implemented:
|
||||
# support dtd, properties, inc
|
||||
# keep white space and comments
|
||||
# add new entities (and their comment)
|
||||
# comment out or remove obsolete entities
|
||||
# backup (rename) or remove obsolete file
|
||||
# not implemented:
|
||||
# check syntax error (assuming valid file only so far)
|
||||
# fix the order of entities
|
||||
# new entity insertion mode
|
||||
# must take care about the order of entities
|
||||
# remove l10n comment
|
||||
# merge comment change
|
||||
# ***** END MEMO BLOCK *****
|
||||
|
||||
|
||||
import logging
|
||||
from optparse import OptionParser
|
||||
from pprint import pprint
|
||||
|
||||
from Mozilla import Paths, L10nMerge
|
||||
from Mozilla.CompareLocales import Separator
|
||||
|
||||
usage = 'usage: %prog [options] language1 [language2 ...]'
|
||||
parser = OptionParser(usage=usage)
|
||||
|
||||
parser.add_option('-a', '--application', default='browser',
|
||||
help='merge localizations for the specified application'+
|
||||
' [default: browser]')
|
||||
parser.add_option('-v', '--verbose', action='count', dest='v', default=0,
|
||||
help='Make more noise')
|
||||
parser.add_option('-q', '--quiet', action='count', dest='q', default=0,
|
||||
help='Make less noise')
|
||||
parser.add_option('-b', '--backup', action='store_true', dest='backup',
|
||||
help='Backup obsolete files')
|
||||
parser.add_option('-c', '--cleanobsolete', action='store_true', dest='cleanobsolete',
|
||||
help='Don\'t keep obsolete entities as comments')
|
||||
# not implemented yet...
|
||||
#parser.add_option('-i', '--insertnew', action='store_true', dest='i',
|
||||
# help='Insert new entities instead of adding')
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
if len(args) == 0:
|
||||
parser.error('At least one language required')
|
||||
|
||||
# log as verbose or quiet as we want, warn by default
|
||||
logging.basicConfig(level=(logging.WARNING - (options.v - options.q)*10))
|
||||
|
||||
# import Paths loaded all-locales for both browser and mail, we overwrite
|
||||
# that with our settings before calling into L10nMerge
|
||||
locales = {options.application: args}
|
||||
|
||||
# mode setting optargs
|
||||
L10nMerge.options['backup'] = options.backup
|
||||
L10nMerge.options['cleanobsolete'] = options.cleanobsolete
|
||||
|
||||
|
||||
# actually merge the localizations
|
||||
res = L10nMerge.merge(testLocales = locales)
|
||||
|
||||
|
||||
s = Separator([options.application])
|
||||
|
||||
# pretty print results for all localizations
|
||||
for loc in args:
|
||||
print(loc + ':')
|
||||
pprint(s.getDetails(res, loc))
|
||||
result = res[loc]
|
||||
pprint(result)
|
||||
rate = result['changed']*100/ \
|
||||
(result['changed'] + result['unchanged'] + \
|
||||
result['missing']['total'])
|
||||
print('%d%% of entries changed (translated)' % rate)
|
||||
@@ -1,244 +0,0 @@
|
||||
#! python
|
||||
# ***** 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 l10n test automation.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.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 *****
|
||||
|
||||
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
from datetime import datetime
|
||||
import time
|
||||
from optparse import OptionParser
|
||||
import gzip
|
||||
import codecs
|
||||
|
||||
from Mozilla import Parser, CompareLocales, Paths, Tests
|
||||
import simplejson
|
||||
|
||||
#
|
||||
# Helper classes
|
||||
#
|
||||
|
||||
#
|
||||
# Logging
|
||||
#
|
||||
class LogHandler(logging.Handler):
|
||||
def __init__(self):
|
||||
self.log = []
|
||||
logging.Handler.__init__(self)
|
||||
def emit(self, record):
|
||||
self.log.append((record.name, record.levelname, record.getMessage().strip()))
|
||||
|
||||
#
|
||||
# JSON with optional gzip
|
||||
#
|
||||
class Wrapper:
|
||||
def __init__(self, path, name):
|
||||
self.p = os.path.join(path, name)
|
||||
self.n = name
|
||||
self.f = None
|
||||
if opts.gzip:
|
||||
self.p += '.gz'
|
||||
def open(self, mode):
|
||||
if self.f:
|
||||
self.f.close()
|
||||
if opts.gzip:
|
||||
mode += 'b'
|
||||
self.f = open(self.p, mode)
|
||||
if opts.gzip:
|
||||
self.f = gzip.GzipFile(fileobj = self.f, filename = self.n)
|
||||
self.w = codecs.getwriter('utf-8')(self.f)
|
||||
self.r = codecs.getreader('utf-8')(self.f)
|
||||
def write(self, str):
|
||||
self.w.write(str)
|
||||
def read(self, size = -1):
|
||||
return self.r.read(size)
|
||||
def rewind(self):
|
||||
if opts.gzip:
|
||||
self.f.rewind()
|
||||
else:
|
||||
self.f.seek(0,0)
|
||||
def close(self):
|
||||
if opts.gzip:
|
||||
f = self.f.fileobj;
|
||||
self.f.close()
|
||||
if opts.gzip:
|
||||
f.close()
|
||||
self.w = self.r = self.f = None
|
||||
#
|
||||
# Helper function for JSON output with optional gzip
|
||||
#
|
||||
def saveJSON(dic, localName):
|
||||
name = os.path.join(basePath, localName) ;
|
||||
if opts.gzip:
|
||||
f = open(name + '.gz', 'wb')
|
||||
s = gzip.GzipFile(fileobj = f, filename = localName)
|
||||
else:
|
||||
f = open(name, 'w')
|
||||
s = f
|
||||
sw = codecs.getwriter('utf-8')(s)
|
||||
sw.write(simplejson.dumps(dic, sort_keys=True))
|
||||
sw.reset()
|
||||
if opts.gzip:
|
||||
s.close()
|
||||
f.close()
|
||||
|
||||
|
||||
lvl = logging.WARNING
|
||||
date = datetime.utcnow().replace(second=0,microsecond=0).isoformat(' ')
|
||||
# parse commandline arguments
|
||||
cp = OptionParser(version='0.2')
|
||||
cp.add_option('-v', '--verbose', action='count', dest='v', default=0,
|
||||
help='Make more noise')
|
||||
cp.add_option('-q', '--quiet', action='count', dest='q', default=0,
|
||||
help='Make less noise')
|
||||
cp.add_option('-O', '--base-dir', type='string', dest='target',
|
||||
default='results',
|
||||
help='Destination base directory')
|
||||
cp.add_option('-c', '--checkout', action='store_true', dest='checkout',
|
||||
default=False,
|
||||
help='Run make -f client.mk l10n-checkout [Default: not]')
|
||||
cp.add_option('-d', '--date', type='string', dest='date',
|
||||
help='Explicit start date or subdir [Default: now]')
|
||||
cp.add_option('-z',action="store_true", dest="gzip", default=False,
|
||||
help='Use gzip compression for output')
|
||||
cp.add_option('-w','--enable-waterfall', action="store_true",
|
||||
dest="waterfall", default=False,
|
||||
help='Update waterfall data')
|
||||
cp.add_option('--end-date', type='string', dest='enddate',
|
||||
help='Explicit (faked) end date')
|
||||
opts, optlist = cp.parse_args(sys.argv[1:])
|
||||
|
||||
#
|
||||
# Set up Logging
|
||||
#
|
||||
logging.basicConfig(level=(logging.WARNING + 10*(opts.q - opts.v)))
|
||||
# Add a handler to store the output
|
||||
h = LogHandler()
|
||||
logging.getLogger('').addHandler(h)
|
||||
|
||||
#
|
||||
# Check that we're in the right location and check out if requested
|
||||
#
|
||||
try:
|
||||
os.chdir('mozilla')
|
||||
if opts.checkout:
|
||||
env = ''
|
||||
l = logging.getLogger('cvsco')
|
||||
if opts.date:
|
||||
env = 'MOZ_CO_DATE="' + opts.date + ' +0" '
|
||||
fh = os.popen(env + 'make -f client.mk l10n-checkout')
|
||||
for ln in fh:
|
||||
l.info(ln.strip())
|
||||
if fh.close():
|
||||
raise Exception('cvs checkout failed')
|
||||
os.chdir('..')
|
||||
except Exception,e:
|
||||
sys.exit(str(e))
|
||||
|
||||
if not opts.date:
|
||||
opts.date = date # use default set above
|
||||
|
||||
logging.debug(' Ensure output directory')
|
||||
# replace : with -
|
||||
opts.date = opts.date.replace(':','-')
|
||||
if not os.path.isdir(opts.target):
|
||||
sys.exit('error: ' + opts.target + ' is not a directory')
|
||||
if opts.waterfall:
|
||||
startdate = time.mktime(time.strptime(opts.date, '%Y-%m-%d %H-%M-%S')) + time.altzone
|
||||
basePath = os.path.join(opts.target, opts.date)
|
||||
if not os.path.isdir(basePath):
|
||||
os.mkdir(basePath)
|
||||
|
||||
|
||||
tests = [Tests.CompareTest(),
|
||||
Tests.SearchTest(),
|
||||
Tests.RSSReaderTest(),
|
||||
Tests.BookmarksTest()]
|
||||
drop = {}
|
||||
for test in tests:
|
||||
res = test.run()
|
||||
test.serialize(res, saveJSON)
|
||||
if opts.waterfall:
|
||||
test.failureTest(res, drop)
|
||||
|
||||
if not opts.waterfall:
|
||||
saveJSON(h.log, 'buildlog.json')
|
||||
sys.exit()
|
||||
|
||||
|
||||
if opts.enddate:
|
||||
endtime = time.mktime(time.strptime(opts.enddate, '%Y-%m-%d %H:%M:%S')) + time.altzone
|
||||
else:
|
||||
endtime = time.mktime(datetime.now().timetuple())
|
||||
f = None
|
||||
w = Wrapper(opts.target, 'waterfall.json')
|
||||
if os.path.isfile(w.p):
|
||||
w.open('r')
|
||||
water = simplejson.load(w)
|
||||
else:
|
||||
water = []
|
||||
|
||||
water.append((opts.date, (startdate, endtime), drop))
|
||||
#
|
||||
# Check if we need to rotate the waterfall
|
||||
#
|
||||
rotateLen = 24
|
||||
if len(water) > rotateLen * 1.5:
|
||||
# rotate, maximum of 16 logs
|
||||
suffix = ''
|
||||
if opts.gzip:
|
||||
suffix = '.gz'
|
||||
fnames = [os.path.join(opts.target, 'waterfall-%x.json'%i) + suffix for i in range(16)]
|
||||
# remove oldest log
|
||||
if os.path.isfile(fnames[15]):
|
||||
os.remove(fnames[15])
|
||||
for l in range(14, -1, -1):
|
||||
if os.path.isfile(fnames[l]):
|
||||
os.rename(fnames[l], fnames[l+1])
|
||||
w0 = Wrapper('.', fnames[0])
|
||||
w0.open('w')
|
||||
simplejson.dump(water[:rotateLen], w0, sort_keys=True)
|
||||
w0.close()
|
||||
water = water[rotateLen:]
|
||||
|
||||
w.open('w')
|
||||
simplejson.dump(water, w, sort_keys=True)
|
||||
w.close()
|
||||
|
||||
saveJSON(h.log, 'buildlog.json')
|
||||
@@ -1,105 +0,0 @@
|
||||
#!python
|
||||
# ***** 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 l10n test automation.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2006
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <l10n@mozilla.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 *****
|
||||
|
||||
import sys
|
||||
import logging
|
||||
from optparse import OptionParser
|
||||
from urlparse import urlparse
|
||||
import httplib
|
||||
from urllib2 import urlopen
|
||||
|
||||
EN_US_FEED = 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml'
|
||||
FEEDSERVER = '%s.fxfeeds.mozilla.com'
|
||||
FEEDPATH = '/%s/firefox/headlines.xml'
|
||||
|
||||
L10NFEEDS = 'http://wiki.mozilla.org/Firefox2/L10n_Feed_Redirects?action=raw'
|
||||
|
||||
op = OptionParser()
|
||||
op.add_option('--oldid', dest='oldid',
|
||||
help='explicitly give a version number on the wiki')
|
||||
op.add_option('-v', dest='verbose', action='count', default=0,
|
||||
help='increase verbosity')
|
||||
(options, args) = op.parse_args()
|
||||
|
||||
if len(args) != 1:
|
||||
sys.exit('all-locales or shipped-locales path expected')
|
||||
|
||||
logging.basicConfig(level=(logging.WARNING - options.verbose*10))
|
||||
|
||||
if options.oldid:
|
||||
L10NFEEDS += '&oldid=' + options.oldid
|
||||
|
||||
lFeeds = urlopen(L10NFEEDS)
|
||||
redirs = {}
|
||||
|
||||
for row in lFeeds:
|
||||
d, loc, url = row.split(' ', 2)
|
||||
redirs[loc] = url.strip()
|
||||
|
||||
# parse all-locales and shipped-locales, only take first bunch
|
||||
lFile = open(args[0])
|
||||
locales = [ln.split(' ', 1)[0].strip() for ln in lFile]
|
||||
# ignore ja-JP-mac, same bookmarks as ja
|
||||
def not_ja_JP_mac(loc): return loc != 'ja-JP-mac'
|
||||
locales = filter(not_ja_JP_mac, locales)
|
||||
|
||||
for loc in locales:
|
||||
logging.debug('testing ' + loc)
|
||||
server = FEEDSERVER % loc
|
||||
path = FEEDPATH % loc
|
||||
while server.endswith('mozilla.com'):
|
||||
url = None
|
||||
conn = httplib.HTTPConnection(server)
|
||||
conn.request('HEAD', path)
|
||||
r = conn.getresponse()
|
||||
if r.status != 302:
|
||||
logging.error('mozilla.com loses feed for ' + loc)
|
||||
server = ''
|
||||
continue
|
||||
url = r.getheader('location')
|
||||
server, path = urlparse(url)[1:3]
|
||||
conn.close()
|
||||
refurl = EN_US_FEED
|
||||
if redirs.has_key(loc):
|
||||
refurl = redirs[loc]
|
||||
if url != refurl:
|
||||
print loc, "FAIL"
|
||||
logging.info(str(url) + ' is not ' + refurl)
|
||||
else:
|
||||
logging.debug(loc + ' PASS')
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
#! python
|
||||
|
||||
from xml import sax
|
||||
from types import DictType, FunctionType
|
||||
import md5
|
||||
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import logging
|
||||
from codecs import utf_8_encode
|
||||
|
||||
from Mozilla import Paths, Parser
|
||||
import simplejson
|
||||
|
||||
lvl = logging.WARNING
|
||||
# parse commandline arguments
|
||||
argsiter = sys.argv.__iter__()
|
||||
# drop command
|
||||
argsiter.next()
|
||||
for arg in argsiter:
|
||||
if arg == '-V':
|
||||
lvl -= 10
|
||||
|
||||
logging.basicConfig(level=lvl)
|
||||
|
||||
|
||||
class DummyHandler(sax.handler.ContentHandler):
|
||||
def startDocument(self):
|
||||
self.md5 = md5.new()
|
||||
self.indent = ''
|
||||
self.engine = {'urls':[]}
|
||||
self.lNames = []
|
||||
self.textField = None
|
||||
return
|
||||
def endDocument(self):
|
||||
self.engine['md5'] = self.md5.hexdigest()
|
||||
return
|
||||
def startElementNS(self, (ns, local), qname, attrs):
|
||||
self.indent += ' '
|
||||
if ns != u'http://www.mozilla.org/2006/browser/search/':
|
||||
raise UserWarning, ('bad namespace: ' + ns)
|
||||
self.lNames.append(local)
|
||||
handler = self.getOpenHandler()
|
||||
if handler:
|
||||
handler(self, attrs)
|
||||
self.update(ns+local)
|
||||
for qna in attrs.getQNames():
|
||||
self.update(qna[0] + qna[1] + attrs.getValueByQName(qna))
|
||||
return
|
||||
def endElementNS(self, (ns, local), qname):
|
||||
self.lNames.pop()
|
||||
self.indent = self.indent[0:-2]
|
||||
def characters(self, content):
|
||||
self.update(content)
|
||||
if not self.textField:
|
||||
return
|
||||
self.engine[self.textField] = content
|
||||
self.textField = None
|
||||
def update(self, content):
|
||||
self.md5.update(utf_8_encode(content)[0])
|
||||
def openURL(self, attrs):
|
||||
entry = {'params':{},
|
||||
'type': attrs.getValueByQName(u'type'),
|
||||
'template': attrs.getValueByQName(u'template')}
|
||||
self.engine['urls'].append(entry)
|
||||
def handleParam(self, attrs):
|
||||
try:
|
||||
self.engine['urls'][-1]['params'][attrs.getValueByQName(u'name')] = attrs.getValueByQName(u'value')
|
||||
except KeyError:
|
||||
raise UserWarning, 'bad param'
|
||||
return
|
||||
def handleMozParam(self, attrs):
|
||||
try:
|
||||
self.engine['urls'][-1]['MozParams'] = {
|
||||
'name': attrs.getValueByQName(u'name'),
|
||||
'condition': attrs.getValueByQName(u'condition'),
|
||||
'trueValue': attrs.getValueByQName(u'trueValue'),
|
||||
'falseValue': attrs.getValueByQName(u'falseValue')}
|
||||
except KeyError:
|
||||
raise UserWarning, 'bad mozParam'
|
||||
return
|
||||
def handleShortName(self, attrs):
|
||||
self.textField = 'ShortName'
|
||||
return
|
||||
def handleImage(self, attrs):
|
||||
self.textField = 'Image'
|
||||
return
|
||||
def getOpenHandler(self):
|
||||
return self.getHandler(DummyHandler.openHandlers)
|
||||
def getHandler(self, handlers):
|
||||
for local in self.lNames:
|
||||
if type(handlers) != DictType or not handlers.has_key(local):
|
||||
return
|
||||
handlers = handlers[local]
|
||||
if handlers.has_key('_handler'):
|
||||
return handlers['_handler']
|
||||
return
|
||||
openHandlers = {'SearchPlugin':
|
||||
{'ShortName': {'_handler': handleShortName},
|
||||
'Image': {'_handler': handleImage},
|
||||
'Url':{'_handler': openURL,
|
||||
'Param': {'_handler':handleParam},
|
||||
'MozParam': {'_handler':handleMozParam}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handler = DummyHandler()
|
||||
parser = sax.make_parser()
|
||||
parser.setContentHandler(handler)
|
||||
parser.setFeature(sax.handler.feature_namespaces, True)
|
||||
|
||||
locales = [loc.strip() for loc in open('mozilla/browser/locales/all-locales')]
|
||||
locales.insert(0, 'en-US')
|
||||
sets = {}
|
||||
details = {}
|
||||
|
||||
for loc in locales:
|
||||
try:
|
||||
lst = open(Paths.get_path('browser',loc,'searchplugins/list.txt'),'r')
|
||||
except IOError:
|
||||
logging.error("Locale " + loc + " doesn't have search plugins")
|
||||
details[Paths.get_path('browser',loc,'searchplugins/list.txt')] = {
|
||||
'error': 'not found'
|
||||
}
|
||||
continue
|
||||
sets[loc] = {'list': []}
|
||||
regprop = Paths.get_path('browser', loc, 'chrome/browser-region/region.properties')
|
||||
p = Parser.getParser(regprop)
|
||||
p.read(regprop)
|
||||
orders = {}
|
||||
for key, val in p:
|
||||
m = re.match('browser.search.order.([1-9])', key)
|
||||
if m:
|
||||
orders[val.strip()] = int(m.group(1))
|
||||
sets[loc]['orders'] = orders
|
||||
for fn in lst:
|
||||
name = fn.strip()
|
||||
leaf = 'searchplugins/' + name + '.xml'
|
||||
_path = Paths.get_path('browser','en-US', leaf)
|
||||
if not os.access(_path, os.R_OK):
|
||||
_path = Paths.get_path('browser', loc, leaf)
|
||||
logging.info('testing ' + _path)
|
||||
sets[loc]['list'].append(_path)
|
||||
try:
|
||||
parser.parse(_path)
|
||||
except IOError:
|
||||
logging.error("can't open " + _path)
|
||||
details[_path] = {'_name': name, 'error': 'not found'}
|
||||
continue
|
||||
except UserWarning, ex:
|
||||
logging.error("error in searchplugin " + _path)
|
||||
details[_path] = {'_name': name, 'error': ex.args[0]}
|
||||
continue
|
||||
except sax._exceptions.SAXParseException, ex:
|
||||
logging.error("error in searchplugin " + _path)
|
||||
details[_path] = {'_name': name, 'error': ex.args[0]}
|
||||
continue
|
||||
details[_path] = handler.engine
|
||||
details[_path]['_name'] = name
|
||||
|
||||
engines = {'locales': sets,
|
||||
'details': details}
|
||||
enginelist = details.keys()
|
||||
enginelist.sort()
|
||||
fp = open('search-results.js','w')
|
||||
fp.write('results = ')
|
||||
simplejson.dump(engines, fp, sort_keys=True)
|
||||
fp.close()
|
||||
print enginelist
|
||||
@@ -1,32 +0,0 @@
|
||||
from distutils.core import setup
|
||||
|
||||
from distutils.cmd import Command
|
||||
import glob
|
||||
|
||||
class web(Command):
|
||||
description = 'install web files'
|
||||
user_options = [('target=','d','base directory for installation')]
|
||||
|
||||
def initialize_options(self):
|
||||
self.target = None
|
||||
pass
|
||||
def finalize_options(self):
|
||||
pass
|
||||
def run(self):
|
||||
self.ensure_dirname('target')
|
||||
for f in glob.glob('web/*.*'):
|
||||
if f.find('/CVS') >=0 or f.find('~') >= 0:
|
||||
continue
|
||||
self.copy_file(f, self.target)
|
||||
|
||||
setup(name="l10n-tools",
|
||||
version="0.2",
|
||||
author="Axel Hecht",
|
||||
author_email="l10n@mozilla.com",
|
||||
scripts=['scripts/compare-locales', 'scripts/verify-search',
|
||||
'scripts/test-locales',
|
||||
'scripts/verify-rss-redirects'],
|
||||
package_dir={'': 'lib'},
|
||||
packages=['Mozilla'],
|
||||
cmdclass={'web': web}
|
||||
)
|
||||
@@ -1,147 +0,0 @@
|
||||
/* ***** 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 Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
|
||||
var bookmarksView = {
|
||||
__proto__: baseView,
|
||||
setUpHandlers: function() {
|
||||
_t = this;
|
||||
},
|
||||
destroyHandlers: function() {
|
||||
},
|
||||
// Helper methods
|
||||
createFullTree: function ct(aDetails, aNode, aName) {
|
||||
if (!aDetails || ! (aDetails instanceof Object))
|
||||
return;
|
||||
var cat = new YAHOO.widget.TextNode(aName, aNode, true);
|
||||
for each (postfix in ["Files", ""]) {
|
||||
var subRes = aDetails[aName + postfix];
|
||||
var append = postfix ? ' (files)' : '';
|
||||
for (mod in subRes) {
|
||||
var mn = new YAHOO.widget.TextNode(mod + append, cat, true);
|
||||
for (fl in subRes[mod]) {
|
||||
if (postfix) {
|
||||
new YAHOO.widget.TextNode(subRes[mod][fl], mn, false);
|
||||
continue;
|
||||
}
|
||||
var fn = new YAHOO.widget.TextNode(fl, mn, false);
|
||||
var keys = [];
|
||||
for each (k in subRes[mod][fl]) {
|
||||
keys.push(k);
|
||||
}
|
||||
new YAHOO.widget.HTMLNode("<pre>" + keys.join("\n") + "</pre>", fn, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cat;
|
||||
}
|
||||
};
|
||||
var bookmarksController = {
|
||||
__proto__: baseController,
|
||||
get path() {
|
||||
return 'results/' + this.tag + '/bookmarks-results.json';
|
||||
},
|
||||
beforeSelect: function() {
|
||||
this.result = {};
|
||||
this.isShown = false;
|
||||
bookmarksView.setUpHandlers();
|
||||
var _t = this;
|
||||
var callback = function(obj) {
|
||||
delete _t.req;
|
||||
if (view != bookmarksView) {
|
||||
// ignore, we have switched again
|
||||
return;
|
||||
}
|
||||
_t.result = obj;
|
||||
bookmarksView.updateView(keys(_t.result));
|
||||
};
|
||||
this.req = JSON.get('results/' + this.tag + '/bookmarks-results.json', callback);
|
||||
},
|
||||
beforeUnSelect: function() {
|
||||
if (this.req) {
|
||||
this.req.abort();
|
||||
delete this.req;
|
||||
}
|
||||
bookmarksView.destroyHandlers();
|
||||
},
|
||||
showView: function(aClosure) {
|
||||
// json onload handler does this;
|
||||
},
|
||||
getContent: function(aLoc) {
|
||||
var row = view.getCell();
|
||||
var inner = document.createElement('div');
|
||||
row.appendChild(inner);
|
||||
var r = this.result[aLoc];
|
||||
var id = "bookmarks-" + aLoc;
|
||||
inner.id = id;
|
||||
var hasDetails = true;
|
||||
t = new YAHOO.widget.TreeView(inner);
|
||||
var d = this.result[aLoc];
|
||||
var innerContent = d['__title__'];
|
||||
function createChildren(aData, aParent, isOpen) {
|
||||
if ('children' in aData) {
|
||||
// Folder
|
||||
innerContent = aData['__title__'];
|
||||
if ('__desc__' in aData && aData['__desc__']) {
|
||||
innerContent += '<br><em>' + aData['__desc__'] + '</em>';
|
||||
}
|
||||
var nd = new YAHOO.widget.HTMLNode(innerContent, aParent, isOpen, true);
|
||||
for each (child in aData['children']) {
|
||||
createChildren(child, nd, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Link
|
||||
innerContent = '';
|
||||
if ('ICON' in aData) {
|
||||
innerContent = '<img src="' + aData['ICON'] + '">';
|
||||
}
|
||||
innerContent += '<a href="' + aData['HREF'] + '">' +
|
||||
aData['__title__'] + '</a>';
|
||||
if ('FEEDURL' in aData) {
|
||||
innerContent += '<a href="' + aData['FEEDURL'] + '"> <em>(FEED)</em></a>';
|
||||
}
|
||||
new YAHOO.widget.HTMLNode(innerContent, aParent, false, false);
|
||||
}
|
||||
}
|
||||
createChildren(d, t.getRoot(), false);
|
||||
t.draw();
|
||||
return row;
|
||||
}
|
||||
};
|
||||
controller.addPane('Bookmarks', 'bookmarks', bookmarksController,
|
||||
bookmarksView);
|
||||
@@ -1,409 +0,0 @@
|
||||
/* ***** 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 Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
var controller = {}, view = {};
|
||||
|
||||
const kModules = ['browser','mail','toolkit'];
|
||||
const Tier1 = ['en-GB', 'fr', 'de', 'ja', 'ja-JP-mac', 'pl', 'es-ES'];
|
||||
const Tier2 = ['zh-CN', 'zh-TW', 'cs', 'da', 'nl', 'fi', 'hu', 'it', 'ko', 'pt-BR', 'pt-PT', 'ru', 'es-AR', 'sv-SE', 'tr'];
|
||||
|
||||
tierMap = {};
|
||||
for each (var loc in Tier1) tierMap[loc] = 'Tier-1';
|
||||
for each (var loc in Tier2) tierMap[loc] = 'Tier-2';
|
||||
|
||||
|
||||
function keys(obj) {
|
||||
var k = [];
|
||||
for (var f in obj) k.push(f);
|
||||
k.sort();
|
||||
return k;
|
||||
}
|
||||
|
||||
function JSON_c() {
|
||||
this._requests = [];
|
||||
this._getRequest = function() {
|
||||
for each (var req in this._requests) {
|
||||
if (!req.status)
|
||||
return req;
|
||||
}
|
||||
req = new XMLHttpRequest();
|
||||
this._requests.push(req);
|
||||
return req;
|
||||
};
|
||||
};
|
||||
JSON_c.prototype = {
|
||||
cache : {
|
||||
MAX_SIZE: 6,
|
||||
_objs: {},
|
||||
_lru: [],
|
||||
get: function(aURL) {
|
||||
if (!(aURL in this._objs)) {
|
||||
return null;
|
||||
}
|
||||
var i = this._lru.indexOf(aURL);
|
||||
for (var j = i; j>0; j--) {
|
||||
this._lru[j] = this._lru[j-1];
|
||||
}
|
||||
this._lru[0] = aURL;
|
||||
return this._objs[aURL];
|
||||
},
|
||||
put: function(aURL, aObject) {
|
||||
this._lru.unshift(aURL);
|
||||
this._objs[aURL] = aObject;
|
||||
}
|
||||
},
|
||||
get : function(aURL, aCallback) {
|
||||
var obj = this.cache.get(aURL);
|
||||
if (obj) {
|
||||
controller.delay(controller, aCallback, [obj]);
|
||||
return;
|
||||
}
|
||||
var _t = this;
|
||||
var req = this._getRequest();
|
||||
req.overrideMimeType("text/plain"); // don't parse XML, this is js
|
||||
req.onerror = function(event) {
|
||||
_t.handleFailure(event.target);
|
||||
event.stopPropagation();
|
||||
};
|
||||
req.onload = function(event) {
|
||||
_t.handleSuccess(event.target);
|
||||
event.stopPropagation();
|
||||
};
|
||||
req._mURL = aURL;
|
||||
if (aCallback) {
|
||||
req.callback = aCallback;
|
||||
}
|
||||
req.open("GET", aURL, true);
|
||||
try {
|
||||
req.send(null);
|
||||
} catch (e) {
|
||||
// work around send sending errors, but not the callback
|
||||
this.handleFailure(req);
|
||||
}
|
||||
return req;
|
||||
},
|
||||
// callbacks
|
||||
handleSuccess : function(o) {
|
||||
if (o.responseText === undefined)
|
||||
throw "expected response text in handleSuccess";
|
||||
if (o.callback) {
|
||||
var obj = eval('('+o.responseText+')');
|
||||
this.cache.put(o._mURL, obj);
|
||||
o.callback(obj);
|
||||
delete o.callback;
|
||||
}
|
||||
},
|
||||
handleFailure : function(o) {
|
||||
YAHOO.widget.Logger("load failed with " + o.status + " " + o.statusText);
|
||||
}
|
||||
};
|
||||
var JSON = new JSON_c();
|
||||
|
||||
|
||||
baseView = {
|
||||
init: function() {
|
||||
this.content = document.getElementById('content');
|
||||
var checks = document.getElementById('checks');
|
||||
checks.addEventListener("click", view.onClickDisplay, true);
|
||||
for (var i = 0; i < checks.childNodes.length; i++) {
|
||||
if (checks.childNodes[i] instanceof HTMLInputElement) {
|
||||
this.setTierDisplay(checks.childNodes[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
showHeader: function() {
|
||||
document.getElementById('head').innerHTML='<td class="locale">Locale</td>';
|
||||
},
|
||||
updateView: function(aLocales, aClosure) {
|
||||
YAHOO.widget.Logger.log('updateView called');
|
||||
this.showHeader();
|
||||
var oldIndex = 0;
|
||||
var selection = null;
|
||||
for each (loc in aLocales) {
|
||||
var id = "row-" + loc;
|
||||
var oldChild = this.content.childNodes[oldIndex++];
|
||||
var t;
|
||||
if (oldChild) {
|
||||
t = oldChild;
|
||||
t.innerHTML = '';
|
||||
if (t.id != id) {
|
||||
// we don't have the right row, make sure to remove the ID
|
||||
// from the pre-existing one, just in case
|
||||
var obsRow = document.getElementById(id);
|
||||
if (obsRow) {
|
||||
obsRow.id = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
t = document.createElement("tr");
|
||||
this.content.appendChild(t);
|
||||
}
|
||||
t.id = id;
|
||||
t.className = '';
|
||||
if (tierMap[loc])
|
||||
t.className += ' ' + tierMap[loc];
|
||||
else
|
||||
t.className += ' Tier-3';
|
||||
t.innerHTML = '<td class="locale">' + loc + '</td>';
|
||||
t.appendChild(controller.getContent(loc));
|
||||
};
|
||||
while ((oldChild = this.content.childNodes[oldIndex])) {
|
||||
this.content.removeChild(oldChild);
|
||||
}
|
||||
},
|
||||
addTab: function(aName, aKey) {
|
||||
var tab = document.createElement('li');
|
||||
tab.textContent = aName;
|
||||
tab.id = '_tab_' + aKey;
|
||||
document.getElementById('tabs').appendChild(tab);
|
||||
tab.onclick = function(event){return controller.select(aKey);};
|
||||
},
|
||||
selectTab: function(aKey) {
|
||||
var tabs = document.getElementById('tabs');
|
||||
var id = '_tab_' + aKey;
|
||||
for (var i=0; i < tabs.childNodes.length; i++) {
|
||||
var tab = tabs.childNodes[i];
|
||||
var toBeSelected = tab.id == id;
|
||||
if (toBeSelected) {
|
||||
tab.setAttribute('selected','selected');
|
||||
}
|
||||
else {
|
||||
tab.removeAttribute('selected');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
onClickDisplay: function(event) {
|
||||
if (event.target.localName != 'INPUT') {
|
||||
return false;
|
||||
}
|
||||
var handler = function() {return function(){view.setTierDisplay(event.target)}};
|
||||
window.setTimeout(handler(),10);
|
||||
return true;
|
||||
},
|
||||
setTierDisplay: function(aTier, aTruth) {
|
||||
if (aTruth === undefined && aTier instanceof HTMLInputElement) {
|
||||
aTruth = aTier.checked;
|
||||
}
|
||||
var disable = aTruth;
|
||||
var name = aTier;
|
||||
if (aTier instanceof HTMLInputElement) {
|
||||
name = aTier.name;
|
||||
}
|
||||
var id = 'style-' + name;
|
||||
document.getElementById(id).disabled = disable;
|
||||
return false;
|
||||
},
|
||||
setTag: function(aTag) {
|
||||
document.getElementById('tag-view').value = aTag;
|
||||
},
|
||||
getCell: function() {
|
||||
return document.createElement('td');
|
||||
},
|
||||
getClass: function(aLoc) {
|
||||
if (tierMap[aLoc]) {
|
||||
return tierMap[aLoc];
|
||||
}
|
||||
return 'Tier-3';
|
||||
}
|
||||
};
|
||||
|
||||
baseController = {
|
||||
_l: [],
|
||||
_c: null,
|
||||
_pending: [],
|
||||
_target: null,
|
||||
_tag: '.',
|
||||
beforeUnSelect: function(){},
|
||||
beforeSelect: function(){},
|
||||
get locales() {
|
||||
return this._l;
|
||||
},
|
||||
get tag() {
|
||||
return baseController._tag;
|
||||
},
|
||||
set tag(aTag) {
|
||||
baseController._tag = aTag;
|
||||
view.setTag(aTag);
|
||||
},
|
||||
get path() {
|
||||
throw 'not implemented';
|
||||
},
|
||||
addLocales: function(lst) {
|
||||
var nl = lst.filter(function(el,i,a) {return this._l.indexOf(el) < 0;}, this);
|
||||
this._l = this._l.concat(nl);
|
||||
this._l.sort();
|
||||
},
|
||||
select: function(aKey) {
|
||||
if (this._target == aKey) {
|
||||
return;
|
||||
}
|
||||
if (this._target)
|
||||
this._c[this._target].controller.beforeUnSelect();
|
||||
this._target = aKey;
|
||||
var nCV = this._c[this._target];
|
||||
view = nCV.view;
|
||||
controller = nCV.controller;
|
||||
controller.beforeSelect();
|
||||
controller._target = aKey;
|
||||
view.selectTab(aKey);
|
||||
this.delay(controller, controller.showView, []);
|
||||
//controller.ensureData(aKey, nCV.controller.showView, nCV.controller);
|
||||
},
|
||||
ensureData: function(aKey, aCallback, aController) {
|
||||
var p = a;
|
||||
},
|
||||
showView: function(aClosure) {
|
||||
view.updateView(controller.locales, aClosure);
|
||||
},
|
||||
showLog: function(aTag, aLocale) {
|
||||
var _t = this;
|
||||
var dlgProps = { xy: ["1em", "1em"], height: "40em", width: "40em",
|
||||
modal:true, draggable:false }
|
||||
var dlg = new YAHOO.widget.SimpleDialog("log-dlg", dlgProps);
|
||||
var prefix = '';
|
||||
if (aLocale) {
|
||||
prefix = '[' + aLocale + '] ';
|
||||
}
|
||||
dlg.setHeader(prefix + 'build log, ' + aTag);
|
||||
dlg.setBody('Loading …');
|
||||
var okButton = {
|
||||
text: 'OK',
|
||||
handler: function(){
|
||||
this.hide();
|
||||
this.destroy()
|
||||
},
|
||||
isDefault: true
|
||||
};
|
||||
dlg.cfg.queueProperty("buttons", [okButton]);
|
||||
dlg.render(document.body);
|
||||
dlg.moveTo(10, 10);
|
||||
document.body.scrollTop = 0;
|
||||
var callback = function(obj) {
|
||||
_t.handleLog.apply(_t, [obj, dlg, aLocale]);
|
||||
};
|
||||
JSON.get('results/' + aTag + '/buildlog.json', callback);
|
||||
},
|
||||
handleLog: function(aLog, aDlg, aLocale) {
|
||||
var df = document.createDocumentFragment();
|
||||
var filter = function(lr) {
|
||||
return true;
|
||||
}
|
||||
if (aLocale) {
|
||||
filter = function(lr) {
|
||||
var logName = lr[0];
|
||||
var level = lr[1];
|
||||
var msg = lr[2];
|
||||
var loc = '/' + aLocale + '/';
|
||||
if (logName == 'cvsco') {
|
||||
return msg.indexOf('mozilla/') >= 0 ||
|
||||
msg.indexOf(loc) >= 0 ||
|
||||
msg.indexOf('make[') >= 0 ||
|
||||
msg.indexOf('checkout') >= 0;
|
||||
}
|
||||
if (logName == 'locales') {
|
||||
return msg.indexOf(loc) >= 0;
|
||||
}
|
||||
return logName == ('locales.' + aLocale);
|
||||
}
|
||||
}
|
||||
for each (var r in aLog) {
|
||||
if (!filter(r)) {
|
||||
continue;
|
||||
}
|
||||
var d = document.createElement('pre');
|
||||
d.className = 'log-row ' + r[1];
|
||||
// XXX filter on r[0:1]
|
||||
d.textContent = r[2];
|
||||
df.appendChild(d);
|
||||
}
|
||||
aDlg.setBody(df);
|
||||
},
|
||||
showDetails: function(aTag, aLoc) {
|
||||
var cells = [];
|
||||
for (var key in baseController._c) {
|
||||
if (key != 'waterfall') {
|
||||
cells.push(baseController._c[key].controller.getContent(aLoc));
|
||||
}
|
||||
}
|
||||
},
|
||||
getContent: function(aLoc) {
|
||||
if (! this._target) return;
|
||||
return this._c[this._target].getContent(aLoc);
|
||||
},
|
||||
addPane: function(aName, aKey, aController, aView) {
|
||||
if (! this._c) {
|
||||
this._pending.push([aName, aKey, aController, aView]);
|
||||
return;
|
||||
}
|
||||
view.addTab(aName, aKey);
|
||||
this._c[aKey] = {controller: aController, view: aView};
|
||||
},
|
||||
loaded: function() {
|
||||
this._c = {};
|
||||
for each (var c in this._pending) {
|
||||
this.addPane.apply(this, c);
|
||||
}
|
||||
this.select(this._pending[0][1]);
|
||||
delete this._pending;
|
||||
},
|
||||
delay: function(context, f, args) {
|
||||
window.setTimeout(function(){f.apply(context,args);}, 10);
|
||||
}
|
||||
};
|
||||
|
||||
var outlineController = {
|
||||
__proto__: baseController,
|
||||
getHeader: function() {
|
||||
var h = document.createElement('th');
|
||||
h.textContent = 'Details';
|
||||
return h;
|
||||
},
|
||||
getContent: function(aLoc) {
|
||||
var cell = view.getCell();
|
||||
cell.innerHTML = 'Details for ' + aLoc;
|
||||
return cell;
|
||||
}
|
||||
};
|
||||
var outlineView = {
|
||||
__proto__: baseView
|
||||
};
|
||||
//baseController.addPane('Outline', 'outline', outlineController, outlineView);
|
||||
|
||||
view = baseView;
|
||||
controller = baseController;
|
||||
@@ -1,200 +0,0 @@
|
||||
/* ***** 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 Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
|
||||
var comparisonView = {
|
||||
__proto__: baseView,
|
||||
setUpHandlers: function() {
|
||||
_t = this;
|
||||
//this.omv = function(event){_t.onMouseOver.apply(_t, [event]);};
|
||||
//this.omo = function(event){_t.onMouseOut.apply(_t, [event]);};
|
||||
//this.content.addEventListener("mouseover", this.omv, true);
|
||||
//this.content.addEventListener("mouseout", this.omv, true);
|
||||
},
|
||||
destroyHandlers: function() {
|
||||
//this.content.removeEventListener("mouseover", this.omv, true);
|
||||
//this.content.removeEventListener("mouseout", this.omv, true);
|
||||
},
|
||||
// Helper methods
|
||||
createFullTree: function ct(aDetails, aNode, aName) {
|
||||
if (!aDetails || ! (aDetails instanceof Object))
|
||||
return;
|
||||
var cat = new YAHOO.widget.TextNode(aName, aNode, true);
|
||||
for each (postfix in ["Files", ""]) {
|
||||
var subRes = aDetails[aName + postfix];
|
||||
var append = postfix ? ' (files)' : '';
|
||||
for (mod in subRes) {
|
||||
var mn = new YAHOO.widget.TextNode(mod + append, cat, true);
|
||||
for (fl in subRes[mod]) {
|
||||
if (postfix) {
|
||||
new YAHOO.widget.TextNode(subRes[mod][fl], mn, false);
|
||||
continue;
|
||||
}
|
||||
var fn = new YAHOO.widget.TextNode(fl, mn, false);
|
||||
var keys = [];
|
||||
for each (k in subRes[mod][fl]) {
|
||||
keys.push(k);
|
||||
}
|
||||
keys.sort();
|
||||
new YAHOO.widget.HTMLNode("<pre>" + keys.join("\n") + "</pre>", fn, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cat;
|
||||
}
|
||||
};
|
||||
var comparisonController = {
|
||||
__proto__: baseController,
|
||||
get path() {
|
||||
return 'results/' + this.tag + '/cmp-data.json';
|
||||
},
|
||||
beforeSelect: function() {
|
||||
this.result = {};
|
||||
this.isShown = false;
|
||||
comparisonView.setUpHandlers();
|
||||
var _t = this;
|
||||
var callback = function(obj) {
|
||||
delete _t.req;
|
||||
if (view != comparisonView) {
|
||||
// ignore, we have switched again
|
||||
return;
|
||||
}
|
||||
_t.result = obj;
|
||||
comparisonView.updateView(keys(_t.result));
|
||||
};
|
||||
this.req = JSON.get('results/' + this.tag + '/cmp-data.json', callback);
|
||||
},
|
||||
beforeUnSelect: function() {
|
||||
if (this.req) {
|
||||
this.req.abort();
|
||||
delete this.req;
|
||||
}
|
||||
comparisonView.destroyHandlers();
|
||||
},
|
||||
showView: function(aClosure) {
|
||||
// json onload handler does this;
|
||||
},
|
||||
getContent: function(aLoc) {
|
||||
var row = view.getCell();
|
||||
var inner = document.createElement('div');
|
||||
row.appendChild(inner);
|
||||
var r = this.result[aLoc];
|
||||
var id = "tree-" + aLoc;
|
||||
inner.id = id;
|
||||
var hasDetails = true;
|
||||
if (r.missing.total + r.missingFiles.total) {
|
||||
inner.className = "has_missing";
|
||||
}
|
||||
else if (r.obsolete.total + r.obsoleteFiles.total) {
|
||||
inner.className = "has_obsolete";
|
||||
}
|
||||
else {
|
||||
inner.className = "is_good";
|
||||
hasDetails = false;
|
||||
}
|
||||
t = new YAHOO.widget.TreeView(inner);
|
||||
var _l = aLoc;
|
||||
var rowCollector = {
|
||||
_c : '',
|
||||
pushCell: function(content, class) {
|
||||
this._c += '<td';
|
||||
if (content == 0)
|
||||
class += ' zero'
|
||||
if (class)
|
||||
this._c += ' class="' + class + '"';
|
||||
this._c += '>' + content + '</td>';
|
||||
},
|
||||
get content() {return '<table class="locale-row"><tr>' +
|
||||
this._c + '</tr></table>';}
|
||||
};
|
||||
for each (app in kModules) {
|
||||
var class;
|
||||
if (r.tested.indexOf(app) < 0) {
|
||||
class = 'void';
|
||||
}
|
||||
else if (r.missing[app] + r.missingFiles[app]) {
|
||||
class = 'missing';
|
||||
}
|
||||
else if (r.obsolete[app] + r.obsoleteFiles[app]) {
|
||||
class = 'obsolete';
|
||||
}
|
||||
else {
|
||||
class = "good";
|
||||
}
|
||||
rowCollector.pushCell(app, 'app-res ' + class);
|
||||
}
|
||||
|
||||
rowCollector.pushCell(r.missingFiles.total, "missing count");
|
||||
rowCollector.pushCell(r.missing.total, "missing count");
|
||||
rowCollector.pushCell(r.obsoleteFiles.total, "obsolete count");
|
||||
rowCollector.pushCell(r.obsolete.total, "obsolete count");
|
||||
rowCollector.pushCell(r.unchanged +r.changed, "good count");
|
||||
var tld = new YAHOO.widget.HTMLNode(rowCollector.content, t.getRoot(), false, hasDetails);
|
||||
if (hasDetails) {
|
||||
tld.__cl_locale = aLoc;
|
||||
tld.__do_load = true;
|
||||
tmp = new YAHOO.widget.HTMLNode("<span class='ygtvloading'> </span> loading…", tld, true, true);
|
||||
var l = aLoc;
|
||||
var _c = this;
|
||||
var expander = function(node) {
|
||||
if (!node.__do_load)
|
||||
return true;
|
||||
var callback = function(aRes) {
|
||||
comparisonView.createFullTree(aRes, node, 'missing');
|
||||
comparisonView.createFullTree(aRes, node, 'obsolete');
|
||||
delete node.__do_load;
|
||||
node.tree.removeNode(node.children[0]);
|
||||
node.refresh();
|
||||
};
|
||||
JSON.get('results/' + _c.tag + '/cmp-details-'+aLoc+'.json', callback);
|
||||
}
|
||||
t.onExpand = expander;
|
||||
delete expander;
|
||||
}
|
||||
t.draw();
|
||||
var rowToggle = function(){
|
||||
YAHOO.util.Event.addListener(tld.getContentEl(), "click",
|
||||
function(){tld.toggle();}, tld, true);
|
||||
};
|
||||
YAHOO.util.Event.onAvailable(tld.contentElId, rowToggle, tld);
|
||||
//YAHOO.util.Event.addListener(tld.getContentEl(), "click", rowToggle, tld, true);
|
||||
return row;
|
||||
}
|
||||
};
|
||||
controller.addPane('Compare', 'comparison', comparisonController,
|
||||
comparisonView);
|
||||
//controller.addLocales(keys(results.locales));
|
||||
@@ -1,94 +0,0 @@
|
||||
<!-- ***** 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 Mozilla.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Mozilla Foundation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2006
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Axel Hecht <axel@pike.org>
|
||||
-
|
||||
- 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 LGPL or the GPL. 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 ***** -->
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>1.8.1 Locales status</title>
|
||||
<style type="text/css" id="style-Tier-1">
|
||||
.Tier-1 {display: none}
|
||||
</style>
|
||||
<style type="text/css" id="style-Tier-2">
|
||||
.Tier-2 {display: none}
|
||||
</style>
|
||||
<style type="text/css" id="style-Tier-3">
|
||||
.Tier-3 {display: none}
|
||||
</style>
|
||||
<style type="text/css">
|
||||
div {min-height: 5px;}
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="yui/examples/treeview/css/local/tree.css">
|
||||
<link rel="stylesheet" type="text/css" href="yui/build/container/assets/container.css">
|
||||
<link rel="stylesheet" type="text/css" href="layout.css">
|
||||
<script type="text/javascript" src="yui/build/yahoo/yahoo.js"></script>
|
||||
<script type="text/javascript" src="yui/build/dom/dom.js"></script>
|
||||
<script type="text/javascript" src="yui/build/event/event.js"></script>
|
||||
<script type="text/javascript" src="yui/build/logger/logger.js"></script>
|
||||
<script type="text/javascript" src="yui/build/treeview/treeview.js"></script>
|
||||
<script type="text/javascript" src="yui/build/calendar/calendar.js"></script>
|
||||
<script type="text/javascript" src="yui/build/dragdrop/dragdrop.js"></script>
|
||||
<script type="text/javascript" src="yui/build/container/container.js"></script>
|
||||
<script type="text/javascript" src="code-base.js"></script>
|
||||
<script type="text/javascript" src="waterfall-code.js"></script>
|
||||
<script type="text/javascript" src="comparison-code.js"></script>
|
||||
<script type="text/javascript" src="search-code.js"></script>
|
||||
<script type="text/javascript" src="bookmarks-code.js"></script>
|
||||
<script type="text/javascript" src="rss-reader-code.js"></script>
|
||||
</head>
|
||||
<body onload="">
|
||||
<div id="sidebar">
|
||||
<p id="checks">Showing Tier 1
|
||||
<input type="checkbox" name="Tier-1" checked>
|
||||
2 <input type="checkbox" name="Tier-2" checked>
|
||||
3 <input type="checkbox" name="Tier-3" checked> for
|
||||
</p>
|
||||
<input type="text" id="tag-view" size="30">
|
||||
</div>
|
||||
<h1>Locale Tests</h1>
|
||||
<div id="menu">
|
||||
<ul id="tabs"></ul>
|
||||
</div>
|
||||
<table id="main" cellspacing="0" border="1px" cellpadding="2px">
|
||||
<thead>
|
||||
<tr id="head"></tr>
|
||||
</thead>
|
||||
<tbody id="content"></tbody>
|
||||
</table>
|
||||
<script type="text/javascript" src="post.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,133 +0,0 @@
|
||||
/* ***** 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 Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#sidebar {
|
||||
float: right;
|
||||
margin-top: -8px;
|
||||
}
|
||||
|
||||
#menu li[selected] {
|
||||
background-color: lightgrey;
|
||||
border-style: inset inset none inset;
|
||||
}
|
||||
#menu li {
|
||||
display: block;
|
||||
float: left;
|
||||
font-weight: bold;
|
||||
padding: .5em;
|
||||
margin-left:1px;
|
||||
margin-right:1px;
|
||||
border-style: outset outset none outset;
|
||||
-moz-border-radius-topleft: 15px;
|
||||
-moz-border-radius-topright: 15px;
|
||||
}
|
||||
|
||||
#main {
|
||||
clear: left;
|
||||
}
|
||||
body {
|
||||
overflow: scroll;
|
||||
}
|
||||
#content {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
div.is_good {
|
||||
padding-left: 16px;
|
||||
}
|
||||
|
||||
.missing, .busted {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.obsolete, .fair {
|
||||
background-color: orange;
|
||||
}
|
||||
|
||||
.zero {
|
||||
opacity: .3;
|
||||
background-color: green !important;
|
||||
}
|
||||
|
||||
|
||||
.good {
|
||||
background-color: limegreen;
|
||||
}
|
||||
|
||||
.void {
|
||||
color: grey;
|
||||
background-color: lightgrey;
|
||||
}
|
||||
|
||||
td.locale {
|
||||
width: 4em;
|
||||
}
|
||||
td.app-res {
|
||||
width: 4em;
|
||||
}
|
||||
|
||||
td.count {
|
||||
padding-left:3px;
|
||||
padding-right: 3px;
|
||||
width: 3.5em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
div.calbordered {
|
||||
float: none;
|
||||
}
|
||||
|
||||
/* waterfall view */
|
||||
#log-dlg {
|
||||
overflow: scroll;
|
||||
}
|
||||
.log-row {
|
||||
margin: 0pt;
|
||||
}
|
||||
.ERROR {
|
||||
background-color: coral;
|
||||
}
|
||||
|
||||
/* search view */
|
||||
|
||||
td.ordered {border: 2px solid black;}
|
||||
td.error {background-color: coral;}
|
||||
td.conflict {background-color: grey;}
|
||||
td.enUS {opacity: .5;}
|
||||
|
||||
/* feedreader view */
|
||||
.feedreader { border: thin solid lightgrey }
|
||||
@@ -1,40 +0,0 @@
|
||||
/* ***** 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 Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
view.init();
|
||||
controller.addLocales(keys(tierMap));
|
||||
controller.loaded();
|
||||
@@ -1,93 +0,0 @@
|
||||
/* ***** 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 Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
|
||||
var rssController = {
|
||||
__proto__: baseController,
|
||||
get path() {
|
||||
return 'results/' + this.tag + '/feed-reader-results.json';
|
||||
},
|
||||
beforeSelect: function() {
|
||||
this.hashes = {};
|
||||
rssView.setUpHandlers();
|
||||
var _t = this;
|
||||
var callback = function(obj) {
|
||||
delete _t.req;
|
||||
if (view != rssView) {
|
||||
// ignore, we have switched again
|
||||
return;
|
||||
}
|
||||
_t.result = obj;
|
||||
rssView.updateView(keys(_t.result));
|
||||
};
|
||||
this.req = JSON.get('results/' + this.tag + '/feed-reader-results.json',
|
||||
callback);
|
||||
},
|
||||
beforeUnSelect: function() {
|
||||
rssView.destroyHandlers();
|
||||
},
|
||||
showView: function(aClosure) {
|
||||
// json onload handler does this;
|
||||
},
|
||||
getContent: function(aLoc) {
|
||||
var row = document.createDocumentFragment();
|
||||
var lst = this.result[aLoc];
|
||||
var _t = this;
|
||||
for each (var pair in lst) {
|
||||
//YAHOO.widget.Logger.log('testing ' + path);
|
||||
var td = document.createElement('td');
|
||||
td.className = 'feedreader';
|
||||
td.innerHTML = pair[0];
|
||||
td.title = pair[1];
|
||||
row.appendChild(td);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
};
|
||||
var rssView = {
|
||||
__proto__: baseView,
|
||||
setUpHandlers: function() {
|
||||
_t = this;
|
||||
},
|
||||
destroyHandlers: function() {
|
||||
if (this._dv) {
|
||||
this._dv.hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
controller.addPane('RSS', 'rss', rssController, rssView);
|
||||
//controller.addLocales(keys(results.locales));
|
||||
@@ -1,241 +0,0 @@
|
||||
/* ***** 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 Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
|
||||
var searchController = {
|
||||
__proto__: baseController,
|
||||
get path() {
|
||||
return 'results/' + this.tag + '/search-results.json';
|
||||
},
|
||||
beforeSelect: function() {
|
||||
this.hashes = {};
|
||||
searchView.setUpHandlers();
|
||||
var _t = this;
|
||||
var callback = function(obj) {
|
||||
delete _t.req;
|
||||
if (view != searchView) {
|
||||
// ignore, we have switched again
|
||||
return;
|
||||
}
|
||||
_t.result = obj;
|
||||
searchView.updateView(keys(_t.result.locales));
|
||||
};
|
||||
this.req = JSON.get('results/' + this.tag + '/search-results.json',
|
||||
callback);
|
||||
},
|
||||
beforeUnSelect: function() {
|
||||
this.hashes = {};
|
||||
searchView.destroyHandlers();
|
||||
},
|
||||
showView: function(aClosure) {
|
||||
// json onload handler does this;
|
||||
},
|
||||
getContent: function(aLoc) {
|
||||
var row = document.createDocumentFragment();
|
||||
var lst = this.result.locales[aLoc].list;
|
||||
var _t = this;
|
||||
lst.sort(function(a,b){return _t.cmp.apply(_t,[a,b])});
|
||||
var orders = this.result.locales[aLoc].orders;
|
||||
if (orders) {
|
||||
var explicit = [];
|
||||
var implicit = [];
|
||||
for (var sn in orders) {
|
||||
if (explicit[sn]) {
|
||||
fatal = true;
|
||||
break;
|
||||
}
|
||||
explicit[sn] = orders[sn];
|
||||
}
|
||||
explicit = [];
|
||||
for each (var path in lst) {
|
||||
var shortName = this.result.details[path].ShortName;
|
||||
if (orders[shortName]) {
|
||||
explicit[orders[shortName] - 1] = path;
|
||||
}
|
||||
else {
|
||||
implicit.push(path);
|
||||
}
|
||||
}
|
||||
lst = explicit.concat(implicit);
|
||||
}
|
||||
row.innerHTML = '<td class="locale"><a href="https://bugzilla.mozilla.org/buglist.cgi?query_format=advanced&short_desc_type=regexp&short_desc=' + aLoc + '%5B%20-%5D&chfieldto=Now&field0-0-0=blocked&type0-0-0=substring&value0-0-0=347914">bug</a></td>';
|
||||
for each (var path in lst) {
|
||||
//YAHOO.widget.Logger.log('testing ' + path);
|
||||
var innerContent;
|
||||
var cl = '';
|
||||
if (path.match(/^mozilla/)) {
|
||||
cl += ' enUS';
|
||||
}
|
||||
var localName = path.substr(path.lastIndexOf('/') + 1);
|
||||
if (this.result.details[path].error) {
|
||||
innerContent = 'error in ' + localName;
|
||||
cl += ' error';
|
||||
}
|
||||
else {
|
||||
var shortName = this.result.details[path].ShortName;
|
||||
var img = this.result.details[path].Image;
|
||||
if (this.result.locales[aLoc].orders && this.result.locales[aLoc].orders[shortName]) {
|
||||
cl += " ordered";
|
||||
}
|
||||
innerContent = '<img src="' + img + '">' + shortName;
|
||||
}
|
||||
var td = document.createElement('td');
|
||||
td.className = 'searchplugin' + cl;
|
||||
td.innerHTML = innerContent;
|
||||
row.appendChild(td);
|
||||
td.details = this.result.details[path];
|
||||
// test the hash code
|
||||
if (td.details.error) {
|
||||
// ignore errorenous plugins
|
||||
continue;
|
||||
}
|
||||
if (this.hashes[localName]) {
|
||||
this.hashes[localName].nodes.push(td);
|
||||
if (this.hashes[localName].conflict) {
|
||||
td.className += ' conflict';
|
||||
}
|
||||
else if (this.hashes[localName].key != td.details.md5) {
|
||||
this.hashes[localName].conflict = true;
|
||||
for each (td in this.hashes[localName].nodes) {
|
||||
td.className += ' conflict';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.hashes[localName] = {key: td.details.md5, nodes: [td]};
|
||||
}
|
||||
}
|
||||
for (localName in this.hashes) {
|
||||
if ( ! ('conflict' in this.hashes[localName])) {
|
||||
continue;
|
||||
}
|
||||
locs = [];
|
||||
for each (var td in this.hashes[localName].nodes) {
|
||||
locs.push(td.parentNode.firstChild.textContent);
|
||||
}
|
||||
YAHOO.widget.Logger.log('difference in ' + localName + ' for ' + locs.join(', '));
|
||||
}
|
||||
return row;
|
||||
},
|
||||
cmp: function(l,r) {
|
||||
var lName = this.result.details[l].ShortName;
|
||||
var rName = this.result.details[r].ShortName;
|
||||
if (lName) lName = lName.toLowerCase();
|
||||
if (rName) rName = rName.toLowerCase();
|
||||
return lName < rName ? -1 : lName > rName ? 1 : 0;
|
||||
}
|
||||
};
|
||||
var searchView = {
|
||||
__proto__: baseView,
|
||||
setUpHandlers: function() {
|
||||
_t = this;
|
||||
this.omv = function(event){_t.onMouseOver.apply(_t, [event]);};
|
||||
this.omo = function(event){_t.onMouseOut.apply(_t, [event]);};
|
||||
this.content.addEventListener("mouseover", this.omv, true);
|
||||
this.content.addEventListener("mouseout", this.omv, true);
|
||||
},
|
||||
destroyHandlers: function() {
|
||||
this.content.removeEventListener("mouseover", this.omv, true);
|
||||
this.content.removeEventListener("mouseout", this.omv, true);
|
||||
if (this._dv) {
|
||||
this._dv.hide();
|
||||
}
|
||||
},
|
||||
onMouseOver: function(event) {
|
||||
if (!event.target.details)
|
||||
return;
|
||||
var _e = {
|
||||
details: event.target.details,
|
||||
clientX: event.clientX,
|
||||
clientY: event.clientY
|
||||
};
|
||||
this.pending = setTimeout(function(){searchView.showDetail(_e);}, 500);
|
||||
},
|
||||
onMouseOut: function(event) {
|
||||
if (this.pending) {
|
||||
clearTimeout(this.pending);
|
||||
delete this.pending;
|
||||
return;
|
||||
}
|
||||
if (!event.target.details)
|
||||
return;
|
||||
},
|
||||
showDetail: function(event) {
|
||||
delete this.pending;
|
||||
if (!this._dv) {
|
||||
this._dv = new YAHOO.widget.Panel('dv', {visible:true,draggable:true,constraintoviewport:true});
|
||||
this._dv.beforeHideEvent.subscribe(function(){delete this._dv;}, null);
|
||||
}
|
||||
var dt = event.details;
|
||||
if (dt.error) {
|
||||
this._dv.setHeader("Error");
|
||||
this._dv.setBody(dt.error);
|
||||
}
|
||||
else {
|
||||
this._dv.setHeader("Details");
|
||||
var c = '';
|
||||
var q = 'test';
|
||||
var len = 0;
|
||||
for each (var url in dt.urls) {
|
||||
var uc = url.template;
|
||||
var sep = (uc.indexOf('?') > -1) ? '&' : '?';
|
||||
for (var p in url.params) {
|
||||
uc += sep + p + '=' + url.params[p];
|
||||
sep = '&';
|
||||
}
|
||||
uc = uc.replace('{searchTerms}', q);
|
||||
var mpContent = '';
|
||||
if (url.MozParams) {
|
||||
for each (var mp in url.MozParams) {
|
||||
// add at least the yahoo prefs
|
||||
if (mp.condition == 'pref') {
|
||||
mpContent += ', using pref ' + mp.name + '=' + mp.pref;
|
||||
}
|
||||
}
|
||||
}
|
||||
c += '<button onclick="window.open(this.textContent)">' + uc + '</button>' +mpContent+ '<br>';
|
||||
len = len < c.length ? c.length : len;
|
||||
}
|
||||
this._dv.setBody(c);
|
||||
}
|
||||
this._dv.render(document.body);
|
||||
this._dv.moveTo(event.clientX + window.scrollX, event.clientY + window.scrollY);
|
||||
this._dv.show();
|
||||
}
|
||||
};
|
||||
controller.addPane('Search', 'search', searchController, searchView);
|
||||
//controller.addLocales(keys(results.locales));
|
||||
@@ -1,191 +0,0 @@
|
||||
/* ***** 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 Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
|
||||
var waterfallView = {
|
||||
__proto__: baseView,
|
||||
scale: 1/60,
|
||||
unstyle: function() {
|
||||
this.content.innerHTML = '';
|
||||
},
|
||||
updateView: function(aResult) {
|
||||
YAHOO.widget.Logger.log('waterfallView.updateView called');
|
||||
var head = document.getElementById('head');
|
||||
head.innerHTML = '<th></th>';
|
||||
this.content.innerHTML = '';
|
||||
for each (var loc in controller.locales) {
|
||||
var h = document.createElement('th');
|
||||
h.className = 'wf-locale-head ' + view.getClass(loc);
|
||||
h.textContent = loc;
|
||||
head.appendChild(h);
|
||||
}
|
||||
var heads = head.childNodes;
|
||||
var lastDate = -1;
|
||||
function pad(aNumber, length) {
|
||||
str = String(aNumber);
|
||||
while (str.length < length) {
|
||||
str = '0' + str;
|
||||
}
|
||||
return str;
|
||||
};
|
||||
for (var i = aResult.length - 1; i >= 0; i--) {
|
||||
var wf = document.createElement('tr');
|
||||
wf.className = 'waterfall-row';
|
||||
wf.setAttribute('style','vertical-align: top;');
|
||||
this.content.appendChild(wf);
|
||||
var b = aResult[i];
|
||||
var height = Math.floor((b[1][1] - b[1][0]) * this.scale);
|
||||
var style = "height: " + height + "px;";
|
||||
wf.setAttribute('style', style);
|
||||
var cell = view.getCell();
|
||||
cell.className = 'cell-label';
|
||||
var d = this.getUTCDate(b[0]);
|
||||
var label = pad(d.getUTCHours(), 2) + ':' +
|
||||
pad(d.getUTCMinutes(), 2);
|
||||
if (lastDate != d.getUTCDate()) {
|
||||
lastDate = d.getUTCDate();
|
||||
label = d.getUTCDate() +'/'+ (d.getUTCMonth()+1) + '<br>' + label;
|
||||
}
|
||||
cell.innerHTML = label +
|
||||
'<br><a href="javascript:controller.showLog(\'' + b[0] + '\');">L</a>';
|
||||
wf.appendChild(cell);
|
||||
var locs = keys(b[2]);
|
||||
var h = 1;
|
||||
for each (loc in locs) {
|
||||
if (h >= heads.length) {
|
||||
YAHOO.widget.Logger.log("dropping result for " + loc);
|
||||
continue;
|
||||
}
|
||||
while (heads[h].textContent < loc) {
|
||||
// we don't have a result for this column in this build
|
||||
cell = view.getCell();
|
||||
cell.className = view.getClass(heads[h].textContent)
|
||||
wf.appendChild(cell);
|
||||
h++;
|
||||
if (h >= heads.length) {
|
||||
YAHOO.widget.Logger.log("dropping result for " + loc);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (heads[h].textContent > loc) {
|
||||
YAHOO.widget.Logger.log("dropping result for " + loc);
|
||||
continue;
|
||||
}
|
||||
cell = view.getCell();
|
||||
cell.innerHTML = '<a href="javascript:controller.showLog(\'' +
|
||||
b[0] + '\',\'' + loc + '\');">L</a> <a href="javascript:controller.showDetails(\'' +
|
||||
b[0] + '\',\'' + loc + '\');">B</a>';
|
||||
if (b[2][loc] & 2) {
|
||||
cell.className = 'busted ';
|
||||
}
|
||||
else if (b[2][loc] & 1) {
|
||||
cell.className = 'fair ';
|
||||
}
|
||||
else {
|
||||
cell.className = 'good ';
|
||||
}
|
||||
cell.className += ' ' + view.getClass(loc);
|
||||
wf.appendChild(cell);
|
||||
h++;
|
||||
}
|
||||
if (i == 0) {
|
||||
continue;
|
||||
}
|
||||
// XXX don't make output sparse
|
||||
continue;
|
||||
wf = document.createElement('tr');
|
||||
wf.className = 'waterfall-row';
|
||||
wf.setAttribute('style','vertical-align: top;');
|
||||
this.content.appendChild(wf);
|
||||
var b = aResult[i];
|
||||
var height = Math.floor((b[1][0] - aResult[i-1][1][1]) * this.scale);
|
||||
var style = "height: " + height + "px;";
|
||||
wf.setAttribute('style', style);
|
||||
//var cell = view.getCell();
|
||||
}
|
||||
},
|
||||
setUpHandlers: function() {
|
||||
_t = this;
|
||||
},
|
||||
destroyHandlers: function() {
|
||||
},
|
||||
// Helper functions
|
||||
getUTCDate: function(aTag) {
|
||||
var D = new Date();
|
||||
var d = aTag.split(/[ -]/).map(function(aEl){return Number(aEl);});
|
||||
d[1] -= 1; // adjust month
|
||||
D.setTime(Date.UTC.apply(null,d));
|
||||
return D;
|
||||
}
|
||||
};
|
||||
var waterfallController = {
|
||||
__proto__: baseController,
|
||||
get path() {
|
||||
return 'results/waterfall.json';
|
||||
},
|
||||
beforeSelect: function() {
|
||||
this.result = {};
|
||||
this.isShown = false;
|
||||
waterfallView.setUpHandlers();
|
||||
var _t = this;
|
||||
var callback = function(obj) {
|
||||
delete _t.req;
|
||||
if (view != waterfallView) {
|
||||
// ignore, we have switched again
|
||||
return;
|
||||
}
|
||||
_t.result = obj;
|
||||
_t.tag = obj[obj.length - 1][0]; // set the subdir to latest build
|
||||
controller.addLocales(keys(obj[obj.length - 1][2]));
|
||||
waterfallView.updateView(_t.result);
|
||||
};
|
||||
this.req = JSON.get('results/waterfall.json', callback);
|
||||
},
|
||||
beforeUnSelect: function() {
|
||||
if (this.req) {
|
||||
this.req.abort();
|
||||
delete this.req;
|
||||
}
|
||||
waterfallView.unstyle();
|
||||
waterfallView.destroyHandlers();
|
||||
},
|
||||
showView: function(aClosure) {
|
||||
// json onload handler does this;
|
||||
}
|
||||
};
|
||||
controller.addPane('Tinder', 'waterfall', waterfallController,
|
||||
waterfallView);
|
||||
39
mozilla/xpinstall/Makefile.in
Normal file
39
mozilla/xpinstall/Makefile.in
Normal file
@@ -0,0 +1,39 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (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/NPL/
|
||||
#
|
||||
# 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 Mozilla Communicator client code,
|
||||
# released March 31, 1998.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
# Contributors:
|
||||
# Daniel Veditz <dveditz@netscape.com>
|
||||
# Douglas Turner <dougt@netscape.com>
|
||||
|
||||
|
||||
DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
BIN
mozilla/xpinstall/macbuild/xpinstall.mcp
Normal file
BIN
mozilla/xpinstall/macbuild/xpinstall.mcp
Normal file
Binary file not shown.
BIN
mozilla/xpinstall/macbuild/xpinstallIDL.mcp
Normal file
BIN
mozilla/xpinstall/macbuild/xpinstallIDL.mcp
Normal file
Binary file not shown.
30
mozilla/xpinstall/makefile.win
Normal file
30
mozilla/xpinstall/makefile.win
Normal file
@@ -0,0 +1,30 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (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/NPL/
|
||||
#
|
||||
# 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 Mozilla Communicator client code,
|
||||
# released March 31, 1998.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
# Contributors:
|
||||
# Daniel Veditz <dveditz@netscape.com>
|
||||
# Douglas Turner <dougt@netscape.com>
|
||||
|
||||
|
||||
DEPTH=..
|
||||
|
||||
DIRS= public res src
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
33
mozilla/xpinstall/notifier/SoftwareUpdate-Source-1.rdf
Normal file
33
mozilla/xpinstall/notifier/SoftwareUpdate-Source-1.rdf
Normal file
@@ -0,0 +1,33 @@
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:NC="http://home.netscape.com/NC-rdf#">
|
||||
|
||||
<RDF:Bag ID="NC:SoftwareUpdateRoot">
|
||||
<RDF:li>
|
||||
<RDF:Bag ID="NC:NewSoftwareToday" NC:title="New Software">
|
||||
|
||||
<RDF:li>
|
||||
<RDF:Description ID="AimUpdate344">
|
||||
<NC:type resource="http://home.netscape.com/NC-rdf#SoftwarePackage" />
|
||||
<NC:title>AOL AIM</NC:title>
|
||||
<NC:description>An Instant Message Client</NC:description>
|
||||
<NC:version>3.4.1.12</NC:version>
|
||||
<NC:registryKey>/AOL/AIM/</NC:registryKey>
|
||||
<NC:url>http://home.netscape.com/index.html</NC:url>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
|
||||
<RDF:li>
|
||||
<RDF:Description ID="PGPPlugin345">
|
||||
<NC:type resource="http://home.netscape.com/NC-rdf#SoftwarePackage" />
|
||||
<NC:title>PGP Plugin For Mozilla</NC:title>
|
||||
<NC:description>A high grade encryption plugin</NC:description>
|
||||
<NC:version>1.1.2.0</NC:version>
|
||||
<NC:registryKey>/PGP/ROCKS/</NC:registryKey>
|
||||
<NC:url>http://home.netscape.com/index.html</NC:url>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
|
||||
</RDF:Bag>
|
||||
</RDF:li>
|
||||
</RDF:Bag>
|
||||
</RDF:RDF>
|
||||
57
mozilla/xpinstall/notifier/SoftwareUpdate.css
Normal file
57
mozilla/xpinstall/notifier/SoftwareUpdate.css
Normal file
@@ -0,0 +1,57 @@
|
||||
window {
|
||||
display: block;
|
||||
}
|
||||
|
||||
tree {
|
||||
display: table;
|
||||
background-color: #FFFFFF;
|
||||
border: none;
|
||||
border-spacing: 0px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
treecol {
|
||||
display: table-column;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
treeitem {
|
||||
display: table-row;
|
||||
}
|
||||
|
||||
treehead {
|
||||
display: table-header-group;
|
||||
}
|
||||
|
||||
treebody {
|
||||
display: table-row-group;
|
||||
}
|
||||
|
||||
treecell {
|
||||
display: table-cell;
|
||||
font-family: Verdana, Sans-Serif;
|
||||
font-size: 8pt;
|
||||
}
|
||||
|
||||
treecell[selectedcell] {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
|
||||
treehead treeitem treecell {
|
||||
background-color: #c0c0c0;
|
||||
border: outset 1px;
|
||||
border-color: white #707070 #707070 white;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
treeitem[type="http://home.netscape.com/NC-rdf#SoftwarePackage"] > treecell > titledbutton {
|
||||
list-style-image: url("resource:/res/rdf/SoftwareUpdatePackage.gif");
|
||||
}
|
||||
|
||||
treeitem[type="http://home.netscape.com/NC-rdf#Folder"] > treecell > titledbutton {
|
||||
list-style-image: url("resource:/res/rdf/bookmark-folder-closed.gif");
|
||||
|
||||
treeitem[type="http://home.netscape.com/NC-rdf#Folder"][open="true"] > treecell > titledbutton {
|
||||
list-style-image: url("resource:/res/rdf/bookmark-folder-open.gif");
|
||||
}
|
||||
123
mozilla/xpinstall/notifier/SoftwareUpdate.js
Normal file
123
mozilla/xpinstall/notifier/SoftwareUpdate.js
Normal file
@@ -0,0 +1,123 @@
|
||||
// the rdf service
|
||||
var RDF = Components.classes['component://netscape/rdf/rdf-service'].getService();
|
||||
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
|
||||
function getAttr(registry,service,attr_name)
|
||||
{
|
||||
var attr = registry.GetTarget(service,
|
||||
RDF.GetResource('http://home.netscape.com/NC-rdf#' + attr_name),
|
||||
true);
|
||||
if (attr)
|
||||
attr = attr.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
|
||||
if (attr)
|
||||
attr = attr.Value;
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
||||
function Init()
|
||||
{
|
||||
// this is the main rdf file.
|
||||
|
||||
var mainRegistry = RDF.GetDataSource('resource://res/rdf/SoftwareUpdates.rdf');
|
||||
|
||||
var mainContainer = Components.classes['component://netscape/rdf/container'].createInstance();
|
||||
mainContainer = mainContainer.QueryInterface(Components.interfaces.nsIRDFContainer);
|
||||
|
||||
mainContainer.Init(mainRegistry, RDF.GetResource('NC:SoftwareUpdateDataSources'));
|
||||
|
||||
// Now enumerate all of the softwareupdate datasources.
|
||||
var mainEnumerator = mainContainer.GetElements();
|
||||
while (mainEnumerator.HasMoreElements())
|
||||
{
|
||||
var aDistributor = mainEnumerator.GetNext();
|
||||
aDistributor = aDistributor.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
||||
var distributorContainer = Components.classes['component://netscape/rdf/container'].createInstance();
|
||||
distributorContainer = distributorContainer.QueryInterface(Components.interfaces.nsIRDFContainer);
|
||||
|
||||
var distributorRegistry = RDF.GetDataSource(aDistributor.Value);
|
||||
var distributorResource = RDF.GetResource('NC:SoftwareUpdateRoot');
|
||||
|
||||
distributorContainer.Init(distributorRegistry, distributorResource);
|
||||
|
||||
// Now enumerate all of the distributorContainer's packages.
|
||||
|
||||
var distributorEnumerator = distributorContainer.GetElements();
|
||||
|
||||
while (distributorEnumerator.HasMoreElements())
|
||||
{
|
||||
var aPackage = distributorEnumerator.GetNext();
|
||||
aPackage = aPackage.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
||||
// remove any that we do not want.
|
||||
|
||||
if (getAttr(distributorRegistry, aPackage, 'title') == "AOL AIM")
|
||||
{
|
||||
//distributorContainer.RemoveElement(aPackage, true);
|
||||
}
|
||||
}
|
||||
var tree = document.getElementById('tree');
|
||||
|
||||
// Add it to the tree control's composite datasource.
|
||||
tree.database.AddDataSource(distributorRegistry);
|
||||
|
||||
}
|
||||
|
||||
// Install all of the stylesheets in the softwareupdate Registry into the
|
||||
// panel.
|
||||
|
||||
// TODO
|
||||
|
||||
// XXX hack to force the tree to rebuild
|
||||
var treebody = document.getElementById('NC:SoftwareUpdateRoot');
|
||||
treebody.setAttribute('id', 'NC:SoftwareUpdateRoot');
|
||||
}
|
||||
|
||||
|
||||
function OpenURL(event, node)
|
||||
{
|
||||
if (node.getAttribute('type') == "http://home.netscape.com/NC-rdf#SoftwarePackage")
|
||||
{
|
||||
url = node.getAttribute('url');
|
||||
|
||||
/*window.open(url,'bookmarks');*/
|
||||
|
||||
var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
|
||||
if (!toolkitCore)
|
||||
{
|
||||
toolkitCore = new ToolkitCore();
|
||||
if (toolkitCore)
|
||||
{
|
||||
toolkitCore.Init("ToolkitCore");
|
||||
}
|
||||
}
|
||||
|
||||
if (toolkitCore)
|
||||
{
|
||||
toolkitCore.ShowWindow(url,window);
|
||||
}
|
||||
|
||||
dump("OpenURL(" + url + ")\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// To get around "window.onload" not working in viewer.
|
||||
function Boot()
|
||||
{
|
||||
var tree = document.getElementById('tree');
|
||||
if (tree == null) {
|
||||
setTimeout(Boot, 0);
|
||||
}
|
||||
else {
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout('Boot()', 0);
|
||||
|
||||
30
mozilla/xpinstall/notifier/SoftwareUpdate.xul
Normal file
30
mozilla/xpinstall/notifier/SoftwareUpdate.xul
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="resource:/res/rdf/sidebar.css" type="text/css"?>
|
||||
<?xml-stylesheet href="resource:/res/rdf/SoftwareUpdate.css" type="text/css"?>
|
||||
<window
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<html:script src="SoftwareUpdate.js"/>
|
||||
|
||||
<tree id="tree"
|
||||
flex="100%"
|
||||
datasources="rdf:softwareupdates"
|
||||
ondblclick="return OpenURL(event, event.target.parentNode);">
|
||||
|
||||
<treecol rdf:resource="http://home.netscape.com/NC-rdf#title" />
|
||||
<treecol rdf:resource="http://home.netscape.com/NC-rdf#description" />
|
||||
<treecol rdf:resource="http://home.netscape.com/NC-rdf#version" />
|
||||
|
||||
<treehead>
|
||||
<treeitem>
|
||||
<treecell>Title</treecell>
|
||||
<treecell>Description</treecell>
|
||||
<treecell>Version</treecell>
|
||||
</treeitem>
|
||||
</treehead>
|
||||
|
||||
<treebody id="NC:SoftwareUpdateRoot" rdf:containment="http://home.netscape.com/NC-rdf#child" />
|
||||
</tree>
|
||||
</window>
|
||||
BIN
mozilla/xpinstall/notifier/SoftwareUpdatePackage.gif
Normal file
BIN
mozilla/xpinstall/notifier/SoftwareUpdatePackage.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 201 B |
7
mozilla/xpinstall/notifier/SoftwareUpdates.rdf
Normal file
7
mozilla/xpinstall/notifier/SoftwareUpdates.rdf
Normal file
@@ -0,0 +1,7 @@
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:NC="http://home.netscape.com/softwareupdate-schema#">
|
||||
|
||||
<RDF:Bag ID="NC:SoftwareUpdateDataSources">
|
||||
<RDF:li resource="resource:/res/rdf/SoftwareUpdate-Source-1.rdf" />
|
||||
</RDF:Bag>
|
||||
</RDF:RDF>
|
||||
6
mozilla/xpinstall/public/MANIFEST
Normal file
6
mozilla/xpinstall/public/MANIFEST
Normal file
@@ -0,0 +1,6 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
nsISoftwareUpdate.h
|
||||
nsSoftwareUpdateIIDs.h
|
||||
47
mozilla/xpinstall/public/Makefile.in
Normal file
47
mozilla/xpinstall/public/Makefile.in
Normal file
@@ -0,0 +1,47 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (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/NPL/
|
||||
#
|
||||
# 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 Mozilla Communicator client code,
|
||||
# released March 31, 1998.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
# Contributors:
|
||||
# Daniel Veditz <dveditz@netscape.com>
|
||||
# Douglas Turner <dougt@netscape.com>
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = xpinstall
|
||||
|
||||
XPIDLSRCS = nsIXPInstallProgress.idl
|
||||
|
||||
EXPORTS = \
|
||||
nsIDOMInstallTriggerGlobal.h \
|
||||
nsIDOMInstallVersion.h \
|
||||
nsSoftwareUpdateIIDs.h \
|
||||
nsISoftwareUpdate.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
113
mozilla/xpinstall/public/idl/Install.idl
Normal file
113
mozilla/xpinstall/public/idl/Install.idl
Normal file
@@ -0,0 +1,113 @@
|
||||
interface Install
|
||||
{
|
||||
/* IID: { 0x18c2f988, 0xb09f, 0x11d2, \
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}} */
|
||||
|
||||
const int BAD_PACKAGE_NAME = -200;
|
||||
const int UNEXPECTED_ERROR = -201;
|
||||
const int ACCESS_DENIED = -202;
|
||||
const int TOO_MANY_CERTIFICATES = -203; /* Installer file must have 1 certificate */
|
||||
const int NO_INSTALLER_CERTIFICATE = -204; /* Installer file must have a certificate */
|
||||
const int NO_CERTIFICATE = -205; /* Extracted file is not signed */
|
||||
const int NO_MATCHING_CERTIFICATE = -206; /* Extracted file does not match installer certificate */
|
||||
const int UNKNOWN_JAR_FILE = -207; /* JAR file has not been opened */
|
||||
const int INVALID_ARGUMENTS = -208; /* Bad arguments to a function */
|
||||
const int ILLEGAL_RELATIVE_PATH = -209; /* Illegal relative path */
|
||||
const int USER_CANCELLED = -210; /* User cancelled */
|
||||
const int INSTALL_NOT_STARTED = -211;
|
||||
const int SILENT_MODE_DENIED = -212;
|
||||
const int NO_SUCH_COMPONENT = -213; /* no such component in the registry. */
|
||||
const int FILE_DOES_NOT_EXIST = -214; /* File cannot be deleted as it does not exist */
|
||||
const int FILE_READ_ONLY = -215; /* File cannot be deleted as it is read only. */
|
||||
const int FILE_IS_DIRECTORY = -216; /* File cannot be deleted as it is a directory */
|
||||
const int NETWORK_FILE_IS_IN_USE = -217; /* File on the network is in-use */
|
||||
const int APPLE_SINGLE_ERR = -218; /* error in AppleSingle unpacking */
|
||||
const int INVALID_PATH_ERR = -219; /* GetFolder() did not like the folderID */
|
||||
const int PATCH_BAD_DIFF = -220; /* error in GDIFF patch */
|
||||
const int PATCH_BAD_CHECKSUM_TARGET = -221; /* source file doesn't checksum */
|
||||
const int PATCH_BAD_CHECKSUM_RESULT = -222; /* final patched file fails checksum */
|
||||
const int UNINSTALL_FAILED = -223; /* error while uninstalling a package */
|
||||
const int GESTALT_UNKNOWN_ERR = -5550;
|
||||
const int GESTALT_INVALID_ARGUMENT = -5551;
|
||||
|
||||
const int SUCCESS = 0;
|
||||
const int REBOOT_NEEDED = 999;
|
||||
|
||||
/* install types */
|
||||
const int LIMITED_INSTALL = 0;
|
||||
const int FULL_INSTALL = 1;
|
||||
const int NO_STATUS_DLG = 2;
|
||||
const int NO_FINALIZE_DLG = 4;
|
||||
|
||||
// these should not be public...
|
||||
/* message IDs*/
|
||||
const int SU_INSTALL_FILE_UNEXPECTED_MSG_ID = 0;
|
||||
const int SU_DETAILS_REPLACE_FILE_MSG_ID = 1;
|
||||
const int SU_DETAILS_INSTALL_FILE_MSG_ID = 2;
|
||||
//////////////////////////
|
||||
|
||||
readonly attribute wstring UserPackageName;
|
||||
readonly attribute wstring RegPackageName;
|
||||
|
||||
void Install();
|
||||
|
||||
void AbortInstall();
|
||||
|
||||
long AddDirectory( in wstring regName,
|
||||
in wstring version,
|
||||
in wstring jarSource,
|
||||
in InstallFolder folder,
|
||||
in wstring subdir,
|
||||
in boolean forceMode );
|
||||
|
||||
|
||||
long AddSubcomponent( in wstring regName,
|
||||
in wstring version,
|
||||
in wstring jarSource,
|
||||
in InstallFolder folder,
|
||||
in wstring targetName,
|
||||
in boolean forceMode );
|
||||
|
||||
long DeleteComponent( in wstring registryName);
|
||||
|
||||
long DeleteFile( in InstallFolder folder,
|
||||
in wstring relativeFileName );
|
||||
|
||||
long DiskSpaceAvailable( in InstallFolder folder );
|
||||
|
||||
long Execute(in wstring jarSource, in wstring args);
|
||||
|
||||
long FinalizeInstall();
|
||||
|
||||
long Gestalt (in wstring selector);
|
||||
|
||||
InstallFolder GetComponentFolder( in wstring regName,
|
||||
in wstring subdirectory);
|
||||
|
||||
InstallFolder GetFolder(in wstring targetFolder,
|
||||
in wstring subdirectory);
|
||||
|
||||
long GetLastError();
|
||||
|
||||
long GetWinProfile(in InstallFolder folder, in wstring file);
|
||||
|
||||
long GetWinRegistry();
|
||||
|
||||
long Patch( in wstring regName,
|
||||
in wstring version,
|
||||
in wstring jarSource,
|
||||
in InstallFolder folder,
|
||||
in wstring targetName );
|
||||
|
||||
void ResetError();
|
||||
|
||||
void SetPackageFolder( in InstallFolder folder );
|
||||
|
||||
long StartInstall( in wstring userPackageName,
|
||||
in wstring packageName,
|
||||
in wstring version,
|
||||
in long flags );
|
||||
|
||||
long Uninstall( in wstring packageName);
|
||||
|
||||
};
|
||||
24
mozilla/xpinstall/public/idl/InstallTrigger.idl
Normal file
24
mozilla/xpinstall/public/idl/InstallTrigger.idl
Normal file
@@ -0,0 +1,24 @@
|
||||
interface InstallTriggerGlobal
|
||||
{
|
||||
/* IID: { 0x18c2f987, 0xb09f, 0x11d2, \
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}} */
|
||||
|
||||
const int MAJOR_DIFF = 4;
|
||||
const int MINOR_DIFF = 3;
|
||||
const int REL_DIFF = 2;
|
||||
const int BLD_DIFF = 1;
|
||||
const int EQUAL = 0;
|
||||
|
||||
boolean UpdateEnabled ();
|
||||
|
||||
long StartSoftwareUpdate(in wstring URL);
|
||||
|
||||
long ConditionalSoftwareUpdate( in wstring URL,
|
||||
in wstring regName,
|
||||
in long diffLevel,
|
||||
in wstring version,
|
||||
in long mode);
|
||||
|
||||
long CompareVersion( in wstring regName, in wstring version );
|
||||
|
||||
};
|
||||
34
mozilla/xpinstall/public/idl/InstallVersion.idl
Normal file
34
mozilla/xpinstall/public/idl/InstallVersion.idl
Normal file
@@ -0,0 +1,34 @@
|
||||
interface InstallVersion
|
||||
{
|
||||
/* IID: { 0x18c2f986, 0xb09f, 0x11d2, \
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}} */
|
||||
|
||||
const int EQUAL = 0;
|
||||
const int BLD_DIFF = 1;
|
||||
const int BLD_DIFF_MINUS = -1;
|
||||
const int REL_DIFF = 2;
|
||||
const int REL_DIFF_MINUS = -2;
|
||||
const int MINOR_DIFF = 3;
|
||||
const int MINOR_DIFF_MINUS = -3;
|
||||
const int MAJOR_DIFF = 4;
|
||||
const int MAJOR_DIFF_MINUS = -4;
|
||||
|
||||
attribute int major;
|
||||
attribute int minor;
|
||||
attribute int release;
|
||||
attribute int build;
|
||||
|
||||
void InstallVersion();
|
||||
|
||||
void init(in wstring versionString);
|
||||
/*
|
||||
void init(in int major, in int minor, in int release, in int build);
|
||||
*/
|
||||
wstring toString();
|
||||
|
||||
/* int compareTo(in wstring version);
|
||||
int compareTo(in int major, in int minor, in int release, in int build);
|
||||
*/
|
||||
int compareTo(in InstallVersion versionObject);
|
||||
|
||||
};
|
||||
36
mozilla/xpinstall/public/makefile.win
Normal file
36
mozilla/xpinstall/public/makefile.win
Normal file
@@ -0,0 +1,36 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (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/NPL/
|
||||
#
|
||||
# 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 Mozilla Communicator client code,
|
||||
# released March 31, 1998.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
# Contributors:
|
||||
# Daniel Veditz <dveditz@netscape.com>
|
||||
# Douglas Turner <dougt@netscape.com>
|
||||
|
||||
MODULE=xpinstall
|
||||
DEPTH=..\..
|
||||
|
||||
EXPORTS= nsIDOMInstallTriggerGlobal.h \
|
||||
nsIDOMInstallVersion.h \
|
||||
nsSoftwareUpdateIIDs.h \
|
||||
nsISoftwareUpdate.h
|
||||
|
||||
XPIDLSRCS = .\nsIXPInstallProgress.idl
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
1
mozilla/xpinstall/public/nsIDOMInstall.h
Normal file
1
mozilla/xpinstall/public/nsIDOMInstall.h
Normal file
@@ -0,0 +1 @@
|
||||
#error
|
||||
96
mozilla/xpinstall/public/nsIDOMInstallTriggerGlobal.h
Normal file
96
mozilla/xpinstall/public/nsIDOMInstallTriggerGlobal.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMInstallTriggerGlobal_h__
|
||||
#define nsIDOMInstallTriggerGlobal_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
|
||||
#define NS_IDOMINSTALLTRIGGERGLOBAL_IID \
|
||||
{ 0x18c2f987, 0xb09f, 0x11d2, \
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}}
|
||||
|
||||
class nsIDOMInstallTriggerGlobal : public nsISupports {
|
||||
public:
|
||||
static const nsIID& IID() { static nsIID iid = NS_IDOMINSTALLTRIGGERGLOBAL_IID; return iid; }
|
||||
enum {
|
||||
MAJOR_DIFF = 4,
|
||||
MINOR_DIFF = 3,
|
||||
REL_DIFF = 2,
|
||||
BLD_DIFF = 1,
|
||||
EQUAL = 0
|
||||
};
|
||||
|
||||
NS_IMETHOD UpdateEnabled(PRBool* aReturn)=0;
|
||||
|
||||
NS_IMETHOD StartSoftwareUpdate(const nsString& aURL, PRInt32* aReturn)=0;
|
||||
NS_IMETHOD StartSoftwareUpdate(const nsString& aURL, PRInt32 aFlags, PRInt32* aReturn)=0;
|
||||
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn)=0;
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, nsIDOMInstallVersion* aVersion, PRInt32 aMode, PRInt32* aReturn)=0;
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32 aMode, PRInt32* aReturn)=0;
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn)=0;
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, const nsString& aVersion, PRInt32* aReturn)=0;
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn)=0;
|
||||
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn)=0;
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, const nsString& aVersion, PRInt32* aReturn)=0;
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMINSTALLTRIGGERGLOBAL \
|
||||
NS_IMETHOD UpdateEnabled(PRBool* aReturn); \
|
||||
NS_IMETHOD StartSoftwareUpdate(const nsString& aURL, PRInt32 aFlags, PRInt32* aReturn); \
|
||||
NS_IMETHOD StartSoftwareUpdate(const nsString& aURL, PRInt32* aReturn); \
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn); \
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, nsIDOMInstallVersion* aVersion, PRInt32 aMode, PRInt32* aReturn); \
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32 aMode, PRInt32* aReturn); \
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn); \
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, const nsString& aVersion, PRInt32* aReturn); \
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn); \
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn); \
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, const nsString& aVersion, PRInt32* aReturn); \
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMINSTALLTRIGGERGLOBAL(_to) \
|
||||
NS_IMETHOD UpdateEnabled(PRBool* aReturn) { return _to##UpdateEnabled(aReturn); } \
|
||||
NS_IMETHOD StartSoftwareUpdate(const nsString& aURL, PRInt32 aFlags, PRInt32* aReturn) { return _to##StartSoftwareUpdate(aURL, aFlags, aReturn); } \
|
||||
NS_IMETHOD StartSoftwareUpdate(const nsString& aURL, PRInt32* aReturn) { return _to##StartSoftwareUpdate(aURL, aReturn); } \
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn) { return _to##ConditionalSoftwareUpdate(aURL, aRegName, aDiffLevel, aVersion, aMode, aReturn); } \
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, nsIDOMInstallVersion* aVersion, PRInt32 aMode, PRInt32* aReturn) { return _to##ConditionalSoftwareUpdate(aURL, aRegName, aDiffLevel, aVersion, aMode, aReturn); } \
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, nsIDOMInstallVersion* aRegName, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn) { return _to##ConditionalSoftwareUpdate(aURL, aDiffLevel, aVersion, aMode, aReturn); } \
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn) { return _to##ConditionalSoftwareUpdate(aURL, aDiffLevel, aVersion, aMode, aReturn); } \
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, const nsString& aVersion, PRInt32* aReturn) { return _to##ConditionalSoftwareUpdate(aURL, aDiffLevel, aVersion, aReturn); } \
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn) { return _to##ConditionalSoftwareUpdate(aURL, aDiffLevel, aVersion, aReturn); } \
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn) { return _to##CompareVersion(aRegName, aMajor, aMinor, aRelease, aBuild, aReturn); } \
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, const nsString& aVersion, PRInt32* aReturn) { return _to##CompareVersion(aRegName, aVersion, aReturn); } \
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn) { return _to##CompareVersion(aRegName, aVersion, aReturn); } \
|
||||
|
||||
|
||||
extern nsresult NS_InitInstallTriggerGlobalClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptInstallTriggerGlobal(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMInstallTriggerGlobal_h__
|
||||
107
mozilla/xpinstall/public/nsIDOMInstallVersion.h
Normal file
107
mozilla/xpinstall/public/nsIDOMInstallVersion.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMInstallVersion_h__
|
||||
#define nsIDOMInstallVersion_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIDOMInstallVersion;
|
||||
|
||||
#define NS_IDOMINSTALLVERSION_IID \
|
||||
{ 0x18c2f986, 0xb09f, 0x11d2, \
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}}
|
||||
|
||||
class nsIDOMInstallVersion : public nsISupports {
|
||||
public:
|
||||
static const nsIID& IID() { static nsIID iid = NS_IDOMINSTALLVERSION_IID; return iid; }
|
||||
enum {
|
||||
EQUAL = 0,
|
||||
BLD_DIFF = 1,
|
||||
BLD_DIFF_MINUS = -1,
|
||||
REL_DIFF = 2,
|
||||
REL_DIFF_MINUS = -2,
|
||||
MINOR_DIFF = 3,
|
||||
MINOR_DIFF_MINUS = -3,
|
||||
MAJOR_DIFF = 4,
|
||||
MAJOR_DIFF_MINUS = -4
|
||||
};
|
||||
|
||||
NS_IMETHOD GetMajor(PRInt32* aMajor)=0;
|
||||
NS_IMETHOD SetMajor(PRInt32 aMajor)=0;
|
||||
|
||||
NS_IMETHOD GetMinor(PRInt32* aMinor)=0;
|
||||
NS_IMETHOD SetMinor(PRInt32 aMinor)=0;
|
||||
|
||||
NS_IMETHOD GetRelease(PRInt32* aRelease)=0;
|
||||
NS_IMETHOD SetRelease(PRInt32 aRelease)=0;
|
||||
|
||||
NS_IMETHOD GetBuild(PRInt32* aBuild)=0;
|
||||
NS_IMETHOD SetBuild(PRInt32 aBuild)=0;
|
||||
|
||||
NS_IMETHOD Init(const nsString& aVersionString)=0;
|
||||
|
||||
NS_IMETHOD ToString(nsString& aReturn)=0;
|
||||
|
||||
NS_IMETHOD CompareTo(nsIDOMInstallVersion* aVersionObject, PRInt32* aReturn)=0;
|
||||
NS_IMETHOD CompareTo(const nsString& aString, PRInt32* aReturn)=0;
|
||||
NS_IMETHOD CompareTo(PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMINSTALLVERSION \
|
||||
NS_IMETHOD GetMajor(PRInt32* aMajor); \
|
||||
NS_IMETHOD SetMajor(PRInt32 aMajor); \
|
||||
NS_IMETHOD GetMinor(PRInt32* aMinor); \
|
||||
NS_IMETHOD SetMinor(PRInt32 aMinor); \
|
||||
NS_IMETHOD GetRelease(PRInt32* aRelease); \
|
||||
NS_IMETHOD SetRelease(PRInt32 aRelease); \
|
||||
NS_IMETHOD GetBuild(PRInt32* aBuild); \
|
||||
NS_IMETHOD SetBuild(PRInt32 aBuild); \
|
||||
NS_IMETHOD Init(const nsString& aVersionString); \
|
||||
NS_IMETHOD ToString(nsString& aReturn); \
|
||||
NS_IMETHOD CompareTo(nsIDOMInstallVersion* aVersionObject, PRInt32* aReturn); \
|
||||
NS_IMETHOD CompareTo(const nsString& aString, PRInt32* aReturn); \
|
||||
NS_IMETHOD CompareTo(PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMINSTALLVERSION(_to) \
|
||||
NS_IMETHOD GetMajor(PRInt32* aMajor) { return _to##GetMajor(aMajor); } \
|
||||
NS_IMETHOD SetMajor(PRInt32 aMajor) { return _to##SetMajor(aMajor); } \
|
||||
NS_IMETHOD GetMinor(PRInt32* aMinor) { return _to##GetMinor(aMinor); } \
|
||||
NS_IMETHOD SetMinor(PRInt32 aMinor) { return _to##SetMinor(aMinor); } \
|
||||
NS_IMETHOD GetRelease(PRInt32* aRelease) { return _to##GetRelease(aRelease); } \
|
||||
NS_IMETHOD SetRelease(PRInt32 aRelease) { return _to##SetRelease(aRelease); } \
|
||||
NS_IMETHOD GetBuild(PRInt32* aBuild) { return _to##GetBuild(aBuild); } \
|
||||
NS_IMETHOD SetBuild(PRInt32 aBuild) { return _to##SetBuild(aBuild); } \
|
||||
NS_IMETHOD Init(const nsString& aVersionString) { return _to##Init(aVersionString); } \
|
||||
NS_IMETHOD ToString(nsString& aReturn) { return _to##ToString(aReturn); } \
|
||||
NS_IMETHOD CompareTo(nsIDOMInstallVersion* aVersionObject, PRInt32* aReturn) { return _to##CompareTo(aVersionObject, aReturn); } \
|
||||
NS_IMETHOD CompareTo(const nsString& aString, PRInt32* aReturn) { return _to##CompareTo(aString, aReturn); } \
|
||||
NS_IMETHOD CompareTo(PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn) { return _to##CompareTo(aMajor, aMinor, aRelease, aBuild, aReturn); } \
|
||||
|
||||
|
||||
extern nsresult NS_InitInstallVersionClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptInstallVersion(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMInstallVersion_h__
|
||||
85
mozilla/xpinstall/public/nsISoftwareUpdate.h
Normal file
85
mozilla/xpinstall/public/nsISoftwareUpdate.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef nsISoftwareUpdate_h__
|
||||
#define nsISoftwareUpdate_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsIXPInstallProgress.h"
|
||||
|
||||
#define NS_IXPINSTALLCOMPONENT_PROGID NS_IAPPSHELLCOMPONENT_PROGID "/xpinstall"
|
||||
#define NS_IXPINSTALLCOMPONENT_CLASSNAME "Mozilla XPInstall Component"
|
||||
|
||||
|
||||
#define NS_ISOFTWAREUPDATE_IID \
|
||||
{ 0x18c2f992, \
|
||||
0xb09f, \
|
||||
0x11d2, \
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}\
|
||||
}
|
||||
|
||||
|
||||
class nsISoftwareUpdate : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISOFTWAREUPDATE_IID)
|
||||
|
||||
NS_IMETHOD InstallJar(const nsString& fromURL,
|
||||
const nsString& localFile,
|
||||
long flags) = 0;
|
||||
|
||||
NS_IMETHOD RegisterNotifier(nsIXPInstallProgress *notifier) = 0;
|
||||
|
||||
NS_IMETHOD InstallPending(void) = 0;
|
||||
|
||||
/* FIX: these should be in a private interface */
|
||||
NS_IMETHOD InstallJarCallBack() = 0;
|
||||
NS_IMETHOD GetTopLevelNotifier(nsIXPInstallProgress **notifier) = 0;
|
||||
};
|
||||
|
||||
|
||||
class nsSoftwareUpdateFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
|
||||
nsSoftwareUpdateFactory();
|
||||
virtual ~nsSoftwareUpdateFactory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // nsISoftwareUpdate_h__
|
||||
|
||||
30
mozilla/xpinstall/public/nsIXPInstallProgress.idl
Normal file
30
mozilla/xpinstall/public/nsIXPInstallProgress.idl
Normal file
@@ -0,0 +1,30 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[uuid(eea90d40-b059-11d2-915e-c12b696c9333)]
|
||||
interface nsIXPInstallProgress : nsISupports
|
||||
{
|
||||
void BeforeJavascriptEvaluation();
|
||||
void AfterJavascriptEvaluation();
|
||||
void InstallStarted([const] in string UIPackageName);
|
||||
void ItemScheduled([const] in string message );
|
||||
void InstallFinalization([const] in string message, in long itemNum, in long totNum );
|
||||
void InstallAborted();
|
||||
};
|
||||
93
mozilla/xpinstall/public/nsIXPInstallProgressNotifier.h
Normal file
93
mozilla/xpinstall/public/nsIXPInstallProgressNotifier.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef nsIXPInstallProgressNotifier_h__
|
||||
#define nsIXPInstallProgressNotifier_h__
|
||||
|
||||
|
||||
class nsIXPInstallProgressNotifier
|
||||
{
|
||||
public:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Function name : BeforeJavascriptEvaluation
|
||||
// Description : This will be called when prior to the install script being evaluate
|
||||
// Return type : void
|
||||
// Argument : void
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void BeforeJavascriptEvaluation(void) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Function name : AfterJavascriptEvaluation
|
||||
// Description : This will be called after the install script has being evaluated
|
||||
// Return type : void
|
||||
// Argument : void
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void AfterJavascriptEvaluation(void) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Function name : InstallStarted
|
||||
// Description : This will be called when StartInstall has been called
|
||||
// Return type : void
|
||||
// Argument : char* UIPackageName - User Package Name
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void InstallStarted(const char* UIPackageName) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Function name : ItemScheduled
|
||||
// Description : This will be called when items are being scheduled
|
||||
// Return type : Any value returned other than zero, will be treated as an error and the script will be aborted
|
||||
// Argument : The message that should be displayed to the user
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual long ItemScheduled( const char* message ) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Function name : InstallFinalization
|
||||
// Description : This will be called when the installation is in its Finalize stage
|
||||
// Return type : void
|
||||
// Argument : char* message - The message that should be displayed to the user
|
||||
// Argument : long itemNum - This is the current item number
|
||||
// Argument : long totNum - This is the total number of items
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void InstallFinalization( const char* message, long itemNum, long totNum ) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Function name : InstallAborted
|
||||
// Description : This will be called when the install is aborted
|
||||
// Return type : void
|
||||
// Argument : void
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void InstallAborted(void) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
64
mozilla/xpinstall/public/nsSoftwareUpdateIIDs.h
Normal file
64
mozilla/xpinstall/public/nsSoftwareUpdateIIDs.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef nsSoftwareUpdateIIDs_h___
|
||||
#define nsSoftwareUpdateIIDs_h___
|
||||
|
||||
#define NS_SoftwareUpdate_CID \
|
||||
{ /* 18c2f989-b09f-11d2-bcde-00805f0e1353 */ \
|
||||
0x18c2f989, \
|
||||
0xb09f, \
|
||||
0x11d2, \
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
|
||||
}
|
||||
|
||||
#define NS_SoftwareUpdateInstall_CID \
|
||||
{ /* 18c2f98b-b09f-11d2-bcde-00805f0e1353 */ \
|
||||
0x18c2f98b, \
|
||||
0xb09f, \
|
||||
0x11d2, \
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
|
||||
}
|
||||
|
||||
#define NS_SoftwareUpdateInstallTrigger_CID \
|
||||
{ /* 18c2f98d-b09f-11d2-bcde-00805f0e1353 */ \
|
||||
0x18c2f98d, \
|
||||
0xb09f, \
|
||||
0x11d2, \
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
|
||||
}
|
||||
|
||||
#define NS_SoftwareUpdateInstallVersion_CID \
|
||||
{ /* 18c2f98f-b09f-11d2-bcde-00805f0e1353 */ \
|
||||
0x18c2f98f, \
|
||||
0xb09f, \
|
||||
0x11d2, \
|
||||
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* nsSoftwareUpdateIIDs_h___ */
|
||||
|
||||
3
mozilla/xpinstall/res/MANIFEST
Normal file
3
mozilla/xpinstall/res/MANIFEST
Normal file
@@ -0,0 +1,3 @@
|
||||
progress.xul
|
||||
progress.css
|
||||
progress.html
|
||||
34
mozilla/xpinstall/res/Makefile.in
Normal file
34
mozilla/xpinstall/res/Makefile.in
Normal file
@@ -0,0 +1,34 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/config.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
EXPORT_RESOURCE_XPINSTALL = \
|
||||
$(srcdir)/progress.xul \
|
||||
$(srcdir)/progress.html \
|
||||
$(srcdir)/progress.css \
|
||||
$(NULL)
|
||||
|
||||
install::
|
||||
$(INSTALL) $(EXPORT_RESOURCE_XPINSTALL) $(DIST)/bin/res/xpinstall
|
||||
31
mozilla/xpinstall/res/makefile.win
Normal file
31
mozilla/xpinstall/res/makefile.win
Normal file
@@ -0,0 +1,31 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) progress.xul $(DIST)\bin\res\xpinstall
|
||||
$(MAKE_INSTALL) progress.css $(DIST)\bin\res\xpinstall
|
||||
$(MAKE_INSTALL) progress.html $(DIST)\bin\res\xpinstall
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\res\xpinstall\progress.xul
|
||||
rm -f $(DIST)\res\xpinstall\progress.css
|
||||
rm -f $(DIST)\res\xpinstall\progress.html
|
||||
3
mozilla/xpinstall/res/progress.css
Normal file
3
mozilla/xpinstall/res/progress.css
Normal file
@@ -0,0 +1,3 @@
|
||||
TD {
|
||||
font: 10pt sans-serif;
|
||||
}
|
||||
16
mozilla/xpinstall/res/progress.html
Normal file
16
mozilla/xpinstall/res/progress.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<body bgcolor="#C0C0C0" style="overflow:visible; margin: 0px; color-background: rgb(192,192,192);">
|
||||
<center>
|
||||
<table BORDER COLS=5 WIDTH="99%" style="color-background:rgb(192,192,192);">
|
||||
<tr>
|
||||
<td WIDTH="3%" NOWRAP style="border: 1px inset rgb(192,192,192);"> </td>
|
||||
<td WIDTH="3%" NOWRAP style="border: 1px inset rgb(192,192,192);"> </td>
|
||||
<td WIDTH="3%" NOWRAP style="border: 1px inset rgb(192,192,192);"> </td>
|
||||
<td WIDTH="10%" NOWRAP style="border: 1px inset rgb(192,192,192);"> </td>
|
||||
<td WIDTH="81%" NOWRAP style="border: 1px inset rgb(192,192,192);"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
67
mozilla/xpinstall/res/progress.xul
Normal file
67
mozilla/xpinstall/res/progress.xul
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="../samples/xul.css" type="text/css"?>
|
||||
<?xml-stylesheet href="progress.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE window
|
||||
[
|
||||
<!ENTITY downloadWindow.title "XPInstall Progress">
|
||||
<!ENTITY status "Status:">
|
||||
<!ENTITY cancelButtonTitle "Cancel">
|
||||
]
|
||||
>
|
||||
|
||||
<window xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="XPInstall Progress"
|
||||
width="425"
|
||||
height="225">
|
||||
|
||||
<data>
|
||||
<broadcaster id="data.canceled" type="string" value="false"/>
|
||||
</data>
|
||||
|
||||
|
||||
<html:script>
|
||||
|
||||
function cancelInstall()
|
||||
{
|
||||
var cancelData = document.getElementById("data.canceled");
|
||||
cancelData.setAttribute( "value", "true");
|
||||
}
|
||||
|
||||
</html:script>
|
||||
|
||||
<html:center>
|
||||
<html:table style="width:100%;">
|
||||
|
||||
<html:tr>
|
||||
<html:td align="center">
|
||||
<html:input id="dialog.uiPackageName" readonly="" style="background-color:lightgray;width:300px;"/>
|
||||
</html:td>
|
||||
</html:tr>
|
||||
|
||||
<html:tr>
|
||||
<html:td nowrap="" style="border: 1px rgb(192,192,192);" align="center">
|
||||
<html:input id="dialog.currentAction" readonly="" style="background-color:lightgray;width:450px;"/>
|
||||
</html:td>
|
||||
</html:tr>
|
||||
|
||||
|
||||
<html:tr>
|
||||
<html:td align="center" width="15%" nowrap="" style="border: 1px rgb(192,192,192);">
|
||||
<progressmeter id="dialog.progress" mode="undetermined" style="width:300px;height:16px;">
|
||||
</progressmeter>
|
||||
</html:td>
|
||||
</html:tr>
|
||||
|
||||
<html:tr>
|
||||
<html:td align="center" width="3%" nowrap="" style="border: 1px rgb(192,192,192);">
|
||||
<html:button onclick="cancelInstall()" height="12">
|
||||
&cancelButtonTitle;
|
||||
</html:button>
|
||||
</html:td>
|
||||
</html:tr>
|
||||
</html:table>
|
||||
|
||||
</html:center>
|
||||
</window>
|
||||
61
mozilla/xpinstall/src/Makefile.in
Normal file
61
mozilla/xpinstall/src/Makefile.in
Normal file
@@ -0,0 +1,61 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (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/NPL/
|
||||
#
|
||||
# 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 Mozilla Communicator client code,
|
||||
# released March 31, 1998.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
# Contributors:
|
||||
# Daniel Veditz <dveditz@netscape.com>
|
||||
# Douglas Turner <dougt@netscape.com>
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = xpinstall
|
||||
LIBRARY_NAME = xpinstall
|
||||
IS_COMPONENT = 1
|
||||
REQUIRES = dom js netlib raptor xpcom
|
||||
|
||||
CPPSRCS = \
|
||||
nsSoftwareUpdate.cpp \
|
||||
nsInstall.cpp \
|
||||
nsInstallDelete.cpp \
|
||||
nsInstallExecute.cpp \
|
||||
nsInstallFile.cpp \
|
||||
nsInstallFolder.cpp \
|
||||
nsInstallPatch.cpp \
|
||||
nsInstallUninstall.cpp \
|
||||
nsInstallTrigger.cpp \
|
||||
nsInstallResources.cpp \
|
||||
nsJSInstall.cpp \
|
||||
nsJSInstallTriggerGlobal.cpp\
|
||||
nsSoftwareUpdateRun.cpp \
|
||||
nsSoftwareUpdateStream.cpp \
|
||||
nsTopProgressNotifier.cpp \
|
||||
nsLoggingProgressNotifier \
|
||||
ScheduledTasks.cpp \
|
||||
nsInstallFileOpItem.cpp \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES += -I$(srcdir)/../public
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
1854
mozilla/xpinstall/src/PatchableAppleSingle.cpp
Normal file
1854
mozilla/xpinstall/src/PatchableAppleSingle.cpp
Normal file
File diff suppressed because it is too large
Load Diff
233
mozilla/xpinstall/src/PatchableAppleSingle.h
Normal file
233
mozilla/xpinstall/src/PatchableAppleSingle.h
Normal file
@@ -0,0 +1,233 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
|
||||
/*
|
||||
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
|
||||
* Version 1.0 (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/NPL/
|
||||
|
||||
*
|
||||
|
||||
* 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 Mozilla Communicator client code,
|
||||
|
||||
* released March 31, 1998.
|
||||
|
||||
*
|
||||
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
|
||||
* Corporation. Portions created by Netscape are
|
||||
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
|
||||
* Reserved.
|
||||
|
||||
*
|
||||
|
||||
* Contributors:
|
||||
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef SU_PAS_H
|
||||
|
||||
#define SU_PAS_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <Errors.h>
|
||||
|
||||
#include <Types.h>
|
||||
|
||||
#include <Files.h>
|
||||
|
||||
#include <Script.h>
|
||||
|
||||
#include <Resources.h>
|
||||
|
||||
|
||||
|
||||
typedef struct PASHeader /* header portion of Patchable AppleSingle */
|
||||
|
||||
{
|
||||
|
||||
UInt32 magicNum; /* internal file type tag = 0x00244200*/
|
||||
|
||||
UInt32 versionNum; /* format version: 1 = 0x00010000 */
|
||||
|
||||
UInt8 filler[16]; /* filler */
|
||||
|
||||
UInt16 numEntries; /* number of entries which follow */
|
||||
|
||||
} PASHeader ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct PASEntry /* one Patchable AppleSingle entry descriptor */
|
||||
|
||||
{
|
||||
|
||||
UInt32 entryID; /* entry type: see list, 0 invalid */
|
||||
|
||||
UInt32 entryOffset; /* offset, in bytes, from beginning */
|
||||
|
||||
/* of file to this entry's data */
|
||||
|
||||
UInt32 entryLength; /* length of data in octets */
|
||||
|
||||
|
||||
|
||||
} PASEntry;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct PASMiscInfo
|
||||
|
||||
{
|
||||
|
||||
short fileHasResFork;
|
||||
|
||||
short fileResAttrs;
|
||||
|
||||
OSType fileType;
|
||||
|
||||
OSType fileCreator;
|
||||
|
||||
UInt32 fileFlags;
|
||||
|
||||
|
||||
|
||||
} PASMiscInfo;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct PASResFork
|
||||
|
||||
{
|
||||
|
||||
short NumberOfTypes;
|
||||
|
||||
|
||||
|
||||
} PASResFork;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct PASResource
|
||||
|
||||
{
|
||||
|
||||
short attr;
|
||||
|
||||
short attrID;
|
||||
|
||||
OSType attrType;
|
||||
|
||||
Str255 attrName;
|
||||
|
||||
unsigned long length;
|
||||
|
||||
|
||||
|
||||
} PASResource;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if PRAGMA_ALIGN_SUPPORTED
|
||||
|
||||
#pragma options align=reset
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define kCreator 'MOSS'
|
||||
|
||||
#define kType 'PASf'
|
||||
|
||||
#define PAS_BUFFER_SIZE (1024*512)
|
||||
|
||||
|
||||
|
||||
#define PAS_MAGIC_NUM (0x00244200)
|
||||
|
||||
#define PAS_VERSION (0x00010000)
|
||||
|
||||
|
||||
|
||||
enum
|
||||
|
||||
{
|
||||
|
||||
ePas_Data = 1,
|
||||
|
||||
ePas_Misc,
|
||||
|
||||
ePas_Resource
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
extern "C" {
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Prototypes */
|
||||
|
||||
OSErr PAS_EncodeFile(FSSpec *inSpec, FSSpec *outSpec);
|
||||
|
||||
OSErr PAS_DecodeFile(FSSpec *inSpec, FSSpec *outSpec);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* SU_PAS_H */
|
||||
380
mozilla/xpinstall/src/ScheduledTasks.cpp
Normal file
380
mozilla/xpinstall/src/ScheduledTasks.cpp
Normal file
@@ -0,0 +1,380 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "NSReg.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsInstall.h" // for error codes
|
||||
#include "prmem.h"
|
||||
#include "ScheduledTasks.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <sys/stat.h>
|
||||
#include <windows.h>
|
||||
|
||||
BOOL WIN32_IsMoveFileExBroken()
|
||||
{
|
||||
/* the NT option MOVEFILE_DELAY_UNTIL_REBOOT is broken on
|
||||
* Windows NT 3.51 Service Pack 4 and NT 4.0 before Service Pack 2
|
||||
*/
|
||||
BOOL broken = FALSE;
|
||||
OSVERSIONINFO osinfo;
|
||||
|
||||
// they *all* appear broken--better to have one way that works.
|
||||
return TRUE;
|
||||
|
||||
osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if (GetVersionEx(&osinfo) && osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||
{
|
||||
if ( osinfo.dwMajorVersion == 3 && osinfo.dwMinorVersion == 51 )
|
||||
{
|
||||
if ( 0 == stricmp(osinfo.szCSDVersion,"Service Pack 4"))
|
||||
{
|
||||
broken = TRUE;
|
||||
}
|
||||
}
|
||||
else if ( osinfo.dwMajorVersion == 4 )
|
||||
{
|
||||
if (osinfo.szCSDVersion[0] == '\0' ||
|
||||
(0 == stricmp(osinfo.szCSDVersion,"Service Pack 1")))
|
||||
{
|
||||
broken = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return broken;
|
||||
}
|
||||
|
||||
|
||||
PRInt32 DoWindowsReplaceExistingFileStuff(const char* currentName, const char* finalName)
|
||||
{
|
||||
PRInt32 err = 0;
|
||||
|
||||
char* final = strdup(finalName);
|
||||
char* current = strdup(currentName);
|
||||
|
||||
/* couldn't delete, probably in use. Schedule for later */
|
||||
DWORD dwVersion, dwWindowsMajorVersion;
|
||||
|
||||
/* Get OS version info */
|
||||
dwVersion = GetVersion();
|
||||
dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
||||
|
||||
/* Get build numbers for Windows NT or Win32s */
|
||||
|
||||
if (dwVersion < 0x80000000) // Windows NT
|
||||
{
|
||||
/* On Windows NT */
|
||||
if ( WIN32_IsMoveFileExBroken() )
|
||||
{
|
||||
/* the MOVEFILE_DELAY_UNTIL_REBOOT option doesn't work on
|
||||
* NT 3.51 SP4 or on NT 4.0 until SP2
|
||||
*/
|
||||
struct stat statbuf;
|
||||
PRBool nameFound = PR_FALSE;
|
||||
char tmpname[_MAX_PATH];
|
||||
|
||||
strncpy( tmpname, finalName, _MAX_PATH );
|
||||
int len = strlen(tmpname);
|
||||
while (!nameFound && len < _MAX_PATH )
|
||||
{
|
||||
tmpname[len-1] = '~';
|
||||
tmpname[len] = '\0';
|
||||
if ( stat(tmpname, &statbuf) != 0 )
|
||||
nameFound = TRUE;
|
||||
else
|
||||
len++;
|
||||
}
|
||||
|
||||
if ( nameFound )
|
||||
{
|
||||
if ( MoveFile( finalName, tmpname ) )
|
||||
{
|
||||
if ( MoveFile( currentName, finalName ) )
|
||||
{
|
||||
DeleteFileNowOrSchedule(nsFileSpec(tmpname));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 2nd move failed, put old file back */
|
||||
MoveFile( tmpname, finalName );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* non-executable in use; schedule for later */
|
||||
return -1; // let the start registry stuff do our work!
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( MoveFileEx(currentName, finalName, MOVEFILE_DELAY_UNTIL_REBOOT) )
|
||||
{
|
||||
err = 0;
|
||||
}
|
||||
}
|
||||
else // Windows 95 or Win16
|
||||
{
|
||||
/*
|
||||
* Place an entry in the WININIT.INI file in the Windows directory
|
||||
* to delete finalName and rename currentName to be finalName at reboot
|
||||
*/
|
||||
|
||||
int strlen;
|
||||
char Src[_MAX_PATH]; // 8.3 name
|
||||
char Dest[_MAX_PATH]; // 8.3 name
|
||||
|
||||
strlen = GetShortPathName( (LPCTSTR)currentName, (LPTSTR)Src, (DWORD)sizeof(Src) );
|
||||
if ( strlen > 0 )
|
||||
{
|
||||
free(current);
|
||||
current = strdup(Src);
|
||||
}
|
||||
|
||||
strlen = GetShortPathName( (LPCTSTR) finalName, (LPTSTR) Dest, (DWORD) sizeof(Dest));
|
||||
if ( strlen > 0 )
|
||||
{
|
||||
free(final);
|
||||
final = strdup(Dest);
|
||||
}
|
||||
|
||||
/* NOTE: use OEM filenames! Even though it looks like a Windows
|
||||
* .INI file, WININIT.INI is processed under DOS
|
||||
*/
|
||||
|
||||
AnsiToOem( final, final );
|
||||
AnsiToOem( current, current );
|
||||
|
||||
if ( WritePrivateProfileString( "Rename", final, current, "WININIT.INI" ) )
|
||||
err = 0;
|
||||
}
|
||||
|
||||
free(final);
|
||||
free(current);
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
REGERR DeleteFileNowOrSchedule(nsFileSpec& filename)
|
||||
{
|
||||
|
||||
REGERR result = 0;
|
||||
|
||||
filename.Delete(false);
|
||||
|
||||
if (filename.Exists())
|
||||
{
|
||||
RKEY newkey;
|
||||
HREG reg;
|
||||
if ( REGERR_OK == NR_RegOpen("", ®) )
|
||||
{
|
||||
if (REGERR_OK == NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY, &newkey) )
|
||||
{
|
||||
// FIX should be using nsPersistentFileDescriptor!!!
|
||||
|
||||
result = NR_RegSetEntry( reg, newkey, (char*)(const char*)filename.GetNativePathCString(), REGTYPE_ENTRY_FILE, nsnull, 0);
|
||||
if (result == REGERR_OK)
|
||||
result = nsInstall::REBOOT_NEEDED;
|
||||
}
|
||||
|
||||
NR_RegClose(reg);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/* tmp file is the bad one that we want to replace with target. */
|
||||
|
||||
REGERR ReplaceFileNowOrSchedule(nsFileSpec& replacementFile, nsFileSpec& doomedFile )
|
||||
{
|
||||
REGERR result = 0;
|
||||
|
||||
if(replacementFile == doomedFile)
|
||||
{
|
||||
/* do not have to do anything */
|
||||
return result;
|
||||
}
|
||||
|
||||
doomedFile.Delete(false);
|
||||
|
||||
if (! doomedFile.Exists() )
|
||||
{
|
||||
// Now that we have move the existing file, we can move the mExtracedFile into place.
|
||||
nsFileSpec parentofFinalFile;
|
||||
|
||||
doomedFile.GetParent(parentofFinalFile);
|
||||
result = replacementFile.Move(parentofFinalFile);
|
||||
if ( NS_SUCCEEDED(result) )
|
||||
{
|
||||
char* leafName = doomedFile.GetLeafName();
|
||||
replacementFile.Rename(leafName);
|
||||
nsCRT::free(leafName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
if (DoWindowsReplaceExistingFileStuff(replacementFile.GetNativePathCString(), doomedFile.GetNativePathCString()) == 0)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
RKEY newkey;
|
||||
HREG reg;
|
||||
|
||||
if ( REGERR_OK == NR_RegOpen("", ®) )
|
||||
{
|
||||
result = NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY, &newkey);
|
||||
if ( result == REGERR_OK )
|
||||
{
|
||||
char* replacementFileName = (char*)(const char*)replacementFile.GetNativePathCString();
|
||||
result = NR_RegSetEntry( reg, newkey, (char*)(const char*)doomedFile.GetNativePathCString(), REGTYPE_ENTRY_FILE, replacementFileName, strlen(replacementFileName));
|
||||
if (result == REGERR_OK)
|
||||
result = nsInstall::REBOOT_NEEDED;
|
||||
}
|
||||
|
||||
NR_RegClose(reg);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void DeleteScheduledFiles(void);
|
||||
void ReplaceScheduledFiles(void);
|
||||
|
||||
extern "C" void PerformScheduledTasks(void *data)
|
||||
{
|
||||
DeleteScheduledFiles();
|
||||
ReplaceScheduledFiles();
|
||||
}
|
||||
|
||||
|
||||
void DeleteScheduledFiles(void)
|
||||
{
|
||||
HREG reg;
|
||||
|
||||
if (REGERR_OK == NR_RegOpen("", ®))
|
||||
{
|
||||
RKEY key;
|
||||
REGENUM state;
|
||||
|
||||
/* perform scheduled file deletions and replacements (PC only) */
|
||||
if (REGERR_OK == NR_RegGetKey(reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY,&key))
|
||||
{
|
||||
char buf[MAXREGNAMELEN];
|
||||
|
||||
while (REGERR_OK == NR_RegEnumEntries(reg, key, &state, buf, sizeof(buf), NULL ))
|
||||
{
|
||||
nsFileSpec doomedFile(buf);
|
||||
|
||||
doomedFile.Delete(PR_FALSE);
|
||||
|
||||
if (! doomedFile.Exists())
|
||||
{
|
||||
NR_RegDeleteEntry( reg, key, buf );
|
||||
}
|
||||
}
|
||||
|
||||
/* delete list node if empty */
|
||||
if (REGERR_NOMORE == NR_RegEnumEntries( reg, key, &state, buf, sizeof(buf), NULL ))
|
||||
{
|
||||
NR_RegDeleteKey(reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
NR_RegClose(reg);
|
||||
}
|
||||
}
|
||||
|
||||
void ReplaceScheduledFiles(void)
|
||||
{
|
||||
HREG reg;
|
||||
|
||||
if (REGERR_OK == NR_RegOpen("", ®))
|
||||
{
|
||||
RKEY key;
|
||||
REGENUM state;
|
||||
|
||||
/* replace files if any listed */
|
||||
if (REGERR_OK == NR_RegGetKey(reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY, &key))
|
||||
{
|
||||
char tmpfile[MAXREGNAMELEN];
|
||||
char target[MAXREGNAMELEN];
|
||||
|
||||
state = 0;
|
||||
while (REGERR_OK == NR_RegEnumEntries(reg, key, &state, tmpfile, sizeof(tmpfile), NULL ))
|
||||
{
|
||||
|
||||
nsFileSpec replaceFile(tmpfile);
|
||||
|
||||
if (! replaceFile.Exists() )
|
||||
{
|
||||
NR_RegDeleteEntry( reg, key, tmpfile );
|
||||
}
|
||||
else if ( REGERR_OK != NR_RegGetEntryString( reg, key, tmpfile, target, sizeof(target) ) )
|
||||
{
|
||||
/* can't read target filename, corruption? */
|
||||
NR_RegDeleteEntry( reg, key, tmpfile );
|
||||
}
|
||||
else
|
||||
{
|
||||
nsFileSpec targetFile(target);
|
||||
|
||||
targetFile.Delete(PR_FALSE);
|
||||
|
||||
if (!targetFile.Exists())
|
||||
{
|
||||
nsFileSpec parentofTarget;
|
||||
targetFile.GetParent(parentofTarget);
|
||||
|
||||
nsresult result = replaceFile.Move(parentofTarget);
|
||||
if ( NS_SUCCEEDED(result) )
|
||||
{
|
||||
char* leafName = targetFile.GetLeafName();
|
||||
replaceFile.Rename(leafName);
|
||||
nsCRT::free(leafName);
|
||||
|
||||
NR_RegDeleteEntry( reg, key, tmpfile );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* delete list node if empty */
|
||||
if (REGERR_NOMORE == NR_RegEnumEntries(reg, key, &state, tmpfile, sizeof(tmpfile), NULL ))
|
||||
{
|
||||
NR_RegDeleteKey(reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
NR_RegClose(reg);
|
||||
}
|
||||
}
|
||||
42
mozilla/xpinstall/src/ScheduledTasks.h
Normal file
42
mozilla/xpinstall/src/ScheduledTasks.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __SCHEDULEDTASKS_H__
|
||||
#define __SCHEDULEDTASKS_H__
|
||||
|
||||
|
||||
#include "NSReg.h"
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
|
||||
REGERR DeleteFileNowOrSchedule(nsFileSpec& filename);
|
||||
REGERR ReplaceFileNowOrSchedule(nsFileSpec& tmpfile, nsFileSpec& target );
|
||||
|
||||
|
||||
extern "C" void PerformScheduledTasks(void *data);
|
||||
|
||||
|
||||
#endif
|
||||
135
mozilla/xpinstall/src/gdiff.h
Normal file
135
mozilla/xpinstall/src/gdiff.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*--------------------------------------------------------------
|
||||
* GDIFF.H
|
||||
*
|
||||
* Constants used in processing the GDIFF format
|
||||
*--------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "prio.h"
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
#define GDIFF_MAGIC "\xD1\xFF\xD1\xFF"
|
||||
#define GDIFF_MAGIC_LEN 4
|
||||
#define GDIFF_VER 5
|
||||
#define GDIFF_EOF "\0"
|
||||
|
||||
#define GDIFF_VER_POS 4
|
||||
#define GDIFF_CS_POS 5
|
||||
#define GDIFF_CSLEN_POS 6
|
||||
|
||||
#define GDIFF_HEADERSIZE 7
|
||||
#define GDIFF_APPDATALEN 4
|
||||
|
||||
#define GDIFF_CS_NONE 0
|
||||
#define GDIFF_CS_MD5 1
|
||||
#define GDIFF_CS_SHA 2
|
||||
#define GDIFF_CS_CRC32 32
|
||||
|
||||
#define CRC32_LEN 4
|
||||
|
||||
/*--------------------------------------
|
||||
* GDIFF opcodes
|
||||
*------------------------------------*/
|
||||
#define ENDDIFF 0
|
||||
#define ADD8MAX 246
|
||||
#define ADD16 247
|
||||
#define ADD32 248
|
||||
#define COPY16BYTE 249
|
||||
#define COPY16SHORT 250
|
||||
#define COPY16LONG 251
|
||||
#define COPY32BYTE 252
|
||||
#define COPY32SHORT 253
|
||||
#define COPY32LONG 254
|
||||
#define COPY64 255
|
||||
|
||||
/* instruction sizes */
|
||||
#define ADD16SIZE 2
|
||||
#define ADD32SIZE 4
|
||||
#define COPY16BYTESIZE 3
|
||||
#define COPY16SHORTSIZE 4
|
||||
#define COPY16LONGSIZE 6
|
||||
#define COPY32BYTESIZE 5
|
||||
#define COPY32SHORTSIZE 6
|
||||
#define COPY32LONGSIZE 8
|
||||
#define COPY64SIZE 12
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* error codes
|
||||
*------------------------------------*/
|
||||
#define GDIFF_OK 0
|
||||
#define GDIFF_ERR_UNKNOWN -1
|
||||
#define GDIFF_ERR_ARGS -2
|
||||
#define GDIFF_ERR_ACCESS -3
|
||||
#define GDIFF_ERR_MEM -4
|
||||
#define GDIFF_ERR_HEADER -5
|
||||
#define GDIFF_ERR_BADDIFF -6
|
||||
#define GDIFF_ERR_OPCODE -7
|
||||
#define GDIFF_ERR_OLDFILE -8
|
||||
#define GDIFF_ERR_CHKSUMTYPE -9
|
||||
#define GDIFF_ERR_CHECKSUM -10
|
||||
#define GDIFF_ERR_CHECKSUM_TARGET -11
|
||||
#define GDIFF_ERR_CHECKSUM_RESULT -12
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* types
|
||||
*------------------------------------*/
|
||||
#ifndef AIX
|
||||
#ifdef OSF1
|
||||
#include <sys/types.h>
|
||||
#else
|
||||
typedef unsigned char uchar;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct _diffdata {
|
||||
PRFileDesc* fSrc;
|
||||
PRFileDesc* fOut;
|
||||
PRFileDesc* fDiff;
|
||||
uint8 checksumType;
|
||||
uint8 checksumLength;
|
||||
uchar* oldChecksum;
|
||||
uchar* newChecksum;
|
||||
PRBool bMacAppleSingle;
|
||||
PRBool bWin32BoundImage;
|
||||
uchar* databuf;
|
||||
uint32 bufsize;
|
||||
} DIFFDATA;
|
||||
|
||||
typedef DIFFDATA* pDIFFDATA;
|
||||
|
||||
|
||||
/*--------------------------------------
|
||||
* miscellaneous
|
||||
*------------------------------------*/
|
||||
|
||||
#define APPFLAG_W32BOUND "autoinstall:Win32PE"
|
||||
#define APPFLAG_APPLESINGLE "autoinstall:AppleSingle"
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
|
||||
111
mozilla/xpinstall/src/makefile.win
Normal file
111
mozilla/xpinstall/src/makefile.win
Normal file
@@ -0,0 +1,111 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (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/NPL/
|
||||
#
|
||||
# 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 Mozilla Communicator client code,
|
||||
# released March 31, 1998.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
# Contributors:
|
||||
# Daniel Veditz <dveditz@netscape.com>
|
||||
# Douglas Turner <dougt@netscape.com>
|
||||
|
||||
|
||||
DEPTH=..\..
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
MODULE=xpinstall
|
||||
|
||||
DLL=.\$(OBJDIR)\$(MODULE).dll
|
||||
|
||||
DEFINES=-D_IMPL_NS_DOM -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
LINCS= \
|
||||
-I$(PUBLIC)\xpinstall \
|
||||
-I$(PUBLIC)\jar \
|
||||
-I$(PUBLIC)\libreg \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\pref \
|
||||
-I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\js \
|
||||
-I$(PUBLIC)\dom \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\nspr2 \
|
||||
-I$(PUBLIC)\zlib \
|
||||
-I$(PUBLIC)\xpfe\components \
|
||||
$(NULL)
|
||||
|
||||
LLIBS = \
|
||||
$(DIST)\lib\jar50.lib \
|
||||
$(DIST)\lib\libreg32.lib \
|
||||
$(DIST)\lib\netlib.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\js3250.lib \
|
||||
$(DIST)\lib\jsdombase_s.lib \
|
||||
$(DIST)\lib\jsdomevents_s.lib \
|
||||
$(DIST)\lib\zlib.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(LIBNSPR) \
|
||||
$(NULL)
|
||||
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\nsInstall.obj \
|
||||
.\$(OBJDIR)\nsInstallTrigger.obj \
|
||||
.\$(OBJDIR)\nsInstallVersion.obj \
|
||||
.\$(OBJDIR)\nsInstallFolder.obj \
|
||||
.\$(OBJDIR)\nsJSInstall.obj \
|
||||
.\$(OBJDIR)\nsJSInstallTriggerGlobal.obj \
|
||||
.\$(OBJDIR)\nsJSInstallVersion.obj \
|
||||
.\$(OBJDIR)\nsSoftwareUpdate.obj \
|
||||
.\$(OBJDIR)\nsSoftwareUpdateRun.obj \
|
||||
.\$(OBJDIR)\nsSoftwareUpdateStream.obj \
|
||||
.\$(OBJDIR)\nsInstallFile.obj \
|
||||
.\$(OBJDIR)\nsInstallDelete.obj \
|
||||
.\$(OBJDIR)\nsInstallExecute.obj \
|
||||
.\$(OBJDIR)\nsInstallPatch.obj \
|
||||
.\$(OBJDIR)\nsInstallUninstall.obj \
|
||||
.\$(OBJDIR)\nsInstallResources.obj \
|
||||
.\$(OBJDIR)\nsTopProgressNotifier.obj \
|
||||
.\$(OBJDIR)\nsLoggingProgressNotifier.obj\
|
||||
.\$(OBJDIR)\ScheduledTasks.obj \
|
||||
.\$(OBJDIR)\nsWinReg.obj \
|
||||
.\$(OBJDIR)\nsJSWinReg.obj \
|
||||
.\$(OBJDIR)\nsWinRegItem.obj \
|
||||
.\$(OBJDIR)\nsWinRegValue.obj \
|
||||
.\$(OBJDIR)\nsWinProfile.obj \
|
||||
.\$(OBJDIR)\nsJSWinProfile.obj \
|
||||
.\$(OBJDIR)\nsWinProfileItem.obj \
|
||||
.\$(OBJDIR)\nsInstallProgressDialog.obj \
|
||||
.\$(OBJDIR)\nsInstallFileOpItem.obj \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(MODULE).lib $(DIST)\lib
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(MODULE).dll $(DIST)\bin\components
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(MODULE).lib
|
||||
rm -f $(DIST)\bin\components\$(MODULE).dll
|
||||
|
||||
1692
mozilla/xpinstall/src/nsInstall.cpp
Normal file
1692
mozilla/xpinstall/src/nsInstall.cpp
Normal file
File diff suppressed because it is too large
Load Diff
265
mozilla/xpinstall/src/nsInstall.h
Normal file
265
mozilla/xpinstall/src/nsInstall.h
Normal file
@@ -0,0 +1,265 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __NS_INSTALL_H__
|
||||
#define __NS_INSTALL_H__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
#include "plevent.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsVector.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
#include "nsSoftwareUpdate.h"
|
||||
|
||||
#include "nsInstallObject.h"
|
||||
#include "nsInstallVersion.h"
|
||||
|
||||
#include "nsIXPInstallProgress.h"
|
||||
|
||||
|
||||
class nsInstallInfo
|
||||
{
|
||||
public:
|
||||
|
||||
nsInstallInfo(const nsString& fromURL, const nsString& localFile, long flags);
|
||||
|
||||
nsInstallInfo(nsVector* fromURL, nsVector* localFiles, long flags);
|
||||
|
||||
virtual ~nsInstallInfo();
|
||||
|
||||
nsString& GetFromURL(PRUint32 index = 0);
|
||||
|
||||
nsString& GetLocalFile(PRUint32 index = 0);
|
||||
|
||||
void GetArguments(nsString& args, PRUint32 index = 0);
|
||||
|
||||
long GetFlags();
|
||||
|
||||
PRBool IsMultipleTrigger();
|
||||
|
||||
static void DeleteVector(nsVector* vector);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
PRBool mMultipleTrigger;
|
||||
nsresult mError;
|
||||
|
||||
long mFlags;
|
||||
nsVector *mFromURLs;
|
||||
nsVector *mLocalFiles;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class nsInstall
|
||||
{
|
||||
friend class nsWinReg;
|
||||
friend class nsWinProfile;
|
||||
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
BAD_PACKAGE_NAME = -200,
|
||||
UNEXPECTED_ERROR = -201,
|
||||
ACCESS_DENIED = -202,
|
||||
TOO_MANY_CERTIFICATES = -203,
|
||||
NO_INSTALLER_CERTIFICATE = -204,
|
||||
NO_CERTIFICATE = -205,
|
||||
NO_MATCHING_CERTIFICATE = -206,
|
||||
UNKNOWN_JAR_FILE = -207,
|
||||
INVALID_ARGUMENTS = -208,
|
||||
ILLEGAL_RELATIVE_PATH = -209,
|
||||
USER_CANCELLED = -210,
|
||||
INSTALL_NOT_STARTED = -211,
|
||||
SILENT_MODE_DENIED = -212,
|
||||
NO_SUCH_COMPONENT = -213,
|
||||
FILE_DOES_NOT_EXIST = -214,
|
||||
FILE_READ_ONLY = -215,
|
||||
FILE_IS_DIRECTORY = -216,
|
||||
NETWORK_FILE_IS_IN_USE = -217,
|
||||
APPLE_SINGLE_ERR = -218,
|
||||
INVALID_PATH_ERR = -219,
|
||||
PATCH_BAD_DIFF = -220,
|
||||
PATCH_BAD_CHECKSUM_TARGET = -221,
|
||||
PATCH_BAD_CHECKSUM_RESULT = -222,
|
||||
UNINSTALL_FAILED = -223,
|
||||
GESTALT_UNKNOWN_ERR = -5550,
|
||||
GESTALT_INVALID_ARGUMENT = -5551,
|
||||
|
||||
SUCCESS = 0,
|
||||
REBOOT_NEEDED = 999,
|
||||
|
||||
LIMITED_INSTALL = 0,
|
||||
FULL_INSTALL = 1,
|
||||
NO_STATUS_DLG = 2,
|
||||
NO_FINALIZE_DLG = 4,
|
||||
|
||||
INSTALL_FILE_UNEXPECTED_MSG_ID = 0,
|
||||
DETAILS_REPLACE_FILE_MSG_ID = 1,
|
||||
DETAILS_INSTALL_FILE_MSG_ID = 2
|
||||
};
|
||||
|
||||
|
||||
nsInstall();
|
||||
virtual ~nsInstall();
|
||||
|
||||
PRInt32 SetScriptObject(void* aScriptObject);
|
||||
|
||||
PRInt32 SaveWinRegPrototype(void* aScriptObject);
|
||||
PRInt32 SaveWinProfilePrototype(void* aScriptObject);
|
||||
|
||||
JSObject* RetrieveWinRegPrototype(void);
|
||||
JSObject* RetrieveWinProfilePrototype(void);
|
||||
|
||||
PRInt32 GetUserPackageName(nsString& aUserPackageName);
|
||||
PRInt32 GetRegPackageName(nsString& aRegPackageName);
|
||||
|
||||
PRInt32 AbortInstall();
|
||||
|
||||
PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aSubdir, PRBool aForceMode, PRInt32* aReturn);
|
||||
PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aSubdir, PRInt32* aReturn);
|
||||
PRInt32 AddDirectory(const nsString& aRegName, const nsString& aJarSource, const nsString& aFolder, const nsString& aSubdir, PRInt32* aReturn);
|
||||
PRInt32 AddDirectory(const nsString& aJarSource, PRInt32* aReturn);
|
||||
|
||||
PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRBool aForceMode, PRInt32* aReturn);
|
||||
PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);
|
||||
PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);
|
||||
PRInt32 AddSubcomponent(const nsString& aJarSource, PRInt32* aReturn);
|
||||
|
||||
PRInt32 DeleteComponent(const nsString& aRegistryName, PRInt32* aReturn);
|
||||
PRInt32 DeleteFile(const nsString& aFolder, const nsString& aRelativeFileName, PRInt32* aReturn);
|
||||
PRInt32 DiskSpaceAvailable(const nsString& aFolder, PRInt32* aReturn);
|
||||
PRInt32 Execute(const nsString& aJarSource, const nsString& aArgs, PRInt32* aReturn);
|
||||
PRInt32 Execute(const nsString& aJarSource, PRInt32* aReturn);
|
||||
PRInt32 FinalizeInstall(PRInt32* aReturn);
|
||||
PRInt32 Gestalt(const nsString& aSelector, PRInt32* aReturn);
|
||||
PRInt32 GetComponentFolder(const nsString& aComponentName, const nsString& aSubdirectory, nsString** aFolder);
|
||||
PRInt32 GetComponentFolder(const nsString& aComponentName, nsString** aFolder);
|
||||
PRInt32 GetFolder(const nsString& aTargetFolder, const nsString& aSubdirectory, nsString** aFolder);
|
||||
PRInt32 GetFolder(const nsString& aTargetFolder, nsString** aFolder);
|
||||
PRInt32 GetLastError(PRInt32* aReturn);
|
||||
PRInt32 GetWinProfile(const nsString& aFolder, const nsString& aFile, JSContext* jscontext, JSClass* WinProfileClass, jsval* aReturn);
|
||||
PRInt32 GetWinRegistry(JSContext* jscontext, JSClass* WinRegClass, jsval* aReturn);
|
||||
PRInt32 Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);
|
||||
PRInt32 Patch(const nsString& aRegName, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);
|
||||
PRInt32 ResetError();
|
||||
PRInt32 SetPackageFolder(const nsString& aFolder);
|
||||
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32* aReturn);
|
||||
PRInt32 Uninstall(const nsString& aPackageName, PRInt32* aReturn);
|
||||
|
||||
PRInt32 FileOpDirCreate(nsFileSpec& aTarget, PRInt32* aReturn);
|
||||
PRInt32 FileOpDirGetParent(nsFileSpec& aTarget, nsFileSpec* aReturn);
|
||||
PRInt32 FileOpDirRemove(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn);
|
||||
PRInt32 FileOpDirRename(nsFileSpec& aSrc, nsFileSpec& aTarget, PRInt32* aReturn);
|
||||
PRInt32 FileOpFileCopy(nsFileSpec& aSrc, nsFileSpec& aTarget, PRInt32* aReturn);
|
||||
PRInt32 FileOpFileDelete(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn);
|
||||
PRInt32 FileOpFileExists(nsFileSpec& aTarget, PRBool* aReturn);
|
||||
PRInt32 FileOpFileExecute(nsFileSpec& aTarget, nsString& aParams, PRInt32* aReturn);
|
||||
PRInt32 FileOpFileGetNativeVersion(nsFileSpec& aTarget, nsString* aReturn);
|
||||
PRInt32 FileOpFileGetDiskSpaceAvailable(nsFileSpec& aTarget, PRUint32* aReturn);
|
||||
PRInt32 FileOpFileGetModDate(nsFileSpec& aTarget, nsFileSpec::TimeStamp* aReturn);
|
||||
PRInt32 FileOpFileGetSize(nsFileSpec& aTarget, PRUint32* aReturn);
|
||||
PRInt32 FileOpFileIsDirectory(nsFileSpec& aTarget, PRBool* aReturn);
|
||||
PRInt32 FileOpFileIsFile(nsFileSpec& aTarget, PRBool* aReturn);
|
||||
PRInt32 FileOpFileModDateChanged(nsFileSpec& aTarget, nsFileSpec::TimeStamp& aOldStamp, PRBool* aReturn);
|
||||
PRInt32 FileOpFileMove(nsFileSpec& aSrc, nsFileSpec& aTarget, PRInt32* aReturn);
|
||||
PRInt32 FileOpFileRename(nsFileSpec& aSrc, nsFileSpec& aTarget, PRInt32* aReturn);
|
||||
PRInt32 FileOpFileWinShortcutCreate(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn);
|
||||
PRInt32 FileOpFileMacAliasCreate(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn);
|
||||
PRInt32 FileOpFileUnixLinkCreate(nsFileSpec& aTarget, PRInt32 aFlags, PRInt32* aReturn);
|
||||
|
||||
PRInt32 ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedName, nsFileSpec** aRealName);
|
||||
void AddPatch(nsHashKey *aKey, nsFileSpec* fileName);
|
||||
void GetPatch(nsHashKey *aKey, nsFileSpec* fileName);
|
||||
|
||||
void GetJarFileLocation(nsString& aFile);
|
||||
void SetJarFileLocation(const nsString& aFile);
|
||||
|
||||
void GetInstallArguments(nsString& args);
|
||||
void SetInstallArguments(const nsString& args);
|
||||
|
||||
|
||||
private:
|
||||
JSObject* mScriptObject;
|
||||
|
||||
JSObject* mWinRegObject;
|
||||
JSObject* mWinProfileObject;
|
||||
|
||||
nsString mJarFileLocation;
|
||||
void* mJarFileData;
|
||||
|
||||
nsString mInstallArguments;
|
||||
|
||||
PRBool mUserCancelled;
|
||||
|
||||
PRBool mUninstallPackage;
|
||||
PRBool mRegisterPackage;
|
||||
|
||||
nsString mRegistryPackageName; /* Name of the package we are installing */
|
||||
nsString mUIName; /* User-readable package name */
|
||||
|
||||
nsInstallVersion* mVersionInfo; /* Component version info */
|
||||
|
||||
nsVector* mInstalledFiles;
|
||||
nsHashtable* mPatchList;
|
||||
|
||||
nsIXPInstallProgress *mNotifier;
|
||||
|
||||
PRInt32 mLastError;
|
||||
|
||||
void ParseFlags(int flags);
|
||||
PRInt32 SanityCheck(void);
|
||||
void GetTime(nsString &aString);
|
||||
|
||||
|
||||
PRInt32 GetQualifiedRegName(const nsString& name, nsString& qualifiedRegName );
|
||||
PRInt32 GetQualifiedPackageName( const nsString& name, nsString& qualifiedName );
|
||||
|
||||
void CurrentUserNode(nsString& userRegNode);
|
||||
PRBool BadRegName(const nsString& regName);
|
||||
PRInt32 SaveError(PRInt32 errcode);
|
||||
|
||||
void CleanUp();
|
||||
|
||||
PRInt32 OpenJARFile(void);
|
||||
void CloseJARFile(void);
|
||||
PRInt32 ExtractDirEntries(const nsString& directory, nsVector *paths);
|
||||
|
||||
PRInt32 ScheduleForInstall(nsInstallObject* ob);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
235
mozilla/xpinstall/src/nsInstallDelete.cpp
Normal file
235
mozilla/xpinstall/src/nsInstallDelete.cpp
Normal file
@@ -0,0 +1,235 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
#include "VerReg.h"
|
||||
#include "ScheduledTasks.h"
|
||||
#include "nsInstallDelete.h"
|
||||
#include "nsInstallResources.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
|
||||
nsInstallDelete::nsInstallDelete( nsInstall* inInstall,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRInt32 *error)
|
||||
|
||||
: nsInstallObject(inInstall)
|
||||
{
|
||||
if ((folderSpec == "null") || (inInstall == NULL))
|
||||
{
|
||||
*error = nsInstall::INVALID_ARGUMENTS;
|
||||
return;
|
||||
}
|
||||
|
||||
mDeleteStatus = DELETE_FILE;
|
||||
mFinalFile = nsnull;
|
||||
mRegistryName = "";
|
||||
|
||||
|
||||
mFinalFile = new nsFileSpec(folderSpec);
|
||||
*mFinalFile += inPartialPath;
|
||||
|
||||
*error = ProcessInstallDelete();
|
||||
}
|
||||
|
||||
nsInstallDelete::nsInstallDelete( nsInstall* inInstall,
|
||||
const nsString& inComponentName,
|
||||
PRInt32 *error)
|
||||
|
||||
: nsInstallObject(inInstall)
|
||||
{
|
||||
if (inInstall == NULL)
|
||||
{
|
||||
*error = nsInstall::INVALID_ARGUMENTS;
|
||||
return;
|
||||
}
|
||||
|
||||
mDeleteStatus = DELETE_COMPONENT;
|
||||
mFinalFile = nsnull;
|
||||
mRegistryName = inComponentName;
|
||||
|
||||
*error = ProcessInstallDelete();
|
||||
}
|
||||
|
||||
|
||||
nsInstallDelete::~nsInstallDelete()
|
||||
{
|
||||
if (mFinalFile == nsnull)
|
||||
delete mFinalFile;
|
||||
}
|
||||
|
||||
|
||||
PRInt32 nsInstallDelete::Prepare()
|
||||
{
|
||||
// no set-up necessary
|
||||
return nsInstall::SUCCESS;
|
||||
}
|
||||
|
||||
PRInt32 nsInstallDelete::Complete()
|
||||
{
|
||||
PRInt32 err = nsInstall::SUCCESS;
|
||||
|
||||
if (mInstall == NULL)
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
|
||||
if (mDeleteStatus == DELETE_COMPONENT)
|
||||
{
|
||||
char* temp = mRegistryName.ToNewCString();
|
||||
err = VR_Remove(temp);
|
||||
delete [] temp;
|
||||
}
|
||||
|
||||
if ((mDeleteStatus == DELETE_FILE) || (err == REGERR_OK))
|
||||
{
|
||||
err = NativeComplete();
|
||||
}
|
||||
else
|
||||
{
|
||||
err = nsInstall::UNEXPECTED_ERROR;
|
||||
}
|
||||
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void nsInstallDelete::Abort()
|
||||
{
|
||||
}
|
||||
|
||||
char* nsInstallDelete::toString()
|
||||
{
|
||||
char* buffer = new char[1024];
|
||||
|
||||
if (mDeleteStatus == DELETE_COMPONENT)
|
||||
{
|
||||
sprintf( buffer, nsInstallResources::GetDeleteComponentString(), nsAutoCString(mRegistryName));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mFinalFile)
|
||||
sprintf( buffer, nsInstallResources::GetDeleteFileString(), mFinalFile->GetCString());
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsInstallDelete::CanUninstall()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsInstallDelete::RegisterPackageNode()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
PRInt32 nsInstallDelete::ProcessInstallDelete()
|
||||
{
|
||||
PRInt32 err;
|
||||
|
||||
char* tempCString = nsnull;
|
||||
|
||||
if (mDeleteStatus == DELETE_COMPONENT)
|
||||
{
|
||||
/* Check if the component is in the registry */
|
||||
tempCString = mRegistryName.ToNewCString();
|
||||
|
||||
err = VR_InRegistry( tempCString );
|
||||
|
||||
if (err != REGERR_OK)
|
||||
{
|
||||
return err;
|
||||
}
|
||||
else
|
||||
{
|
||||
char* tempRegistryString;
|
||||
|
||||
tempRegistryString = (char*)PR_Calloc(MAXREGPATHLEN, sizeof(char));
|
||||
|
||||
err = VR_GetPath( tempCString , MAXREGPATHLEN, tempRegistryString);
|
||||
|
||||
if (err == REGERR_OK)
|
||||
{
|
||||
if (mFinalFile)
|
||||
delete mFinalFile;
|
||||
|
||||
mFinalFile = new nsFileSpec(tempRegistryString);
|
||||
}
|
||||
|
||||
PR_FREEIF(tempRegistryString);
|
||||
}
|
||||
}
|
||||
|
||||
if(tempCString)
|
||||
delete [] tempCString;
|
||||
|
||||
if (mFinalFile->Exists())
|
||||
{
|
||||
if (mFinalFile->IsFile())
|
||||
{
|
||||
err = nsInstall::SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = nsInstall::FILE_IS_DIRECTORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
err = nsInstall::FILE_DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRInt32 nsInstallDelete::NativeComplete()
|
||||
{
|
||||
if (mFinalFile->Exists())
|
||||
{
|
||||
if (mFinalFile->IsFile())
|
||||
{
|
||||
return DeleteFileNowOrSchedule(*mFinalFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
return nsInstall::FILE_IS_DIRECTORY;
|
||||
}
|
||||
}
|
||||
|
||||
return nsInstall::FILE_DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
78
mozilla/xpinstall/src/nsInstallDelete.h
Normal file
78
mozilla/xpinstall/src/nsInstallDelete.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef nsInstallDelete_h__
|
||||
#define nsInstallDelete_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsInstallObject.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
|
||||
#define DELETE_COMPONENT 1
|
||||
#define DELETE_FILE 2
|
||||
|
||||
class nsInstallDelete : public nsInstallObject
|
||||
{
|
||||
public:
|
||||
|
||||
nsInstallDelete( nsInstall* inInstall,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRInt32 *error);
|
||||
|
||||
nsInstallDelete( nsInstall* inInstall,
|
||||
const nsString& ,
|
||||
PRInt32 *error);
|
||||
|
||||
virtual ~nsInstallDelete();
|
||||
|
||||
PRInt32 Prepare();
|
||||
PRInt32 Complete();
|
||||
void Abort();
|
||||
char* toString();
|
||||
|
||||
PRBool CanUninstall();
|
||||
PRBool RegisterPackageNode();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/* Private Fields */
|
||||
|
||||
nsFileSpec* mFinalFile;
|
||||
|
||||
nsString mRegistryName;
|
||||
PRInt32 mDeleteStatus;
|
||||
|
||||
PRInt32 ProcessInstallDelete();
|
||||
PRInt32 NativeComplete();
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsInstallDelete_h__ */
|
||||
136
mozilla/xpinstall/src/nsInstallExecute.cpp
Normal file
136
mozilla/xpinstall/src/nsInstallExecute.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
#include "VerReg.h"
|
||||
#include "nsInstallExecute.h"
|
||||
#include "nsInstallResources.h"
|
||||
#include "ScheduledTasks.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
|
||||
nsInstallExecute:: nsInstallExecute( nsInstall* inInstall,
|
||||
const nsString& inJarLocation,
|
||||
const nsString& inArgs,
|
||||
PRInt32 *error)
|
||||
|
||||
: nsInstallObject(inInstall)
|
||||
{
|
||||
if ((inInstall == nsnull) || (inJarLocation == "null"))
|
||||
{
|
||||
*error = nsInstall::INVALID_ARGUMENTS;
|
||||
return;
|
||||
}
|
||||
|
||||
mJarLocation = inJarLocation;
|
||||
mArgs = inArgs;
|
||||
mExecutableFile = nsnull;
|
||||
|
||||
}
|
||||
|
||||
|
||||
nsInstallExecute::~nsInstallExecute()
|
||||
{
|
||||
if (mExecutableFile)
|
||||
delete mExecutableFile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRInt32 nsInstallExecute::Prepare()
|
||||
{
|
||||
if (mInstall == NULL || mJarLocation == "null")
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
|
||||
return mInstall->ExtractFileFromJar(mJarLocation, nsnull, &mExecutableFile);
|
||||
}
|
||||
|
||||
PRInt32 nsInstallExecute::Complete()
|
||||
{
|
||||
if (mExecutableFile == nsnull)
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
|
||||
nsFileSpec app( *mExecutableFile);
|
||||
|
||||
if (!app.Exists())
|
||||
{
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
PRInt32 result = app.Execute( mArgs );
|
||||
|
||||
DeleteFileNowOrSchedule( app );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void nsInstallExecute::Abort()
|
||||
{
|
||||
/* Get the names */
|
||||
if (mExecutableFile == nsnull)
|
||||
return;
|
||||
|
||||
DeleteFileNowOrSchedule(*mExecutableFile);
|
||||
}
|
||||
|
||||
char* nsInstallExecute::toString()
|
||||
{
|
||||
char* buffer = new char[1024];
|
||||
|
||||
// if the FileSpec is NULL, just us the in jar file name.
|
||||
|
||||
if (mExecutableFile == nsnull)
|
||||
{
|
||||
char *tempString = mJarLocation.ToNewCString();
|
||||
sprintf( buffer, nsInstallResources::GetExecuteString(), tempString);
|
||||
delete [] tempString;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( buffer, nsInstallResources::GetExecuteString(), mExecutableFile->GetCString());
|
||||
}
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsInstallExecute::CanUninstall()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsInstallExecute::RegisterPackageNode()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
73
mozilla/xpinstall/src/nsInstallExecute.h
Normal file
73
mozilla/xpinstall/src/nsInstallExecute.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef nsInstallExecute_h__
|
||||
#define nsInstallExecute_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsInstallObject.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
|
||||
|
||||
class nsInstallExecute : public nsInstallObject
|
||||
{
|
||||
public:
|
||||
|
||||
nsInstallExecute( nsInstall* inInstall,
|
||||
const nsString& inJarLocation,
|
||||
const nsString& inArgs,
|
||||
PRInt32 *error);
|
||||
|
||||
|
||||
virtual ~nsInstallExecute();
|
||||
|
||||
PRInt32 Prepare();
|
||||
PRInt32 Complete();
|
||||
void Abort();
|
||||
char* toString();
|
||||
|
||||
PRBool CanUninstall();
|
||||
PRBool RegisterPackageNode();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
nsString mJarLocation; // Location in the JAR
|
||||
nsString mArgs; // command line arguments
|
||||
|
||||
nsFileSpec *mExecutableFile; // temporary file location
|
||||
|
||||
|
||||
PRInt32 NativeComplete(void);
|
||||
void NativeAbort(void);
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsInstallExecute_h__ */
|
||||
366
mozilla/xpinstall/src/nsInstallFile.cpp
Normal file
366
mozilla/xpinstall/src/nsInstallFile.cpp
Normal file
@@ -0,0 +1,366 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsInstallFile.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "VerReg.h"
|
||||
#include "ScheduledTasks.h"
|
||||
#include "nsInstall.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
#include "nsInstallResources.h"
|
||||
|
||||
/* Public Methods */
|
||||
|
||||
/* Constructor
|
||||
inInstall - softUpdate object we belong to
|
||||
inComponentName - full path of the registry component
|
||||
inVInfo - full version info
|
||||
inJarLocation - location inside the JAR file
|
||||
inFinalFileSpec - final location on disk
|
||||
*/
|
||||
|
||||
|
||||
nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
||||
const nsString& inComponentName,
|
||||
const nsString& inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRBool forceInstall,
|
||||
PRInt32 *error)
|
||||
: nsInstallObject(inInstall)
|
||||
{
|
||||
mVersionRegistryName = nsnull;
|
||||
mJarLocation = nsnull;
|
||||
mExtracedFile = nsnull;
|
||||
mFinalFile = nsnull;
|
||||
mVersionInfo = nsnull;
|
||||
|
||||
mUpgradeFile = PR_FALSE;
|
||||
|
||||
if ((folderSpec == "null") || (inInstall == NULL))
|
||||
{
|
||||
*error = nsInstall::INVALID_ARGUMENTS;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check for existence of the newer version */
|
||||
|
||||
PRBool versionNewer = PR_FALSE; // Is this a newer version
|
||||
char* qualifiedRegNameString = inComponentName.ToNewCString();
|
||||
|
||||
if ( (forceInstall == PR_FALSE ) && (inVInfo != "") && ( VR_ValidateComponent( qualifiedRegNameString ) == 0 ) )
|
||||
{
|
||||
nsInstallVersion *newVersion = new nsInstallVersion();
|
||||
newVersion->Init(inVInfo);
|
||||
|
||||
VERSION versionStruct;
|
||||
|
||||
VR_GetVersion( qualifiedRegNameString, &versionStruct );
|
||||
|
||||
nsInstallVersion* oldVersion = new nsInstallVersion();
|
||||
|
||||
oldVersion->Init(versionStruct.major,
|
||||
versionStruct.minor,
|
||||
versionStruct.release,
|
||||
versionStruct.build);
|
||||
|
||||
PRInt32 areTheyEqual;
|
||||
newVersion->CompareTo(oldVersion, &areTheyEqual);
|
||||
|
||||
delete oldVersion;
|
||||
delete newVersion;
|
||||
|
||||
if (areTheyEqual == nsIDOMInstallVersion::MAJOR_DIFF_MINUS ||
|
||||
areTheyEqual == nsIDOMInstallVersion::MINOR_DIFF_MINUS ||
|
||||
areTheyEqual == nsIDOMInstallVersion::REL_DIFF_MINUS ||
|
||||
areTheyEqual == nsIDOMInstallVersion::BLD_DIFF_MINUS )
|
||||
{
|
||||
// the file to be installed is OLDER than what is on disk. Return error
|
||||
delete qualifiedRegNameString;
|
||||
*error = areTheyEqual;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
delete qualifiedRegNameString;
|
||||
|
||||
|
||||
mFinalFile = new nsFileSpec(folderSpec);
|
||||
*mFinalFile += inPartialPath;
|
||||
|
||||
mReplaceFile = mFinalFile->Exists();
|
||||
|
||||
if (mReplaceFile == PR_FALSE)
|
||||
{
|
||||
nsFileSpec parent;
|
||||
mFinalFile->GetParent(parent);
|
||||
nsFileSpec makeDirs(parent.GetCString(), PR_TRUE);
|
||||
}
|
||||
|
||||
mForceInstall = forceInstall;
|
||||
|
||||
mVersionRegistryName = new nsString(inComponentName);
|
||||
mJarLocation = new nsString(inJarLocation);
|
||||
mVersionInfo = new nsString(inVInfo);
|
||||
|
||||
nsString regPackageName;
|
||||
mInstall->GetRegPackageName(regPackageName);
|
||||
|
||||
// determine Child status
|
||||
if ( regPackageName == "" )
|
||||
{
|
||||
// in the "current communicator package" absolute pathnames (start
|
||||
// with slash) indicate shared files -- all others are children
|
||||
mChildFile = ( mVersionRegistryName->CharAt(0) != '/' );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// there is no "starts with" api in nsString. LAME!
|
||||
nsString startsWith;
|
||||
mVersionRegistryName->Left(startsWith, regPackageName.Length());
|
||||
|
||||
if (startsWith.Equals(regPackageName))
|
||||
{
|
||||
mChildFile = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
mChildFile = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsInstallFile::~nsInstallFile()
|
||||
{
|
||||
if (mVersionRegistryName)
|
||||
delete mVersionRegistryName;
|
||||
|
||||
if (mJarLocation)
|
||||
delete mJarLocation;
|
||||
|
||||
if (mExtracedFile)
|
||||
delete mExtracedFile;
|
||||
|
||||
if (mFinalFile)
|
||||
delete mFinalFile;
|
||||
|
||||
if (mVersionInfo)
|
||||
delete mVersionInfo;
|
||||
}
|
||||
|
||||
/* Prepare
|
||||
* Extracts file out of the JAR archive
|
||||
*/
|
||||
PRInt32 nsInstallFile::Prepare()
|
||||
{
|
||||
if (mInstall == nsnull || mFinalFile == nsnull || mJarLocation == nsnull )
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
|
||||
return mInstall->ExtractFileFromJar(*mJarLocation, mFinalFile, &mExtracedFile);
|
||||
}
|
||||
|
||||
/* Complete
|
||||
* Completes the install:
|
||||
* - move the downloaded file to the final location
|
||||
* - updates the registry
|
||||
*/
|
||||
PRInt32 nsInstallFile::Complete()
|
||||
{
|
||||
PRInt32 err;
|
||||
|
||||
if (mInstall == nsnull || mVersionRegistryName == nsnull || mFinalFile == nsnull )
|
||||
{
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
err = CompleteFileMove();
|
||||
|
||||
if ( 0 == err || nsInstall::REBOOT_NEEDED == err )
|
||||
{
|
||||
err = RegisterInVersionRegistry();
|
||||
}
|
||||
|
||||
return err;
|
||||
|
||||
}
|
||||
|
||||
void nsInstallFile::Abort()
|
||||
{
|
||||
if (mExtracedFile != nsnull)
|
||||
mExtracedFile->Delete(PR_FALSE);
|
||||
}
|
||||
|
||||
char* nsInstallFile::toString()
|
||||
{
|
||||
char* buffer = new char[1024];
|
||||
|
||||
if (mFinalFile == nsnull)
|
||||
{
|
||||
sprintf( buffer, nsInstallResources::GetInstallFileString(), nsnull);
|
||||
}
|
||||
else if (mReplaceFile)
|
||||
{
|
||||
// we are replacing this file.
|
||||
|
||||
sprintf( buffer, nsInstallResources::GetReplaceFileString(), mFinalFile->GetCString());
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( buffer, nsInstallResources::GetInstallFileString(), mFinalFile->GetCString());
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
PRInt32 nsInstallFile::CompleteFileMove()
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (mExtracedFile == nsnull)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( *mExtracedFile == *mFinalFile )
|
||||
{
|
||||
/* No need to rename, they are the same */
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = ReplaceFileNowOrSchedule(*mExtracedFile, *mFinalFile );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFile::RegisterInVersionRegistry()
|
||||
{
|
||||
int refCount;
|
||||
nsString regPackageName;
|
||||
mInstall->GetRegPackageName(regPackageName);
|
||||
|
||||
|
||||
// Register file and log for Uninstall
|
||||
|
||||
if (!mChildFile)
|
||||
{
|
||||
int found;
|
||||
if (regPackageName != "")
|
||||
{
|
||||
found = VR_UninstallFileExistsInList( (char*)(const char*)nsAutoCString(regPackageName) ,
|
||||
(char*)(const char*)nsAutoCString(*mVersionRegistryName));
|
||||
}
|
||||
else
|
||||
{
|
||||
found = VR_UninstallFileExistsInList( "", (char*)(const char*)nsAutoCString(*mVersionRegistryName) );
|
||||
}
|
||||
|
||||
if (found != REGERR_OK)
|
||||
mUpgradeFile = PR_FALSE;
|
||||
else
|
||||
mUpgradeFile = PR_TRUE;
|
||||
}
|
||||
else if (REGERR_OK == VR_InRegistry( (char*)(const char*)nsAutoCString(*mVersionRegistryName)))
|
||||
{
|
||||
mUpgradeFile = PR_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mUpgradeFile = PR_FALSE;
|
||||
}
|
||||
|
||||
if ( REGERR_OK != VR_GetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), &refCount ))
|
||||
{
|
||||
refCount = 0;
|
||||
}
|
||||
|
||||
VR_Install( (char*)(const char*)nsAutoCString(*mVersionRegistryName),
|
||||
(char*)(const char*)mFinalFile->GetNativePathCString(), // DO NOT CHANGE THIS.
|
||||
(char*)(const char*)nsAutoCString(*mVersionInfo),
|
||||
PR_FALSE );
|
||||
|
||||
if (mUpgradeFile)
|
||||
{
|
||||
if (refCount == 0)
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 1 );
|
||||
else
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), refCount ); //FIX?? what should the ref count be/
|
||||
}
|
||||
else
|
||||
{
|
||||
if (refCount != 0)
|
||||
{
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), refCount + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mReplaceFile)
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 2 );
|
||||
else
|
||||
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 1 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !mChildFile && !mUpgradeFile )
|
||||
{
|
||||
if (regPackageName != "")
|
||||
{
|
||||
VR_UninstallAddFileToList( (char*)(const char*)nsAutoCString(regPackageName),
|
||||
(char*)(const char*)nsAutoCString(*mVersionRegistryName));
|
||||
}
|
||||
else
|
||||
{
|
||||
VR_UninstallAddFileToList( "", (char*)(const char*)nsAutoCString(*mVersionRegistryName) );
|
||||
}
|
||||
}
|
||||
|
||||
return nsInstall::SUCCESS;
|
||||
}
|
||||
|
||||
/* CanUninstall
|
||||
* InstallFile() installs files which can be uninstalled,
|
||||
* hence this function returns true.
|
||||
*/
|
||||
PRBool
|
||||
nsInstallFile::CanUninstall()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* RegisterPackageNode
|
||||
* InstallFile() installs files which need to be registered,
|
||||
* hence this function returns true.
|
||||
*/
|
||||
PRBool
|
||||
nsInstallFile::RegisterPackageNode()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
93
mozilla/xpinstall/src/nsInstallFile.h
Normal file
93
mozilla/xpinstall/src/nsInstallFile.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef nsInstallFile_h__
|
||||
#define nsInstallFile_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsInstallObject.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallVersion.h"
|
||||
|
||||
class nsInstallFile : public nsInstallObject
|
||||
{
|
||||
public:
|
||||
|
||||
/*************************************************************
|
||||
* Public Methods
|
||||
*
|
||||
* Constructor
|
||||
* inSoftUpdate - softUpdate object we belong to
|
||||
* inComponentName - full path of the registry component
|
||||
* inVInfo - full version info
|
||||
* inJarLocation - location inside the JAR file
|
||||
* inFinalFileSpec - final location on disk
|
||||
*************************************************************/
|
||||
nsInstallFile( nsInstall* inInstall,
|
||||
const nsString& inVRName,
|
||||
const nsString& inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRBool forceInstall,
|
||||
PRInt32 *error);
|
||||
|
||||
virtual ~nsInstallFile();
|
||||
|
||||
PRInt32 Prepare();
|
||||
PRInt32 Complete();
|
||||
void Abort();
|
||||
char* toString();
|
||||
|
||||
PRBool CanUninstall();
|
||||
PRBool RegisterPackageNode();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/* Private Fields */
|
||||
nsString* mVersionInfo; /* Version info for this file*/
|
||||
|
||||
nsString* mJarLocation; /* Location in the JAR */
|
||||
nsFileSpec* mExtracedFile; /* temporary file location */
|
||||
nsFileSpec* mFinalFile; /* final file destination */
|
||||
|
||||
nsString* mVersionRegistryName; /* full version path */
|
||||
|
||||
PRBool mForceInstall; /* whether install is forced */
|
||||
PRBool mReplaceFile; /* whether file exists */
|
||||
PRBool mChildFile; /* whether file is a child */
|
||||
PRBool mUpgradeFile; /* whether file is an upgrade */
|
||||
|
||||
|
||||
PRInt32 CompleteFileMove();
|
||||
PRInt32 RegisterInVersionRegistry();
|
||||
};
|
||||
|
||||
#endif /* nsInstallFile_h__ */
|
||||
38
mozilla/xpinstall/src/nsInstallFileOpEnums.h
Normal file
38
mozilla/xpinstall/src/nsInstallFileOpEnums.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsInstallFileOpEnums_h__
|
||||
#define nsInstallFileOpEnums_h__
|
||||
|
||||
typedef enum nsInstallFileOpEnums {
|
||||
NS_FOP_DIR_CREATE = 0,
|
||||
NS_FOP_DIR_REMOVE = 1,
|
||||
NS_FOP_DIR_RENAME = 2,
|
||||
NS_FOP_FILE_COPY = 3,
|
||||
NS_FOP_FILE_DELETE = 4,
|
||||
NS_FOP_FILE_EXECUTE = 5,
|
||||
NS_FOP_FILE_MOVE = 6,
|
||||
NS_FOP_FILE_RENAME = 7,
|
||||
NS_FOP_WIN_SHORTCUT_CREATE = 8,
|
||||
NS_FOP_MAC_ALIAS_CREATE = 9,
|
||||
NS_FOP_UNIX_LINK_CREATE = 10,
|
||||
NS_FOP_FILE_SET_STAT = 11
|
||||
|
||||
} nsInstallFileOpEnums;
|
||||
|
||||
#endif /* nsInstallFileOpEnums_h__ */
|
||||
316
mozilla/xpinstall/src/nsInstallFileOpItem.cpp
Normal file
316
mozilla/xpinstall/src/nsInstallFileOpItem.cpp
Normal file
@@ -0,0 +1,316 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallFileOpEnums.h"
|
||||
#include "nsInstallFileOpItem.h"
|
||||
|
||||
/* Public Methods */
|
||||
|
||||
nsInstallFileOpItem::nsInstallFileOpItem(nsInstall* aInstallObj,
|
||||
PRInt32 aCommand,
|
||||
nsFileSpec& aTarget,
|
||||
PRInt32 aFlags,
|
||||
PRInt32* aReturn)
|
||||
:nsInstallObject(aInstallObj)
|
||||
{
|
||||
mIObj = aInstallObj;
|
||||
mCommand = aCommand;
|
||||
mFlags = aFlags;
|
||||
mSrc = nsnull;
|
||||
mParams = nsnull;
|
||||
mTarget = new nsFileSpec(aTarget);
|
||||
|
||||
*aReturn = NS_OK;
|
||||
}
|
||||
|
||||
nsInstallFileOpItem::nsInstallFileOpItem(nsInstall* aInstallObj,
|
||||
PRInt32 aCommand,
|
||||
nsFileSpec& aSrc,
|
||||
nsFileSpec& aTarget,
|
||||
PRInt32* aReturn)
|
||||
:nsInstallObject(aInstallObj)
|
||||
{
|
||||
mIObj = aInstallObj;
|
||||
mCommand = aCommand;
|
||||
mFlags = 0;
|
||||
mSrc = new nsFileSpec(aSrc);
|
||||
mParams = nsnull;
|
||||
mTarget = new nsFileSpec(aTarget);
|
||||
|
||||
*aReturn = NS_OK;
|
||||
}
|
||||
|
||||
nsInstallFileOpItem::nsInstallFileOpItem(nsInstall* aInstallObj,
|
||||
PRInt32 aCommand,
|
||||
nsFileSpec& aTarget,
|
||||
PRInt32* aReturn)
|
||||
:nsInstallObject(aInstallObj)
|
||||
{
|
||||
mIObj = aInstallObj;
|
||||
mCommand = aCommand;
|
||||
mFlags = 0;
|
||||
mSrc = nsnull;
|
||||
mParams = nsnull;
|
||||
mTarget = new nsFileSpec(aTarget);
|
||||
|
||||
*aReturn = NS_OK;
|
||||
}
|
||||
|
||||
nsInstallFileOpItem::nsInstallFileOpItem(nsInstall* aInstallObj,
|
||||
PRInt32 aCommand,
|
||||
nsFileSpec& aTarget,
|
||||
nsString& aParams,
|
||||
PRInt32* aReturn)
|
||||
:nsInstallObject(aInstallObj)
|
||||
{
|
||||
mIObj = aInstallObj;
|
||||
mCommand = aCommand;
|
||||
mFlags = 0;
|
||||
mSrc = nsnull;
|
||||
mParams = new nsString(aParams);
|
||||
mTarget = new nsFileSpec(aTarget);
|
||||
|
||||
*aReturn = NS_OK;
|
||||
}
|
||||
|
||||
nsInstallFileOpItem::~nsInstallFileOpItem()
|
||||
{
|
||||
if(mSrc)
|
||||
delete mSrc;
|
||||
if(mTarget)
|
||||
delete mTarget;
|
||||
}
|
||||
|
||||
PRInt32 nsInstallFileOpItem::Complete()
|
||||
{
|
||||
PRInt32 aReturn = NS_OK;
|
||||
|
||||
switch(mCommand)
|
||||
{
|
||||
case NS_FOP_DIR_CREATE:
|
||||
NativeFileOpDirCreate(mTarget);
|
||||
break;
|
||||
case NS_FOP_DIR_REMOVE:
|
||||
NativeFileOpDirRemove(mTarget, mFlags);
|
||||
break;
|
||||
case NS_FOP_DIR_RENAME:
|
||||
NativeFileOpDirRename(mSrc, mTarget);
|
||||
break;
|
||||
case NS_FOP_FILE_COPY:
|
||||
NativeFileOpFileCopy(mSrc, mTarget);
|
||||
break;
|
||||
case NS_FOP_FILE_DELETE:
|
||||
NativeFileOpFileDelete(mTarget, mFlags);
|
||||
break;
|
||||
case NS_FOP_FILE_EXECUTE:
|
||||
NativeFileOpFileExecute(mTarget, mParams);
|
||||
break;
|
||||
case NS_FOP_FILE_MOVE:
|
||||
NativeFileOpFileMove(mSrc, mTarget);
|
||||
break;
|
||||
case NS_FOP_FILE_RENAME:
|
||||
NativeFileOpFileRename(mSrc, mTarget);
|
||||
break;
|
||||
case NS_FOP_WIN_SHORTCUT_CREATE:
|
||||
NativeFileOpWinShortcutCreate();
|
||||
break;
|
||||
case NS_FOP_MAC_ALIAS_CREATE:
|
||||
NativeFileOpMacAliasCreate();
|
||||
break;
|
||||
case NS_FOP_UNIX_LINK_CREATE:
|
||||
NativeFileOpUnixLinkCreate();
|
||||
break;
|
||||
}
|
||||
return aReturn;
|
||||
}
|
||||
|
||||
float nsInstallFileOpItem::GetInstallOrder()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
char* nsInstallFileOpItem::toString()
|
||||
{
|
||||
nsString result;
|
||||
char* resultCString;
|
||||
|
||||
switch(mCommand)
|
||||
{
|
||||
case NS_FOP_FILE_COPY:
|
||||
result = "Copy file: ";
|
||||
result.Append(mSrc->GetNativePathCString());
|
||||
result.Append(" to ");
|
||||
result.Append(mTarget->GetNativePathCString());
|
||||
resultCString = result.ToNewCString();
|
||||
break;
|
||||
case NS_FOP_FILE_DELETE:
|
||||
result = "Delete file: ";
|
||||
result.Append(mTarget->GetNativePathCString());
|
||||
resultCString = result.ToNewCString();
|
||||
break;
|
||||
case NS_FOP_FILE_MOVE:
|
||||
result = "Move file: ";
|
||||
result.Append(mSrc->GetNativePathCString());
|
||||
result.Append(" to ");
|
||||
result.Append(mTarget->GetNativePathCString());
|
||||
resultCString = result.ToNewCString();
|
||||
break;
|
||||
case NS_FOP_FILE_RENAME:
|
||||
result = "Rename file: ";
|
||||
result.Append(mTarget->GetNativePathCString());
|
||||
resultCString = result.ToNewCString();
|
||||
break;
|
||||
case NS_FOP_DIR_CREATE:
|
||||
result = "Create Folder: ";
|
||||
result.Append(mTarget->GetNativePathCString());
|
||||
resultCString = result.ToNewCString();
|
||||
break;
|
||||
case NS_FOP_DIR_REMOVE:
|
||||
result = "Remove Folder: ";
|
||||
result.Append(mTarget->GetNativePathCString());
|
||||
resultCString = result.ToNewCString();
|
||||
break;
|
||||
case NS_FOP_WIN_SHORTCUT_CREATE:
|
||||
break;
|
||||
case NS_FOP_MAC_ALIAS_CREATE:
|
||||
break;
|
||||
case NS_FOP_UNIX_LINK_CREATE:
|
||||
break;
|
||||
case NS_FOP_FILE_SET_STAT:
|
||||
result = "Set file stat: ";
|
||||
result.Append(mTarget->GetNativePathCString());
|
||||
resultCString = result.ToNewCString();
|
||||
break;
|
||||
default:
|
||||
result = "Unkown file operation command!";
|
||||
resultCString = result.ToNewCString();
|
||||
break;
|
||||
}
|
||||
return resultCString;
|
||||
}
|
||||
|
||||
PRInt32 nsInstallFileOpItem::Prepare()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void nsInstallFileOpItem::Abort()
|
||||
{
|
||||
}
|
||||
|
||||
/* Private Methods */
|
||||
|
||||
/* CanUninstall
|
||||
* InstallFileOpItem() does not install any files which can be uninstalled,
|
||||
* hence this function returns false.
|
||||
*/
|
||||
PRBool
|
||||
nsInstallFileOpItem::CanUninstall()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* RegisterPackageNode
|
||||
* InstallFileOpItem() does notinstall files which need to be registered,
|
||||
* hence this function returns false.
|
||||
*/
|
||||
PRBool
|
||||
nsInstallFileOpItem::RegisterPackageNode()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// File operation functions begin here
|
||||
//
|
||||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpDirCreate(nsFileSpec* aTarget)
|
||||
{
|
||||
aTarget->CreateDirectory();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpDirRemove(nsFileSpec* aTarget, PRInt32 aFlags)
|
||||
{
|
||||
aTarget->Delete(aFlags);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpDirRename(nsFileSpec* aSrc, nsFileSpec* aTarget)
|
||||
{
|
||||
aSrc->Rename(*aTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpFileCopy(nsFileSpec* aSrc, nsFileSpec* aTarget)
|
||||
{
|
||||
aSrc->Copy(*aTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpFileDelete(nsFileSpec* aTarget, PRInt32 aFlags)
|
||||
{
|
||||
aTarget->Delete(aFlags);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpFileExecute(nsFileSpec* aTarget, nsString* aParams)
|
||||
{
|
||||
aTarget->Execute(*aParams);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpFileMove(nsFileSpec* aSrc, nsFileSpec* aTarget)
|
||||
{
|
||||
aSrc->Move(*aTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpFileRename(nsFileSpec* aSrc, nsFileSpec* aTarget)
|
||||
{
|
||||
aSrc->Rename(*aTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpWinShortcutCreate()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpMacAliasCreate()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFileOpItem::NativeFileOpUnixLinkCreate()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
111
mozilla/xpinstall/src/nsInstallFileOpItem.h
Normal file
111
mozilla/xpinstall/src/nsInstallFileOpItem.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsInstallFileOpItem_h__
|
||||
#define nsInstallFileOpItem_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsSoftwareUpdate.h"
|
||||
#include "nsInstallObject.h"
|
||||
#include "nsInstall.h"
|
||||
|
||||
class nsInstallFileOpItem : public nsInstallObject
|
||||
{
|
||||
public:
|
||||
/* Public Fields */
|
||||
|
||||
/* Public Methods */
|
||||
// used by:
|
||||
// FileOpFileDelete()
|
||||
nsInstallFileOpItem(nsInstall* installObj,
|
||||
PRInt32 aCommand,
|
||||
nsFileSpec& aTarget,
|
||||
PRInt32 aFlags,
|
||||
PRInt32* aReturn);
|
||||
|
||||
// used by:
|
||||
// FileOpDirRemove()
|
||||
// FileOpDirRename()
|
||||
// FileOpFileCopy()
|
||||
// FileOpFileMove()
|
||||
// FileOpFileRename()
|
||||
nsInstallFileOpItem(nsInstall* installObj,
|
||||
PRInt32 aCommand,
|
||||
nsFileSpec& aSrc,
|
||||
nsFileSpec& aTarget,
|
||||
PRInt32* aReturn);
|
||||
|
||||
// used by:
|
||||
// FileOpDirCreate()
|
||||
nsInstallFileOpItem(nsInstall* aInstallObj,
|
||||
PRInt32 aCommand,
|
||||
nsFileSpec& aTarget,
|
||||
PRInt32* aReturn);
|
||||
|
||||
// used by:
|
||||
// FileOpFileExecute()
|
||||
nsInstallFileOpItem(nsInstall* aInstallObj,
|
||||
PRInt32 aCommand,
|
||||
nsFileSpec& aTarget,
|
||||
nsString& aParams,
|
||||
PRInt32* aReturn);
|
||||
|
||||
~nsInstallFileOpItem();
|
||||
|
||||
PRInt32 Prepare(void);
|
||||
PRInt32 Complete();
|
||||
char* toString();
|
||||
void Abort();
|
||||
float GetInstallOrder();
|
||||
|
||||
/* should these be protected? */
|
||||
PRBool CanUninstall();
|
||||
PRBool RegisterPackageNode();
|
||||
|
||||
private:
|
||||
|
||||
/* Private Fields */
|
||||
|
||||
nsInstall* mIObj; // initiating Install object
|
||||
nsFileSpec* mSrc;
|
||||
nsFileSpec* mTarget;
|
||||
nsString* mParams;
|
||||
long mFStat;
|
||||
PRInt32 mFlags;
|
||||
PRInt32 mCommand;
|
||||
|
||||
/* Private Methods */
|
||||
|
||||
PRInt32 NativeFileOpDirCreate(nsFileSpec* aTarget);
|
||||
PRInt32 NativeFileOpDirRemove(nsFileSpec* aTarget, PRInt32 aFlags);
|
||||
PRInt32 NativeFileOpDirRename(nsFileSpec* aSrc, nsFileSpec* aTarget);
|
||||
PRInt32 NativeFileOpFileCopy(nsFileSpec* aSrc, nsFileSpec* aTarget);
|
||||
PRInt32 NativeFileOpFileDelete(nsFileSpec* aTarget, PRInt32 aFlags);
|
||||
PRInt32 NativeFileOpFileExecute(nsFileSpec* aTarget, nsString* aParams);
|
||||
PRInt32 NativeFileOpFileMove(nsFileSpec* aSrc, nsFileSpec* aTarget);
|
||||
PRInt32 NativeFileOpFileRename(nsFileSpec* aSrc, nsFileSpec* aTarget);
|
||||
PRInt32 NativeFileOpWinShortcutCreate();
|
||||
PRInt32 NativeFileOpMacAliasCreate();
|
||||
PRInt32 NativeFileOpUnixLinkCreate();
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsInstallFileOpItem_h__ */
|
||||
|
||||
336
mozilla/xpinstall/src/nsInstallFolder.cpp
Normal file
336
mozilla/xpinstall/src/nsInstallFolder.cpp
Normal file
@@ -0,0 +1,336 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallFolder.h"
|
||||
|
||||
#include "nscore.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsRepository.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
#include "nsFileLocations.h"
|
||||
#include "nsIFileLocator.h"
|
||||
|
||||
struct DirectoryTable
|
||||
{
|
||||
char * directoryName; /* The formal directory name */
|
||||
PRInt32 folderEnum; /* Directory ID */
|
||||
};
|
||||
|
||||
struct DirectoryTable DirectoryTable[] =
|
||||
{
|
||||
{"Plugins", 100 },
|
||||
{"Program", 101 },
|
||||
{"Communicator", 102 },
|
||||
{"User Pick", 103 },
|
||||
{"Temporary", 104 },
|
||||
{"Installed", 105 },
|
||||
{"Current User", 106 },
|
||||
{"Preferences", 107 },
|
||||
{"OS Drive", 108 },
|
||||
{"file:///", 109 },
|
||||
|
||||
{"Components", 110 },
|
||||
{"Chrome", 111 },
|
||||
|
||||
{"Win System", 200 },
|
||||
{"Windows", 201 },
|
||||
|
||||
{"Mac System", 300 },
|
||||
{"Mac Desktop", 301 },
|
||||
{"Mac Trash", 302 },
|
||||
{"Mac Startup", 303 },
|
||||
{"Mac Shutdown", 304 },
|
||||
{"Mac Apple Menu", 305 },
|
||||
{"Mac Control Panel", 306 },
|
||||
{"Mac Extension", 307 },
|
||||
{"Mac Fonts", 308 },
|
||||
{"Mac Preferences", 309 },
|
||||
{"Mac Documents", 310 },
|
||||
|
||||
{"Unix Local", 400 },
|
||||
{"Unix Lib", 401 },
|
||||
|
||||
{"", -1 }
|
||||
};
|
||||
|
||||
|
||||
|
||||
nsInstallFolder::nsInstallFolder(const nsString& aFolderID)
|
||||
{
|
||||
mFileSpec = nsnull;
|
||||
SetDirectoryPath( aFolderID, "");
|
||||
}
|
||||
|
||||
nsInstallFolder::nsInstallFolder(const nsString& aFolderID, const nsString& aRelativePath)
|
||||
{
|
||||
mFileSpec = nsnull;
|
||||
|
||||
/*
|
||||
aFolderID can be either a Folder enum in which case we merely pass it to SetDirectoryPath, or
|
||||
it can be a Directory. If it is the later, it must already exist and of course be a directory
|
||||
not a file.
|
||||
*/
|
||||
|
||||
nsFileSpec dirCheck(aFolderID);
|
||||
if ( (dirCheck.Error() == NS_OK) && (dirCheck.IsDirectory()) && (dirCheck.Exists()))
|
||||
{
|
||||
nsString tempString = aFolderID;
|
||||
tempString += aRelativePath;
|
||||
mFileSpec = new nsFileSpec(tempString);
|
||||
|
||||
// make sure that the directory is created.
|
||||
nsFileSpec(mFileSpec->GetCString(), PR_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDirectoryPath( aFolderID, aRelativePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsInstallFolder::~nsInstallFolder()
|
||||
{
|
||||
if (mFileSpec != nsnull)
|
||||
delete mFileSpec;
|
||||
}
|
||||
|
||||
void
|
||||
nsInstallFolder::GetDirectoryPath(nsString& aDirectoryPath)
|
||||
{
|
||||
aDirectoryPath = "";
|
||||
|
||||
if (mFileSpec != nsnull)
|
||||
{
|
||||
// We want the a NATIVE path.
|
||||
aDirectoryPath.SetString(mFileSpec->GetCString());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath)
|
||||
{
|
||||
if ( aFolderID.EqualsIgnoreCase("User Pick") )
|
||||
{
|
||||
PickDefaultDirectory();
|
||||
return;
|
||||
}
|
||||
else if ( aFolderID.EqualsIgnoreCase("Installed") )
|
||||
{
|
||||
mFileSpec = new nsFileSpec(aRelativePath, PR_TRUE); // creates the directories to the relative path.
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
PRInt32 folderDirSpecID = MapNameToEnum(aFolderID);
|
||||
|
||||
switch (folderDirSpecID)
|
||||
{
|
||||
case 100: /////////////////////////////////////////////////////////// Plugins
|
||||
SetAppShellDirectory(nsSpecialFileSpec::App_PluginsDirectory );
|
||||
break;
|
||||
|
||||
case 101: /////////////////////////////////////////////////////////// Program
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_CurrentProcessDirectory ));
|
||||
break;
|
||||
|
||||
case 102: /////////////////////////////////////////////////////////// Communicator
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_CurrentProcessDirectory ));
|
||||
break;
|
||||
|
||||
case 103: /////////////////////////////////////////////////////////// User Pick
|
||||
// we should never be here.
|
||||
mFileSpec = nsnull;
|
||||
break;
|
||||
|
||||
case 104: /////////////////////////////////////////////////////////// Temporary
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_TemporaryDirectory ));
|
||||
break;
|
||||
|
||||
case 105: /////////////////////////////////////////////////////////// Installed
|
||||
// we should never be here.
|
||||
mFileSpec = nsnull;
|
||||
break;
|
||||
|
||||
case 106: /////////////////////////////////////////////////////////// Current User
|
||||
SetAppShellDirectory(nsSpecialFileSpec::App_UserProfileDirectory50 );
|
||||
break;
|
||||
|
||||
case 107: /////////////////////////////////////////////////////////// Preferences
|
||||
SetAppShellDirectory(nsSpecialFileSpec::App_PrefsDirectory50 );
|
||||
break;
|
||||
|
||||
case 108: /////////////////////////////////////////////////////////// OS Drive
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_DriveDirectory ));
|
||||
break;
|
||||
|
||||
case 109: /////////////////////////////////////////////////////////// File URL
|
||||
{
|
||||
nsString tempFileURLString = aFolderID;
|
||||
tempFileURLString += aRelativePath;
|
||||
mFileSpec = new nsFileSpec( nsFileURL(tempFileURLString) );
|
||||
}
|
||||
break;
|
||||
|
||||
case 110: /////////////////////////////////////////////////////////// Components
|
||||
SetAppShellDirectory(nsSpecialFileSpec::App_ComponentsDirectory );
|
||||
break;
|
||||
|
||||
case 111: /////////////////////////////////////////////////////////// Chrome
|
||||
SetAppShellDirectory(nsSpecialFileSpec::App_ChromeDirectory );
|
||||
break;
|
||||
|
||||
case 200: /////////////////////////////////////////////////////////// Win System
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Win_SystemDirectory ));
|
||||
break;
|
||||
|
||||
case 201: /////////////////////////////////////////////////////////// Windows
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Win_WindowsDirectory ));
|
||||
break;
|
||||
|
||||
case 300: /////////////////////////////////////////////////////////// Mac System
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_SystemDirectory ));
|
||||
break;
|
||||
|
||||
case 301: /////////////////////////////////////////////////////////// Mac Desktop
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_DesktopDirectory ));
|
||||
break;
|
||||
|
||||
case 302: /////////////////////////////////////////////////////////// Mac Trash
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_TrashDirectory ));
|
||||
break;
|
||||
|
||||
case 303: /////////////////////////////////////////////////////////// Mac Startup
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_StartupDirectory ));
|
||||
break;
|
||||
|
||||
case 304: /////////////////////////////////////////////////////////// Mac Shutdown
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_StartupDirectory ));
|
||||
break;
|
||||
|
||||
case 305: /////////////////////////////////////////////////////////// Mac Apple Menu
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_AppleMenuDirectory ));
|
||||
break;
|
||||
|
||||
case 306: /////////////////////////////////////////////////////////// Mac Control Panel
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_ControlPanelDirectory ));
|
||||
break;
|
||||
|
||||
case 307: /////////////////////////////////////////////////////////// Mac Extension
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_ExtensionDirectory ));
|
||||
break;
|
||||
|
||||
case 308: /////////////////////////////////////////////////////////// Mac Fonts
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_FontsDirectory ));
|
||||
break;
|
||||
|
||||
case 309: /////////////////////////////////////////////////////////// Mac Preferences
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_PreferencesDirectory ));
|
||||
break;
|
||||
|
||||
case 310: /////////////////////////////////////////////////////////// Mac Documents
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_DocumentsDirectory ));
|
||||
break;
|
||||
|
||||
case 400: /////////////////////////////////////////////////////////// Unix Local
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Unix_LocalDirectory ));
|
||||
break;
|
||||
|
||||
case 401: /////////////////////////////////////////////////////////// Unix Lib
|
||||
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Unix_LibDirectory ));
|
||||
break;
|
||||
|
||||
|
||||
case -1:
|
||||
default:
|
||||
mFileSpec = nsnull;
|
||||
return;
|
||||
}
|
||||
#ifndef XP_MAC
|
||||
if (aRelativePath.Length() > 0)
|
||||
{
|
||||
nsString tempPath(aRelativePath);
|
||||
|
||||
if (aRelativePath.Last() != '/' || aRelativePath.Last() != '\\')
|
||||
tempPath += '/';
|
||||
|
||||
*mFileSpec += tempPath;
|
||||
}
|
||||
#endif
|
||||
// make sure that the directory is created.
|
||||
nsFileSpec(mFileSpec->GetCString(), PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void nsInstallFolder::PickDefaultDirectory()
|
||||
{
|
||||
//FIX: Need to put up a dialog here and set mFileSpec
|
||||
return;
|
||||
}
|
||||
|
||||
/* MapNameToEnum
|
||||
* maps name from the directory table to its enum */
|
||||
PRInt32
|
||||
nsInstallFolder::MapNameToEnum(const nsString& name)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if ( name == "null")
|
||||
return -1;
|
||||
|
||||
while ( DirectoryTable[i].directoryName[0] != 0 )
|
||||
{
|
||||
if ( name.EqualsIgnoreCase(DirectoryTable[i].directoryName) )
|
||||
return DirectoryTable[i].folderEnum;
|
||||
i++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kFileLocatorIID, NS_IFILELOCATOR_IID);
|
||||
static NS_DEFINE_IID(kFileLocatorCID, NS_FILELOCATOR_CID);
|
||||
|
||||
void
|
||||
nsInstallFolder::SetAppShellDirectory(PRUint32 value)
|
||||
{
|
||||
nsIFileLocator * appShellLocator;
|
||||
|
||||
nsresult rv = nsComponentManager::CreateInstance(kFileLocatorCID,
|
||||
nsnull,
|
||||
kFileLocatorIID,
|
||||
(void**) &appShellLocator);
|
||||
|
||||
if ( NS_SUCCEEDED(rv) )
|
||||
{
|
||||
mFileSpec = new nsFileSpec();
|
||||
appShellLocator->GetFileLocation(value, mFileSpec);
|
||||
NS_RELEASE(appShellLocator);
|
||||
}
|
||||
}
|
||||
58
mozilla/xpinstall/src/nsInstallFolder.h
Normal file
58
mozilla/xpinstall/src/nsInstallFolder.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __NS_INSTALLFOLDER_H__
|
||||
#define __NS_INSTALLFOLDER_H__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "prtypes.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
class nsInstallFolder
|
||||
{
|
||||
public:
|
||||
|
||||
nsInstallFolder(const nsString& aFolderID);
|
||||
nsInstallFolder(const nsString& aFolderID, const nsString& aRelativePath);
|
||||
virtual ~nsInstallFolder();
|
||||
|
||||
void GetDirectoryPath(nsString& aDirectoryPath);
|
||||
|
||||
private:
|
||||
|
||||
nsFileSpec* mFileSpec;
|
||||
|
||||
void SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath);
|
||||
void PickDefaultDirectory();
|
||||
PRInt32 MapNameToEnum(const nsString& name);
|
||||
void SetAppShellDirectory(PRUint32 value);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
52
mozilla/xpinstall/src/nsInstallObject.h
Normal file
52
mozilla/xpinstall/src/nsInstallObject.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsInstallObject_h__
|
||||
#define nsInstallObject_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
class nsInstall;
|
||||
|
||||
class nsInstallObject
|
||||
{
|
||||
public:
|
||||
/* Public Methods */
|
||||
nsInstallObject(nsInstall* inInstall) {mInstall = inInstall; }
|
||||
|
||||
/* Override with your set-up action */
|
||||
virtual PRInt32 Prepare() = 0;
|
||||
|
||||
/* Override with your Completion action */
|
||||
virtual PRInt32 Complete() = 0;
|
||||
|
||||
/* Override with an explanatory string for the progress dialog */
|
||||
virtual char* toString() = 0;
|
||||
|
||||
/* Override with your clean-up function */
|
||||
virtual void Abort() = 0;
|
||||
|
||||
/* should these be protected? */
|
||||
virtual PRBool CanUninstall() = 0;
|
||||
virtual PRBool RegisterPackageNode() = 0;
|
||||
|
||||
protected:
|
||||
nsInstall* mInstall;
|
||||
};
|
||||
|
||||
#endif /* nsInstallObject_h__ */
|
||||
986
mozilla/xpinstall/src/nsInstallPatch.cpp
Normal file
986
mozilla/xpinstall/src/nsInstallPatch.cpp
Normal file
@@ -0,0 +1,986 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
#include "prmem.h"
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallPatch.h"
|
||||
#include "nsInstallResources.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
#include "zlib.h"
|
||||
|
||||
#include "gdiff.h"
|
||||
|
||||
#include "VerReg.h"
|
||||
#include "ScheduledTasks.h"
|
||||
#include "plstr.h"
|
||||
#include "xp_file.h" /* for XP_PlatformFileToURL */
|
||||
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include "PatchableAppleSingle.h"
|
||||
#endif
|
||||
|
||||
#define BUFSIZE 32768
|
||||
#define OPSIZE 1
|
||||
#define MAXCMDSIZE 12
|
||||
#define SRCFILE 0
|
||||
#define OUTFILE 1
|
||||
|
||||
#define getshort(s) (uint16)( ((uchar)*(s) << 8) + ((uchar)*((s)+1)) )
|
||||
|
||||
#define getlong(s) \
|
||||
(uint32)( ((uchar)*(s) << 24) + ((uchar)*((s)+1) << 16 ) + \
|
||||
((uchar)*((s)+2) << 8) + ((uchar)*((s)+3)) )
|
||||
|
||||
|
||||
|
||||
static int32 gdiff_parseHeader( pDIFFDATA dd );
|
||||
static int32 gdiff_validateFile( pDIFFDATA dd, int file );
|
||||
static int32 gdiff_valCRC32( pDIFFDATA dd, PRFileDesc* fh, uint32 chksum );
|
||||
static int32 gdiff_ApplyPatch( pDIFFDATA dd );
|
||||
static int32 gdiff_getdiff( pDIFFDATA dd, uchar *buffer, uint32 length );
|
||||
static int32 gdiff_add( pDIFFDATA dd, uint32 count );
|
||||
static int32 gdiff_copy( pDIFFDATA dd, uint32 position, uint32 count );
|
||||
static int32 gdiff_validateFile( pDIFFDATA dd, int file );
|
||||
|
||||
|
||||
nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
|
||||
const nsString& inVRName,
|
||||
const nsString& inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
PRInt32 *error)
|
||||
|
||||
: nsInstallObject(inInstall)
|
||||
{
|
||||
char tempTargetFile[MAXREGPATHLEN];
|
||||
char* tempVersionString = inVRName.ToNewCString();
|
||||
|
||||
PRInt32 err = VR_GetPath(tempVersionString, MAXREGPATHLEN, tempTargetFile );
|
||||
|
||||
delete [] tempVersionString;
|
||||
|
||||
if (err != REGERR_OK)
|
||||
{
|
||||
*error = nsInstall::NO_SUCH_COMPONENT;
|
||||
return;
|
||||
}
|
||||
nsString folderSpec(tempTargetFile);
|
||||
|
||||
mPatchFile = nsnull;
|
||||
mTargetFile = nsnull;
|
||||
mPatchedFile = nsnull;
|
||||
mRegistryName = new nsString(inVRName);
|
||||
mJarLocation = new nsString(inJarLocation);
|
||||
mTargetFile = new nsFileSpec(folderSpec);
|
||||
|
||||
mVersionInfo = new nsInstallVersion();
|
||||
|
||||
mVersionInfo->Init(inVInfo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
|
||||
const nsString& inVRName,
|
||||
const nsString& inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRInt32 *error)
|
||||
|
||||
: nsInstallObject(inInstall)
|
||||
{
|
||||
if ((inInstall == nsnull) || (inVRName == "null") || (inJarLocation == "null"))
|
||||
{
|
||||
*error = nsInstall::INVALID_ARGUMENTS;
|
||||
return;
|
||||
}
|
||||
|
||||
mPatchFile = nsnull;
|
||||
mTargetFile = nsnull;
|
||||
mPatchedFile = nsnull;
|
||||
mRegistryName = new nsString(inVRName);
|
||||
mJarLocation = new nsString(inJarLocation);
|
||||
mVersionInfo = new nsInstallVersion();
|
||||
|
||||
mVersionInfo->Init(inVInfo);
|
||||
|
||||
mTargetFile = new nsFileSpec(folderSpec);
|
||||
if(inPartialPath != "null")
|
||||
*mTargetFile += inPartialPath;
|
||||
}
|
||||
|
||||
nsInstallPatch::~nsInstallPatch()
|
||||
{
|
||||
if (mVersionInfo)
|
||||
delete mVersionInfo;
|
||||
|
||||
if (mTargetFile)
|
||||
delete mTargetFile;
|
||||
|
||||
if (mJarLocation)
|
||||
delete mJarLocation;
|
||||
|
||||
if (mRegistryName)
|
||||
delete mRegistryName;
|
||||
|
||||
if (mPatchedFile)
|
||||
delete mPatchedFile;
|
||||
|
||||
if (mPatchFile)
|
||||
delete mPatchFile;
|
||||
|
||||
}
|
||||
|
||||
|
||||
PRInt32 nsInstallPatch::Prepare()
|
||||
{
|
||||
PRInt32 err;
|
||||
PRBool deleteOldSrc;
|
||||
|
||||
if (mTargetFile == nsnull)
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
|
||||
if (mTargetFile->Exists())
|
||||
{
|
||||
if (mTargetFile->IsFile())
|
||||
{
|
||||
err = nsInstall::SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = nsInstall::FILE_IS_DIRECTORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
err = nsInstall::FILE_DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
if (err != nsInstall::SUCCESS)
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
err = mInstall->ExtractFileFromJar(*mJarLocation, mTargetFile, &mPatchFile);
|
||||
|
||||
|
||||
nsFileSpec *fileName = nsnull;
|
||||
nsVoidKey ikey( HashFilePath( nsFilePath(*mTargetFile) ) );
|
||||
|
||||
mInstall->GetPatch(&ikey, fileName);
|
||||
|
||||
if (fileName != nsnull)
|
||||
{
|
||||
deleteOldSrc = PR_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = mTargetFile;
|
||||
deleteOldSrc = PR_FALSE;
|
||||
}
|
||||
|
||||
err = NativePatch( *fileName, // the file to patch
|
||||
*mPatchFile, // the patch that was extracted from the jarfile
|
||||
&mPatchedFile); // the new patched file
|
||||
|
||||
if (err != nsInstall::SUCCESS)
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
PR_ASSERT(mPatchedFile != nsnull);
|
||||
mInstall->AddPatch(&ikey, mPatchedFile );
|
||||
|
||||
if ( deleteOldSrc )
|
||||
{
|
||||
DeleteFileNowOrSchedule(*fileName );
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
PRInt32 nsInstallPatch::Complete()
|
||||
{
|
||||
if ((mInstall == nsnull) || (mVersionInfo == nsnull) || (mPatchedFile == nsnull) || (mTargetFile == nsnull))
|
||||
{
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
PRInt32 err = nsInstall::SUCCESS;
|
||||
|
||||
nsFileSpec *fileName = nsnull;
|
||||
nsVoidKey ikey( HashFilePath( nsFilePath(*mTargetFile) ) );
|
||||
|
||||
mInstall->GetPatch(&ikey, fileName);
|
||||
|
||||
if (fileName != nsnull && (*fileName == *mPatchedFile) )
|
||||
{
|
||||
// the patch has not been superceded--do final replacement
|
||||
err = ReplaceFileNowOrSchedule( *mTargetFile, *mPatchedFile);
|
||||
if ( 0 == err || nsInstall::REBOOT_NEEDED == err )
|
||||
{
|
||||
nsString tempVersionString;
|
||||
mVersionInfo->ToString(tempVersionString);
|
||||
|
||||
char* tempRegName = mRegistryName->ToNewCString();
|
||||
char* tempVersion = tempVersionString.ToNewCString();
|
||||
|
||||
err = VR_Install( tempRegName,
|
||||
(char*) (const char *) nsNSPRPath(*mTargetFile),
|
||||
tempVersion,
|
||||
PR_FALSE );
|
||||
|
||||
delete [] tempRegName;
|
||||
delete [] tempVersion;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
err = nsInstall::UNEXPECTED_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// nothing -- old intermediate patched file was
|
||||
// deleted by a superceding patch
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void nsInstallPatch::Abort()
|
||||
{
|
||||
nsFileSpec *fileName = nsnull;
|
||||
nsVoidKey ikey( HashFilePath( nsFilePath(*mTargetFile) ) );
|
||||
|
||||
mInstall->GetPatch(&ikey, fileName);
|
||||
|
||||
if (fileName != nsnull && (*fileName == *mPatchedFile) )
|
||||
{
|
||||
DeleteFileNowOrSchedule( *mPatchedFile );
|
||||
}
|
||||
}
|
||||
|
||||
char* nsInstallPatch::toString()
|
||||
{
|
||||
char* buffer = new char[1024];
|
||||
|
||||
// FIX! sprintf( buffer, nsInstallResources::GetPatchFileString(), mPatchedFile->GetCString());
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsInstallPatch::CanUninstall()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsInstallPatch::RegisterPackageNode()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
PRInt32
|
||||
nsInstallPatch::NativePatch(const nsFileSpec &sourceFile, const nsFileSpec &patchFile, nsFileSpec **newFile)
|
||||
{
|
||||
|
||||
DIFFDATA *dd;
|
||||
PRInt32 status = GDIFF_ERR_MEM;
|
||||
char *tmpurl = NULL;
|
||||
char *realfile = PL_strdup(nsNSPRPath(sourceFile)); // needs to be sourceFile!!!
|
||||
nsFileSpec outFileSpec = sourceFile;
|
||||
|
||||
dd = (DIFFDATA *)PR_Calloc( 1, sizeof(DIFFDATA));
|
||||
if (dd != NULL)
|
||||
{
|
||||
dd->databuf = (uchar*)PR_Malloc(BUFSIZE);
|
||||
if (dd->databuf == NULL)
|
||||
{
|
||||
status = GDIFF_ERR_MEM;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
dd->bufsize = BUFSIZE;
|
||||
|
||||
// validate patch header & check for special instructions
|
||||
dd->fDiff = PR_Open (nsNSPRPath(patchFile), PR_RDONLY, 0666);
|
||||
|
||||
|
||||
if (dd->fDiff != NULL)
|
||||
{
|
||||
status = gdiff_parseHeader(dd);
|
||||
} else {
|
||||
status = GDIFF_ERR_ACCESS;
|
||||
}
|
||||
|
||||
#ifdef dono
|
||||
#ifdef WIN32
|
||||
|
||||
/* unbind Win32 images */
|
||||
if ( dd->bWin32BoundImage && status == GDIFF_OK ) {
|
||||
tmpurl = WH_TempName( xpURL, NULL );
|
||||
if ( tmpurl != NULL ) {
|
||||
if (su_unbind( srcfile, srctype, tmpurl, xpURL ))
|
||||
{
|
||||
PL_strfree(realfile);
|
||||
realfile = tmpurl;
|
||||
realtype = xpURL;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
status = GDIFF_ERR_MEM;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
||||
if ( dd->bMacAppleSingle && status == GDIFF_OK )
|
||||
{
|
||||
// create a tmp file, so that we can AppleSingle the src file
|
||||
nsSpecialSystemDirectory tempMacFile(nsSpecialSystemDirectory::OS_TemporaryDirectory);
|
||||
nsString srcName = sourceFile.GetLeafName();
|
||||
tempMacFile.SetLeafName(srcName);
|
||||
tempMacFile.MakeUnique();
|
||||
|
||||
// Encode!
|
||||
// Encode src file, and put into temp file
|
||||
FSSpec sourceSpec = sourceFile.GetFSSpec();
|
||||
FSSpec tempSpec = tempMacFile.GetFSSpec();
|
||||
|
||||
status = PAS_EncodeFile(&sourceSpec, &tempSpec);
|
||||
|
||||
if (status == noErr)
|
||||
{
|
||||
// set
|
||||
PL_strfree(realfile);
|
||||
realfile = PL_strdup(nsNSPRPath(tempMacFile));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (status != NS_OK)
|
||||
goto cleanup;
|
||||
|
||||
// make a unique file at the same location of our source file (FILENAME-ptch.EXT)
|
||||
nsString patchFileName = "-ptch";
|
||||
nsString newFileName = sourceFile.GetLeafName();
|
||||
|
||||
PRInt32 index;
|
||||
if ((index = newFileName.RFind(".")) > 0)
|
||||
{
|
||||
nsString extention;
|
||||
nsString fileName;
|
||||
newFileName.Right(extention, (newFileName.Length() - index) );
|
||||
newFileName.Left(fileName, (newFileName.Length() - (newFileName.Length() - index)));
|
||||
newFileName = fileName + patchFileName + extention;
|
||||
|
||||
} else {
|
||||
newFileName += patchFileName;
|
||||
}
|
||||
|
||||
|
||||
outFileSpec.SetLeafName(newFileName); //????
|
||||
outFileSpec.MakeUnique();
|
||||
|
||||
char *outFile = PL_strdup(nsNSPRPath(outFileSpec));
|
||||
|
||||
// apply patch to the source file
|
||||
dd->fSrc = PR_Open ( realfile, PR_RDONLY, 0666);
|
||||
dd->fOut = PR_Open ( outFile, PR_RDWR|PR_CREATE_FILE|PR_TRUNCATE, 0666);
|
||||
|
||||
if (dd->fSrc != NULL && dd->fOut != NULL)
|
||||
{
|
||||
status = gdiff_validateFile (dd, SRCFILE);
|
||||
|
||||
// specify why diff failed
|
||||
if (status == GDIFF_ERR_CHECKSUM)
|
||||
status = GDIFF_ERR_CHECKSUM_TARGET;
|
||||
|
||||
if (status == GDIFF_OK)
|
||||
status = gdiff_ApplyPatch(dd);
|
||||
|
||||
if (status == GDIFF_OK)
|
||||
status = gdiff_validateFile (dd, OUTFILE);
|
||||
|
||||
if (status == GDIFF_ERR_CHECKSUM)
|
||||
status = GDIFF_ERR_CHECKSUM_RESULT;
|
||||
|
||||
if (status == GDIFF_OK)
|
||||
{
|
||||
*newFile = &outFileSpec;
|
||||
if ( outFile != nsnull)
|
||||
PL_strfree( outFile );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
status = GDIFF_ERR_ACCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef XP_MAC
|
||||
if ( dd->bMacAppleSingle && status == GDIFF_OK )
|
||||
{
|
||||
// create another file, so that we can decode somewhere
|
||||
nsFileSpec anotherName = outFileSpec;
|
||||
anotherName.MakeUnique();
|
||||
|
||||
// Close the out file so that we can read it
|
||||
PR_Close( dd->fOut );
|
||||
dd->fOut = NULL;
|
||||
|
||||
|
||||
FSSpec outSpec = outFileSpec.GetFSSpec();
|
||||
FSSpec anotherSpec = anotherName.GetFSSpec();
|
||||
|
||||
|
||||
status = PAS_DecodeFile(&outSpec, &anotherSpec);
|
||||
if (status != noErr)
|
||||
{
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
nsFileSpec parent;
|
||||
|
||||
outFileSpec.GetParent(parent);
|
||||
|
||||
outFileSpec.Delete(PR_FALSE);
|
||||
anotherName.Copy(parent);
|
||||
|
||||
*newFile = &anotherName;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
cleanup:
|
||||
if ( dd != NULL )
|
||||
{
|
||||
if ( dd->fSrc != nsnull )
|
||||
PR_Close( dd->fSrc );
|
||||
|
||||
|
||||
if ( dd->fDiff != nsnull )
|
||||
PR_Close( dd->fDiff );
|
||||
|
||||
if ( dd->fOut != nsnull )
|
||||
{
|
||||
PR_Close( dd->fOut );
|
||||
}
|
||||
|
||||
if ( status != GDIFF_OK )
|
||||
//XP_FileRemove( outfile, outtype );
|
||||
newFile = NULL;
|
||||
|
||||
PR_FREEIF( dd->databuf );
|
||||
PR_FREEIF( dd->oldChecksum );
|
||||
PR_FREEIF( dd->newChecksum );
|
||||
PR_DELETE(dd);
|
||||
}
|
||||
|
||||
if ( tmpurl != NULL ) {
|
||||
//XP_FileRemove( tmpurl, xpURL );
|
||||
tmpurl = NULL;
|
||||
PR_DELETE( tmpurl );
|
||||
}
|
||||
|
||||
/* lets map any GDIFF error to nice SU errors */
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case GDIFF_OK:
|
||||
break;
|
||||
case GDIFF_ERR_HEADER:
|
||||
case GDIFF_ERR_BADDIFF:
|
||||
case GDIFF_ERR_OPCODE:
|
||||
case GDIFF_ERR_CHKSUMTYPE:
|
||||
status = nsInstall::PATCH_BAD_DIFF;
|
||||
break;
|
||||
case GDIFF_ERR_CHECKSUM_TARGET:
|
||||
status = nsInstall::PATCH_BAD_CHECKSUM_TARGET;
|
||||
break;
|
||||
case GDIFF_ERR_CHECKSUM_RESULT:
|
||||
status = nsInstall::PATCH_BAD_CHECKSUM_RESULT;
|
||||
break;
|
||||
case GDIFF_ERR_OLDFILE:
|
||||
case GDIFF_ERR_ACCESS:
|
||||
case GDIFF_ERR_MEM:
|
||||
case GDIFF_ERR_UNKNOWN:
|
||||
default:
|
||||
status = nsInstall::UNEXPECTED_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
// return -1; //old return value
|
||||
}
|
||||
|
||||
|
||||
void*
|
||||
nsInstallPatch::HashFilePath(const nsFilePath& aPath)
|
||||
{
|
||||
PRUint32 rv = 0;
|
||||
|
||||
char* cPath = PL_strdup(nsNSPRPath(aPath));
|
||||
|
||||
if(cPath != nsnull)
|
||||
{
|
||||
char ch;
|
||||
char* filePath = PL_strdup(cPath);
|
||||
PRUint32 cnt=0;
|
||||
|
||||
while ((ch = *filePath++) != 0)
|
||||
{
|
||||
// FYI: rv = rv*37 + ch
|
||||
rv = ((rv << 5) + (rv << 2) + rv) + ch;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
for (PRUint32 i=0; i<=cnt; i++)
|
||||
*filePath--;
|
||||
PL_strfree(filePath);
|
||||
}
|
||||
|
||||
PL_strfree(cPath);
|
||||
|
||||
return (void*)rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------
|
||||
* gdiff_parseHeader()
|
||||
*
|
||||
* reads and validates the GDIFF header info
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int32 gdiff_parseHeader( pDIFFDATA dd )
|
||||
{
|
||||
int32 err = GDIFF_OK;
|
||||
uint8 cslen;
|
||||
uint8 oldcslen;
|
||||
uint8 newcslen;
|
||||
uint32 nRead;
|
||||
uchar header[GDIFF_HEADERSIZE];
|
||||
|
||||
/* Read the fixed-size part of the header */
|
||||
|
||||
nRead = PR_Read (dd->fDiff, header, GDIFF_HEADERSIZE);
|
||||
if ( nRead != GDIFF_HEADERSIZE ||
|
||||
memcmp( header, GDIFF_MAGIC, GDIFF_MAGIC_LEN ) != 0 ||
|
||||
header[GDIFF_VER_POS] != GDIFF_VER )
|
||||
{
|
||||
err = GDIFF_ERR_HEADER;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get the checksum information */
|
||||
|
||||
dd->checksumType = header[GDIFF_CS_POS];
|
||||
cslen = header[GDIFF_CSLEN_POS];
|
||||
|
||||
if ( cslen > 0 )
|
||||
{
|
||||
oldcslen = cslen / 2;
|
||||
newcslen = cslen - oldcslen;
|
||||
PR_ASSERT( newcslen == oldcslen );
|
||||
|
||||
dd->checksumLength = oldcslen;
|
||||
dd->oldChecksum = (uchar*)PR_MALLOC(oldcslen);
|
||||
dd->newChecksum = (uchar*)PR_MALLOC(newcslen);
|
||||
|
||||
if ( dd->oldChecksum != NULL && dd->newChecksum != NULL )
|
||||
{
|
||||
nRead = PR_Read (dd->fDiff, dd->oldChecksum, oldcslen);
|
||||
if ( nRead == oldcslen )
|
||||
{
|
||||
nRead = PR_Read (dd->fDiff, dd->newChecksum, newcslen);
|
||||
if ( nRead != newcslen ) {
|
||||
err = GDIFF_ERR_HEADER;
|
||||
}
|
||||
}
|
||||
else {
|
||||
err = GDIFF_ERR_HEADER;
|
||||
}
|
||||
}
|
||||
else {
|
||||
err = GDIFF_ERR_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* get application data, if any */
|
||||
|
||||
if ( err == GDIFF_OK )
|
||||
{
|
||||
uint32 appdataSize;
|
||||
uchar *buf;
|
||||
uchar lenbuf[GDIFF_APPDATALEN];
|
||||
|
||||
nRead = PR_Read(dd->fDiff, lenbuf, GDIFF_APPDATALEN);
|
||||
if ( nRead == GDIFF_APPDATALEN )
|
||||
{
|
||||
appdataSize = getlong(lenbuf);
|
||||
|
||||
if ( appdataSize > 0 )
|
||||
{
|
||||
buf = (uchar *)PR_MALLOC( appdataSize );
|
||||
|
||||
if ( buf != NULL )
|
||||
{
|
||||
nRead = PR_Read (dd->fDiff, buf, appdataSize);
|
||||
if ( nRead == appdataSize )
|
||||
{
|
||||
if ( 0 == memcmp( buf, APPFLAG_W32BOUND, appdataSize ) )
|
||||
dd->bWin32BoundImage = TRUE;
|
||||
|
||||
if ( 0 == memcmp( buf, APPFLAG_APPLESINGLE, appdataSize ) )
|
||||
dd->bMacAppleSingle = TRUE;
|
||||
}
|
||||
else {
|
||||
err = GDIFF_ERR_HEADER;
|
||||
}
|
||||
|
||||
PR_DELETE( buf );
|
||||
}
|
||||
else {
|
||||
err = GDIFF_ERR_MEM;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
err = GDIFF_ERR_HEADER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------
|
||||
* gdiff_validateFile()
|
||||
*
|
||||
* computes the checksum of the file and compares it to
|
||||
* the value stored in the GDIFF header
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int32 gdiff_validateFile( pDIFFDATA dd, int file )
|
||||
{
|
||||
int32 result;
|
||||
PRFileDesc* fh;
|
||||
uchar* chksum;
|
||||
|
||||
/* which file are we dealing with? */
|
||||
if ( file == SRCFILE ) {
|
||||
fh = dd->fSrc;
|
||||
chksum = dd->oldChecksum;
|
||||
}
|
||||
else { /* OUTFILE */
|
||||
fh = dd->fOut;
|
||||
chksum = dd->newChecksum;
|
||||
}
|
||||
|
||||
/* make sure file's at beginning */
|
||||
PR_Seek( fh, 0, PR_SEEK_SET );
|
||||
|
||||
/* calculate appropriate checksum */
|
||||
switch (dd->checksumType)
|
||||
{
|
||||
case GDIFF_CS_NONE:
|
||||
result = GDIFF_OK;
|
||||
break;
|
||||
|
||||
|
||||
case GDIFF_CS_CRC32:
|
||||
if ( dd->checksumLength == CRC32_LEN )
|
||||
result = gdiff_valCRC32( dd, fh, getlong(chksum) );
|
||||
else
|
||||
result = GDIFF_ERR_HEADER;
|
||||
break;
|
||||
|
||||
|
||||
case GDIFF_CS_MD5:
|
||||
|
||||
|
||||
case GDIFF_CS_SHA:
|
||||
|
||||
|
||||
default:
|
||||
/* unsupported checksum type */
|
||||
result = GDIFF_ERR_CHKSUMTYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* reset file position to beginning and return status */
|
||||
PR_Seek( fh, 0, PR_SEEK_SET );
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------
|
||||
* gdiff_valCRC32()
|
||||
*
|
||||
* computes the checksum of the file and compares it to
|
||||
* the passed in checksum. Assumes file is positioned at
|
||||
* beginning.
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int32 gdiff_valCRC32( pDIFFDATA dd, PRFileDesc* fh, uint32 chksum )
|
||||
{
|
||||
uint32 crc;
|
||||
uint32 nRead;
|
||||
|
||||
crc = crc32(0L, Z_NULL, 0);
|
||||
|
||||
nRead = PR_Read (fh, dd->databuf, dd->bufsize);
|
||||
while ( nRead > 0 )
|
||||
{
|
||||
crc = crc32( crc, dd->databuf, nRead );
|
||||
nRead = PR_Read (fh, dd->databuf, dd->bufsize);
|
||||
}
|
||||
|
||||
if ( crc == chksum )
|
||||
return GDIFF_OK;
|
||||
else
|
||||
return GDIFF_ERR_CHECKSUM;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------
|
||||
* gdiff_ApplyPatch()
|
||||
*
|
||||
* Combines patch data with source file to produce the
|
||||
* new target file. Assumes all three files have been
|
||||
* opened, GDIFF header read, and all other setup complete
|
||||
*
|
||||
* The GDIFF patch is processed sequentially which random
|
||||
* access is neccessary for the source file.
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int32 gdiff_ApplyPatch( pDIFFDATA dd )
|
||||
{
|
||||
int32 err;
|
||||
XP_Bool done;
|
||||
uint32 position;
|
||||
uint32 count;
|
||||
uchar opcode;
|
||||
uchar cmdbuf[MAXCMDSIZE];
|
||||
|
||||
done = FALSE;
|
||||
while ( !done ) {
|
||||
err = gdiff_getdiff( dd, &opcode, OPSIZE );
|
||||
if ( err != GDIFF_OK )
|
||||
break;
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case ENDDIFF:
|
||||
done = TRUE;
|
||||
break;
|
||||
|
||||
case ADD16:
|
||||
err = gdiff_getdiff( dd, cmdbuf, ADD16SIZE );
|
||||
if ( err == GDIFF_OK ) {
|
||||
err = gdiff_add( dd, getshort( cmdbuf ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case ADD32:
|
||||
err = gdiff_getdiff( dd, cmdbuf, ADD32SIZE );
|
||||
if ( err == GDIFF_OK ) {
|
||||
err = gdiff_add( dd, getlong( cmdbuf ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY16BYTE:
|
||||
err = gdiff_getdiff( dd, cmdbuf, COPY16BYTESIZE );
|
||||
if ( err == GDIFF_OK ) {
|
||||
position = getshort( cmdbuf );
|
||||
count = *(cmdbuf + sizeof(short));
|
||||
err = gdiff_copy( dd, position, count );
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY16SHORT:
|
||||
err = gdiff_getdiff( dd, cmdbuf, COPY16SHORTSIZE );
|
||||
if ( err == GDIFF_OK ) {
|
||||
position = getshort( cmdbuf );
|
||||
count = getshort(cmdbuf + sizeof(short));
|
||||
err = gdiff_copy( dd, position, count );
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY16LONG:
|
||||
err = gdiff_getdiff( dd, cmdbuf, COPY16LONGSIZE );
|
||||
if ( err == GDIFF_OK ) {
|
||||
position = getshort( cmdbuf );
|
||||
count = getlong(cmdbuf + sizeof(short));
|
||||
err = gdiff_copy( dd, position, count );
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY32BYTE:
|
||||
err = gdiff_getdiff( dd, cmdbuf, COPY32BYTESIZE );
|
||||
if ( err == GDIFF_OK ) {
|
||||
position = getlong( cmdbuf );
|
||||
count = *(cmdbuf + sizeof(long));
|
||||
err = gdiff_copy( dd, position, count );
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY32SHORT:
|
||||
err = gdiff_getdiff( dd, cmdbuf, COPY32SHORTSIZE );
|
||||
if ( err == GDIFF_OK ) {
|
||||
position = getlong( cmdbuf );
|
||||
count = getshort(cmdbuf + sizeof(long));
|
||||
err = gdiff_copy( dd, position, count );
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY32LONG:
|
||||
err = gdiff_getdiff( dd, cmdbuf, COPY32LONGSIZE );
|
||||
if ( err == GDIFF_OK ) {
|
||||
position = getlong( cmdbuf );
|
||||
count = getlong(cmdbuf + sizeof(long));
|
||||
err = gdiff_copy( dd, position, count );
|
||||
}
|
||||
break;
|
||||
|
||||
case COPY64:
|
||||
/* we don't support 64-bit file positioning yet */
|
||||
err = GDIFF_ERR_OPCODE;
|
||||
break;
|
||||
|
||||
default:
|
||||
err = gdiff_add( dd, opcode );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( err != GDIFF_OK )
|
||||
done = TRUE;
|
||||
}
|
||||
|
||||
/* return status */
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------
|
||||
* gdiff_getdiff()
|
||||
*
|
||||
* reads the next "length" bytes of the diff into "buffer"
|
||||
*
|
||||
* XXX: need a diff buffer to optimize reads!
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int32 gdiff_getdiff( pDIFFDATA dd, uchar *buffer, uint32 length )
|
||||
{
|
||||
uint32 bytesRead;
|
||||
|
||||
bytesRead = PR_Read (dd->fDiff, buffer, length);
|
||||
if ( bytesRead != length )
|
||||
return GDIFF_ERR_BADDIFF;
|
||||
|
||||
return GDIFF_OK;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------
|
||||
* gdiff_add()
|
||||
*
|
||||
* append "count" bytes from diff file to new file
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int32 gdiff_add( pDIFFDATA dd, uint32 count )
|
||||
{
|
||||
int32 err = GDIFF_OK;
|
||||
uint32 nRead;
|
||||
uint32 chunksize;
|
||||
|
||||
while ( count > 0 ) {
|
||||
chunksize = ( count > dd->bufsize) ? dd->bufsize : count;
|
||||
nRead = PR_Read (dd->fDiff, dd->databuf, chunksize);
|
||||
if ( nRead != chunksize ) {
|
||||
err = GDIFF_ERR_BADDIFF;
|
||||
break;
|
||||
}
|
||||
|
||||
PR_Write (dd->fOut, dd->databuf, chunksize);
|
||||
|
||||
count -= chunksize;
|
||||
}
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------
|
||||
* gdiff_copy()
|
||||
*
|
||||
* copy "count" bytes from "position" in source file
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int32 gdiff_copy( pDIFFDATA dd, uint32 position, uint32 count )
|
||||
{
|
||||
int32 err = GDIFF_OK;
|
||||
uint32 nRead;
|
||||
uint32 chunksize;
|
||||
|
||||
PR_Seek (dd->fSrc, position, PR_SEEK_SET);
|
||||
|
||||
while ( count > 0 ) {
|
||||
chunksize = (count > dd->bufsize) ? dd->bufsize : count;
|
||||
|
||||
nRead = PR_Read (dd->fSrc, dd->databuf, chunksize);
|
||||
if ( nRead != chunksize ) {
|
||||
err = GDIFF_ERR_OLDFILE;
|
||||
break;
|
||||
}
|
||||
|
||||
PR_Write (dd->fOut, dd->databuf, chunksize);
|
||||
|
||||
count -= chunksize;
|
||||
}
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
79
mozilla/xpinstall/src/nsInstallPatch.h
Normal file
79
mozilla/xpinstall/src/nsInstallPatch.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsInstallPatch_h__
|
||||
#define nsInstallPatch_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsInstallObject.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallFolder.h"
|
||||
#include "nsInstallVersion.h"
|
||||
|
||||
|
||||
class nsInstallPatch : public nsInstallObject
|
||||
{
|
||||
public:
|
||||
|
||||
nsInstallPatch( nsInstall* inInstall,
|
||||
const nsString& inVRName,
|
||||
const nsString& inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRInt32 *error);
|
||||
|
||||
nsInstallPatch( nsInstall* inInstall,
|
||||
const nsString& inVRName,
|
||||
const nsString& inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
PRInt32 *error);
|
||||
|
||||
virtual ~nsInstallPatch();
|
||||
|
||||
PRInt32 Prepare();
|
||||
PRInt32 Complete();
|
||||
void Abort();
|
||||
char* toString();
|
||||
|
||||
PRBool CanUninstall();
|
||||
PRBool RegisterPackageNode();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
nsInstallVersion *mVersionInfo;
|
||||
|
||||
nsFileSpec *mTargetFile;
|
||||
nsFileSpec *mPatchFile;
|
||||
nsFileSpec *mPatchedFile;
|
||||
|
||||
nsString *mJarLocation;
|
||||
nsString *mRegistryName;
|
||||
|
||||
|
||||
|
||||
PRInt32 NativePatch(const nsFileSpec &sourceFile, const nsFileSpec &patchfile, nsFileSpec **newFile);
|
||||
void* HashFilePath(const nsFilePath& aPath);
|
||||
};
|
||||
|
||||
#endif /* nsInstallPatch_h__ */
|
||||
343
mozilla/xpinstall/src/nsInstallProgressDialog.cpp
Normal file
343
mozilla/xpinstall/src/nsInstallProgressDialog.cpp
Normal file
@@ -0,0 +1,343 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "nsIXPInstallProgress.h"
|
||||
#include "nsInstallProgressDialog.h"
|
||||
|
||||
#include "nsIAppShellComponentImpl.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsINetService.h"
|
||||
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID( kAppShellServiceCID, NS_APPSHELL_SERVICE_CID );
|
||||
static NS_DEFINE_IID( kNetServiceCID, NS_NETSERVICE_CID );
|
||||
|
||||
// Utility to set element attribute.
|
||||
static nsresult setAttribute( nsIDOMXULDocument *doc,
|
||||
const char *id,
|
||||
const char *name,
|
||||
const nsString &value ) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if ( doc ) {
|
||||
// Find specified element.
|
||||
nsCOMPtr<nsIDOMElement> elem;
|
||||
rv = doc->GetElementById( id, getter_AddRefs( elem ) );
|
||||
if ( elem ) {
|
||||
// Set the text attribute.
|
||||
rv = elem->SetAttribute( name, value );
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
} else {
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: SetAttribute failed, rv=0x%X\n",
|
||||
__FILE__, (int)__LINE__, (int)rv );
|
||||
}
|
||||
} else {
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: GetElementById failed, rv=0x%X\n",
|
||||
__FILE__, (int)__LINE__, (int)rv );
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// Utility to get element attribute.
|
||||
static nsresult getAttribute( nsIDOMXULDocument *doc,
|
||||
const char *id,
|
||||
const char *name,
|
||||
nsString &value ) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if ( doc ) {
|
||||
// Find specified element.
|
||||
nsCOMPtr<nsIDOMElement> elem;
|
||||
rv = doc->GetElementById( id, getter_AddRefs( elem ) );
|
||||
if ( elem ) {
|
||||
// Set the text attribute.
|
||||
rv = elem->GetAttribute( name, value );
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
} else {
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: SetAttribute failed, rv=0x%X\n",
|
||||
__FILE__, (int)__LINE__, (int)rv );
|
||||
}
|
||||
} else {
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: GetElementById failed, rv=0x%X\n",
|
||||
__FILE__, (int)__LINE__, (int)rv );
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsInstallProgressDialog::nsInstallProgressDialog()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mWindow = nsnull;
|
||||
mDocument = nsnull;
|
||||
|
||||
}
|
||||
|
||||
nsInstallProgressDialog::~nsInstallProgressDialog()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF( nsInstallProgressDialog );
|
||||
NS_IMPL_RELEASE( nsInstallProgressDialog );
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallProgressDialog::QueryInterface(REFNSIID aIID,void** aInstancePtr)
|
||||
{
|
||||
if (aInstancePtr == NULL) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(nsIXPInstallProgress::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsInstallProgressDialog*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsIXULWindowCallbacks::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIXULWindowCallbacks*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) (nsISupports*)((nsIXPInstallProgress*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallProgressDialog::BeforeJavascriptEvaluation()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get app shell service.
|
||||
nsIAppShellService *appShell;
|
||||
rv = nsServiceManager::GetService( kAppShellServiceCID,
|
||||
nsIAppShellService::GetIID(),
|
||||
(nsISupports**)&appShell );
|
||||
|
||||
if ( NS_SUCCEEDED( rv ) )
|
||||
{
|
||||
// Open "progress" dialog.
|
||||
nsIURL *url;
|
||||
rv = NS_NewURL( &url, "resource:/res/xpinstall/progress.xul" );
|
||||
|
||||
if ( NS_SUCCEEDED(rv) )
|
||||
{
|
||||
|
||||
nsIWebShellWindow *newWindow;
|
||||
|
||||
rv = appShell->CreateTopLevelWindow( nsnull,
|
||||
url,
|
||||
PR_TRUE,
|
||||
newWindow,
|
||||
nsnull,
|
||||
this, // callbacks??
|
||||
0,
|
||||
0 );
|
||||
|
||||
if ( NS_SUCCEEDED( rv ) )
|
||||
{
|
||||
mWindow = newWindow;
|
||||
NS_RELEASE( newWindow );
|
||||
|
||||
if (mWindow != nsnull)
|
||||
mWindow->Show(PR_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINTF( PR_STDOUT, "Error creating progress dialog, rv=0x%X\n", (int)rv );
|
||||
}
|
||||
NS_RELEASE( url );
|
||||
}
|
||||
|
||||
nsServiceManager::ReleaseService( kAppShellServiceCID, appShell );
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINTF( PR_STDOUT, "Unable to get app shell service, rv=0x%X\n", (int)rv );
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallProgressDialog::AfterJavascriptEvaluation()
|
||||
{
|
||||
if (mWindow)
|
||||
{
|
||||
mWindow->Close();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallProgressDialog::InstallStarted(const char *UIPackageName)
|
||||
{
|
||||
setAttribute( mDocument, "dialog.uiPackageName", "value", nsString(UIPackageName) );
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallProgressDialog::ItemScheduled(const char *message)
|
||||
{
|
||||
PRInt32 maxChars = 40;
|
||||
|
||||
nsString theMessage(message);
|
||||
PRInt32 len = theMessage.Length();
|
||||
if (len > maxChars)
|
||||
{
|
||||
PRInt32 offset = (len/2) - ((len - maxChars)/2);
|
||||
PRInt32 count = (len - maxChars);
|
||||
theMessage.Cut(offset, count);
|
||||
theMessage.Insert(nsString("..."), offset);
|
||||
}
|
||||
setAttribute( mDocument, "dialog.currentAction", "value", theMessage );
|
||||
|
||||
nsString aValue;
|
||||
getAttribute( mDocument, "data.canceled", "value", aValue );
|
||||
|
||||
if (aValue.EqualsIgnoreCase("true"))
|
||||
return -1;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallProgressDialog::InstallFinalization(const char *message, PRInt32 itemNum, PRInt32 totNum)
|
||||
{
|
||||
|
||||
PRInt32 maxChars = 40;
|
||||
|
||||
nsString theMessage(message);
|
||||
PRInt32 len = theMessage.Length();
|
||||
if (len > maxChars)
|
||||
{
|
||||
PRInt32 offset = (len/2) - ((len - maxChars)/2);
|
||||
PRInt32 count = (len - maxChars);
|
||||
theMessage.Cut(offset, count);
|
||||
theMessage.Insert(nsString("..."), offset);
|
||||
}
|
||||
|
||||
setAttribute( mDocument, "dialog.currentAction", "value", theMessage );
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
char buf[16];
|
||||
|
||||
PR_snprintf( buf, sizeof buf, "%lu", totNum );
|
||||
setAttribute( mDocument, "dialog.progress", "max", buf );
|
||||
|
||||
if (totNum != 0)
|
||||
{
|
||||
PR_snprintf( buf, sizeof buf, "%lu", ((totNum-itemNum)/totNum) );
|
||||
}
|
||||
else
|
||||
{
|
||||
PR_snprintf( buf, sizeof buf, "%lu", 0 );
|
||||
}
|
||||
setAttribute( mDocument, "dialog.progress", "value", buf );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallProgressDialog::InstallAborted()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Do startup stuff from C++ side.
|
||||
NS_IMETHODIMP
|
||||
nsInstallProgressDialog::ConstructBeforeJavaScript(nsIWebShell *aWebShell)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get content viewer from the web shell.
|
||||
nsCOMPtr<nsIContentViewer> contentViewer;
|
||||
rv = aWebShell ? aWebShell->GetContentViewer(getter_AddRefs(contentViewer))
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
|
||||
if ( contentViewer ) {
|
||||
// Up-cast to a document viewer.
|
||||
nsCOMPtr<nsIDocumentViewer> docViewer( do_QueryInterface( contentViewer, &rv ) );
|
||||
if ( docViewer ) {
|
||||
// Get the document from the doc viewer.
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
rv = docViewer->GetDocument(*getter_AddRefs(document));
|
||||
if ( document ) {
|
||||
// Upcast to XUL document.
|
||||
mDocument = do_QueryInterface( document, &rv );
|
||||
if ( ! mDocument )
|
||||
{
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: Upcast to nsIDOMXULDocument failed, rv=0x%X\n",
|
||||
__FILE__, (int)__LINE__, (int)rv );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: GetDocument failed, rv=0x%X\n",
|
||||
__FILE__, (int)__LINE__, (int)rv );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: Upcast to nsIDocumentViewer failed, rv=0x%X\n",
|
||||
__FILE__, (int)__LINE__, (int)rv );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINTF( PR_STDOUT, "%s %d: GetContentViewer failed, rv=0x%X\n",
|
||||
__FILE__, (int)__LINE__, (int)rv );
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
67
mozilla/xpinstall/src/nsInstallProgressDialog.h
Normal file
67
mozilla/xpinstall/src/nsInstallProgressDialog.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
#ifndef __nsInstallProgressDialog_h__
|
||||
#define __nsInstallProgressDialog_h__
|
||||
|
||||
#include "nsIXPInstallProgress.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIXULWindowCallbacks.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
|
||||
|
||||
class nsInstallProgressDialog : public nsIXPInstallProgress, public nsIXULWindowCallbacks
|
||||
{
|
||||
public:
|
||||
|
||||
nsInstallProgressDialog();
|
||||
virtual ~nsInstallProgressDialog();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
NS_IMETHOD BeforeJavascriptEvaluation();
|
||||
NS_IMETHOD AfterJavascriptEvaluation();
|
||||
NS_IMETHOD InstallStarted(const char *UIPackageName);
|
||||
NS_IMETHOD ItemScheduled(const char *message);
|
||||
NS_IMETHOD InstallFinalization(const char *message, PRInt32 itemNum, PRInt32 totNum);
|
||||
NS_IMETHOD InstallAborted();
|
||||
|
||||
// Declare implementations of nsIXULWindowCallbacks interface functions.
|
||||
NS_IMETHOD ConstructBeforeJavaScript(nsIWebShell *aWebShell);
|
||||
NS_IMETHOD ConstructAfterJavaScript(nsIWebShell *aWebShell) { return NS_OK; }
|
||||
|
||||
private:
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> mDocument;
|
||||
nsCOMPtr<nsIWebShellWindow> mWindow;
|
||||
};
|
||||
#endif
|
||||
67
mozilla/xpinstall/src/nsInstallResources.cpp
Normal file
67
mozilla/xpinstall/src/nsInstallResources.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsInstallResources.h"
|
||||
|
||||
char* nsInstallResources::GetInstallFileString(void)
|
||||
{
|
||||
return "Installing: %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetReplaceFileString(void)
|
||||
{
|
||||
return "Replacing %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetDeleteFileString(void)
|
||||
{
|
||||
return "Deleting file: %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetDeleteComponentString(void)
|
||||
{
|
||||
return "Deleting component: %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetExecuteString(void)
|
||||
{
|
||||
return "Executing: %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetExecuteWithArgsString(void)
|
||||
{
|
||||
return "Executing: %s with argument: %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetPatchFileString(void)
|
||||
{
|
||||
return "Patching: %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetUninstallString(void)
|
||||
{
|
||||
return "Uninstalling: %s";
|
||||
}
|
||||
|
||||
45
mozilla/xpinstall/src/nsInstallResources.h
Normal file
45
mozilla/xpinstall/src/nsInstallResources.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __NS_INSTALLRESOURCES_H__
|
||||
#define __NS_INSTALLRESOURCES_H__
|
||||
|
||||
class nsInstallResources
|
||||
{
|
||||
public:
|
||||
|
||||
static char* GetInstallFileString(void);
|
||||
static char* GetReplaceFileString(void);
|
||||
static char* GetDeleteFileString(void);
|
||||
static char* GetDeleteComponentString(void);
|
||||
static char* GetExecuteString(void);
|
||||
static char* GetExecuteWithArgsString(void);
|
||||
static char* GetPatchFileString(void);
|
||||
static char* GetUninstallString(void);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
359
mozilla/xpinstall/src/nsInstallTrigger.cpp
Normal file
359
mozilla/xpinstall/src/nsInstallTrigger.cpp
Normal file
@@ -0,0 +1,359 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nsSoftwareUpdate.h"
|
||||
#include "nsSoftwareUpdateStream.h"
|
||||
#include "nsInstallTrigger.h"
|
||||
#include "nsIDOMInstallTriggerGlobal.h"
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
|
||||
#include "nsRepository.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIInstallTrigger_IID, NS_IDOMINSTALLTRIGGERGLOBAL_IID);
|
||||
static NS_DEFINE_IID(kIInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
nsInstallTrigger::nsInstallTrigger()
|
||||
{
|
||||
mScriptObject = nsnull;
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsInstallTrigger::~nsInstallTrigger()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::QueryInterface(REFNSIID aIID,void** aInstancePtr)
|
||||
{
|
||||
if (aInstancePtr == NULL)
|
||||
{
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if ( aIID.Equals(kIScriptObjectOwnerIID))
|
||||
{
|
||||
*aInstancePtr = (void*) ((nsIScriptObjectOwner*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
else if ( aIID.Equals(kIInstallTrigger_IID) )
|
||||
{
|
||||
*aInstancePtr = (void*) ((nsIDOMInstallTriggerGlobal*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
else if ( aIID.Equals(kISupportsIID) )
|
||||
{
|
||||
*aInstancePtr = (void*)(nsISupports*)(nsIScriptObjectOwner*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsInstallTrigger)
|
||||
NS_IMPL_RELEASE(nsInstallTrigger)
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (nsnull == mScriptObject)
|
||||
{
|
||||
nsIScriptGlobalObject *global = aContext->GetGlobalObject();
|
||||
|
||||
res = NS_NewScriptInstallTriggerGlobal( aContext,
|
||||
(nsISupports *)(nsIDOMInstallTriggerGlobal*)this,
|
||||
(nsISupports *)global,
|
||||
&mScriptObject);
|
||||
NS_IF_RELEASE(global);
|
||||
|
||||
}
|
||||
|
||||
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kPrefsIID, NS_IPREF_IID);
|
||||
static NS_DEFINE_IID(kPrefsCID, NS_PREF_CID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::UpdateEnabled(PRBool* aReturn)
|
||||
{
|
||||
nsIPref * prefs;
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(kPrefsCID,
|
||||
kPrefsIID,
|
||||
(nsISupports**) &prefs);
|
||||
|
||||
|
||||
if ( NS_SUCCEEDED(rv) )
|
||||
{
|
||||
rv = prefs->GetBoolPref( (const char*) AUTOUPDATE_ENABLE_PREF, aReturn);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
*aReturn = PR_FALSE;
|
||||
}
|
||||
|
||||
NS_RELEASE(prefs);
|
||||
}
|
||||
else
|
||||
{
|
||||
*aReturn = PR_FALSE; /* no prefs manager. set to false */
|
||||
}
|
||||
|
||||
//FIX!!!!!!!!!!
|
||||
*aReturn = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::StartSoftwareUpdate(const nsString& aURL, PRInt32 aFlags, PRInt32* aReturn)
|
||||
{
|
||||
nsString localFile;
|
||||
CreateTempFileFromURL(aURL, localFile);
|
||||
|
||||
// start the download (this will clean itself up)
|
||||
nsSoftwareUpdateListener *downloader = new nsSoftwareUpdateListener(aURL, localFile, aFlags);
|
||||
|
||||
*aReturn = NS_OK; // maybe we should do something more.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::StartSoftwareUpdate(const nsString& aURL, PRInt32* aReturn)
|
||||
{
|
||||
nsString localFile;
|
||||
CreateTempFileFromURL(aURL, localFile);
|
||||
|
||||
// start the download (this will clean itself up)
|
||||
nsSoftwareUpdateListener *downloader = new nsSoftwareUpdateListener(aURL, localFile, 0);
|
||||
|
||||
*aReturn = NS_OK; // maybe we should do something more.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, nsIDOMInstallVersion* aVersion, PRInt32 aMode, PRInt32* aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32 aMode, PRInt32* aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, const nsString& aVersion, PRInt32* aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::CompareVersion(const nsString& aRegName, PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::CompareVersion(const nsString& aRegName, const nsString& aVersion, PRInt32* aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::CompareVersion(const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// this will take a nsIUrl, and create a temporary file. If it is local, we just us it.
|
||||
|
||||
void
|
||||
nsInstallTrigger::CreateTempFileFromURL(const nsString& aURL, nsString& tempFileString)
|
||||
{
|
||||
// Checking to see if the url is local
|
||||
|
||||
if ( aURL.EqualsIgnoreCase("file://", 7) )
|
||||
{
|
||||
tempFileString.SetString( nsNSPRPath(nsFileURL(aURL)) );
|
||||
}
|
||||
else
|
||||
{
|
||||
nsSpecialSystemDirectory tempFile(nsSpecialSystemDirectory::OS_TemporaryDirectory);
|
||||
|
||||
PRInt32 result = aURL.RFind("/");
|
||||
if (result != -1)
|
||||
{
|
||||
nsString jarName;
|
||||
|
||||
aURL.Right(jarName, (aURL.Length() - result) );
|
||||
|
||||
PRInt32 argOffset = jarName.RFind("?");
|
||||
|
||||
if (argOffset != -1)
|
||||
{
|
||||
// we need to remove ? and everything after it
|
||||
jarName.Truncate(argOffset);
|
||||
}
|
||||
|
||||
|
||||
tempFile += jarName;
|
||||
}
|
||||
else
|
||||
{
|
||||
tempFile += "xpinstall.jar";
|
||||
}
|
||||
|
||||
tempFile.MakeUnique();
|
||||
|
||||
tempFileString.SetString( nsNSPRPath( nsFilePath(tempFile) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
nsInstallTriggerFactory::nsInstallTriggerFactory(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsInstallTriggerFactory::~nsInstallTriggerFactory(void)
|
||||
{
|
||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTriggerFactory::QueryInterface(const nsIID &aIID, void **aResult)
|
||||
{
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = nsnull;
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsISupports*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(kIFactoryIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIFactory*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsInstallTriggerFactory);
|
||||
NS_IMPL_RELEASE(nsInstallTriggerFactory);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTriggerFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aResult = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsInstallTrigger *inst = new nsInstallTrigger();
|
||||
|
||||
if (! inst)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_FAILED(rv = inst->QueryInterface(aIID, aResult)))
|
||||
{
|
||||
// We didn't get the right interface.
|
||||
NS_ERROR("didn't support the interface you wanted");
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallTriggerFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
// Not implemented in simplest case.
|
||||
return NS_OK;
|
||||
}
|
||||
72
mozilla/xpinstall/src/nsInstallTrigger.h
Normal file
72
mozilla/xpinstall/src/nsInstallTrigger.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef __NS_INSTALLTRIGGER_H__
|
||||
#define __NS_INSTALLTRIGGER_H__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
#include "nsIDOMInstallTriggerGlobal.h"
|
||||
#include "nsSoftwareUpdate.h"
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsVector.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class nsInstallTrigger: public nsIScriptObjectOwner, public nsIDOMInstallTriggerGlobal
|
||||
{
|
||||
public:
|
||||
static const nsIID& IID() { static nsIID iid = NS_SoftwareUpdateInstallTrigger_CID; return iid; }
|
||||
|
||||
nsInstallTrigger();
|
||||
~nsInstallTrigger();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
NS_IMETHOD UpdateEnabled(PRBool* aReturn);
|
||||
NS_IMETHOD StartSoftwareUpdate(const nsString& aURL, PRInt32 aFlags, PRInt32* aReturn);
|
||||
NS_IMETHOD StartSoftwareUpdate(const nsString& aURL, PRInt32* aReturn);
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn);
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, PRInt32 aDiffLevel, nsIDOMInstallVersion* aVersion, PRInt32 aMode, PRInt32* aReturn);
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32 aMode, PRInt32* aReturn);
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, const nsString& aVersion, PRInt32 aMode, PRInt32* aReturn);
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, const nsString& aVersion, PRInt32* aReturn);
|
||||
NS_IMETHOD ConditionalSoftwareUpdate(const nsString& aURL, const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn);
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn);
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, const nsString& aVersion, PRInt32* aReturn);
|
||||
NS_IMETHOD CompareVersion(const nsString& aRegName, nsIDOMInstallVersion* aVersion, PRInt32* aReturn);
|
||||
|
||||
|
||||
private:
|
||||
void *mScriptObject;
|
||||
void CreateTempFileFromURL(const nsString& aURL, nsString& tempFileString);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class nsInstallTriggerFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
|
||||
nsInstallTriggerFactory();
|
||||
~nsInstallTriggerFactory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
196
mozilla/xpinstall/src/nsInstallUninstall.cpp
Normal file
196
mozilla/xpinstall/src/nsInstallUninstall.cpp
Normal file
@@ -0,0 +1,196 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallUninstall.h"
|
||||
#include "nsInstallResources.h"
|
||||
#include "VerReg.h"
|
||||
#include "prmem.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "ScheduledTasks.h"
|
||||
|
||||
extern "C" NS_EXPORT PRInt32 SU_Uninstall(char *regPackageName);
|
||||
REGERR su_UninstallProcessItem(char *component_path);
|
||||
|
||||
|
||||
nsInstallUninstall::nsInstallUninstall( nsInstall* inInstall,
|
||||
const nsString& regName,
|
||||
PRInt32 *error)
|
||||
|
||||
: nsInstallObject(inInstall)
|
||||
{
|
||||
if (regName == "null")
|
||||
{
|
||||
*error = nsInstall::INVALID_ARGUMENTS;
|
||||
return;
|
||||
}
|
||||
|
||||
mRegName.SetString(regName);
|
||||
|
||||
char* userName = (char*)PR_Malloc(MAXREGPATHLEN);
|
||||
PRInt32 err = VR_GetUninstallUserName( (char*) (const char*) nsAutoCString(regName),
|
||||
userName,
|
||||
MAXREGPATHLEN );
|
||||
|
||||
mUIName.SetString(userName);
|
||||
|
||||
if (err != REGERR_OK)
|
||||
{
|
||||
*error = nsInstall::NO_SUCH_COMPONENT;
|
||||
}
|
||||
|
||||
PR_FREEIF(userName);
|
||||
|
||||
}
|
||||
|
||||
nsInstallUninstall::~nsInstallUninstall()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PRInt32 nsInstallUninstall::Prepare()
|
||||
{
|
||||
// no set-up necessary
|
||||
return nsInstall::SUCCESS;
|
||||
}
|
||||
|
||||
PRInt32 nsInstallUninstall::Complete()
|
||||
{
|
||||
PRInt32 err = nsInstall::SUCCESS;
|
||||
|
||||
if (mInstall == NULL)
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
|
||||
err = SU_Uninstall( (char*)(const char*) nsAutoCString(mRegName) );
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void nsInstallUninstall::Abort()
|
||||
{
|
||||
}
|
||||
|
||||
char* nsInstallUninstall::toString()
|
||||
{
|
||||
char* buffer = new char[1024];
|
||||
|
||||
char* temp = mUIName.ToNewCString();
|
||||
sprintf( buffer, nsInstallResources::GetUninstallString(), temp);
|
||||
delete [] temp;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsInstallUninstall::CanUninstall()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsInstallUninstall::RegisterPackageNode()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT PRInt32 SU_Uninstall(char *regPackageName)
|
||||
{
|
||||
REGERR status = REGERR_FAIL;
|
||||
char pathbuf[MAXREGPATHLEN+1] = {0};
|
||||
char sharedfilebuf[MAXREGPATHLEN+1] = {0};
|
||||
REGENUM state = 0;
|
||||
int32 length;
|
||||
int32 err;
|
||||
|
||||
if (regPackageName == NULL)
|
||||
return REGERR_PARAM;
|
||||
|
||||
if (pathbuf == NULL)
|
||||
return REGERR_PARAM;
|
||||
|
||||
/* Get next path from Registry */
|
||||
status = VR_Enum( regPackageName, &state, pathbuf, MAXREGPATHLEN );
|
||||
|
||||
/* if we got a good path */
|
||||
while (status == REGERR_OK)
|
||||
{
|
||||
char component_path[2*MAXREGPATHLEN+1] = {0};
|
||||
strcat(component_path, regPackageName);
|
||||
length = strlen(regPackageName);
|
||||
if (component_path[length - 1] != '/')
|
||||
strcat(component_path, "/");
|
||||
strcat(component_path, pathbuf);
|
||||
err = su_UninstallProcessItem(component_path);
|
||||
status = VR_Enum( regPackageName, &state, pathbuf, MAXREGPATHLEN );
|
||||
}
|
||||
|
||||
err = VR_Remove(regPackageName);
|
||||
// there is a problem here. It looks like if the file is refcounted, we still blow away the reg key
|
||||
// FIX!
|
||||
state = 0;
|
||||
status = VR_UninstallEnumSharedFiles( regPackageName, &state, sharedfilebuf, MAXREGPATHLEN );
|
||||
while (status == REGERR_OK)
|
||||
{
|
||||
err = su_UninstallProcessItem(sharedfilebuf);
|
||||
err = VR_UninstallDeleteFileFromList(regPackageName, sharedfilebuf);
|
||||
status = VR_UninstallEnumSharedFiles( regPackageName, &state, sharedfilebuf, MAXREGPATHLEN );
|
||||
}
|
||||
|
||||
err = VR_UninstallDeleteSharedFilesKey(regPackageName);
|
||||
err = VR_UninstallDestroy(regPackageName);
|
||||
return err;
|
||||
}
|
||||
|
||||
REGERR su_UninstallProcessItem(char *component_path)
|
||||
{
|
||||
int refcount;
|
||||
int err;
|
||||
char filepath[MAXREGPATHLEN];
|
||||
|
||||
err = VR_GetPath(component_path, sizeof(filepath), filepath);
|
||||
if ( err == REGERR_OK )
|
||||
{
|
||||
err = VR_GetRefCount(component_path, &refcount);
|
||||
if ( err == REGERR_OK )
|
||||
{
|
||||
--refcount;
|
||||
if (refcount > 0)
|
||||
err = VR_SetRefCount(component_path, refcount);
|
||||
else
|
||||
{
|
||||
err = VR_Remove(component_path);
|
||||
DeleteFileNowOrSchedule(nsFileSpec(filepath));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* delete node and file */
|
||||
err = VR_Remove(component_path);
|
||||
DeleteFileNowOrSchedule(nsFileSpec(filepath));
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
63
mozilla/xpinstall/src/nsInstallUninstall.h
Normal file
63
mozilla/xpinstall/src/nsInstallUninstall.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef nsInstallUninstall_h__
|
||||
#define nsInstallUninstall_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsString.h"
|
||||
#include "nsInstallObject.h"
|
||||
#include "nsInstall.h"
|
||||
|
||||
class nsInstallUninstall : public nsInstallObject
|
||||
{
|
||||
public:
|
||||
|
||||
nsInstallUninstall( nsInstall* inInstall,
|
||||
const nsString& regName,
|
||||
PRInt32 *error);
|
||||
|
||||
|
||||
virtual ~nsInstallUninstall();
|
||||
|
||||
PRInt32 Prepare();
|
||||
PRInt32 Complete();
|
||||
void Abort();
|
||||
char* toString();
|
||||
|
||||
PRBool CanUninstall();
|
||||
PRBool RegisterPackageNode();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
nsString mRegName; // Registry name of package
|
||||
nsString mUIName; // User name of package
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsInstallUninstall_h__ */
|
||||
399
mozilla/xpinstall/src/nsInstallVersion.cpp
Normal file
399
mozilla/xpinstall/src/nsInstallVersion.cpp
Normal file
@@ -0,0 +1,399 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nsSoftwareUpdate.h"
|
||||
|
||||
#include "nsInstallVersion.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
#include "prprf.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIInstallVersion_IID, NS_IDOMINSTALLVERSION_IID);
|
||||
|
||||
|
||||
nsInstallVersion::nsInstallVersion()
|
||||
{
|
||||
mScriptObject = nsnull;
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsInstallVersion::~nsInstallVersion()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::QueryInterface(REFNSIID aIID,void** aInstancePtr)
|
||||
{
|
||||
if (aInstancePtr == NULL)
|
||||
{
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if ( aIID.Equals(kIScriptObjectOwnerIID))
|
||||
{
|
||||
*aInstancePtr = (void*) ((nsIScriptObjectOwner*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
else if ( aIID.Equals(kIInstallVersion_IID) )
|
||||
{
|
||||
*aInstancePtr = (void*) ((nsIDOMInstallVersion*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
else if ( aIID.Equals(kISupportsIID) )
|
||||
{
|
||||
*aInstancePtr = (void*)(nsISupports*)(nsIScriptObjectOwner*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsInstallVersion)
|
||||
NS_IMPL_RELEASE(nsInstallVersion)
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (nsnull == mScriptObject)
|
||||
{
|
||||
res = NS_NewScriptInstallVersion(aContext,
|
||||
(nsISupports *)(nsIDOMInstallVersion*)this,
|
||||
nsnull,
|
||||
&mScriptObject);
|
||||
}
|
||||
|
||||
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// this will go away when our constructors can have parameters.
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::Init(PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild)
|
||||
{
|
||||
major = aMajor;
|
||||
minor = aMinor;
|
||||
release = aRelease;
|
||||
build = aBuild;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::Init(const nsString& version)
|
||||
{
|
||||
PRInt32 errorCode;
|
||||
PRInt32 aMajor, aMinor, aRelease, aBuild;
|
||||
|
||||
major = minor = release = build = 0;
|
||||
|
||||
errorCode = nsInstallVersion::StringToVersionNumbers(version, &aMajor, &aMinor, &aRelease, &aBuild);
|
||||
if (NS_SUCCEEDED(errorCode))
|
||||
{
|
||||
Init(aMajor, aMinor, aRelease, aBuild);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::GetMajor(PRInt32* aMajor)
|
||||
{
|
||||
*aMajor = major;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::SetMajor(PRInt32 aMajor)
|
||||
{
|
||||
major = aMajor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::GetMinor(PRInt32* aMinor)
|
||||
{
|
||||
*aMinor = minor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::SetMinor(PRInt32 aMinor)
|
||||
{
|
||||
minor = aMinor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::GetRelease(PRInt32* aRelease)
|
||||
{
|
||||
*aRelease = release;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::SetRelease(PRInt32 aRelease)
|
||||
{
|
||||
release = aRelease;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::GetBuild(PRInt32* aBuild)
|
||||
{
|
||||
*aBuild = build;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::SetBuild(PRInt32 aBuild)
|
||||
{
|
||||
build = aBuild;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::CompareTo(nsIDOMInstallVersion* aVersion, PRInt32* aReturn)
|
||||
{
|
||||
PRInt32 aMajor, aMinor, aRelease, aBuild;
|
||||
|
||||
aVersion->GetMajor(&aMajor);
|
||||
aVersion->GetMinor(&aMinor);
|
||||
aVersion->GetRelease(&aRelease);
|
||||
aVersion->GetBuild(&aBuild);
|
||||
|
||||
CompareTo(aMajor, aMinor, aRelease, aBuild, aReturn);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::CompareTo(const nsString& aAString, PRInt32* aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::CompareTo(PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn)
|
||||
{
|
||||
int diff;
|
||||
|
||||
if ( major == aMajor )
|
||||
{
|
||||
if ( minor == aMinor )
|
||||
{
|
||||
if ( release == aRelease )
|
||||
{
|
||||
if ( build == aBuild )
|
||||
diff = EQUAL;
|
||||
else if ( build > aBuild )
|
||||
diff = BLD_DIFF;
|
||||
else
|
||||
diff = BLD_DIFF_MINUS;
|
||||
}
|
||||
else if ( release > aRelease )
|
||||
diff = REL_DIFF;
|
||||
else
|
||||
diff = REL_DIFF_MINUS;
|
||||
}
|
||||
else if ( minor > aMinor )
|
||||
diff = MINOR_DIFF;
|
||||
else
|
||||
diff = MINOR_DIFF_MINUS;
|
||||
}
|
||||
else if ( major > aMajor )
|
||||
diff = MAJOR_DIFF;
|
||||
else
|
||||
diff = MAJOR_DIFF_MINUS;
|
||||
|
||||
*aReturn = diff;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersion::ToString(nsString& aReturn)
|
||||
{
|
||||
char *result=NULL;
|
||||
result = PR_sprintf_append(result, "%d.%d.%d.%d", major, minor, release, build);
|
||||
|
||||
aReturn = result;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsInstallVersion::StringToVersionNumbers(const nsString& version, PRInt32 *aMajor, PRInt32 *aMinor, PRInt32 *aRelease, PRInt32 *aBuild)
|
||||
{
|
||||
PRInt32 errorCode;
|
||||
|
||||
int dot = version.Find('.', 0);
|
||||
|
||||
if ( dot == -1 )
|
||||
{
|
||||
*aMajor = version.ToInteger(&errorCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsString majorStr;
|
||||
version.Mid(majorStr, 0, dot);
|
||||
*aMajor = majorStr.ToInteger(&errorCode);
|
||||
|
||||
int prev = dot+1;
|
||||
dot = version.Find('.',prev);
|
||||
if ( dot == -1 )
|
||||
{
|
||||
nsString minorStr;
|
||||
version.Mid(minorStr, prev, version.Length() - prev);
|
||||
*aMinor = minorStr.ToInteger(&errorCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsString minorStr;
|
||||
version.Mid(minorStr, prev, dot - prev);
|
||||
*aMinor = minorStr.ToInteger(&errorCode);
|
||||
|
||||
prev = dot+1;
|
||||
dot = version.Find('.',prev);
|
||||
if ( dot == -1 )
|
||||
{
|
||||
nsString releaseStr;
|
||||
version.Mid(releaseStr, prev, version.Length() - prev);
|
||||
*aRelease = releaseStr.ToInteger(&errorCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsString releaseStr;
|
||||
version.Mid(releaseStr, prev, dot - prev);
|
||||
*aRelease = releaseStr.ToInteger(&errorCode);
|
||||
|
||||
prev = dot+1;
|
||||
if ( version.Length() > dot )
|
||||
{
|
||||
nsString buildStr;
|
||||
version.Mid(buildStr, prev, version.Length() - prev);
|
||||
*aBuild = buildStr.ToInteger(&errorCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsInstallVersionFactory::nsInstallVersionFactory(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsInstallVersionFactory::~nsInstallVersionFactory(void)
|
||||
{
|
||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersionFactory::QueryInterface(const nsIID &aIID, void **aResult)
|
||||
{
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = nsnull;
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsISupports*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(kIFactoryIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIFactory*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsInstallVersionFactory);
|
||||
NS_IMPL_RELEASE(nsInstallVersionFactory);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersionFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
{
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aResult = NULL;
|
||||
|
||||
/* do I have to use iSupports? */
|
||||
nsInstallVersion *inst = new nsInstallVersion();
|
||||
|
||||
if (inst == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult result = inst->QueryInterface(aIID, aResult);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
delete inst;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallVersionFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
76
mozilla/xpinstall/src/nsInstallVersion.h
Normal file
76
mozilla/xpinstall/src/nsInstallVersion.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#ifndef __NS_INSTALLVERSION_H__
|
||||
#define __NS_INSTALLVERSION_H__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
#include "nsSoftwareUpdate.h"
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
class nsInstallVersion: public nsIScriptObjectOwner, public nsIDOMInstallVersion
|
||||
{
|
||||
public:
|
||||
static const nsIID& IID() { static nsIID iid = NS_SoftwareUpdateInstallVersion_CID; return iid; }
|
||||
|
||||
nsInstallVersion();
|
||||
virtual ~nsInstallVersion();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
NS_IMETHOD Init(PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild);
|
||||
NS_IMETHOD Init(const nsString& aVersionString);
|
||||
|
||||
NS_IMETHOD GetMajor(PRInt32* aMajor);
|
||||
NS_IMETHOD SetMajor(PRInt32 aMajor);
|
||||
|
||||
NS_IMETHOD GetMinor(PRInt32* aMinor);
|
||||
NS_IMETHOD SetMinor(PRInt32 aMinor);
|
||||
|
||||
NS_IMETHOD GetRelease(PRInt32* aRelease);
|
||||
NS_IMETHOD SetRelease(PRInt32 aRelease);
|
||||
|
||||
NS_IMETHOD GetBuild(PRInt32* aBuild);
|
||||
NS_IMETHOD SetBuild(PRInt32 aBuild);
|
||||
|
||||
NS_IMETHOD ToString(nsString& aReturn);
|
||||
NS_IMETHOD CompareTo(nsIDOMInstallVersion* aVersion, PRInt32* aReturn);
|
||||
NS_IMETHOD CompareTo(const nsString& aString, PRInt32* aReturn);
|
||||
NS_IMETHOD CompareTo(PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PRInt32 aBuild, PRInt32* aReturn);
|
||||
|
||||
static nsresult StringToVersionNumbers(const nsString& version, PRInt32 *aMajor, PRInt32 *aMinor, PRInt32 *aRelease, PRInt32 *aBuild);
|
||||
|
||||
private:
|
||||
void *mScriptObject;
|
||||
PRInt32 major;
|
||||
PRInt32 minor;
|
||||
PRInt32 release;
|
||||
PRInt32 build;
|
||||
};
|
||||
|
||||
|
||||
class nsInstallVersionFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
|
||||
nsInstallVersionFactory();
|
||||
virtual ~nsInstallVersionFactory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user