Back to index

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

#include <nsNewsDownloader.h>

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

List of all members.

Public Member Functions

 DownloadMatchingNewsArticlesToNewsDB (nsIMsgWindow *window, nsIMsgFolder *folder, nsIMsgDatabase *newsDB, nsIUrlListener *listener)
virtual ~DownloadMatchingNewsArticlesToNewsDB ()
nsresult RunSearch (nsIMsgFolder *folder, nsIMsgDatabase *newsDB, nsIMsgSearchSession *searchSession)
NS_IMETHOD OnStartRunningUrl (nsIURI *url)
void OnStartRunningUrl (in nsIURI url)
NS_IMETHOD OnStopRunningUrl (nsIURI *url, nsresult exitCode)
void OnStopRunningUrl (in nsIURI url, in nsresult aExitCode)
NS_DECL_ISUPPORTS
NS_DECL_NSIURLLISTENER virtual
NS_DECL_NSIMSGSEARCHNOTIFY
nsresult 
DownloadArticles (nsIMsgWindow *window, nsIMsgFolder *folder, nsMsgKeyArray *pKeyArray)
PRBool ShouldAbort () const
void onSearchHit (in nsIMsgDBHdr header, in nsIMsgFolder folder)
void onSearchDone (in nsresult status)
void onNewSearch ()

Protected Member Functions

virtual PRInt32 StartDownload ()
virtual PRInt32 FinishDownload ()
virtual PRBool GetNextHdrToRetrieve ()
virtual PRInt32 Write (const char *, PRInt32 length)
virtual void Abort ()
virtual void Complete ()
virtual nsresult DownloadNext (PRBool firstTimeP)
virtual nsresult ShowProgress (const PRUnichar *progressString, PRInt32 percent)

Protected Attributes

nsCOMPtr< nsISimpleEnumeratorm_headerEnumerator
nsCOMPtr< nsIMsgDBHdrm_newsHeader
nsMsgKeyArray m_keysToDownload
nsCOMPtr< nsIMsgFolderm_folder
nsCOMPtr< nsIMsgDatabasem_newsDB
nsCOMPtr< nsIUrlListenerm_listener
PRPackedBool m_downloadFromKeys
PRPackedBool m_existedP
PRPackedBool m_wroteAnyP
PRPackedBool m_summaryValidP
PRPackedBool m_abort
PRInt32 m_numwrote
nsMsgKey m_keyToDownload
nsCOMPtr< nsIMsgWindowm_window
nsCOMPtr< nsIMsgStatusFeedbackm_statusFeedback
nsCOMPtr< nsIMsgSearchSessionm_searchSession
PRInt32 m_lastPercent
PRInt64 m_lastProgressTime
nsresult m_status

Detailed Description

Definition at line 116 of file nsNewsDownloader.h.


Constructor & Destructor Documentation

Definition at line 343 of file nsNewsDownloader.cpp.

                                  :
        DownloadNewsArticlesToOfflineStore(window, newsDB, listener)
{
  m_window = window;
  m_folder = folder;
  m_newsDB = newsDB;
  m_downloadFromKeys = PR_TRUE;    // search term matching means downloadFromKeys.
}

Definition at line 353 of file nsNewsDownloader.cpp.

{
}

Member Function Documentation

void nsNewsDownloader::Abort ( ) [protected, virtual, inherited]

Definition at line 183 of file nsNewsDownloader.cpp.

{}
void nsNewsDownloader::Complete ( ) [protected, virtual, inherited]

Definition at line 184 of file nsNewsDownloader.cpp.

{}
nsresult nsNewsDownloader::DownloadArticles ( nsIMsgWindow window,
nsIMsgFolder folder,
nsMsgKeyArray *  pKeyArray 
) [virtual, inherited]

Definition at line 61 of file nsNewsDownloader.cpp.

{
  if (pIds != nsnull)
    m_keysToDownload.InsertAt(0, pIds);
  
  if (m_keysToDownload.GetSize() > 0)
    m_downloadFromKeys = PR_TRUE;
  
  m_folder = folder;
  m_window = window;
  m_numwrote = 0;
  
  PRBool headersToDownload = GetNextHdrToRetrieve();
  // should we have a special error code for failure here?
  return (headersToDownload) ? DownloadNext(PR_TRUE) : NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsNewsDownloader::DownloadNext ( PRBool  firstTimeP) [protected, virtual, inherited]

Definition at line 129 of file nsNewsDownloader.cpp.

{
  nsresult rv;
  if (!firstTimeP)
  {
    PRBool moreHeaders = GetNextHdrToRetrieve();
    if (!moreHeaders)
    {
      if (m_listener)
        m_listener->OnStopRunningUrl(nsnull, NS_OK);
      return NS_OK;
    }
  }
  StartDownload();
  m_wroteAnyP = PR_FALSE;
  nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID,&rv);
  NS_ENSURE_SUCCESS(rv, rv);

  return nntpService->FetchMessage(m_folder, m_keyToDownload, m_window, nsnull, this, nsnull);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int DownloadNewsArticlesToOfflineStore::FinishDownload ( ) [protected, virtual, inherited]

Reimplemented from nsNewsDownloader.

Definition at line 283 of file nsNewsDownloader.cpp.

{
  return 0;
}

Reimplemented from nsNewsDownloader.

Definition at line 150 of file nsNewsDownloader.cpp.

{
  nsresult rv;

  if (m_downloadFromKeys)
    return nsNewsDownloader::GetNextHdrToRetrieve();

  if (m_headerEnumerator == nsnull)
    rv = m_newsDB->EnumerateMessages(getter_AddRefs(m_headerEnumerator));

  PRBool hasMore = PR_FALSE;

  while (NS_SUCCEEDED(rv = m_headerEnumerator->HasMoreElements(&hasMore)) && hasMore) 
  {
    nsCOMPtr <nsISupports> supports;
    rv = m_headerEnumerator->GetNext(getter_AddRefs(supports));
    m_newsHeader = do_QueryInterface(supports);
    NS_ENSURE_SUCCESS(rv,rv);
    PRUint32 hdrFlags;
    m_newsHeader->GetFlags(&hdrFlags);
    if (hdrFlags & MSG_FLAG_MARKED)
    {
      m_newsHeader->GetMessageKey(&m_keyToDownload);
      break;
    }
    else
    {
      m_newsHeader = nsnull;
    }
  }
  return hasMore;
}

Here is the call graph for this function:

void nsIMsgSearchNotify::onSearchHit ( in nsIMsgDBHdr  header,
in nsIMsgFolder  folder 
) [inherited]

Here is the caller graph for this function:

Definition at line 258 of file nsNewsDownloader.cpp.

{
  return NS_OK;
}
void nsIUrlListener::OnStopRunningUrl ( in nsIURI  url,
in nsresult  aExitCode 
) [inherited]

Here is the caller graph for this function:

Definition at line 264 of file nsNewsDownloader.cpp.

{
  m_status = exitCode;
  if (m_newsHeader != nsnull)
  {
#ifdef DEBUG_bienvenu
    //        XP_Trace("finished retrieving %ld\n", m_newsHeader->GetMessageKey());
#endif
    if (m_newsDB)
    {
      nsMsgKey msgKey;
      m_newsHeader->GetMessageKey(&msgKey);
      m_newsDB->MarkMarked(msgKey, PR_FALSE, nsnull);
    }
  }    
  m_newsHeader = nsnull;
  return nsNewsDownloader::OnStopRunningUrl(url, exitCode);
}

Here is the call graph for this function:

Definition at line 516 of file nsNewsDownloader.cpp.

{
  m_folder = folder;
  m_newsDB = newsDB;
  m_searchSession = searchSession;

  m_keysToDownload.RemoveAll();
  nsresult rv;
  NS_ENSURE_ARG(searchSession);
  NS_ENSURE_ARG(folder);

  searchSession->RegisterListener(this);
  rv = searchSession->AddScopeTerm(nsMsgSearchScope::localNews, folder);
  return searchSession->Search(m_window);
}

Here is the caller graph for this function:

PRBool nsNewsDownloader::ShouldAbort ( ) const [inline, inherited]

Definition at line 64 of file nsNewsDownloader.h.

{ return m_abort; }
nsresult nsNewsDownloader::ShowProgress ( const PRUnichar progressString,
PRInt32  percent 
) [protected, virtual, inherited]

Definition at line 239 of file nsNewsDownloader.cpp.

{
  if (!m_statusFeedback)
  {
    if (m_window)
      m_window->GetStatusFeedback(getter_AddRefs(m_statusFeedback));
  }
  if (m_statusFeedback)
  {
    m_statusFeedback->ShowStatusString(progressString);
    if (percent != m_lastPercent)
    {
      m_statusFeedback->ShowProgress(percent);
      m_lastPercent = percent;
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int DownloadNewsArticlesToOfflineStore::StartDownload ( ) [protected, virtual, inherited]

Reimplemented from nsNewsDownloader.

Definition at line 326 of file nsNewsDownloader.cpp.

{
  m_newsDB->GetMsgHdrForKey(m_keyToDownload, getter_AddRefs(m_newsHeader));
  return 0;
}

Here is the call graph for this function:

virtual PRInt32 nsNewsDownloader::Write ( const char *  ,
PRInt32  length 
) [inline, protected, virtual, inherited]

Definition at line 67 of file nsNewsDownloader.h.

{return length;}

Member Data Documentation

PRPackedBool nsNewsDownloader::m_abort [protected, inherited]

Definition at line 84 of file nsNewsDownloader.h.

Definition at line 80 of file nsNewsDownloader.h.

Definition at line 81 of file nsNewsDownloader.h.

Definition at line 77 of file nsNewsDownloader.h.

Definition at line 110 of file nsNewsDownloader.h.

nsMsgKeyArray nsNewsDownloader::m_keysToDownload [protected, inherited]

Definition at line 76 of file nsNewsDownloader.h.

Definition at line 86 of file nsNewsDownloader.h.

PRInt32 nsNewsDownloader::m_lastPercent [protected, inherited]

Definition at line 90 of file nsNewsDownloader.h.

Definition at line 91 of file nsNewsDownloader.h.

Definition at line 79 of file nsNewsDownloader.h.

Definition at line 78 of file nsNewsDownloader.h.

Definition at line 111 of file nsNewsDownloader.h.

PRInt32 nsNewsDownloader::m_numwrote [protected, inherited]

Definition at line 85 of file nsNewsDownloader.h.

Definition at line 89 of file nsNewsDownloader.h.

nsresult nsNewsDownloader::m_status [protected, inherited]

Definition at line 92 of file nsNewsDownloader.h.

Definition at line 88 of file nsNewsDownloader.h.

Definition at line 83 of file nsNewsDownloader.h.

Definition at line 87 of file nsNewsDownloader.h.

Definition at line 82 of file nsNewsDownloader.h.


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