mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 15:26:07 +00:00
added WinProfile object to the Install object
This commit is contained in:
parent
6d5d2a45b2
commit
3ed1dc53f0
@ -96,6 +96,9 @@ OBJS = \
|
||||
.\$(OBJDIR)\nsJSWinReg.obj \
|
||||
.\$(OBJDIR)\nsWinRegItem.obj \
|
||||
.\$(OBJDIR)\nsWinRegValue.obj \
|
||||
.\$(OBJDIR)\nsWinProfile.obj \
|
||||
.\$(OBJDIR)\nsJSWinProfile.obj \
|
||||
.\$(OBJDIR)\nsWinProfileItem.obj \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
@ -59,6 +59,7 @@
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include "nsWinReg.h"
|
||||
#include "nsWinProfile.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_PC
|
||||
@ -2278,9 +2279,24 @@ nsInstall::GetLastError(PRInt32* aReturn)
|
||||
}
|
||||
|
||||
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
|
||||
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 */
|
||||
|
||||
return NS_OK;
|
||||
|
@ -85,6 +85,7 @@ class nsInstallInfo
|
||||
class nsInstall
|
||||
{
|
||||
friend class nsWinReg;
|
||||
friend class nsWinProfile;
|
||||
|
||||
public:
|
||||
|
||||
@ -171,7 +172,7 @@ class nsInstall
|
||||
PRInt32 GetFolder(const nsString& aTargetFolder, const nsString& aSubdirectory, nsString** aFolder);
|
||||
PRInt32 GetFolder(const nsString& aTargetFolder, nsString** aFolder);
|
||||
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 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);
|
||||
|
@ -29,10 +29,8 @@
|
||||
#include "stdio.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include "nsWinReg.h"
|
||||
#include "nsJSWinReg.h"
|
||||
|
||||
extern JSClass WinRegClass;
|
||||
extern JSClass WinProfileClass;
|
||||
#endif
|
||||
|
||||
//
|
||||
@ -48,23 +46,6 @@ enum Install_slots
|
||||
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
|
||||
@ -174,12 +155,6 @@ static void PR_CALLBACK FinalizeInstall(JSContext *cx, JSObject *obj)
|
||||
delete nativeThis;
|
||||
}
|
||||
|
||||
// static void PR_CALLBACK WinProfileCleanup(JSContext *cx, JSObject *obj)
|
||||
// {
|
||||
// nsWinProfile *nativeThis = (nsWinProfile*)JS_GetPrivate(cx, obj);
|
||||
// delete nativeThis;
|
||||
// }
|
||||
|
||||
void nsCvrtJSValToStr(nsString& aString,
|
||||
JSContext* aContext,
|
||||
jsval aValue)
|
||||
@ -1013,15 +988,14 @@ PR_STATIC_CALLBACK(JSBool)
|
||||
InstallGetWinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRInt32 nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
JSBool rBool = JS_FALSE;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
#ifdef XP_WIN
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
if(nsnull == nativeThis)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@ -1029,22 +1003,17 @@ InstallGetWinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
||||
{
|
||||
// public int GetWinProfile (Object folder,
|
||||
// String file);
|
||||
|
||||
nsCvrtJSValToStr(b0, cx, argv[0]);
|
||||
nsCvrtJSValToStr(b1, cx, argv[1]);
|
||||
|
||||
if(NS_OK != nativeThis->GetWinProfile(b0, b1, &nativeRet))
|
||||
if(NS_OK != nativeThis->GetWinProfile(cx, &WinProfileClass, rval))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "Function GetWinProfile requires 2 parameters");
|
||||
JS_ReportError(cx, "Function GetWinProfile requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
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
|
||||
@ -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)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
JSObject *installObject = nsnull;
|
||||
JSObject *winRegPrototype = nsnull;
|
||||
// JSObject *winProfilePrototype = nsnull;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
JSObject *installObject = nsnull;
|
||||
JSObject *winRegPrototype = nsnull;
|
||||
JSObject *winProfilePrototype = nsnull;
|
||||
nsInstall *nativeInstallObject;
|
||||
|
||||
installObject = JS_InitClass( jscontext, // context
|
||||
@ -1564,17 +1520,6 @@ PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, const char* jarfile, co
|
||||
InstallProperties, // ctor props (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)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -1598,11 +1543,11 @@ PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, const char* jarfile, co
|
||||
}
|
||||
nativeInstallObject->SaveWinRegPrototype(winRegPrototype);
|
||||
|
||||
// if(NS_OK != InitWinProfileObject(jscontext, global, winRegPrototype)
|
||||
// {
|
||||
// return NS_ERROR_FAILURE;
|
||||
// }
|
||||
// nativeInstallObject->SaveWinProfilePrototype(winProfilePrototype);
|
||||
if(NS_OK != InitWinProfilePrototype(jscontext, global, &winRegPrototype)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nativeInstallObject->SaveWinProfilePrototype(winProfilePrototype);
|
||||
#endif
|
||||
|
||||
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)
|
||||
{
|
||||
JSObject *installObject = nsnull;
|
||||
JSObject *winRegPrototype = nsnull;
|
||||
// JSObject *winProfilePrototype = nsnull;
|
||||
JSObject *installObject = nsnull;
|
||||
JSObject *winRegPrototype = nsnull;
|
||||
JSObject *winProfilePrototype = nsnull;
|
||||
nsInstall *nativeInstallObject;
|
||||
|
||||
installObject = JS_InitClass( jscontext, // context
|
||||
@ -1629,17 +1574,6 @@ PRInt32 InitXPInstallObjects(JSContext *jscontext, JSObject *global, const char*
|
||||
InstallProperties, // ctor props (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)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -1663,11 +1597,11 @@ PRInt32 InitXPInstallObjects(JSContext *jscontext, JSObject *global, const char*
|
||||
}
|
||||
nativeInstallObject->SaveWinRegPrototype(winRegPrototype);
|
||||
|
||||
// if(NS_OK != InitWinProfileObject(jscontext, global, winRegPrototype)
|
||||
// {
|
||||
// return NS_ERROR_FAILURE;
|
||||
// }
|
||||
// nativeInstallObject->SaveWinProfilePrototype(winProfilePrototype);
|
||||
if(NS_OK != InitWinProfilePrototype(jscontext, global, &winRegPrototype)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nativeInstallObject->SaveWinProfilePrototype(winProfilePrototype);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "nsWinProfile.h"
|
||||
#include "nsJSWinProfile.h"
|
||||
|
||||
static void PR_CALLBACK WinProfileCleanup(JSContext *cx, JSObject *obj);
|
||||
|
||||
extern void nsCvrtJSValToStr(nsString& aString,
|
||||
JSContext* aContext,
|
||||
jsval aValue);
|
||||
@ -168,15 +166,11 @@ JSClass WinProfileClass = {
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
WinProfileCleanup
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
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}
|
||||
};
|
||||
|
||||
@ -209,7 +203,7 @@ InitWinProfilePrototype(JSContext *jscontext, JSObject *global, JSObject **winPr
|
||||
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_OK;
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "jsapi.h"
|
||||
//#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
@ -26,9 +25,6 @@
|
||||
#include "nsWinReg.h"
|
||||
#include "nsJSWinReg.h"
|
||||
|
||||
//extern JSClass WinRegClass;
|
||||
// extern JSClass WinProfileClass;
|
||||
|
||||
static void PR_CALLBACK WinRegCleanup(JSContext *cx, JSObject *obj);
|
||||
|
||||
extern void nsCvrtJSValToStr(nsString& aString,
|
||||
@ -448,14 +444,6 @@ WinReg(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// WinProfile constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
WinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
|
@ -23,9 +23,15 @@
|
||||
|
||||
/* 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;
|
||||
|
||||
// principal = suObj->GetPrincipal();
|
||||
@ -34,18 +40,24 @@ nsWinProfile::nsWinProfile( nsSoftwareUpdate* suObj, nsFolderSpec* folder, char*
|
||||
// target = (nsUserTarget*)nsTarget::findTarget(INSTALL_PRIV);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsWinProfile::getString(nsString section, nsString key, nsString* aReturn )
|
||||
nsWinProfile::~nsWinProfile()
|
||||
{
|
||||
*aReturn = nativeGetString(section, key);
|
||||
return NS_OK;
|
||||
delete filename;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
*aReturn = NS_OK;
|
||||
|
||||
if(wi == NULL)
|
||||
return PR_FALSE;
|
||||
|
||||
@ -64,7 +76,7 @@ nsInstall* nsWinProfile::installObject()
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsWinProfile::finalWriteString( char* section, char* key, char* value )
|
||||
nsWinProfile::finalWriteString( nsString section, nsString key, nsString value )
|
||||
{
|
||||
/* do we need another security check here? */
|
||||
return nativeWriteString(section, key, value);
|
||||
@ -72,38 +84,61 @@ nsWinProfile::finalWriteString( char* section, char* key, char* value )
|
||||
|
||||
/* Private Methods */
|
||||
|
||||
#define STRBUFLEN 255
|
||||
|
||||
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 */
|
||||
if(section != NULL && key != NULL && filename != NULL)
|
||||
success = WritePrivateProfileString( section, key, value, filename );
|
||||
if(section.First() != '\0' && key.First() != '\0' && filename->First() != '\0')
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
@ -22,53 +22,51 @@
|
||||
#include "prtypes.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
|
||||
* section via a null "key". The actual write takes place during
|
||||
* SoftwareUpdate.FinalizeInstall();
|
||||
*
|
||||
* @return false for failure, true for success
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @return String value from INI, "" if not found, null if error
|
||||
*/
|
||||
PRInt32 getString( char* section, char* key, nsString* aReturn );
|
||||
|
||||
char* getFilename();
|
||||
nsInstall* softUpdate();
|
||||
|
||||
int finalWriteString( char* section, char* key, char* value );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/* Private Fields */
|
||||
char* filename;
|
||||
nsInstall* su;
|
||||
|
||||
nsUserTarget* target;
|
||||
|
||||
/* Private Methods */
|
||||
int nativeWriteString( char* section, char* key, char* value );
|
||||
char* nativeGetString( char* section, char* key );
|
||||
/**
|
||||
* Schedules a write into a windows "ini" file. "Value" can be
|
||||
* null to delete the value, but we don't support deleting an entire
|
||||
* section via a null "key". The actual write takes place during
|
||||
* SoftwareUpdate.FinalizeInstall();
|
||||
*
|
||||
* @return false for failure, true for success
|
||||
*/
|
||||
PRInt32 writeString( nsString section, nsString key, nsString 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
|
||||
*
|
||||
* @return String value from INI, "" if not found, null if error
|
||||
*/
|
||||
PRInt32 getString( nsString section, nsString key, nsString* aReturn );
|
||||
|
||||
nsString* getFilename();
|
||||
nsInstall* installObject();
|
||||
|
||||
PRInt32 finalWriteString( nsString section, nsString key, nsString value );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/* Private Fields */
|
||||
nsString* filename;
|
||||
nsInstall* su;
|
||||
|
||||
/* Private Methods */
|
||||
PRInt32 nativeWriteString( nsString section, nsString key, nsString value );
|
||||
PRInt32 nativeGetString( nsString section, nsString key, nsString* aReturn );
|
||||
};
|
||||
|
||||
#endif /* nsWinProfile_h__ */
|
||||
|
@ -18,27 +18,34 @@
|
||||
|
||||
|
||||
#include "nsWinProfileItem.h"
|
||||
#include "xp.h"
|
||||
#include "xp_str.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
#include "nspr.h"
|
||||
#include <windows.h>
|
||||
|
||||
/* Public Methods */
|
||||
|
||||
nsWinProfileItem::nsWinProfileItem(nsWinProfile* profileObj,
|
||||
char* sectionName, char* keyName,
|
||||
char* val) : nsInstallObject(profileObj->softUpdate())
|
||||
nsString sectionName,
|
||||
nsString keyName,
|
||||
nsString val) : nsInstallObject(profileObj->installObject())
|
||||
{
|
||||
profile = profileObj;
|
||||
section = XP_STRDUP(sectionName);
|
||||
key = XP_STRDUP(keyName);
|
||||
value = XP_STRDUP(val);
|
||||
profile = profileObj;
|
||||
section = new nsString(sectionName);
|
||||
key = new nsString(keyName);
|
||||
value = new nsString(val);
|
||||
}
|
||||
|
||||
char* nsWinProfileItem::Complete()
|
||||
nsWinProfileItem::~nsWinProfileItem()
|
||||
{
|
||||
profile->finalWriteString(section, key, value);
|
||||
return NULL;
|
||||
delete profile;
|
||||
delete section;
|
||||
delete key;
|
||||
delete value;
|
||||
}
|
||||
|
||||
PRInt32 nsWinProfileItem::Complete()
|
||||
{
|
||||
profile->finalWriteString(*section, *key, *value);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
float nsWinProfileItem::GetInstallOrder()
|
||||
@ -48,34 +55,33 @@ float nsWinProfileItem::GetInstallOrder()
|
||||
|
||||
char* nsWinProfileItem::toString()
|
||||
{
|
||||
PRInt32 len;
|
||||
char* result;
|
||||
char* filename = profile->getFilename();
|
||||
char* resultCString;
|
||||
nsString* result;
|
||||
nsString* filename = new nsString(*profile->getFilename());
|
||||
|
||||
len = XP_STRLEN("Write ") + XP_STRLEN(filename) +
|
||||
XP_STRLEN(": [") + XP_STRLEN(section) + XP_STRLEN("] ") +
|
||||
XP_STRLEN(key) + XP_STRLEN("=") + XP_STRLEN(value);
|
||||
result = new nsString("Write ");
|
||||
result->Append(*filename);
|
||||
result->Append(": [");
|
||||
result->Append(*section);
|
||||
result->Append("] ");
|
||||
result->Append(*key);
|
||||
result->Append("=");
|
||||
result->Append(*value);
|
||||
|
||||
result = (char*)XP_ALLOC((len+1)*sizeof(char));
|
||||
XP_STRCAT(result, "Write ");
|
||||
XP_STRCAT(result, filename);
|
||||
XP_STRCAT(result, ": [");
|
||||
XP_STRCAT(result, section);
|
||||
XP_STRCAT(result, "] ");
|
||||
XP_STRCAT(result, key);
|
||||
XP_STRCAT(result, "=");
|
||||
XP_STRCAT(result, value);
|
||||
resultCString = result->ToNewCString();
|
||||
delete result;
|
||||
delete filename;
|
||||
|
||||
return result;
|
||||
return resultCString;
|
||||
}
|
||||
|
||||
void nsWinProfileItem::Abort()
|
||||
{
|
||||
}
|
||||
|
||||
char* nsWinProfileItem::Prepare()
|
||||
PRInt32 nsWinProfileItem::Prepare()
|
||||
{
|
||||
return NULL;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
@ -99,5 +105,3 @@ nsWinProfileItem::RegisterPackageNode()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
@ -36,15 +36,17 @@ public:
|
||||
/* Public Methods */
|
||||
|
||||
nsWinProfileItem(nsWinProfile* profileObj,
|
||||
char* sectionName,
|
||||
char* keyName,
|
||||
char* val);
|
||||
nsString sectionName,
|
||||
nsString keyName,
|
||||
nsString val);
|
||||
|
||||
~nsWinProfileItem();
|
||||
|
||||
/**
|
||||
* Completes the install:
|
||||
* - writes the data into the .INI file
|
||||
*/
|
||||
char* Complete();
|
||||
PRInt32 Complete();
|
||||
|
||||
float GetInstallOrder();
|
||||
|
||||
@ -54,7 +56,7 @@ public:
|
||||
void Abort();
|
||||
|
||||
// no need for set-up
|
||||
char* Prepare();
|
||||
PRInt32 Prepare();
|
||||
|
||||
/* should these be protected? */
|
||||
PRBool CanUninstall();
|
||||
@ -63,13 +65,13 @@ public:
|
||||
private:
|
||||
|
||||
/* Private Fields */
|
||||
nsWinProfile* profile; // initiating profile object
|
||||
char* section; // Name of section
|
||||
char* key; // Name of key
|
||||
char* value; // data to write
|
||||
nsWinProfile* profile; // initiating profile object
|
||||
nsString* section; // Name of section
|
||||
nsString* key; // Name of key
|
||||
nsString* value; // data to write
|
||||
|
||||
/* Private Methods */
|
||||
|
||||
|
||||
};
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
@ -19,15 +19,9 @@
|
||||
#ifndef __NS_WINREG_H__
|
||||
#define __NS_WINREG_H__
|
||||
|
||||
//#include "prtypes.h"
|
||||
#include "nsSoftUpdateEnums.h"
|
||||
#include "nsWinRegEnums.h"
|
||||
#include "nsWinRegValue.h"
|
||||
|
||||
//#include "nsPrincipal.h"
|
||||
//#include "nsPrivilegeManager.h"
|
||||
//#include "nsTarget.h"
|
||||
//#include "nsUserTarget.h"
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
|
@ -40,19 +40,15 @@ nsWinRegItem::nsWinRegItem(nsWinReg* regObj, PRInt32 root, PRInt32 action, nsStr
|
||||
|
||||
nsWinRegItem::~nsWinRegItem()
|
||||
{
|
||||
if(subkey != nsnull)
|
||||
delete subkey;
|
||||
|
||||
if(name != nsnull)
|
||||
delete name;
|
||||
|
||||
if(value != nsnull)
|
||||
delete value;
|
||||
delete reg;
|
||||
delete subkey;
|
||||
delete name;
|
||||
delete value;
|
||||
}
|
||||
|
||||
PRInt32 nsWinRegItem::Complete()
|
||||
{
|
||||
PRInt32 aReturn;
|
||||
PRInt32 aReturn = NS_OK;
|
||||
|
||||
switch (command)
|
||||
{
|
||||
@ -96,51 +92,51 @@ char* nsWinRegItem::toString()
|
||||
{
|
||||
case NS_WIN_REG_CREATE:
|
||||
keyString = keystr(rootkey, subkey, nsnull);
|
||||
result = new nsString(kCRK);
|
||||
result = new nsString(kCRK);
|
||||
result->Append(*keyString);
|
||||
resultCString = result->ToNewCString();
|
||||
delete [] keyString;
|
||||
delete [] result;
|
||||
delete keyString;
|
||||
delete result;
|
||||
return resultCString;
|
||||
case NS_WIN_REG_DELETE:
|
||||
keyString = keystr(rootkey, subkey, nsnull);
|
||||
result = new nsString(kDRK);
|
||||
result = new nsString(kDRK);
|
||||
result->Append(*keyString);
|
||||
resultCString = result->ToNewCString();
|
||||
delete [] keyString;
|
||||
delete [] result;
|
||||
delete keyString;
|
||||
delete result;
|
||||
return resultCString;
|
||||
case NS_WIN_REG_DELETE_VAL:
|
||||
keyString = keystr(rootkey, subkey, name);
|
||||
result = new nsString(kDRV);
|
||||
result = new nsString(kDRV);
|
||||
result->Append(*keyString);
|
||||
resultCString = result->ToNewCString();
|
||||
delete [] keyString;
|
||||
delete [] result;
|
||||
delete keyString;
|
||||
delete result;
|
||||
return resultCString;
|
||||
case NS_WIN_REG_SET_VAL_STRING:
|
||||
keyString = keystr(rootkey, subkey, name);
|
||||
result = new nsString(kSRV);
|
||||
result = new nsString(kSRV);
|
||||
result->Append(*keyString);
|
||||
resultCString = result->ToNewCString();
|
||||
delete [] keyString;
|
||||
delete [] result;
|
||||
delete keyString;
|
||||
delete result;
|
||||
return resultCString;
|
||||
case NS_WIN_REG_SET_VAL:
|
||||
keyString = keystr(rootkey, subkey, name);
|
||||
result = new nsString(kSRV);
|
||||
result = new nsString(kSRV);
|
||||
result->Append(*keyString);
|
||||
resultCString = result->ToNewCString();
|
||||
delete [] keyString;
|
||||
delete [] result;
|
||||
delete keyString;
|
||||
delete result;
|
||||
return resultCString;
|
||||
default:
|
||||
keyString = keystr(rootkey, subkey, name);
|
||||
result = new nsString(kUNK);
|
||||
result = new nsString(kUNK);
|
||||
result->Append(*keyString);
|
||||
resultCString = result->ToNewCString();
|
||||
delete [] keyString;
|
||||
delete [] result;
|
||||
delete keyString;
|
||||
delete result;
|
||||
return resultCString;
|
||||
}
|
||||
}
|
||||
@ -193,7 +189,7 @@ nsString* nsWinRegItem::keystr(PRInt32 root, nsString* subkey, nsString* name)
|
||||
finalstr->Append(*name);
|
||||
finalstr->Append("]");
|
||||
}
|
||||
delete [] rootstr;
|
||||
delete rootstr;
|
||||
return finalstr;
|
||||
}
|
||||
|
||||
|
@ -62,12 +62,12 @@ private:
|
||||
|
||||
/* Private Fields */
|
||||
|
||||
nsWinReg* reg; // initiating WinReg object
|
||||
nsWinReg* reg; // initiating WinReg object
|
||||
PRInt32 rootkey;
|
||||
PRInt32 command;
|
||||
nsString* subkey; // Name of section
|
||||
nsString* name; // Name of key
|
||||
void* value; // data to write
|
||||
nsString* name; // Name of key
|
||||
void* value; // data to write
|
||||
|
||||
/* Private Methods */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user