Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
nsMsgOfflineManager Class Reference

#include <nsMsgOfflineManager.h>

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

List of all members.

Public Types

enum  offlineManagerState {
  eStarting = 0, eSynchronizingOfflineImapChanges = 1, eDownloadingNews = 2, eDownloadingMail = 3,
  eSendingUnsent = 4, eDone = 5, eNoState = 6
}
enum  offlineManagerOperation { eGoingOnline = 0, eDownloadingForOffline = 1, eNoOp = 2 }

Public Member Functions

 nsMsgOfflineManager ()
virtual ~nsMsgOfflineManager ()
void goOnline (in boolean sendUnsentMessages, in boolean playbackOfflineImapOperations, in nsIMsgWindow aMsgWindow)
void synchronizeForOffline (in boolean downloadNews, in boolean downloadMail, in boolean sendUnsentMessages, in boolean goOfflineWhenDone, in nsIMsgWindow aMsgWindow)
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.
void OnStartSending (in PRUint32 aTotalMessageCount)
 Notify the observer that the operation of sending all unset messages has started.
void OnProgress (in PRUint32 aCurrentMessage, in PRUint32 aTotalMessage)
 Notify the observer that progress as occurred for send operation.
void OnStatus (in wstring aMsg)
 Notify the observer with a status message for the send later operation.
void OnStopSending (in nsresult aStatus, in wstring aMsg, in PRUint32 aTotalTried, in PRUint32 aSuccessful)
 Notify the observer that the message has been sent.
void OnStartRunningUrl (in nsIURI url)
void OnStopRunningUrl (in nsIURI url, in nsresult aExitCode)

Public Attributes

attribute nsIMsgWindow window
attribute boolean inProgress

Private Member Functions

nsresult AdvanceToNextState (nsresult exitStatus)
nsresult SynchronizeOfflineImapChanges ()
nsresult StopRunning (nsresult exitStatus)
nsresult SendUnsentMessages ()
nsresult DownloadOfflineNewsgroups ()
nsresult DownloadMail ()
nsresult SetOnlineState (PRBool online)
nsresult ShowStatus (const char *statusMsgName)

Private Attributes

PRBool m_inProgress
PRBool m_sendUnsentMessages
PRBool m_downloadNews
PRBool m_downloadMail
PRBool m_playbackOfflineImapOps
PRBool m_goOfflineWhenDone
offlineManagerState m_curState
offlineManagerOperation m_curOperation
nsCOMPtr< nsIMsgWindowm_window
nsCOMPtr< nsIMsgStatusFeedbackm_statusFeedback
nsCOMPtr< nsIStringBundlemStringBundle
nsCOMPtr< nsISupports > mOfflineImapSync

Detailed Description

Definition at line 51 of file nsMsgOfflineManager.h.


Member Enumeration Documentation

Enumerator:
eGoingOnline 
eDownloadingForOffline 
eNoOp 

Definition at line 83 of file nsMsgOfflineManager.h.

  {
    eGoingOnline = 0,
    eDownloadingForOffline = 1,
    eNoOp = 2 // no operation in progress
  } offlineManagerOperation;
Enumerator:
eStarting 
eSynchronizingOfflineImapChanges 
eDownloadingNews 
eDownloadingMail 
eSendingUnsent 
eDone 
eNoState 

Definition at line 72 of file nsMsgOfflineManager.h.


Constructor & Destructor Documentation

Definition at line 80 of file nsMsgOfflineManager.cpp.

{
}

Member Function Documentation

Definition at line 122 of file nsMsgOfflineManager.cpp.

{
  // NS_BINDING_ABORTED is used for the user pressing stop, which
  // should cause us to abort the offline process. Other errors
  // should allow us to continue.
  if (exitStatus == NS_BINDING_ABORTED)
  {
    return StopRunning(exitStatus);
  }
  if (m_curOperation == eGoingOnline)
  {
    switch (m_curState)
    {
    case eNoState:

      m_curState = eSendingUnsent;
      if (m_sendUnsentMessages)
      {
        SendUnsentMessages();
      }
      else
        AdvanceToNextState(NS_OK);
      break;
    case eSendingUnsent:

      m_curState = eSynchronizingOfflineImapChanges;
      if (m_playbackOfflineImapOps)
        return SynchronizeOfflineImapChanges();
      else
        AdvanceToNextState(NS_OK); // recurse to next state.
      break;
    case eSynchronizingOfflineImapChanges:
      m_curState = eDone;
      return StopRunning(exitStatus);
      default:
        NS_ASSERTION(PR_FALSE, "unhandled current state when going online");
    }
  }
  else if (m_curOperation == eDownloadingForOffline)
  {
    switch (m_curState)
    {
      case eNoState:
        m_curState = eDownloadingNews;
        if (m_downloadNews)
          DownloadOfflineNewsgroups();
        else
          AdvanceToNextState(NS_OK);
        break;
      case eSendingUnsent:
        if (m_goOfflineWhenDone)
        {
          SetOnlineState(PR_FALSE);
        }
        break;
      case eDownloadingNews:
        m_curState = eDownloadingMail;
        if (m_downloadMail)
          DownloadMail();
        else
          AdvanceToNextState(NS_OK);
        break;
      case eDownloadingMail:
        m_curState = eSendingUnsent;
        if (m_sendUnsentMessages)
          SendUnsentMessages();
        else
          AdvanceToNextState(NS_OK);
        break;
      default:
        NS_ASSERTION(PR_FALSE, "unhandled current state when downloading for offline");
    }

  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 310 of file nsMsgOfflineManager.cpp.

{
  nsresult rv = NS_OK;
  ShowStatus("downloadingMail");
       nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);
  return imapService->DownloadAllOffineImapFolders(m_window, this);
  // ### we should do get new mail on pop servers, and download imap messages for offline use.
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 297 of file nsMsgOfflineManager.cpp.

{
       nsresult rv;
  ShowStatus("downloadingNewsgroups");
  nsCOMPtr<nsINntpService> nntpService(do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv));
  if (NS_SUCCEEDED(rv) && nntpService)
    rv = nntpService->DownloadNewsgroupsForOffline(m_window, this);

  if (NS_FAILED(rv))
    return AdvanceToNextState(rv);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMsgOfflineManager::goOnline ( in boolean  sendUnsentMessages,
in boolean  playbackOfflineImapOperations,
in nsIMsgWindow  aMsgWindow 
) [inherited]
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 nsIMsgSendLaterListener::OnProgress ( in PRUint32  aCurrentMessage,
in PRUint32  aTotalMessage 
) [inherited]

Notify the observer that progress as occurred for send operation.

Here is the caller graph for this function:

Here is the caller graph for this function:

void nsIMsgSendLaterListener::OnStartSending ( in PRUint32  aTotalMessageCount) [inherited]

Notify the observer that the operation of sending all unset messages has started.

Here is the caller graph for this function:

void nsIMsgSendLaterListener::OnStatus ( in wstring  aMsg) [inherited]

Notify the observer with a status message for the send later operation.

Here is the caller graph for this function:

void nsIUrlListener::OnStopRunningUrl ( in nsIURI  url,
in nsresult  aExitCode 
) [inherited]

Here is the caller graph for this function:

void nsIMsgSendLaterListener::OnStopSending ( in nsresult  aStatus,
in wstring  aMsg,
in PRUint32  aTotalTried,
in PRUint32  aSuccessful 
) [inherited]

Notify the observer that the message has been sent.

This method is called once when the networking library has finished processing the message.

This method is called regardless of whether the the operation was successful. aMsgID The message id for the mail message status Status code for the message send. msg A text string describing the error. returnFileSpec The returned file spec for save to file operations.

Here is the caller graph for this function:

Definition at line 207 of file nsMsgOfflineManager.cpp.

{
       nsresult rv;
       nsCOMPtr<nsIMsgSendLater> pMsgSendLater = do_CreateInstance(kMsgSendLaterCID, &rv); 
  NS_ENSURE_SUCCESS(rv, rv);
  nsCOMPtr<nsIMsgAccountManager> accountManager = 
           do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);
  // now we have to iterate over the identities, finding the *unique* unsent messages folder
  // for each one, determine if they have unsent messages, and if so, add them to the list
  // of identities to send unsent messages from.
  // However, I think there's only ever one unsent messages folder at the moment,
  // so I think we'll go with that for now.
  nsCOMPtr<nsISupportsArray> identities;

  if (NS_SUCCEEDED(rv) && accountManager) 
  {
    rv = accountManager->GetAllIdentities(getter_AddRefs(identities));
    NS_ENSURE_SUCCESS(rv, rv);
  }
  nsCOMPtr <nsIMsgIdentity> identityToUse;
  PRUint32 numIndentities;
  identities->Count(&numIndentities);
  for (PRUint32 i = 0; i < numIndentities; i++)
  {
    // convert supports->Identity
    nsCOMPtr<nsISupports> thisSupports;
    rv = identities->GetElementAt(i, getter_AddRefs(thisSupports));
    if (NS_FAILED(rv)) continue;
    
    nsCOMPtr<nsIMsgIdentity> thisIdentity = do_QueryInterface(thisSupports, &rv);

    if (NS_SUCCEEDED(rv) && thisIdentity)
    {
      nsCOMPtr <nsIMsgFolder> outboxFolder;
      pMsgSendLater->GetUnsentMessagesFolder(thisIdentity, getter_AddRefs(outboxFolder));
      if (outboxFolder)
      {
        PRInt32 numMessages;
        outboxFolder->GetTotalMessages(PR_FALSE, &numMessages);
        if (numMessages > 0)
        {
          identityToUse = thisIdentity;
          break;
        }
      }
    }
  }
       if (identityToUse) 
       { 
    pMsgSendLater->AddListener(this);
    pMsgSendLater->SetMsgWindow(m_window);
    rv = pMsgSendLater->SendUnsentMessages(identityToUse);
    ShowStatus("sendingUnsent");
    // if we succeeded, return - we'll run the next operation when the
    // send finishes. Otherwise, advance to the next state.
    if (NS_SUCCEEDED(rv))
      return rv;
       } 
       return AdvanceToNextState(rv);

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 356 of file nsMsgOfflineManager.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIIOService> netService(do_GetService(kIOServiceCID, &rv));
  if (NS_SUCCEEDED(rv) && netService)
  {
    rv = netService->SetOffline(!online);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgOfflineManager::ShowStatus ( const char *  statusMsgName) [private]

Definition at line 272 of file nsMsgOfflineManager.cpp.

{
  nsresult res = NS_OK;
  if (!mStringBundle)
  {
    static const char propertyURL[] = MESSENGER_STRING_URL;

    nsCOMPtr<nsIStringBundleService> sBundleService = 
             do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
    if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) 
    {
      res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(mStringBundle));
    }
  }
  if (mStringBundle)
  {
    nsXPIDLString statusString;
              res = mStringBundle->GetStringFromName(NS_ConvertASCIItoUCS2(statusMsgName).get(), getter_Copies(statusString));

    if ( NS_SUCCEEDED(res))
      OnStatus(statusString);
  }
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 116 of file nsMsgOfflineManager.cpp.

{
  m_inProgress = PR_FALSE;
  return exitStatus;
}

Here is the caller graph for this function:

void nsIMsgOfflineManager::synchronizeForOffline ( in boolean  downloadNews,
in boolean  downloadMail,
in boolean  sendUnsentMessages,
in boolean  goOfflineWhenDone,
in nsIMsgWindow  aMsgWindow 
) [inherited]

Definition at line 199 of file nsMsgOfflineManager.cpp.

{
  nsresult rv = NS_OK;
       nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);
  return imapService->PlaybackAllOfflineOperations(m_window, this, getter_AddRefs(mOfflineImapSync));
}

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 nsIMsgOfflineManager.idl.

Definition at line 108 of file nsMsgOfflineManager.h.

Definition at line 107 of file nsMsgOfflineManager.h.

Definition at line 104 of file nsMsgOfflineManager.h.

Definition at line 103 of file nsMsgOfflineManager.h.

Definition at line 106 of file nsMsgOfflineManager.h.

Definition at line 101 of file nsMsgOfflineManager.h.

Definition at line 105 of file nsMsgOfflineManager.h.

Definition at line 102 of file nsMsgOfflineManager.h.

Definition at line 110 of file nsMsgOfflineManager.h.

Definition at line 109 of file nsMsgOfflineManager.h.

Definition at line 112 of file nsMsgOfflineManager.h.

Definition at line 111 of file nsMsgOfflineManager.h.

Definition at line 48 of file nsIMsgOfflineManager.idl.


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