Back to index

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

List of all members.

Public Member Functions

 FileTypeRegistryEntry (const char **ext, const char *fileType, const char *desc, const char *defDescKey, const char *iconFile)
nsresult set ()
nsresult reset ()
PRBool isAlreadySet () const
nsCString currentSetting (PRBool *currentUndefined=0) const
const char * valueNameArg () const
nsCString fullName () const

Public Attributes

nsCString fileType
const char ** ext
nsCString desc
nsCString defDescKey
nsCString iconFile
nsCString protocol
HKEY baseKey
PRBool isNull
nsCString keyName
nsCString valueName
nsCString setting

Detailed Description

Definition at line 271 of file nsWindowsHooksUtil.cpp.


Constructor & Destructor Documentation

FileTypeRegistryEntry::FileTypeRegistryEntry ( const char **  ext,
const char *  fileType,
const char *  desc,
const char *  defDescKey,
const char *  iconFile 
) [inline]

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 ProtocolRegistryEntry.

Definition at line 855 of file nsWindowsHooksUtil.cpp.

                                      {
    nsresult rv = ProtocolRegistryEntry::reset();

    for ( int i = 0; ext[ i ]; i++ ) {
        nsCAutoString thisExt( "Software\\Classes\\" );
        thisExt += ext[i];
        (void)SavedRegistryEntry( HKEY_LOCAL_MACHINE, thisExt.get(), "", fileType.get() ).reset();
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from ProtocolRegistryEntry.

Reimplemented in EditableFileTypeRegistryEntry.

Definition at line 769 of file nsWindowsHooksUtil.cpp.

                                    {
    nsresult rv = NS_OK;

    // Set file extensions.
    for ( int i = 0; NS_SUCCEEDED( rv ) && ext[i]; i++ ) {
        nsCAutoString thisExt( "Software\\Classes\\" );
        thisExt += ext[i];
        rv = SavedRegistryEntry( HKEY_LOCAL_MACHINE, thisExt.get(), "", fileType.get() ).set();
    }

    // If OK, set file type opener.
    if ( NS_SUCCEEDED( rv ) ) {
        rv = ProtocolRegistryEntry::set();

        // If we just created this file type entry, set description and default icon.
        if ( NS_SUCCEEDED( rv ) ) {
            nsCAutoString iconFileToUse( "%1" );
            nsCAutoString descKey( "Software\\Classes\\" );
            descKey += protocol;
            RegistryEntry descEntry( HKEY_LOCAL_MACHINE, descKey.get(), NULL, "" );
            if ( descEntry.currentSetting().IsEmpty() ) {
                nsCAutoString defaultDescKey( "Software\\Classes\\" );
                defaultDescKey += defDescKey;
                RegistryEntry defaultDescEntry( HKEY_LOCAL_MACHINE, defaultDescKey.get(), NULL, "" );

                descEntry.setting = defaultDescEntry.currentSetting();
                if ( descEntry.setting.IsEmpty() )
                    descEntry.setting = desc;
                descEntry.set();
            }
            nsCAutoString iconKey( "Software\\Classes\\" );
            iconKey += protocol;
            iconKey += "\\DefaultIcon";

            if ( !iconFile.Equals(iconFileToUse) ) {
            iconFileToUse = thisApplication() + NS_LITERAL_CSTRING( ",0" );

            // Check to see if there's an icon file name associated with this extension.
            // If there is, then we need to use this icon file.  If not, then we default
            // to the main app's icon.
            if ( !iconFile.IsEmpty() ) {
                nsCOMPtr<nsIFile> iconFileSpec;
                PRBool            flagExists;

                // Use the directory service to get the path to the chrome folder.  The
                // icons will be located in [chrome dir]\icons\default.
                // The abs path to the icon has to be in the short filename
                // format, else it won't work under win9x systems.
                rv = NS_GetSpecialDirectory( NS_APP_CHROME_DIR, getter_AddRefs( iconFileSpec ) );
                if ( NS_SUCCEEDED( rv ) ) {
                    iconFileSpec->AppendNative( NS_LITERAL_CSTRING( "icons" ) );
                    iconFileSpec->AppendNative( NS_LITERAL_CSTRING( "default" ) );
                    iconFileSpec->AppendNative( iconFile );

                    // Check to make sure that the icon file exists on disk.
                    iconFileSpec->Exists( &flagExists );
                    if ( flagExists ) {
                        rv = iconFileSpec->GetNativePath( iconFileToUse );
                        if ( NS_SUCCEEDED( rv ) ) {
                            TCHAR buffer[MAX_PATH];
                            DWORD len;

                            // Get the short path name (8.3) format for iconFileToUse
                            // else it won't work under win9x.
                            len = ::GetShortPathName( iconFileToUse.get(), buffer, sizeof buffer );
                            NS_ASSERTION ( (len > 0) && ( len < sizeof buffer ), "GetShortPathName failed!" );
                            iconFileToUse.Assign( buffer );
                            iconFileToUse.Append( NS_LITERAL_CSTRING( ",0" ) );
                        }
                        }
                    }
                }
            }

            RegistryEntry iconEntry( HKEY_LOCAL_MACHINE, iconKey.get(), NULL, iconFileToUse.get() );
            if( !iconEntry.currentSetting().Equals( iconFileToUse ) )
                iconEntry.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 275 of file nsWindowsHooksUtil.cpp.

Definition at line 274 of file nsWindowsHooksUtil.cpp.

Definition at line 273 of file nsWindowsHooksUtil.cpp.

Definition at line 272 of file nsWindowsHooksUtil.cpp.

Definition at line 276 of file nsWindowsHooksUtil.cpp.

Definition at line 130 of file nsWindowsHooksUtil.cpp.

Definition at line 131 of file nsWindowsHooksUtil.cpp.

Definition at line 188 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: