Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Private Member Functions | Private Attributes
nsWinReg Class Reference

#include <nsWinReg.h>

Collaboration diagram for nsWinReg:
Collaboration graph
[legend]

List of all members.

Public Types

enum  { NS_HKEY_CLASSES_ROOT = 0x80000000, NS_HKEY_CURRENT_USER = 0x80000001, NS_HKEY_LOCAL_MACHINE = 0x80000002, NS_HKEY_USERS = 0x80000003 }

Public Member Functions

 nsWinReg (nsInstall *suObj)
 ~nsWinReg ()
PRInt32 SetRootKey (PRInt32 key)
PRInt32 CreateKey (const nsAString &subkey, const nsAString &classname, PRInt32 *aReturn)
PRInt32 DeleteKey (const nsAString &subkey, PRInt32 *aReturn)
PRInt32 DeleteValue (const nsAString &subkey, const nsAString &valname, PRInt32 *aReturn)
PRInt32 SetValueString (const nsAString &subkey, const nsAString &valname, const nsAString &value, PRInt32 *aReturn)
PRInt32 GetValueString (const nsString &subkey, const nsString &valname, nsString *aReturn)
PRInt32 SetValueNumber (const nsString &subkey, const nsString &valname, PRInt32 value, PRInt32 *aReturn)
PRInt32 GetValueNumber (const nsString &subkey, const nsString &valname, PRInt32 *aReturn)
PRInt32 SetValue (const nsString &subkey, const nsString &valname, nsWinRegValue *value, PRInt32 *aReturn)
PRInt32 GetValue (const nsString &subkey, const nsString &valname, nsWinRegValue **aReturn)
PRInt32 EnumValueNames (const nsString &keyname, PRInt32 index, nsString &aReturn)
PRInt32 EnumKeys (const nsString &keyname, PRInt32 index, nsString &aReturn)
nsInstallInstallObject (void)
PRInt32 KeyExists (const nsString &subkey, PRInt32 *aReturn)
PRInt32 ValueExists (const nsString &subkey, const nsString &valname, PRInt32 *aReturn)
PRInt32 IsKeyWritable (const nsString &subkey, PRInt32 *aReturn)
PRInt32 PrepareCreateKey (PRInt32 root, const nsString &subkey, PRInt32 *aReturn)
PRInt32 PrepareDeleteKey (PRInt32 root, const nsString &subkey, PRInt32 *aReturn)
PRInt32 PrepareDeleteValue (PRInt32 root, const nsString &subkey, const nsString &valname, PRInt32 *aReturn)
PRInt32 PrepareSetValueString (PRInt32 root, const nsString &subkey, PRInt32 *aReturn)
PRInt32 PrepareSetValueNumber (PRInt32 root, const nsString &subkey, PRInt32 *aReturn)
PRInt32 PrepareSetValue (PRInt32 root, const nsString &subkey, PRInt32 *aReturn)
PRInt32 FinalCreateKey (PRInt32 root, const nsString &subkey, const nsString &classname, PRInt32 *aReturn)
PRInt32 FinalDeleteKey (PRInt32 root, const nsString &subkey, PRInt32 *aReturn)
PRInt32 FinalDeleteValue (PRInt32 root, const nsString &subkey, const nsString &valname, PRInt32 *aReturn)
PRInt32 FinalSetValueString (PRInt32 root, const nsString &subkey, const nsString &valname, const nsString &value, PRInt32 *aReturn)
PRInt32 FinalSetValueNumber (PRInt32 root, const nsString &subkey, const nsString &valname, PRInt32 value, PRInt32 *aReturn)
PRInt32 FinalSetValue (PRInt32 root, const nsString &subkey, const nsString &valname, nsWinRegValue *value, PRInt32 *aReturn)

Private Member Functions

PRBool NativeKeyExists (const nsString &subkey)
PRBool NativeValueExists (const nsString &subkey, const nsString &valname)
PRBool NativeIsKeyWritable (const nsString &subkey)
PRInt32 NativeCreateKey (const nsString &subkey, const nsString &classname)
PRInt32 NativeDeleteKey (const nsString &subkey)
PRInt32 NativeDeleteValue (const nsString &subkey, const nsString &valname)
PRInt32 NativeSetValueString (const nsString &subkey, const nsString &valname, const nsString &value)
PRInt32 NativeGetValueString (const nsString &subkey, const nsString &valname, nsString *aReturn)
PRInt32 NativeSetValueNumber (const nsString &subkey, const nsString &valname, PRInt32 value)
PRInt32 NativeGetValueNumber (const nsString &subkey, const nsString &valname, PRInt32 *aReturn)
PRInt32 NativeSetValue (const nsString &subkey, const nsString &valname, nsWinRegValue *value)
nsWinRegValueNativeGetValue (const nsString &subkey, const nsString &valname)

Private Attributes

PRInt32 mRootKey
nsInstallmInstallObject

Detailed Description

Definition at line 66 of file nsWinReg.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
NS_HKEY_CLASSES_ROOT 
NS_HKEY_CURRENT_USER 
NS_HKEY_LOCAL_MACHINE 
NS_HKEY_USERS 

Definition at line 70 of file nsWinReg.h.

    {
      NS_HKEY_CLASSES_ROOT          = 0x80000000,
      NS_HKEY_CURRENT_USER          = 0x80000001,
      NS_HKEY_LOCAL_MACHINE         = 0x80000002,
      NS_HKEY_USERS                 = 0x80000003
    };

Constructor & Destructor Documentation

Definition at line 48 of file nsWinReg.cpp.

{
    MOZ_COUNT_CTOR(nsWinReg);

    mInstallObject      = suObj;
       mRootKey = (PRInt32)HKEY_CLASSES_ROOT;
}

Definition at line 56 of file nsWinReg.cpp.


Member Function Documentation

PRInt32 nsWinReg::CreateKey ( const nsAString &  subkey,
const nsAString &  classname,
PRInt32 aReturn 
)

Definition at line 69 of file nsWinReg.cpp.

{
       nsWinRegItem* wi = new nsWinRegItem(this, mRootKey, NS_WIN_REG_CREATE, subkey, classname, NS_LITERAL_STRING("null"), aReturn);

  if(wi == nsnull)
  {
    *aReturn = nsInstall::OUT_OF_MEMORY;
    return NS_OK;
  }

  if(*aReturn != nsInstall::SUCCESS)
  {
    if(wi)
    {
      delete wi;
      return NS_OK;
    }
  }

  if(mInstallObject)
       *aReturn = mInstallObject->ScheduleForInstall(wi);
       
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::DeleteKey ( const nsAString &  subkey,
PRInt32 aReturn 
)

Definition at line 95 of file nsWinReg.cpp.

{
       nsWinRegItem* wi = new nsWinRegItem(this, mRootKey, NS_WIN_REG_DELETE, subkey, NS_LITERAL_STRING("null"), NS_LITERAL_STRING("null"), aReturn);

  if(wi == nsnull)
  {
    *aReturn = nsInstall::OUT_OF_MEMORY;
    return NS_OK;
  }

  if(*aReturn != nsInstall::SUCCESS)
  {
    if(wi)
    {
      delete wi;
      return NS_OK;
    }
  }

  if(mInstallObject)
    *aReturn = mInstallObject->ScheduleForInstall(wi);

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::DeleteValue ( const nsAString &  subkey,
const nsAString &  valname,
PRInt32 aReturn 
)

Definition at line 121 of file nsWinReg.cpp.

{
       nsWinRegItem* wi = new nsWinRegItem(this, mRootKey, NS_WIN_REG_DELETE_VAL, subkey, valname, NS_LITERAL_STRING("null"), aReturn);

  if(wi == nsnull)
  {
    *aReturn = nsInstall::OUT_OF_MEMORY;
    return NS_OK;
  }

  if(*aReturn != nsInstall::SUCCESS)
  {
    if(wi)
    {
      delete wi;
      return NS_OK;
    }
  }

  if(mInstallObject)
    *aReturn = mInstallObject->ScheduleForInstall(wi);

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::EnumKeys ( const nsString keyname,
PRInt32  index,
nsString aReturn 
)

Definition at line 214 of file nsWinReg.cpp.

{
    char            keybuf[MAX_BUF];
    HKEY            root;
    HKEY            newkey;
    LONG            result;
    DWORD           type            = REG_SZ;
    PRInt32         rv = nsInstall::UNEXPECTED_ERROR;

    nsCAutoString subkey;
    if ( NS_FAILED(NS_CopyUnicodeToNative(aSubkey, subkey) ) )
        return nsInstall::UNEXPECTED_ERROR;

    root   = (HKEY) mRootKey;
    result = RegOpenKeyEx( root, subkey.get(), 0, KEY_READ, &newkey );

    if ( ERROR_SUCCESS == result ) {
        result = RegEnumKey( newkey, aIndex, keybuf, sizeof keybuf );
        RegCloseKey( newkey );
        
        if ( ERROR_SUCCESS == result ) {
            nsCAutoString cstrKey(keybuf);
            nsAutoString key;
            if (NS_SUCCEEDED(NS_CopyNativeToUnicode(cstrKey, key) ) )
            {
                aReturn.Assign(key);
                rv = nsInstall::SUCCESS;
            }
        }
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::EnumValueNames ( const nsString keyname,
PRInt32  index,
nsString aReturn 
)

Definition at line 179 of file nsWinReg.cpp.

{
    char           namebuf[MAX_BUF];
    HKEY           root;
    HKEY           newkey;
    LONG           result;
    DWORD          namesize         = sizeof(namebuf);
    PRInt32        rv = nsInstall::UNEXPECTED_ERROR;

    nsCAutoString subkey;
    if ( NS_FAILED ( NS_CopyUnicodeToNative(aSubkey, subkey) ) )
        return nsInstall::UNEXPECTED_ERROR;

    root   = (HKEY) mRootKey;
    result = RegOpenKeyEx( root, subkey.get(), 0, KEY_READ, &newkey );

    if ( ERROR_SUCCESS == result ) {
        result = RegEnumValue( newkey, aIndex, namebuf, &namesize, nsnull, 0, 0, 0 );
        RegCloseKey( newkey );

        if ( ERROR_SUCCESS == result ) {
            nsCAutoString cstrName(namebuf);
            nsAutoString name;
            if(NS_SUCCEEDED(NS_CopyNativeToUnicode(cstrName, name)))
            {
                aReturn.Assign(name);
                rv = nsInstall::SUCCESS;
            }
        } 
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::FinalCreateKey ( PRInt32  root,
const nsString subkey,
const nsString classname,
PRInt32 aReturn 
)

Definition at line 428 of file nsWinReg.cpp.

{
       SetRootKey(root);
       *aReturn = NativeCreateKey(subkey, classname);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::FinalDeleteKey ( PRInt32  root,
const nsString subkey,
PRInt32 aReturn 
)

Definition at line 436 of file nsWinReg.cpp.

{
       SetRootKey(root);
  if ( PR_TRUE == NativeKeyExists(subkey) )
    *aReturn = NativeDeleteKey(subkey);
  else {
    NS_WARNING("Trying to delete a key that doesn't exist anymore. Possible causes include calling deleteKey for the same key multiple times, or key+subkey are not unique");
    *aReturn = ERROR_SUCCESS;
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::FinalDeleteValue ( PRInt32  root,
const nsString subkey,
const nsString valname,
PRInt32 aReturn 
)

Definition at line 449 of file nsWinReg.cpp.

{
       SetRootKey(root);
       *aReturn = NativeDeleteValue(subkey, valname);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::FinalSetValue ( PRInt32  root,
const nsString subkey,
const nsString valname,
nsWinRegValue value,
PRInt32 aReturn 
)

Definition at line 473 of file nsWinReg.cpp.

{
       SetRootKey(root);
       *aReturn = NativeSetValue(subkey, valname, value);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::FinalSetValueNumber ( PRInt32  root,
const nsString subkey,
const nsString valname,
PRInt32  value,
PRInt32 aReturn 
)

Definition at line 465 of file nsWinReg.cpp.

{
       SetRootKey(root);
       *aReturn = NativeSetValueNumber(subkey, valname, value);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::FinalSetValueString ( PRInt32  root,
const nsString subkey,
const nsString valname,
const nsString value,
PRInt32 aReturn 
)

Definition at line 457 of file nsWinReg.cpp.

{
       SetRootKey(root);
       *aReturn = NativeSetValueString(subkey, valname, value);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::GetValue ( const nsString subkey,
const nsString valname,
nsWinRegValue **  aReturn 
)

Definition at line 296 of file nsWinReg.cpp.

{
  // fix:
  return NS_OK;
}

Here is the caller graph for this function:

PRInt32 nsWinReg::GetValueNumber ( const nsString subkey,
const nsString valname,
PRInt32 aReturn 
)

Definition at line 275 of file nsWinReg.cpp.

{
    return NativeGetValueNumber(subkey, valname, aReturn);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::GetValueString ( const nsString subkey,
const nsString valname,
nsString aReturn 
)

Definition at line 173 of file nsWinReg.cpp.

{
   return NativeGetValueString(subkey, valname, aReturn);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 302 of file nsWinReg.cpp.

{
       return mInstallObject;
}
PRInt32 nsWinReg::IsKeyWritable ( const nsString subkey,
PRInt32 aReturn 
)

Definition at line 325 of file nsWinReg.cpp.

{
  *aReturn = NativeIsKeyWritable(subkey);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::KeyExists ( const nsString subkey,
PRInt32 aReturn 
)

Definition at line 308 of file nsWinReg.cpp.

{
  *aReturn = NativeKeyExists(subkey);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::NativeCreateKey ( const nsString subkey,
const nsString classname 
) [private]

Definition at line 629 of file nsWinReg.cpp.

{
    HKEY    root, newkey;
    LONG    result;
    ULONG   disposition;

#ifdef WIN32
    nsCAutoString subkey;
    nsCAutoString classname;

    if (NS_FAILED(NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
        NS_FAILED(NS_CopyUnicodeToNative(aClassname, classname) ) )
        return nsInstall::UNEXPECTED_ERROR;

    root   = (HKEY)mRootKey;
    result = RegCreateKeyEx(root, subkey.get(), 0, NS_CONST_CAST(char*, classname.get()),
                REG_OPTION_NON_VOLATILE, KEY_WRITE, nsnull, &newkey, &disposition);

    if(ERROR_SUCCESS == result)
    {
        RegCloseKey( newkey );
    }
#endif

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 657 of file nsWinReg.cpp.

{
    HKEY  root;
    LONG  result;

#ifdef WIN32
    nsCAutoString subkey;

    if (NS_FAILED(NS_CopyUnicodeToNative(aSubkey, subkey) ) )
      return nsInstall::UNEXPECTED_ERROR;

    root   = (HKEY) mRootKey;
    result = RegDeleteKey( root, subkey.get() );
#endif

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::NativeDeleteValue ( const nsString subkey,
const nsString valname 
) [private]

Definition at line 676 of file nsWinReg.cpp.

{
#if defined (WIN32) || defined (XP_OS2)
    HKEY    root, newkey;
    LONG    result;
    nsCAutoString subkey;
    nsCAutoString valname;

    if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
         NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
        return nsInstall::UNEXPECTED_ERROR;
    root   = (HKEY) mRootKey;
    result = RegOpenKeyEx( root, subkey.get(), 0, KEY_WRITE, &newkey);

    if ( ERROR_SUCCESS == result )
    {
        result = RegDeleteValue( newkey, valname.get() );
        RegCloseKey( newkey );
    }

    return result;
#else
    return ERROR_INVALID_PARAMETER;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsWinRegValue * nsWinReg::NativeGetValue ( const nsString subkey,
const nsString valname 
) [private]

Definition at line 878 of file nsWinReg.cpp.

{
#if defined (WIN32) || defined (XP_OS2)
    unsigned char    valbuf[STRBUFLEN];
    HKEY    root;
    HKEY    newkey;
    LONG    result;
    DWORD   length=STRBUFLEN;
    DWORD   type;
    nsString* data;
    nsWinRegValue* value = nsnull;
    nsCAutoString subkey;
    nsCAutoString valname;

    if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
         NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
        return nsnull;

    root   = (HKEY) mRootKey;
    result = RegOpenKeyEx( root, subkey.get(), 0, KEY_READ, &newkey );

    if(ERROR_SUCCESS == result)
    {
        result = RegQueryValueEx( newkey, valname.get(), nsnull, &type, valbuf, &length );

        if ( ERROR_SUCCESS == result ) {
            data = new nsString;
            data->AssignWithConversion((char *)valbuf);
                           length = data->Length();
            value = new nsWinRegValue(type, (void*)data, length);
        }

        RegCloseKey( newkey );
    }

    return value;
#else
    return nsnull;
#endif
}

Here is the call graph for this function:

PRInt32 nsWinReg::NativeGetValueNumber ( const nsString subkey,
const nsString valname,
PRInt32 aReturn 
) [private]

Definition at line 803 of file nsWinReg.cpp.

{
    PRInt32 valbuf;
    PRInt32 valbuflen;
    HKEY    root;
    HKEY    newkey;
    LONG    result;
    DWORD   type            = REG_DWORD;
    DWORD   length          = _MAXKEYVALUE_;
    nsCAutoString subkey;
    nsCAutoString valname;

    if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
         NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
        return nsInstall::UNEXPECTED_ERROR;

    valbuflen = sizeof(PRInt32);
    root      = (HKEY) mRootKey;
    result    = RegOpenKeyEx( root, subkey.get(), 0, KEY_READ, &newkey );

    if ( ERROR_SUCCESS == result ) {
        result = RegQueryValueEx( newkey, valname.get(), nsnull, &type, (LPBYTE)&valbuf, (LPDWORD)&valbuflen);

        RegCloseKey( newkey );

        if(type == REG_DWORD)
            *aReturn = valbuf;
    }

    if(ERROR_ACCESS_DENIED == result)
        return nsInstall::ACCESS_DENIED;
    else if (result != ERROR_SUCCESS)
        return nsInstall::UNEXPECTED_ERROR;

    return nsInstall::SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::NativeGetValueString ( const nsString subkey,
const nsString valname,
nsString aReturn 
) [private]

Definition at line 736 of file nsWinReg.cpp.

{
    unsigned char     valbuf[_MAXKEYVALUE_];
    HKEY              root;
    HKEY              newkey;
    LONG              result;
    DWORD             type            = REG_SZ;
    DWORD             length          = sizeof(valbuf);
    nsCAutoString     subkey;
    nsCAutoString     valname;

    if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
         NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
        return nsInstall::UNEXPECTED_ERROR;

    root   = (HKEY) mRootKey;
    result = RegOpenKeyEx( root, subkey.get(), 0, KEY_READ, &newkey );

    if ( ERROR_SUCCESS == result ) {
        result = RegQueryValueEx( newkey, valname.get(), nsnull, &type, valbuf, &length );

        RegCloseKey( newkey );

        if( result == ERROR_SUCCESS && type == REG_SZ)
        {
            // this cast is ok until mozilla is compiled in UNICODE, then this
            // will break.
            nsAutoString value;
            if (NS_SUCCEEDED( NS_CopyNativeToUnicode(nsDependentCString(NS_REINTERPRET_CAST(const char *, valbuf)), value) ) )
              aReturn->Assign(value);
            else
              result = nsInstall::UNEXPECTED_ERROR;
        }
    }

    if(ERROR_ACCESS_DENIED == result)
        result = nsInstall::ACCESS_DENIED;

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 569 of file nsWinReg.cpp.

{
    HKEY     root;
    HKEY     newkey;
    LONG     result;
    nsString subkeyParent = aSubkey;
    PRInt32  index;
    PRInt32  rv = PR_FALSE;

#ifdef WIN32
    /* In order to check to see if a key is writable (user has write access
     * to the key), we need to open the key with KEY_WRITE access.  In order
     * to open a key, the key must first exist.  If the key passed does not
     * exist, we need to search for one of its parent key that _does_ exist.
     * This do{} loop will search for an existing parent key. */
    do
    {
        rv = NativeKeyExists(subkeyParent);
        if(!rv)
        {
            index = subkeyParent.RFindChar('\\', -1, -1);
            if(index > 0)
                /* delete everything from the '\\' found to the end of the string */
                subkeyParent.SetLength(index);
            else
                /* key does not exist and no parent key found */
                break;
        }
    }while(!rv);

    if(rv)
    {
        nsCAutoString subkey;

        if ( NS_FAILED( NS_CopyUnicodeToNative(subkeyParent, subkey) ) )
            result = nsInstall::UNEXPECTED_ERROR;
        else
        {
            rv     = PR_FALSE;
            root   = (HKEY)mRootKey;
            result = RegOpenKeyEx(root, subkey.get(), 0, KEY_WRITE, &newkey);
            switch(result)
            {
                case ERROR_SUCCESS:
                    RegCloseKey(newkey);
                    rv = PR_TRUE;
                    break;

                case ERROR_FILE_NOT_FOUND:
                case ERROR_ACCESS_DENIED:
                default:
                    break;
            }
        }
    }
#endif
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 484 of file nsWinReg.cpp.

{
    HKEY    root, newkey;
    LONG    result;
    PRBool  keyExists     = PR_FALSE;

#ifdef WIN32
    nsCAutoString subkey;

    if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) )
        return PR_FALSE;

    root   = (HKEY)mRootKey;
    result = RegOpenKeyEx(root, subkey.get(), 0, KEY_READ, &newkey);
    switch(result)
    {
        case ERROR_SUCCESS:
            RegCloseKey(newkey);
            keyExists = PR_TRUE;
            break;

        case ERROR_FILE_NOT_FOUND:
        case ERROR_ACCESS_DENIED:
        default:
            break;
    }
#endif

    return keyExists;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::NativeSetValue ( const nsString subkey,
const nsString valname,
nsWinRegValue value 
) [private]

Definition at line 842 of file nsWinReg.cpp.

{
#if defined (WIN32) || defined (XP_OS2)
    HKEY    root;
    HKEY    newkey;
    LONG    result;
    DWORD   length;
    DWORD   type;
    unsigned char* data;
    nsCAutoString subkey;
    nsCAutoString valname;

    if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
         NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
        return nsnull;

    root   = (HKEY) mRootKey;
    result = RegOpenKeyEx( root, subkey.get(), 0, KEY_WRITE, &newkey );

    if(ERROR_SUCCESS == result)
    {
        type = (DWORD)aValue->type;
        data = (unsigned char*)aValue->data;
        length = (DWORD)aValue->data_length;

        result = RegSetValueEx( newkey, valname.get(), 0, type, data, length);
        RegCloseKey( newkey );
    }

    return result;
#else
    return ERROR_INVALID_PARAMETER;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::NativeSetValueNumber ( const nsString subkey,
const nsString valname,
PRInt32  value 
) [private]

Definition at line 778 of file nsWinReg.cpp.

{
    HKEY    root;
    HKEY    newkey;
    LONG    result;
    nsCAutoString subkey;
    nsCAutoString valname;

    if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
         NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
        return nsInstall::UNEXPECTED_ERROR;

    root   = (HKEY) mRootKey;
    result = RegOpenKeyEx( root, subkey.get(), 0, KEY_WRITE, &newkey);

    if(ERROR_SUCCESS == result)
    {
        result = RegSetValueEx( newkey, valname.get(), 0, REG_DWORD, (LPBYTE)&aValue, sizeof(PRInt32));
        RegCloseKey( newkey );
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::NativeSetValueString ( const nsString subkey,
const nsString valname,
const nsString value 
) [private]

Definition at line 703 of file nsWinReg.cpp.

{
    HKEY    root;
    HKEY    newkey;
    LONG    result;
    DWORD   length;

    nsCAutoString subkey;
    nsCAutoString valname;
    nsCAutoString value;

    if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
         NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) ||
         NS_FAILED( NS_CopyUnicodeToNative(aValue, value) ) )
        return nsInstall::UNEXPECTED_ERROR;

    length = value.Length();

    root   = (HKEY) mRootKey;
    result = RegOpenKeyEx( root, subkey.get(), 0, KEY_WRITE, &newkey);

    if(ERROR_SUCCESS == result)
    {
        result = RegSetValueEx( newkey, valname.get(), 0, REG_SZ, (unsigned char*)value.get(), length );
        RegCloseKey( newkey );
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsWinReg::NativeValueExists ( const nsString subkey,
const nsString valname 
) [private]

Definition at line 516 of file nsWinReg.cpp.

{
    HKEY          root;
    HKEY          newkey;
    LONG          result;
    PRBool        valueExists = PR_FALSE;
    DWORD         length      = _MAXKEYVALUE_;
    unsigned char valbuf[_MAXKEYVALUE_];
    
#ifdef WIN32
    nsCAutoString subkey;
    nsCAutoString valname;

    if ( NS_FAILED( NS_CopyUnicodeToNative(aSubkey, subkey) ) ||
         NS_FAILED( NS_CopyUnicodeToNative(aValname, valname) ) )
        return PR_FALSE;

    root   = (HKEY) mRootKey;
    result = RegOpenKeyEx(root, subkey.get(), 0, KEY_READ, &newkey);
    switch(result)
    {
        case ERROR_SUCCESS:
            result = RegQueryValueEx(newkey,
                                     valname.get(),
                                     0,
                                     NULL,
                                     valbuf,
                                     &length);
            switch(result)
            {
                case ERROR_SUCCESS:
                    valueExists = PR_TRUE;
                    break;

                case ERROR_FILE_NOT_FOUND:
                case ERROR_ACCESS_DENIED:
                default:
                    break;
            }
            RegCloseKey(newkey);
            break;

        case ERROR_FILE_NOT_FOUND:
        case ERROR_ACCESS_DENIED:
        default:
            break;
    }
#endif

    return valueExists;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::PrepareCreateKey ( PRInt32  root,
const nsString subkey,
PRInt32 aReturn 
)

Definition at line 333 of file nsWinReg.cpp.

{
  SetRootKey(root);
  if(NativeIsKeyWritable(subkey))
    *aReturn = nsInstall::SUCCESS;
  else
    *aReturn = nsInstall::KEY_ACCESS_DENIED;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::PrepareDeleteKey ( PRInt32  root,
const nsString subkey,
PRInt32 aReturn 
)

Definition at line 347 of file nsWinReg.cpp.

{
  SetRootKey(root);
  if(NativeKeyExists(subkey))
  {
    if(NativeIsKeyWritable(subkey))
      *aReturn = nsInstall::SUCCESS;
    else
      *aReturn = nsInstall::KEY_ACCESS_DENIED;
  }
  else
    *aReturn = nsInstall::KEY_DOES_NOT_EXIST;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::PrepareDeleteValue ( PRInt32  root,
const nsString subkey,
const nsString valname,
PRInt32 aReturn 
)

Definition at line 366 of file nsWinReg.cpp.

{
  SetRootKey(root);
  if(NativeValueExists(subkey, valname))
  {
    if(NativeIsKeyWritable(subkey))
      *aReturn = nsInstall::SUCCESS;
    else
      *aReturn = nsInstall::KEY_ACCESS_DENIED;
  }
  else
    *aReturn = nsInstall::VALUE_DOES_NOT_EXIST;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::PrepareSetValue ( PRInt32  root,
const nsString subkey,
PRInt32 aReturn 
)

Definition at line 414 of file nsWinReg.cpp.

{
  SetRootKey(root);
  if(NativeIsKeyWritable(subkey))
    *aReturn = nsInstall::SUCCESS;
  else
    *aReturn = nsInstall::KEY_ACCESS_DENIED;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::PrepareSetValueNumber ( PRInt32  root,
const nsString subkey,
PRInt32 aReturn 
)

Definition at line 400 of file nsWinReg.cpp.

{
  SetRootKey(root);
  if(NativeIsKeyWritable(subkey))
    *aReturn = nsInstall::SUCCESS;
  else
    *aReturn = nsInstall::KEY_ACCESS_DENIED;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::PrepareSetValueString ( PRInt32  root,
const nsString subkey,
PRInt32 aReturn 
)

Definition at line 386 of file nsWinReg.cpp.

{
  SetRootKey(root);
  if(NativeIsKeyWritable(subkey))
    *aReturn = nsInstall::SUCCESS;
  else
    *aReturn = nsInstall::KEY_ACCESS_DENIED;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 62 of file nsWinReg.cpp.

{
       mRootKey = key;
    return NS_OK;
}

Here is the caller graph for this function:

PRInt32 nsWinReg::SetValue ( const nsString subkey,
const nsString valname,
nsWinRegValue value,
PRInt32 aReturn 
)

Definition at line 281 of file nsWinReg.cpp.

{
  // fix: need to figure out what to do with nsWinRegValue class.
  //
       // nsWinRegItem* wi = new nsWinRegItem(this, mRootKey, NS_WIN_REG_SET_VAL, subkey, valname, (nsWinRegValue*)value, aReturn);
  //
       // if(wi == nsnull)
  // {
  //   return NS_OK;
  // }
       // mInstallObject->ScheduleForInstall(wi);
       return 0;
}
PRInt32 nsWinReg::SetValueNumber ( const nsString subkey,
const nsString valname,
PRInt32  value,
PRInt32 aReturn 
)

Definition at line 249 of file nsWinReg.cpp.

{
       nsWinRegItem* wi = new nsWinRegItem(this, mRootKey, NS_WIN_REG_SET_VAL_NUMBER, subkey, valname, value, aReturn);

  if(wi == nsnull)
  {
    *aReturn = nsInstall::OUT_OF_MEMORY;
    return NS_OK;
  }

  if(*aReturn != nsInstall::SUCCESS)
  {
    if(wi)
    {
      delete wi;
      return NS_OK;
    }
  }

  if(mInstallObject)
    *aReturn = mInstallObject->ScheduleForInstall(wi);

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::SetValueString ( const nsAString &  subkey,
const nsAString &  valname,
const nsAString &  value,
PRInt32 aReturn 
)

Definition at line 147 of file nsWinReg.cpp.

{
       nsWinRegItem* wi = new nsWinRegItem(this, mRootKey, NS_WIN_REG_SET_VAL_STRING, subkey, valname, value, aReturn);

  if(wi == nsnull)
  {
    *aReturn = nsInstall::OUT_OF_MEMORY;
    return NS_OK;
  }

  if(*aReturn != nsInstall::SUCCESS)
  {
    if(wi)
    {
      delete wi;
      return NS_OK;
    }
  }

  if(mInstallObject)
    *aReturn = mInstallObject->ScheduleForInstall(wi);
       
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinReg::ValueExists ( const nsString subkey,
const nsString valname,
PRInt32 aReturn 
)

Definition at line 316 of file nsWinReg.cpp.

{
  *aReturn = NativeValueExists(subkey, valname);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 122 of file nsWinReg.h.

Definition at line 121 of file nsWinReg.h.


The documentation for this class was generated from the following files: