Compare commits

..

18 Commits

Author SHA1 Message Date
ssu%netscape.com
f5e87189a8 ifdef'ed out win32 specific code
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31481 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 22:31:09 +00:00
ssu%netscape.com
a447cb3602 cleaned up commented out code
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31459 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 21:44:47 +00:00
ssu%netscape.com
ab5baaeea9 ifdef'ed out win32 specific code
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31455 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 21:03:36 +00:00
ssu%netscape.com
cf9cd93369 ifdef'ed out win32 specific code
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31447 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 20:43:26 +00:00
ssu%netscape.com
1217d1716a ifdef'ed out win32 specific code
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31438 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 19:30:12 +00:00
ssu%netscape.com
9033ed8ae9 ifdef'ed out win32 specific code
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31435 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 18:34:53 +00:00
ssu%netscape.com
7a0eb564c6 ifdef'ed out win32 specific code
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31434 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 18:29:49 +00:00
ssu%netscape.com
ca132a7d74 moved the winreg glue code into it's own file, nsJSWinreg.cpp
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31433 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 18:27:14 +00:00
ssu%netscape.com
b3aa2e3994 removed WinRegFinal functions from being exposed to java script
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31331 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-12 23:59:33 +00:00
ssu%netscape.com
53645d6478 removed references to XP calls and replaced it with PR calls
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31306 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-12 22:45:21 +00:00
ssu%netscape.com
bfb8561c95 changed case of the first letter for the WinReg functions
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31283 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-12 20:33:52 +00:00
ssu%netscape.com
657271988e changed case of the first letter for the WinReg functions
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31282 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-12 20:12:46 +00:00
ssu%netscape.com
c0aa7107dd moved the static function declaration of WinRegCleanup to the nsJSInstall.cpp file
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31281 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-12 19:11:57 +00:00
ssu%netscape.com
446014e9b7 moved the static function declaration of WinRegCleanup to the .cpp file
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31279 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-12 19:11:21 +00:00
ssu%netscape.com
5e0e58db9b trying to modularize the WinReg functions
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31278 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-12 19:09:35 +00:00
ssu%netscape.com
dfd9622170 initial checkin for WinReg object files
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31200 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-12 01:52:53 +00:00
ssu%netscape.com
3f88348d48 added WinReg object
git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@31199 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-12 01:48:29 +00:00
(no author)
d772ad7b42 This commit was manufactured by cvs2svn to create branch
'XPINSTALL_DEV2_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/XPINSTALL_DEV2_BRANCH@30911 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-10 05:34:27 +00:00
74 changed files with 3396 additions and 5580 deletions

View File

@@ -25,6 +25,6 @@
DEPTH=..
DIRS= public res src
DIRS= public src
include <$(DEPTH)\config\rules.mak>

View File

@@ -1,33 +0,0 @@
<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>

View File

@@ -1,57 +0,0 @@
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");
}

View File

@@ -1,123 +0,0 @@
// 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);

View File

@@ -1,30 +0,0 @@
<?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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 B

View File

@@ -1,7 +0,0 @@
<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>

View File

@@ -31,8 +31,6 @@ include $(DEPTH)/config/autoconf.mk
MODULE = xpinstall
XPIDLSRCS = nsIXPInstallProgress.idl
EXPORTS = \
nsIDOMInstallTriggerGlobal.h \
nsIDOMInstallVersion.h \

View File

@@ -22,15 +22,16 @@
# Daniel Veditz <dveditz@netscape.com>
# Douglas Turner <dougt@netscape.com>
MODULE=xpinstall
DEPTH=..\..
DEFINES=-D_IMPL_NS_DOM
EXPORTS= nsIDOMInstallTriggerGlobal.h \
nsIDOMInstallVersion.h \
nsSoftwareUpdateIIDs.h \
nsISoftwareUpdate.h
XPIDLSRCS = .\nsIXPInstallProgress.idl
MODULE=xpinstall
include <$(DEPTH)\config\config.mak>
include <$(DEPTH)\config\rules.mak>

View File

@@ -30,11 +30,7 @@
#include "nsIFactory.h"
#include "nsString.h"
#include "nsIXPInstallProgress.h"
#define NS_IXPINSTALLCOMPONENT_PROGID NS_IAPPSHELLCOMPONENT_PROGID "/xpinstall"
#define NS_IXPINSTALLCOMPONENT_CLASSNAME "Mozilla XPInstall Component"
class nsInstallInfo;
#define NS_ISOFTWAREUPDATE_IID \
{ 0x18c2f992, \
@@ -44,31 +40,31 @@
}
class nsISoftwareUpdate : public nsISupports
class nsISoftwareUpdate : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISOFTWAREUPDATE_IID)
NS_IMETHOD InstallJar(nsInstallInfo *installInfo) = 0;
NS_IMETHOD InstallJar(const nsString& fromURL,
const nsString& localFile,
long flags) = 0;
NS_IMETHOD InstallJar(const nsString& fromURL,
const nsString& flags,
const nsString& args) = 0;
NS_IMETHOD RegisterNotifier(nsIXPInstallProgress *notifier) = 0;
NS_IMETHOD InstallPending(void) = 0;
// these should be in a private interface:
NS_IMETHOD RunNextInstall() = 0;
NS_IMETHOD InstallJarCallBack() = 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();
~nsSoftwareUpdateFactory();
NS_DECL_ISUPPORTS

View File

@@ -1,30 +0,0 @@
/* -*- 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();
};

View File

@@ -1,93 +0,0 @@
/* -*- 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

View File

@@ -34,6 +34,14 @@
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateFactory_CID \
{ /* 18c2f98a-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98a, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstall_CID \
{ /* 18c2f98b-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98b, \
@@ -42,6 +50,14 @@
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstallFactory_CID \
{ /* 18c2f98c-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98c, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstallTrigger_CID \
{ /* 18c2f98d-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98d, \
@@ -50,6 +66,14 @@
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstallTriggerFactory_CID \
{ /* 18c2f98e-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98e, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstallVersion_CID \
{ /* 18c2f98f-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f98f, \
@@ -58,7 +82,31 @@
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstallVersionFactory_CID \
{ /* 18c2f990-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f990, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#if 0
#define NS_SoftwareUpdateInstallFolder_CID \
{ /* 18c2f991-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f991, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#define NS_SoftwareUpdateInstallFolderFactory_CID \
{ /* 18c2f992-b09f-11d2-bcde-00805f0e1353 */ \
0x18c2f992, \
0xb09f, \
0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
}
#endif
#endif /* nsSoftwareUpdateIIDs_h___ */

View File

@@ -1,3 +0,0 @@
progress.xul
progress.css
progress.html

View File

@@ -1,34 +0,0 @@
#!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

View File

@@ -1,31 +0,0 @@
#!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

View File

@@ -1,3 +0,0 @@
TD {
font: 10pt sans-serif;
}

View File

@@ -1,16 +0,0 @@
<!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);">&nbsp</td>
<td WIDTH="3%" NOWRAP style="border: 1px inset rgb(192,192,192);">&nbsp</td>
<td WIDTH="3%" NOWRAP style="border: 1px inset rgb(192,192,192);">&nbsp</td>
<td WIDTH="10%" NOWRAP style="border: 1px inset rgb(192,192,192);">&nbsp</td>
<td WIDTH="81%" NOWRAP style="border: 1px inset rgb(192,192,192);">&nbsp</td>
</tr>
</table>
</center>
</body>
</html>

View File

@@ -1,67 +0,0 @@
<?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>

View File

@@ -49,10 +49,7 @@ CPPSRCS = \
nsJSInstallTriggerGlobal.cpp\
nsSoftwareUpdateRun.cpp \
nsSoftwareUpdateStream.cpp \
nsTopProgressNotifier.cpp \
nsLoggingProgressNotifier \
ScheduledTasks.cpp \
nsInstallFileOpItem.cpp \
$(NULL)
INCLUDES += -I$(srcdir)/../public

View File

@@ -29,162 +29,8 @@
#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 DeleteFileLater(nsFileSpec& filename)
{
REGERR result = 0;
@@ -199,9 +45,12 @@ REGERR DeleteFileNowOrSchedule(nsFileSpec& filename)
{
if (REGERR_OK == NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY, &newkey) )
{
// FIX should be using nsPersistentFileDescriptor!!!
nsPersistentFileDescriptor savethis(filename);
char* buffer = nsnull;
nsOutputStringStream s(buffer);
s << savethis;
result = NR_RegSetEntry( reg, newkey, (char*)(const char*)filename.GetNativePathCString(), REGTYPE_ENTRY_FILE, nsnull, 0);
result = NR_RegSetEntry( reg, newkey, "", REGTYPE_ENTRY_BYTES, buffer, strlen(buffer));
if (result == REGERR_OK)
result = nsInstall::REBOOT_NEEDED;
}
@@ -212,41 +61,25 @@ REGERR DeleteFileNowOrSchedule(nsFileSpec& filename)
return result;
}
/* tmp file is the bad one that we want to replace with target. */
REGERR ReplaceFileNowOrSchedule(nsFileSpec& replacementFile, nsFileSpec& doomedFile )
REGERR ReplaceFileLater(nsFileSpec& tmpfile, nsFileSpec& target )
{
REGERR result = 0;
if(replacementFile == doomedFile)
{
/* do not have to do anything */
return result;
}
doomedFile.Delete(false);
if (! doomedFile.Exists() )
if (! target.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);
}
target.GetParent(parentofFinalFile);
result = tmpfile.Move(parentofFinalFile);
char* leafName = target.GetLeafName();
tmpfile.Rename(leafName);
nsCRT::free(leafName);
}
else
{
#ifdef _WINDOWS
if (DoWindowsReplaceExistingFileStuff(replacementFile.GetNativePathCString(), doomedFile.GetNativePathCString()) == 0)
return 0;
#endif
RKEY newkey;
HREG reg;
@@ -255,10 +88,22 @@ REGERR ReplaceFileNowOrSchedule(nsFileSpec& replacementFile, nsFileSpec& doomedF
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));
nsPersistentFileDescriptor tempDesc(tmpfile);
nsPersistentFileDescriptor targDesc(target);
char* tempBuffer = nsnull;
char* targBuffer = nsnull;
nsOutputStringStream tempStream(tempBuffer);
nsOutputStringStream targStream(targBuffer);
tempStream << tempDesc;
targStream << targDesc;
result = NR_RegSetEntry( reg, newkey, tempBuffer, REGTYPE_ENTRY_BYTES, targBuffer, strlen(targBuffer));
if (result == REGERR_OK)
result = nsInstall::REBOOT_NEEDED;
}
NR_RegClose(reg);
@@ -290,11 +135,16 @@ void DeleteScheduledFiles(void)
/* perform scheduled file deletions and replacements (PC only) */
if (REGERR_OK == NR_RegGetKey(reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY,&key))
{
char buf[MAXREGNAMELEN];
char buf[MAXREGNAMELEN]; // what about the mac? FIX
while (REGERR_OK == NR_RegEnumEntries(reg, key, &state, buf, sizeof(buf), NULL ))
{
nsFileSpec doomedFile(buf);
nsPersistentFileDescriptor doomedDesc;
nsInputStringStream tempStream(buf);
tempStream >> doomedDesc;
nsFileSpec doomedFile(doomedDesc);
doomedFile.Delete(PR_FALSE);
@@ -334,7 +184,12 @@ void ReplaceScheduledFiles(void)
while (REGERR_OK == NR_RegEnumEntries(reg, key, &state, tmpfile, sizeof(tmpfile), NULL ))
{
nsFileSpec replaceFile(tmpfile);
nsPersistentFileDescriptor doomedDesc;
nsInputStringStream tempStream(tmpfile);
tempStream >> doomedDesc;
nsFileSpec replaceFile(doomedDesc);
if (! replaceFile.Exists() )
{
@@ -347,7 +202,11 @@ void ReplaceScheduledFiles(void)
}
else
{
nsFileSpec targetFile(target);
nsPersistentFileDescriptor targetDesc;
nsInputStringStream anotherStream(target);
anotherStream >> targetDesc;
nsFileSpec targetFile(targetDesc);
targetFile.Delete(PR_FALSE);

View File

@@ -32,8 +32,8 @@
#include "nsFileSpec.h"
REGERR DeleteFileNowOrSchedule(nsFileSpec& filename);
REGERR ReplaceFileNowOrSchedule(nsFileSpec& tmpfile, nsFileSpec& target );
REGERR DeleteFileLater(nsFileSpec& filename);
REGERR ReplaceFileLater(nsFileSpec& tmpfile, nsFileSpec& target );
extern "C" void PerformScheduledTasks(void *data);

View File

@@ -39,29 +39,32 @@ LCFLAGS = \
$(NULL)
LINCS= \
-I$(PUBLIC)\libxpt \
-I$(PUBLIC)\xptinfo \
-I$(PUBLIC)\xptcall \
-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\xpcom32.lib \
$(DIST)\lib\xppref32.lib \
$(DIST)\lib\js3250.lib \
$(DIST)\lib\jsdombase_s.lib \
$(DIST)\lib\jsdomevents_s.lib \
$(DIST)\lib\raptorbase.lib \
$(DIST)\lib\zlib.lib \
$(DIST)\lib\plc3.lib \
$(LIBNSPR) \
@@ -85,18 +88,11 @@ OBJS = \
.\$(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>

File diff suppressed because it is too large Load Diff

View File

@@ -44,48 +44,54 @@
#include "nsInstallObject.h"
#include "nsInstallVersion.h"
#include "nsIXPInstallProgress.h"
class nsInstallInfo
{
public:
nsInstallInfo(const nsString& fromURL);
nsInstallInfo(const nsString& fromURL, const nsString& arguments);
nsInstallInfo(const nsString& fromURL, const nsString& arguments, const nsString& flags);
nsInstallInfo(const nsString& fromURL, const nsString& localFile, long flags);
nsInstallInfo(nsVector* fromURL, nsVector* localFiles, long flags);
virtual ~nsInstallInfo();
nsInstallInfo(nsVector* fromURL, const nsString& arguments, const nsString& flags);
~nsInstallInfo();
nsString& GetFromURL(PRUint32 index = 0);
nsString& GetLocalFile(PRUint32 index = 0);
void GetArguments(nsString& args, PRUint32 index = 0);
long GetFlags();
nsString& GetArguments();
nsString& GetFlags();
PRBool IsMultipleTrigger();
static void DeleteVector(nsVector* vector);
PLEventQueue* GetUIEventQueue(void) const { return mUIEventQueue; }
void SetUIEventQueue(PLEventQueue* queue) { mUIEventQueue = queue; }
private:
PRBool mMultipleTrigger;
nsresult mError;
void DeleteVector(nsVector* vector);
void MakeTempFile(nsString aURL, nsString& tempFileString);
long mFlags;
nsVector *mFromURLs;
nsVector *mLocalFiles;
nsString *mLocalFile;
nsString *mFromURL;
nsString *mArguments;
nsString *mFlags;
PRBool mInstalled;
PRBool mMultipleTrigger;
nsVector *mFromURLs;
nsVector *mLocalFiles;
PLEventQueue *mUIEventQueue; // this should be moved to private and have accessors
};
class nsInstall
{
friend class nsWinReg;
friend class nsWinProfile;
public:
@@ -133,31 +139,32 @@ class nsInstall
nsInstall();
virtual ~nsInstall();
~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, nsIDOMInstallVersion* 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, nsIDOMInstallVersion* 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, nsIDOMInstallVersion* 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, nsIDOMInstallVersion* 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);
@@ -170,35 +177,20 @@ class nsInstall
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 GetWinProfile(const nsString& aFolder, const nsString& aFile, PRInt32* 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, nsIDOMInstallVersion* 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 aFlags, PRInt32* aReturn);
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, nsIDOMInstallVersion* aVersion, PRInt32 aFlags, PRInt32* aReturn);
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32* aReturn);
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, nsIDOMInstallVersion* 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);
@@ -235,7 +227,7 @@ class nsInstall
nsVector* mInstalledFiles;
nsHashtable* mPatchList;
nsIXPInstallProgress *mNotifier;
nsOutputFileStream *mLogStream;
PRInt32 mLastError;
@@ -243,12 +235,10 @@ class nsInstall
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);
nsString * GetQualifiedRegName( const nsString& name );
nsString* GetQualifiedPackageName( const nsString& name );
nsString* CurrentUserNode();
PRBool BadRegName(nsString* regName);
PRInt32 SaveError(PRInt32 errcode);
void CleanUp();

View File

@@ -222,7 +222,7 @@ PRInt32 nsInstallDelete::NativeComplete()
{
if (mFinalFile->IsFile())
{
return DeleteFileNowOrSchedule(*mFinalFile);
return DeleteFileLater(*mFinalFile);
}
else
{

View File

@@ -87,7 +87,7 @@ PRInt32 nsInstallExecute::Complete()
PRInt32 result = app.Execute( mArgs );
DeleteFileNowOrSchedule( app );
DeleteFileLater( app );
return result;
}
@@ -98,25 +98,15 @@ void nsInstallExecute::Abort()
if (mExecutableFile == nsnull)
return;
DeleteFileNowOrSchedule(*mExecutableFile);
DeleteFileLater(*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());
}
sprintf( buffer, nsInstallResources::GetExecuteString(), mExecutableFile->GetCString());
return buffer;
}

