зеркало из https://github.com/mozilla/pjs.git
try to speed up downloading for offline imap, get rid of obsolete method, notifystoreclosedallheaders, r/sr=mscott 214245
This commit is contained in:
Родитель
3e5d40f9b0
Коммит
6d119aa8fa
|
@ -144,8 +144,6 @@ NS_IMETHODIMP nsMsgDBFolder::Shutdown(PRBool shutdownChildren)
|
|||
|
||||
NS_IMETHODIMP nsMsgDBFolder::ForceDBClosed ()
|
||||
{
|
||||
NotifyStoreClosedAllHeaders();
|
||||
|
||||
PRUint32 cnt = 0, i;
|
||||
if (mSubFolders)
|
||||
{
|
||||
|
@ -1265,12 +1263,6 @@ NS_IMETHODIMP nsMsgDBFolder::IsCommandEnabled(const char *command, PRBool *resul
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgDBFolder::NotifyStoreClosedAllHeaders()
|
||||
{
|
||||
// don't need this anymore.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsMsgDBFolder::WriteStartOfNewLocalMessage()
|
||||
{
|
||||
|
@ -1317,7 +1309,18 @@ nsresult nsMsgDBFolder::WriteStartOfNewLocalMessage()
|
|||
|
||||
nsresult nsMsgDBFolder::StartNewOfflineMessage()
|
||||
{
|
||||
nsresult rv = GetOfflineStoreOutputStream(getter_AddRefs(m_tempMessageStream));
|
||||
nsresult rv = NS_OK;
|
||||
if (!m_tempMessageStream)
|
||||
rv = GetOfflineStoreOutputStream(getter_AddRefs(m_tempMessageStream));
|
||||
else
|
||||
{
|
||||
nsCOMPtr <nsISeekableStream> seekable;
|
||||
|
||||
seekable = do_QueryInterface(m_tempMessageStream);
|
||||
|
||||
if (seekable)
|
||||
seekable->Seek(PR_SEEK_END, 0);
|
||||
}
|
||||
if (NS_SUCCEEDED(rv))
|
||||
WriteStartOfNewLocalMessage();
|
||||
m_numOfflineMsgLines = 0;
|
||||
|
|
|
@ -138,7 +138,6 @@ protected:
|
|||
|
||||
nsresult GetFolderCacheKey(nsIFileSpec **aFileSpec);
|
||||
nsresult GetFolderCacheElemFromFileSpec(nsIFileSpec *fileSpec, nsIMsgFolderCacheElement **cacheElement);
|
||||
nsresult NotifyStoreClosedAllHeaders();
|
||||
|
||||
// offline support methods.
|
||||
nsresult StartNewOfflineMessage();
|
||||
|
|
|
@ -1361,7 +1361,6 @@ NS_IMETHODIMP nsImapMailFolder::RenameLocal(const char *newName, nsIMsgFolder *p
|
|||
leafname.Cut(0, leafpos+1);
|
||||
m_msgParser = nsnull;
|
||||
PrepareToRename();
|
||||
NotifyStoreClosedAllHeaders();
|
||||
ForceDBClosed();
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -2349,7 +2348,6 @@ NS_IMETHODIMP nsImapMailFolder::UpdateImapMailboxInfo(
|
|||
if (mDatabase)
|
||||
{
|
||||
dbFolderInfo = nsnull;
|
||||
NotifyStoreClosedAllHeaders();
|
||||
mDatabase->ForceClosed();
|
||||
}
|
||||
mDatabase = nsnull;
|
||||
|
@ -3455,53 +3453,27 @@ void nsImapMailFolder::FindKeysToAdd(const nsMsgKeyArray &existingKeys, nsMsgKey
|
|||
void nsImapMailFolder::PrepareToAddHeadersToMailDB(nsIImapProtocol* aProtocol, const nsMsgKeyArray &keysToFetch,
|
||||
nsIMailboxSpec *boxSpec)
|
||||
{
|
||||
PRUint32 *theKeys = (PRUint32 *) PR_Malloc( keysToFetch.GetSize() * sizeof(PRUint32) );
|
||||
if (theKeys)
|
||||
{
|
||||
PRUint32 *theKeys = (PRUint32 *) PR_Malloc( keysToFetch.GetSize() * sizeof(PRUint32) );
|
||||
if (theKeys)
|
||||
{
|
||||
PRUint32 total = keysToFetch.GetSize();
|
||||
|
||||
for (PRUint32 keyIndex=0; keyIndex < total; keyIndex++)
|
||||
theKeys[keyIndex] = keysToFetch[keyIndex];
|
||||
|
||||
// m_DownLoadState = kDownLoadingAllMessageHeaders;
|
||||
|
||||
nsresult res = NS_OK; /*ImapMailDB::Open(m_pathName,
|
||||
PR_TRUE, // create if necessary
|
||||
&mailDB,
|
||||
m_master,
|
||||
&dbWasCreated); */
|
||||
|
||||
// don't want to download headers in a composition pane
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
#if 0
|
||||
SetParseMailboxState(new ParseIMAPMailboxState(m_master, m_host, this,
|
||||
urlQueue,
|
||||
boxSpec->flagState));
|
||||
boxSpec->flagState = nsnull; // adopted by ParseIMAPMailboxState
|
||||
GetParseMailboxState()->SetPane(url_pane);
|
||||
|
||||
GetParseMailboxState()->SetDB(mailDB);
|
||||
GetParseMailboxState()->SetIncrementalUpdate(PR_TRUE);
|
||||
GetParseMailboxState()->SetMaster(m_master);
|
||||
GetParseMailboxState()->SetContext(url_pane->GetContext());
|
||||
GetParseMailboxState()->SetFolder(this);
|
||||
|
||||
GetParseMailboxState()->BeginParsingFolder(0);
|
||||
#endif // 0 hook up parsing later.
|
||||
// the imap libnet module will start downloading message headers imap.h
|
||||
if (aProtocol)
|
||||
aProtocol->NotifyHdrsToDownload(theKeys, total /*keysToFetch.GetSize() */);
|
||||
|
||||
for (PRUint32 keyIndex=0; keyIndex < total; keyIndex++)
|
||||
theKeys[keyIndex] = keysToFetch[keyIndex];
|
||||
|
||||
// tell the imap thread which hdrs to download
|
||||
if (aProtocol)
|
||||
{
|
||||
aProtocol->NotifyHdrsToDownload(theKeys, total /*keysToFetch.GetSize() */);
|
||||
// now, tell it we don't need any bodies.
|
||||
if (aProtocol)
|
||||
aProtocol->NotifyBodysToDownload(nsnull, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aProtocol)
|
||||
aProtocol->NotifyHdrsToDownload(nsnull, 0);
|
||||
}
|
||||
aProtocol->NotifyBodysToDownload(nsnull, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aProtocol)
|
||||
aProtocol->NotifyHdrsToDownload(nsnull, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -3699,7 +3671,7 @@ nsImapMailFolder::ParseAdoptedMsgLine(const char *adoptedMessageLine, nsMsgKey u
|
|||
nsresult rv = NS_OK;
|
||||
// remember the uid of the message we're downloading.
|
||||
m_curMsgUid = uidOfMessage;
|
||||
if (m_downloadMessageForOfflineUse && !m_tempMessageStream)
|
||||
if (m_downloadMessageForOfflineUse && !m_offlineHeader)
|
||||
{
|
||||
GetMessageHeader(uidOfMessage, getter_AddRefs(m_offlineHeader));
|
||||
rv = StartNewOfflineMessage();
|
||||
|
@ -3728,6 +3700,17 @@ nsImapMailFolder::ParseAdoptedMsgLine(const char *adoptedMessageLine, nsMsgKey u
|
|||
return rv;
|
||||
}
|
||||
|
||||
void nsImapMailFolder::EndOfflineDownload()
|
||||
{
|
||||
if (m_tempMessageStream)
|
||||
{
|
||||
m_tempMessageStream->Close();
|
||||
m_tempMessageStream = nsnull;
|
||||
if (mDatabase)
|
||||
mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMailFolder::NormalEndMsgWriteStream(nsMsgKey uidOfMessage,
|
||||
PRBool markRead,
|
||||
|
@ -3736,15 +3719,8 @@ nsImapMailFolder::NormalEndMsgWriteStream(nsMsgKey uidOfMessage,
|
|||
nsresult res = NS_OK;
|
||||
PRBool commit = PR_FALSE;
|
||||
if (m_offlineHeader)
|
||||
{
|
||||
EndNewOfflineMessage();
|
||||
commit = PR_TRUE;
|
||||
}
|
||||
if (m_tempMessageStream)
|
||||
{
|
||||
m_tempMessageStream->Close();
|
||||
m_tempMessageStream = nsnull;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr;
|
||||
m_curMsgUid = uidOfMessage;
|
||||
res = GetMessageHeader(m_curMsgUid, getter_AddRefs(msgHdr));
|
||||
|
@ -4231,12 +4207,14 @@ NS_IMETHODIMP
|
|||
nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRBool endedOfflineDownload = PR_FALSE;
|
||||
m_urlRunning = PR_FALSE;
|
||||
if (m_downloadingFolderForOfflineUse)
|
||||
{
|
||||
ReleaseSemaphore(NS_STATIC_CAST(nsIMsgImapMailFolder*, this));
|
||||
m_downloadingFolderForOfflineUse = PR_FALSE;
|
||||
endedOfflineDownload = PR_TRUE;
|
||||
EndOfflineDownload();
|
||||
}
|
||||
nsCOMPtr<nsIMsgMailSession> session =
|
||||
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
||||
|
@ -4264,6 +4242,8 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
|
|||
{
|
||||
ReleaseSemaphore(NS_STATIC_CAST(nsIMsgImapMailFolder*, this));
|
||||
SetNotifyDownloadedLines(PR_FALSE);
|
||||
if (!endedOfflineDownload)
|
||||
EndOfflineDownload();
|
||||
}
|
||||
|
||||
switch(imapAction)
|
||||
|
@ -4602,13 +4582,9 @@ NS_IMETHODIMP
|
|||
nsImapMailFolder::RefreshFolderRights()
|
||||
{
|
||||
if (GetFolderACL()->GetIsFolderShared())
|
||||
{
|
||||
SetFlag(MSG_FOLDER_FLAG_PERSONAL_SHARED);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearFlag(MSG_FOLDER_FLAG_PERSONAL_SHARED);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -4695,37 +4671,33 @@ nsImapMailFolder::NotifySearchHit(nsIMsgMailNewsUrl * aUrl,
|
|||
currentPosition += strlen("SEARCH");
|
||||
char *newStr;
|
||||
|
||||
PRBool shownUpdateAlert = PR_FALSE;
|
||||
char *hitUidToken = nsCRT::strtok(currentPosition, WHITESPACE, &newStr);
|
||||
while (hitUidToken)
|
||||
PRBool shownUpdateAlert = PR_FALSE;
|
||||
char *hitUidToken = nsCRT::strtok(currentPosition, WHITESPACE, &newStr);
|
||||
while (hitUidToken)
|
||||
{
|
||||
long naturalLong; // %l is 64 bits on OSF1
|
||||
sscanf(hitUidToken, "%ld", &naturalLong);
|
||||
nsMsgKey hitUid = (nsMsgKey) naturalLong;
|
||||
|
||||
nsCOMPtr <nsIMsgDBHdr> hitHeader;
|
||||
rv = mDatabase->GetMsgHdrForKey(hitUid, getter_AddRefs(hitHeader));
|
||||
if (NS_SUCCEEDED(rv) && hitHeader)
|
||||
{
|
||||
long naturalLong; // %l is 64 bits on OSF1
|
||||
sscanf(hitUidToken, "%ld", &naturalLong);
|
||||
nsMsgKey hitUid = (nsMsgKey) naturalLong;
|
||||
nsCOMPtr <nsIMsgSearchSession> searchSession;
|
||||
nsCOMPtr <nsIMsgSearchAdapter> searchAdapter;
|
||||
aUrl->GetSearchSession(getter_AddRefs(searchSession));
|
||||
if (searchSession)
|
||||
{
|
||||
searchSession->GetRunningAdapter(getter_AddRefs(searchAdapter));
|
||||
if (searchAdapter)
|
||||
searchAdapter->AddResultElement(hitHeader);
|
||||
}
|
||||
}
|
||||
else if (!shownUpdateAlert)
|
||||
{
|
||||
}
|
||||
|
||||
nsCOMPtr <nsIMsgDBHdr> hitHeader;
|
||||
rv = mDatabase->GetMsgHdrForKey(hitUid, getter_AddRefs(hitHeader));
|
||||
if (NS_SUCCEEDED(rv) && hitHeader)
|
||||
{
|
||||
nsCOMPtr <nsIMsgSearchSession> searchSession;
|
||||
nsCOMPtr <nsIMsgSearchAdapter> searchAdapter;
|
||||
aUrl->GetSearchSession(getter_AddRefs(searchSession));
|
||||
if (searchSession)
|
||||
{
|
||||
searchSession->GetRunningAdapter(getter_AddRefs(searchAdapter));
|
||||
if (searchAdapter)
|
||||
searchAdapter->AddResultElement(hitHeader);
|
||||
}
|
||||
}
|
||||
else if (!shownUpdateAlert)
|
||||
{
|
||||
#if 0 // can't do this yet
|
||||
FE_Alert(context, XP_GetString(MK_MSG_SEARCH_HITS_NOT_IN_DB));
|
||||
shownUpdateAlert = PR_TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
hitUidToken = nsCRT::strtok(newStr, WHITESPACE, &newStr);
|
||||
hitUidToken = nsCRT::strtok(newStr, WHITESPACE, &newStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4755,8 +4727,6 @@ nsImapMailFolder::SetAppendMsgUid(nsIImapProtocol* aProtocol,
|
|||
|
||||
if (mailCopyState->m_undoMsgTxn) // CopyMessages()
|
||||
{
|
||||
// nsImapMailCopyState* mailCopyState =
|
||||
// (nsImapMailCopyState*) copyState;
|
||||
nsCOMPtr<nsImapMoveCopyMsgTxn> msgTxn;
|
||||
msgTxn = do_QueryInterface(mailCopyState->m_undoMsgTxn, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
@ -4876,7 +4846,7 @@ nsImapMailFolder::SetBiffStateAndUpdate(nsIImapProtocol* aProtocol,
|
|||
nsMsgBiffState biffState)
|
||||
{
|
||||
SetBiffState(biffState);
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -5641,6 +5611,7 @@ nsImapMailFolder::SetUrlState(nsIImapProtocol* aProtocol,
|
|||
{
|
||||
ProgressStatus(aProtocol, IMAP_DONE, nsnull);
|
||||
m_urlRunning = PR_FALSE;
|
||||
EndOfflineDownload();
|
||||
if (m_downloadingFolderForOfflineUse)
|
||||
{
|
||||
ReleaseSemaphore(NS_STATIC_CAST(nsIMsgImapMailFolder*, this));
|
||||
|
|
|
@ -365,6 +365,8 @@ protected:
|
|||
nsresult ParseAdoptedHeaderLine(const char *messageLine, PRUint32 msgKey);
|
||||
nsresult NormalEndHeaderParseStream(nsIImapProtocol *aProtocol);
|
||||
|
||||
void EndOfflineDownload();
|
||||
|
||||
nsresult MarkMessagesImapDeleted(nsMsgKeyArray *keyArray, PRBool deleted, nsIMsgDatabase *db);
|
||||
|
||||
void UpdatePendingCounts(PRBool countUnread, PRBool missingAreRead);
|
||||
|
@ -463,8 +465,7 @@ protected:
|
|||
// "Other Users' Mailboxes"
|
||||
|
||||
nsCString m_adminUrl; // url to run to set admin privileges for this folder
|
||||
nsIMAPNamespace *m_namespace; // Opaque pointer to the IMAP namespace for this folder
|
||||
// Use libnet accessors for various namespace functionality
|
||||
nsIMAPNamespace *m_namespace;
|
||||
PRPackedBool m_verifiedAsOnlineFolder;
|
||||
PRPackedBool m_explicitlyVerify; // whether or not we need to explicitly verify this through LIST
|
||||
PRPackedBool m_folderIsNamespace;
|
||||
|
|
|
@ -1107,7 +1107,6 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Delete()
|
|||
|
||||
if(mDatabase)
|
||||
{
|
||||
NotifyStoreClosedAllHeaders();
|
||||
mDatabase->ForceClosed();
|
||||
mDatabase = nsnull;
|
||||
}
|
||||
|
@ -1260,7 +1259,6 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
|
|||
return rv;
|
||||
}
|
||||
|
||||
NotifyStoreClosedAllHeaders();
|
||||
ForceDBClosed();
|
||||
|
||||
nsCAutoString newNameDirStr(newDiskName.get()); //save of dir name before appending .msf
|
||||
|
|
Загрузка…
Ссылка в новой задаче