Back to index

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

List of all members.

Public Member Functions

 SavedRegistryEntry (HKEY baseKey, const char *keyName, const char *valueName, const char *setting)
nsresult set ()
nsresult reset ()
PRBool isAlreadySet () const
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 172 of file nsWindowsHooksUtil.cpp.


Constructor & Destructor Documentation

SavedRegistryEntry::SavedRegistryEntry ( HKEY  baseKey,
const char *  keyName,
const char *  valueName,
const char *  setting 
) [inline]

Definition at line 173 of file nsWindowsHooksUtil.cpp.

Here is the caller graph for this function:


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:

Reimplemented from RegistryEntry.

Reimplemented in FileTypeRegistryEntry, DDERegistryEntry, and ProtocolRegistryEntry.

Definition at line 560 of file nsWindowsHooksUtil.cpp.

                                   {
    nsresult result = NS_OK;

    // Get current setting for this key/value.
    nsCAutoString current( currentSetting() );

    // Test if we "own" it.
    if ( current == setting ) {
        // Unset it, then.  First get saved value it had previously.
        PRBool noSavedValue = PR_TRUE;
        RegistryEntry saved = RegistryEntry( HKEY_LOCAL_MACHINE, mozillaKeyName, fullName().get(), "" );
        // There are 3 cases:
        //    - no saved entry
        //    - empty saved entry
        //    - a non-empty saved entry
        // We delete the current entry in the first case, and restore
        // the saved entry (empty or otherwise) in the other two.
        setting = saved.currentSetting( &noSavedValue );
        if ( !setting.IsEmpty() || !noSavedValue ) {
            // Set to previous value.
            isNull = PR_FALSE; // Since we're resetting and the saved value may be empty, we
                               // need to make sure set() doesn't mistakenly delete this entry.
            result = RegistryEntry::set();
            // Remove saved entry.
            saved.reset();
        } else {
            // No saved value, just delete this entry.
            result = RegistryEntry::reset();
        }
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from RegistryEntry.

Reimplemented in EditableFileTypeRegistryEntry, FileTypeRegistryEntry, DDERegistryEntry, and ProtocolRegistryEntry.

Definition at line 407 of file nsWindowsHooksUtil.cpp.

                                 {
    nsresult rv = NS_OK;
    PRBool   currentlyUndefined = PR_TRUE;
    nsCAutoString prev( currentSetting( &currentlyUndefined ) );
    // See if value is changing.
    // We need an extra check for the case where we have an empty entry
    // and we need to remove it entirely.
    if ( setting != prev || ( !currentlyUndefined && isNull ) ) {
        // Set new.
        rv = RegistryEntry::set();
        if ( NS_SUCCEEDED( rv ) ) {
            // Save old.
            RegistryEntry tmp( HKEY_LOCAL_MACHINE, "Software\\Mozilla\\Desktop", fullName().get(), prev.get() );
            tmp.set();
        }
    }
    return rv;
}

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: