Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Events | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
nsMessengerWinIntegration Class Reference

#include <nsMessengerWinIntegration.h>

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

List of all members.

Public Member Functions

 nsMessengerWinIntegration ()
virtual ~nsMessengerWinIntegration ()
virtual nsresult Init ()
void OnItemAdded (in nsIRDFResource parentItem, in nsISupports item)
void OnItemRemoved (in nsIRDFResource parentItem, in nsISupports item)
void OnItemPropertyChanged (in nsIRDFResource item, in nsIAtom property, in string oldValue, in string newValue)
void OnItemIntPropertyChanged (in nsIRDFResource item, in nsIAtom property, in long oldValue, in long newValue)
void OnItemBoolPropertyChanged (in nsIRDFResource item, in nsIAtom property, in boolean oldValue, in boolean newValue)
void OnItemUnicharPropertyChanged (in nsIRDFResource item, in nsIAtom property, in wstring oldValue, in wstring newValue)
void OnItemPropertyFlagChanged (in nsIMsgDBHdr item, in nsIAtom property, in unsigned long oldFlag, in unsigned long newFlag)
void OnItemEvent (in nsIMsgFolder item, in nsIAtom event)
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Public Attributes

const folderListenerNotifyFlagValue added = 0x1
const folderListenerNotifyFlagValue removed = 0x2
const folderListenerNotifyFlagValue propertyChanged = 0x4
const folderListenerNotifyFlagValue intPropertyChanged = 0x8
const folderListenerNotifyFlagValue boolPropertyChanged = 0x10
const folderListenerNotifyFlagValue unicharPropertyChanged = 0x20
const folderListenerNotifyFlagValue propertyFlagChanged = 0x40

Events

const
folderListenerNotifyFlagValue=0 
x80
const folderListenerNotifyFlagValue all = 0xFFFFFFFF

Private Member Functions

nsresult AlertFinished ()
nsresult AlertClicked ()
void InitializeBiffStatusIcon ()
void FillToolTipInfo ()
void GenericShellNotify (DWORD aMessage)
void SetToolTipStringOnIconData (const PRUnichar *aToolTipString)
void DestroyBiffIcon ()
void RevertToNonUnicodeShellAPI ()
PRUint32 GetToolTipSize ()
nsresult ShowAlertMessage (const PRUnichar *aAlertTitle, const PRUnichar *aAlertText, const char *aFolderURI)
nsresult GetFirstFolderWithNewMail (char **aFolderURI)
nsresult GetStringBundle (nsIStringBundle **aBundle)
nsresult ResetCurrent ()
nsresult RemoveCurrentFromRegistry ()
nsresult UpdateRegistryWithCurrent ()
nsresult SetupInbox ()
nsresult SetupUnreadCountUpdateTimer ()
nsresult UpdateUnreadCount ()

Static Private Member Functions

static void OnUnreadCountUpdateTimer (nsITimer *timer, void *osIntegration)

Private Attributes

nsCOMPtr< nsISupportsArraymFoldersWithNewMail
fnShellNotifyW mShellNotifyWideChar
nsCOMPtr< nsIAtommBiffStateAtom
PRUint32 mCurrentBiffState
PRPackedBool mUseWideCharBiffIcon
PRPackedBool mStoreUnreadCounts
PRPackedBool mBiffIconVisible
PRPackedBool mBiffIconInitialized
PRPackedBool mSuppressBiffIcon
PRPackedBool mAlertInProgress
PRPackedBool mDefaultAccountMightHaveAnInbox
PRPackedBool mUnreadTimerActive
nsCOMPtr< nsIAtommDefaultServerAtom
nsCOMPtr< nsIAtommTotalUnreadMessagesAtom
nsCOMPtr< nsITimermUnreadCountUpdateTimer
fnSHSetUnreadMailCount mSHSetUnreadMailCount
fnSHEnumerateUnreadMailAccounts mSHEnumerateUnreadMailAccounts
char * mInboxURI
char * mEmail
nsAutoString mAppName
nsAutoString mEmailPrefix
nsCString mShellDllPath
nsXPIDLString mProfileName
PRInt32 mCurrentUnreadCount
PRInt32 mLastUnreadCountWrittenToRegistry

Static Private Attributes

static NOTIFYICONDATAW sWideBiffIconData
static NOTIFYICONDATA sNativeBiffIconData

Detailed Description

Definition at line 74 of file nsMessengerWinIntegration.h.


Constructor & Destructor Documentation

Definition at line 277 of file nsMessengerWinIntegration.cpp.

{
  if (mUnreadCountUpdateTimer) {
    mUnreadCountUpdateTimer->Cancel();
    mUnreadCountUpdateTimer = nsnull;
  }

  // one last attempt, update the registry
  nsresult rv = UpdateRegistryWithCurrent();
  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to update registry on shutdown");
  
  CRTFREEIF(mInboxURI);
  CRTFREEIF(mEmail);

  DestroyBiffIcon(); 
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 622 of file nsMessengerWinIntegration.cpp.

{
#ifdef MOZ_THUNDERBIRD
  nsresult rv;
  nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);
  nsCOMPtr<nsIMsgWindow> topMostMsgWindow;
  rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(topMostMsgWindow));
  if (topMostMsgWindow)
  {
    nsCOMPtr<nsIDocShell> rootDocShell;
    rv = topMostMsgWindow->GetRootDocShell(getter_AddRefs(rootDocShell));
    NS_ENSURE_SUCCESS(rv, rv);
    
    nsCOMPtr<nsIDOMWindowInternal> domWindow(do_GetInterface(rootDocShell, &rv));
    NS_ENSURE_SUCCESS(rv, rv);
    
    activateWindow(domWindow);
  }
#else
  // make sure we don't insert the icon in the system tray since the user clicked on the alert.
  mSuppressBiffIcon = PR_TRUE;

  nsXPIDLCString folderURI;
  GetFirstFolderWithNewMail(getter_Copies(folderURI));

  openMailWindow(NS_LITERAL_STRING("mail:3pane").get(), folderURI);
#endif
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 601 of file nsMessengerWinIntegration.cpp.

