Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes
BoolRegistryEntry Struct Reference
Inheritance diagram for BoolRegistryEntry:
Inheritance graph
[legend]
Collaboration diagram for BoolRegistryEntry:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 BoolRegistryEntry (const char *name)
 operator PRBool ()
PRBool isAlreadySet () const
nsresult set ()
nsresult reset ()
nsCString currentSetting (PRBool *currentUndefined=0) const
const char * valueNameArg () const
nsCString fullName () const

Public Attributes

HKEY baseKey
PRBool isNull
nsCString keyName
nsCString valueName
nsCString setting

Detailed Description

Definition at line 161 of file nsWindowsHooksUtil.cpp.


Constructor & Destructor Documentation

BoolRegistryEntry::BoolRegistryEntry ( const char *  name) [inline]

Definition at line 162 of file nsWindowsHooksUtil.cpp.


Member Function Documentation

nsCString RegistryEntry::currentSetting ( PRBool currentUndefined = 0) const [inherited]

Definition at line 725 of file nsWindowsHooksUtil.cpp.

                                                                          {
    nsCString result;

    if ( currentlyUndefined ) {
        *currentlyUndefined = PR_TRUE;
    }

    HKEY   key;
    LONG   rc = ::RegOpenKey( baseKey, keyName.get(), &key );
    if ( rc == ERROR_SUCCESS ) {
        if (!IsNT()) {
            char buffer[4096] = { 0 };
            DWORD len = sizeof buffer;
            rc = ::RegQueryValueExA( key, valueNameArg(), NULL, NULL,
                 (LPBYTE)buffer, &len );
            if ( rc == ERROR_SUCCESS ) {
                nsAutoString uResult;
                NS_CopyNativeToUnicode(nsDependentCString(buffer), uResult);
                CopyUTF16toUTF8(uResult, result);
                if ( currentlyUndefined ) {
                    *currentlyUndefined = PR_FALSE; // Indicate entry is present
                }
            }
        } else {
            PRUnichar buffer[4096] = { 0 };
            DWORD len = sizeof buffer;
            rc = ::RegQueryValueExW( key,
                 NS_ConvertASCIItoUTF16(valueNameArg()).get(), NULL, NULL,
                 (LPBYTE)buffer, &len );
            if ( rc == ERROR_SUCCESS ) {
                CopyUTF16toUTF8(buffer, result);
                if ( currentlyUndefined ) {
                    *currentlyUndefined = PR_FALSE; // Indicate entry is present
                }
            }
        }
        ::RegCloseKey( key );
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsCString RegistryEntry::fullName ( ) const [inherited]

Definition at line 302 of file nsWindowsHooksUtil.cpp.

                                        {
    nsCString result;
    if ( baseKey == HKEY_CURRENT_USER ) {
        result = "HKEY_CURRENT_USER\\";
    } else if ( baseKey == HKEY_LOCAL_MACHINE ) {
        result = "HKEY_LOCAL_MACHINE\\";
    } else {
        result = "\\";
    }
    result += keyName;
    if ( !valueName.IsEmpty() ) {
        result += "[";
        result += valueName;
        result += "]";
    }
    return result;
}

Here is the caller graph for this function:

PRBool RegistryEntry::isAlreadySet ( ) const [inherited]

Definition at line 321 of file nsWindowsHooksUtil.cpp.

                                         {
    PRBool result = FALSE;

    nsCAutoString current( currentSetting() );

    result = ( current == setting );

    return result;
}

Here is the call graph for this function:

BoolRegistryEntry::operator PRBool ( )

Definition at line 894 of file nsWindowsHooksUtil.cpp.

                                   {
    return currentSetting().Equals( "1" ) ? PR_TRUE : PR_FALSE;
}

Here is the call graph for this function:

nsresult RegistryEntry::reset ( ) [inherited]

Reimplemented in FileTypeRegistryEntry, DDERegistryEntry, ProtocolRegistryEntry, and SavedRegistryEntry.

Definition at line 545 of file nsWindowsHooksUtil.cpp.

                              {
    HKEY key;
    LONG rc = ::RegOpenKey( baseKey, keyName.get(), &key );
    if ( rc == ERROR_SUCCESS ) {
        rc = ::RegDeleteValue( key, valueNameArg() );
#ifdef DEBUG_law
if ( rc == ERROR_SUCCESS ) printf( "Deleting key=%s\n", (const char*)fullName().get() );
#endif
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult RegistryEntry::set ( ) [inherited]

Reimplemented in EditableFileTypeRegistryEntry, FileTypeRegistryEntry, DDERegistryEntry, ProtocolRegistryEntry, and SavedRegistryEntry.

Definition at line 332 of file nsWindowsHooksUtil.cpp.

                            {
#ifdef DEBUG_law
if ( isNull && setting.IsEmpty() ) printf( "Deleting %s\n", fullName().get() );
else printf( "Setting %s=%s\n", fullName().get(), setting.get() );
#endif
    nsresult result = NS_ERROR_FAILURE;

    HKEY   key;
    LONG   rc = ::RegOpenKey( baseKey, keyName.get(), &key );

    // See if key doesn't exist yet...
    if ( rc == ERROR_FILE_NOT_FOUND ) {
        rc = ::RegCreateKey( baseKey, keyName.get(), &key );
    }
    if ( rc == ERROR_SUCCESS ) {
        if ( isNull && setting.IsEmpty() ) {
            // This means we need to actually remove the value, not merely set it to an
            // empty string.
            rc = ::RegDeleteValue( key, valueNameArg() );
            if ( rc == ERROR_SUCCESS ) {
                result = NS_OK;
            }
        } else {
            NS_ConvertUTF8toUTF16 utf16Setting(setting);
            if (!IsNT()) {
                // Get current value to see if it is set properly already.
               char buffer[4096] = { 0 };
               DWORD len = sizeof buffer;
               rc = ::RegQueryValueExA( key, valueNameArg(), NULL, NULL,
                    (LPBYTE)buffer, &len );
               nsCAutoString cSetting;
               NS_CopyUnicodeToNative(utf16Setting, cSetting);
               if ( rc != ERROR_SUCCESS || !cSetting.Equals(buffer)) {
                   rc = ::RegSetValueExA( key, valueNameArg(), 0, REG_SZ,
                        (LPBYTE)cSetting.get(), cSetting.Length() );
#ifdef DEBUG_law
                   NS_WARN_IF_FALSE( rc == ERROR_SUCCESS, fullName().get() );
#endif
                   if ( rc == ERROR_SUCCESS ) {
                      result = NS_OK;
                   }
               } else {
                   // Already has desired setting.
                   result = NS_OK;
               }
           } else {
                // Get current value to see if it is set properly already.
               PRUnichar buffer[4096] = { 0 };
               DWORD len = sizeof buffer;
               NS_ConvertASCIItoUTF16 wValueName(valueNameArg());
               rc = ::RegQueryValueExW( key, wValueName.get(), NULL,
                    NULL, (LPBYTE)buffer, &len );
               if ( rc != ERROR_SUCCESS || !utf16Setting.Equals(buffer) ) {
                   rc = ::RegSetValueExW( key, wValueName.get(), 0, REG_SZ,
                        (LPBYTE) (utf16Setting.get()),
                        utf16Setting.Length() * 2);
                   if ( rc == ERROR_SUCCESS ) {
                      result = NS_OK;
                   }
               } else {
                   // Already has desired setting.
                   result = NS_OK;
               }
           }  // NT
        }
        ::RegCloseKey( key );
    } else {
#ifdef DEBUG_law
NS_WARN_IF_FALSE( rc == ERROR_SUCCESS, fullName().get() );
#endif
    }
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* RegistryEntry::valueNameArg ( ) const [inline, inherited]

Definition at line 148 of file nsWindowsHooksUtil.cpp.

                                     {
        return valueName.IsEmpty() ? NULL : valueName.get();
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 129 of file nsWindowsHooksUtil.cpp.

Definition at line 130 of file nsWindowsHooksUtil.cpp.

Definition at line 131 of file nsWindowsHooksUtil.cpp.

Definition at line 133 of file nsWindowsHooksUtil.cpp.

Definition at line 132 of file nsWindowsHooksUtil.cpp.


The documentation for this struct was generated from the following file: