Back to index

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

#include <nsNewsDownloader.h>

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

List of all members.

Public Member Functions

 nsMsgDownloadAllNewsgroups (nsIMsgWindow *window, nsIUrlListener *listener)
virtual ~nsMsgDownloadAllNewsgroups ()
NS_DECL_ISUPPORTS
NS_DECL_NSIURLLISTENER
nsresult 
ProcessNextGroup ()
void OnStartRunningUrl (in nsIURI url)
void OnStopRunningUrl (in nsIURI url, in nsresult aExitCode)

Protected Member Functions

nsresult AdvanceToNextServer (PRBool *done)
nsresult AdvanceToNextGroup (PRBool *done)
nsresult DownloadMsgsForCurrentGroup ()

Protected Attributes

DownloadMatchingNewsArticlesToNewsDBm_downloaderForGroup
nsCOMPtr< nsIMsgFolderm_currentFolder
nsCOMPtr< nsIMsgWindowm_window
nsCOMPtr< nsISupportsArraym_allServers
nsCOMPtr< nsISupportsArraym_allFolders
nsCOMPtr< nsIMsgIncomingServerm_currentServer
nsCOMPtr< nsIEnumeratorm_serverEnumerator
nsCOMPtr< nsIUrlListenerm_listener
nsCOMPtr< nsISupportsArraym_termList
PRBool m_downloadedHdrsForCurGroup

Detailed Description

Definition at line 127 of file nsNewsDownloader.h.


Constructor & Destructor Documentation

Definition at line 370 of file nsNewsDownloader.cpp.


Member Function Documentation

Definition at line 471 of file nsNewsDownloader.cpp.

{
  nsresult rv;
  NS_ENSURE_ARG(done);
  *done = PR_TRUE;

  if (m_currentFolder)
  {
    nsCOMPtr <nsIMsgNewsFolder> newsFolder = do_QueryInterface(m_currentFolder);
    if (newsFolder)
      newsFolder->SetSaveArticleOffline(PR_FALSE);
  
    nsCOMPtr<nsIMsgMailSession> session = 
             do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); 
    if (NS_SUCCEEDED(rv) && session) 
    {
      PRBool folderOpen;
      PRUint32 folderFlags;
      m_currentFolder->GetFlags(&folderFlags);
      session->IsFolderOpenInWindow(m_currentFolder, &folderOpen);
      if (!folderOpen && ! (folderFlags & (MSG_FOLDER_FLAG_TRASH | MSG_FOLDER_FLAG_INBOX)))
        m_currentFolder->SetMsgDatabase(nsnull);
    }
    m_currentFolder = nsnull;
  }

  *done = PR_FALSE;

  if (!m_currentServer)
     rv = AdvanceToNextServer(done);
  else
    rv = m_serverEnumerator->Next();
  if (NS_FAILED(rv))
    rv = AdvanceToNextServer(done);

  if (NS_SUCCEEDED(rv) && !*done && m_serverEnumerator)
  {
    nsCOMPtr <nsISupports> supports;
    rv = m_serverEnumerator->CurrentItem(getter_AddRefs(supports));
    m_currentFolder = do_QueryInterface(supports);
    *done = PR_FALSE;
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 415 of file nsNewsDownloader.cpp.

{
  nsresult rv;

  NS_ENSURE_ARG(done);

  *done = PR_TRUE;
  if (!m_allServers)
  {
    nsCOMPtr<nsIMsgAccountManager> accountManager = 
             do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
    NS_ASSERTION(accountManager && NS_SUCCEEDED(rv), "couldn't get account mgr");
    if (!accountManager || NS_FAILED(rv)) return rv;

    rv = accountManager->GetAllServers(getter_AddRefs(m_allServers));
    NS_ENSURE_SUCCESS(rv, rv);
  }
  PRUint32 serverIndex = (m_currentServer) ? m_allServers->IndexOf(m_currentServer) + 1 : 0;
  m_currentServer = nsnull;
  PRUint32 numServers; 
  m_allServers->Count(&numServers);
  nsCOMPtr <nsIMsgFolder> rootFolder;

  while (serverIndex < numServers)
  {
    nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(m_allServers, serverIndex);
    serverIndex++;

    nsCOMPtr <nsINntpIncomingServer> newsServer = do_QueryInterface(server);
    if (!newsServer) // we're only looking for news servers
      continue;
    if (server)
    {
      m_currentServer = server;
      server->GetRootFolder(getter_AddRefs(rootFolder));
      if (rootFolder)
      {
        NS_NewISupportsArray(getter_AddRefs(m_allFolders));
        rv = rootFolder->ListDescendents(m_allFolders);
        if (NS_SUCCEEDED(rv))
          m_allFolders->Enumerate(getter_AddRefs(m_serverEnumerator));
        if (NS_SUCCEEDED(rv) && m_serverEnumerator)
        {
          rv = m_serverEnumerator->First();
          if (NS_SUCCEEDED(rv))
          {
            *done = PR_FALSE;
            break;
          }
        }
      }
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 557 of file nsNewsDownloader.cpp.

{
  NS_ENSURE_TRUE(m_downloaderForGroup, NS_ERROR_OUT_OF_MEMORY);
  nsCOMPtr <nsIMsgDatabase> db;
  nsCOMPtr <nsISupportsArray> termList;
  nsCOMPtr <nsIMsgDownloadSettings> downloadSettings;
  m_currentFolder->GetMsgDatabase(m_window, getter_AddRefs(db));
  nsresult rv = m_currentFolder->GetDownloadSettings(getter_AddRefs(downloadSettings));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr <nsIMsgNewsFolder> newsFolder = do_QueryInterface(m_currentFolder);
  if (newsFolder)
    newsFolder->SetSaveArticleOffline(PR_TRUE);

  if (!m_termList)
  {
    rv = NS_NewISupportsArray(getter_AddRefs(m_termList));
    NS_ENSURE_SUCCESS(rv, rv);
  }

  nsCOMPtr <nsIMsgSearchSession> searchSession = do_CreateInstance(NS_MSGSEARCHSESSION_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  PRBool downloadByDate, downloadUnreadOnly;
  PRUint32 ageLimitOfMsgsToDownload;

  downloadSettings->GetDownloadByDate(&downloadByDate);
  downloadSettings->GetDownloadUnreadOnly(&downloadUnreadOnly);
  downloadSettings->GetAgeLimitOfMsgsToDownload(&ageLimitOfMsgsToDownload);

  nsCOMPtr <nsIMsgSearchTerm> term;
  nsCOMPtr <nsIMsgSearchValue>    value;

  rv = searchSession->CreateTerm(getter_AddRefs(term));
  NS_ENSURE_SUCCESS(rv, rv);
  term->GetValue(getter_AddRefs(value));

  if (downloadUnreadOnly)
  {
    value->SetAttrib(nsMsgSearchAttrib::MsgStatus);
    value->SetStatus(MSG_FLAG_READ);
    searchSession->AddSearchTerm(nsMsgSearchAttrib::MsgStatus, nsMsgSearchOp::Isnt, value, PR_TRUE, nsnull);
  }
  if (downloadByDate)
  {
    value->SetAttrib(nsMsgSearchAttrib::AgeInDays);
    value->SetAge(ageLimitOfMsgsToDownload);
    searchSession->AddSearchTerm(nsMsgSearchAttrib::AgeInDays, nsMsgSearchOp::IsLessThan, value, nsMsgSearchBooleanOp::BooleanAND, nsnull);
  }
  value->SetAttrib(nsMsgSearchAttrib::MsgStatus);
  value->SetStatus(MSG_FLAG_OFFLINE);
  searchSession->AddSearchTerm(nsMsgSearchAttrib::MsgStatus, nsMsgSearchOp::Isnt, value, nsMsgSearchBooleanOp::BooleanAND, nsnull);

  m_downloaderForGroup->RunSearch(m_currentFolder, db, searchSession);
  return rv;
}

Here is the call graph for this function:

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:

Definition at line 532 of file nsNewsDownloader.cpp.

{
  nsresult rv = NS_OK;
  PRBool done = PR_FALSE;

  while (NS_SUCCEEDED(rv) && !done)
  {
    rv = AdvanceToNextGroup(&done); 
    if (m_currentFolder)
    {
      PRUint32 folderFlags;
      m_currentFolder->GetFlags(&folderFlags);
      if (folderFlags & MSG_FOLDER_FLAG_OFFLINE)
        break;
    }
  }
  if (NS_FAILED(rv) || done)
  {
    if (m_listener)
      return m_listener->OnStopRunningUrl(nsnull, NS_OK);
  }
  m_downloadedHdrsForCurGroup = PR_TRUE;
  return m_currentFolder->GetNewMessages(m_window, this);
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 148 of file nsNewsDownloader.h.

Definition at line 147 of file nsNewsDownloader.h.

Definition at line 145 of file nsNewsDownloader.h.

Definition at line 149 of file nsNewsDownloader.h.

Definition at line 154 of file nsNewsDownloader.h.

Definition at line 143 of file nsNewsDownloader.h.

Definition at line 151 of file nsNewsDownloader.h.

Definition at line 150 of file nsNewsDownloader.h.

Definition at line 152 of file nsNewsDownloader.h.

Definition at line 146 of file nsNewsDownloader.h.


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