Adding XPInstall .dll stub for Install Wizards

This commit is contained in:
dveditz%netscape.com 1999-07-06 05:48:12 +00:00
Родитель e0e557e1bd
Коммит 03c2ca372b
5 изменённых файлов: 431 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,49 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Communicator client code,
# released March 31, 1998.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
# Reserved.
#
# Contributors:
# Daniel Veditz <dveditz@netscape.com>
DEPTH=..\..
MAKE_OBJ_TYPE = DLL
DLL = .\$(OBJDIR)\xpistub.dll
OBJS = \
.\$(OBJDIR)\nsStubNotifier.obj \
.\$(OBJDIR)\xpistub.obj \
$(NULL)
LLIBS = \
$(DIST)\lib\xpcom.lib \
$(NULL)
LINCS = \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\xpinstall \
$(NULL)
include <$(DEPTH)\config\rules.mak>
libs:: $(DLL)
$(MAKE_INSTALL) $(DLL) $(DIST)\bin
clobber::
$(RM) $(DIST)\bin\xpistub.dll

Просмотреть файл

@ -0,0 +1,94 @@
/* -*- 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>
*/
#include "nsStubNotifier.h"
nsStubNotifier::nsStubNotifier( pfnXPIStart aStart,
pfnXPIProgress aProgress,
pfnXPIFinal aFinal)
: m_start(aStart), m_progress(aProgress), m_final(aFinal)
{
NS_INIT_ISUPPORTS();
}
nsStubNotifier::~nsStubNotifier()
{}
NS_IMPL_ISUPPORTS(nsStubNotifier, NS_IXPINOTIFIER_IID);
NS_IMETHODIMP
nsStubNotifier::BeforeJavascriptEvaluation(void)
{
// we're not interested in this one
return NS_OK;
}
NS_IMETHODIMP
nsStubNotifier::AfterJavascriptEvaluation(void)
{
// we're not interested in this one
return NS_OK;
}
NS_IMETHODIMP
nsStubNotifier::InstallStarted(const char* UIPackageName)
{
if (m_start)
m_start(UIPackageName);
return NS_OK;
}
NS_IMETHODIMP
nsStubNotifier::ItemScheduled(const char* message )
{
if (m_progress)
return m_progress( message, 0, 0 );
else
return NS_OK;
}
NS_IMETHODIMP
nsStubNotifier::InstallFinalization(const char* message, PRInt32 itemNum, PRInt32 totNum )
{
if (m_progress)
return m_progress( message, itemNum, totNum );
else
return NS_OK;
}
NS_IMETHODIMP
nsStubNotifier::InstallAborted(void)
{
// XXX need to hook this one to m_final
return NS_OK;
}
NS_IMETHODIMP
nsStubNotifier::LogComment(const char* comment)
{
// we're not interested in this one
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,56 @@
/* -*- 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 nsStubNotifier_H__
#define nsStubNotifier_H__
#include "xpistub.h"
#include "nsIXPINotifier.h"
class nsStubNotifier : public nsIXPINotifier
{
public:
nsStubNotifier( pfnXPIStart, pfnXPIProgress, pfnXPIFinal );
virtual ~nsStubNotifier();
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();
NS_IMETHOD LogComment(const char *comment);
private:
pfnXPIStart m_start;
pfnXPIProgress m_progress;
pfnXPIFinal m_final;
};
#endif

129
xpinstall/stub/xpistub.cpp Normal file
Просмотреть файл

@ -0,0 +1,129 @@
/* -*- 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>
*/
#include "xpistub.h"
#include "nsRepository.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsSpecialSystemDirectory.h"
#include "nscore.h"
#include "nspr.h"
#include "nsStubNotifier.h"
#include "nsISoftwareUpdate.h"
#include "nsSoftwareUpdateIIDs.h"
//------------------------------------------------------------------------
// globals
//------------------------------------------------------------------------
static nsIXPINotifier *gNotifier = 0;
static nsISoftwareUpdate *gXPI = 0;
static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
//------------------------------------------------------------------------
// XPI_Init()
//------------------------------------------------------------------------
PR_PUBLIC_API(nsresult) XPI_Init( pfnXPIStart startCB,
pfnXPIProgress progressCB,
pfnXPIFinal finalCB )
{
nsresult rv;
rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, 0);
if (NS_SUCCEEDED(rv))
{
rv = nsComponentManager::CreateInstance(kSoftwareUpdateCID,
nsnull,
nsISoftwareUpdate::GetIID(),
(void**) &gXPI);
if (NS_SUCCEEDED(rv))
{
gNotifier = new nsStubNotifier( startCB, progressCB, finalCB );
if (!gNotifier)
{
gXPI->Release();
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
gNotifier->AddRef();
}
}
return rv;
}
//------------------------------------------------------------------------
// XPI_Exit()
//------------------------------------------------------------------------
PR_PUBLIC_API(void) XPI_Exit()
{
if (gNotifier)
gNotifier->Release();
if (gXPI)
gXPI->Release();
// XXX How do I shut down XPCOM? Do I need to?
}
//------------------------------------------------------------------------
// XPI_Install()
//------------------------------------------------------------------------
PR_PUBLIC_API(nsresult) XPI_Install(
#ifndef XP_MAC
const char* aFile,
#else
const FSSpec& aFile,
#endif
const char* aArgs,
long aFlags )
{
nsresult rv = NS_ERROR_NULL_POINTER;
nsString args(aArgs);
nsCOMPtr<nsIFileSpec> iFile;
nsFileSpec file(aFile);
NS_NewFileSpecWithSpec( file, getter_AddRefs(iFile) );
if (iFile && gXPI)
rv = gXPI->InstallJar( iFile, args.GetUnicode(), aFlags, gNotifier );
return rv;
}

103
xpinstall/stub/xpistub.h Normal file
Просмотреть файл

@ -0,0 +1,103 @@
/* -*- 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>
*/
#include "nsError.h"
#include "prtypes.h"
#ifdef XP_MAC
#include <Files.h>
#endif
PR_BEGIN_EXTERN_C
/** pfnXPIStart -- script start callback
*
* When an install script gets to StartInstall() this function
* will be called to tell the observer the pretty-name of the
* install package. You are not guaranteed this will be called
* for all scripts--there might be a fatal error before it gets
* to StartInstall(), either in the script itself or in the
* engine trying to set up for it.
*/
typedef void (*pfnXPIStart) (const char* UIName);
/** pfnXPIProgress -- individual install item callback
*
* This callback will be called twice for each installed item,
* First when it is scheduled (val and max will both be 0) and
* then during the finalize step.
*
* This function must return NS_OK unless it wants to stop
* the script execution (for example, to implement a user-cancel
* feature). To stop the script return a failing nsresult value.
*/
typedef nsresult (*pfnXPIProgress)(const char* msg, PRInt32 val, PRInt32 max);
/** pfnXPIFinal -- script end callback
*
* This function will be called when the script calls either
* AbortInstall() or FinalizeInstall() and will return the
* last error code.
*/
typedef void (*pfnXPIFinal) (PRInt32 finalStatus);
/** XPI_Init
*
* call XPI_Init() to initialize XPCOM and the XPInstall
* engine, and to pass in your callback functions
*
* @returns XPCOM status code indicating success or failure
*/
PR_EXTERN(nsresult) XPI_Init( pfnXPIStart startCB,
pfnXPIProgress progressCB,
pfnXPIFinal finalCB );
/** XPI_Install
*
* Install a XPI package from a local file
*
* @param file Native filename of XPI archive
* @param args Install.arguments, if any
* @param flags the old SmartUpdate trigger flags. This may go away
*/
PR_EXTERN(nsresult) XPI_Install(
#ifndef XP_MAC
const char* file,
#else
const FSSpec& file,
#endif
const char* args,
long flags );
/** XPI_Exit
*
* call when done to shut down the XPInstall and XPCOM engines
* and free allocated memory
*/
PR_EXTERN(void) XPI_Exit();
PR_END_EXTERN_C