2000-03-17 07:35:06 +00:00
|
|
|
/* -*- 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_XIENGINE_H_
|
|
|
|
#define _NS_XIENGINE_H_
|
|
|
|
|
|
|
|
#include "XIDefines.h"
|
|
|
|
#include "nsXInstaller.h"
|
|
|
|
#include "nsComponent.h"
|
|
|
|
#include "nsComponentList.h"
|
|
|
|
#include "nsInstallDlg.h"
|
2000-08-19 18:50:10 +00:00
|
|
|
#include "nsZipExtractor.h"
|
2000-03-17 07:35:06 +00:00
|
|
|
|
|
|
|
#include "xpistub.h"
|
|
|
|
|
2001-08-18 01:15:59 +00:00
|
|
|
#define STANDALONE 1
|
|
|
|
#include "zipfile.h"
|
|
|
|
#include <ctype.h>
|
|
|
|
|
2000-03-17 07:35:06 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------*
|
|
|
|
* XPI Stub Glue
|
|
|
|
*------------------------------------------------------------------------*/
|
|
|
|
typedef nsresult (*pfnXPI_Init)
|
2000-07-10 23:15:46 +00:00
|
|
|
(const char *aProgramDir, const char *aLogName,
|
|
|
|
pfnXPIProgress progressCB);
|
2000-03-17 07:35:06 +00:00
|
|
|
typedef nsresult (*pfnXPI_Install)
|
|
|
|
(const char *file, const char *args, long flags);
|
|
|
|
typedef void (*pfnXPI_Exit)();
|
|
|
|
|
|
|
|
typedef struct _xpistub_t
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
void *handle;
|
|
|
|
pfnXPI_Init fn_init;
|
|
|
|
pfnXPI_Install fn_install;
|
|
|
|
pfnXPI_Exit fn_exit;
|
|
|
|
} xpistub_t;
|
|
|
|
|
2001-08-18 01:15:59 +00:00
|
|
|
#define TYPE_UNDEF 0
|
|
|
|
#define TYPE_PROXY 1
|
|
|
|
#define TYPE_HTTP 2
|
|
|
|
#define TYPE_FTP 3
|
|
|
|
|
|
|
|
typedef struct _conn
|
|
|
|
{
|
|
|
|
unsigned char type; // TYPE_UNDEF, etc.
|
|
|
|
char *URL; // URL this connection is for
|
|
|
|
void *conn; // pointer to open connection
|
|
|
|
} CONN;
|
2000-03-17 07:35:06 +00:00
|
|
|
|
|
|
|
/*------------------------------------------------------------------------*
|
|
|
|
* nsXIEngine
|
|
|
|
*------------------------------------------------------------------------*/
|
|
|
|
class nsXIEngine
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsXIEngine();
|
|
|
|
~nsXIEngine();
|
|
|
|
|
|
|
|
int Download(int aCustom, nsComponentList *aComps);
|
|
|
|
int Extract(nsComponent *aXPIEngine);
|
|
|
|
int Install(int aCustom, nsComponentList *aComps, char *aDestination);
|
2001-05-03 02:17:27 +00:00
|
|
|
int DeleteXPIs(int aCustom, nsComponentList *aComps);
|
2000-03-17 07:35:06 +00:00
|
|
|
|
2000-04-05 05:16:05 +00:00
|
|
|
static void ProgressCallback(const char* aMsg, PRInt32 aVal, PRInt32 aMax);
|
2000-07-24 07:08:35 +00:00
|
|
|
static int ExistAllXPIs(int aCustom, nsComponentList *aComps, int *aTotal);
|
2000-03-17 07:35:06 +00:00
|
|
|
|
2001-05-03 02:17:27 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
OK = 0,
|
|
|
|
E_PARAM = -1201,
|
|
|
|
E_MEM = -1202,
|
|
|
|
E_OPEN_MKR = -1203,
|
|
|
|
E_WRITE_MKR = -1204,
|
|
|
|
E_READ_MKR = -1205,
|
|
|
|
E_FIND_COMP = -1206,
|
|
|
|
E_STAT = -1207
|
|
|
|
};
|
|
|
|
|
2000-03-17 07:35:06 +00:00
|
|
|
private:
|
|
|
|
int MakeUniqueTmpDir();
|
|
|
|
int ParseURL(char *aURL, char **aHost, char **aDir);
|
|
|
|
int LoadXPIStub(xpistub_t *aStub, char *aDestionation);
|
|
|
|
int InstallXPI(nsComponent *aComp, xpistub_t *aStub);
|
|
|
|
int UnloadXPIStub(xpistub_t *aStub);
|
2001-05-03 02:17:27 +00:00
|
|
|
int GetFileSize(char *aPath);
|
|
|
|
int SetDLMarker(char *aCompName);
|
|
|
|
int GetDLMarkedComp(nsComponentList *aComps, int aCustom,
|
|
|
|
nsComponent **aOutComp, int *aOutCompNum);
|
|
|
|
int DelDLMarker();
|
|
|
|
int TotalToDownload(int aCustom, nsComponentList *aComps);
|
2001-08-18 01:15:59 +00:00
|
|
|
PRBool CRCCheckDownloadedArchives(char *dlPath, short dlPathLen,
|
|
|
|
nsComponent *currComp, int count);
|
|
|
|
PRBool IsArchiveFile(char *path);
|
|
|
|
int VerifyArchive(char *szArchive);
|
|
|
|
PRBool CheckConn( char *URL, int type, CONN *myConn, PRBool force );
|
2000-04-05 05:16:05 +00:00
|
|
|
char *mTmp;
|
2000-07-24 07:08:35 +00:00
|
|
|
int mTotalComps;
|
|
|
|
char *mOriginalDir;
|
2000-03-17 07:35:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _NS_XIENGINE_H_ */
|