added WinProfile object to the Install object

This commit is contained in:
ssu%netscape.com 1999-05-17 21:58:52 +00:00
parent 6d5d2a45b2
commit 3ed1dc53f0
13 changed files with 237 additions and 272 deletions

View File

@ -96,6 +96,9 @@ OBJS = \
.\$(OBJDIR)\nsJSWinReg.obj \ .\$(OBJDIR)\nsJSWinReg.obj \
.\$(OBJDIR)\nsWinRegItem.obj \ .\$(OBJDIR)\nsWinRegItem.obj \
.\$(OBJDIR)\nsWinRegValue.obj \ .\$(OBJDIR)\nsWinRegValue.obj \
.\$(OBJDIR)\nsWinProfile.obj \
.\$(OBJDIR)\nsJSWinProfile.obj \
.\$(OBJDIR)\nsWinProfileItem.obj \
$(NULL) $(NULL)
include <$(DEPTH)\config\rules.mak> include <$(DEPTH)\config\rules.mak>

View File

@ -59,6 +59,7 @@
#ifdef XP_WIN #ifdef XP_WIN
#include "nsWinReg.h" #include "nsWinReg.h"
#include "nsWinProfile.h"
#endif #endif
#ifdef XP_PC #ifdef XP_PC
@ -2278,9 +2279,24 @@ nsInstall::GetLastError(PRInt32* aReturn)
} }
PRInt32 PRInt32
nsInstall::GetWinProfile(const nsString& aFolder, const nsString& aFile, PRInt32* aReturn) nsInstall::GetWinProfile(JSContext* jscontext, JSClass* WinProfileClass, const nsString& aFolder, const nsString& aFile, jsval* aReturn)
{ {
#ifdef XP_WIN #ifdef XP_WIN
JSObject* winProfileObject;
nsWinProfile* nativeWinProfileObject = new nsWinProfile(this, aFolder, aFile);
JSObject* winProfilePrototype = this->RetrieveWinProfilePrototype();
winProfileObject = JS_NewObject(jscontext, WinProfileClass, winProfilePrototype, NULL);
if(winProfileObject == NULL)
{
return PR_FALSE;
}
JS_SetPrivate(jscontext, winProfileObject, nativeWinProfileObject);
*aReturn = OBJECT_TO_JSVAL(winProfileObject);
#else
*aReturn = JSVAL_NULL;
#endif /* XP_WIN */ #endif /* XP_WIN */
return NS_OK; return NS_OK;

View File

@ -85,6 +85,7 @@ class nsInstallInfo
class nsInstall class nsInstall
{ {
friend class nsWinReg; friend class nsWinReg;
friend class nsWinProfile;
public: public:
@ -171,7 +172,7 @@ class nsInstall
PRInt32 GetFolder(const nsString& aTargetFolder, const nsString& aSubdirectory, nsString** aFolder); PRInt32 GetFolder(const nsString& aTargetFolder, const nsString& aSubdirectory, nsString** aFolder);
PRInt32 GetFolder(const nsString& aTargetFolder, nsString** aFolder); PRInt32 GetFolder(const nsString& aTargetFolder, nsString** aFolder);
PRInt32 GetLastError(PRInt32* aReturn); PRInt32 GetLastError(PRInt32* aReturn);
PRInt32 GetWinProfile(const nsString& aFolder, const nsString& aFile, PRInt32* aReturn); PRInt32 GetWinProfile(JSContext* jscontext, JSClass* WinProfileClass, const nsString& aFolder, const nsString& aFile, jsval* aReturn);
PRInt32 GetWinRegistry(JSContext* jscontext, JSClass* WinRegClass, jsval* aReturn); PRInt32 GetWinRegistry(JSContext* jscontext, JSClass* WinRegClass, jsval* aReturn);
PRInt32 Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn); PRInt32 Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);
PRInt32 Patch(const nsString& aRegName, nsIDOMInstallVersion* aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn); PRInt32 Patch(const nsString& aRegName, nsIDOMInstallVersion* aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);

View File

@ -29,10 +29,8 @@
#include "stdio.h" #include "stdio.h"
#ifdef XP_WIN #ifdef XP_WIN
#include "nsWinReg.h"
#include "nsJSWinReg.h"
extern JSClass WinRegClass; extern JSClass WinRegClass;
extern JSClass WinProfileClass;
#endif #endif
// //
@ -48,23 +46,6 @@ enum Install_slots
INSTALL_ARGUMENTS = -6 INSTALL_ARGUMENTS = -6
}; };
/***********************************************************************/
//
// class for WinProfile
//
// JSClass WinProfileClass = {
// "WinProfile",
// JSCLASS_HAS_PRIVATE,
// JS_PropertyStub,
// JS_PropertyStub,
// JS_PropertyStub,
// JS_PropertyStub,
// JS_EnumerateStub,
// JS_ResolveStub,
// JS_ConvertStub,
// WinProfileCleanup
//};
/***********************************************************************/ /***********************************************************************/
// //
// Install Properties Getter // Install Properties Getter
@ -174,12 +155,6 @@ static void PR_CALLBACK FinalizeInstall(JSContext *cx, JSObject *obj)
delete nativeThis; delete nativeThis;
} }
// static void PR_CALLBACK WinProfileCleanup(JSContext *cx, JSObject *obj)
// {
// nsWinProfile *nativeThis = (nsWinProfile*)JS_GetPrivate(cx, obj);
// delete nativeThis;
// }
void nsCvrtJSValToStr(nsString& aString, void nsCvrtJSValToStr(nsString& aString,
JSContext* aContext, JSContext* aContext,
jsval aValue) jsval aValue)
@ -1013,15 +988,14 @@ PR_STATIC_CALLBACK(JSBool)
InstallGetWinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) InstallGetWinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{ {
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj); nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE; JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL; *rval = JSVAL_NULL;
#ifdef XP_WIN
// If there's no private data, this must be the prototype, so ignore // If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) { if(nsnull == nativeThis)
{
return JS_TRUE; return JS_TRUE;
} }
@ -1029,22 +1003,17 @@ InstallGetWinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
{ {
// public int GetWinProfile (Object folder, // public int GetWinProfile (Object folder,
// String file); // String file);
if(NS_OK != nativeThis->GetWinProfile(cx, &WinProfileClass, rval))
nsCvrtJSValToStr(b0, cx, argv[0]);
nsCvrtJSValToStr(b1, cx, argv[1]);
if(NS_OK != nativeThis->GetWinProfile(b0, b1, &nativeRet))
{ {
return JS_FALSE; return JS_FALSE;
} }
*rval = INT_TO_JSVAL(nativeRet);
} }
else else
{ {
JS_ReportError(cx, "Function GetWinProfile requires 2 parameters"); JS_ReportError(cx, "Function GetWinProfile requires 0 parameters");
return JS_FALSE; return JS_FALSE;
} }
#endif
return JS_TRUE; return JS_TRUE;
} }
@ -1517,19 +1486,6 @@ static JSFunctionSpec InstallMethods[] =
}; };
//
// WinProfile class methods
//
// static JSFunctionSpec WinProfileMethods[] =
// {
// {"writeString", WinProfileWriteString, 3},
// {"getString", WinProfileGetString, 2},
// {"getFilename", WinProfileGetFilename, 0},
// {"install", WinProfileInstall, 0},
// {"finalWriteString", WinProfileFinalWriteString, 3},
// {0}
// };
// //
// Install constructor // Install constructor
@ -1546,11 +1502,11 @@ Install(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, const char* jarfile, const char* args) PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, const char* jarfile, const char* args)
{ {
JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
JSObject *global = JS_GetGlobalObject(jscontext); JSObject *global = JS_GetGlobalObject(jscontext);
JSObject *installObject = nsnull; JSObject *installObject = nsnull;
JSObject *winRegPrototype = nsnull; JSObject *winRegPrototype = nsnull;
// JSObject *winProfilePrototype = nsnull; JSObject *winProfilePrototype = nsnull;
nsInstall *nativeInstallObject; nsInstall *nativeInstallObject;
installObject = JS_InitClass( jscontext, // context installObject = JS_InitClass( jscontext, // context
@ -1564,17 +1520,6 @@ PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, const char* jarfile, co
InstallProperties, // ctor props (static) InstallProperties, // ctor props (static)
InstallMethods); // ctor funcs (static) InstallMethods); // ctor funcs (static)
// winProfilePrototype = JS_InitClass( jscontext, // context
// global, // global object
// nsnull, // parent proto
// &WinProfileClass, // JSClass
// nsnull, // JSNative ctor
// 0, // ctor args
// nsnull, // proto props
// nsnull, // proto funcs
// nsnull, // ctor props (static)
// WinProfileMethods); // ctor funcs (static)
if (nsnull == installObject) if (nsnull == installObject)
{ {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -1598,11 +1543,11 @@ PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, const char* jarfile, co
} }
nativeInstallObject->SaveWinRegPrototype(winRegPrototype); nativeInstallObject->SaveWinRegPrototype(winRegPrototype);
// if(NS_OK != InitWinProfileObject(jscontext, global, winRegPrototype) if(NS_OK != InitWinProfilePrototype(jscontext, global, &winRegPrototype)
// { {
// return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
// } }
// nativeInstallObject->SaveWinProfilePrototype(winProfilePrototype); nativeInstallObject->SaveWinProfilePrototype(winProfilePrototype);
#endif #endif
return NS_OK; return NS_OK;
@ -1613,9 +1558,9 @@ PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, const char* jarfile, co
PRInt32 InitXPInstallObjects(JSContext *jscontext, JSObject *global, const char* jarfile, const char* args) PRInt32 InitXPInstallObjects(JSContext *jscontext, JSObject *global, const char* jarfile, const char* args)
{ {
JSObject *installObject = nsnull; JSObject *installObject = nsnull;
JSObject *winRegPrototype = nsnull; JSObject *winRegPrototype = nsnull;
// JSObject *winProfilePrototype = nsnull; JSObject *winProfilePrototype = nsnull;
nsInstall *nativeInstallObject; nsInstall *nativeInstallObject;
installObject = JS_InitClass( jscontext, // context installObject = JS_InitClass( jscontext, // context
@ -1629,17 +1574,6 @@ PRInt32 InitXPInstallObjects(JSContext *jscontext, JSObject *global, const char*
InstallProperties, // ctor props (static) InstallProperties, // ctor props (static)
InstallMethods); // ctor funcs (static) InstallMethods); // ctor funcs (static)
// winProfilePrototype = JS_InitClass( jscontext, // context
// global, // global object
// nsnull, // parent proto
// &WinProfileClass, // JSClass
// nsnull, // JSNative ctor
// 0, // ctor args
// nsnull, // proto props
// nsnull, // proto funcs
// nsnull, // ctor props (static)
// WinProfileMethods); // ctor funcs (static)
if (nsnull == installObject) if (nsnull == installObject)
{ {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -1663,11 +1597,11 @@ PRInt32 InitXPInstallObjects(JSContext *jscontext, JSObject *global, const char*
} }
nativeInstallObject->SaveWinRegPrototype(winRegPrototype); nativeInstallObject->SaveWinRegPrototype(winRegPrototype);
// if(NS_OK != InitWinProfileObject(jscontext, global, winRegPrototype) if(NS_OK != InitWinProfilePrototype(jscontext, global, &winRegPrototype)
// { {
// return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
// } }
// nativeInstallObject->SaveWinProfilePrototype(winProfilePrototype); nativeInstallObject->SaveWinProfilePrototype(winProfilePrototype);
#endif #endif
return NS_OK; return NS_OK;

View File

@ -25,8 +25,6 @@
#include "nsWinProfile.h" #include "nsWinProfile.h"
#include "nsJSWinProfile.h" #include "nsJSWinProfile.h"
static void PR_CALLBACK WinProfileCleanup(JSContext *cx, JSObject *obj);
extern void nsCvrtJSValToStr(nsString& aString, extern void nsCvrtJSValToStr(nsString& aString,
JSContext* aContext, JSContext* aContext,
jsval aValue); jsval aValue);
@ -168,15 +166,11 @@ JSClass WinProfileClass = {
JS_ResolveStub, JS_ResolveStub,
JS_ConvertStub, JS_ConvertStub,
WinProfileCleanup WinProfileCleanup
; };
static JSConstDoubleSpec winprofile_constants[] = static JSConstDoubleSpec winprofile_constants[] =
{ {
// { nsWinProfile::HKEY_CLASSES_ROOT, "HKEY_CLASSES_ROOT" },
// { nsWinProfile::HKEY_CURRENT_USER, "HKEY_CURRENT_USER" },
// { nsWinProfile::HKEY_LOCAL_MACHINE, "HKEY_LOCAL_MACHINE" },
// { nsWinProfile::HKEY_USERS, "HKEY_USERS" },
{0} {0}
}; };
@ -209,7 +203,7 @@ InitWinProfilePrototype(JSContext *jscontext, JSObject *global, JSObject **winPr
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
if(PR_FALSE == JS_DefineConstDoubles(jscontext, *winProfilePrototype, winProfile_constants)) if(PR_FALSE == JS_DefineConstDoubles(jscontext, *winProfilePrototype, winprofile_constants))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
return NS_OK; return NS_OK;

View File

@ -17,7 +17,6 @@
*/ */
#include "jsapi.h" #include "jsapi.h"
//#include "nsJSUtils.h"
#include "nscore.h" #include "nscore.h"
#include "nsIScriptContext.h" #include "nsIScriptContext.h"
@ -26,9 +25,6 @@
#include "nsWinReg.h" #include "nsWinReg.h"
#include "nsJSWinReg.h" #include "nsJSWinReg.h"
//extern JSClass WinRegClass;
// extern JSClass WinProfileClass;
static void PR_CALLBACK WinRegCleanup(JSContext *cx, JSObject *obj); static void PR_CALLBACK WinRegCleanup(JSContext *cx, JSObject *obj);
extern void nsCvrtJSValToStr(nsString& aString, extern void nsCvrtJSValToStr(nsString& aString,
@ -448,14 +444,6 @@ WinReg(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return JS_FALSE; return JS_FALSE;
} }
//
// WinProfile constructor
//
PR_STATIC_CALLBACK(JSBool)
WinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_FALSE;
}
/***********************************************************************/ /***********************************************************************/
// //

View File

@ -23,9 +23,15 @@
/* Public Methods */ /* Public Methods */
nsWinProfile::nsWinProfile( nsSoftwareUpdate* suObj, nsFolderSpec* folder, char* file ) nsWinProfile::nsWinProfile( nsInstall* suObj, const nsString& folder, const nsString& file )
{ {
filename = folder->MakeFullPath(file, NULL); /* can I pass NULL here? */ filename = new nsString(folder);
if(filename->Last() != '\\')
{
filename->Append("\\");
}
filename->Append(file);
su = suObj; su = suObj;
// principal = suObj->GetPrincipal(); // principal = suObj->GetPrincipal();
@ -34,18 +40,24 @@ nsWinProfile::nsWinProfile( nsSoftwareUpdate* suObj, nsFolderSpec* folder, char*
// target = (nsUserTarget*)nsTarget::findTarget(INSTALL_PRIV); // target = (nsUserTarget*)nsTarget::findTarget(INSTALL_PRIV);
} }
PRInt32 nsWinProfile::~nsWinProfile()
nsWinProfile::getString(nsString section, nsString key, nsString* aReturn )
{ {
*aReturn = nativeGetString(section, key); delete filename;
return NS_OK;
} }
PRInt32 PRInt32
nsWinProfile::writeString( char* section, char* key, char* value, PRInt32* aReturn ) nsWinProfile::getString(nsString section, nsString key, nsString* aReturn)
{
return nativeGetString(section, key, aReturn);
}
PRInt32
nsWinProfile::writeString(nsString section, nsString key, nsString value, PRInt32* aReturn)
{ {
nsWinProfileItem* wi = new nsWinProfileItem(this, section, key, value); nsWinProfileItem* wi = new nsWinProfileItem(this, section, key, value);
*aReturn = NS_OK;
if(wi == NULL) if(wi == NULL)
return PR_FALSE; return PR_FALSE;
@ -64,7 +76,7 @@ nsInstall* nsWinProfile::installObject()
} }
PRInt32 PRInt32
nsWinProfile::finalWriteString( char* section, char* key, char* value ) nsWinProfile::finalWriteString( nsString section, nsString key, nsString value )
{ {
/* do we need another security check here? */ /* do we need another security check here? */
return nativeWriteString(section, key, value); return nativeWriteString(section, key, value);
@ -72,38 +84,61 @@ nsWinProfile::finalWriteString( char* section, char* key, char* value )
/* Private Methods */ /* Private Methods */
#define STRBUFLEN 255
PRInt32 PRInt32
nsWinProfile::nativeWriteString( char* section, char* key, char* value ) nsWinProfile::nativeGetString(nsString section, nsString key, nsString* aReturn )
{ {
int success = 0; int numChars;
char valbuf[STRBUFLEN];
char* sectionCString;
char* keyCString;
char* filenameCString;
/* make sure conversions worked */
if(section.First() != '\0' && key.First() != '\0' && filename->First() != '\0')
{
sectionCString = section.ToNewCString();
keyCString = key.ToNewCString();
filenameCString = filename->ToNewCString();
numChars = GetPrivateProfileString(sectionCString, keyCString, "", valbuf, STRBUFLEN, filenameCString);
*aReturn = valbuf;
delete [] sectionCString;
delete [] keyCString;
delete [] filenameCString;
}
return numChars;
}
PRInt32
nsWinProfile::nativeWriteString( nsString section, nsString key, nsString value )
{
char* sectionCString;
char* keyCString;
char* valueCString;
char* filenameCString;
int success = 0;
/* make sure conversions worked */ /* make sure conversions worked */
if(section != NULL && key != NULL && filename != NULL) if(section.First() != '\0' && key.First() != '\0' && filename->First() != '\0')
success = WritePrivateProfileString( section, key, value, filename ); {
sectionCString = section.ToNewCString();
keyCString = key.ToNewCString();
valueCString = value.ToNewCString();
filenameCString = filename->ToNewCString();
success = WritePrivateProfileString( sectionCString, keyCString, valueCString, filenameCString );
delete [] sectionCString;
delete [] keyCString;
delete [] valueCString;
delete [] filenameCString;
}
return success; return success;
} }
#define STRBUFLEN 255
char* nsWinProfile::nativeGetString(nsString section, nsString key )
{
int numChars;
char valbuf[STRBUFLEN];
char* value = NULL;
/* make sure conversions worked */
if(section != "nsnull" && key != "nsnull" && filename != NULL)
{
numChars = GetPrivateProfileString( section, key, "", valbuf, STRBUFLEN, filename );
/* if the value fit in the buffer */
if(numChars < STRBUFLEN)
{
value = XP_STRDUP(valbuf);
}
}
return value;
}

View File

@ -22,53 +22,51 @@
#include "prtypes.h" #include "prtypes.h"
#include "nsInstall.h" #include "nsInstall.h"
#include "nsFolderSpec.h"
struct nsWinProfile { class nsWinProfile
{
public:
public: /* Public Fields */
/* Public Fields */ /* Public Methods */
/* Public Methods */ nsWinProfile( nsInstall* suObj, const nsString& folder, const nsString& file );
~nsWinProfile();
nsWinProfile( nsSoftwareUpdate* suObj, nsFolderSpec* folder, char* file ); /**
* Schedules a write into a windows "ini" file. "Value" can be
/** * null to delete the value, but we don't support deleting an entire
* Schedules a write into a windows "ini" file. "Value" can be * section via a null "key". The actual write takes place during
* null to delete the value, but we don't support deleting an entire * SoftwareUpdate.FinalizeInstall();
* section via a null "key". The actual write takes place during *
* SoftwareUpdate.FinalizeInstall(); * @return false for failure, true for success
* */
* @return false for failure, true for success PRInt32 writeString( nsString section, nsString key, nsString value, PRInt32* aReturn );
*/
PRInt32 writeString( char* section, char* key, char* value, PRInt32* aReturn ); /**
* Reads a value from a windows "ini" file. We don't support using
/** * a null "key" to return a list of keys--you have to know what you want
* Reads a value from a windows "ini" file. We don't support using *
* a null "key" to return a list of keys--you have to know what you want * @return String value from INI, "" if not found, null if error
* */
* @return String value from INI, "" if not found, null if error PRInt32 getString( nsString section, nsString key, nsString* aReturn );
*/
PRInt32 getString( char* section, char* key, nsString* aReturn ); nsString* getFilename();
nsInstall* installObject();
char* getFilename();
nsInstall* softUpdate(); PRInt32 finalWriteString( nsString section, nsString key, nsString value );
int finalWriteString( char* section, char* key, char* value );
private:
private: /* Private Fields */
nsString* filename;
/* Private Fields */ nsInstall* su;
char* filename;
nsInstall* su; /* Private Methods */
PRInt32 nativeWriteString( nsString section, nsString key, nsString value );
nsUserTarget* target; PRInt32 nativeGetString( nsString section, nsString key, nsString* aReturn );
/* Private Methods */
int nativeWriteString( char* section, char* key, char* value );
char* nativeGetString( char* section, char* key );
}; };
#endif /* nsWinProfile_h__ */ #endif /* nsWinProfile_h__ */

View File

@ -18,27 +18,34 @@
#include "nsWinProfileItem.h" #include "nsWinProfileItem.h"
#include "xp.h" #include "nspr.h"
#include "xp_str.h" #include <windows.h>
PR_BEGIN_EXTERN_C
/* Public Methods */ /* Public Methods */
nsWinProfileItem::nsWinProfileItem(nsWinProfile* profileObj, nsWinProfileItem::nsWinProfileItem(nsWinProfile* profileObj,
char* sectionName, char* keyName, nsString sectionName,
char* val) : nsInstallObject(profileObj->softUpdate()) nsString keyName,
nsString val) : nsInstallObject(profileObj->installObject())
{ {
profile = profileObj; profile = profileObj;
section = XP_STRDUP(sectionName); section = new nsString(sectionName);
key = XP_STRDUP(keyName); key = new nsString(keyName);
value = XP_STRDUP(val); value = new nsString(val);
} }
char* nsWinProfileItem::Complete() nsWinProfileItem::~nsWinProfileItem()
{ {
profile->finalWriteString(section, key, value); delete profile;
return NULL; delete section;
delete key;
delete value;
}
PRInt32 nsWinProfileItem::Complete()
{
profile->finalWriteString(*section, *key, *value);
return NS_OK;
} }
float nsWinProfileItem::GetInstallOrder() float nsWinProfileItem::GetInstallOrder()
@ -48,34 +55,33 @@ float nsWinProfileItem::GetInstallOrder()
char* nsWinProfileItem::toString() char* nsWinProfileItem::toString()
{ {
PRInt32 len; char* resultCString;
char* result; nsString* result;
char* filename = profile->getFilename(); nsString* filename = new nsString(*profile->getFilename());
len = XP_STRLEN("Write ") + XP_STRLEN(filename) + result = new nsString("Write ");
XP_STRLEN(": [") + XP_STRLEN(section) + XP_STRLEN("] ") + result->Append(*filename);
XP_STRLEN(key) + XP_STRLEN("=") + XP_STRLEN(value); result->Append(": [");
result->Append(*section);
result->Append("] ");
result->Append(*key);
result->Append("=");
result->Append(*value);
result = (char*)XP_ALLOC((len+1)*sizeof(char)); resultCString = result->ToNewCString();
XP_STRCAT(result, "Write "); delete result;
XP_STRCAT(result, filename); delete filename;
XP_STRCAT(result, ": [");
XP_STRCAT(result, section);
XP_STRCAT(result, "] ");
XP_STRCAT(result, key);
XP_STRCAT(result, "=");
XP_STRCAT(result, value);
return result; return resultCString;
} }
void nsWinProfileItem::Abort() void nsWinProfileItem::Abort()
{ {
} }
char* nsWinProfileItem::Prepare() PRInt32 nsWinProfileItem::Prepare()
{ {
return NULL; return nsnull;
} }
@ -99,5 +105,3 @@ nsWinProfileItem::RegisterPackageNode()
return TRUE; return TRUE;
} }
PR_END_EXTERN_C

View File

@ -36,15 +36,17 @@ public:
/* Public Methods */ /* Public Methods */
nsWinProfileItem(nsWinProfile* profileObj, nsWinProfileItem(nsWinProfile* profileObj,
char* sectionName, nsString sectionName,
char* keyName, nsString keyName,
char* val); nsString val);
~nsWinProfileItem();
/** /**
* Completes the install: * Completes the install:
* - writes the data into the .INI file * - writes the data into the .INI file
*/ */
char* Complete(); PRInt32 Complete();
float GetInstallOrder(); float GetInstallOrder();
@ -54,7 +56,7 @@ public:
void Abort(); void Abort();
// no need for set-up // no need for set-up
char* Prepare(); PRInt32 Prepare();
/* should these be protected? */ /* should these be protected? */
PRBool CanUninstall(); PRBool CanUninstall();
@ -63,13 +65,13 @@ public:
private: private:
/* Private Fields */ /* Private Fields */
nsWinProfile* profile; // initiating profile object nsWinProfile* profile; // initiating profile object
char* section; // Name of section nsString* section; // Name of section
char* key; // Name of key nsString* key; // Name of key
char* value; // data to write nsString* value; // data to write
/* Private Methods */ /* Private Methods */
}; };
PR_END_EXTERN_C PR_END_EXTERN_C

View File

@ -19,15 +19,9 @@
#ifndef __NS_WINREG_H__ #ifndef __NS_WINREG_H__
#define __NS_WINREG_H__ #define __NS_WINREG_H__
//#include "prtypes.h" #include "nsWinRegEnums.h"
#include "nsSoftUpdateEnums.h"
#include "nsWinRegValue.h" #include "nsWinRegValue.h"
//#include "nsPrincipal.h"
//#include "nsPrivilegeManager.h"
//#include "nsTarget.h"
//#include "nsUserTarget.h"
#include "nscore.h" #include "nscore.h"
#include "nsISupports.h" #include "nsISupports.h"

View File

@ -40,19 +40,15 @@ nsWinRegItem::nsWinRegItem(nsWinReg* regObj, PRInt32 root, PRInt32 action, nsStr
nsWinRegItem::~nsWinRegItem() nsWinRegItem::~nsWinRegItem()
{ {
if(subkey != nsnull) delete reg;
delete subkey; delete subkey;
delete name;
if(name != nsnull) delete value;
delete name;
if(value != nsnull)
delete value;
} }
PRInt32 nsWinRegItem::Complete() PRInt32 nsWinRegItem::Complete()
{ {
PRInt32 aReturn; PRInt32 aReturn = NS_OK;
switch (command) switch (command)
{ {
@ -96,51 +92,51 @@ char* nsWinRegItem::toString()
{ {
case NS_WIN_REG_CREATE: case NS_WIN_REG_CREATE:
keyString = keystr(rootkey, subkey, nsnull); keyString = keystr(rootkey, subkey, nsnull);
result = new nsString(kCRK); result = new nsString(kCRK);
result->Append(*keyString); result->Append(*keyString);
resultCString = result->ToNewCString(); resultCString = result->ToNewCString();
delete [] keyString; delete keyString;
delete [] result; delete result;
return resultCString; return resultCString;
case NS_WIN_REG_DELETE: case NS_WIN_REG_DELETE:
keyString = keystr(rootkey, subkey, nsnull); keyString = keystr(rootkey, subkey, nsnull);
result = new nsString(kDRK); result = new nsString(kDRK);
result->Append(*keyString); result->Append(*keyString);
resultCString = result->ToNewCString(); resultCString = result->ToNewCString();
delete [] keyString; delete keyString;
delete [] result; delete result;
return resultCString; return resultCString;
case NS_WIN_REG_DELETE_VAL: case NS_WIN_REG_DELETE_VAL:
keyString = keystr(rootkey, subkey, name); keyString = keystr(rootkey, subkey, name);
result = new nsString(kDRV); result = new nsString(kDRV);
result->Append(*keyString); result->Append(*keyString);
resultCString = result->ToNewCString(); resultCString = result->ToNewCString();
delete [] keyString; delete keyString;
delete [] result; delete result;
return resultCString; return resultCString;
case NS_WIN_REG_SET_VAL_STRING: case NS_WIN_REG_SET_VAL_STRING:
keyString = keystr(rootkey, subkey, name); keyString = keystr(rootkey, subkey, name);
result = new nsString(kSRV); result = new nsString(kSRV);
result->Append(*keyString); result->Append(*keyString);
resultCString = result->ToNewCString(); resultCString = result->ToNewCString();
delete [] keyString; delete keyString;
delete [] result; delete result;
return resultCString; return resultCString;
case NS_WIN_REG_SET_VAL: case NS_WIN_REG_SET_VAL:
keyString = keystr(rootkey, subkey, name); keyString = keystr(rootkey, subkey, name);
result = new nsString(kSRV); result = new nsString(kSRV);
result->Append(*keyString); result->Append(*keyString);
resultCString = result->ToNewCString(); resultCString = result->ToNewCString();
delete [] keyString; delete keyString;
delete [] result; delete result;
return resultCString; return resultCString;
default: default:
keyString = keystr(rootkey, subkey, name); keyString = keystr(rootkey, subkey, name);
result = new nsString(kUNK); result = new nsString(kUNK);
result->Append(*keyString); result->Append(*keyString);
resultCString = result->ToNewCString(); resultCString = result->ToNewCString();
delete [] keyString; delete keyString;
delete [] result; delete result;
return resultCString; return resultCString;
} }
} }
@ -193,7 +189,7 @@ nsString* nsWinRegItem::keystr(PRInt32 root, nsString* subkey, nsString* name)
finalstr->Append(*name); finalstr->Append(*name);
finalstr->Append("]"); finalstr->Append("]");
} }
delete [] rootstr; delete rootstr;
return finalstr; return finalstr;
} }

View File

@ -62,12 +62,12 @@ private:
/* Private Fields */ /* Private Fields */
nsWinReg* reg; // initiating WinReg object nsWinReg* reg; // initiating WinReg object
PRInt32 rootkey; PRInt32 rootkey;
PRInt32 command; PRInt32 command;
nsString* subkey; // Name of section nsString* subkey; // Name of section
nsString* name; // Name of key nsString* name; // Name of key
void* value; // data to write void* value; // data to write
/* Private Methods */ /* Private Methods */