Linux install wizard progress.
This commit is contained in:
sgehani%netscape.com 2000-02-11 00:57:43 +00:00
Родитель d26a527af4
Коммит b6f48bd954
22 изменённых файлов: 509 добавлений и 57 удалений

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

@ -40,8 +40,15 @@ CPPSRCS = \
nsSetupTypeDlg.cpp \
nsComponentsDlg.cpp \
nsInstallDlg.cpp \
nsXIContext.cpp \
nsXInstaller.cpp \
nsINIParser.cpp \
$(NULL)
LIBS = \
$(TK_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
CXXFLAGS += $(MOZ_TOOLKIT_REGISTRY_CFLAGS)

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

@ -0,0 +1,98 @@
/* -*- 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 _XIDEFINES_H_
#define _XIDEFINES_H_
#include "XIErrors.h"
/*--------------------------------------------------------------------*
* Limits
*--------------------------------------------------------------------*/
#define MAX_COMPONENTS 64
#define MAX_SETUP_TYPES 32
/*--------------------------------------------------------------------*
* Widget Dims
*--------------------------------------------------------------------*/
#define XI_WIN_HEIGHT 320
#define XI_WIN_WIDTH 550
/*--------------------------------------------------------------------*
* Macros
*--------------------------------------------------------------------*/
#define XI_IF_DELETE(_object) \
do { \
if (_object) \
delete _object; \
} while(0);
#define XI_IF_FREE(_ptr) \
do { \
if (_ptr) \
free(_ptr); \
} while(0);
#define XI_ERR_BAIL(_function) \
do { \
err = _function; \
if (err != OK) \
{ \
ErrorHandler(err); \
goto BAIL; \
} \
} while (0);
#define XI_ERR_BAIL_EXCEPT(_function, _errexpected) \
do { \
err = _function; \
if (err != OK && err != _errexpected) \
{ \
ErrorHandler(err); \
goto BAIL; \
} \
} while(0);
#define XI_VERIFY(_ptr) \
do { \
if (!_ptr) \
return ErrorHandler(E_INVALID_PTR); \
} while (0);
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif
#endif /* _XIDEFINES_H_ */

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

@ -25,6 +25,8 @@
#ifndef _XI_ERRORS_H_
#define _XI_ERRORS_H_
#include <stdio.h>
/*------------------------------------------------------------------*
* X Installer Errors
*------------------------------------------------------------------*/
@ -33,19 +35,34 @@
OK = 0,
E_MEM = -601, /* out of memory */
E_PARAM = -602, /* invalid param */
E_NO_MEMBER = -603 /* invalid member variable */
E_NO_MEMBER = -603, /* invalid member variable */
E_INVALID_PTR = -604 /* invalid pointer */
};
#ifndef TRUE
#define TRUE 1
#endif
#define FATAL_ERR_THRESHOLD -500 /* errs below this cause app quit */
#define GENERAL_ERR_THRESHOLD -1 /* errs below this cause dlg to come up*/
#ifndef FALSE
#define FALSE 0
#endif
/*------------------------------------------------------------------*
* Default Error Handler
*------------------------------------------------------------------*/
static int ErrorHandler(int aErr)
{
// XXX 1. fix this to get a string associated with the error code
// XXX from a resourced string bundle
// XXX
// XXX 2. fix this to throw up a dialog rather than writing to stdout
#ifndef NULL
#define NULL 0
#endif
if (aErr < FATAL_ERR_THRESHOLD)
{
printf("Fatal error[%d]: Doom and darkness has struck!\n", aErr);
exit(aErr);
}
else if (aErr < GENERAL_ERR_THRESHOLD)
printf("Error[%d]: Regular error so moving right along.\n", aErr);
else
printf("Warning[%d]: We spit crap to stdout cos we can!\n", aErr);
return aErr;
}
#endif /* _XI_ERRORS_H_ */

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

@ -25,7 +25,7 @@
#ifndef _NS_COMPONENT_H_
#define _NS_COMPONENT_H_
#include "XILimits.h"
#include "XIDefines.h"
#include "XIErrors.h"
#include <malloc.h>

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

