Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes
nsMailMacIntegration Class Reference

#include <nsMailMacIntegration.h>

Inheritance diagram for nsMailMacIntegration:
Inheritance graph
[legend]
Collaboration diagram for nsMailMacIntegration:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSISHELLSERVICE 
nsMailMacIntegration ()
boolean isDefaultClient (in boolean aStartupCheck, in unsigned short aApps)
 Determines whether or not Thunderbird is the "Default Client" for the passed in app type.
void setDefaultClient (in boolean aForAllUsers, in unsigned short aApps)
 Registers Thunderbird as the "Default Mail Client" for the passed in app type.

Public Attributes

const unsigned short MAIL = 0x0001
 app types we can be registered to handle
const unsigned short NEWS = 0x0002
const unsigned short RSS = 0x0004
attribute boolean shouldCheckDefaultClient
 Used to determine whether or not to show a "Set Default Client" query dialog.

Protected Member Functions

PRBool isDefaultHandlerForProtocol (CFStringRef aScheme)
nsresult setAsDefaultHandlerForProtocol (CFStringRef aScheme)

Private Member Functions

virtual ~nsMailMacIntegration ()

Private Attributes

PRBool mCheckedThisSession

Detailed Description

Definition at line 51 of file nsMailMacIntegration.h.


Constructor & Destructor Documentation

Definition at line 65 of file nsMailMacIntegration.cpp.

virtual nsMailMacIntegration::~nsMailMacIntegration ( ) [inline, private, virtual]

Definition at line 63 of file nsMailMacIntegration.h.

{};

Member Function Documentation

boolean nsIShellService::isDefaultClient ( in boolean  aStartupCheck,
in unsigned short  aApps 
) [inherited]

Determines whether or not Thunderbird is the "Default Client" for the passed in app type.

This is simply whether or not Thunderbid is registered to handle the url scheme associatd with the app.

Parameters:
aStartupChecktrue if this is the check being performed by the first mail window at startup, false otherwise.
aAppsthe application types being tested (Mail, News, RSS, etc.)
PRBool nsMailMacIntegration::isDefaultHandlerForProtocol ( CFStringRef  aScheme) [protected]

Definition at line 123 of file nsMailMacIntegration.cpp.

{
  PRBool isDefault = PR_FALSE;
  // Since neither Launch Services nor Internet Config actually differ between 
  // bundles which have the same bundle identifier (That is, if we set our
  // URL of our bundle as the default handler for the given protocol,
  // Launch Service might return the URL of another thunderbird bundle as the
  // defualt handler for that protocol), we are comparing the identifiers of the
  // bundles rather than their URLs.

  CFStringRef tbirdID = ::CFBundleGetIdentifier(CFBundleGetMainBundle());
  if (!tbirdID) {
    // CFBundleGetIdentifier is expected to return NULL only if the specified
    // bundle doesn't have a bundle identifier in its dictionary. In this case,
    // that means a failure, since our bundle does have an identifier.
    return isDefault;
  }

  ::CFRetain(tbirdID);

  // Get the default handler URL of the given protocol
  CFURLRef defaultHandlerURL;
  OSStatus err = ::_LSCopyDefaultSchemeHandlerURL(aScheme,
                                                  &defaultHandlerURL);

  nsresult rv = NS_ERROR_FAILURE;
  if (err == noErr) {
    // Get a reference to the bundle (based on its URL)
    CFBundleRef defaultHandlerBundle = ::CFBundleCreate(NULL, 
                                                        defaultHandlerURL);
    if (defaultHandlerBundle) {
      CFStringRef defaultHandlerID =
        ::CFBundleGetIdentifier(defaultHandlerBundle);
      if (defaultHandlerID) {
        ::CFRetain(defaultHandlerID);
        // and compare it to our bundle identifier
        isDefault = ::CFStringCompare(tbirdID, defaultHandlerID, 0)
                       == kCFCompareEqualTo;
        ::CFRelease(defaultHandlerID);
      }
      else {
        // If the bundle doesn't have an identifier in its info property list,
        // it's not our bundle.
        isDefault = PR_FALSE;
      }

      ::CFRelease(defaultHandlerBundle);
    }

    ::CFRelease(defaultHandlerURL);
  }
  else {
    // If |_LSCopyDefaultSchemeHandlerURL| failed, there's no default
    // handler for the given protocol
    isDefault = PR_FALSE;
  }

  ::CFRelease(tbirdID);
  return isDefault;
}

Here is the call graph for this function:

nsresult nsMailMacIntegration::setAsDefaultHandlerForProtocol ( CFStringRef  aScheme) [protected]

Definition at line 185 of file nsMailMacIntegration.cpp.

{
  CFURLRef tbirdURL = ::CFBundleCopyBundleURL(CFBundleGetMainBundle());

  ::_LSSetDefaultSchemeHandlerURL(aScheme, tbirdURL);
  ::_LSSaveAndRefresh();
  ::CFRelease(tbirdURL);

  return NS_OK;
}

Here is the call graph for this function:

void nsIShellService::setDefaultClient ( in boolean  aForAllUsers,
in unsigned short  aApps 
) [inherited]

Registers Thunderbird as the "Default Mail Client" for the passed in app type.

Parameters:
aForAllUsersWhether or not Thunderbird should attempt to become the default client for all users on a multi-user system.
aAppsthe application types being tested (Mail, News, RSS, etc.)

Member Data Documentation

const unsigned short nsIShellService::MAIL = 0x0001 [inherited]

app types we can be registered to handle

Definition at line 47 of file nsIShellService.idl.

Definition at line 63 of file nsMailMacIntegration.h.

const unsigned short nsIShellService::NEWS = 0x0002 [inherited]

Definition at line 48 of file nsIShellService.idl.

const unsigned short nsIShellService::RSS = 0x0004 [inherited]

Definition at line 49 of file nsIShellService.idl.

Used to determine whether or not to show a "Set Default Client" query dialog.

This attribute is true if the application is starting up and "mail.shell.checkDefaultClient" is true, otherwise it is false.

Definition at line 82 of file nsIShellService.idl.


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