Back to index

lightning-sunbird  0.9+nobinonly
Defines | Typedefs | Enumerations | Functions | Variables
nsMailWinIntegration.cpp File Reference
#include "nsMailWinIntegration.h"
#include "nsIServiceManager.h"
#include "nsICategoryManager.h"
#include "nsCRT.h"
#include "nsIStringBundle.h"
#include "nsNativeCharsetUtils.h"
#include "nsIPrefService.h"
#include "nsIMapiSupport.h"
#include "shlobj.h"
#include "windows.h"
#include "shellapi.h"
#include "nsILocalFile.h"
#include <mbstring.h>

Go to the source code of this file.

Defines

#define MAX_BUF   4096
#define REG_FAILED(val)   (val != ERROR_SUCCESS)
#define CLS   "SOFTWARE\\Classes\\"
#define MAILCLIENTS   "SOFTWARE\\Clients\\Mail\\"
#define NEWSCLIENTS   "SOFTWARE\\Clients\\News\\"
#define MOZ_CLIENT_MAIL_KEY   "Software\\Clients\\Mail"
#define MOZ_CLIENT_NEWS_KEY   "Software\\Clients\\News"
#define DI   "\\DefaultIcon"
#define II   "\\InstallInfo"
#define APP_REG_NAME_MAIL   L"Thunderbird"
#define APP_REG_NAME_NEWS   L"Thunderbird (News)"
#define CLS_EML   "ThunderbirdEML"
#define CLS_MAILTOURL   "Thunderbird.Url.mailto"
#define CLS_NEWSURL   "Thunderbird.Url.news"
#define CLS_FEEDURL   "Thunderbird.Url.feed"
#define SOP   "\\shell\\open\\command"
#define UNINSTALL_EXE   "\\uninstall\\helper.exe"
#define EXE   "thunderbird.exe"
#define VAL_ICON   "%APPPATH%,0"
#define VAL_OPEN   "\"%APPPATH%\" \"%1\""
#define MAKE_KEY_NAME1(PREFIX, MID)   PREFIX MID
#define MAKE_KEY_NAME2(PREFIX, MID, SUFFIX)   PREFIX MID SUFFIX

Typedefs

typedef enum tagASSOCIATIONLEVEL ASSOCIATIONLEVEL
typedef enum tagASSOCIATIONTYPE ASSOCIATIONTYPE

Enumerations

enum  SettingFlags {
  NO_SUBSTITUTION = 0x00, APP_PATH_SUBSTITUTION = 0x01, APPNAME_SUBSTITUTION = 0x02, UNINST_PATH_SUBSTITUTION = 0x04,
  MAPIDLL_PATH_SUBSTITUTION = 0x08, HKLM_ONLY = 0x10, USE_FOR_DEFAULT_TEST = 0x20
}
enum  tagASSOCIATIONLEVEL { AL_MACHINE, AL_EFFECTIVE, AL_USER }
enum  tagASSOCIATIONTYPE { AT_FILEEXTENSION, AT_URLPROTOCOL, AT_STARTMENUCLIENT, AT_MIMETYPE }

Functions

static nsresult OpenUserKeyForReading (HKEY aStartKey, const char *aKeyName, HKEY *aKey)
static nsresult OpenKeyForWriting (HKEY aStartKey, const char *aKeyName, HKEY *aKey, PRBool aHKLMOnly)
virtual HRESULT STDMETHODCALLTYPE QueryAppIsDefault (LPCWSTR pszQuery, ASSOCIATIONTYPE atQueryType, ASSOCIATIONLEVEL alQueryLevel, LPCWSTR pszAppRegistryName, BOOL *pfDefault)=0
virtual HRESULT STDMETHODCALLTYPE QueryAppIsDefaultAll (ASSOCIATIONLEVEL alQueryLevel, LPCWSTR pszAppRegistryName, BOOL *pfDefault)=0
virtual HRESULT STDMETHODCALLTYPE SetAppAsDefault (LPCWSTR pszAppRegistryName, LPCWSTR pszSet, ASSOCIATIONTYPE atSetType)=0
virtual HRESULT STDMETHODCALLTYPE SetAppAsDefaultAll (LPCWSTR pszAppRegistryName)=0
virtual HRESULT STDMETHODCALLTYPE ClearUserAssociations (void)=0

Variables

static SETTING gMailSettings []
static SETTING gNewsSettings []
static SETTING gFeedSettings []
IApplicationAssociationRegistration __pad0__
IApplicationAssociationRegistration
ASSOCIATIONTYPE 
atQueryType
IApplicationAssociationRegistration
ASSOCIATIONTYPE
ASSOCIATIONLEVEL 
alQueryLevel
IApplicationAssociationRegistration
ASSOCIATIONTYPE
ASSOCIATIONLEVEL LPWSTR
ppszAssociation = 0
static const CLSID CLSID_ApplicationAssociationReg = {0x591209C7,0x767B,0x42B2,{0x9F,0xBA,0x44,0xEE,0x46,0x15,0xF2,0xC7}}
static const IID IID_IApplicationAssociationReg = {0x4e530b0a,0xe611,0x4c77,{0xa3,0xac,0x90,0x31,0xd0,0x22,0x28,0x1b}}

Define Documentation

#define APP_REG_NAME_MAIL   L"Thunderbird"

Definition at line 146 of file nsMailWinIntegration.cpp.

#define APP_REG_NAME_NEWS   L"Thunderbird (News)"

Definition at line 147 of file nsMailWinIntegration.cpp.

#define CLS   "SOFTWARE\\Classes\\"

Definition at line 136 of file nsMailWinIntegration.cpp.

#define CLS_EML   "ThunderbirdEML"

Definition at line 148 of file nsMailWinIntegration.cpp.

#define CLS_FEEDURL   "Thunderbird.Url.feed"

Definition at line 151 of file nsMailWinIntegration.cpp.

#define CLS_MAILTOURL   "Thunderbird.Url.mailto"

Definition at line 149 of file nsMailWinIntegration.cpp.

#define CLS_NEWSURL   "Thunderbird.Url.news"

Definition at line 150 of file nsMailWinIntegration.cpp.

#define DI   "\\DefaultIcon"

Definition at line 141 of file nsMailWinIntegration.cpp.

#define EXE   "thunderbird.exe"

Definition at line 157 of file nsMailWinIntegration.cpp.

#define II   "\\InstallInfo"

Definition at line 142 of file nsMailWinIntegration.cpp.

#define MAILCLIENTS   "SOFTWARE\\Clients\\Mail\\"

Definition at line 137 of file nsMailWinIntegration.cpp.

#define MAKE_KEY_NAME1 (   PREFIX,
  MID 
)    PREFIX MID

Definition at line 162 of file nsMailWinIntegration.cpp.

#define MAKE_KEY_NAME2 (   PREFIX,
  MID,
  SUFFIX 
)    PREFIX MID SUFFIX

Definition at line 165 of file nsMailWinIntegration.cpp.

#define MAX_BUF   4096

Definition at line 56 of file nsMailWinIntegration.cpp.

#define MOZ_CLIENT_MAIL_KEY   "Software\\Clients\\Mail"

Definition at line 139 of file nsMailWinIntegration.cpp.

#define MOZ_CLIENT_NEWS_KEY   "Software\\Clients\\News"

Definition at line 140 of file nsMailWinIntegration.cpp.

#define NEWSCLIENTS   "SOFTWARE\\Clients\\News\\"

Definition at line 138 of file nsMailWinIntegration.cpp.

#define REG_FAILED (   val)    (val != ERROR_SUCCESS)

Definition at line 59 of file nsMailWinIntegration.cpp.

#define SOP   "\\shell\\open\\command"

Definition at line 152 of file nsMailWinIntegration.cpp.

#define UNINSTALL_EXE   "\\uninstall\\helper.exe"

Definition at line 156 of file nsMailWinIntegration.cpp.

#define VAL_ICON   "%APPPATH%,0"

Definition at line 159 of file nsMailWinIntegration.cpp.

#define VAL_OPEN   "\"%APPPATH%\" \"%1\""

