New interfaces to profiles

This commit is contained in:
racham%netscape.com 1999-06-12 00:50:17 +00:00
parent c29a663e78
commit 68a0b30566
4 changed files with 162 additions and 3 deletions

View File

@ -41,6 +41,12 @@ public:
NS_IMETHOD DeleteProfile(const nsString& aProfileName)=0;
NS_IMETHOD GetProfileList(nsString& aReturn)=0;
NS_IMETHOD StartCommunicator(const nsString& aProfileName)=0;
NS_IMETHOD GetCurrentProfile(nsString& aReturn)=0;
NS_IMETHOD MigrateProfile(const nsString& aProfileName)=0;
};
@ -49,6 +55,9 @@ public:
NS_IMETHOD RenameProfile(const nsString& aOldName, const nsString& aNewName); \
NS_IMETHOD DeleteProfile(const nsString& aProfileName); \
NS_IMETHOD GetProfileList(nsString& aReturn); \
NS_IMETHOD StartCommunicator(const nsString& aProfileName); \
NS_IMETHOD GetCurrentProfile(nsString& aReturn); \
NS_IMETHOD MigrateProfile(const nsString& aProfileName); \
@ -57,6 +66,9 @@ public:
NS_IMETHOD RenameProfile(const nsString& aOldName, const nsString& aNewName) { return _to RenameProfile(aOldName, aNewName); } \
NS_IMETHOD DeleteProfile(const nsString& aProfileName) { return _to DeleteProfile(aProfileName); } \
NS_IMETHOD GetProfileList(nsString& aReturn) { return _to GetProfileList(aReturn); } \
NS_IMETHOD StartCommunicator(const nsString& aProfileName) { return _to StartCommunicator(aProfileName); } \
NS_IMETHOD GetCurrentProfile(nsString& aReturn) { return _to GetCurrentProfile(aReturn); } \
NS_IMETHOD MigrateProfile(const nsString& aProfileName) { return _to MigrateProfile(aProfileName); } \
extern "C" NS_DOM nsresult NS_InitProfileCoreClass(nsIScriptContext *aContext, void **aPrototype);

View File

@ -273,6 +273,112 @@ ProfileCoreGetProfileList(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
}
//
// Native method StartCommunicator
//
PR_STATIC_CALLBACK(JSBool)
ProfileCoreStartCommunicator(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMProfileCore *nativeThis = (nsIDOMProfileCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
if (NS_OK != nativeThis->StartCommunicator(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function StartCommunicator requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method GetCurrentProfile
//
PR_STATIC_CALLBACK(JSBool)
ProfileCoreGetCurrentProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMProfileCore *nativeThis = (nsIDOMProfileCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString nativeRet;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->GetCurrentProfile(nativeRet)) {
return JS_FALSE;
}
nsJSUtils::nsConvertStringToJSVal(nativeRet, cx, rval);
}
else {
JS_ReportError(cx, "Function GetCurrentProfile requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method MigrateProfile
//
PR_STATIC_CALLBACK(JSBool)
ProfileCoreMigrateProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMProfileCore *nativeThis = (nsIDOMProfileCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
if (NS_OK != nativeThis->MigrateProfile(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function MigrateProfile requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for ProfileCore
@ -309,6 +415,9 @@ static JSFunctionSpec ProfileCoreMethods[] =
{"RenameProfile", ProfileCoreRenameProfile, 2},
{"DeleteProfile", ProfileCoreDeleteProfile, 1},
{"GetProfileList", ProfileCoreGetProfileList, 0},
{"StartCommunicator", ProfileCoreStartCommunicator, 1},
{"GetCurrentProfile", ProfileCoreGetCurrentProfile, 0},
{"MigrateProfile", ProfileCoreMigrateProfile, 1},
{0}
};

View File

@ -204,3 +204,41 @@ NS_IMETHODIMP nsProfileCore::GetProfileList(nsString& profileList)
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsProfileCore::StartCommunicator(const nsString& profileName)
// Start loading of a new Profile panel.
//----------------------------------------------------------------------------------------
{
printf ("Entered Start AppRunner Routine\n");
printf ("Run AppRunner with profile -> %s <-\n", profileName.ToNewCString());
mProfile->StartCommunicator(profileName.ToNewCString());
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsProfileCore::GetCurrentProfile(nsString& currProfile)
// Start loading of a new Profile panel.
//----------------------------------------------------------------------------------------
{
printf ("Entered GetCurrentProfile Routine\n");
mProfile->GetCurrProfile(currProfile);
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsProfileCore::MigrateProfile(const nsString& profileName)
// Start loading of a new Profile panel.
//----------------------------------------------------------------------------------------
{
#ifdef XP_PC
printf ("Entered Migrate Profile Routine\n");
printf ("Requesting migration of profile -> %s <-\n", profileName.ToNewCString());
mProfile->MigrateProfile(profileName.ToNewCString());
#endif
return NS_OK;
}

View File

@ -127,9 +127,9 @@ class nsProfileCore
NS_IMETHOD DeleteProfile(const nsString& profileName);
NS_IMETHOD GetProfileList(nsString& profileList);
NS_IMETHOD StartCommunicator(const nsString& profileName);
NS_IMETHOD GetCurrentProfile(nsString& currProfile);
NS_IMETHOD MigrateProfile(const nsString& profileName);
protected: