Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
nsMessengerWinIntegration.cpp File Reference
#include <windows.h>
#include <shellapi.h>
#include "nsMessengerWinIntegration.h"
#include "nsIMsgAccountManager.h"
#include "nsIMsgMailSession.h"
#include "nsIMsgIncomingServer.h"
#include "nsIMsgIdentity.h"
#include "nsIMsgAccount.h"
#include "nsIRDFResource.h"
#include "nsIMsgFolder.h"
#include "nsCOMPtr.h"
#include "nsMsgBaseCID.h"
#include "nsMsgFolderFlags.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsIDirectoryService.h"
#include "nsIWindowWatcher.h"
#include "nsIWindowMediator.h"
#include "nsIDOMWindowInternal.h"
#include "nsPIDOMWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocShell.h"
#include "nsIBaseWindow.h"
#include "nsIWidget.h"
#include "nsWidgetsCID.h"
#include "nsILookAndFeel.h"
#include "nsIMessengerWindowService.h"
#include "prprf.h"
#include "nsIWeakReference.h"
#include "nsIStringBundle.h"
#include "nsIAlertsService.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsISupportsPrimitives.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsNativeCharsetUtils.h"
#include "nsIProfile.h"

Go to the source code of this file.


#define XP_SHSetUnreadMailCounts   "SHSetUnreadMailCountW"
#define XP_SHEnumerateUnreadMailAccounts   "SHEnumerateUnreadMailAccountsW"
#define ShellNotifyWideVersion   "Shell_NotifyIconW"
#define NOTIFICATIONCLASSNAME   "MailBiffNotificationMessageWindow"
#define UNREADMAILNODEKEY   "Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\"
#define SHELL32_DLL   NS_LITERAL_CSTRING("shell32.dll")
#define DOUBLE_QUOTE   "\""
#define MAIL_COMMANDLINE_ARG   " -mail"
#define IDI_MAILBIFF   101
#define UNREAD_UPDATE_INTERVAL   (20 * 1000)
#define ALERT_CHROME_URL   "chrome://messenger/content/newmailalert.xul"
#define NEW_MAIL_ALERT_ICON   "chrome://messenger/skin/icons/new-mail-alert.png"
#define SHOW_ALERT_PREF   "mail.biff.show_alert"
#define SHOW_TRAY_ICON_PREF   "mail.biff.show_tray_icon"
#define MAIL_DLL_NAME   "msgbase.dll"


HWND hwndForDOMWindow (nsISupports *window)
static void activateWindow (nsIDOMWindowInternal *win)
static void openMailWindow (const PRUnichar *aMailWindowName, const char *aFolderUri)
static void CALLBACK delayedSingleClick (HWND msgWindow, UINT msg, INT_PTR idEvent, DWORD dwTime)
static long CALLBACK MessageWindowProc (HWND msgWindow, UINT msg, WPARAM wp, LPARAM lp)
static nsresult Create ()


static HWND msgWindow

Define Documentation

#define ALERT_CHROME_URL   "chrome://messenger/content/newmailalert.xul"

Definition at line 99 of file nsMessengerWinIntegration.cpp.

#define DOUBLE_QUOTE   "\""

Definition at line 95 of file nsMessengerWinIntegration.cpp.

#define IDI_MAILBIFF   101

Definition at line 97 of file nsMessengerWinIntegration.cpp.

#define MAIL_COMMANDLINE_ARG   " -mail"

Definition at line 96 of file nsMessengerWinIntegration.cpp.

#define MAIL_DLL_NAME   "msgbase.dll"

Definition at line 341 of file nsMessengerWinIntegration.cpp.

#define NEW_MAIL_ALERT_ICON   "chrome://messenger/skin/icons/new-mail-alert.png"

Definition at line 100 of file nsMessengerWinIntegration.cpp.

#define NOTIFICATIONCLASSNAME   "MailBiffNotificationMessageWindow"

Definition at line 92 of file nsMessengerWinIntegration.cpp.

Definition at line 86 of file nsMessengerWinIntegration.cpp.

#define SHELL32_DLL   NS_LITERAL_CSTRING("shell32.dll")

Definition at line 94 of file nsMessengerWinIntegration.cpp.

#define ShellNotifyWideVersion   "Shell_NotifyIconW"

Definition at line 91 of file nsMessengerWinIntegration.cpp.

#define SHOW_ALERT_PREF   "mail.biff.show_alert"

Definition at line 101 of file nsMessengerWinIntegration.cpp.

#define SHOW_TRAY_ICON_PREF   "mail.biff.show_tray_icon"

Definition at line 102 of file nsMessengerWinIntegration.cpp.

#define UNREAD_UPDATE_INTERVAL   (20 * 1000)

Definition at line 98 of file nsMessengerWinIntegration.cpp.

#define UNREADMAILNODEKEY   "Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\"

Definition at line 93 of file nsMessengerWinIntegration.cpp.

#define XP_SHEnumerateUnreadMailAccounts   "SHEnumerateUnreadMailAccountsW"

Definition at line 90 of file nsMessengerWinIntegration.cpp.

#define XP_SHSetUnreadMailCounts   "SHSetUnreadMailCountW"

Definition at line 89 of file nsMessengerWinIntegration.cpp.

Function Documentation

static void activateWindow ( nsIDOMWindowInternal win) [static]

Definition at line 126 of file nsMessengerWinIntegration.cpp.

  // Try to get native window handle.
  HWND hwnd = hwndForDOMWindow( win );
  if ( hwnd ) 
    // Restore the window if it is minimized.
    if ( ::IsIconic( hwnd ) ) 
      ::ShowWindow( hwnd, SW_RESTORE );
    // Use the OS call, if possible.
    ::SetForegroundWindow( hwnd );
  } else // Use internal method.  

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult Create ( ) [static]

Definition at line 226 of file nsMessengerWinIntegration.cpp.

  if (msgWindow)
    return NS_OK;

  WNDCLASS classStruct = { 0,                          // style
                           &MessageWindowProc,         // lpfnWndProc
                           0,                          // cbClsExtra
                           0,                          // cbWndExtra
                           0,                          // hInstance
                           0,                          // hIcon
                           0,                          // hCursor
                           0,                          // hbrBackground
                           0,                          // lpszMenuName
                           NOTIFICATIONCLASSNAME };    // lpszClassName

  // Register the window class.
  NS_ENSURE_TRUE( ::RegisterClass( &classStruct ), NS_ERROR_FAILURE );
  // Create the window.
                                              0,          // title
                                              WS_CAPTION, // style
                                              0,0,0,0,    // x, y, cx, cy
                                              0,          // parent
                                              0,          // menu
                                              0,          // instance
                                              0 ),        // create struct
                  NS_ERROR_FAILURE );
  return NS_OK;

Here is the call graph for this function:

static void CALLBACK delayedSingleClick ( HWND  msgWindow,
UINT  msg,
INT_PTR  idEvent,
DWORD  dwTime 
) [static]

Definition at line 181 of file nsMessengerWinIntegration.cpp.

  ::KillTimer(msgWindow, idEvent);

  // single clicks on the biff icon should re-open the alert notification
  nsresult rv = NS_OK;
  nsCOMPtr<nsIMessengerOSIntegration> integrationService = 
  if (NS_SUCCEEDED(rv))
    // we know we are dealing with the windows integration object    
    nsMessengerWinIntegration * winIntegrationService = NS_STATIC_CAST(nsMessengerWinIntegration*, 
                                                                       NS_STATIC_CAST(nsIMessengerOSIntegration*, integrationService.get()));

Here is the call graph for this function:

Here is the caller graph for this function:

HWND hwndForDOMWindow ( nsISupports *  window)

Definition at line 110 of file nsMessengerWinIntegration.cpp.

  nsCOMPtr<nsIScriptGlobalObject> ppScriptGlobalObj( do_QueryInterface(window) );
  if ( !ppScriptGlobalObj )
      return 0;
  nsCOMPtr<nsIBaseWindow> ppBaseWindow =
      do_QueryInterface( ppScriptGlobalObj->GetDocShell() );
  if (!ppBaseWindow) return 0;

  nsCOMPtr<nsIWidget> ppWidget;
  ppBaseWindow->GetMainWidget( getter_AddRefs( ppWidget ) );

  return (HWND)( ppWidget->GetNativeData( NS_NATIVE_WIDGET ) );

Here is the call graph for this function:

Here is the caller graph for this function:

static long CALLBACK MessageWindowProc ( HWND  msgWindow,
UINT  msg,
) [static]

Definition at line 201 of file nsMessengerWinIntegration.cpp.

  if (msg == WM_USER)
    if (lp == WM_LBUTTONDOWN)
      // the only way to tell a single left click 
      // from a double left click is to fire a timer which gets cleared if we end up getting
      // a WM_LBUTTONDBLK event.
      ::SetTimer(msgWindow, 1, GetDoubleClickTime(), (TIMERPROC) delayedSingleClick);
    else if (lp == WM_LBUTTONDBLCLK)
      ::KillTimer(msgWindow, 1);
      NS_NAMED_LITERAL_STRING(mailName, "mail:3pane");
      openMailWindow(mailName.get(), nsnull);

  return TRUE;

Here is the call graph for this function:

Here is the caller graph for this function:

static void openMailWindow ( const PRUnichar aMailWindowName,
const char *  aFolderUri 
) [static]

Definition at line 142 of file nsMessengerWinIntegration.cpp.

  nsCOMPtr<nsIWindowMediator> mediator ( do_GetService(NS_WINDOWMEDIATOR_CONTRACTID) );
  if (!mediator)

  nsCOMPtr<nsIDOMWindowInternal> domWindow;
  mediator->GetMostRecentWindow(aMailWindowName, getter_AddRefs(domWindow));
  if (domWindow)
    if (aFolderUri)
      nsCOMPtr<nsPIDOMWindow> piDOMWindow(do_QueryInterface(domWindow));
      if (piDOMWindow)
        nsCOMPtr<nsISupports> xpConnectObj;
        piDOMWindow->GetObjectProperty(NS_LITERAL_STRING("MsgWindowCommands").get(), getter_AddRefs(xpConnectObj));
        nsCOMPtr<nsIMsgWindowCommands> msgWindowCommands = do_QueryInterface(xpConnectObj);
        if (msgWindowCommands)

    // the user doesn't have a mail window open already so open one for them...
    nsCOMPtr<nsIMessengerWindowService> messengerWindowService =
    // if we want to preselect the first account with new mail,
    // here is where we would try to generate a uri to pass in
    // (and add code to the messenger window service to make that work)
    if (messengerWindowService)
                                "mail:3pane", aFolderUri, nsMsgKey_None);

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

HWND msgWindow [static]

Definition at line 223 of file nsMessengerWinIntegration.cpp.