View File

@@ -28,7 +28,7 @@
#include "VerReg.h"
#include "ScheduledTasks.h"
#include "nsInstall.h"
#include "nsIDOMInstallVersion.h"
#include "nsInstallVersion.h"
#include "nsInstallResources.h"
/* Public Methods */
@@ -40,11 +40,9 @@
inJarLocation - location inside the JAR file
inFinalFileSpec - final location on disk
*/
nsInstallFile::nsInstallFile(nsInstall* inInstall,
const nsString& inComponentName,
const nsString& inVInfo,
nsIDOMInstallVersion* inVInfo,
const nsString& inJarLocation,
const nsString& folderSpec,
const nsString& inPartialPath,
@@ -52,79 +50,30 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
PRInt32 *error)
: nsInstallObject(inInstall)
{
mVersionRegistryName = nsnull;
mJarLocation = nsnull;
mExtracedFile = nsnull;
mFinalFile = nsnull;
mVersionInfo = nsnull;
mExtracedFile= nsnull;
mFinalFile = nsnull;
mUpgradeFile = PR_FALSE;
if ((folderSpec == "null") || (inInstall == NULL))
if ((folderSpec == "null") || (inInstall == NULL) || (inVInfo == 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);
}
mReplaceFile = mFinalFile->Exists();
mForceInstall = forceInstall;
mVersionRegistryName = new nsString(inComponentName);
mJarLocation = new nsString(inJarLocation);
mVersionInfo = new nsString(inVInfo);
mVersionInfo = new nsInstallVersion();
nsString tempString;
inVInfo->ToString(tempString);
mVersionInfo->Init(tempString);
nsString regPackageName;
mInstall->GetRegPackageName(regPackageName);
@@ -138,12 +87,9 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
}
else
{
// there is no "starts with" api in nsString. LAME!
nsString startsWith;
mVersionRegistryName->Left(startsWith, regPackageName.Length());
if (startsWith.Equals(regPackageName))
//mChildFile = mVersionRegistryName.startsWith(regPackageName);
/* Because nsString doesn't support startWith, implemented the following. Waiting for approval */
if (mVersionRegistryName->Find(regPackageName) == 0)
{
mChildFile = true;
}
@@ -152,6 +98,8 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
mChildFile = false;
}
}
}
@@ -254,7 +202,7 @@ PRInt32 nsInstallFile::CompleteFileMove()
}
else
{
result = ReplaceFileNowOrSchedule(*mExtracedFile, *mFinalFile );
result = ReplaceFileLater(*mExtracedFile, *mFinalFile );
}
return result;
@@ -303,18 +251,11 @@ nsInstallFile::RegisterInVersionRegistry()
}
VR_Install( (char*)(const char*)nsAutoCString(*mVersionRegistryName),
(char*)(const char*)mFinalFile->GetNativePathCString(), // DO NOT CHANGE THIS.
(char*)(const char*)nsAutoCString(*mVersionInfo),
(char*)(const char*)nsNSPRPath(*mFinalFile),
(char*)(const char*)nsAutoCString(regPackageName),
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 (!mUpgradeFile)
{
if (refCount != 0)
{
@@ -322,11 +263,18 @@ nsInstallFile::RegisterInVersionRegistry()
}
else
{
if (mReplaceFile)
if (mFinalFile->Exists())
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 2 );
else
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 1 );
}
}
else
{
if (refCount == 0)
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 1 );
else
VR_SetRefCount( (char*)(const char*)nsAutoCString(*mVersionRegistryName), 0 );
}
if ( !mChildFile && !mUpgradeFile )

View File

@@ -51,7 +51,7 @@ class nsInstallFile : public nsInstallObject
*************************************************************/
nsInstallFile( nsInstall* inInstall,
const nsString& inVRName,
const nsString& inVInfo,
nsIDOMInstallVersion* inVInfo,
const nsString& inJarLocation,
const nsString& folderSpec,
const nsString& inPartialPath,
@@ -72,7 +72,7 @@ class nsInstallFile : public nsInstallObject
private:
/* Private Fields */
nsString* mVersionInfo; /* Version info for this file*/
nsInstallVersion* mVersionInfo; /* Version info for this file*/
nsString* mJarLocation; /* Location in the JAR */
nsFileSpec* mExtracedFile; /* temporary file location */

View File

@@ -1,38 +0,0 @@
/* -*- 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__ */

View File

@@ -1,316 +0,0 @@
/* -*- 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;
}

View File

@@ -1,111 +0,0 @@
/* -*- 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__ */

View File

@@ -28,15 +28,11 @@
#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 */
@@ -52,12 +48,9 @@ struct DirectoryTable DirectoryTable[] =
{"Temporary", 104 },
{"Installed", 105 },
{"Current User", 106 },
{"Preferences", 107 },
{"NetHelp", 107 },
{"OS Drive", 108 },
{"file:///", 109 },
{"Components", 110 },
{"Chrome", 111 },
{"File URL", 109 },
{"Win System", 200 },
{"Windows", 201 },
@@ -84,34 +77,13 @@ struct DirectoryTable DirectoryTable[] =
nsInstallFolder::nsInstallFolder(const nsString& aFolderID)
{
mFileSpec = nsnull;
SetDirectoryPath( aFolderID, "");
nsInstallFolder(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);
}
SetDirectoryPath( aFolderID, aRelativePath);
}
@@ -124,7 +96,7 @@ nsInstallFolder::~nsInstallFolder()
void
nsInstallFolder::GetDirectoryPath(nsString& aDirectoryPath)
{
aDirectoryPath = "";
aDirectoryPath.SetLength(0);
if (mFileSpec != nsnull)
{
@@ -153,123 +125,108 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
switch (folderDirSpecID)
{
case 100: /////////////////////////////////////////////////////////// Plugins
SetAppShellDirectory(nsSpecialFileSpec::App_PluginsDirectory );
// FIX
break;
case 101: /////////////////////////////////////////////////////////// Program
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_CurrentProcessDirectory ));
*this = nsSpecialSystemDirectory::OS_CurrentProcessDirectory;
break;
case 102: /////////////////////////////////////////////////////////// Communicator
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_CurrentProcessDirectory ));
*this = nsSpecialSystemDirectory::OS_CurrentProcessDirectory; // FIX?
break;
case 103: /////////////////////////////////////////////////////////// User Pick
// we should never be here.
mFileSpec = nsnull;
break;
case 104: /////////////////////////////////////////////////////////// Temporary
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_TemporaryDirectory ));
*this = nsSpecialSystemDirectory::OS_TemporaryDirectory;
break;
case 105: /////////////////////////////////////////////////////////// Installed
// we should never be here.
mFileSpec = nsnull;
break;
case 106: /////////////////////////////////////////////////////////// Current User
SetAppShellDirectory(nsSpecialFileSpec::App_UserProfileDirectory50 );
// FIX
break;
case 107: /////////////////////////////////////////////////////////// Preferences
SetAppShellDirectory(nsSpecialFileSpec::App_PrefsDirectory50 );
case 107: /////////////////////////////////////////////////////////// NetHelp
// FIX
break;
case 108: /////////////////////////////////////////////////////////// OS Drive
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::OS_DriveDirectory ));
*this = 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 );
// we should never be here.
break;
case 200: /////////////////////////////////////////////////////////// Win System
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Win_SystemDirectory ));
*this = nsSpecialSystemDirectory::Win_SystemDirectory;
break;
case 201: /////////////////////////////////////////////////////////// Windows
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Win_WindowsDirectory ));
*this = nsSpecialSystemDirectory::Win_WindowsDirectory;
break;
case 300: /////////////////////////////////////////////////////////// Mac System
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_SystemDirectory ));
*this = nsSpecialSystemDirectory::Mac_SystemDirectory;
break;
case 301: /////////////////////////////////////////////////////////// Mac Desktop
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_DesktopDirectory ));
*this = nsSpecialSystemDirectory::Mac_DesktopDirectory;
break;
case 302: /////////////////////////////////////////////////////////// Mac Trash
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_TrashDirectory ));
*this = nsSpecialSystemDirectory::Mac_TrashDirectory;
break;
case 303: /////////////////////////////////////////////////////////// Mac Startup
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_StartupDirectory ));
*this = nsSpecialSystemDirectory::Mac_StartupDirectory;
break;
case 304: /////////////////////////////////////////////////////////// Mac Shutdown
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_StartupDirectory ));
*this = nsSpecialSystemDirectory::Mac_StartupDirectory;
break;
case 305: /////////////////////////////////////////////////////////// Mac Apple Menu
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_AppleMenuDirectory ));
*this = nsSpecialSystemDirectory::Mac_AppleMenuDirectory;
break;
case 306: /////////////////////////////////////////////////////////// Mac Control Panel
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_ControlPanelDirectory ));
*this = nsSpecialSystemDirectory::Mac_ControlPanelDirectory;
break;
case 307: /////////////////////////////////////////////////////////// Mac Extension
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_ExtensionDirectory ));
*this = nsSpecialSystemDirectory::Mac_ExtensionDirectory;
break;
case 308: /////////////////////////////////////////////////////////// Mac Fonts
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_FontsDirectory ));
*this = nsSpecialSystemDirectory::Mac_FontsDirectory;
break;
case 309: /////////////////////////////////////////////////////////// Mac Preferences
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_PreferencesDirectory ));
*this = nsSpecialSystemDirectory::Mac_PreferencesDirectory;
break;
case 310: /////////////////////////////////////////////////////////// Mac Documents
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Mac_DocumentsDirectory ));
*this = nsSpecialSystemDirectory::Mac_DocumentsDirectory;
break;
case 400: /////////////////////////////////////////////////////////// Unix Local
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Unix_LocalDirectory ));
*this = nsSpecialSystemDirectory::Unix_LocalDirectory;
break;
case 401: /////////////////////////////////////////////////////////// Unix Lib
mFileSpec = new nsFileSpec( nsSpecialSystemDirectory( nsSpecialSystemDirectory::Unix_LibDirectory ));
*this = nsSpecialSystemDirectory::Unix_LibDirectory;
break;
case -1:
default:
mFileSpec = nsnull;
return;
}
#ifndef XP_MAC
@@ -314,23 +271,11 @@ nsInstallFolder::MapNameToEnum(const nsString& name)
}
static NS_DEFINE_IID(kFileLocatorIID, NS_IFILELOCATOR_IID);
static NS_DEFINE_IID(kFileLocatorCID, NS_FILELOCATOR_CID);
void
nsInstallFolder::SetAppShellDirectory(PRUint32 value)
//----------------------------------------------------------------------------------------
void nsInstallFolder::operator = (enum nsSpecialSystemDirectory::SystemDirectories aSystemSystemDirectory)
//----------------------------------------------------------------------------------------
{
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);
}
}
nsSpecialSystemDirectory temp(aSystemSystemDirectory);
mFileSpec = new nsFileSpec(temp);
}

View File

@@ -40,7 +40,7 @@ class nsInstallFolder
nsInstallFolder(const nsString& aFolderID);
nsInstallFolder(const nsString& aFolderID, const nsString& aRelativePath);
virtual ~nsInstallFolder();
~nsInstallFolder();
void GetDirectoryPath(nsString& aDirectoryPath);
@@ -51,7 +51,8 @@ class nsInstallFolder
void SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath);
void PickDefaultDirectory();
PRInt32 MapNameToEnum(const nsString& name);
void SetAppShellDirectory(PRUint32 value);
void operator = (enum nsSpecialSystemDirectory::SystemDirectories aSystemSystemDirectory);
};

View File

@@ -62,7 +62,7 @@ static int32 gdiff_validateFile( pDIFFDATA dd, int file );
nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
const nsString& inVRName,
const nsString& inVInfo,
nsIDOMInstallVersion* inVInfo,
const nsString& inJarLocation,
PRInt32 *error)
@@ -87,18 +87,21 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
mPatchedFile = nsnull;
mRegistryName = new nsString(inVRName);
mJarLocation = new nsString(inJarLocation);
mTargetFile = new nsFileSpec(folderSpec);
nsString tempString;
inVInfo->ToString(tempString);
mVersionInfo = new nsInstallVersion();
mVersionInfo->Init(tempString);
mVersionInfo = new nsInstallVersion();
mVersionInfo->Init(inVInfo);
mTargetFile = new nsFileSpec(folderSpec);
}
nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
const nsString& inVRName,
const nsString& inVInfo,
nsIDOMInstallVersion* inVInfo,
const nsString& inJarLocation,
const nsString& folderSpec,
const nsString& inPartialPath,
@@ -117,12 +120,15 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
mPatchedFile = nsnull;
mRegistryName = new nsString(inVRName);
mJarLocation = new nsString(inJarLocation);
mVersionInfo = new nsInstallVersion();
nsString tempString;
inVInfo->ToString(tempString);
mVersionInfo = new nsInstallVersion();
mVersionInfo->Init(tempString);
mVersionInfo->Init(inVInfo);
mTargetFile = new nsFileSpec(folderSpec);
if(inPartialPath != "null")
mTargetFile = new nsFileSpec(folderSpec);
if(inPartialPath != "null")
*mTargetFile += inPartialPath;
}
@@ -210,7 +216,7 @@ PRInt32 nsInstallPatch::Prepare()
if ( deleteOldSrc )
{
DeleteFileNowOrSchedule(*fileName );
DeleteFileLater(*fileName );
}
return err;
@@ -233,7 +239,7 @@ PRInt32 nsInstallPatch::Complete()
if (fileName != nsnull && (*fileName == *mPatchedFile) )
{
// the patch has not been superceded--do final replacement
err = ReplaceFileNowOrSchedule( *mTargetFile, *mPatchedFile);
err = ReplaceFileLater( *mTargetFile, *mPatchedFile);
if ( 0 == err || nsInstall::REBOOT_NEEDED == err )
{
nsString tempVersionString;
@@ -274,7 +280,7 @@ void nsInstallPatch::Abort()
if (fileName != nsnull && (*fileName == *mPatchedFile) )
{
DeleteFileNowOrSchedule( *mPatchedFile );
DeleteFileLater( *mPatchedFile );
}
}

View File

@@ -26,7 +26,7 @@
#include "nsInstall.h"
#include "nsInstallFolder.h"
#include "nsInstallVersion.h"
#include "nsIDOMInstallVersion.h"
class nsInstallPatch : public nsInstallObject
@@ -35,7 +35,7 @@ class nsInstallPatch : public nsInstallObject
nsInstallPatch( nsInstall* inInstall,
const nsString& inVRName,
const nsString& inVInfo,
nsIDOMInstallVersion* inVInfo,
const nsString& inJarLocation,
const nsString& folderSpec,
const nsString& inPartialPath,
@@ -43,7 +43,7 @@ class nsInstallPatch : public nsInstallObject
nsInstallPatch( nsInstall* inInstall,
const nsString& inVRName,
const nsString& inVInfo,
nsIDOMInstallVersion* inVInfo,
const nsString& inJarLocation,
PRInt32 *error);

View File

@@ -1,343 +0,0 @@
/* -*- 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;
}

View File

@@ -1,67 +0,0 @@
/* -*- 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

View File

@@ -27,24 +27,14 @@
#include "nsISupports.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPref.h"
#include "nsRepository.h"
#include "nsIServiceManager.h"
#include "nsSpecialSystemDirectory.h"
#include "pratom.h"
#include "prefapi.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()
{
@@ -124,37 +114,11 @@ nsInstallTrigger::SetScriptObject(void *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;
PREF_GetBoolPref( (const char*) AUTOUPDATE_ENABLE_PREF, aReturn);
return NS_OK;
}
@@ -162,11 +126,12 @@ nsInstallTrigger::UpdateEnabled(PRBool* aReturn)
NS_IMETHODIMP
nsInstallTrigger::StartSoftwareUpdate(const nsString& aURL, PRInt32 aFlags, PRInt32* aReturn)
{
nsString localFile;
CreateTempFileFromURL(aURL, localFile);
// fix: aFlags is not processed!
nsInstallInfo *nextInstall = new nsInstallInfo( aURL, "", "");
// start the download (this will clean itself up)
nsSoftwareUpdateListener *downloader = new nsSoftwareUpdateListener(aURL, localFile, aFlags);
nsSoftwareUpdateListener *downloader = new nsSoftwareUpdateListener(nextInstall);
*aReturn = NS_OK; // maybe we should do something more.
return NS_OK;
@@ -175,11 +140,14 @@ nsInstallTrigger::StartSoftwareUpdate(const nsString& aURL, PRInt32 aFlags, PRIn
NS_IMETHODIMP
nsInstallTrigger::StartSoftwareUpdate(const nsString& aURL, PRInt32* aReturn)
{
nsString localFile;
CreateTempFileFromURL(aURL, localFile);
PRInt32 aFlags = 0;
// fix: aFlags is not processed!
nsInstallInfo *nextInstall = new nsInstallInfo( aURL, "", "");
// start the download (this will clean itself up)
nsSoftwareUpdateListener *downloader = new nsSoftwareUpdateListener(aURL, localFile, 0);
nsSoftwareUpdateListener *downloader = new nsSoftwareUpdateListener(nextInstall);
*aReturn = NS_OK; // maybe we should do something more.
return NS_OK;
@@ -240,120 +208,104 @@ nsInstallTrigger::CompareVersion(const nsString& aRegName, nsIDOMInstallVersion*
}
// 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) ) );
}
}
/////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////
static PRInt32 gInstallTriggerInstanceCnt = 0;
static PRInt32 gInstallTriggerLock = 0;
nsInstallTriggerFactory::nsInstallTriggerFactory(void)
{
NS_INIT_REFCNT();
mRefCnt=0;
PR_AtomicIncrement(&gInstallTriggerInstanceCnt);
}
nsInstallTriggerFactory::~nsInstallTriggerFactory(void)
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
PR_AtomicDecrement(&gInstallTriggerInstanceCnt);
}
NS_IMETHODIMP
nsInstallTriggerFactory::QueryInterface(const nsIID &aIID, void **aResult)
NS_IMETHODIMP
nsInstallTriggerFactory::QueryInterface(REFNSIID aIID,void** aInstancePtr)
{
if (! aResult)
if (aInstancePtr == NULL)
{
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;
// Always NULL result, in case of failure
*aInstancePtr = NULL;
if ( aIID.Equals(kISupportsIID) )
{
*aInstancePtr = (void*) this;
}
else if ( aIID.Equals(kIFactoryIID) )
{
*aInstancePtr = (void*) this;
}
if (aInstancePtr == NULL)
{
return NS_ERROR_NO_INTERFACE;
}
AddRef();
return NS_OK;
}
NS_IMPL_ADDREF(nsInstallTriggerFactory);
NS_IMPL_RELEASE(nsInstallTriggerFactory);
NS_IMETHODIMP
nsInstallTriggerFactory::AddRef(void)
{
return ++mRefCnt;
}
NS_IMETHODIMP
nsInstallTriggerFactory::Release(void)
{
if (--mRefCnt ==0)
{
delete this;
return 0; // Don't access mRefCnt after deleting!
}
return mRefCnt;
}
NS_IMETHODIMP
nsInstallTriggerFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (! aResult)
if (aResult == NULL)
{
return NS_ERROR_NULL_POINTER;
}
*aResult = nsnull;
nsresult rv;
*aResult = NULL;
/* do I have to use iSupports? */
nsInstallTrigger *inst = new nsInstallTrigger();
if (! inst)
if (inst == NULL)
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;
nsresult result = inst->QueryInterface(aIID, aResult);
if (NS_FAILED(result))
delete inst;
return result;
}
NS_IMETHODIMP
nsInstallTriggerFactory::LockFactory(PRBool aLock)
{
// Not implemented in simplest case.
if (aLock)
PR_AtomicIncrement(&gInstallTriggerLock);
else
PR_AtomicDecrement(&gInstallTriggerLock);
return NS_OK;
}

View File

@@ -14,10 +14,6 @@
#include "nsHashtable.h"
#include "nsVector.h"
class nsInstallTrigger: public nsIScriptObjectOwner, public nsIDOMInstallTriggerGlobal
{
public:
@@ -47,7 +43,6 @@ class nsInstallTrigger: public nsIScriptObjectOwner, public nsIDOMInstallTrigger
private:
void *mScriptObject;
void CreateTempFileFromURL(const nsString& aURL, nsString& tempFileString);
};

View File

@@ -182,14 +182,14 @@ REGERR su_UninstallProcessItem(char *component_path)
else
{
err = VR_Remove(component_path);
DeleteFileNowOrSchedule(nsFileSpec(filepath));
DeleteFileLater(nsFileSpec(filepath));
}
}
else
{
/* delete node and file */
err = VR_Remove(component_path);
DeleteFileNowOrSchedule(nsFileSpec(filepath));
DeleteFileLater(nsFileSpec(filepath));
}
}
return err;

View File

@@ -27,6 +27,7 @@
#include "nsISupports.h"
#include "nsIScriptGlobalObject.h"
#include "pratom.h"
#include "prprf.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
@@ -333,40 +334,69 @@ nsInstallVersion::StringToVersionNumbers(const nsString& version, PRInt32 *aMajo
/////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////
static PRInt32 gInstallVersionInstanceCnt = 0;
static PRInt32 gInstallVersionLock = 0;
nsInstallVersionFactory::nsInstallVersionFactory(void)
{
NS_INIT_REFCNT();
mRefCnt=0;
PR_AtomicIncrement(&gInstallVersionInstanceCnt);
}
nsInstallVersionFactory::~nsInstallVersionFactory(void)
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
PR_AtomicDecrement(&gInstallVersionInstanceCnt);
}
NS_IMETHODIMP
nsInstallVersionFactory::QueryInterface(const nsIID &aIID, void **aResult)
NS_IMETHODIMP
nsInstallVersionFactory::QueryInterface(REFNSIID aIID,void** aInstancePtr)
{
if (! aResult)
if (aInstancePtr == NULL)
{
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aResult = nsnull;
*aInstancePtr = NULL;
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;
if ( aIID.Equals(kISupportsIID) )
{
*aInstancePtr = (void*) this;
}
return NS_NOINTERFACE;
else if ( aIID.Equals(kIFactoryIID) )
{
*aInstancePtr = (void*) this;
}
if (aInstancePtr == NULL)
{
return NS_ERROR_NO_INTERFACE;
}
AddRef();
return NS_OK;
}
NS_IMPL_ADDREF(nsInstallVersionFactory);
NS_IMPL_RELEASE(nsInstallVersionFactory);
NS_IMETHODIMP
nsInstallVersionFactory::AddRef(void)
{
return ++mRefCnt;
}
NS_IMETHODIMP
nsInstallVersionFactory::Release(void)
{
if (--mRefCnt ==0)
{
delete this;
return 0; // Don't access mRefCnt after deleting!
}
return mRefCnt;
}
NS_IMETHODIMP
nsInstallVersionFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
@@ -395,5 +425,10 @@ nsInstallVersionFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void
NS_IMETHODIMP
nsInstallVersionFactory::LockFactory(PRBool aLock)
{
return NS_OK;
}
if (aLock)
PR_AtomicIncrement(&gInstallVersionLock);
else
PR_AtomicDecrement(&gInstallVersionLock);
return NS_OK;
}

