*** NOT PART OF BUILD ***

Initial checkin of Unix installer.



git-svn-id: svn://10.0.0.236/trunk@56794 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sgehani%netscape.com 2000-01-05 02:30:42 +00:00
parent e3ea0136ed
commit 46bbfbbefd
30 changed files with 2974 additions and 0 deletions

View File

@ -0,0 +1,9 @@
libjar50.so
libjsdom.so
libmozjs.so
libnspr3.so
libplc3.so
libplds3.so
libxpcom.so
libxpinstall.so
libxpistub.so

View File

@ -0,0 +1,352 @@
/* -*- 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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#include "INSTALL.h"
static xpistub_t gstub;
int
main(int argc, char **argv)
{
int err = XI_OK;
xpi_t *pkglist;
ERR_CHECK( init() );
ERR_CHECK( build_list(&pkglist) );
ERR_CHECK( install_all(pkglist) );
ERR_CHECK( shutdown(pkglist) );
return err;
}
int
init()
{
nsresult rv = NS_OK;
char progdir[512];
int err = XI_OK;
DUMP("initialize");
err = extract_core();
if (err != XI_OK)
{
PRINT_ERR(err);
shutdown(NULL);
return err;
}
err = load_stub();
if (err != XI_OK)
{
PRINT_ERR(err);
shutdown(NULL);
return err;
}
getcwd(progdir, 512);
rv = gstub.fn_init(progdir, progress_callback);
if (NS_FAILED(rv))
{
PRINT_ERR(rv);
shutdown(NULL);
return XI_XPI_FAIL;
}
DUMP("XPI_Init called");
return err;
}
int
extract_core()
{
char cmd[256];
int i;
int err = XI_OK;
DUMP("extract_core");
for (i = 0; i < CORE_LIB_COUNT*2; i++)
{
strcpy(cmd, "unzip -j "); /* -j = junk paths; install here */
strcat(cmd, CORE_ARCHIVE); /* relative path to install.xpi */
strcat(cmd, " -d . "); /* -d = destination root */
strcat(cmd, core_libs[i]); /* archive subdir */
strcat(cmd, core_libs[++i]);/* lib file name */
strcat(cmd, "\0");
DUMP(cmd);
system(cmd);
}
return err;
}
int
load_stub()
{
char libpath[512];
char *dlerr;
int err = XI_OK;
DUMP("load_stub");
/* get the working dir and tack on lib name */
getcwd(libpath, 512);
strncat(libpath, "/", 1);
strncat(libpath, XPISTUB, strlen(XPISTUB));
DUMP(libpath);
/* open the library */
gstub.handle = NULL;
gstub.handle = dlopen(libpath, RTLD_NOW);
if (!gstub.handle)
{
dlerr = dlerror();
DUMP(dlerr);
return XI_LIB_OPEN;
}
DUMP("xpistub opened");
/* read and store symbol addresses */
gstub.fn_init = (pfnXPI_Init) dlsym(gstub.handle, FN_INIT);
gstub.fn_install = (pfnXPI_Install) dlsym(gstub.handle, FN_INSTALL);
gstub.fn_exit = (pfnXPI_Exit) dlsym(gstub.handle, FN_EXIT);
if (!gstub.fn_init || !gstub.fn_install || !gstub.fn_exit)
{
dlerr = dlerror();
DUMP(dlerr);
return XI_LIB_SYM;
}
return err;
}
void
progress_callback(const char* msg, PRInt32 max, PRInt32 val)
{
DUMP("progress_callback");
if (max == 0)
{
if (val > 0)
printf("Preparing item %d ...\n", val);
}
else
printf("Installing item %d of %d ...\n", val, max);
}
int
build_list(xpi_t **listhead)
{
xpi_t *currxpi = NULL, *lastxpi = NULL;
char mfpath[512];
char *buf = NULL, *pcurr, curr[32];
fpos_t mfeof;
FILE *fdmf;
size_t rd = 0;
int len = 0, total, head;
int err = XI_OK;
DUMP("build_list");
if (!listhead)
return XI_NULL_PTR;
*listhead = NULL;
/* XXX optionally set mf path in cmd line args */
strcpy(mfpath, MANIFEST);
/* open manifest file */
fdmf = NULL;
fdmf = fopen(mfpath, "r");
if (!fdmf)
{
err = XI_NO_MANIFEST;
goto bail;
}
DUMP("opened manifest");
/* read the file into a buffer */
if (fseek(fdmf, 0, SEEK_END) != 0)
{
err = XI_NO_MANIFEST;
goto bail;
}
if (fgetpos(fdmf, &mfeof) != 0)
{
err = XI_NO_MANIFEST;
goto bail;
}
DUMP("eof manifest found");
buf = (char*) malloc(mfeof * sizeof(char));
if (!buf)
{
err = XI_OUT_OF_MEM;
goto bail;
}
DUMP("malloc'd manifest buf");
if (fseek(fdmf, 0, SEEK_SET) != 0)
{
err = XI_NO_MANIFEST;
goto bail;
}
rd = fread( (void*)buf, 1, mfeof, fdmf);
if (!rd)
{
err = XI_NO_MANIFEST;
goto bail;
}
DUMP(buf);
/* loop over each line reading in a .xpi module
* name unless commented with ';'
*/
head = 1;
for (pcurr = buf, total = 0; total < mfeof; pcurr = strchr(pcurr, '\n')+1)
{
len = strchr(pcurr, '\n') - pcurr;
total += len + 1;
strncpy(curr, pcurr, len);
curr[ (len>32?32:len) ] = '\0';
/* malloc a new xpi structure */
currxpi = (xpi_t *) malloc(sizeof(xpi_t));
if (!currxpi)
{
err = XI_OUT_OF_MEM;
goto bail;
}
currxpi->next = NULL;
if (head)
{
*listhead = currxpi;
lastxpi = currxpi;
}
strncpy(currxpi->name, curr, (len>32?32:len));
/* link to xpi list */
if (!head && *listhead)
{
lastxpi->next = currxpi;
lastxpi = currxpi;
}
else
head = 0;
}
/* close manifest file */
fclose(fdmf);
return err;
bail:
if (buf)
free(buf);
shutdown(*listhead);
return err;
}
int
install_all(xpi_t *listhead)
{
xpi_t *curr = listhead;
int err = XI_OK;
DUMP("install_all");
if (!listhead)
return XI_NULL_PTR;
while (curr)
{
install_one(curr);
curr = curr->next;
}
return err;
}
int
install_one(xpi_t *pkg)
{
nsresult rv = NS_OK;
char xpipath[512];
int err = XI_OK;
DUMP("install_one");
getcwd(xpipath, 512);
strncat(xpipath, "/modules/", 9);
strncat(xpipath, pkg->name, strlen(pkg->name));
DUMP("--------- installing xpi package: ");
DUMP(xpipath);
DUMP("---------\n");
/* XXX check if file exists: if not skip it with status */
rv = gstub.fn_install(xpipath, "", 0);
if (NS_FAILED(rv))
{
err = XI_XPI_FAIL;
printf("ERROR %d: Installation of %s failed.\n", rv, pkg->name);
}
else
printf("Installed %s successfully.\n", pkg->name);
return err;
}
int
shutdown(xpi_t *list)
{
xpi_t *curr = list;
int i;
int err = XI_OK;
DUMP("shutdown");
/* release XPCOM and XPInstall */
if (gstub.fn_exit)
{
gstub.fn_exit();
DUMP("XPI_Exit called");
}
/* close xpistub library */
if (gstub.handle)
{
dlclose(gstub.handle);
DUMP("xpistub closed");
}
while (curr)
{
list = curr->next;
free(curr);
curr = list;
}
/* clean up extracted core libs */
for (i=1; i<CORE_LIB_COUNT*2; i+=2)
{
unlink(core_libs[i]);
}
return err;
}

View File

@ -0,0 +1,136 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* The contents of this file are subject to the Netscape Public License
* Version 1.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) 1999
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors:
* Samir Gehani <sgehani@netscape.com>
*/
#ifndef _INSTALL_H_
#define _INSTALL_H_
#include "xpistub.h"
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include <dlfcn.h>
/*_____________________________________________ func ptrs __*/
typedef nsresult (*pfnXPI_Init) (const char *aProgramDir, pfnXPIProgress progressCB);
typedef nsresult (*pfnXPI_Install) (const char *file, const char *args, long flags);
typedef void (*pfnXPI_Exit) ();
/*________________________________________________ arrays __*/
#define CORE_LIB_COUNT 10
static char core_libs[CORE_LIB_COUNT*2][32] =
{
/* Archive Subdir File */
/* -------------- ---- */
"bin/", "libjsdom.so",
"bin/", "libmozjs.so",
"bin/", "libnspr3.so",
"bin/", "libplc3.so",
"bin/", "libplds3.so",
"bin/", "libxpcom.so",
"bin/", "libxpistub.so",
"bin/components/", "libxpinstall.so",
"bin/components/", "libjar50.so",
"bin/", "component.reg"
};
/*_______________________________________________ structs __*/
typedef struct _xpistub_t
{
const char *name;
void *handle;
pfnXPI_Init fn_init;
pfnXPI_Install fn_install;
pfnXPI_Exit fn_exit;
} xpistub_t;
typedef struct _xpi_t
{
char name[32];
struct _xpi_t *next;
} xpi_t;
/*_________________________________________________ funcs __*/
int main(int argc, char **argv);
int init();
int extract_core();
int load_stub();
void progress_callback(const char *msg, PRInt32 max, PRInt32 val);
int build_list(xpi_t **listhead);
int install_all(xpi_t *listhead);
int install_one(xpi_t *pkg);
int shutdown(xpi_t *list);
/*________________________________________________ macros __*/
#ifdef DEBUG_sgehani___
#define DUMP(_msg) \
printf("%s %d: ", __FILE__, __LINE__); \
printf(_msg); \
printf("\n");
#else
#define DUMP(_msg)
#endif
#define XPISTUB "libxpistub.so"
#define FN_INIT "XPI_Init"
#define FN_INSTALL "XPI_Install"
#define FN_EXIT "XPI_Exit"
#ifndef RTLD_NOW
#define RTLD_NOW 0
#endif
#ifndef NULL
#define NULL 0
#endif
#define CORE_ARCHIVE "modules/install.xpi"
#define MANIFEST "modules/MANIFEST"
#define ERR_CHECK(_func) \
{ \
int ret_err = XI_OK; \
ret_err = _func; \
if (ret_err != XI_OK) \
{ \
PRINT_ERR(ret_err); \
return ret_err; \
} \
}
#ifdef DEBUG_sgehani
#define PRINT_ERR(_err) \
printf("%s %d: err = %d \n", __FILE__, __LINE__, _err);
#endif
/*________________________________________________ errors __*/
#define XI_OK 0
#define XI_NULL_PTR -1
#define XI_OUT_OF_MEM -2
#define XI_FAIL -3
#define XI_LIB_OPEN -4
#define XI_LIB_SYM -5
#define XI_XPI_FAIL -6
#define XI_NO_MANIFEST -7
#endif /* _INSTALL_H_ */

View File

@ -0,0 +1,47 @@
#
# 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>
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
PROGRAM = MozInstaller
CPPSRCS = \
nsXInstallerDlg.cpp \
nsComponent.cpp \
nsSetupType.cpp \
nsComponentList.cpp \
nsLicenseDlg.cpp \
nsWelcomeDlg.cpp \
nsSetupTypeDlg.cpp \
nsComponentsDlg.cpp \
nsInstallDlg.cpp \
nsXInstaller.cpp \
nsINIParser.cpp \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,51 @@
/* -*- 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 _XI_ERRORS_H_
#define _XI_ERRORS_H_
/*------------------------------------------------------------------*
* X Installer Errors
*------------------------------------------------------------------*/
enum
{
OK = 0,
E_MEM = -601, /* out of memory */
E_PARAM = -602, /* invalid param */
E_NO_MEMBER = -603 /* invalid member variable */
};
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif
#endif /* _XI_ERRORS_H_ */

View File

@ -0,0 +1,32 @@
/* -*- 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 _XILIMITS_H_
#define _XILIMITS_H_
#define MAX_COMPONENTS 64
#define MAX_SETUP_TYPES 32
#endif /* _XILIMITS_H_ */

View File

@ -0,0 +1,17 @@
[section1]
key1=value_of_key1_of_section1
key2=value_of_key2_of_section1
[section2]
key1=value_of_key1_of_section2
; key2=commentvalue_of_key2_of_section2
key2=realvalue_of_key2_of_section2
; dhdks
; kjdsakjdas
[SetupType0]
Short Description=Browser
Long Description=This is the browser component.
Size=9090

View File

@ -0,0 +1,32 @@
#include <stdio.h>
#include <stdlib.h>
#ifndef NULL
#define NULL 0
#endif
int
main(int arc, char **argv)
{
char *ftphost = "sweetlou";
char *file = "/products/server/README";
char *basename = "./README";
char *user = "test";
char *localhost = "test.com";
char *ftpcmds = malloc(1024);
sprintf(ftpcmds, "\
\
ftp -n %s <<EndFTP\n\
binary\n\
user anonymous %s@%s\n\
get %s %s\n\
EndFTP\n\
\
", ftphost, user, localhost, file, basename);
printf(ftpcmds);
system(ftpcmds);
return 0;
}

View File

@ -0,0 +1,240 @@
/* -*- 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 "nsComponent.h"
nsComponent::nsComponent() :
mDescShort(NULL),
mDescLong(NULL),
mArchive(NULL),
mSize(0),
mDependencies(NULL),
mAttributes(NO_ATTR)
{
}
nsComponent::~nsComponent()
{
if (mDescShort)
free (mDescShort);
if (mDescLong)
free (mDescLong);
if (mArchive)
free (mArchive);
if (mDependencies)
delete mDependencies;
}
int
nsComponent::SetDescShort(char *aDescShort)
{
if (!aDescShort)
return E_PARAM;
mDescShort = aDescShort;
return OK;
}
char *
nsComponent::GetDescShort()
{
if (mDescShort)
return mDescShort;
return NULL;
}
int
nsComponent::SetDescLong(char *aDescLong)
{
if (!aDescLong)
return E_PARAM;
mDescLong = aDescLong;
return OK;
}
char *
nsComponent::GetDescLong()
{
if (mDescLong)
return mDescLong;
return NULL;
}
int
nsComponent::SetArchive(char *aArchive)
{
if (!aArchive)
return E_PARAM;
mArchive = aArchive;
return OK;
}
char *
nsComponent::GetArchive()
{
if (mArchive)
return mArchive;
return NULL;
}
int
nsComponent::SetSize(int aSize)
{
mSize = aSize;
return OK;
}
int
nsComponent::GetSize()
{
if (mSize >= 0)
return mSize;
return 0;
}
int
nsComponent::AddDependency(nsComponent *aDependent)
{
if (!aDependent)
return E_PARAM;
if (!mDependencies)
mDependencies = new nsComponentList();
if (!mDependencies)
return E_MEM;
return mDependencies->AddComponent(aDependent);
}
int
nsComponent::RemoveDependency(nsComponent *aIndependent)
{
if (!aIndependent)
return E_PARAM;
if (!mDependencies)
return E_NO_MEMBER;
return mDependencies->RemoveComponent(aIndependent);
}
nsComponentList *
nsComponent::GetDependencies()
{
if (mDependencies)
return mDependencies;
return NULL;
}
int
nsComponent::SetSelected()
{
mAttributes |= nsComponent::SELECTED;
return OK;
}
int
nsComponent::SetUnselected()
{
if (IsSelected())
mAttributes &= ~nsComponent::SELECTED;
return OK;
}
int
nsComponent::IsSelected()
{
if (mAttributes & nsComponent::SELECTED)
return TRUE;
return FALSE;
}
int
nsComponent::SetInvisible()
{
mAttributes |= nsComponent::INVISIBLE;
return OK;
}
int
nsComponent::SetVisible()
{
if (IsInvisible())
mAttributes &= ~nsComponent::INVISIBLE;
return OK;
}
int
nsComponent::IsInvisible()
{
if (mAttributes & nsComponent::INVISIBLE)
return TRUE;
return FALSE;
}
int
nsComponent::SetNext(nsComponent *aComponent)
{
if (!aComponent)
return E_PARAM;
mNext = aComponent;
return OK;
}
int
nsComponent::InitNext()
{
mNext = NULL;
return OK;
}
nsComponent *
nsComponent::GetNext()
{
if (mNext)
return mNext;
return NULL;
}

View File

@ -0,0 +1,84 @@
/* -*- 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_COMPONENT_H_
#define _NS_COMPONENT_H_
#include "XILimits.h"
#include "XIErrors.h"
#include <malloc.h>
#include "nsComponentList.h"
class nsComponent
{
public:
nsComponent();
~nsComponent();
/*--------------------------------------------------------------*
* Accessors/Mutators
*--------------------------------------------------------------*/
int SetDescShort(char *aDescShort);
char * GetDescShort();
int SetDescLong(char *aDescLong);
char * GetDescLong();
int SetArchive(char *aAcrhive);
char * GetArchive();
int SetSize(int aSize);
int GetSize();
int AddDependency(nsComponent *aDependent);
int RemoveDependency(nsComponent *aIndependent);
nsComponentList *GetDependencies();
int SetSelected();
int SetUnselected();
int IsSelected();
int SetInvisible();
int SetVisible();
int IsInvisible();
int SetNext(nsComponent *aComponent);
int InitNext();
nsComponent *GetNext();
/*---------------------------------------------------------------*
* Attributes
*---------------------------------------------------------------*/
enum
{
NO_ATTR = 0x00000000,
SELECTED = 0x00000001,
INVISIBLE = 0x00000010
};
private:
char *mDescShort;
char *mDescLong;
char *mArchive;
int mSize;
nsComponentList *mDependencies;
int mAttributes;
nsComponent *mNext;
};
#endif /* _NS_COMPONENT_H_ */