Definition at line 160 of file nsMailWinIntegration.cpp.


Typedef Documentation


Enumeration Type Documentation

Enumerator:
NO_SUBSTITUTION 
APP_PATH_SUBSTITUTION 
APPNAME_SUBSTITUTION 
UNINST_PATH_SUBSTITUTION 
MAPIDLL_PATH_SUBSTITUTION 
HKLM_ONLY 
USE_FOR_DEFAULT_TEST 

Definition at line 128 of file nsMailWinIntegration.cpp.

Enumerator:
AL_MACHINE 
AL_EFFECTIVE 
AL_USER 

Definition at line 650 of file nsMailWinIntegration.cpp.

Enumerator:
AT_FILEEXTENSION 
AT_URLPROTOCOL 
AT_STARTMENUCLIENT 
AT_MIMETYPE 

Definition at line 657 of file nsMailWinIntegration.cpp.


Function Documentation

virtual HRESULT STDMETHODCALLTYPE ClearUserAssociations ( void  ) [pure virtual]
static nsresult OpenKeyForWriting ( HKEY  aStartKey,
const char *  aKeyName,
HKEY aKey,
PRBool  aHKLMOnly 
) [static]

Definition at line 91 of file nsMailWinIntegration.cpp.

{
  DWORD dwDisp = 0;
  DWORD rv = ::RegCreateKeyEx(aStartKey, aKeyName, 0, NULL, 0,
                              KEY_READ | KEY_WRITE, NULL, aKey, &dwDisp);

  switch (rv) 
  {
    case ERROR_SUCCESS:
      break;
    case ERROR_ACCESS_DENIED:
      if (aHKLMOnly || aStartKey == HKEY_CURRENT_USER)
        return NS_ERROR_FILE_ACCESS_DENIED;
      // fallback to HKCU immediately on access denied since we won't be able
      // to create the key.
      return OpenKeyForWriting(HKEY_CURRENT_USER, aKeyName, aKey, aHKLMOnly);
    case ERROR_FILE_NOT_FOUND:
      rv = ::RegCreateKey(aStartKey, aKeyName, aKey);
      if (rv != ERROR_SUCCESS)
      {
        if (aHKLMOnly || aStartKey == HKEY_CURRENT_USER) 
        {
          // prevent infinite recursion on the second pass through here if 
          // ::RegCreateKey fails in the current user case.
          return NS_ERROR_FILE_ACCESS_DENIED;
        }
        return OpenKeyForWriting(HKEY_CURRENT_USER, aKeyName, aKey, aHKLMOnly);
      }
  }

  return NS_OK;
}

Here is the caller graph for this function:

static nsresult OpenUserKeyForReading ( HKEY  aStartKey,
const char *  aKeyName,
HKEY aKey 
) [static]

Definition at line 65 of file nsMailWinIntegration.cpp.

{
  DWORD result = ::RegOpenKeyEx(aStartKey, aKeyName, 0, KEY_READ, aKey);

  switch (result) 
  {
    case ERROR_SUCCESS:
      break;
    case ERROR_ACCESS_DENIED:
      return NS_ERROR_FILE_ACCESS_DENIED;
    case ERROR_FILE_NOT_FOUND:
      if (aStartKey == HKEY_LOCAL_MACHINE) 
      {
        // prevent infinite recursion on the second pass through here if 
        // ::RegOpenKeyEx fails in the all-users case. 
        return NS_ERROR_NOT_AVAILABLE;
      }
      return OpenUserKeyForReading(HKEY_LOCAL_MACHINE, aKeyName, aKey);
  }
  return NS_OK;
}

Here is the caller graph for this function:

