Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions | Static Protected Member Functions | Static Protected Attributes
CMimeTypes Class Reference

#include <MapiMimeTypes.h>

List of all members.

Static Public Member Functions

static PRUint8GetMimeType (nsCString &theExt)

Static Protected Member Functions

static BOOL GetKey (HKEY root, LPCTSTR pName, PHKEY pKey)
static BOOL GetValueBytes (HKEY rootKey, LPCTSTR pValName, LPBYTE *ppBytes)
static void ReleaseValueBytes (LPBYTE pBytes)
static BOOL GetMimeTypeFromReg (const nsCString &ext, LPBYTE *ppBytes)

Static Protected Attributes

static PRUint8 m_mimeBuffer [kMaxMimeTypeSize]

Detailed Description

Definition at line 45 of file MapiMimeTypes.h.


Member Function Documentation

BOOL CMimeTypes::GetKey ( HKEY  root,
LPCTSTR  pName,
PHKEY  pKey 
) [static, protected]

Definition at line 46 of file MapiMimeTypes.cpp.

{
       LONG result = RegOpenKeyEx( root, pName, 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, pKey);
       return (result == ERROR_SUCCESS);
}

Here is the caller graph for this function:

PRUint8 * CMimeTypes::GetMimeType ( nsCString theExt) [static]

Definition at line 95 of file MapiMimeTypes.cpp.

{
       nsCString     ext = theExt;
       if (ext.Length()) {
              if (ext.First() != '.') {
                     ext = ".";
                     ext += theExt;
              }
       }
       
       
       BOOL   result = FALSE;  
       int           len;

       if (!ext.Length())
              return( NULL);
       LPBYTE pByte;
       if (GetMimeTypeFromReg( ext, &pByte)) {
              len = strlen( (const char *) pByte);
              if (len && (len < kMaxMimeTypeSize)) {
                     memcpy( m_mimeBuffer, pByte, len);
                     m_mimeBuffer[len] = 0;
                     result = TRUE;
              }
              ReleaseValueBytes( pByte);
       }

       if (result)
              return( m_mimeBuffer);

       return( NULL);
}

Here is the call graph for this function:

BOOL CMimeTypes::GetMimeTypeFromReg ( const nsCString ext,
LPBYTE ppBytes 
) [static, protected]

Definition at line 78 of file MapiMimeTypes.cpp.

{
       HKEY   extensionKey;
       BOOL   result = FALSE;


       *ppBytes = NULL;
       if (GetKey( HKEY_CLASSES_ROOT, ext.get(), &extensionKey)) {
              result = GetValueBytes( extensionKey, "Content Type", ppBytes);
              RegCloseKey( extensionKey);
       }
       
       return( result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMimeTypes::GetValueBytes ( HKEY  rootKey,
LPCTSTR  pValName,
LPBYTE ppBytes 
) [static, protected]

Definition at line 52 of file MapiMimeTypes.cpp.

{
       LONG   err;
       DWORD  bufSz;
       
       *ppBytes = NULL;
       // Get the installed directory
       err = RegQueryValueEx( rootKey, pValName, NULL, NULL, NULL, &bufSz); 
       if (err == ERROR_SUCCESS) {
              *ppBytes = new BYTE[bufSz];
              err = RegQueryValueEx( rootKey, pValName, NULL, NULL, *ppBytes, &bufSz);
              if (err == ERROR_SUCCESS) {
                     return( TRUE);
              }
              delete *ppBytes;
              *ppBytes = NULL;
       }
       return( FALSE);
}

Here is the caller graph for this function:

void CMimeTypes::ReleaseValueBytes ( LPBYTE  pBytes) [static, protected]

Definition at line 72 of file MapiMimeTypes.cpp.

{
       if (pBytes)
              delete pBytes;
}

Here is the caller graph for this function:


Member Data Documentation

PRUint8 CMimeTypes::m_mimeBuffer [static, protected]

Definition at line 58 of file MapiMimeTypes.h.


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