@ -51,6 +51,17 @@ nsComponentsDlg::Next()
return OK;
}
int
nsComponentsDlg::Parse(nsINIParser *aParser)
{
int err = OK;
return err;
BAIL:
return err;
}
int
nsComponentsDlg::SetMsg0(char *aMsg)
{

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

@ -42,6 +42,8 @@ public:
int Back();
int Next();
int Parse(nsINIParser* aParser);
/*--------------------------------------------------------------------*
* INI Properties
*--------------------------------------------------------------------*/

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

@ -90,7 +90,6 @@ public:
*/
int GetError();
/*--------------------------------------------------------------------*
* Errors
*--------------------------------------------------------------------*/

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

@ -47,6 +47,17 @@ nsInstallDlg::Next()
return OK;
}
int
nsInstallDlg::Parse(nsINIParser *aParser)
{
int err = OK;
return err;
BAIL:
return err;
}
int
nsInstallDlg::SetMsg0(char *aMsg)
{

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

@ -40,6 +40,8 @@ public:
int Back();
int Next();
int Parse(nsINIParser* aParser);
/*------------------------------------------------------------------*
* INI Properties
*------------------------------------------------------------------*/

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

@ -53,6 +53,17 @@ nsLicenseDlg::Next()
return OK;
}
int
nsLicenseDlg::Parse(nsINIParser *aParser)
{
int err = OK;
return err;
BAIL:
return err;
}
int
nsLicenseDlg::SetLicenseFile(char *aLicenseFile)
{

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

@ -40,6 +40,8 @@ public:
int Back();
int Next();
int Parse(nsINIParser *aParser);
/*-------------------------------------------------------------------*
* INI Properties
*-------------------------------------------------------------------*/

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

@ -25,7 +25,7 @@
#ifndef _NS_SETUPTYPE_H_
#define _NS_SETUPTYPE_H_
#include "XILimits.h"
#include "XIDefines.h"
#include "XIErrors.h"
#include "nsComponent.h"

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

@ -27,6 +27,17 @@ nsSetupTypeDlg::Next()
return OK;
}
int
nsSetupTypeDlg::Parse(nsINIParser *aParser)
{
int err = OK;
return err;
BAIL:
return err;
}
int
nsSetupTypeDlg::SetMsg0(char *aMsg)
{

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

@ -40,6 +40,8 @@ public:
int Back();
int Next();
int Parse(nsINIParser *aParser);
/*---------------------------------------------------------------------*
* INI Properties
*---------------------------------------------------------------------*/

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

@ -56,6 +56,17 @@ nsWelcomeDlg::Next()
return OK;
}
int
nsWelcomeDlg::Parse(nsINIParser *aParser)
{
int err = OK;
return err;
BAIL:
return err;
}
int
nsWelcomeDlg::SetReadmeFile(char *aReadmeFile)
{

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

@ -40,6 +40,8 @@ public:
int Back();
int Next();
int Parse(nsINIParser *aParser);
/*--------------------------------------------------------------------*
* INI Properties
*--------------------------------------------------------------------*/

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

@ -0,0 +1,57 @@
/* -*- 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 "nsXIContext.h"
nsXIContext::nsXIContext()
{
me = NULL;
ldlg = NULL;
wdlg = NULL;
sdlg = NULL;
cdlg = NULL;
idlg = NULL;
window = NULL;
back = NULL;
next = NULL;
logo = NULL;
}
nsXIContext::~nsXIContext()
{
// NOTE: don't try to delete "me" cause I control thee
XI_IF_DELETE(ldlg);
XI_IF_DELETE(wdlg);
XI_IF_DELETE(sdlg);
XI_IF_DELETE(cdlg);
XI_IF_DELETE(idlg);
XI_IF_FREE(window);
XI_IF_FREE(back);
XI_IF_FREE(next);
XI_IF_FREE(logo);
}

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

@ -0,0 +1,67 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.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_XICONTEXT_H_
#define _NS_XICONTEXT_H_
#include <gtk/gtk.h>
#include "nsLicenseDlg.h"
#include "nsWelcomeDlg.h"
#include "nsSetupTypeDlg.h"
#include "nsComponentsDlg.h"
#include "nsInstallDlg.h"
class nsXInstaller;
class nsXIContext
{
public:
nsXIContext();
~nsXIContext();
nsXInstaller *me;
/*-------------------------------------------------------------------*
* Dialog Contexts
*-------------------------------------------------------------------*/
nsLicenseDlg *ldlg;
nsWelcomeDlg *wdlg;
nsSetupTypeDlg *sdlg;
nsComponentsDlg *cdlg;
nsInstallDlg *idlg;
/*-------------------------------------------------------------------*
* Global Widgets
*-------------------------------------------------------------------*/
GtkWidget *window; /* unique canvas for dialogs */
GtkWidget *back; /* back button */
GtkWidget *next; /* next button */
GtkWidget *logo; /* branding icon: an xpm image */
GtkWidget *mainbox; /* vbox holding all except logo */
GtkWidget *canvas; /* vbox for mutable dlgs (no nav btns) */
};
#endif /* _NS_XICONTEXT_H_ */

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

