~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/xpinstall/src/nsInstall.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
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/
 
7
 *
 
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.
 
12
 *
 
13
 * The Original Code is Mozilla Communicator client code,
 
14
 * released March 31, 1998.
 
15
 *
 
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
 
19
 * Rights Reserved.
 
20
 *
 
21
 * Contributor(s):
 
22
 *     Daniel Veditz <dveditz@netscape.com>
 
23
 *     Douglas Turner <dougt@netscape.com>
 
24
 */
 
25
 
 
26
 
 
27
#ifndef __NS_INSTALL_H__
 
28
#define __NS_INSTALL_H__
 
29
 
 
30
#include "nscore.h"
 
31
#include "nsISupports.h"
 
32
 
 
33
#include "jsapi.h"
 
34
 
 
35
#include "plevent.h"
 
36
 
 
37
#include "nsString.h"
 
38
#include "nsVoidArray.h"
 
39
#include "nsHashtable.h"
 
40
#include "nsCOMPtr.h"
 
41
#include "nsILocalFile.h"
 
42
 
 
43
#include "nsSoftwareUpdate.h"
 
44
 
 
45
#include "nsInstallObject.h"
 
46
#include "nsInstallVersion.h"
 
47
#include "nsInstallFolder.h"
 
48
 
 
49
#include "nsIXPINotifier.h"
 
50
#include "nsPIXPIProxy.h"
 
51
 
 
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"
 
62
 
 
63
#define XPINSTALL_BUNDLE_URL "chrome://global/locale/xpinstall/xpinstall.properties"
 
64
 
 
65
//file and directory name length maximums
 
66
#ifdef XP_MAC
 
67
#define MAX_FILENAME 31
 
68
#elif defined (XP_WIN) || defined(XP_OS2)
 
69
#define MAX_FILENAME 128
 
70
#else
 
71
#define MAX_FILENAME 1024
 
72
#endif
 
73
 
 
74
class nsInstallInfo
 
75
{
 
76
  public:
 
77
 
 
78
    nsInstallInfo( PRUint32         aInstallType,
 
79
                   nsIFile*         aFile,
 
80
                   const PRUnichar* aURL,
 
81
                   const PRUnichar* aArgs,
 
82
                   nsIPrincipal*    mPrincipal,
 
83
                   PRUint32         aFlags,
 
84
                   nsIXPIListener*  aListener,
 
85
                   nsIXULChromeRegistry*   aChromeReg,
 
86
                   nsIExtensionManager*    aExtensionManager);
 
87
 
 
88
    virtual ~nsInstallInfo();
 
89
 
 
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(); }
 
98
 
 
99
    nsCOMPtr<nsIPrincipal>      mPrincipal;
 
100
 
 
101
  private:
 
102
 
 
103
    nsresult  mError;
 
104
 
 
105
    PRUint32   mType;
 
106
    PRUint32   mFlags;
 
107
    nsString   mURL;
 
108
    nsString   mArgs;
 
109
 
 
110
    nsCOMPtr<nsIFile>           mFile;
 
111
    nsCOMPtr<nsIXPIListener>    mListener;
 
112
    nsCOMPtr<nsIXULChromeRegistry> mChromeRegistry;
 
113
    nsCOMPtr<nsIExtensionManager> mExtensionManager;
 
114
};
 
115
 
 
116
#if defined(XP_WIN) || defined(XP_OS2)
 
117
#define FILESEP '\\'
 
118
#elif defined XP_MAC
 
119
#define FILESEP ':'
 
120
#elif defined XP_BEOS
 
121
#define FILESEP '/'
 
122
#else
 
123
#define FILESEP '/'
 
124
#endif
 
125
 
 
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
 
130
 
 
131
class nsInstall
 
132
{
 
133
    friend class nsWinReg;
 
134
    friend class nsWinProfile;
 
135
 
 
136
    public:
 
137
 
 
138
        enum
 
139
        {
 
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,
 
155
            READ_ONLY                   = -215,
 
156
            IS_DIRECTORY                = -216,
 
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,
 
169
            SCRIPT_ERROR                = -229,
 
170
 
 
171
            ALREADY_EXISTS              = -230,
 
172
            IS_FILE                     = -231,
 
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,
 
178
 
 
179
            UNABLE_TO_LOCATE_LIB_FUNCTION = -237,
 
180
            UNABLE_TO_LOAD_LIBRARY        = -238,
 
181
 
 
182
            CHROME_REGISTRY_ERROR       = -239,
 
183
 
 
184
            MALFORMED_INSTALL           = -240,
 
185
 
 
186
            KEY_ACCESS_DENIED           = -241,
 
187
            KEY_DOES_NOT_EXIST          = -242,
 
188
            VALUE_DOES_NOT_EXIST        = -243,
 
189
 
 
190
            INVALID_SIGNATURE           = -260,
 
191
 
 
192
            OUT_OF_MEMORY               = -299,
 
193
 
 
194
            GESTALT_UNKNOWN_ERR         = -5550,
 
195
            GESTALT_INVALID_ARGUMENT    = -5551,
 
196
 
 
197
            SUCCESS                     = 0,
 
198
            REBOOT_NEEDED               = 999
 
199
        };
 
200
 
 
201
 
 
202
        nsInstall(nsIZipReader * theJARFile);
 
203
        virtual ~nsInstall();
 
204
 
 
205
        PRInt32    SetScriptObject(void* aScriptObject);
 
206
 
 
207
        PRInt32    SaveWinRegPrototype(void* aScriptObject);
 
208
        PRInt32    SaveWinProfilePrototype(void* aScriptObject);
 
209
 
 
210
        JSObject*  RetrieveWinRegPrototype(void);
 
211
        JSObject*  RetrieveWinProfilePrototype(void);
 
212
 
 
213
        PRInt32    AbortInstall(PRInt32 aErrorNumber);
 
214
 
 
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);
 
219
 
 
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);
 
224
 
 
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);
 
229
 
 
230
        PRInt32    GetComponentFolder(const nsString& aComponentName, const nsString& aSubdirectory, nsInstallFolder** aFolder);
 
231
        PRInt32    GetComponentFolder(const nsString& aComponentName, nsInstallFolder** aFolder);
 
232
 
 
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);
 
236
 
 
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);
 
249
 
 
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);
 
273
 
 
274
        void       LogComment(const nsAString& aComment);
 
275
 
 
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);
 
280
 
 
281
        nsIFile*   GetJarFileLocation() { return mJarFileLocation; }
 
282
        void       SetJarFileLocation(nsIFile* aFile);
 
283
 
 
284
        void       GetInstallArguments(nsString& args);
 
285
        void       SetInstallArguments(const nsString& args);
 
286
 
 
287
        void       GetInstallURL(nsString& url);
 
288
        void       SetInstallURL(const nsString& url);
 
289
 
 
290
        PRUint32   GetInstallFlags()  { return mInstallFlags; }
 
291
        void       SetInstallFlags(PRUint32 aFlags) { mInstallFlags = aFlags; }
 
292
 
 
293
        PRInt32    GetInstallPlatform(nsCString& aPlatform);
 
294
 
 
295
        nsIXULChromeRegistry*  GetChromeRegistry() { return mChromeRegistry; }
 
296
        void                SetChromeRegistry(nsIXULChromeRegistry* reg)
 
297
                                { mChromeRegistry = reg; }
 
298
 
 
299
        PRUint32   GetFinalStatus() { return mFinalStatus; }
 
300
        PRBool     InInstallTransaction(void) { return mInstalledFiles != nsnull; }
 
301
 
 
302
        PRInt32    Alert(nsString& string);
 
303
        PRInt32    Confirm(nsString& string, PRBool* aReturn);
 
304
        void       InternalAbort(PRInt32 errcode);
 
305
 
 
306
        PRInt32    ScheduleForInstall(nsInstallObject* ob);
 
307
 
 
308
        PRInt32    SaveError(PRInt32 errcode);
 
309
 
 
310
    private:
 
311
        JSObject*           mScriptObject;
 
312
 
 
313
        JSObject*           mWinRegObject;
 
314
        JSObject*           mWinProfileObject;
 
315
 
 
316
 
 
317
        nsCOMPtr<nsIFile>   mJarFileLocation;
 
318
        nsIZipReader*       mJarFileData;
 
319
 
 
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;
 
326
 
 
327
        PRBool              mUserCancelled;
 
328
        PRUint32            mFinalStatus;
 
329
 
 
330
        PRBool              mUninstallPackage;
 
331
        PRBool              mRegisterPackage;
 
332
        PRBool              mStartInstallCompleted;
 
333
 
 
334
        nsString            mRegistryPackageName;   /* Name of the package we are installing */
 
335
        nsString            mUIName;                /* User-readable package name */
 
336
        nsInstallVersion*   mVersionInfo;           /* Component version info */
 
337
 
 
338
        nsVoidArray*        mInstalledFiles;
 
339
        //nsCOMPtr<nsISupportsArray>   mInstalledFiles;
 
340
        nsHashtable*        mPatchList;
 
341
 
 
342
        nsCOMPtr<nsIXPIListener>    mListener;
 
343
        nsCOMPtr<nsPIXPIProxy>      mUIThreadProxy;
 
344
 
 
345
        nsCOMPtr<nsIStringBundle>   mStringBundle;
 
346
 
 
347
        PRInt32             mLastError;
 
348
 
 
349
        void        ParseFlags(int flags);
 
350
        PRInt32     SanityCheck(void);
 
351
        void        GetTime(nsString &aString);
 
352
 
 
353
        nsPIXPIProxy* GetUIThreadProxy();
 
354
 
 
355
        PRInt32     GetQualifiedRegName(const nsString& name, nsString& qualifiedRegName );
 
356
        PRInt32     GetQualifiedPackageName( const nsString& name, nsString& qualifiedName );
 
357
 
 
358
        void        CurrentUserNode(nsString& userRegNode);
 
359
        PRBool      BadRegName(const nsString& regName);
 
360
 
 
361
        void        CleanUp();
 
362
 
 
363
        PRInt32     ExtractDirEntries(const nsString& directory, nsVoidArray *paths);
 
364
 
 
365
        static void DeleteVector(nsVoidArray* vector);
 
366
};
 
367
 
 
368
nsresult MakeUnique(nsILocalFile* file);
 
369
 
 
370
#endif