View File

@@ -18,7 +18,7 @@ class nsInstallVersion: public nsIScriptObjectOwner, public nsIDOMInstallVersion
static const nsIID& IID() { static nsIID iid = NS_SoftwareUpdateInstallVersion_CID; return iid; }
nsInstallVersion();
virtual ~nsInstallVersion();
~nsInstallVersion();
NS_DECL_ISUPPORTS
@@ -61,7 +61,7 @@ class nsInstallVersionFactory : public nsIFactory
public:
nsInstallVersionFactory();
virtual ~nsInstallVersionFactory();
~nsInstallVersionFactory();
NS_DECL_ISUPPORTS

File diff suppressed because it is too large Load Diff

View File

@@ -29,19 +29,19 @@
#include "nsIDOMInstallVersion.h"
#include "nsIDOMInstallTriggerGlobal.h"
extern void ConvertJSValToStr(nsString& aString,
extern void nsCvrtJSValToStr(nsString& aString,
JSContext* aContext,
jsval aValue);
extern void ConvertStrToJSVal(const nsString& aProp,
extern void nsCvrtStrToJSVal(const nsString& aProp,
JSContext* aContext,
jsval* aReturn);
extern PRBool ConvertJSValToBool(PRBool* aProp,
extern PRBool nsCvrtJSValToBool(PRBool* aProp,
JSContext* aContext,
jsval aValue);
extern PRBool ConvertJSValToObj(nsISupports** aSupports,
extern PRBool nsCvrtJSValToObj(nsISupports** aSupports,
REFNSIID aIID,
const nsString& aTypeName,
JSContext* aContext,
@@ -199,7 +199,7 @@ InstallTriggerGlobalStartSoftwareUpdate(JSContext *cx, JSObject *obj, uintN argc
// public int StartSoftwareUpdate(String url,
// int flag);
ConvertJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b0, cx, argv[0]);
if(!JS_ValueToInt32(cx, argv[1], (int32 *)&b1))
{
@@ -218,7 +218,7 @@ InstallTriggerGlobalStartSoftwareUpdate(JSContext *cx, JSObject *obj, uintN argc
{
// public int StartSoftwareUpdate(String url);
ConvertJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b0, cx, argv[0]);
if(NS_OK != nativeThis->StartSoftwareUpdate(b0, &nativeRet))
{
@@ -269,8 +269,8 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
// String version, --OR-- VersionInfo version
// int mode);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsCvrtJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b1, cx, argv[1]);
if(!JS_ValueToInt32(cx, argv[2], (int32 *)&b2int))
{
@@ -283,7 +283,7 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
JS_ReportError(cx, "5th parameter must be a number");
return JS_FALSE;
}
if(JSVAL_IS_OBJECT(argv[3]))
{
JSObject* jsobj = JSVAL_TO_OBJECT(argv[3]);
@@ -300,7 +300,7 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
}
else
{
ConvertJSValToStr(b3str, cx, argv[3]);
nsCvrtJSValToStr(b3str, cx, argv[3]);
if(NS_OK != nativeThis->ConditionalSoftwareUpdate(b0, b1, b2int, b3str, b4, &nativeRet))
{
return JS_FALSE;
@@ -316,8 +316,8 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
// String version, --OR-- VersionInfo version
// int mode);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsCvrtJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b1, cx, argv[1]);
if(!JS_ValueToInt32(cx, argv[3], (int32 *)&b3int))
{
@@ -341,7 +341,7 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
}
else
{
ConvertJSValToStr(b2str, cx, argv[2]);
nsCvrtJSValToStr(b2str, cx, argv[2]);
if(NS_OK != nativeThis->ConditionalSoftwareUpdate(b0, b1, b2str, b3int, &nativeRet))
{
return JS_FALSE;
@@ -356,8 +356,8 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
// String registryName,
// String version); --OR-- VersionInfo version
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsCvrtJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b1, cx, argv[1]);
if(JSVAL_IS_OBJECT(argv[2]))
{
@@ -375,7 +375,7 @@ InstallTriggerGlobalConditionalSoftwareUpdate(JSContext *cx, JSObject *obj, uint
}
else
{
ConvertJSValToStr(b2str, cx, argv[2]);
nsCvrtJSValToStr(b2str, cx, argv[2]);
if(NS_OK != nativeThis->ConditionalSoftwareUpdate(b0, b1, b2str, &nativeRet))
{
return JS_FALSE;
@@ -425,7 +425,7 @@ InstallTriggerGlobalCompareVersion(JSContext *cx, JSObject *obj, uintN argc, jsv
// int release,
// int build);
ConvertJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b0, cx, argv[0]);
if(!JS_ValueToInt32(cx, argv[1], (int32 *)&b1int))
{
@@ -460,7 +460,7 @@ InstallTriggerGlobalCompareVersion(JSContext *cx, JSObject *obj, uintN argc, jsv
// public int CompareVersion(String registryName,
// String version); --OR-- VersionInfo version
ConvertJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b0, cx, argv[0]);
if(JSVAL_IS_OBJECT(argv[1]))
{
@@ -478,7 +478,7 @@ InstallTriggerGlobalCompareVersion(JSContext *cx, JSObject *obj, uintN argc, jsv
}
else
{
ConvertJSValToStr(b1str, cx, argv[1]);
nsCvrtJSValToStr(b1str, cx, argv[1]);
if(NS_OK != nativeThis->CompareVersion(b0, b1str, &nativeRet))
{
return JS_FALSE;

View File

@@ -31,26 +31,24 @@
#include "nsRepository.h"
#include "nsDOMCID.h"
extern void ConvertJSValToStr(nsString& aString,
extern void nsCvrtJSValToStr(nsString& aString,
JSContext* aContext,
jsval aValue);
extern void ConvertStrToJSVal(const nsString& aProp,
extern void nsCvrtStrToJSVal(const nsString& aProp,
JSContext* aContext,
jsval* aReturn);
extern PRBool ConvertJSValToBool(PRBool* aProp,
extern PRBool nsCvrtJSValToBool(PRBool* aProp,
JSContext* aContext,
jsval aValue);
extern PRBool ConvertJSValToObj(nsISupports** aSupports,
extern PRBool nsCvrtJSValToObj(nsISupports** aSupports,
REFNSIID aIID,
const nsString& aTypeName,
JSContext* aContext,
jsval aValue);
void ConvertJSvalToVersionString(nsString& versionString, JSContext* cx, jsval* argument);
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
@@ -401,7 +399,7 @@ InstallVersionCompareTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
if(JSVAL_IS_OBJECT(argv[0]))
{
if(JS_FALSE == ConvertJSValToObj((nsISupports **)&versionObj,
if(JS_FALSE == nsCvrtJSValToObj((nsISupports **)&versionObj,
kIInstallVersionIID,
"InstallVersion",
cx,
@@ -417,7 +415,7 @@ InstallVersionCompareTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
}
else
{
ConvertJSValToStr(b0str, cx, argv[0]);
nsCvrtJSValToStr(b0str, cx, argv[0]);
if(NS_OK != nativeThis->CompareTo(b0str, &nativeRet))
{

View File

@@ -1,207 +0,0 @@
/* -*- 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.
*/
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsString.h"
#include "nsInstall.h"
#include "nsWinProfile.h"
#include "nsJSWinProfile.h"
extern void ConvertJSValToStr(nsString& aString,
JSContext* aContext,
jsval aValue);
extern void ConvertStrToJSVal(const nsString& aProp,
JSContext* aContext,
jsval* aReturn);
extern PRBool ConvertJSValToBool(PRBool* aProp,
JSContext* aContext,
jsval aValue);
extern PRBool ConvertJSValToObj(nsISupports** aSupports,
REFNSIID aIID,
const nsString& aTypeName,
JSContext* aContext,
jsval aValue);
static void PR_CALLBACK WinProfileCleanup(JSContext *cx, JSObject *obj)
{
nsWinProfile *nativeThis = (nsWinProfile*)JS_GetPrivate(cx, obj);
delete nativeThis;
}
/***********************************************************************************/
// Native mothods for WinProfile functions
//
// Native method GetString
//
PR_STATIC_CALLBACK(JSBool)
WinProfileGetString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinProfile *nativeThis = (nsWinProfile*)JS_GetPrivate(cx, obj);
nsString nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 2)
{
// public int getString ( String section,
// String key);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nativeThis->getString(b0, b1, &nativeRet);
ConvertStrToJSVal(nativeRet, cx, rval);
}
else
{
JS_ReportError(cx, "WinProfile.getString() parameters error");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method WriteString
//
PR_STATIC_CALLBACK(JSBool)
WinProfileWriteString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinProfile *nativeThis = (nsWinProfile*)JS_GetPrivate(cx, obj);
PRInt32 nativeRet;
nsAutoString b0;
nsAutoString b1;
nsAutoString b2;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if(nsnull == nativeThis)
{
return JS_TRUE;
}
if(argc >= 3)
{
// public int writeString ( String section,
// String key,
// String value);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
ConvertJSValToStr(b2, cx, argv[2]);
if(NS_OK != nativeThis->writeString(b0, b1, b2, &nativeRet))
{
return JS_FALSE;
}
*rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportError(cx, "WinProfile.writeString() parameters error");
return JS_FALSE;
}
return JS_TRUE;
}
//
// WinProfile constructor
//
PR_STATIC_CALLBACK(JSBool)
WinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_FALSE;
}
/***********************************************************************/
//
// class for WinProfile
//
JSClass WinProfileClass = {
"WinProfile",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
JS_PropertyStub,
JS_PropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
WinProfileCleanup
};
static JSConstDoubleSpec winprofile_constants[] =
{
{0}
};
//
// WinProfile class methods
//
static JSFunctionSpec WinProfileMethods[] =
{
{"getString", WinProfileGetString, 2},
{"writeString", WinProfileWriteString, 3},
{0}
};
PRInt32
InitWinProfilePrototype(JSContext *jscontext, JSObject *global, JSObject **winProfilePrototype)
{
*winProfilePrototype = JS_InitClass( jscontext, // context
global, // global object
nsnull, // parent proto
&WinProfileClass, // JSClass
nsnull, // JSNative ctor
0, // ctor args
nsnull, // proto props
nsnull, // proto funcs
nsnull, // ctor props (static)
WinProfileMethods); // ctor funcs (static)
if(nsnull == *winProfilePrototype)
{
return NS_ERROR_FAILURE;
}
if(PR_FALSE == JS_DefineConstDoubles(jscontext, *winProfilePrototype, winprofile_constants))
return NS_ERROR_FAILURE;
return NS_OK;
}

View File

@@ -1,25 +0,0 @@
/* -*- 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.
*/
#ifndef __NS_JSWINPROTOTYPE_H__
#define __NS_JSWINPROTOTYPE_H__
PRInt32
InitWinProfilePrototype(JSContext *jscontext, JSObject *global, JSObject **winRegPrototype);
#endif

View File

@@ -17,6 +17,7 @@
*/
#include "jsapi.h"
//#include "nsJSUtils.h"
#include "nscore.h"
#include "nsIScriptContext.h"
@@ -25,21 +26,24 @@
#include "nsWinReg.h"
#include "nsJSWinReg.h"
//extern JSClass WinRegClass;
// extern JSClass WinProfileClass;
static void PR_CALLBACK WinRegCleanup(JSContext *cx, JSObject *obj);
extern void ConvertJSValToStr(nsString& aString,
extern void nsCvrtJSValToStr(nsString& aString,
JSContext* aContext,
jsval aValue);
extern void ConvertStrToJSVal(const nsString& aProp,
extern void nsCvrtStrToJSVal(const nsString& aProp,
JSContext* aContext,
jsval* aReturn);
extern PRBool ConvertJSValToBool(PRBool* aProp,
extern PRBool nsCvrtJSValToBool(PRBool* aProp,
JSContext* aContext,
jsval aValue);
extern PRBool ConvertJSValToObj(nsISupports** aSupports,
extern PRBool nsCvrtJSValToObj(nsISupports** aSupports,
REFNSIID aIID,
const nsString& aTypeName,
JSContext* aContext,
@@ -124,8 +128,8 @@ WinRegCreateKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
// public int createKey ( String subKey,
// String className);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsCvrtJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b1, cx, argv[1]);
if(NS_OK != nativeThis->createKey(b0, b1, &nativeRet))
{
@@ -165,7 +169,7 @@ WinRegDeleteKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
{
// public int deleteKey ( String subKey);
ConvertJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b0, cx, argv[0]);
if(NS_OK != nativeThis->deleteKey(b0, &nativeRet))
{
@@ -208,8 +212,8 @@ WinRegDeleteValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
// public int deleteValue ( String subKey,
// String valueName);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsCvrtJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b1, cx, argv[1]);
if(NS_OK != nativeThis->deleteValue(b0, b1, &nativeRet))
{
@@ -253,9 +257,9 @@ WinRegSetValueString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
// String valueName,
// String value);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
ConvertJSValToStr(b2, cx, argv[2]);
nsCvrtJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b1, cx, argv[1]);
nsCvrtJSValToStr(b2, cx, argv[2]);
if(NS_OK != nativeThis->setValueString(b0, b1, b2, &nativeRet))
{
@@ -297,8 +301,8 @@ WinRegGetValueString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
// public int getValueString ( String subKey,
// String valueName);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsCvrtJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b1, cx, argv[1]);
if(NS_OK != nativeThis->getValueString(b0, b1, &nativeRet))
{
@@ -342,12 +346,12 @@ WinRegSetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
// String valueName,
// nsWinRegItem *value);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsCvrtJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b1, cx, argv[1]);
// fix: this parameter is an object, not a string.
// A way needs to be figured out to convert the JSVAL to this object type
// ConvertJSValToStr(b2, cx, argv[2]);
// nsCvrtJSValToStr(b2, cx, argv[2]);
// if(NS_OK != nativeThis->setValue(b0, b1, b2, &nativeRet))
// {
@@ -389,8 +393,8 @@ WinRegGetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
// public int getValue ( String subKey,
// String valueName);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nsCvrtJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b1, cx, argv[1]);
if(NS_OK != nativeThis->getValue(b0, b1, &nativeRet))
{
@@ -444,6 +448,14 @@ WinReg(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return JS_FALSE;
}
//
// WinProfile constructor
//
PR_STATIC_CALLBACK(JSBool)
WinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_FALSE;
}
/***********************************************************************/
//

View File

@@ -1,134 +0,0 @@
/* -*- 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 "nsLoggingProgressNotifier.h"
#include "nsFileSpec.h"
#include "nsFileStream.h"
#include "nsSpecialSystemDirectory.h"
#include "nspr.h"
nsLoggingProgressNotifier::nsLoggingProgressNotifier()
{
NS_INIT_REFCNT();
}
nsLoggingProgressNotifier::~nsLoggingProgressNotifier()
{
}
NS_IMPL_ISUPPORTS(nsLoggingProgressNotifier, nsIXPInstallProgress::GetIID());
NS_IMETHODIMP
nsLoggingProgressNotifier::BeforeJavascriptEvaluation()
{
nsSpecialSystemDirectory logFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
logFile += "Install.log";
mLogStream = new nsOutputFileStream(logFile, PR_WRONLY | PR_CREATE_FILE | PR_APPEND, 0744 );
mLogStream->seek(logFile.GetFileSize());
return NS_OK;
}
NS_IMETHODIMP
nsLoggingProgressNotifier::AfterJavascriptEvaluation()
{
char* time;
GetTime(&time);
*mLogStream << nsEndl;
*mLogStream << " Finished Installation " << time << nsEndl << nsEndl;
PL_strfree(time);
mLogStream->close();
delete mLogStream;
mLogStream = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsLoggingProgressNotifier::InstallStarted(const char* UIPackageName)
{
if (mLogStream == nsnull) return -1;
char* time;
GetTime(&time);
*mLogStream << "---------------------------------------------------------------------------" << nsEndl;
*mLogStream << UIPackageName << nsEndl;
*mLogStream << "---------------------------------------------------------------------------" << nsEndl;
*mLogStream << nsEndl;
*mLogStream << " Starting Installation at " << nsAutoCString(time) << nsEndl;
*mLogStream << nsEndl;
PL_strfree(time);
return NS_OK;
}
NS_IMETHODIMP
nsLoggingProgressNotifier::ItemScheduled(const char* message )
{
return NS_OK;
}
NS_IMETHODIMP
nsLoggingProgressNotifier::InstallFinalization(const char* message, PRInt32 itemNum, PRInt32 totNum )
{
if (mLogStream == nsnull) return -1;
*mLogStream << " Item [" << (itemNum+1) << "/" << totNum << "]\t" << message << nsEndl;
return NS_OK;
}
NS_IMETHODIMP
nsLoggingProgressNotifier::InstallAborted()
{
if (mLogStream == nsnull) return -1;
char* time;
GetTime(&time);
*mLogStream << " Aborted Installation at " << time << nsEndl << nsEndl;
PL_strfree(time);
return NS_OK;
}
void
nsLoggingProgressNotifier::GetTime(char** aString)
{
PRExplodedTime et;
char line[256];
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &et);
PR_FormatTimeUSEnglish(line, sizeof(line), "%m/%d/%Y %H:%M:%S", &et);
*aString = PL_strdup(line);
}

View File

@@ -1,55 +0,0 @@
/* -*- 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 nsLoggingProgressNotifier_H__
#define nsLoggingProgressNotifier_H__
#include "nsIXPInstallProgress.h"
#include "nsFileStream.h"
class nsLoggingProgressNotifier : public nsIXPInstallProgress
{
public:
nsLoggingProgressNotifier();
virtual ~nsLoggingProgressNotifier();
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();
private:
void GetTime(char** aString);
nsOutputFileStream *mLogStream;
};
#endif

View File

@@ -0,0 +1,117 @@
/* -*- 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 nsSoftUpdateEnums_h__
#define nsSoftUpdateEnums_h__
/* SoftwareUpdate Errors -200 to -300 */
#define SUERR_BAD_PACKAGE_NAME -200
#define SUERR_UNEXPECTED_ERROR -201
#define SUERR_ACCESS_DENIED -202
#define SUERR_TOO_MANY_CERTIFICATES -203 /* Installer file must have 1 certificate */
#define SUERR_NO_INSTALLER_CERTIFICATE -204 /* Installer file must have a certificate */
#define SUERR_NO_CERTIFICATE -205 /* Extracted file is not signed */
#define SUERR_NO_MATCHING_CERTIFICATE -206 /* Extracted file does not match installer certificate */
#define SUERR_UNKNOWN_JAR_FILE -207 /* JAR file has not been opened */
#define SUERR_INVALID_ARGUMENTS -208 /* Bad arguments to a function */
#define SUERR_ILLEGAL_RELATIVE_PATH -209 /* Illegal relative path */
#define SUERR_USER_CANCELLED -210 /* User cancelled */
#define SUERR_INSTALL_NOT_STARTED -211
#define SUERR_SILENT_MODE_DENIED -212
#define SUERR_NO_SUCH_COMPONENT -213 /* no such component in the registry. */
#define SUERR_FILE_DOES_NOT_EXIST -214 /* File cannot be deleted as it does not exist */
#define SUERR_FILE_READ_ONLY -215 /* File cannot be deleted as it is read only. */
#define SUERR_FILE_IS_DIRECTORY -216 /* File cannot be deleted as it is a directory */
#define SUERR_NETWORK_FILE_IS_IN_USE -217 /* File on the network is in-use */
#define SUERR_APPLE_SINGLE_ERR -218 /* error in AppleSingle unpacking */
#define SUERR_INVALID_PATH_ERR -219 /* GetFolder() did not like the folderID */
#define SUERR_PATCH_BAD_DIFF -220 /* error in GDIFF patch */
#define SUERR_PATCH_BAD_CHECKSUM_TARGET -221 /* source file doesn't checksum */
#define SUERR_PATCH_BAD_CHECKSUM_RESULT -222 /* final patched file fails checksum */
#define SUERR_UNINSTALL_FAILED -223 /* error while uninstalling a package */
#define SUERR_GESTALT_UNKNOWN_ERR -5550
#define SUERR_GESTALT_INVALID_ARGUMENT -5551
#define SU_SUCCESS 0
#define SU_REBOOT_NEEDED 999
/* install types */
#define SU_LIMITED_INSTALL 0
#define SU_FULL_INSTALL 1
#define SU_NO_STATUS_DLG 2
#define SU_NO_FINALIZE_DLG 4
typedef enum nsVersionEnum {
nsVersionEnum_MAJOR_DIFF = 4,
nsVersionEnum_MAJOR_DIFF_MINUS = -4,
nsVersionEnum_MINOR_DIFF = 3,
nsVersionEnum_MINOR_DIFF_MINUS = -3,
nsVersionEnum_REL_DIFF = 2,
nsVersionEnum_REL_DIFF_MINUS = -2,
nsVersionEnum_BLD_DIFF = 1,
nsVersionEnum_BLD_DIFF_MINUS = -1,
nsVersionEnum_EQUAL = 0
} nsVersionEnum;
//typedef enum nsInstallDeleteEnum {
// DELETE_FILE = 1,
// DELETE_COMPONENT=2
//} nsInstallDeleteEnum;
/**
* diff levels are borrowed from the VersionInfo class
*/
typedef enum nsTriggerDiffLevelEnum {
MAJOR_DIFF = 4,
MINOR_DIFF = 3,
REL_DIFF = 2,
BLD_DIFF = 1,
EQUAL = 0
} nsTriggerDiffLevelEnum;
typedef enum nsWinRegEnum {
NS_WIN_REG_CREATE = 1,
NS_WIN_REG_DELETE = 2,
NS_WIN_REG_DELETE_VAL = 3,
NS_WIN_REG_SET_VAL_STRING = 4,
NS_WIN_REG_SET_VAL = 5
} nsWinRegEnum;
typedef enum nsWinRegValueEnum {
NS_WIN_REG_SZ = 1,
NS_WIN_REG_EXPAND_SZ = 2,
NS_WIN_REG_BINARY = 3,
NS_WIN_REG_DWORD = 4,
NS_WIN_REG_DWORD_LITTLE_ENDIAN = 4,
NS_WIN_REG_DWORD_BIG_ENDIAN = 5,
NS_WIN_REG_LINK = 6,
NS_WIN_REG_MULTI_SZ = 7,
NS_WIN_REG_RESOURCE_LIST = 8,
NS_WIN_REG_FULL_RESOURCE_DESCRIPTOR = 9,
NS_WIN_REG_RESOURCE_REQUIREMENTS_LIST = 10
} nsWinRegValueEnum;
typedef enum nsRegistryErrorsEnum {
REGERR_SECURITY = 99,
} nsRegistryErrorsEnum;
#endif /* nsSoftUpdateEnums_h__ */

View File

@@ -38,13 +38,6 @@
#include "nsInstallVersion.h"
#include "ScheduledTasks.h"
#include "nsTopProgressNotifier.h"
#include "nsLoggingProgressNotifier.h"
#include "nsInstallProgressDialog.h"
#include "nsIAppShellComponent.h"
#include "nsIRegistry.h"
/* For Javascript Namespace Access */
#include "nsDOMCID.h"
#include "nsIServiceManager.h"
@@ -55,10 +48,6 @@
#include "nsIScriptNameSpaceManager.h"
#include "nsIScriptExternalNameSet.h"
#include "nsIEventQueueService.h"
#include "nsProxyObjectManager.h"
////////////////////////////////////////////////////////////////////////////////
// Globals
////////////////////////////////////////////////////////////////////////////////
@@ -81,19 +70,39 @@ static NS_DEFINE_IID(kInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID);
static NS_DEFINE_IID(kIInstallVersion_IID, NS_IDOMINSTALLVERSION_IID);
static NS_DEFINE_IID(kInstallVersion_CID, NS_SoftwareUpdateInstallVersion_CID);
static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID);
static NS_DEFINE_IID(kEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
nsSoftwareUpdate* nsSoftwareUpdate::mInstance = NULL;
nsSoftwareUpdate::nsSoftwareUpdate()
{
#ifdef NS_DEBUG
printf("XPInstall Component created\n");
#endif
NS_INIT_ISUPPORTS();
/***************************************/
Startup();
}
nsSoftwareUpdate::~nsSoftwareUpdate()
{
Shutdown();
}
nsSoftwareUpdate *nsSoftwareUpdate::GetInstance()
{
if (mInstance == NULL)
{
mInstance = new nsSoftwareUpdate();
}
return mInstance;
}
NS_IMPL_ISUPPORTS(nsSoftwareUpdate,nsISoftwareUpdate::GetIID());
nsresult
nsSoftwareUpdate::Startup()
{
/***************************************/
/* Create us a queue */
/***************************************/
mInstalling = nsnull;
@@ -116,11 +125,11 @@ nsSoftwareUpdate::nsSoftwareUpdate()
/* Startup the Version Registry */
/***************************************/
nsSpecialSystemDirectory appDir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
VR_SetRegDirectory( nsNSPRPath(appDir) );
NR_StartupRegistry(); /* startup the registry; if already started, this will essentially be a noop */
nsSpecialSystemDirectory appDir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
VR_SetRegDirectory( appDir.GetNativePathCString() );
/***************************************/
/* Stupid Hack to test js env*/
/***************************************/
@@ -137,6 +146,7 @@ nsSoftwareUpdate::nsSoftwareUpdate()
/* Perform Scheduled Tasks */
/***************************************/
#if 1
PR_CreateThread(PR_USER_THREAD,
PerformScheduledTasks,
nsnull,
@@ -144,71 +154,16 @@ nsSoftwareUpdate::nsSoftwareUpdate()
PR_GLOBAL_THREAD,
PR_UNJOINABLE_THREAD,
0);
#endif
// PerformScheduledTasks(nsnull);
/***************************************/
/* Create a top level observer */
/***************************************/
mTopLevelObserver = new nsTopProgressNotifier();
nsLoggingProgressNotifier *logger = new nsLoggingProgressNotifier();
RegisterNotifier(logger);
nsIProxyObjectManager *manager;
nsInstallProgressDialog *dialog = new nsInstallProgressDialog();
nsInstallProgressDialog *proxy;
nsISupports *dialogBase;
nsresult rv = dialog->QueryInterface(kISupportsIID, (void**)&dialogBase);
if (NS_SUCCEEDED(rv))
{
rv = nsServiceManager::GetService( NS_XPCOMPROXY_PROGID,
kProxyObjectManagerIID,
(nsISupports **)&manager);
if (NS_SUCCEEDED(rv))
{
// I am assuming that the thread that starts us up is the UI thread. this will/may break
// I need to make a generic way of getting at the UI event queue.
nsIEventQueueService *eventQService;
rv = nsServiceManager::GetService(NS_EVENTQUEUESERVICE_PROGID,
kEventQueueServiceIID,
(nsISupports **)&eventQService);
if (NS_SUCCEEDED(rv))
{
nsIEventQueue *eventQ;
eventQService->GetThreadEventQueue(PR_GetCurrentThread(), &eventQ);
PLEventQueue *plEventQ;
eventQ->GetPLEventQueue(&plEventQ);
rv = manager->GetProxyObject(plEventQ, nsIXPInstallProgress::GetIID(), dialogBase, PROXY_SYNC, (void**)&proxy);
if (NS_SUCCEEDED(rv))
{
RegisterNotifier(proxy);
}
}
}
}
if (dialog)
dialog->Release();
return NS_OK;
}
nsSoftwareUpdate::~nsSoftwareUpdate()
nsresult
nsSoftwareUpdate::Shutdown()
{
#ifdef NS_DEBUG
printf("*** XPInstall Component destroyed\n");
#endif
if (mJarInstallQueue != nsnull)
{
PRUint32 i=0;
@@ -225,99 +180,25 @@ nsSoftwareUpdate::~nsSoftwareUpdate()
}
NR_ShutdownRegistry();
}
NS_IMPL_ADDREF( nsSoftwareUpdate );
NS_IMPL_RELEASE( nsSoftwareUpdate );
NS_IMETHODIMP
nsSoftwareUpdate::QueryInterface( REFNSIID anIID, void **anInstancePtr )
{
nsresult rv = NS_OK;
/* Check for place to return result. */
if ( !anInstancePtr )
{
rv = NS_ERROR_NULL_POINTER;
}
else
{
/* Initialize result. */
*anInstancePtr = 0;
/* Check for IIDs we support and cast this appropriately. */
if ( anIID.Equals( nsISoftwareUpdate::GetIID() ) )
{
*anInstancePtr = (void*) ( (nsISoftwareUpdate*)this );
NS_ADDREF_THIS();
}
else if ( anIID.Equals( nsIAppShellComponent::GetIID() ) )
{
*anInstancePtr = (void*) ( (nsIAppShellComponent*)this );
NS_ADDREF_THIS();
}
else if ( anIID.Equals( kISupportsIID ) )
{
*anInstancePtr = (void*) ( (nsISupports*) (nsISoftwareUpdate*) this );
NS_ADDREF_THIS();
}
else
{
/* Not an interface we support. */\
rv = NS_NOINTERFACE;
}
}
return rv;
}
NS_IMETHODIMP
nsSoftwareUpdate::Initialize( nsIAppShellService *anAppShell, nsICmdLineService *aCmdLineService )
{
nsresult rv;
rv = nsServiceManager::RegisterService( NS_IXPINSTALLCOMPONENT_PROGID, ( (nsISupports*) (nsISoftwareUpdate*) this ) );
return rv;
}
NS_IMETHODIMP
nsSoftwareUpdate::Shutdown()
{
nsresult rv;
rv = nsServiceManager::ReleaseService( NS_IXPINSTALLCOMPONENT_PROGID, ( (nsISupports*) (nsISoftwareUpdate*) this ) );
return rv;
}
NS_IMETHODIMP
nsSoftwareUpdate::RegisterNotifier(nsIXPInstallProgress *notifier)
{
// we are going to ignore the returned ID and enforce that once you
// register a notifier, you can not remove it. This should at some
// point be fixed.
(void) mTopLevelObserver->RegisterNotifier(notifier);
return NS_OK;
}
NS_IMETHODIMP
nsSoftwareUpdate::GetTopLevelNotifier(nsIXPInstallProgress **notifier)
nsSoftwareUpdate::InstallJar( const nsString& fromURL,
const nsString& flags,
const nsString& args)
{
*notifier = mTopLevelObserver;
nsInstallInfo *installInfo = new nsInstallInfo(fromURL, flags, args);
InstallJar(installInfo);
return NS_OK;
}
NS_IMETHODIMP
nsSoftwareUpdate::InstallJar( const nsString& fromURL,
const nsString& localFile,
long flags)
nsSoftwareUpdate::InstallJar(nsInstallInfo *installInfo)
{
nsInstallInfo *installInfo = new nsInstallInfo(fromURL, localFile, flags);
mJarInstallQueue->Add( installInfo );
RunNextInstall();
@@ -325,18 +206,6 @@ nsSoftwareUpdate::InstallJar( const nsString& fromURL,
return NS_OK;
}
NS_IMETHODIMP
nsSoftwareUpdate::InstallPending(void)
{
if (mInstalling || mJarInstallQueue->GetSize() > 0)
{
return 1;
}
else
{
return 0;
}
}
NS_IMETHODIMP
nsSoftwareUpdate::InstallJarCallBack()
@@ -355,7 +224,7 @@ nsSoftwareUpdate::InstallJarCallBack()
}
nsresult
NS_IMETHODIMP
nsSoftwareUpdate::RunNextInstall()
{
if (mInstalling == PR_TRUE)
@@ -411,7 +280,7 @@ nsSoftwareUpdateFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void
*aResult = NULL;
nsSoftwareUpdate *inst = new nsSoftwareUpdate();
nsSoftwareUpdate *inst = nsSoftwareUpdate::GetInstance();
if (inst == NULL)
return NS_ERROR_OUT_OF_MEMORY;
@@ -536,45 +405,12 @@ NSRegisterSelf(nsISupports* aServMgr, const char *path)
printf("*** XPInstall is being registered\n");
#endif
rv = compMgr->RegisterComponent( kSoftwareUpdate_CID,
NS_IXPINSTALLCOMPONENT_CLASSNAME,
NS_IXPINSTALLCOMPONENT_PROGID,
path,
PR_TRUE,
PR_TRUE );
rv = compMgr->RegisterComponent(kSoftwareUpdate_CID, NULL, NULL, path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) goto done;
nsIRegistry *registry;
rv = servMgr->GetService( NS_REGISTRY_PROGID,
nsIRegistry::GetIID(),
(nsISupports**)&registry );
if ( NS_SUCCEEDED( rv ) )
{
registry->Open();
char buffer[256];
char *cid = nsSoftwareUpdate::GetCID().ToString();
PR_snprintf( buffer,
sizeof buffer,
"%s/%s",
NS_IAPPSHELLCOMPONENT_KEY,
cid ? cid : "unknown" );
delete [] cid;
nsIRegistry::Key key;
rv = registry->AddSubtree( nsIRegistry::Common,
buffer,
&key );
servMgr->ReleaseService( NS_REGISTRY_PROGID, registry );
}
rv = compMgr->RegisterComponent(kInstallTrigger_CID, NULL, NULL, path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) goto done;
rv = compMgr->RegisterComponent(kInstallVersion_CID, NULL, NULL, path, PR_TRUE, PR_TRUE);
done:
done:
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}

View File

@@ -14,42 +14,43 @@
class nsInstallInfo;
#include "nsIScriptExternalNameSet.h"
#include "nsIAppShellComponent.h"
#include "nsIXPInstallProgress.h"
#include "nsTopProgressNotifier.h"
class nsSoftwareUpdate: public nsIAppShellComponent, public nsISoftwareUpdate
class nsSoftwareUpdate: public nsISoftwareUpdate
{
public:
NS_DEFINE_STATIC_CID_ACCESSOR( NS_SoftwareUpdate_CID );
static const nsIID& IID() { static nsIID iid = NS_SoftwareUpdateInstall_CID; return iid; }
nsSoftwareUpdate();
virtual ~nsSoftwareUpdate();
~nsSoftwareUpdate();
static nsSoftwareUpdate *GetInstance();
NS_DECL_ISUPPORTS
NS_DECL_IAPPSHELLCOMPONENT
NS_IMETHOD InstallJar(const nsString& fromURL,
const nsString& localFile,
long flags);
NS_IMETHOD RegisterNotifier(nsIXPInstallProgress *notifier);
NS_IMETHOD InstallPending(void);
NS_IMETHOD InstallJar(nsInstallInfo *installInfo);
NS_IMETHOD InstallJar(const nsString& fromURL,
const nsString& flags,
const nsString& args);
NS_IMETHOD InstallJarCallBack();
NS_IMETHOD GetTopLevelNotifier(nsIXPInstallProgress **notifier);
NS_IMETHOD RunNextInstall();
NS_IMETHOD InstallJarCallBack();
private:
nsresult Startup();
nsresult Shutdown();
nsresult RunNextInstall();
nsresult DeleteScheduledNodes();
PRBool mInstalling;
nsVector* mJarInstallQueue;
nsTopProgressNotifier *mTopLevelObserver;
static nsSoftwareUpdate* mInstance;
};
@@ -57,7 +58,7 @@ class nsSoftwareUpdateNameSet : public nsIScriptExternalNameSet
{
public:
nsSoftwareUpdateNameSet();
virtual ~nsSoftwareUpdateNameSet();
~nsSoftwareUpdateNameSet();
NS_DECL_ISUPPORTS
NS_IMETHOD InitializeClasses(nsIScriptContext* aScriptContext);

View File

@@ -39,8 +39,21 @@
#include "nspr.h"
#include "jsapi.h"
#if 0
#include "nsIEventQueueService.h"
#include "nsXPComCIID.h"
#include "nsIURL.h"
#include "nsAppShellProxy.h"
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID);
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
#endif
static NS_DEFINE_IID(kISoftwareUpdateIID, NS_ISOFTWAREUPDATE_IID);
static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
@@ -65,6 +78,10 @@ static nsresult SetupInstallContext(const char* jarFile, const char* args, JSRun
extern "C" void RunInstallOnThread(void *data);
extern "C" NS_EXPORT PRInt32 RunInstall(const char* jarFile, const char* flags, const char* args, const char* fromURL);
///////////////////////////////////////////////////////////////////////////////////////////////
// Function name : XPInstallErrorReporter
// Description : Prints error message to stdout
@@ -252,20 +269,31 @@ static nsresult SetupInstallContext(const char* jarFile,
///////////////////////////////////////////////////////////////////////////////////////////////
PRInt32 RunInstall(nsInstallInfo *installInfo)
{
if (installInfo->GetFlags() == 0x00000001)
#if 0
// We are one the UI Thread. Get and save the eventQueue.
// Create the Event Queue for the UI thread...
nsIEventQueueService* eventQService;
nsresult rv = nsServiceManager::GetService(kEventQueueServiceCID,
kIEventQueueServiceIID,
(nsISupports **)&eventQService);
PLEventQueue* thisEventQueue;
if (NS_OK == rv)
{
RunInstallOnThread((void *)installInfo);
}
else
{
PR_CreateThread(PR_USER_THREAD,
RunInstallOnThread,
(void*)installInfo,
PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD,
PR_UNJOINABLE_THREAD,
0);
rv = eventQService->GetThreadEventQueue(PR_GetCurrentThread(),
&thisEventQueue);
}
installInfo->SetUIEventQueue(thisEventQueue);
#endif
PR_CreateThread(PR_USER_THREAD,
RunInstallOnThread,
(void*)installInfo,
PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD,
PR_UNJOINABLE_THREAD,
0);
return 0;
}
@@ -281,59 +309,113 @@ PRInt32 RunInstall(nsInstallInfo *installInfo)
extern "C" void RunInstallOnThread(void *data)
{
nsInstallInfo *installInfo = (nsInstallInfo*)data;
nsresult rv;
#if 0
/*
* Create the Application Shell instance...
*/
nsIAppShellService* appShell;
rv = nsServiceManager::GetService(kAppShellServiceCID,
kIAppShellServiceIID,
(nsISupports**)&appShell);
if (NS_FAILED(rv))
{
return;
}
nsAppShellProxy *appShellProxy = new nsAppShellProxy(installInfo->GetUIEventQueue(), appShell);
// DO NOT CALL INIT! appShellProxy->Initialize();
nsString *aCID = new nsString("00000000-dead-beef-0000-000000000000");
nsIWebShellWindow* newWindow;
nsIURL* url;
char* urlstr = "resource:/res/samples/xpinstallprogress.xul";
NS_NewURL(&url, urlstr);
appShellProxy->CreateDialogWindow(nsnull,
url,
*aCID,
newWindow,
nsnull,
nsnull,
250,
125);
#endif
RunInstall( (const char*) nsAutoCString( installInfo->GetLocalFile() ),
(const char*) nsAutoCString( installInfo->GetFlags() ),
(const char*) nsAutoCString( installInfo->GetArguments() ),
(const char*) nsAutoCString( installInfo->GetFromURL() ));
#if 0
appShellProxy->CloseTopLevelWindow(newWindow);
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
// After Install, we need to update the queue.
#endif
nsISoftwareUpdate *softwareUpdate;
rv = nsComponentManager::CreateInstance( kSoftwareUpdateCID,
nsnull,
kISoftwareUpdateIID,
(void**) &softwareUpdate);
if (NS_FAILED(rv))
{
return ;
}
softwareUpdate->InstallJarCallBack();
}
///////////////////////////////////////////////////////////////////////////////////////////////
// Function name : RunInstall
// Description : This is the main C entrypoint to run jar installers
// Return type : PRInt32
// Argument : const char* jarFile - a native filepath to a jarfile to be run
// Argument : const char* flags - UNUSED
// Argument : const char* args - arguments passed into the javascript env
// Argument : const char* fromURL - a url string of where this file came from UNUSED
///////////////////////////////////////////////////////////////////////////////////////////////
extern "C" NS_EXPORT PRInt32 RunInstall(const char* jarFile, const char* flags, const char* args, const char* fromURL)
{
char *scriptBuffer;
PRUint32 scriptLength;
JSRuntime *rt;
JSContext *cx;
JSObject *glob;
nsISoftwareUpdate *softwareUpdate;
nsresult rv = nsServiceManager::GetService( kSoftwareUpdateCID,
kISoftwareUpdateIID,
(nsISupports**)&softwareUpdate);
nsIXPInstallProgress *notifier;
if (NS_SUCCEEDED(rv))
{
softwareUpdate->GetTopLevelNotifier(&notifier);
}
else
{
return;
}
if(notifier)
notifier->BeforeJavascriptEvaluation();
nsString args;
installInfo->GetArguments(args);
rv = GetInstallScriptFromJarfile( nsAutoCString( installInfo->GetLocalFile() ),
&scriptBuffer,
&scriptLength);
nsresult rv = GetInstallScriptFromJarfile(jarFile, &scriptBuffer, &scriptLength);
if (NS_FAILED(rv) || scriptBuffer == nsnull)
{
goto bail;
return rv;
}
rv = SetupInstallContext( nsAutoCString( installInfo->GetLocalFile() ),
nsAutoCString( args ),
&rt, &cx, &glob);
rv = SetupInstallContext(jarFile, args, &rt, &cx, &glob);
if (NS_FAILED(rv))
{
delete [] scriptBuffer;
goto bail;
return rv;
}
// Go ahead and run!!
jsval rval;
@@ -351,12 +433,8 @@ extern "C" void RunInstallOnThread(void *data)
JS_DestroyContext(cx);
JS_DestroyRuntime(rt);
if(notifier)
notifier->AfterJavascriptEvaluation();
bail:
softwareUpdate->InstallJarCallBack();
return rv;
}

View File

@@ -3,4 +3,4 @@
PRInt32 RunInstall(nsInstallInfo *installInfo);
#endif
#endif

View File

@@ -23,7 +23,7 @@
#include "nsVector.h"
#include "nsISupports.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIURL.h"
#include "nsINetlibURL.h"
@@ -39,30 +39,28 @@ static NS_DEFINE_IID(kISoftwareUpdateIID, NS_ISOFTWAREUPDATE_IID);
static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
nsSoftwareUpdateListener::nsSoftwareUpdateListener(const nsString& fromURL, const nsString& localFile, long flags)
nsSoftwareUpdateListener::nsSoftwareUpdateListener(nsInstallInfo *nextInstall)
{
NS_INIT_REFCNT();
mFromURL = fromURL;
mLocalFile = localFile;
mFlags = flags;
mOutFileDesc = PR_Open(nsAutoCString(localFile), PR_CREATE_FILE | PR_RDWR, 0744);
mInstallInfo = nextInstall;
mOutFileDesc = PR_Open(nsAutoCString(nextInstall->GetLocalFile()), PR_CREATE_FILE | PR_RDWR, 0744);
if(mOutFileDesc == NULL)
{
mResult = -1;
};
mResult = nsServiceManager::GetService( kSoftwareUpdateCID,
kISoftwareUpdateIID,
(nsISupports**)&mSoftwareUpdate);
mResult = nsComponentManager::CreateInstance( kSoftwareUpdateCID,
nsnull,
kISoftwareUpdateIID,
(void**) &mSoftwareUpdate);
if (NS_FAILED(mResult))
if (mResult != NS_OK)
return;
nsIURL *pURL = nsnull;
mResult = NS_NewURL(&pURL, fromURL);
mResult = NS_NewURL(&pURL, nextInstall->GetFromURL());
if (NS_FAILED(mResult))
return;
@@ -116,9 +114,8 @@ nsSoftwareUpdateListener::OnStopBinding(nsIURL* aURL,
case NS_BINDING_SUCCEEDED:
PR_Close(mOutFileDesc);
mSoftwareUpdate->InstallJar(mFromURL,
mLocalFile,
mFlags );
// Add to the XPInstall Queue
mSoftwareUpdate->InstallJar(mInstallInfo);
break;
case NS_BINDING_FAILED:
@@ -147,7 +144,7 @@ nsSoftwareUpdateListener::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream
{
err = pIStream->Read(buffer, BUF_SIZE, &len);
if (mResult == 0 && err == 0)
if (err == 0)
{
if ( PR_Write(mOutFileDesc, buffer, len) == -1 )
{

View File

@@ -38,12 +38,17 @@ static NS_DEFINE_IID(kInetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_IID(kInetLibURLIID, NS_INETLIBURL_IID);
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
extern "C" nsresult DownloadJar(nsInstallInfo *nextInstall);
class nsSoftwareUpdateListener : public nsIStreamListener
{
public:
NS_DECL_ISUPPORTS
nsSoftwareUpdateListener(const nsString& fromURL, const nsString& localFile, long flags);
nsSoftwareUpdateListener(nsInstallInfo *nextInstall);
NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* info);
NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 Progress, PRUint32 ProgressMax);
@@ -56,18 +61,14 @@ class nsSoftwareUpdateListener : public nsIStreamListener
protected:
virtual ~nsSoftwareUpdateListener();
~nsSoftwareUpdateListener();
private:
nsISoftwareUpdate *mSoftwareUpdate;
PRFileDesc *mOutFileDesc;
nsString mFromURL;
nsString mLocalFile;
long mFlags;
nsInstallInfo *mInstallInfo;
PRInt32 mResult;
};

View File

@@ -1,169 +0,0 @@
/* -*- 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 "nsTopProgressNotifier.h"
nsTopProgressNotifier::nsTopProgressNotifier()
{
mNotifiers = new nsVector();
}
nsTopProgressNotifier::~nsTopProgressNotifier()
{
if (mNotifiers)
{
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
delete element;
}
mNotifiers->RemoveAll();
delete (mNotifiers);
}
}
NS_IMPL_ISUPPORTS(nsTopProgressNotifier, nsIXPInstallProgress::GetIID());
long
nsTopProgressNotifier::RegisterNotifier(nsIXPInstallProgress * newNotifier)
{
return mNotifiers->Add( newNotifier );
}
void
nsTopProgressNotifier::UnregisterNotifier(long id)
{
mNotifiers->Set(id, NULL);
}
NS_IMETHODIMP
nsTopProgressNotifier::BeforeJavascriptEvaluation()
{
if (mNotifiers)
{
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
if (element != NULL)
element->BeforeJavascriptEvaluation();
}
}
return NS_OK;
}
NS_IMETHODIMP
nsTopProgressNotifier::AfterJavascriptEvaluation(void)
{
if (mNotifiers)
{
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
if (element != NULL)
element->AfterJavascriptEvaluation();
}
}
return NS_OK;
}
NS_IMETHODIMP
nsTopProgressNotifier::InstallStarted(const char* UIPackageName)
{
if (mNotifiers)
{
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
if (element != NULL)
element->InstallStarted(UIPackageName);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsTopProgressNotifier::ItemScheduled( const char* message )
{
long rv = 0;
if (mNotifiers)
{
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
if (element != NULL)
if (element->ItemScheduled( message ) != 0)
rv = -1;
}
}
return rv;
}
NS_IMETHODIMP
nsTopProgressNotifier::InstallFinalization( const char* message, PRInt32 itemNum, PRInt32 totNum )
{
if (mNotifiers)
{
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
if (element != NULL)
element->InstallFinalization( message, itemNum, totNum );
}
}
return NS_OK;
}
NS_IMETHODIMP
nsTopProgressNotifier::InstallAborted(void)
{
if (mNotifiers)
{
PRUint32 i=0;
for (; i < mNotifiers->GetSize(); i++)
{
nsIXPInstallProgress* element = (nsIXPInstallProgress*)mNotifiers->Get(i);
if (element != NULL)
element->InstallAborted();
}
}
return NS_OK;
}

View File

@@ -1,57 +0,0 @@
/* -*- 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 nsTopProgressNotifier_h__
#define nsTopProgressNotifier_h__
#include "nsIXPInstallProgress.h"
#include "nsVector.h"
class nsTopProgressNotifier : public nsIXPInstallProgress
{
public:
nsTopProgressNotifier();
virtual ~nsTopProgressNotifier();
long RegisterNotifier(nsIXPInstallProgress * newNotifier);
void UnregisterNotifier(long id);
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();
private:
nsVector *mNotifiers;
};
#endif

View File

@@ -1,144 +0,0 @@
/* -*- 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 "nsWinProfile.h"
#include "nsWinProfileItem.h"
#include "nspr.h"
#include <windows.h>
/* Public Methods */
nsWinProfile::nsWinProfile( nsInstall* suObj, const nsString& folder, const nsString& file )
{
filename = new nsString(folder);
if(filename->Last() != '\\')
{
filename->Append("\\");
}
filename->Append(file);
su = suObj;
// principal = suObj->GetPrincipal();
// privMgr = nsPrivilegeManager::getPrivilegeManager();
// impersonation = nsTarget::findTarget(IMPERSONATOR);
// target = (nsUserTarget*)nsTarget::findTarget(INSTALL_PRIV);
}
nsWinProfile::~nsWinProfile()
{
delete filename;
}
PRInt32
nsWinProfile::getString(nsString section, nsString key, nsString* aReturn)
{
return nativeGetString(section, key, aReturn);
}
PRInt32
nsWinProfile::writeString(nsString section, nsString key, nsString value, PRInt32* aReturn)
{
nsWinProfileItem* wi = new nsWinProfileItem(this, section, key, value);
*aReturn = NS_OK;
if(wi == NULL)
return PR_FALSE;
su->ScheduleForInstall(wi);
return NS_OK;
}
nsString* nsWinProfile::getFilename()
{
return filename;
}
nsInstall* nsWinProfile::installObject()
{
return su;
}
PRInt32
nsWinProfile::finalWriteString( nsString section, nsString key, nsString value )
{
/* do we need another security check here? */
return nativeWriteString(section, key, value);
}
/* Private Methods */
#define STRBUFLEN 255
PRInt32
nsWinProfile::nativeGetString(nsString section, nsString key, nsString* aReturn )
{
int numChars;
char valbuf[STRBUFLEN];
char* sectionCString;
char* keyCString;
char* filenameCString;
/* make sure conversions worked */
if(section.First() != '\0' && key.First() != '\0' && filename->First() != '\0')
{
sectionCString = section.ToNewCString();
keyCString = key.ToNewCString();
filenameCString = filename->ToNewCString();
numChars = GetPrivateProfileString(sectionCString, keyCString, "", valbuf, STRBUFLEN, filenameCString);
*aReturn = valbuf;
delete [] sectionCString;
delete [] keyCString;
delete [] filenameCString;
}
return numChars;
}
PRInt32
nsWinProfile::nativeWriteString( nsString section, nsString key, nsString value )
{
char* sectionCString;
char* keyCString;
char* valueCString;
char* filenameCString;
int success = 0;
/* make sure conversions worked */
if(section.First() != '\0' && key.First() != '\0' && filename->First() != '\0')
{
sectionCString = section.ToNewCString();
keyCString = key.ToNewCString();
valueCString = value.ToNewCString();
filenameCString = filename->ToNewCString();
success = WritePrivateProfileString( sectionCString, keyCString, valueCString, filenameCString );
delete [] sectionCString;
delete [] keyCString;
delete [] valueCString;
delete [] filenameCString;
}
return success;
}

View File

@@ -1,72 +0,0 @@
/* -*- 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 nsWinProfile_h__
#define nsWinProfile_h__
#include "prtypes.h"
#include "nsInstall.h"
class nsWinProfile
{
public:
/* Public Fields */
/* Public Methods */
nsWinProfile( nsInstall* suObj, const nsString& folder, const nsString& file );
~nsWinProfile();
/**
* Schedules a write into a windows "ini" file. "Value" can be
* null to delete the value, but we don't support deleting an entire
* section via a null "key". The actual write takes place during
* SoftwareUpdate.FinalizeInstall();
*
* @return false for failure, true for success
*/
PRInt32 writeString( nsString section, nsString key, nsString value, PRInt32* aReturn );
/**
* Reads a value from a windows "ini" file. We don't support using
* a null "key" to return a list of keys--you have to know what you want
*
* @return String value from INI, "" if not found, null if error
*/
PRInt32 getString( nsString section, nsString key, nsString* aReturn );
nsString* getFilename();
nsInstall* installObject();
PRInt32 finalWriteString( nsString section, nsString key, nsString value );
private:
/* Private Fields */
nsString* filename;
nsInstall* su;
/* Private Methods */
PRInt32 nativeWriteString( nsString section, nsString key, nsString value );
PRInt32 nativeGetString( nsString section, nsString key, nsString* aReturn );
};
#endif /* nsWinProfile_h__ */

View File

@@ -1,107 +0,0 @@
/* -*- 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 "nsWinProfileItem.h"
#include "nspr.h"
#include <windows.h>
/* Public Methods */
nsWinProfileItem::nsWinProfileItem(nsWinProfile* profileObj,
nsString sectionName,
nsString keyName,
nsString val) : nsInstallObject(profileObj->installObject())
{
profile = profileObj;
section = new nsString(sectionName);
key = new nsString(keyName);
value = new nsString(val);
}
nsWinProfileItem::~nsWinProfileItem()
{
delete profile;
delete section;
delete key;
delete value;
}
PRInt32 nsWinProfileItem::Complete()
{
profile->finalWriteString(*section, *key, *value);
return NS_OK;
}
float nsWinProfileItem::GetInstallOrder()
{
return 4;
}
char* nsWinProfileItem::toString()
{
char* resultCString;
nsString* result;
nsString* filename = new nsString(*profile->getFilename());
result = new nsString("Write ");
result->Append(*filename);
result->Append(": [");
result->Append(*section);
result->Append("] ");
result->Append(*key);
result->Append("=");
result->Append(*value);
resultCString = result->ToNewCString();
delete result;
delete filename;
return resultCString;
}
void nsWinProfileItem::Abort()
{
}
PRInt32 nsWinProfileItem::Prepare()
{
return nsnull;
}
/* CanUninstall
* WinProfileItem() does not install any files which can be uninstalled,
* hence this function returns false.
*/
PRBool
nsWinProfileItem::CanUninstall()
{
return FALSE;
}
/* RegisterPackageNode
* WinProfileItem() installs files which need to be registered,
* hence this function returns true.
*/
PRBool
nsWinProfileItem::RegisterPackageNode()
{
return TRUE;
}

View File

@@ -1,79 +0,0 @@
/* -*- 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 nsWinProfileItem_h__
#define nsWinProfileItem_h__
#include "prtypes.h"
#include "nsSoftwareUpdate.h"
#include "nsInstallObject.h"
#include "nsWinProfile.h"
PR_BEGIN_EXTERN_C
class nsWinProfileItem : public nsInstallObject {
public:
/* Public Fields */
/* Public Methods */
nsWinProfileItem(nsWinProfile* profileObj,
nsString sectionName,
nsString keyName,
nsString val);
~nsWinProfileItem();
/**
* Completes the install:
* - writes the data into the .INI file
*/
PRInt32 Complete();
float GetInstallOrder();
char* toString();
// no need for special clean-up
void Abort();
// no need for set-up
PRInt32 Prepare();
/* should these be protected? */
PRBool CanUninstall();
PRBool RegisterPackageNode();
private:
/* Private Fields */
nsWinProfile* profile; // initiating profile object
nsString* section; // Name of section
nsString* key; // Name of key
nsString* value; // data to write
/* Private Methods */
};
PR_END_EXTERN_C
#endif /* nsWinProfileItem_h__ */

View File

@@ -19,9 +19,15 @@
#ifndef __NS_WINREG_H__
#define __NS_WINREG_H__
#include "nsWinRegEnums.h"
//#include "prtypes.h"
#include "nsSoftUpdateEnums.h"
#include "nsWinRegValue.h"
//#include "nsPrincipal.h"
//#include "nsPrivilegeManager.h"
//#include "nsTarget.h"
//#include "nsUserTarget.h"
#include "nscore.h"
#include "nsISupports.h"

View File

@@ -1,46 +0,0 @@
/* -*- 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 nsWinRegEnums_h__
#define nsWinRegEnums_h__
typedef enum nsWinRegEnum {
NS_WIN_REG_CREATE = 1,
NS_WIN_REG_DELETE = 2,
NS_WIN_REG_DELETE_VAL = 3,
NS_WIN_REG_SET_VAL_STRING = 4,
NS_WIN_REG_SET_VAL = 5
} nsWinRegEnum;
typedef enum nsWinRegValueEnum {
NS_WIN_REG_SZ = 1,
NS_WIN_REG_EXPAND_SZ = 2,
NS_WIN_REG_BINARY = 3,
NS_WIN_REG_DWORD = 4,
NS_WIN_REG_DWORD_LITTLE_ENDIAN = 4,
NS_WIN_REG_DWORD_BIG_ENDIAN = 5,
NS_WIN_REG_LINK = 6,
NS_WIN_REG_MULTI_SZ = 7,
NS_WIN_REG_RESOURCE_LIST = 8,
NS_WIN_REG_FULL_RESOURCE_DESCRIPTOR = 9,
NS_WIN_REG_RESOURCE_REQUIREMENTS_LIST = 10
} nsWinRegValueEnum;
#endif /* nsWinRegEnums_h__ */

View File

@@ -40,15 +40,19 @@ nsWinRegItem::nsWinRegItem(nsWinReg* regObj, PRInt32 root, PRInt32 action, nsStr
nsWinRegItem::~nsWinRegItem()
{
delete reg;
delete subkey;
delete name;
delete value;
if(subkey != nsnull)
delete subkey;
if(name != nsnull)
delete name;
if(value != nsnull)
delete value;
}
PRInt32 nsWinRegItem::Complete()
{
PRInt32 aReturn = NS_OK;
PRInt32 aReturn;
switch (command)
{
@@ -92,51 +96,51 @@ char* nsWinRegItem::toString()
{
case NS_WIN_REG_CREATE:
keyString = keystr(rootkey, subkey, nsnull);
result = new nsString(kCRK);
result = new nsString(kCRK);
result->Append(*keyString);
resultCString = result->ToNewCString();
delete keyString;
delete result;
delete [] keyString;
delete [] result;
return resultCString;
case NS_WIN_REG_DELETE:
keyString = keystr(rootkey, subkey, nsnull);
result = new nsString(kDRK);
result = new nsString(kDRK);
result->Append(*keyString);
resultCString = result->ToNewCString();
delete keyString;
delete result;
delete [] keyString;
delete [] result;
return resultCString;
case NS_WIN_REG_DELETE_VAL:
keyString = keystr(rootkey, subkey, name);
result = new nsString(kDRV);
result = new nsString(kDRV);
result->Append(*keyString);
resultCString = result->ToNewCString();
delete keyString;
delete result;
delete [] keyString;
delete [] result;
return resultCString;
case NS_WIN_REG_SET_VAL_STRING:
keyString = keystr(rootkey, subkey, name);
result = new nsString(kSRV);
result = new nsString(kSRV);
result->Append(*keyString);
resultCString = result->ToNewCString();
delete keyString;
delete result;
delete [] keyString;
delete [] result;
return resultCString;
case NS_WIN_REG_SET_VAL:
keyString = keystr(rootkey, subkey, name);
result = new nsString(kSRV);
result = new nsString(kSRV);
result->Append(*keyString);
resultCString = result->ToNewCString();
delete keyString;
delete result;
delete [] keyString;
delete [] result;
return resultCString;
default:
keyString = keystr(rootkey, subkey, name);
result = new nsString(kUNK);
result = new nsString(kUNK);
result->Append(*keyString);
resultCString = result->ToNewCString();
delete keyString;
delete result;
delete [] keyString;
delete [] result;
return resultCString;
}
}
@@ -189,7 +193,7 @@ nsString* nsWinRegItem::keystr(PRInt32 root, nsString* subkey, nsString* name)
finalstr->Append(*name);
finalstr->Append("]");
}
delete rootstr;
delete [] rootstr;
return finalstr;
}

View File

@@ -62,12 +62,12 @@ private:
/* Private Fields */
nsWinReg* reg; // initiating WinReg object
nsWinReg* reg; // initiating WinReg object
PRInt32 rootkey;
PRInt32 command;
nsString* subkey; // Name of section
nsString* name; // Name of key
void* value; // data to write
nsString* name; // Name of key
void* value; // data to write
/* Private Methods */

View File

@@ -1,49 +0,0 @@
#!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=..\..
MAKE_OBJ_TYPE = EXE
PROGRAM = .\$(OBJDIR)\xpinstall.exe
OBJS = \
.\$(OBJDIR)\standalone.obj \
.\$(OBJDIR)\nsSimpleConsoleProgressNotifier.obj \
$(NULL)
LLIBS = \
$(DIST)\lib\xpinstall.lib \
$(DIST)\lib\raptorbase.lib \
$(DIST)\lib\xpcom32.lib \
$(LIBNSPR) \
$(NULL)
LINCS = \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\xpinstall \
-I$(PUBLIC)\raptor \
$(NULL)
include <$(DEPTH)\config\rules.mak>
export:: $(PROGRAM)
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
clobber::
rm -f $(DIST)\bin\xpinstall.exe
$(PROGRAM):: $(OBJS) $(LLIBS)

View File

@@ -1,75 +0,0 @@
/* -*- 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 "nsIXPInstallProgressNotifier.h"
#include "nsSimpleConsoleProgressNotifier.h"
#include <stdlib.h>
#include <stdio.h>
nsSimpleConsoleProgressNotifier::nsSimpleConsoleProgressNotifier()
{}
nsSimpleConsoleProgressNotifier::~nsSimpleConsoleProgressNotifier()
{}
void
nsSimpleConsoleProgressNotifier::BeforeJavascriptEvaluation(void)
{
printf("Prior to evaluation of Install Script\n");
}
void
nsSimpleConsoleProgressNotifier::AfterJavascriptEvaluation(void)
{
printf("After evaluation of Install Script\n");
}
void
nsSimpleConsoleProgressNotifier::InstallStarted(const char* UIPackageName)
{
printf("Installing: %s\n", UIPackageName);
}
long
nsSimpleConsoleProgressNotifier::ItemScheduled(const char* message )
{
printf("Scheduled Item:\t%s\n", message);
return 0;
}
void
nsSimpleConsoleProgressNotifier::InstallFinalization(const char* message, long itemNum, long totNum )
{
printf("Item: %s\t(%ld of %ld) Installed.\n", message, itemNum, totNum );
}
void
nsSimpleConsoleProgressNotifier::InstallAborted(void)
{
printf("Installation aborted.\n");
}

View File

@@ -1,47 +0,0 @@
/* -*- 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 nsSimpleConsoleProgressNotifier_H__
#define nsSimpleConsoleProgressNotifier_H__
#include "nsIXPInstallProgressNotifier.h"
class nsSimpleConsoleProgressNotifier : public nsIXPInstallProgressNotifier
{
public:
nsSimpleConsoleProgressNotifier();
virtual ~nsSimpleConsoleProgressNotifier();
void BeforeJavascriptEvaluation(void);
void AfterJavascriptEvaluation(void);
void InstallStarted(const char* UIPackageName);
long ItemScheduled(const char* message );
void InstallFinalization(const char* message, long itemNum, long totNum );
void InstallAborted(void);
};
#endif

View File

@@ -1,141 +0,0 @@
/* -*- Mode: C; tab-width: 8; 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 <stdio.h>
#include "nsRepository.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsSpecialSystemDirectory.h"
#include "nscore.h"
#include "nspr.h"
#include "nsSimpleConsoleProgressNotifier.h"
/*********************************************
SoftwareUpdate
*********************************************/
#include "nsISoftwareUpdate.h"
#include "nsSoftwareUpdateIIDs.h"
static nsISoftwareUpdate *softwareUpdate= NULL;
static NS_DEFINE_IID(kFileLocatorIID, NS_IFILELOCATOR_IID);
static NS_DEFINE_IID(kFileLocatorCID, NS_FILELOCATOR_CID);
/*********************************************/
extern "C" void
NS_SetupRegistry()
{
// Autoregistration happens here. The rest of RegisterComponent() calls should happen
// only for dlls not in the components directory.
// Create exeDir/"components"
nsSpecialSystemDirectory sysdir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
sysdir += "components";
const char *componentsDir = sysdir.GetCString(); // native path
if (componentsDir != NULL)
{
#ifdef XP_PC
/* The PC version of the directory from filePath is of the form
* /y|/moz/mozilla/dist/bin/components
* We need to remove the initial / and change the | to :
* for all this to work with NSPR.
*/
#endif /* XP_PC */
printf("nsComponentManager: Using components dir: %s\n", componentsDir);
#ifdef XP_MAC
nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsnull);
#else
nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, componentsDir);
#endif /* XP_MAC */
// XXX Look for user specific components
// XXX UNIX: ~/.mozilla/components
}
}
/***************************************************************************/
static void
xpinstall_usage(int argc, char *argv[])
{
fprintf(stderr, "Usage: %s [-f flags] [-a arguments] filename\n", argv[0]);
}
int
main(int argc, char **argv)
{
for (int i = 1; i < argc; i++)
{
if (argv[i][0] != '-')
break;
switch (argv[i][1])
{
case 'f':
if (argv[i][2] == '\0' && i == argc)
{
fputs("ERROR: missing path after -f\n", stderr);
xpinstall_usage(argc, argv);
return 1;
}
//foo = argv[i + 1];
i++;
break;
default:
fprintf(stderr, "unknown option %s\n", argv[i]);
xpinstall_usage(argc, argv);
return 1;
}
}
NS_SetupRegistry();
nsresult rv = nsComponentManager::CreateInstance(kSoftwareUpdateCID,
nsnull,
kISoftwareUpdateIID,
(void**) &softwareUpdate);
if (NS_SUCCEEDED(rv))
{
nsSimpleConsoleProgressNotifier *progress = new nsSimpleConsoleProgressNotifier();
softwareUpdate->RegisterNotifier(progress);
nsFileSpec jarFile(argv[i]);
nsFileURL jarFileURL(jarFile);
softwareUpdate->InstallJar( nsString( jarFileURL.GetAsString() ) ,
nsString( nsNSPRPath(jarFile) ),
0x00000001);
}
return rv;
}