@ -24,9 +24,9 @@
#include "nsXInstaller.h"
#include "nsINIParser.h"
#include "logo-star.xpm"
#include "XIErrors.h"
nsXIContext *gCtx = NULL;
nsXInstaller::nsXInstaller()
{
@ -40,11 +40,11 @@ int
nsXInstaller::ParseConfig()
{
int err = OK;
nsINIParser *parser = new nsINIParser( CONFIG_INI );
char *bufalloc = NULL;
char buf[512];
int bufsize = 0;
nsINIParser *parser = NULL;
XI_ERR_BAIL(InitContext());
parser = new nsINIParser( CONFIG_INI );
if (!parser)
return E_MEM;
@ -52,43 +52,170 @@ nsXInstaller::ParseConfig()
if (err != nsINIParser::OK)
return err;
bufsize = 512;
// err = parser->GetString("section2", "key2", buf, &bufsize);
err = parser->GetStringAlloc("section2", "key2", &bufalloc, &bufsize);
if ( (err == nsINIParser::OK) && (bufalloc) && (bufsize > 0) )
{
DUMP("section2 key2 = ");
DUMP(bufalloc);
}
XI_ERR_BAIL(gCtx->ldlg->Parse(parser));
XI_ERR_BAIL(gCtx->wdlg->Parse(parser));
XI_ERR_BAIL(gCtx->sdlg->Parse(parser));
XI_ERR_BAIL(gCtx->cdlg->Parse(parser));
XI_ERR_BAIL(gCtx->idlg->Parse(parser));
return OK;
BAIL:
return err;
}
int
nsXInstaller::Run()
nsXInstaller::InitContext()
{
int err = OK;
if ( (err = StartWizard()) != OK)
goto au_revoir;
gCtx = new nsXIContext();
if (!gCtx)
return E_MEM;
if ( (err = Download()) != OK)
goto au_revoir;
gCtx->me = this;
if ( (err = Extract()) != OK)
goto au_revoir;
gCtx->ldlg = new nsLicenseDlg();
gCtx->wdlg = new nsWelcomeDlg();
gCtx->sdlg = new nsSetupTypeDlg();
gCtx->cdlg = new nsComponentsDlg();
gCtx->idlg = new nsInstallDlg();
if (!gCtx->ldlg || !gCtx->wdlg || !gCtx->sdlg ||
!gCtx->cdlg || !gCtx->idlg )
{
err = E_MEM;
goto BAIL;
}
if ( (err = Install()) != OK)
goto au_revoir;
return OK;
BAIL:
XI_IF_DELETE(gCtx->ldlg);
XI_IF_DELETE(gCtx->wdlg);
XI_IF_DELETE(gCtx->sdlg);
XI_IF_DELETE(gCtx->cdlg);
XI_IF_DELETE(gCtx->idlg);
XI_IF_DELETE(gCtx);
au_revoir:
return err;
}
int
nsXInstaller::StartWizard()
nsXInstaller::RunWizard(int argc, char **argv)
{
int err = OK;
XI_VERIFY(gCtx);
// create the dialog window
gtk_init(&argc, &argv);
gdk_rgb_init();
gCtx->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
XI_VERIFY(gCtx->window);
gtk_widget_set_usize(gCtx->window, XI_WIN_WIDTH, XI_WIN_HEIGHT);
gtk_container_set_border_width(GTK_CONTAINER(gCtx->window), 5);
gtk_widget_show(gCtx->window);
// create and display the logo
DrawLogo();
// create and register the nav buttons
XI_ERR_BAIL(DrawNavButtons());
// populate with license dlg
// pop over to main event loop
gtk_main();
return OK;
BAIL:
return err;
}
int
nsXInstaller::DrawLogo()
{
int err = OK;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
GtkWidget *mainhbox;
GtkWidget *logovbox;
GtkWidget *canvasvbox;
style = gtk_widget_get_style(gCtx->window);
pixmap = gdk_pixmap_create_from_xpm_d(gCtx->window->window, &mask,
&style->bg[GTK_STATE_NORMAL],
(gchar **)logo_star_xpm);
gCtx->logo = gtk_pixmap_new(pixmap, mask);
XI_VERIFY(gCtx->logo);
gtk_widget_show(gCtx->logo);
mainhbox = gtk_hbox_new(FALSE, 10);
logovbox = gtk_vbox_new(FALSE, 10);
canvasvbox = gtk_vbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(logovbox), gCtx->logo, FALSE, FALSE, 0);
gtk_widget_show(logovbox);
gtk_widget_show(canvasvbox);
gtk_box_pack_start(GTK_BOX(mainhbox), logovbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(mainhbox), canvasvbox, FALSE, FALSE, 0);
gtk_widget_show(mainhbox);
gtk_container_add(GTK_CONTAINER(gCtx->window), mainhbox);
gCtx->mainbox = canvasvbox; /* canvasvbox = canvas - nav btns' box */
return err;
}
int
nsXInstaller::DrawNavButtons()
{
int err = OK;
GtkWidget *navbtnhbox;
GtkWidget *canvasvbox;
GtkWidget *navbtntable;
XI_VERIFY(gCtx->mainbox);
gCtx->next = gtk_button_new_with_label("Accept"); // XXX from license dlg
gCtx->back = gtk_button_new_with_label("Decline"); // XXX parse keys
XI_VERIFY(gCtx->next);
XI_VERIFY(gCtx->back);
gtk_widget_show(gCtx->next);
gtk_widget_show(gCtx->back);
navbtnhbox = gtk_hbutton_box_new();
canvasvbox = gtk_vbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(gCtx->mainbox), canvasvbox, TRUE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(gCtx->mainbox), navbtnhbox, FALSE, FALSE, 0);
// put a table in the nav btn box
navbtntable = gtk_table_new(1, 6, TRUE);
gtk_box_pack_start(GTK_BOX(navbtnhbox), navbtntable, TRUE, TRUE, 0);
gtk_table_attach(GTK_TABLE(navbtntable), gCtx->back, 5, 6, 0, 1,
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 5, 5);
gtk_table_attach(GTK_TABLE(navbtntable), gCtx->next, 6, 7, 0, 1,
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 5, 5);
gtk_widget_show(navbtntable);
gtk_widget_show(navbtnhbox);
gtk_widget_show(canvasvbox);
gtk_widget_show(gCtx->mainbox);
XI_VERIFY(canvasvbox);
gCtx->canvas = canvasvbox;
return err;
}
int
@ -118,9 +245,12 @@ main(int argc, char **argv)
if (installer)
{
if ( (err = installer->ParseConfig()) == OK)
err = installer->Run();
err = installer->RunWizard(argc, argv);
}
else
err = E_MEM;
XI_IF_DELETE(installer);
exit(err);
}

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

@ -25,9 +25,17 @@
#ifndef _NS_XINSTALLER_H_
#define _NS_XINSTALLER_H_
#include <gtk/gtk.h>
#include <stdio.h>
#include "XIDefines.h"
#include "XIErrors.h"
#include "nsINIParser.h"
#include "nsLicenseDlg.h"
#include "nsXIContext.h"
extern nsXIContext *gCtx;
class nsXInstaller
{
public:
@ -35,13 +43,15 @@ public:
~nsXInstaller();
int ParseConfig();
int Run();
private:
int StartWizard();
int RunWizard(int argc, char **argv);
int Download();
int Extract();
int Install();
private:
int InitContext();
int DrawLogo();
int DrawNavButtons();
};
int main(int argc, char **argv);

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

@ -28,11 +28,13 @@
#include <malloc.h>
#include "XIErrors.h"
#include "nsINIParser.h"
/**
* nsXInstallerDlg
*
* The interface for all installer dialogs. Helps maintain
* uniform navigation mechanism and UI widgets.
* uniform navigation mechanism, startup init, and UI widgets.
*/
class nsXInstallerDlg
{
@ -46,6 +48,8 @@ public:
virtual int Back() = 0;
virtual int Next() = 0;
virtual int Parse(nsINIParser *aParser) = 0;
/*-------------------------------------------------------------------*
* INI Properties
*-------------------------------------------------------------------*/
@ -54,8 +58,6 @@ public:
int SetTitle(char *aTitle);
char *GetTitle();
// TO DO
enum
{
SKIP_DLG = 0,