View File

@ -0,0 +1,149 @@
/* -*- 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 "nsComponentList.h"
#include "nsComponent.h"
nsComponentList::nsComponentList() :
mHead(NULL),
mTail(NULL),
mNext(NULL),
mLength(0)
{
}
nsComponentList::~nsComponentList()
{
nsComponent *curr = mHead;
nsComponent *next = NULL;
while (curr)
{
next = NULL;
next = curr->GetNext();
delete curr;
curr = next;
}
mHead = NULL;
mTail = NULL;
mLength = 0;
}
nsComponent *
nsComponentList::GetHead()
{
if (mHead)
{
mNext = mHead->GetNext();
return mHead;
}
return NULL;
}
nsComponent *
nsComponentList::GetNext()
{
nsComponent *curr = mNext;
if (mNext)
{
mNext = mNext->GetNext();
return curr;
}
return NULL;
}
nsComponent *
nsComponentList::GetTail()
{
if (mTail)
return mTail;
return NULL;
}
int
nsComponentList::AddComponent(nsComponent *aComponent)
{
if (!aComponent)
return E_PARAM;
// empty list: head and tail are the same -- the new comp
if (!mHead)
{
mHead = aComponent;
mHead->InitNext();
mTail = mHead;
return OK;
}
// non-empty list: the new comp is tacked on and tail is updated
mTail->SetNext(aComponent);
mTail = aComponent;
mTail->InitNext();
return OK;
}
int
nsComponentList::RemoveComponent(nsComponent *aComponent)
{
nsComponent *curr = GetHead();
nsComponent *last = NULL;
if (!aComponent)
return E_PARAM;
while (curr)
{
if (aComponent == curr)
{
// remove and link last to next while deleting current
if (last)
{
last->SetNext(curr->GetNext());
}
else
{
mHead = curr->GetNext();
if (mTail == curr)
mTail = NULL;
}
delete aComponent;
return OK;
}
else
{
// move on to next
last = curr;
curr = GetNext();
}
}
}

View File

@ -0,0 +1,96 @@
/* -*- 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_COMPONENTLIST_H_
#define _NS_COMPONENTLIST_H_
#include "XIErrors.h"
class nsComponent;
class nsComponentList
{
public:
nsComponentList();
~nsComponentList();
/**
* GetHead
*
* Initializes the next ptr to the second item and
* returns the head item.
*
* @return mHead the head of the singly-linked list
*/
nsComponent * GetHead();
/**
* GetNext
*
* Returns the next available item. GetFirst() has to have
* been called prior calling this and after the last time
* the entire list was iterated over.
*
* @return mNext the next available component
*/
nsComponent * GetNext();
/**
* GetTail
*
* Returns the tail item of the list.
*
* @return mTail the tail item of the list
*/
nsComponent * GetTail();
/**
* AddComponent
*
* Adds the supplied component to the list's tail.
*
* @param aComponent the component to add
* @return err integer err code (zero means OK)
*/
int AddComponent(nsComponent *aComponent);
/**
* RemoveComponent
*
* Searches the list and removes the first component that
* matches the supplied component.
*
* @param aComponent the component to remove
* @return err integer error code (zero means OK)
*/
int RemoveComponent(nsComponent *aComponent);
private:
nsComponent *mHead;
nsComponent *mTail;
nsComponent *mNext;
int mLength;
};
#endif /* _NS_COMPONENTLIST_H_ */

View File

@ -0,0 +1,92 @@
/* -*- 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 "nsComponentsDlg.h"
nsComponentsDlg::nsComponentsDlg() :
mMsg0(NULL),
mCompList(NULL)
{
}
nsComponentsDlg::~nsComponentsDlg()
{
if (mMsg0)
free (mMsg0);
if (mCompList)
delete mCompList;
}
int
nsComponentsDlg::Back()
{
return OK;
}
int
nsComponentsDlg::Next()
{
return OK;
}
int
nsComponentsDlg::SetMsg0(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg0 = aMsg;
return OK;
}
char *
nsComponentsDlg::GetMsg0()
{
if (mMsg0)
return mMsg0;
return NULL;
}
int
nsComponentsDlg::SetCompList(nsComponentList *aCompList)
{
if (!aCompList)
return E_PARAM;
mCompList = aCompList;
return OK;
}
nsComponentList *
nsComponentsDlg::GetCompList()
{
if (mCompList)
return mCompList;
return NULL;
}

View File

@ -0,0 +1,59 @@
/* -*- 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_COMPONENTSDLG_H_
#define _NS_COMPONENTSDLG_H_
#include "XIErrors.h"
#include "nsXInstallerDlg.h"
#include "nsComponentList.h"
class nsComponentsDlg : public nsXInstallerDlg
{
public:
nsComponentsDlg();
~nsComponentsDlg();
/*--------------------------------------------------------------------*
* Navigation
*--------------------------------------------------------------------*/
int Back();
int Next();
/*--------------------------------------------------------------------*
* INI Properties
*--------------------------------------------------------------------*/
int SetMsg0(char *aMsg);
char *GetMsg0();
int SetCompList(nsComponentList *aCompList);
nsComponentList *GetCompList();
private:
char *mMsg0;
nsComponentList *mCompList;
};
#endif /* _NS_COMPONENTSDLG_H_ */

View File

@ -0,0 +1,265 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.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 "nsINIParser.h"
nsINIParser::nsINIParser(char *aFilename)
{
FILE *fd = NULL;
fpos_t eofpos = (fpos_t) NULL;
int rd = 0;
mFileBuf = NULL;
mFileBufSize = 0;
mError = OK;
DUMP("nsINIParser");
/* param check */
if (!aFilename)
{
mError = E_PARAM;
return;
}
/* open the file */
fd = fopen(aFilename, "r");
if (!fd)
goto bail;
/* get file size */
if (fseek(fd, 0, SEEK_END) != 0)
goto bail;
if (fgetpos(fd, &eofpos) != 0)
goto bail;
/* malloc an internal buf the size of the file */
mFileBuf = (char *) malloc(eofpos * sizeof(char));
if (!mFileBuf)
{
mError = E_MEM;
return;
}
mFileBufSize = eofpos;
/* read the file in one swoop */
if (fseek(fd, 0, SEEK_SET) != 0)
goto bail;
rd = fread((void *)mFileBuf, 1, eofpos, fd);
if (!rd)
goto bail;
/* close file */
fclose(fd);
return;
bail:
mError = E_READ;
return;
}
nsINIParser::~nsINIParser()
{
DUMP("~nsINIParser");
}
int
nsINIParser::GetString( char *aSection, char *aKey,
char *aValBuf, int *aIOValBufSize )
{
char *secPtr = NULL;
mError = OK;
DUMP("GetString");
/* param check */
if ( !aSection || !aKey || !aValBuf ||
!aIOValBufSize || (*aIOValBufSize <= 0) )
return E_PARAM;
/* find the section if it exists */
mError = FindSection(aSection, &secPtr);
if (mError != OK)
return mError;
/* find the key if it exists in the valid section we found */
mError = FindKey(secPtr, aKey, aValBuf, aIOValBufSize);
return mError;
}
int
nsINIParser::GetStringAlloc( char *aSection, char *aKey,
char **aOutBuf, int *aOutBufSize )
{
char buf[MAX_VAL_SIZE];
int bufsize = MAX_VAL_SIZE;
mError = OK;
DUMP("GetStringAlloc");
mError = GetString(aSection, aKey, buf, &bufsize);
if (mError != OK)
return mError;
*aOutBuf = (char *) malloc(bufsize + 1);
strncpy(*aOutBuf, buf, bufsize);
strcat(*aOutBuf, "\0");
*aOutBufSize = bufsize + 1;
return mError;
}
int
nsINIParser::GetError()
{
DUMP("GetError");
return mError;
}
int
nsINIParser::FindSection(char *aSection, char **aOutSecPtr)
{
char *currChar = mFileBuf;
char *nextSec = NULL;
char *secClose = NULL;
char *nextNL = NULL;
mError = E_NO_SEC;
DUMP("FindSection");
// param check
if (!aSection || !aOutSecPtr)
{
mError = E_PARAM;
return mError;
}
while (currChar < (mFileBuf + mFileBufSize))
{
// look for first '['
nextSec = NULL;
nextSec = strchr(currChar, '[');
if (!nextSec)
break;
currChar = nextSec + 1;
// extract section name till first ']'
secClose = NULL; nextNL = NULL;
secClose = strchr(currChar, ']');
nextNL = strchr(currChar, NL);
if ((!nextNL) || (nextNL < secClose))
{
currChar = nextNL;
continue;
}
// if section name matches we succeeded
if (strncmp(aSection, currChar, secClose - currChar) == 0)
{
*aOutSecPtr = secClose + 1;
mError = OK;
break;
}
}
return mError;
}
int
nsINIParser::FindKey(char *aSecPtr, char *aKey, char *aVal, int *aIOValSize)
{
char *nextNL = NULL;
char *secEnd = NULL;
char *currLine = aSecPtr;
char *nextEq = NULL;
mError = E_NO_KEY;
DUMP("FindKey");
// param check
if (!aSecPtr || !aKey || !aVal || !aIOValSize || (*aIOValSize <= 0))
{
mError = E_PARAM;
return mError;
}
// determine the section end
secEnd = strchr(aSecPtr, '['); // search for next sec start
if (!secEnd)
{
secEnd = strchr(aSecPtr, '\0'); // else search for file end
if (!secEnd)
{
mError = E_SEC_CORRUPT; // else this data is corrupt
return mError;
}
}
while (currLine < secEnd)
{
nextNL = NULL;
nextNL = strchr(currLine, NL);
if (!nextNL)
nextNL = mFileBuf + mFileBufSize;
// ignore commented lines (starting with ;)
if (currLine == strchr(currLine, ';'))
{
currLine = nextNL + 1;
continue;
}
// extract key before '='
nextEq = NULL;
nextEq = strchr(currLine, '=');
if (!nextEq || nextEq > nextNL)
{
currLine = nextNL + 1;
continue;
}
// if key matches we succeeded
if (strncmp(currLine, aKey, nextEq - currLine) == 0)
{
// extract the value and return
if (*aIOValSize < nextNL - nextEq)
{
mError = E_SMALL_BUF;
*aVal = "\0";
*aIOValSize = 0;
return mError;
}
*aIOValSize = nextNL - nextEq;
strncpy(aVal, (nextEq + 1), *aIOValSize);
mError = OK;
return mError;
}
else
{
currLine = nextNL + 1;
}
}
return mError;
}

View File

