Back to index

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

#include <nsMessengerUnixIntegration.h>

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

List of all members.

Public Member Functions

 nsMessengerUnixIntegration ()
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 ShowAlertMessage (const PRUnichar *aAlertTitle, const PRUnichar *aAlertText, const char *aFolderURI)
nsresult GetFirstFolderWithNewMail (char **aFolderURI)
nsresult GetStringBundle (nsIStringBundle **aBundle)
nsresult AlertFinished ()
nsresult AlertClicked ()
void FillToolTipInfo ()

Private Attributes

nsCOMPtr< nsISupportsArraymFoldersWithNewMail
nsCOMPtr< nsIAtommBiffStateAtom
PRBool mAlertInProgress

Detailed Description

Definition at line 57 of file nsMessengerUnixIntegration.h.


Constructor & Destructor Documentation

Definition at line 122 of file nsMessengerUnixIntegration.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 276 of file nsMessengerUnixIntegration.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);

    domWindow->Focus();
  }
#else
  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 270 of file nsMessengerUnixIntegration.cpp.

Here is the caller graph for this function:

Definition at line 316 of file nsMessengerUnixIntegration.cpp.

{
  nsCOMPtr<nsIWeakReference> weakReference = do_QueryElementAt(mFoldersWithNewMail, 0);
  nsCOMPtr<nsIMsgFolder> folder = do_QueryReferent(weakReference);
  if (folder)
  {
    nsXPIDLString accountName;
    folder->GetPrettiestName(getter_Copies(accountName));

    nsCOMPtr<nsIStringBundle> bundle; 
    GetStringBundle(getter_AddRefs(bundle));
    if (bundle)
    { 
      PRInt32 numNewMessages = 0;   
      folder->GetNumNewMessages(PR_TRUE, &numNewMessages);
      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));

#ifndef MOZ_THUNDERBIRD
      ShowAlertMessage(accountName, finalText, "");
#else
      ShowNewAlertNotification(PR_FALSE);
#endif
    } // if we got a bundle
  } // if we got a folder
}

Here is the call graph for this function:

Definition at line 356 of file nsMessengerUnixIntegration.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 163 of file nsMessengerUnixIntegration.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 132 of file nsMessengerUnixIntegration.cpp.

{
  nsresult rv;

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

  rv = mailSession->AddFolderListener(this, nsIFolderListener::intPropertyChanged);
  NS_ENSURE_SUCCESS(rv,rv);

  return NS_OK;
}

Here is the call 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]
nsresult nsMessengerUnixIntegration::ShowAlertMessage ( const PRUnichar aAlertTitle,
const PRUnichar aAlertText,
const char *  aFolderURI 
) [private]

Definition at line 176 of file nsMessengerUnixIntegration.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_ConvertASCIItoUTF16(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:


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 86 of file nsMessengerUnixIntegration.h.

Definition at line 85 of file nsMessengerUnixIntegration.h.

Definition at line 84 of file nsMessengerUnixIntegration.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.

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: