Linux installer launches mozilla -installer at tehend of installation.

b=55419
r=ssu
a=dveditz
This commit is contained in:
sgehani%netscape.com 2000-10-14 02:22:48 +00:00
Родитель c1cb60b9d3
Коммит f7e4f6ea74
7 изменённых файлов: 237 добавлений и 1 удалений

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

@ -161,6 +161,13 @@ Message0=Click the Install button to proceed with this installation.
XPInstall Engine=xpcom.xpi
;-------------------------------------------------------------------------
[RunApp0]
;-------------------------------------------------------------------------
Target=mozilla
Arguments=-installer
;-------------------------------------------------------------------------
[LegacyCheck0]
;-------------------------------------------------------------------------

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

@ -38,6 +38,7 @@ CPPSRCS = \
nsSetupType.cpp \
nsComponentList.cpp \
nsLegacyCheck.cpp \
nsRunApp.cpp \
nsLicenseDlg.cpp \
nsWelcomeDlg.cpp \
nsSetupTypeDlg.cpp \

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

@ -91,6 +91,10 @@
#define INVISIBLE_ATTR "INVISIBLE"
#define LAUNCHAPP_ATTR "LAUNCHAPP"
#define RUNAPPd "RunApp%d"
#define TARGET "Target"
#define ARGS "Arguments"
#define DLG_START_INSTALL "Dialog Start Install"
#define XPINSTALL_ENGINE "XPInstall Engine"

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

@ -28,6 +28,7 @@
#include <signal.h>
static char *sXPInstallEngine;
static nsRunApp *sRunAppList = NULL;
static GtkWidget *sMsg0Label;
static GtkWidget *sMajorLabel;
@ -115,6 +116,13 @@ nsInstallDlg::Next(GtkWidget *aWidget, gpointer aData)
XI_GTK_UPDATE_UI();
WorkDammitWork((void*) NULL);
// run all specified applications after installation
if (sRunAppList)
{
RunApps();
FreeRunAppList();
}
gCtx->bMoving = TRUE;
return;
@ -126,6 +134,10 @@ nsInstallDlg::Parse(nsINIParser *aParser)
int err = OK;
int bufsize = 0;
char *showDlg = NULL;
char secName[64];
int i;
char *app = NULL, *args = NULL;
nsRunApp *newRunApp = NULL;
/* compulsory keys*/
XI_ERR_BAIL(aParser->GetStringAlloc(DLG_START_INSTALL,
@ -153,7 +165,25 @@ nsInstallDlg::Parse(nsINIParser *aParser)
XI_ERR_BAIL(aParser->GetStringAlloc(DLG_START_INSTALL, TITLE,
&mTitle, &bufsize));
if (bufsize == 0)
XI_IF_FREE(mTitle);
XI_IF_FREE(mTitle);
for (i = 0; err == OK; i++)
{
/* construct RunAppX section name */
sprintf(secName, RUNAPPd, i);
err = aParser->GetStringAlloc(secName, TARGET, &app, &bufsize);
if (err == OK && bufsize > 0)
{
/* "args" is optional: this may return E_NO_KEY which we ignore */
err = aParser->GetStringAlloc(secName, ARGS, &args, &bufsize);
newRunApp = new nsRunApp(app, args);
if (!newRunApp)
return E_MEM;
err = AppendRunApp(newRunApp);
}
}
err = OK; /* reset error since RunAppX sections are optional
and we could have gotten a parse error (E_NO_SEC) */
return err;
@ -161,6 +191,86 @@ BAIL:
return err;
}
int
nsInstallDlg::AppendRunApp(nsRunApp *aNewRunApp)
{
int err = OK;
nsRunApp *currRunApp = NULL;
/* param check */
if (!aNewRunApp)
return E_PARAM;
/* special case: list is empty */
if (!sRunAppList)
{
sRunAppList = aNewRunApp;
return OK;
}
/* list has at least one element */
currRunApp = sRunAppList;
while (currRunApp)
{
if (!currRunApp->GetNext())
{
currRunApp->SetNext(aNewRunApp);
break;
}
}
return err;
}
void
nsInstallDlg::FreeRunAppList()
{
nsRunApp *currRunApp = NULL, *nextRunApp = NULL;
currRunApp = sRunAppList;
while (currRunApp)
{
nextRunApp = currRunApp->GetNext();
delete currRunApp;
currRunApp = nextRunApp;
}
}
void
nsInstallDlg::RunApps()
{
nsRunApp *currRunApp = sRunAppList;
char *argv[3], *dest;
char apppath[MAXPATHLEN];
extern char **environ; /* globally available to all processes */
int pid;
while (currRunApp)
{
/* run application with supplied args */
if ((pid = fork()) == 0)
{
/* child */
dest = gCtx->opt->mDestination;
if (*(dest + strlen(dest)) == '/') /* trailing slash */
sprintf(apppath, "%s%s", dest, currRunApp->GetApp());
else /* no trailing slash */
sprintf(apppath, "%s/%s", dest, currRunApp->GetApp());
argv[0] = apppath;
argv[1] = currRunApp->GetArgs();
argv[2] = NULL; /* null-terminate arg vector */
execve(apppath, argv, environ);
/* shouldn't reach this but in case execve fails we will */
exit(0);
}
/* parent continues running to finish installation */
currRunApp = currRunApp->GetNext();
}
}
int
nsInstallDlg::Show(int aDirection)
{

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

@ -27,6 +27,7 @@
#include "nsXInstallerDlg.h"
#include "XIErrors.h"
#include "nsRunApp.h"
class nsInstallDlg : public nsXInstallerDlg
{
@ -69,6 +70,9 @@ private:
static void *WorkDammitWork(void *arg); // install start
static void ShowCompleteDlg();
static void CompleteOK(GtkWidget *aWidget, gpointer aData);
static void RunApps();
static void FreeRunAppList();
int AppendRunApp(nsRunApp *aNewRunApp);
char *mMsg0;
};

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

@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/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.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#include "nsRunApp.h"
nsRunApp::nsRunApp(char *aApp, char *aArgs) :
mApp(aApp),
mArgs(aArgs),
mNext(NULL)
{
}
nsRunApp::~nsRunApp()
{
XI_IF_FREE(mApp);
XI_IF_FREE(mArgs);
}
char *
nsRunApp::GetApp()
{
return mApp;
}
char *
nsRunApp::GetArgs()
{
return mArgs;
}
void
nsRunApp::SetNext(nsRunApp *aNext)
{
mNext = aNext;
}
nsRunApp *
nsRunApp::GetNext()
{
return mNext;
}

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

@ -0,0 +1,47 @@
/* -*- 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.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/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.
*
* Contributor(s):
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _NS_RUNAPP_H_
#define _NS_RUNAPP_H_
#include "XIDefines.h"
class nsRunApp
{
public:
nsRunApp(char *aApp, char *aArgs);
~nsRunApp();
char *GetApp();
char *GetArgs();
void SetNext(nsRunApp *aNext);
nsRunApp *GetNext();
private:
char *mApp;
char *mArgs;
nsRunApp *mNext;
};
#endif /* _NS_RUNAPP_H_ */