@ -0,0 +1,128 @@
/* -*- 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_INIPARSER_H_
#define _NS_INIPARSER_H_
#include <stdio.h>
#include <malloc.h>
#include <string.h>
class nsINIParser
{
public:
/**
* nsINIParser
*
* Construct a new INI parser for the file specified.
*
* @param aFilename path to INI file
*/
nsINIParser(char *aFilename);
~nsINIParser();
/**
* GetString
*
* Gets the value of the specified key in the specified section
* of the INI file represented by this instance. The value is stored
* in the supplied buffer. The buffer size is provided as input and
* the actual bytes used by the value is set in the in/out size param.
*
* @param aSection section name
* @param aKey key name
* @param aValBuf user supplied buffer
* @param aIOValBufSize buf size on input; actual buf used on output
*
* @return mError operation success code
*/
int GetString( char *aSection, char *aKey,
char *aValBuf, int *aIOValBufSize );
/**
* GetStringAlloc
*
* Same as GetString() except the buffer is allocated to the exact
* size of the value. Useful when the buffer is allocated everytime
* rather than reusing the same buffer when calling this function
* multiple times.
*
* @param aSection section name
* @param aKey key name
* @param aOutBuf buffer to be allocated
* @param aOutBufSize size of newly allocated buffer
*
* @return mError operation success code
*/
int GetStringAlloc( char *aSection, char *aKey,
char **aOutBuf, int *aOutBufSize );
/**
* GetError
*
* Exposes the last error on this instance. Useful for checking
* teh state of the object after construtcion since the INI file
* is parsed once at object-allocation time.
*
* @return mError last error on ops on this object
*/
int GetError();
/*--------------------------------------------------------------------*
* Errors
*--------------------------------------------------------------------*/
enum
{
OK = 0,
E_READ = -701,
E_MEM = -702,
E_PARAM = -703,
E_NO_SEC = -704,
E_NO_KEY = -705,
E_SEC_CORRUPT = -706,
E_SMALL_BUF = -707
};
private:
int FindSection(char *aSection, char **aOutSecPtr);
int FindKey(char *aSecPtr, char *aKey, char *aVal, int *aIOValSize);
char *mFileBuf;
int mFileBufSize;
int mError;
};
#define NL '\n'
#define MAX_VAL_SIZE 512
#ifdef DEBUG_druidd
#define DUMP(_msg) printf("%s %d: %s \n", __FILE__, __LINE__, _msg);
#else
#define DUMP(_msg)
#endif
#endif /*_NS_INIPARSER_H_ */

View File

@ -0,0 +1,68 @@
/* -*- 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 "nsInstallDlg.h"
nsInstallDlg::nsInstallDlg() :
mMsg0(NULL)
{
}
nsInstallDlg::~nsInstallDlg()
{
if (mMsg0)
free (mMsg0);
}
int
nsInstallDlg::Back()
{
return OK;
}
int
nsInstallDlg::Next()
{
return OK;
}
int
nsInstallDlg::SetMsg0(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg0 = aMsg;
return OK;
}
char *
nsInstallDlg::GetMsg0()
{
if (mMsg0)
return mMsg0;
return NULL;
}

View File

@ -0,0 +1,53 @@
/* -*- 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_INSTALLDLG_H_
#define _NS_INSTALLDLG_H_
#include "nsXInstallerDlg.h"
#include "XIErrors.h"
class nsInstallDlg : public nsXInstallerDlg
{
public:
nsInstallDlg();
~nsInstallDlg();
/*------------------------------------------------------------------*
* Navigation
*------------------------------------------------------------------*/
int Back();
int Next();
/*------------------------------------------------------------------*
* INI Properties
*------------------------------------------------------------------*/
int SetMsg0(char *aMsg);
char *GetMsg0();
private:
char *mMsg0;
};
#endif /* _NS_INSTALLDLG_H_ */

View File

@ -0,0 +1,114 @@
/* -*- 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 "nsLicenseDlg.h"
nsLicenseDlg::nsLicenseDlg() :
mLicenseFile(NULL),
mMsg0(NULL),
mMsg1(NULL)
{
}
nsLicenseDlg::~nsLicenseDlg()
{
if (mLicenseFile)
free (mLicenseFile);
if (mMsg0)
free (mMsg0);
if (mMsg1)
free (mMsg1);
}
int
nsLicenseDlg::Back()
{
return OK;
}
int
nsLicenseDlg::Next()
{
return OK;
}
int
nsLicenseDlg::SetLicenseFile(char *aLicenseFile)
{
if (!aLicenseFile)
return E_PARAM;
aLicenseFile = mLicenseFile;
return OK;
}
char *
nsLicenseDlg::GetLicenseFile()
{
if (mLicenseFile)
return mLicenseFile;
return NULL;
}
int
nsLicenseDlg::SetMsg0(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg0 = aMsg;
return OK;
}
char *
nsLicenseDlg::GetMsg0()
{
if (mMsg0)
return mMsg0;
return NULL;
}
int
nsLicenseDlg::SetMsg1(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg1 = aMsg;
return OK;
}
char *
nsLicenseDlg::GetMsg1()
{
if (mMsg1)
return mMsg1;
return NULL;
}

View File

@ -0,0 +1,59 @@
/* -*- 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_LICENSEDLG_H_
#define _NS_LICENSEDLG_H_
#include "nsXInstallerDlg.h"
#include "XIErrors.h"
class nsLicenseDlg : public nsXInstallerDlg
{
public:
nsLicenseDlg();
~nsLicenseDlg();
/*-------------------------------------------------------------------*
* Navigation
*-------------------------------------------------------------------*/
int Back();
int Next();
/*-------------------------------------------------------------------*
* INI Properties
*-------------------------------------------------------------------*/
int SetLicenseFile(char *aLicenseFile);
char * GetLicenseFile();
int SetMsg0(char *aMsg);
char * GetMsg0();
int SetMsg1(char *aMsg);
char * GetMsg1();
private:
char *mLicenseFile;
char *mMsg0;
char *mMsg1;
};
#endif /* _NS_LICENSEDLG_H_ */

View File

@ -0,0 +1,139 @@
/* -*- 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 "nsSetupType.h"
nsSetupType::nsSetupType() :
mDescShort(NULL),
mDescLong(NULL),
mComponents(NULL),
mNext(NULL)
{
}
nsSetupType::~nsSetupType()
{
if (mDescShort)
free (mDescShort);
if (mDescLong)
free (mDescLong);
if (mComponents)
delete mComponents;
}
int
nsSetupType::SetDescShort(char *aDescShort)
{
if (!aDescShort)
return E_PARAM;
mDescShort = aDescShort;
return OK;
}
char *
nsSetupType::GetDescShort()
{
if (mDescShort)
return mDescShort;
return NULL;
}
int
nsSetupType::SetDescLong(char *aDescLong)
{
if (!aDescLong)
return E_PARAM;
mDescLong = aDescLong;
return OK;
}
char *
nsSetupType::GetDescLong()
{
if (mDescLong)
return mDescLong;
return NULL;
}
int
nsSetupType::SetComponent(nsComponent *aComponent)
{
if (!aComponent)
return E_PARAM;
if (!mComponents)
mComponents = new nsComponentList();
if (!mComponents)
return E_MEM;
return mComponents->AddComponent(aComponent);
}
int
nsSetupType::UnsetComponent(nsComponent *aComponent)
{
if (!aComponent)
return E_PARAM;
if (!mComponents)
return OK;
return mComponents->RemoveComponent(aComponent);
}
nsComponentList *
nsSetupType::GetComponents()
{
if (mComponents)
return mComponents;
return NULL;
}
int
nsSetupType::SetNext(nsSetupType *aSetupType)
{
if (!aSetupType)
return E_PARAM;
mNext = aSetupType;
return OK;
}
nsSetupType *
nsSetupType::GetNext()
{
if (mNext)
return mNext;
return NULL;
}

View File

@ -0,0 +1,61 @@
/* -*- 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_SETUPTYPE_H_
#define _NS_SETUPTYPE_H_
#include "XILimits.h"
#include "XIErrors.h"
#include "nsComponent.h"
class nsComponentList;
class nsSetupType
{
public:
nsSetupType();
~nsSetupType();
/*--------------------------------------------------------------*
* Accessors/Mutators
*--------------------------------------------------------------*/
int SetDescShort(char *aDescShort);
char * GetDescShort();
int SetDescLong(char *aDescLong);
char * GetDescLong();
int SetComponent(nsComponent *aComponent);
int UnsetComponent(nsComponent *aComponent);
nsComponentList *GetComponents();
int SetNext(nsSetupType *aSetupType);
nsSetupType * GetNext();
private:
char *mDescShort;
char *mDescLong;
nsComponentList *mComponents;
nsSetupType *mNext;
};
#endif /* _NS_SETUPTYPE_H_ */

View File

@ -0,0 +1,103 @@
#include "nsSetupTypeDlg.h"
nsSetupTypeDlg::nsSetupTypeDlg() :
mMsg0(NULL),
mSetupTypeList(NULL)
{
}
nsSetupTypeDlg::~nsSetupTypeDlg()
{
FreeSetupTypeList();
if (mMsg0)
free (mMsg0);
}
int
nsSetupTypeDlg::Back()
{
return OK;
}
int
nsSetupTypeDlg::Next()
{
return OK;
}
int
nsSetupTypeDlg::SetMsg0(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg0 = aMsg;
return OK;
}
char *
nsSetupTypeDlg::GetMsg0()
{
if (mMsg0)
return mMsg0;
return NULL;
}
int
nsSetupTypeDlg::AddSetupType(nsSetupType *aSetupType)
{
if (!aSetupType)
return E_PARAM;
if (!mSetupTypeList)
{
mSetupTypeList = aSetupType;
return OK;
}
nsSetupType *curr = mSetupTypeList;
nsSetupType *next;
while (curr)
{
next = NULL;
next = curr->GetNext();
if (!next)
{
return curr->SetNext(aSetupType);
}
curr = next;
}
return OK;
}
nsSetupType *
nsSetupTypeDlg::GetSetupTypeList()
{
if (mSetupTypeList)
return mSetupTypeList;
return NULL;
}
void
nsSetupTypeDlg::FreeSetupTypeList()
{
nsSetupType *curr = mSetupTypeList;
nsSetupType *prev;
while (curr)
{
prev = curr;
curr = curr->GetNext();
if (prev)
delete prev;
}
}

View File

@ -0,0 +1,59 @@
/* -*- 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_SETUPTYPEDLG_H_
#define _NS_SETUPTYPEDLG_H_
#include "nsXInstallerDlg.h"
#include "nsSetupType.h"
class nsSetupTypeDlg : public nsXInstallerDlg
{
public:
nsSetupTypeDlg();
~nsSetupTypeDlg();
/*---------------------------------------------------------------------*
* Navigation
*---------------------------------------------------------------------*/
int Back();
int Next();
/*---------------------------------------------------------------------*
* INI Properties
*---------------------------------------------------------------------*/
int SetMsg0(char *aMsg);
char *GetMsg0();
int AddSetupType(nsSetupType *aSetupType);
nsSetupType *GetSetupTypeList();
private:
void FreeSetupTypeList();
char *mMsg0;
nsSetupType *mSetupTypeList;
};
#endif /* _NS_SETUPTYPEDLG_H_ */

View File

@ -0,0 +1,137 @@
/* -*- 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 "nsWelcomeDlg.h"
nsWelcomeDlg::nsWelcomeDlg() :
mReadmeFile(NULL),
mMsg0(NULL),
mMsg1(NULL),
mMsg2(NULL)
{
}
nsWelcomeDlg::~nsWelcomeDlg()
{
if (mReadmeFile)
free (mReadmeFile);
if (mMsg0)
free (mMsg0);
if (mMsg1)
free (mMsg1);
if (mMsg2)
free (mMsg2);
}
int
nsWelcomeDlg::Back()
{
return OK;
}
int
nsWelcomeDlg::Next()
{
return OK;
}
int
nsWelcomeDlg::SetReadmeFile(char *aReadmeFile)
{
if (!aReadmeFile)
return E_PARAM;
mReadmeFile = aReadmeFile;
return OK;
}
char *
nsWelcomeDlg::GetReadmeFile()
{
if (mReadmeFile)
return mReadmeFile;
return NULL;
}
int
nsWelcomeDlg::SetMsg0(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg0 = aMsg;
return OK;
}
char *
nsWelcomeDlg::GetMsg0()
{
if (mMsg0)
return mMsg0;
return NULL;
}
int
nsWelcomeDlg::SetMsg1(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg1 = aMsg;
return OK;
}
char *
nsWelcomeDlg::GetMsg1()
{
if (mMsg1)
return mMsg1;
return NULL;
}
int
nsWelcomeDlg::SetMsg2(char *aMsg)
{
if (!aMsg)
return E_PARAM;
mMsg2 = aMsg;
return OK;
}
char *
nsWelcomeDlg::GetMsg2()
{
if (mMsg2)
return mMsg2;
return NULL;
}

View File

@ -0,0 +1,62 @@
/* -*- 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_WELCOMEDLG_H_
#define _NS_WELCOMEDLG_H_
#include "nsXInstallerDlg.h"
#include "XIErrors.h"
class nsWelcomeDlg : public nsXInstallerDlg
{
public:
nsWelcomeDlg();
~nsWelcomeDlg();
/*--------------------------------------------------------------------*
* Navigation
*--------------------------------------------------------------------*/
int Back();
int Next();
/*--------------------------------------------------------------------*
* INI Properties
*--------------------------------------------------------------------*/
int SetReadmeFile(char *aReadmeFile);
char *GetReadmeFile();
int SetMsg0(char *aMsg);
char *GetMsg0();
int SetMsg1(char *aMsg);
char *GetMsg1();
int SetMsg2(char *aMsg);
char *GetMsg2();
private:
char *mReadmeFile;
char *mMsg0;
char *mMsg1;
char *mMsg2;
};
#endif /* _NS_WELCOMEDLG_H_ */

View File

@ -0,0 +1,126 @@
/* -*- 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 "nsXInstaller.h"
#include "nsINIParser.h"
#include "XIErrors.h"
nsXInstaller::nsXInstaller()
{
}
nsXInstaller::~nsXInstaller()
{
}
int
nsXInstaller::ParseConfig()
{
int err = OK;
nsINIParser *parser = new nsINIParser( CONFIG_INI );
char *bufalloc = NULL;
char buf[512];
int bufsize = 0;
if (!parser)
return E_MEM;
err = parser->GetError();
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);
}
return err;
}
int
nsXInstaller::Run()
{
int err = OK;
if ( (err = StartWizard()) != OK)
goto au_revoir;
if ( (err = Download()) != OK)
goto au_revoir;
if ( (err = Extract()) != OK)
goto au_revoir;
if ( (err = Install()) != OK)
goto au_revoir;
au_revoir:
return err;
}
int
nsXInstaller::StartWizard()
{
return OK;
}
int
nsXInstaller::Download()
{
return OK;
}
int
nsXInstaller::Extract()
{
return OK;
}
int
nsXInstaller::Install()
{
return OK;
}
int
main(int argc, char **argv)
{
nsXInstaller *installer = new nsXInstaller();
int err = OK;
if (installer)
{
if ( (err = installer->ParseConfig()) == OK)
err = installer->Run();
}
exit(err);
}

View File

@ -0,0 +1,59 @@
/* -*- 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_XINSTALLER_H_
#define _NS_XINSTALLER_H_
#include <stdio.h>
#include "XIErrors.h"
class nsXInstaller
{
public:
nsXInstaller();
~nsXInstaller();
int ParseConfig();
int Run();
private:
int StartWizard();
int Download();
int Extract();
int Install();
};
int main(int argc, char **argv);
#define CONFIG_INI "config.ini"
#ifdef DEBUG_druidd
#define DUMP(_msg) printf("%s %d: %s \n", __FILE__, __LINE__, _msg);
#else
#define DUMP(_msg)
#endif
#endif /*_NS_XINSTALLER_H_ */

View File

@ -0,0 +1,75 @@
/* -*- 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 "nsXInstallerDlg.h"
nsXInstallerDlg::nsXInstallerDlg() :
mShowDlg(nsXInstallerDlg::SHOW_DLG),
mTitle(NULL)
{
}
nsXInstallerDlg::~nsXInstallerDlg()
{
if (mTitle)
free (mTitle);
}
int
nsXInstallerDlg::SetShowDlg(int aShowDlg)
{
if ( aShowDlg != nsXInstallerDlg::SHOW_DLG &&
aShowDlg != nsXInstallerDlg::SKIP_DLG )
return E_PARAM;
mShowDlg = aShowDlg;
return OK;
}
int
nsXInstallerDlg::GetShowDlg()
{
return mShowDlg;
}
int
nsXInstallerDlg::SetTitle(char *aTitle)
{
if (!aTitle)
return E_PARAM;
mTitle = aTitle;
return OK;
}
char *
nsXInstallerDlg::GetTitle()
{
if (mTitle)
return mTitle;
return NULL;
}

View File

@ -0,0 +1,70 @@
/* -*- 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_XINSTALLERDLG_H_
#define _NS_XINSTALLERDLG_H_
#include <malloc.h>
#include "XIErrors.h"
/**
* nsXInstallerDlg
*
* The interface for all installer dialogs. Helps maintain
* uniform navigation mechanism and UI widgets.
*/
class nsXInstallerDlg
{
public:
nsXInstallerDlg();
virtual ~nsXInstallerDlg();
/*-------------------------------------------------------------------*
* Navigation
*-------------------------------------------------------------------*/
virtual int Back() = 0;
virtual int Next() = 0;
/*-------------------------------------------------------------------*
* INI Properties
*-------------------------------------------------------------------*/
int SetShowDlg(int aShowDlg);
int GetShowDlg();
int SetTitle(char *aTitle);
char *GetTitle();
// TO DO
enum
{
SKIP_DLG = 0,
SHOW_DLG = 1
};
protected:
int mShowDlg;
char *mTitle;
};
#endif /* _NS_INSTALLERDLG_H_ */