{
  // okay, we are done showing the alert
  // now put an icon in the system tray, if allowed
  PRBool showTrayIcon = !mSuppressBiffIcon;
  if (showTrayIcon)
  {
    nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
    if (prefBranch)
      prefBranch->GetBoolPref(SHOW_TRAY_ICON_PREF, &showTrayIcon);
  }
  if (showTrayIcon)
  {
    GenericShellNotify(NIM_ADD);
    mBiffIconVisible = PR_TRUE;
  }
  mSuppressBiffIcon = PR_FALSE;
  mAlertInProgress = PR_FALSE;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 800 of file nsMessengerWinIntegration.cpp.

{
  GenericShellNotify(NIM_DELETE); 
  // Don't call DestroyIcon().  see http://bugzilla.mozilla.org/show_bug.cgi?id=134745
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 665 of file nsMessengerWinIntegration.cpp.

{
  // iterate over all the folders in mFoldersWithNewMail
  nsXPIDLString accountName;
  nsXPIDLCString hostName; 
  nsAutoString toolTipText;
  nsAutoString animatedAlertText;
  nsCOMPtr<nsIMsgFolder> folder;
  nsCOMPtr<nsIWeakReference> weakReference;
  PRInt32 numNewMessages = 0;

  PRUint32 count = 0;
  mFoldersWithNewMail->Count(&count);
  PRUint32 maxTooltipSize = GetToolTipSize();

  for (PRUint32 index = 0; index < count; index++)
  {
    weakReference = do_QueryElementAt(mFoldersWithNewMail, index);
    folder = do_QueryReferent(weakReference);
    if (folder)
    {
      folder->GetPrettiestName(getter_Copies(accountName));

      numNewMessages = 0;   
      folder->GetNumNewMessages(PR_TRUE, &numNewMessages);
      nsCOMPtr<nsIStringBundle> bundle; 
      GetStringBundle(getter_AddRefs(bundle));
      if (bundle)
      { 
        nsAutoString numNewMsgsText;     
        numNewMsgsText.AppendInt(numNewMessages);

        const PRUnichar *formatStrings[] =
        {
          numNewMsgsText.get(),       
        };
       
        nsXPIDLString finalText; 
        if (numNewMessages == 1)
          bundle->FormatStringFromName(NS_LITERAL_STRING("biffNotification_message").get(), formatStrings, 1, getter_Copies(finalText));
        else
          bundle->FormatStringFromName(NS_LITERAL_STRING("biffNotification_messages").get(), formatStrings, 1, getter_Copies(finalText));

        // the alert message is special...we actually only want to show the first account with 
        // new mail in the alert. 
        if (animatedAlertText.IsEmpty()) // if we haven't filled in the animated alert text yet
          animatedAlertText = finalText;

        // only add this new string if it will fit without truncation....
        if (maxTooltipSize >= toolTipText.Length() + accountName.Length() + finalText.Length() + 2)
        {
           if (index > 0)
            toolTipText.Append(NS_LITERAL_STRING("\n").get());
          toolTipText.Append(accountName);
          toolTipText.AppendLiteral(" ");
                    toolTipText.Append(finalText);
        }
      } // if we got a bundle
    } // if we got a folder
  } // for each folder

  SetToolTipStringOnIconData(toolTipText.get());

  if (!mBiffIconVisible)
  {
#ifndef MOZ_THUNDERBIRD
    ShowAlertMessage(accountName, animatedAlertText.get(), "");
#else
    ShowNewAlertNotification(PR_FALSE);
#endif
  }
  else
   GenericShellNotify( NIM_MODIFY);
}

Here is the call graph for this function:

Definition at line 838 of file nsMessengerWinIntegration.cpp.

{
  if (mUseWideCharBiffIcon)
  {
    BOOL res = mShellNotifyWideChar( aMessage, &sWideBiffIconData );
    if (!res)
      RevertToNonUnicodeShellAPI(); // oops we don't really implement the unicode shell apis...fall back.
    else
      return; 
  }
  
  ::Shell_NotifyIcon( aMessage, &sNativeBiffIconData ); 
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 742 of file nsMessengerWinIntegration.cpp.

{
  nsresult rv;
  NS_ENSURE_TRUE(mFoldersWithNewMail, NS_ERROR_FAILURE); 

  nsCOMPtr<nsIMsgFolder> folder;
  nsCOMPtr<nsIWeakReference> weakReference;
  PRInt32 numNewMessages = 0;

  PRUint32 count = 0;
  mFoldersWithNewMail->Count(&count);

  if (!count)  // kick out if we don't have any folders with new mail
    return NS_OK;

  weakReference = do_QueryElementAt(mFoldersWithNewMail, 0);
  folder = do_QueryReferent(weakReference);
  
  if (folder)
  {
    nsCOMPtr<nsIMsgFolder> msgFolder;
    // enumerate over the folders under this root folder till we find one with new mail....
    nsCOMPtr<nsISupportsArray> allFolders;
    NS_NewISupportsArray(getter_AddRefs(allFolders));
    rv = folder->ListDescendents(allFolders);
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIEnumerator> enumerator;
    allFolders->Enumerate(getter_AddRefs(enumerator));
    if (enumerator)
    {
      nsCOMPtr<nsISupports> supports;
      nsresult more = enumerator->First();
      while (NS_SUCCEEDED(more))
      {
        rv = enumerator->CurrentItem(getter_AddRefs(supports));
        if (supports)
        {                   
          msgFolder = do_QueryInterface(supports, &rv);
          if (msgFolder)
          {
            numNewMessages = 0;   
            msgFolder->GetNumNewMessages(PR_FALSE, &numNewMessages);
            if (numNewMessages)
              break; // kick out of the while loop
            more = enumerator->Next();
          }
        } // if we have a folder
      }  // if we have more potential folders to enumerate
    }  // if enumerator
    
    if (msgFolder)
      msgFolder->GetURI(aFolderURI);
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 475 of file nsMessengerWinIntegration.cpp.

{
  nsresult rv = NS_OK;
  NS_ENSURE_ARG_POINTER(aBundle);
  nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
  nsCOMPtr<nsIStringBundle> bundle;
  if (bundleService && NS_SUCCEEDED(rv))
    bundleService->CreateBundle("chrome://messenger/locale/messenger.properties", getter_AddRefs(bundle));
  NS_IF_ADDREF(*aBundle = bundle);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 806 of file nsMessengerWinIntegration.cpp.

{
  if (mUseWideCharBiffIcon)
    return (sizeof(sWideBiffIconData.szTip)/sizeof(sWideBiffIconData.szTip[0]));
  else
    return (sizeof(sNativeBiffIconData.szTip));
}

Here is the caller graph for this function:

Definition at line 366 of file nsMessengerWinIntegration.cpp.

{
  nsresult rv;

  // get directory service to build path for shell dll
  nsCOMPtr<nsIProperties> directoryService = 
    do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);

  // get path strings needed for unread mail count update
  nsCOMPtr<nsIFile> systemDir;
  rv = directoryService->Get(NS_OS_SYSTEM_DIR, 
                             NS_GET_IID(nsIFile), 
                             getter_AddRefs(systemDir));
  NS_ENSURE_SUCCESS(rv,rv);

  // get path to shell dll.
  nsCAutoString shellFile;
  rv = systemDir->GetNativePath(shellFile);
  NS_ENSURE_SUCCESS(rv,rv);

  mShellDllPath.Assign(shellFile + NS_LITERAL_CSTRING("\\") + SHELL32_DLL);

  // load shell dll. If no such dll found, return 
  HMODULE hModule = ::LoadLibrary(mShellDllPath.get());
  if (!hModule)
    return NS_OK;

  // get process addresses for the unread mail count functions
  if (hModule) {
    mSHSetUnreadMailCount = (fnSHSetUnreadMailCount)GetProcAddress(hModule, XP_SHSetUnreadMailCounts);
    mSHEnumerateUnreadMailAccounts = (fnSHEnumerateUnreadMailAccounts)GetProcAddress(hModule, XP_SHEnumerateUnreadMailAccounts);
    mShellNotifyWideChar = (fnShellNotifyW)GetProcAddress(hModule, ShellNotifyWideVersion);
    if (mShellNotifyWideChar)
       mUseWideCharBiffIcon = PR_TRUE; // this version of the shell supports I18N friendly ShellNotify routines.
  }

  // if failed to get either of the process addresses, this is not XP platform
  // so we aren't storing unread counts
  if (mSHSetUnreadMailCount && mSHEnumerateUnreadMailAccounts)
    mStoreUnreadCounts = PR_TRUE; 

  nsCOMPtr <nsIMsgAccountManager> accountManager = 
    do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);

  // because we care if the default server changes
  rv = accountManager->AddRootFolderListener(this);
  NS_ENSURE_SUCCESS(rv,rv);

  nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);

  // because we care if the unread total count changes
  rv = mailSession->AddFolderListener(this, nsIFolderListener::boolPropertyChanged | nsIFolderListener::intPropertyChanged);
  NS_ENSURE_SUCCESS(rv,rv);

  if (mStoreUnreadCounts)
  {
#ifdef MOZ_THUNDERBIRD
    // get current profile path for the commandliner
    nsCOMPtr<nsIFile> profilePath;
    rv = directoryService->Get(NS_APP_USER_PROFILE_50_DIR, 
                               NS_GET_IID(nsIFile), 
                               getter_AddRefs(profilePath));
    NS_ENSURE_SUCCESS(rv,rv);

    rv = profilePath->GetPath(mProfilePath);
    NS_ENSURE_SUCCESS(rv, rv);
#else
    // get current profile name to fill in commandliner. 
    nsCOMPtr<nsIProfile> profileService = do_GetService(NS_PROFILE_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv,rv);

    profileService->GetCurrentProfile(getter_Copies(mProfileName));
#endif

    // get application path 
    char appPath[_MAX_PATH] = {0};
    GetModuleFileName(nsnull, appPath, sizeof(appPath));
    WCHAR wideFormatAppPath[_MAX_PATH*2] = {0};
    MultiByteToWideChar(CP_ACP, 0, appPath, strlen(appPath), wideFormatAppPath, _MAX_PATH*2);
    mAppName.Assign((PRUnichar *)wideFormatAppPath);

    rv = ResetCurrent();
    NS_ENSURE_SUCCESS(rv,rv);
  }

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 344 of file nsMessengerWinIntegration.cpp.

{
  // initialize our biff status bar icon 
  Create();

  if (mUseWideCharBiffIcon)
  {
    sWideBiffIconData.hWnd = (HWND) msgWindow;
    sWideBiffIconData.hIcon =  ::LoadIcon( ::GetModuleHandle( MAIL_DLL_NAME ), MAKEINTRESOURCE(IDI_MAILBIFF) );
    sWideBiffIconData.szTip[0] = 0;
  }
  else
  {
    sNativeBiffIconData.hWnd = (HWND) msgWindow;
    sNativeBiffIconData.hIcon =  ::LoadIcon( ::GetModuleHandle( MAIL_DLL_NAME ), MAKEINTRESOURCE(IDI_MAILBIFF) );
    sNativeBiffIconData.szTip[0] = 0;
  }

  mBiffIconInitialized = PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
void nsIFolderListener::OnItemAdded ( in nsIRDFResource  parentItem,
in nsISupports  item 
) [inherited]

Here is the caller graph for this function:

void nsIFolderListener::OnItemBoolPropertyChanged ( in nsIRDFResource  item,
in nsIAtom  property,
in boolean  oldValue,
in boolean  newValue 
) [inherited]

Here is the caller graph for this function:

void nsIFolderListener::OnItemEvent ( in nsIMsgFolder  item,
in nsIAtom  event 
) [inherited]

Here is the caller graph for this function:

void nsIFolderListener::OnItemIntPropertyChanged ( in nsIRDFResource  item,
in nsIAtom  property,
in long  oldValue,
in long  newValue 
) [inherited]

Here is the caller graph for this function:

void nsIFolderListener::OnItemPropertyChanged ( in nsIRDFResource  item,
in nsIAtom  property,
in string  oldValue,
in string  newValue 
) [inherited]
void nsIFolderListener::OnItemPropertyFlagChanged ( in nsIMsgDBHdr  item,
in nsIAtom  property,
in unsigned long  oldFlag,
in unsigned long  newFlag 
) [inherited]

Here is the caller graph for this function:

void nsIFolderListener::OnItemRemoved ( in nsIRDFResource  parentItem,
in nsISupports  item 
) [inherited]
void nsIFolderListener::OnItemUnicharPropertyChanged ( in nsIRDFResource  item,
in nsIAtom  property,
in wstring  oldValue,
in wstring  newValue 
) [inherited]
void nsMessengerWinIntegration::OnUnreadCountUpdateTimer ( nsITimer timer,
void osIntegration 
) [static, private]

Definition at line 1007 of file nsMessengerWinIntegration.cpp.

{
  nsMessengerWinIntegration *winIntegration = (nsMessengerWinIntegration*)osIntegration;

  winIntegration->mUnreadTimerActive = PR_FALSE;
  nsresult rv = winIntegration->UpdateUnreadCount();
  NS_ASSERTION(NS_SUCCEEDED(rv), "updating unread count failed");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1017 of file nsMessengerWinIntegration.cpp.

{
  if (!mStoreUnreadCounts) return NS_OK; // don't do anything here if we aren't storing unread counts...

  // If Windows XP, open the registry and get rid of old account registry entries
  // If there is a email prefix, get it and use it to build the registry key.
  // Otherwise, just the email address will be the registry key.
  nsAutoString currentUnreadMailCountKey;
  if (!mEmailPrefix.IsEmpty()) {
    currentUnreadMailCountKey.Assign(mEmailPrefix);
    currentUnreadMailCountKey.AppendWithConversion(mEmail);
  }
  else {
    currentUnreadMailCountKey.AssignWithConversion(mEmail);
  }


  WCHAR registryUnreadMailCountKey[_MAX_PATH] = {0};
  // Enumerate through registry entries to delete the key matching 
  // currentUnreadMailCountKey
  int index = 0;
  while (SUCCEEDED(mSHEnumerateUnreadMailAccounts(HKEY_CURRENT_USER, 
                                                  index, 
                                                  registryUnreadMailCountKey, 
                                                  sizeof(registryUnreadMailCountKey))))
  {
    if (wcscmp(registryUnreadMailCountKey, currentUnreadMailCountKey.get())==0) {
      nsAutoString deleteKey;
      deleteKey.Assign(NS_LITERAL_STRING(UNREADMAILNODEKEY).get());
      deleteKey.Append(currentUnreadMailCountKey.get());

      if (!deleteKey.IsEmpty()) {
        // delete this key and berak out of the loop
        RegDeleteKey(HKEY_CURRENT_USER, 
                     NS_ConvertUCS2toUTF8(deleteKey).get());
        break;
      }
      else {
        index++;
      }
    }
    else {
      index++;
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 306 of file nsMessengerWinIntegration.cpp.

Here is the caller graph for this function:

Definition at line 855 of file nsMessengerWinIntegration.cpp.

{
  mUseWideCharBiffIcon = PR_FALSE;

  // now initialize the ascii shell notify struct
  InitializeBiffStatusIcon();

  // now we need to copy over any left over tool tip strings
  if (sWideBiffIconData.szTip)
  {
    const PRUnichar * oldTooltipString = sWideBiffIconData.szTip;
    SetToolTipStringOnIconData(oldTooltipString);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 814 of file nsMessengerWinIntegration.cpp.

{
  if (!aToolTipString) return;

  PRUint32 toolTipBufSize = GetToolTipSize();
  
  if (mUseWideCharBiffIcon)
  {
    ::wcsncpy( sWideBiffIconData.szTip, aToolTipString, toolTipBufSize);
    if (wcslen(aToolTipString) >= toolTipBufSize)
      sWideBiffIconData.szTip[toolTipBufSize - 1] = 0;
  }
  else
  {
    nsCAutoString nativeToolTipString;
    NS_CopyUnicodeToNative(nsDependentString(aToolTipString),
                           nativeToolTipString);
    ::strncpy(sNativeBiffIconData.szTip,
              nativeToolTipString.get(), GetToolTipSize());
    if (nativeToolTipString.Length() >= toolTipBufSize)
      sNativeBiffIconData.szTip[toolTipBufSize - 1] = 0;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1123 of file nsMessengerWinIntegration.cpp.

{
  nsresult rv;
  if (!mStoreUnreadCounts) return NS_OK; // don't do anything here if we aren't storing unread counts...

  // get default account
  nsCOMPtr <nsIMsgAccountManager> accountManager = 
    do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv); 
  NS_ENSURE_SUCCESS(rv,rv);

  nsCOMPtr <nsIMsgAccount> account;
  rv = accountManager->GetDefaultAccount(getter_AddRefs(account));
  if (NS_FAILED(rv)) {
    // this can happen if we launch mail on a new profile
    // we don't have a default account yet
    mDefaultAccountMightHaveAnInbox = PR_FALSE;
    return NS_OK;
  }

  // get incoming server
  nsCOMPtr <nsIMsgIncomingServer> server;
  rv = account->GetIncomingServer(getter_AddRefs(server));
  NS_ENSURE_SUCCESS(rv,rv);

  nsXPIDLCString type;
  rv = server->GetType(getter_Copies(type));
  NS_ENSURE_SUCCESS(rv,rv);

  // we only care about imap and pop3
  if (!(nsCRT::strcmp(type.get(), "imap")) ||
      !(nsCRT::strcmp(type.get(), "pop3"))) {
    // imap and pop3 account should have an Inbox
    mDefaultAccountMightHaveAnInbox = PR_TRUE;

    // get the redirector type, use it to get the prefix
    // todo remove this extra copy
    nsXPIDLCString redirectorType;
    server->GetRedirectorType(getter_Copies(redirectorType));

    if (redirectorType) {
      nsCAutoString providerPrefixPref;
      providerPrefixPref.Assign("mail.");
      providerPrefixPref.Append(redirectorType);
      providerPrefixPref.Append(".unreadMailCountRegistryKeyPrefix");

      // get pref service
      nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
      NS_ENSURE_SUCCESS(rv,rv);

      nsCOMPtr<nsISupportsString> tmp;
      rv = prefBranch->GetComplexValue(providerPrefixPref.get(), NS_GET_IID(nsISupportsString),
                                       getter_AddRefs(tmp));

      if (NS_SUCCEEDED(rv))
        tmp->GetData(mEmailPrefix);
      else
        mEmailPrefix.Truncate();
    }
    else {
      mEmailPrefix.Truncate();
    }

    // Get user's email address
    nsCOMPtr<nsIMsgIdentity> identity;
    rv = account->GetDefaultIdentity(getter_AddRefs(identity));
    NS_ENSURE_SUCCESS(rv,rv);
 
    if (!identity)
      return NS_ERROR_FAILURE;
 
    rv = identity->GetEmail(&mEmail);
    NS_ENSURE_SUCCESS(rv,rv);
    
    nsCOMPtr<nsIMsgFolder> rootMsgFolder;
    rv = server->GetRootMsgFolder(getter_AddRefs(rootMsgFolder));
    NS_ENSURE_SUCCESS(rv,rv);
 
    if (!rootMsgFolder)
      return NS_ERROR_FAILURE;
 
    PRUint32 numFolders = 0;
    nsCOMPtr <nsIMsgFolder> inboxFolder;
    rv = rootMsgFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_INBOX, 1, &numFolders, getter_AddRefs(inboxFolder));
    NS_ENSURE_SUCCESS(rv,rv);
 
    if (!inboxFolder)
     return NS_ERROR_FAILURE;
 
    rv = inboxFolder->GetURI(&mInboxURI);
    NS_ENSURE_SUCCESS(rv,rv);

    rv = inboxFolder->GetNumUnread(PR_FALSE, &mCurrentUnreadCount);
    NS_ENSURE_SUCCESS(rv,rv);
  }
  else {
    // the default account is valid, but it's not something 
    // that we expect to have an inbox.  (local folders, news accounts)
    // set this flag to avoid calling SetupInbox() every time
    // the timer goes off.
    mDefaultAccountMightHaveAnInbox = PR_FALSE;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1246 of file nsMessengerWinIntegration.cpp.

{
  if (!mStoreUnreadCounts) return NS_OK; // don't do anything here if we aren't storing unread counts...
  mUnreadTimerActive = PR_TRUE;
  if (mUnreadCountUpdateTimer) {
    mUnreadCountUpdateTimer->Cancel();
  }
  else
  {
    mUnreadCountUpdateTimer = do_CreateInstance("@mozilla.org/timer;1");
  }

  mUnreadCountUpdateTimer->InitWithFuncCallback(OnUnreadCountUpdateTimer,
    (void *)this, UNREAD_UPDATE_INTERVAL, nsITimer::TYPE_ONE_SHOT);

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsMessengerWinIntegration::ShowAlertMessage ( const PRUnichar aAlertTitle,
const PRUnichar aAlertText,
const char *  aFolderURI 
) [private]

Definition at line 488 of file nsMessengerWinIntegration.cpp.

{
  nsresult rv;
  
  // if we are already in the process of showing an alert, don't try to show another....
  if (mAlertInProgress) 
    return NS_OK; 

  nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
  PRBool showAlert = PR_TRUE;
  
  if (prefBranch)
    prefBranch->GetBoolPref(SHOW_ALERT_PREF, &showAlert);
  
  if (showAlert)
  {
    nsCOMPtr<nsIAlertsService> alertsService (do_GetService(NS_ALERTSERVICE_CONTRACTID, &rv));
    if (NS_SUCCEEDED(rv))
    {
      rv = alertsService->ShowAlertNotification(NS_LITERAL_STRING(NEW_MAIL_ALERT_ICON), nsDependentString(aAlertTitle),
                                                nsDependentString(aAlertText), PR_TRUE, 
                                                NS_ConvertASCIItoUCS2(aFolderURI), this); 
      mAlertInProgress = PR_TRUE;
    }
  }

  if (!showAlert || NS_FAILED(rv)) // go straight to showing the system tray icon.
    AlertFinished();

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1066 of file nsMessengerWinIntegration.cpp.

{
  if (!mStoreUnreadCounts) return NS_OK; // don't do anything here if we aren't storing unread counts...

  if (!mInboxURI || !mEmail) 
    return NS_OK;

  // only update the registry if the count has changed
  // and if the unread count is valid
  if ((mCurrentUnreadCount < 0) || (mCurrentUnreadCount == mLastUnreadCountWrittenToRegistry)) {
    return NS_OK;
  }

  // commandliner has to be built in the form of statement
  // which can be open the mailer app to the default user account
  // For given profile 'foo', commandliner will be built as 
  // ""<absolute path to application>" -p foo -mail" where absolute
  // path to application is extracted from mAppName
  nsAutoString commandLinerForAppLaunch;
  commandLinerForAppLaunch.Assign(NS_LITERAL_STRING(DOUBLE_QUOTE));
  commandLinerForAppLaunch.Append(mAppName);
  commandLinerForAppLaunch.Append(NS_LITERAL_STRING(DOUBLE_QUOTE));
  commandLinerForAppLaunch.Append(NS_LITERAL_STRING(PROFILE_COMMANDLINE_ARG));
#ifdef MOZ_THUNDERBIRD
  commandLinerForAppLaunch.Append(NS_LITERAL_STRING(DOUBLE_QUOTE));
  commandLinerForAppLaunch.Append(mProfilePath);
  commandLinerForAppLaunch.Append(NS_LITERAL_STRING(DOUBLE_QUOTE));
#else
  commandLinerForAppLaunch.Append(mProfileName);
#endif
  commandLinerForAppLaunch.Append(NS_LITERAL_STRING(MAIL_COMMANDLINE_ARG));

  if (!commandLinerForAppLaunch.IsEmpty())
  {
    nsAutoString pBuffer;

    if (!mEmailPrefix.IsEmpty()) {
      pBuffer.Assign(mEmailPrefix);
      pBuffer.AppendWithConversion(mEmail);
    }
    else {
      pBuffer.AssignWithConversion(mEmail);
    }

    // Write the info into the registry
    HRESULT hr = mSHSetUnreadMailCount(pBuffer.get(), 
                                       mCurrentUnreadCount, 
                                       commandLinerForAppLaunch.get());
  }

  // do this last
  mLastUnreadCountWrittenToRegistry = mCurrentUnreadCount;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1229 of file nsMessengerWinIntegration.cpp.

{
  nsresult rv;
  if (!mStoreUnreadCounts) return NS_OK; // don't do anything here if we aren't storing unread counts...

  if (mDefaultAccountMightHaveAnInbox && !mInboxURI) {
    rv = SetupInbox();
    NS_ENSURE_SUCCESS(rv,rv);
  }
  
  rv = UpdateRegistryWithCurrent();
  NS_ENSURE_SUCCESS(rv,rv);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 49 of file nsIFolderListener.idl.

Definition at line 69 of file nsIFolderListener.idl.

Definition at line 63 of file nsIFolderListener.idl.

Definition at line 124 of file nsMessengerWinIntegration.h.

Definition at line 152 of file nsMessengerWinIntegration.h.

Definition at line 122 of file nsMessengerWinIntegration.h.

Definition at line 121 of file nsMessengerWinIntegration.h.

Definition at line 115 of file nsMessengerWinIntegration.h.

Definition at line 116 of file nsMessengerWinIntegration.h.

Definition at line 163 of file nsMessengerWinIntegration.h.

Definition at line 128 of file nsMessengerWinIntegration.h.

Definition at line 142 of file nsMessengerWinIntegration.h.

Definition at line 150 of file nsMessengerWinIntegration.h.

Definition at line 153 of file nsMessengerWinIntegration.h.

Definition at line 113 of file nsMessengerWinIntegration.h.

Definition at line 149 of file nsMessengerWinIntegration.h.

Definition at line 164 of file nsMessengerWinIntegration.h.

Definition at line 159 of file nsMessengerWinIntegration.h.

Definition at line 154 of file nsMessengerWinIntegration.h.

Definition at line 114 of file nsMessengerWinIntegration.h.

Definition at line 147 of file nsMessengerWinIntegration.h.

Definition at line 146 of file nsMessengerWinIntegration.h.

Definition at line 119 of file nsMessengerWinIntegration.h.

Definition at line 123 of file nsMessengerWinIntegration.h.

Definition at line 143 of file nsMessengerWinIntegration.h.

Definition at line 144 of file nsMessengerWinIntegration.h.

Definition at line 131 of file nsMessengerWinIntegration.h.

Definition at line 118 of file nsMessengerWinIntegration.h.

Definition at line 57 of file nsIFolderListener.idl.

Definition at line 81 of file nsIFolderListener.idl.

Definition at line 53 of file nsIFolderListener.idl.

NOTIFYICONDATA nsMessengerWinIntegration::sNativeBiffIconData [static, private]
Initial value:
 { sizeof(NOTIFYICONDATA),
                                                    0,
                                                    2,
                                                    NIF_ICON | NIF_MESSAGE | NIF_TIP,
                                                    WM_USER,
                                                    0,
                                                    0 }

Definition at line 97 of file nsMessengerWinIntegration.h.

NOTIFYICONDATAW nsMessengerWinIntegration::sWideBiffIconData [static, private]
Initial value:
 { sizeof(NOTIFYICONDATAW),
                                                    0,
                                                    2,
                                                    NIF_ICON | NIF_MESSAGE | NIF_TIP,
                                                    WM_USER,
                                                    0,
                                                    0 }

Definition at line 96 of file nsMessengerWinIntegration.h.

Definition at line 75 of file nsIFolderListener.idl.


Event Documentation

Definition at line 90 of file nsIFolderListener.idl.

Definition at line 87 of file nsIFolderListener.idl.


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