virtual HRESULT STDMETHODCALLTYPE QueryAppIsDefault ( LPCWSTR  pszQuery,
ASSOCIATIONTYPE  atQueryType,
ASSOCIATIONLEVEL  alQueryLevel,
LPCWSTR  pszAppRegistryName,
BOOL pfDefault 
) [pure virtual]
virtual HRESULT STDMETHODCALLTYPE QueryAppIsDefaultAll ( ASSOCIATIONLEVEL  alQueryLevel,
LPCWSTR  pszAppRegistryName,
BOOL pfDefault 
) [pure virtual]
virtual HRESULT STDMETHODCALLTYPE SetAppAsDefault ( LPCWSTR  pszAppRegistryName,
LPCWSTR  pszSet,
ASSOCIATIONTYPE  atSetType 
) [pure virtual]
virtual HRESULT STDMETHODCALLTYPE SetAppAsDefaultAll ( LPCWSTR  pszAppRegistryName) [pure virtual]

Variable Documentation

IApplicationAssociationRegistration __pad0__

Definition at line 669 of file nsMailWinIntegration.cpp.

IApplicationAssociationRegistration ASSOCIATIONTYPE ASSOCIATIONLEVEL alQueryLevel

Definition at line 669 of file nsMailWinIntegration.cpp.

IApplicationAssociationRegistration ASSOCIATIONTYPE atQueryType

Definition at line 669 of file nsMailWinIntegration.cpp.

const CLSID CLSID_ApplicationAssociationReg = {0x591209C7,0x767B,0x42B2,{0x9F,0xBA,0x44,0xEE,0x46,0x15,0xF2,0xC7}} [static]

Definition at line 689 of file nsMailWinIntegration.cpp.

SETTING gFeedSettings[] [static]
Initial value:

Definition at line 243 of file nsMailWinIntegration.cpp.

SETTING gMailSettings[] [static]

Definition at line 168 of file nsMailWinIntegration.cpp.

SETTING gNewsSettings[] [static]
Initial value:
 {
   
  { MAKE_KEY_NAME2(CLS, CLS_NEWSURL, DI),  "", VAL_ICON, APP_PATH_SUBSTITUTION },
  { MAKE_KEY_NAME2(CLS, CLS_NEWSURL, SOP), "", "\"%APPPATH%\" -osint -mail \"%1\"", APP_PATH_SUBSTITUTION },

  
  { MAKE_KEY_NAME2(CLS, "news", DI),  "", VAL_ICON, APP_PATH_SUBSTITUTION},
  { MAKE_KEY_NAME2(CLS, "news", SOP), "", "\"%APPPATH%\" -osint -mail \"%1\"", APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST},
  { MAKE_KEY_NAME2(CLS, "nntp", DI),  "", VAL_ICON, APP_PATH_SUBSTITUTION},
  { MAKE_KEY_NAME2(CLS, "nntp", SOP), "", "\"%APPPATH%\" -osint -mail \"%1\"", APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST}, 
  { MAKE_KEY_NAME2(CLS, "snews", DI),  "", VAL_ICON, APP_PATH_SUBSTITUTION},
  { MAKE_KEY_NAME2(CLS, "snews", SOP), "", "\"%APPPATH%\" -osint -mail \"%1\"", APP_PATH_SUBSTITUTION}, 

  
  { MAKE_KEY_NAME1(NEWSCLIENTS, "%APPNAME%"),  
    "DLLPath", 
    "%MAPIDLLPATH%", 
    MAPIDLL_PATH_SUBSTITUTION | APPNAME_SUBSTITUTION | HKLM_ONLY },
  { MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%", DI),  
    "", 
    "%APPPATH%,0", 
    APP_PATH_SUBSTITUTION | APPNAME_SUBSTITUTION | HKLM_ONLY },
  { MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%", SOP), 
    "", 
    "\"%APPPATH%\" -mail",   
    APP_PATH_SUBSTITUTION | APPNAME_SUBSTITUTION | HKLM_ONLY },
}

Definition at line 215 of file nsMailWinIntegration.cpp.

const IID IID_IApplicationAssociationReg = {0x4e530b0a,0xe611,0x4c77,{0xa3,0xac,0x90,0x31,0xd0,0x22,0x28,0x1b}} [static]

Definition at line 690 of file nsMailWinIntegration.cpp.

IApplicationAssociationRegistration ASSOCIATIONTYPE ASSOCIATIONLEVEL LPWSTR* ppszAssociation = 0

Definition at line 672 of file nsMailWinIntegration.cpp.