re-use offline store stream when doing a mass download of news messages, r/sr=scott attempt to speed up mass download, 214525 also cleanup tabs and formatting
git-svn-id: svn://10.0.0.236/trunk@145635 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -281,15 +281,6 @@ NS_IMETHODIMP nsNewsDownloader::OnSearchHit(nsIMsgDBHdr *header, nsIMsgFolder *f
|
||||
nsMsgKey key;
|
||||
header->GetMessageKey(&key);
|
||||
m_keysToDownload.Add(key);
|
||||
#ifdef HAVE_PORT
|
||||
char *statusTemplate = XP_GetString (MK_MSG_ARTICLES_TO_RETRIEVE);
|
||||
char *statusString = PR_smprintf (statusTemplate, (long) newsArticleState->m_keysToDownload.GetSize());
|
||||
if (statusString)
|
||||
{
|
||||
FE_Progress (newsArticleState->m_context, statusString);
|
||||
XP_FREE(statusString);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -117,24 +117,24 @@ static NS_DEFINE_CID(kCNewsDB, NS_NEWSDB_CID);
|
||||
nsMsgNewsFolder::nsMsgNewsFolder(void) : nsMsgLineBuffer(nsnull, PR_FALSE),
|
||||
mExpungedBytes(0), mGettingNews(PR_FALSE),
|
||||
mInitialized(PR_FALSE), mOptionLines(""), mUnsubscribedNewsgroupLines(""),
|
||||
m_downloadMessageForOfflineUse(PR_FALSE), mReadSet(nsnull), mGroupUsername(nsnull), mGroupPassword(nsnull), mAsciiName(nsnull)
|
||||
m_downloadMessageForOfflineUse(PR_FALSE), m_downloadingMultipleMessages(PR_FALSE),
|
||||
mReadSet(nsnull), mGroupUsername(nsnull), mGroupPassword(nsnull), mAsciiName(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsNewsFolder); // double count these for now.
|
||||
/* we're parsing the newsrc file, and the line breaks are platform specific.
|
||||
* if MSG_LINEBREAK != CRLF, then we aren't looking for CRLF
|
||||
*/
|
||||
if (PL_strcmp(MSG_LINEBREAK, CRLF)) {
|
||||
if (PL_strcmp(MSG_LINEBREAK, CRLF))
|
||||
SetLookingForCRLF(PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
nsMsgNewsFolder::~nsMsgNewsFolder(void)
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsNewsFolder);
|
||||
delete mReadSet;
|
||||
PR_FREEIF(mGroupUsername);
|
||||
PR_FREEIF(mGroupPassword);
|
||||
PR_FREEIF(mAsciiName);
|
||||
PR_Free(mGroupUsername);
|
||||
PR_Free(mGroupPassword);
|
||||
PR_Free(mAsciiName);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsMsgNewsFolder, nsMsgDBFolder)
|
||||
@@ -487,13 +487,11 @@ nsMsgNewsFolder::GetCanCompact(PRBool *aResult)
|
||||
NS_IMETHODIMP
|
||||
nsMsgNewsFolder::GetMessages(nsIMsgWindow *aMsgWindow, nsISimpleEnumerator* *result)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
rv = GetDatabase(aMsgWindow);
|
||||
nsresult rv = GetDatabase(aMsgWindow);
|
||||
*result = nsnull;
|
||||
|
||||
if(NS_SUCCEEDED(rv))
|
||||
rv = mDatabase->EnumerateMessages(result);
|
||||
rv = mDatabase->EnumerateMessages(result);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@@ -578,10 +576,7 @@ NS_IMETHODIMP nsMsgNewsFolder::CreateSubfolder(const PRUnichar *uninewsgroupname
|
||||
nsCOMPtr<nsISupports> folderSupports;
|
||||
rv = QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(folderSupports));
|
||||
if(childSupports && NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
||||
NotifyItemAdded(folderSupports, childSupports, "folderView");
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@@ -590,7 +585,8 @@ NS_IMETHODIMP nsMsgNewsFolder::Delete()
|
||||
{
|
||||
nsresult rv = GetDatabase(nsnull);
|
||||
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
mDatabase->ForceClosed();
|
||||
mDatabase = nsnull;
|
||||
}
|
||||
@@ -745,10 +741,10 @@ nsresult nsMsgNewsFolder::AbbreviatePrettyName(PRUnichar ** prettyName, PRInt32
|
||||
}
|
||||
|
||||
if (!prettyName)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
// we are going to set *prettyName to something else, so free what was there
|
||||
|
||||
PR_FREEIF(*prettyName);
|
||||
PR_Free(*prettyName);
|
||||
*prettyName = ToNewUnicode(out);
|
||||
|
||||
return (*prettyName) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
@@ -1512,8 +1508,7 @@ NS_IMETHODIMP nsMsgNewsFolder::SetReadSetFromStr(const char *newsrcLine)
|
||||
{
|
||||
if (!newsrcLine) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (mReadSet)
|
||||
delete mReadSet;
|
||||
delete mReadSet;
|
||||
|
||||
mReadSet = nsMsgKeySet::Create(newsrcLine);
|
||||
|
||||
@@ -1533,9 +1528,8 @@ nsMsgNewsFolder::GetUnsubscribedNewsgroupLines(char **aUnsubscribedNewsgroupLine
|
||||
{
|
||||
if (!aUnsubscribedNewsgroupLines) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (!mUnsubscribedNewsgroupLines.IsEmpty()) {
|
||||
if (!mUnsubscribedNewsgroupLines.IsEmpty())
|
||||
*aUnsubscribedNewsgroupLines= ToNewCString(mUnsubscribedNewsgroupLines);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1545,9 +1539,8 @@ nsMsgNewsFolder::GetOptionLines(char **optionLines)
|
||||
{
|
||||
if (!optionLines) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (!mOptionLines.IsEmpty()) {
|
||||
if (!mOptionLines.IsEmpty())
|
||||
*optionLines = ToNewCString(mOptionLines);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1562,25 +1555,25 @@ nsMsgNewsFolder::OnReadChanged(nsIDBChangeListener * aInstigator)
|
||||
NS_IMETHODIMP
|
||||
nsMsgNewsFolder::GetAsciiName(char **asciiName)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv;
|
||||
NS_ENSURE_ARG_POINTER(asciiName);
|
||||
if (!mAsciiName) {
|
||||
nsXPIDLString name;
|
||||
rv = GetName(getter_Copies(name));
|
||||
nsXPIDLString name;
|
||||
rv = GetName(getter_Copies(name));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
|
||||
// convert to ASCII
|
||||
nsCAutoString tmpStr;
|
||||
tmpStr.AssignWithConversion(name);
|
||||
|
||||
nsCAutoString tmpStr;
|
||||
tmpStr.AssignWithConversion(name);
|
||||
|
||||
mAsciiName = nsCRT::strdup(tmpStr.get());
|
||||
if (!mAsciiName) return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*asciiName = nsCRT::strdup(mAsciiName);
|
||||
if (!*asciiName) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
*asciiName = nsCRT::strdup(mAsciiName);
|
||||
if (!*asciiName) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -1674,9 +1667,12 @@ NS_IMETHODIMP nsMsgNewsFolder::DownloadAllForOffline(nsIUrlListener *listener, n
|
||||
}
|
||||
}
|
||||
}
|
||||
DownloadNewsArticlesToOfflineStore *downloadState = new DownloadNewsArticlesToOfflineStore(msgWindow, mDatabase, nsnull);
|
||||
DownloadNewsArticlesToOfflineStore *downloadState = new DownloadNewsArticlesToOfflineStore(msgWindow, mDatabase, this);
|
||||
if (downloadState)
|
||||
{
|
||||
m_downloadingMultipleMessages = PR_TRUE;
|
||||
return downloadState->DownloadArticles(msgWindow, this, &srcKeyArray);
|
||||
}
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@@ -1701,9 +1697,12 @@ NS_IMETHODIMP nsMsgNewsFolder::DownloadMessagesForOffline(nsISupportsArray *mess
|
||||
if (NS_SUCCEEDED(rv))
|
||||
srcKeyArray.Add(key);
|
||||
}
|
||||
DownloadNewsArticlesToOfflineStore *downloadState = new DownloadNewsArticlesToOfflineStore(window, mDatabase, nsnull);
|
||||
DownloadNewsArticlesToOfflineStore *downloadState = new DownloadNewsArticlesToOfflineStore(window, mDatabase, this);
|
||||
if (downloadState)
|
||||
{
|
||||
m_downloadingMultipleMessages = PR_TRUE;
|
||||
return downloadState->DownloadArticles(window, this, &srcKeyArray);
|
||||
}
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@@ -1714,7 +1713,7 @@ NS_IMETHODIMP nsMsgNewsFolder::NotifyDownloadedLine(const char *line, nsMsgKey k
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRBool commit = PR_FALSE;
|
||||
if (m_downloadMessageForOfflineUse && !m_tempMessageStream)
|
||||
if (m_downloadMessageForOfflineUse && !m_offlineHeader)
|
||||
{
|
||||
GetMessageHeader(keyOfArticle, getter_AddRefs(m_offlineHeader));
|
||||
rv = StartNewOfflineMessage();
|
||||
@@ -1732,7 +1731,7 @@ NS_IMETHODIMP nsMsgNewsFolder::NotifyDownloadedLine(const char *line, nsMsgKey k
|
||||
EndNewOfflineMessage();
|
||||
commit = PR_TRUE;
|
||||
}
|
||||
if (m_tempMessageStream)
|
||||
if (m_tempMessageStream && !m_downloadingMultipleMessages)
|
||||
{
|
||||
m_tempMessageStream->Close();
|
||||
m_tempMessageStream = nsnull;
|
||||
@@ -1883,3 +1882,16 @@ nsMsgNewsFolder::GetFilterList(nsIMsgWindow *aMsgWindow, nsIMsgFilterList **aRes
|
||||
NS_IF_ADDREF(*aResult = mFilterList);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgNewsFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
|
||||
{
|
||||
if (m_tempMessageStream)
|
||||
{
|
||||
m_tempMessageStream->Close();
|
||||
m_tempMessageStream = nsnull;
|
||||
}
|
||||
m_downloadingMultipleMessages = PR_FALSE;
|
||||
return nsMsgDBFolder::OnStopRunningUrl(aUrl, aExitCode);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,17 +59,16 @@
|
||||
class nsMsgNewsFolder : public nsMsgDBFolder, public nsIMsgNewsFolder, public nsMsgLineBuffer
|
||||
{
|
||||
public:
|
||||
nsMsgNewsFolder(void);
|
||||
virtual ~nsMsgNewsFolder(void);
|
||||
nsMsgNewsFolder(void);
|
||||
virtual ~nsMsgNewsFolder(void);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIMSGNEWSFOLDER
|
||||
#if 0
|
||||
static nsresult GetRoot(nsIMsgFolder* *result);
|
||||
#endif
|
||||
// nsICollection methods:
|
||||
NS_IMETHOD Enumerate(nsIEnumerator* *result);
|
||||
|
||||
// nsIUrlListener method
|
||||
NS_IMETHOD OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode);
|
||||
// nsIFolder methods:
|
||||
NS_IMETHOD GetSubFolders(nsIEnumerator* *result);
|
||||
|
||||
@@ -146,11 +145,13 @@ protected:
|
||||
|
||||
protected:
|
||||
PRUint32 mExpungedBytes;
|
||||
PRBool mGettingNews;
|
||||
PRBool mInitialized;
|
||||
PRPackedBool mGettingNews;
|
||||
PRPackedBool mInitialized;
|
||||
PRPackedBool m_downloadMessageForOfflineUse;
|
||||
PRPackedBool m_downloadingMultipleMessages;
|
||||
|
||||
nsCString mOptionLines;
|
||||
nsCString mUnsubscribedNewsgroupLines;
|
||||
PRBool m_downloadMessageForOfflineUse;
|
||||
nsMsgKeySet *mReadSet;
|
||||
|
||||
nsCOMPtr<nsIFileSpec> mNewsrcFilePath;
|
||||
|
||||
@@ -98,7 +98,7 @@ static NS_DEFINE_CID(kCacheServiceCID, NS_CACHESERVICE_CID);
|
||||
nsNntpService::nsNntpService()
|
||||
{
|
||||
mPrintingOperation = PR_FALSE;
|
||||
mOpenAttachmentOperation = PR_FALSE;
|
||||
mOpenAttachmentOperation = PR_FALSE;
|
||||
}
|
||||
|
||||
nsNntpService::~nsNntpService()
|
||||
@@ -237,12 +237,12 @@ nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayCon
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_ENSURE_ARG_POINTER(aMessageURI);
|
||||
|
||||
|
||||
nsCOMPtr <nsIMsgFolder> folder;
|
||||
nsMsgKey key = nsMsgKey_None;
|
||||
rv = DecomposeNewsMessageURI(aMessageURI, getter_AddRefs(folder), &key);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
|
||||
nsCAutoString urlStr;
|
||||
// if we are displaying (or printing), we want the news://host/message-id url
|
||||
// we keep the original uri around, for cancelling and so we can get to the
|
||||
@@ -255,35 +255,35 @@ nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayCon
|
||||
nsXPIDLCString messageIdURL;
|
||||
rv = CreateMessageIDURL(folder, key, getter_Copies(messageIdURL));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
|
||||
urlStr = messageIdURL.get();
|
||||
|
||||
|
||||
// rhp: If we are displaying this message for the purposes of printing, append
|
||||
// the magic operand.
|
||||
if (mPrintingOperation)
|
||||
urlStr.Append("?header=print");
|
||||
|
||||
|
||||
nsNewsAction action = nsINntpUrl::ActionFetchArticle;
|
||||
if (mOpenAttachmentOperation)
|
||||
action = nsINntpUrl::ActionFetchPart;
|
||||
|
||||
|
||||
nsCOMPtr<nsIURI> url;
|
||||
rv = ConstructNntpUrl(urlStr.get(), aUrlListener, aMsgWindow, aMessageURI, action, getter_AddRefs(url));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr <nsIMsgMailNewsUrl> msgUrl = do_QueryInterface(url,&rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
|
||||
nsCOMPtr<nsIMsgI18NUrl> i18nurl = do_QueryInterface(msgUrl,&rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
|
||||
i18nurl->SetCharsetOverRide(aCharsetOverride);
|
||||
|
||||
|
||||
PRBool shouldStoreMsgOffline = PR_FALSE;
|
||||
PRBool hasMsgOffline = PR_FALSE;
|
||||
|
||||
|
||||
if (folder)
|
||||
{
|
||||
nsCOMPtr <nsIMsgNewsFolder> newsFolder = do_QueryInterface(folder);
|
||||
@@ -297,7 +297,7 @@ nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayCon
|
||||
if (!hasMsgOffline)
|
||||
{
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
|
||||
|
||||
rv = folder->GetServer(getter_AddRefs(server));
|
||||
if (server)
|
||||
return server->DisplayOfflineMsg(aMsgWindow);
|
||||
@@ -306,26 +306,26 @@ nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayCon
|
||||
newsFolder->SetSaveArticleOffline(shouldStoreMsgOffline);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// now is where our behavior differs....if the consumer is the docshell then we want to
|
||||
// run the url in the webshell in order to display it. If it isn't a docshell then just
|
||||
// run the news url like we would any other news url.
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aDisplayConsumer, &rv));
|
||||
if (NS_SUCCEEDED(rv) && docShell)
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aDisplayConsumer, &rv));
|
||||
if (NS_SUCCEEDED(rv) && docShell)
|
||||
{
|
||||
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
|
||||
// DIRTY LITTLE HACK --> if we are opening an attachment we want the docshell to
|
||||
// treat this load as if it were a user click event. Then the dispatching stuff will be much
|
||||
// happier.
|
||||
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
|
||||
// DIRTY LITTLE HACK --> if we are opening an attachment we want the docshell to
|
||||
// treat this load as if it were a user click event. Then the dispatching stuff will be much
|
||||
// happier.
|
||||
if (mOpenAttachmentOperation)
|
||||
{
|
||||
docShell->CreateLoadInfo(getter_AddRefs(loadInfo));
|
||||
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadLink);
|
||||
}
|
||||
|
||||
rv = docShell->LoadURI(url, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, PR_FALSE);
|
||||
}
|
||||
else
|
||||
docShell->CreateLoadInfo(getter_AddRefs(loadInfo));
|
||||
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadLink);
|
||||
}
|
||||
|
||||
rv = docShell->LoadURI(url, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, PR_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIStreamListener> aStreamListener = do_QueryInterface(aDisplayConsumer, &rv);
|
||||
if (NS_SUCCEEDED(rv) && aStreamListener)
|
||||
@@ -350,13 +350,14 @@ nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayCon
|
||||
rv = aChannel->AsyncOpen(aStreamListener, aCtxt);
|
||||
}
|
||||
else
|
||||
rv = RunNewsUrl(url, aMsgWindow, aDisplayConsumer);
|
||||
}
|
||||
rv = RunNewsUrl(url, aMsgWindow, aDisplayConsumer);
|
||||
}
|
||||
}
|
||||
|
||||
if (aURL) {
|
||||
*aURL = url;
|
||||
NS_IF_ADDREF(*aURL);
|
||||
|
||||
if (aURL)
|
||||
{
|
||||
*aURL = url;
|
||||
NS_IF_ADDREF(*aURL);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user