зеркало из https://github.com/mozilla/gecko-dev.git
Bug 134754; add scriptiable API to get Win32 registry value; r=sgehani, sr=dveditz
This commit is contained in:
Родитель
7e8dda96b3
Коммит
eca7ff9596
|
@ -200,6 +200,29 @@ interface nsIWindowsHooks : nsISupports {
|
|||
void setImageAsWallpaper(in nsIDOMElement aImageElement, in boolean useBackground);
|
||||
};
|
||||
|
||||
/* nsIWindowsRegistry
|
||||
*
|
||||
* This interface describes the service that you can use to
|
||||
* get/set Win32 registry entries.
|
||||
*
|
||||
* Notice: This interface is incomplete and should be used at your own risk!
|
||||
*/
|
||||
[scriptable, uuid(e07e7430-8d11-417c-83ee-c994400c452f)]
|
||||
interface nsIWindowsRegistry : nsISupports {
|
||||
/**
|
||||
* Returns a Win32 registry entry value. The returned string will be truncated
|
||||
* at 4096 bytes. The constants define the set of valid starting keys. You
|
||||
* pass in the subkey name and a value identifier (an empty string returns
|
||||
* the "default" value for that subkey).
|
||||
*/
|
||||
const long HKCR = 0; // HKEY_CLASSES_ROOT
|
||||
const long HKCC = 1; // HKEY_CURRENT_CONFIG
|
||||
const long HKCU = 2; // HKEY_CURRENT_USER
|
||||
const long HKLM = 3; // HKEY_LOCAL_MACHINE
|
||||
const long HKU = 4; // HKEY_USERS
|
||||
string getRegistryEntry( in long aHKeyConstant, in string aSubKeyName, in string aValueName );
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_IWINDOWSHOOKS_CONTRACTID "@mozilla.org/winhooks;1"
|
||||
#define NS_IWINDOWSHOOKS_CLASSNAME "Mozilla Windows Integration Hooks"
|
||||
|
|
|
@ -172,7 +172,7 @@ DEFINE_GETTER_AND_SETTER( HaveBeenSet, mHaveBeenSet )
|
|||
|
||||
// Implementation of the nsIWindowsHooks interface.
|
||||
// Use standard implementation of nsISupports stuff.
|
||||
NS_IMPL_ISUPPORTS1( nsWindowsHooks, nsIWindowsHooks );
|
||||
NS_IMPL_ISUPPORTS2( nsWindowsHooks, nsIWindowsHooks, nsIWindowsRegistry );
|
||||
|
||||
nsWindowsHooks::nsWindowsHooks() {
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
@ -647,6 +647,40 @@ nsWindowsHooks::SetRegistry() {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowsHooks::GetRegistryEntry( PRInt32 aHKEYConstant, const char *aSubKeyName, const char *aValueName, char **aResult ) {
|
||||
NS_ENSURE_ARG( aResult );
|
||||
*aResult = 0;
|
||||
// Calculate HKEY_* starting point based on input nsIWindowsHooks constant.
|
||||
HKEY hKey;
|
||||
switch ( aHKEYConstant ) {
|
||||
case HKCR:
|
||||
hKey = HKEY_CLASSES_ROOT;
|
||||
break;
|
||||
case HKCC:
|
||||
hKey = HKEY_CURRENT_CONFIG;
|
||||
break;
|
||||
case HKCU:
|
||||
hKey = HKEY_CURRENT_USER;
|
||||
break;
|
||||
case HKLM:
|
||||
hKey = HKEY_LOCAL_MACHINE;
|
||||
break;
|
||||
case HKU:
|
||||
hKey = HKEY_USERS;
|
||||
break;
|
||||
default:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Get requested registry entry.
|
||||
nsCAutoString entry( RegistryEntry( hKey, aSubKeyName, aValueName, 0 ).currentSetting() );
|
||||
|
||||
// Copy to result.
|
||||
*aResult = PL_strdup( entry.get() );
|
||||
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// nsIWindowsHooks.idl for documentation
|
||||
|
||||
/*
|
||||
|
@ -742,6 +776,7 @@ NS_IMETHODIMP nsWindowsHooks::StartupAddOption(const char* option) {
|
|||
newsetting.Append(option);
|
||||
startup.setting = newsetting;
|
||||
startup.set();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -944,9 +979,3 @@ nsWindowsHooks::SetImageAsWallpaper(nsIDOMElement* aElement, PRBool aUseBackgrou
|
|||
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if (_MSC_VER == 1100)
|
||||
#define INITGUID
|
||||
#include "objbase.h"
|
||||
DEFINE_OLEGUID(IID_IPersistFile, 0x0000010BL, 0, 0);
|
||||
#endif
|
||||
|
|
|
@ -102,7 +102,7 @@ private:
|
|||
friend class nsWindowsHooks;
|
||||
}; // nsWindowsHooksSettings
|
||||
|
||||
class nsWindowsHooks : public nsIWindowsHooks {
|
||||
class nsWindowsHooks : public nsIWindowsHooks, public nsIWindowsRegistry {
|
||||
public:
|
||||
// ctor/dtor
|
||||
nsWindowsHooks();
|
||||
|
@ -111,6 +111,7 @@ public:
|
|||
// Declare all interface methods we must implement.
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWINDOWSHOOKS
|
||||
NS_DECL_NSIWINDOWSREGISTRY
|
||||
|
||||
protected:
|
||||
// Internal flavor of GetPreferences.
|
||||
|
|
Загрузка…
Ссылка в новой задаче