1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3
* The contents of this file are subject to the Netscape Public
4
* License Version 1.1 (the "License"); you may not use this file
5
* except in compliance with the License. You may obtain a copy of
6
* the License at http://www.mozilla.org/NPL/
8
* Software distributed under the License is distributed on an "AS
9
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
* implied. See the License for the specific language governing
11
* rights and limitations under the License.
13
* The Original Code is Mozilla Communicator client code,
14
* released March 31, 1998.
16
* The Initial Developer of the Original Code is Netscape Communications
17
* Corporation. Portions created by Netscape are
18
* Copyright (C) 1998 Netscape Communications Corporation. All
22
* Daniel Veditz <dveditz@netscape.com>
23
* Douglas Turner <dougt@netscape.com>
27
#ifndef __NS_INSTALL_H__
28
#define __NS_INSTALL_H__
31
#include "nsISupports.h"
38
#include "nsVoidArray.h"
39
#include "nsHashtable.h"
41
#include "nsILocalFile.h"
43
#include "nsSoftwareUpdate.h"
45
#include "nsInstallObject.h"
46
#include "nsInstallVersion.h"
47
#include "nsInstallFolder.h"
49
#include "nsIXPINotifier.h"
50
#include "nsPIXPIProxy.h"
52
#include "nsIStringBundle.h"
53
#include "nsILocale.h"
54
#include "nsIEventQueueService.h"
55
#include "nsIServiceManager.h"
56
#include "nsIComponentManager.h"
57
#include "nsIEnumerator.h"
58
#include "nsIZipReader.h"
59
#include "nsIChromeRegistry.h"
60
#include "nsIExtensionManager.h"
61
#include "nsIPrincipal.h"
63
#define XPINSTALL_BUNDLE_URL "chrome://global/locale/xpinstall/xpinstall.properties"
65
//file and directory name length maximums
67
#define MAX_FILENAME 31
68
#elif defined (XP_WIN) || defined(XP_OS2)
69
#define MAX_FILENAME 128
71
#define MAX_FILENAME 1024
78
nsInstallInfo( PRUint32 aInstallType,
80
const PRUnichar* aURL,
81
const PRUnichar* aArgs,
82
nsIPrincipal* mPrincipal,
84
nsIXPIListener* aListener,
85
nsIXULChromeRegistry* aChromeReg,
86
nsIExtensionManager* aExtensionManager);
88
virtual ~nsInstallInfo();
90
nsIFile* GetFile() { return mFile.get(); }
91
const PRUnichar* GetURL() { return mURL.get(); }
92
const PRUnichar* GetArguments() { return mArgs.get(); }
93
PRUint32 GetFlags() { return mFlags; }
94
PRUint32 GetType() { return mType; }
95
nsIXPIListener* GetListener() { return mListener.get(); }
96
nsIXULChromeRegistry* GetChromeRegistry() { return mChromeRegistry.get(); }
97
nsIExtensionManager* GetExtensionManager(){ return mExtensionManager.get(); }
99
nsCOMPtr<nsIPrincipal> mPrincipal;
110
nsCOMPtr<nsIFile> mFile;
111
nsCOMPtr<nsIXPIListener> mListener;
112
nsCOMPtr<nsIXULChromeRegistry> mChromeRegistry;
113
nsCOMPtr<nsIExtensionManager> mExtensionManager;
116
#if defined(XP_WIN) || defined(XP_OS2)
120
#elif defined XP_BEOS
126
// not using 0x1 in this bitfield because it causes problems with legacy code
127
#define DO_NOT_UNINSTALL 0x2
128
#define WIN_SHARED_FILE 0x4
129
#define WIN_SYSTEM_FILE 0x8
133
friend class nsWinReg;
134
friend class nsWinProfile;
140
BAD_PACKAGE_NAME = -200,
141
UNEXPECTED_ERROR = -201,
142
ACCESS_DENIED = -202,
143
EXECUTION_ERROR = -203,
144
NO_INSTALL_SCRIPT = -204,
145
NO_CERTIFICATE = -205,
146
NO_MATCHING_CERTIFICATE = -206,
147
CANT_READ_ARCHIVE = -207,
148
INVALID_ARGUMENTS = -208,
149
ILLEGAL_RELATIVE_PATH = -209,
150
USER_CANCELLED = -210,
151
INSTALL_NOT_STARTED = -211,
152
SILENT_MODE_DENIED = -212,
153
NO_SUCH_COMPONENT = -213,
154
DOES_NOT_EXIST = -214,
157
NETWORK_FILE_IS_IN_USE = -217,
158
APPLE_SINGLE_ERR = -218,
159
INVALID_PATH_ERR = -219,
160
PATCH_BAD_DIFF = -220,
161
PATCH_BAD_CHECKSUM_TARGET = -221,
162
PATCH_BAD_CHECKSUM_RESULT = -222,
163
UNINSTALL_FAILED = -223,
164
PACKAGE_FOLDER_NOT_SET = -224,
165
EXTRACTION_FAILED = -225,
166
FILENAME_ALREADY_USED = -226,
167
INSTALL_CANCELLED = -227,
168
DOWNLOAD_ERROR = -228,
171
ALREADY_EXISTS = -230,
173
SOURCE_DOES_NOT_EXIST = -232,
174
SOURCE_IS_DIRECTORY = -233,
175
SOURCE_IS_FILE = -234,
176
INSUFFICIENT_DISK_SPACE = -235,
177
FILENAME_TOO_LONG = -236,
179
UNABLE_TO_LOCATE_LIB_FUNCTION = -237,
180
UNABLE_TO_LOAD_LIBRARY = -238,
182
CHROME_REGISTRY_ERROR = -239,
184
MALFORMED_INSTALL = -240,
186
KEY_ACCESS_DENIED = -241,
187
KEY_DOES_NOT_EXIST = -242,
188
VALUE_DOES_NOT_EXIST = -243,
190
INVALID_SIGNATURE = -260,
192
OUT_OF_MEMORY = -299,
194
GESTALT_UNKNOWN_ERR = -5550,
195
GESTALT_INVALID_ARGUMENT = -5551,
202
nsInstall(nsIZipReader * theJARFile);
203
virtual ~nsInstall();
205
PRInt32 SetScriptObject(void* aScriptObject);
207
PRInt32 SaveWinRegPrototype(void* aScriptObject);
208
PRInt32 SaveWinProfilePrototype(void* aScriptObject);
210
JSObject* RetrieveWinRegPrototype(void);
211
JSObject* RetrieveWinProfilePrototype(void);
213
PRInt32 AbortInstall(PRInt32 aErrorNumber);
215
PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aSubdir, PRInt32 aMode, PRInt32* aReturn);
216
PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aSubdir, PRInt32* aReturn);
217
PRInt32 AddDirectory(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aSubdir, PRInt32* aReturn);
218
PRInt32 AddDirectory(const nsString& aJarSource, PRInt32* aReturn);
220
PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aTargetName, PRInt32 aMode, PRInt32* aReturn);
221
PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aTargetName, PRInt32* aReturn);
222
PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aTargetName, PRInt32* aReturn);
223
PRInt32 AddSubcomponent(const nsString& aJarSource, PRInt32* aReturn);
225
PRInt32 DiskSpaceAvailable(const nsString& aFolder, PRInt64* aReturn);
226
PRInt32 Execute(const nsString& aJarSource, const nsString& aArgs, PRBool aBlocking, PRInt32* aReturn);
227
PRInt32 FinalizeInstall(PRInt32* aReturn);
228
PRInt32 Gestalt(const nsString& aSelector, PRInt32* aReturn);
230
PRInt32 GetComponentFolder(const nsString& aComponentName, const nsString& aSubdirectory, nsInstallFolder** aFolder);
231
PRInt32 GetComponentFolder(const nsString& aComponentName, nsInstallFolder** aFolder);
233
PRInt32 GetFolder(nsInstallFolder& aTargetFolder, const nsString& aSubdirectory, nsInstallFolder** aFolder);
234
PRInt32 GetFolder(const nsString& aTargetFolder, const nsString& aSubdirectory, nsInstallFolder** aFolder);
235
PRInt32 GetFolder(const nsString& aTargetFolder, nsInstallFolder** aFolder);
237
PRInt32 GetLastError(PRInt32* aReturn);
238
PRInt32 GetWinProfile(const nsString& aFolder, const nsString& aFile, JSContext* jscontext, JSClass* WinProfileClass, jsval* aReturn);
239
PRInt32 GetWinRegistry(JSContext* jscontext, JSClass* WinRegClass, jsval* aReturn);
240
PRInt32 LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aReturn);
241
PRInt32 Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aTargetName, PRInt32* aReturn);
242
PRInt32 Patch(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aTargetName, PRInt32* aReturn);
243
PRInt32 RegisterChrome(nsIFile* chrome, PRUint32 chromeType, const char* path);
244
PRInt32 RefreshPlugins(PRBool aReloadPages);
245
PRInt32 ResetError(PRInt32 aError);
246
PRInt32 SetPackageFolder(nsInstallFolder& aFolder);
247
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32* aReturn);
248
PRInt32 Uninstall(const nsString& aPackageName, PRInt32* aReturn);
250
PRInt32 FileOpDirCreate(nsInstallFolder& aTarget, PRInt32* aReturn);
251
PRInt32 FileOpDirGetParent(nsInstallFolder& aTarget, nsInstallFolder** theParentFolder);
252
PRInt32 FileOpDirRemove(nsInstallFolder& aTarget, PRInt32 aFlags, PRInt32* aReturn);
253
PRInt32 FileOpDirRename(nsInstallFolder& aSrc, nsString& aTarget, PRInt32* aReturn);
254
PRInt32 FileOpFileCopy(nsInstallFolder& aSrc, nsInstallFolder& aTarget, PRInt32* aReturn);
255
PRInt32 FileOpFileDelete(nsInstallFolder& aTarget, PRInt32 aFlags, PRInt32* aReturn);
256
PRInt32 FileOpFileExists(nsInstallFolder& aTarget, PRBool* aReturn);
257
PRInt32 FileOpFileExecute(nsInstallFolder& aTarget, nsString& aParams, PRBool aBlocking, PRInt32* aReturn);
258
PRInt32 FileOpFileGetNativeVersion(nsInstallFolder& aTarget, nsString* aReturn);
259
PRInt32 FileOpFileGetDiskSpaceAvailable(nsInstallFolder& aTarget, PRInt64* aReturn);
260
PRInt32 FileOpFileGetModDate(nsInstallFolder& aTarget, double* aReturn);
261
PRInt32 FileOpFileGetSize(nsInstallFolder& aTarget, PRInt64* aReturn);
262
PRInt32 FileOpFileIsDirectory(nsInstallFolder& aTarget, PRBool* aReturn);
263
PRInt32 FileOpFileIsWritable(nsInstallFolder& aTarget, PRBool* aReturn);
264
PRInt32 FileOpFileIsFile(nsInstallFolder& aTarget, PRBool* aReturn);
265
PRInt32 FileOpFileModDateChanged(nsInstallFolder& aTarget, double aOldStamp, PRBool* aReturn);
266
PRInt32 FileOpFileMove(nsInstallFolder& aSrc, nsInstallFolder& aTarget, PRInt32* aReturn);
267
PRInt32 FileOpFileRename(nsInstallFolder& aSrc, nsString& aTarget, PRInt32* aReturn);
268
PRInt32 FileOpFileWindowsGetShortName(nsInstallFolder& aTarget, nsString& aShortPathName);
269
PRInt32 FileOpFileWindowsShortcut(nsIFile* aTarget, nsIFile* aShortcutPath, nsString& aDescription, nsIFile* aWorkingPath, nsString& aParams, nsIFile* aIcon, PRInt32 aIconId, PRInt32* aReturn);
270
PRInt32 FileOpFileMacAlias(nsIFile *aSourceFile, nsIFile *aAliasFile, PRInt32* aReturn);
271
PRInt32 FileOpFileUnixLink(nsInstallFolder& aTarget, PRInt32 aFlags, PRInt32* aReturn);
272
PRInt32 FileOpWinRegisterServer(nsInstallFolder& aTarget, PRInt32* aReturn);
274
void LogComment(const nsAString& aComment);
276
PRInt32 ExtractFileFromJar(const nsString& aJarfile, nsIFile* aSuggestedName, nsIFile** aRealName);
277
char* GetResourcedString(const nsAString& aResName);
278
void AddPatch(nsHashKey *aKey, nsIFile* fileName);
279
void GetPatch(nsHashKey *aKey, nsIFile** fileName);
281
nsIFile* GetJarFileLocation() { return mJarFileLocation; }
282
void SetJarFileLocation(nsIFile* aFile);
284
void GetInstallArguments(nsString& args);
285
void SetInstallArguments(const nsString& args);
287
void GetInstallURL(nsString& url);
288
void SetInstallURL(const nsString& url);
290
PRUint32 GetInstallFlags() { return mInstallFlags; }
291
void SetInstallFlags(PRUint32 aFlags) { mInstallFlags = aFlags; }
293
PRInt32 GetInstallPlatform(nsCString& aPlatform);
295
nsIXULChromeRegistry* GetChromeRegistry() { return mChromeRegistry; }
296
void SetChromeRegistry(nsIXULChromeRegistry* reg)
297
{ mChromeRegistry = reg; }
299
PRUint32 GetFinalStatus() { return mFinalStatus; }
300
PRBool InInstallTransaction(void) { return mInstalledFiles != nsnull; }
302
PRInt32 Alert(nsString& string);
303
PRInt32 Confirm(nsString& string, PRBool* aReturn);
304
void InternalAbort(PRInt32 errcode);
306
PRInt32 ScheduleForInstall(nsInstallObject* ob);
308
PRInt32 SaveError(PRInt32 errcode);
311
JSObject* mScriptObject;
313
JSObject* mWinRegObject;
314
JSObject* mWinProfileObject;
317
nsCOMPtr<nsIFile> mJarFileLocation;
318
nsIZipReader* mJarFileData;
320
nsString mInstallArguments;
321
nsString mInstallURL;
322
PRUint32 mInstallFlags;
323
nsCString mInstallPlatform;
324
nsIXULChromeRegistry* mChromeRegistry; // we don't own it, it outlives us
325
nsInstallFolder* mPackageFolder;
327
PRBool mUserCancelled;
328
PRUint32 mFinalStatus;
330
PRBool mUninstallPackage;
331
PRBool mRegisterPackage;
332
PRBool mStartInstallCompleted;
334
nsString mRegistryPackageName; /* Name of the package we are installing */
335
nsString mUIName; /* User-readable package name */
336
nsInstallVersion* mVersionInfo; /* Component version info */
338
nsVoidArray* mInstalledFiles;
339
//nsCOMPtr<nsISupportsArray> mInstalledFiles;
340
nsHashtable* mPatchList;
342
nsCOMPtr<nsIXPIListener> mListener;
343
nsCOMPtr<nsPIXPIProxy> mUIThreadProxy;
345
nsCOMPtr<nsIStringBundle> mStringBundle;
349
void ParseFlags(int flags);
350
PRInt32 SanityCheck(void);
351
void GetTime(nsString &aString);
353
nsPIXPIProxy* GetUIThreadProxy();
355
PRInt32 GetQualifiedRegName(const nsString& name, nsString& qualifiedRegName );
356
PRInt32 GetQualifiedPackageName( const nsString& name, nsString& qualifiedName );
358
void CurrentUserNode(nsString& userRegNode);
359
PRBool BadRegName(const nsString& regName);
363
PRInt32 ExtractDirEntries(const nsString& directory, nsVoidArray *paths);
365
static void DeleteVector(nsVoidArray* vector);
368
nsresult MakeUnique(nsILocalFile* file);