fix imap not to download all msg headers r=naving, sr=sspitzer 137994

This commit is contained in:
bienvenu%netscape.com 2002-04-18 23:40:22 +00:00
Родитель 6f56cb346d
Коммит 8ef85eab23
8 изменённых файлов: 37 добавлений и 24 удалений

Просмотреть файл

@ -69,7 +69,7 @@ interface nsIMsgFilterList : nsISupports {
attribute nsIMsgFolder folder; attribute nsIMsgFolder folder;
readonly attribute short version; readonly attribute short version;
readonly attribute string arbitraryHeaders; readonly attribute string arbitraryHeaders;
readonly attribute boolean shouldDownloadArbitraryHeaders; readonly attribute boolean shouldDownloadAllHeaders;
readonly attribute unsigned long filterCount; readonly attribute unsigned long filterCount;
nsIMsgFilter getFilterAt(in unsigned long filterIndex); nsIMsgFilter getFilterAt(in unsigned long filterIndex);
nsIMsgFilter getFilterNamed(in wstring filterName); nsIMsgFilter getFilterNamed(in wstring filterName);

Просмотреть файл

@ -985,7 +985,16 @@ NS_IMETHODIMP nsMsgFilterList::MatchOrChangeFilterTarget(const char *oldFolderUr
return rv; return rv;
} }
NS_IMETHODIMP nsMsgFilterList::GetShouldDownloadArbitraryHeaders(PRBool *aResult) // this would only return true if any filter was on "any header", which we
// don't support in 6.x
NS_IMETHODIMP nsMsgFilterList::GetShouldDownloadAllHeaders(PRBool *aResult)
{
*aResult = PR_FALSE;
return NS_OK;
}
// leaves m_arbitraryHeaders filed in with the arbitrary headers.
nsresult nsMsgFilterList::ComputeArbitraryHeaders()
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (m_arbitraryHeaders.Length() == 0) if (m_arbitraryHeaders.Length() == 0)
@ -1025,17 +1034,13 @@ NS_IMETHODIMP nsMsgFilterList::GetShouldDownloadArbitraryHeaders(PRBool *aResult
} }
} }
} }
if (m_arbitraryHeaders.Length() > 0) //if any arbitraryHeaders; return rv;
*aResult=PR_TRUE;
return NS_OK;
} }
NS_IMETHODIMP nsMsgFilterList::GetArbitraryHeaders(char **aResult) NS_IMETHODIMP nsMsgFilterList::GetArbitraryHeaders(char **aResult)
{ {
PRBool headers=PR_FALSE; ComputeArbitraryHeaders();
GetShouldDownloadArbitraryHeaders(&headers); *aResult = ToNewCString(m_arbitraryHeaders);
if (headers)
*aResult = ToNewCString(m_arbitraryHeaders);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -83,6 +83,7 @@ protected:
void Dump(); void Dump();
#endif #endif
protected: protected:
nsresult ComputeArbitraryHeaders();
nsresult SaveTextFilters(nsIOFileStream *aStream); nsresult SaveTextFilters(nsIOFileStream *aStream);
// file streaming methods // file streaming methods
char ReadChar(nsIOFileStream *aStream); char ReadChar(nsIOFileStream *aStream);

Просмотреть файл

@ -289,6 +289,7 @@ nsMsgSearchTerm::nsMsgSearchTerm()
m_value.string=nsnull; m_value.string=nsnull;
m_value.attribute=0; m_value.attribute=0;
m_value.u.priority=0; m_value.u.priority=0;
m_attribute = nsMsgSearchAttrib::Default;
} }
nsMsgSearchTerm::nsMsgSearchTerm ( nsMsgSearchTerm::nsMsgSearchTerm (

Просмотреть файл

@ -73,6 +73,6 @@ interface nsIImapServerSink : nsISupports {
/* this is a bogus method on this interface but i need it until misc. sink is scriptable.. */ /* this is a bogus method on this interface but i need it until misc. sink is scriptable.. */
void RemoveChannelFromUrl(in nsIMsgMailNewsUrl aUrl, in unsigned long statusCode); void RemoveChannelFromUrl(in nsIMsgMailNewsUrl aUrl, in unsigned long statusCode);
readonly attribute string arbitraryHeaders; readonly attribute string arbitraryHeaders;
readonly attribute boolean shouldDownloadArbitraryHeaders; readonly attribute boolean shouldDownloadAllHeaders;
}; };

Просмотреть файл

@ -3591,14 +3591,14 @@ nsImapIncomingServer::GetNewMessagesAllFolders(nsIMsgFolder *aRootFolder, nsIMsg
} }
NS_IMETHODIMP NS_IMETHODIMP
nsImapIncomingServer::GetShouldDownloadArbitraryHeaders(PRBool *aResult) nsImapIncomingServer::GetShouldDownloadAllHeaders(PRBool *aResult)
{ {
nsresult rv = NS_OK; //for now checking for filters is enough nsresult rv = NS_OK; //for now checking for filters is enough
nsCOMPtr <nsIMsgFilterList> filterList; //later on we might have to check for MDN ; nsCOMPtr <nsIMsgFilterList> filterList; //later on we might have to check for MDN ;
if (!mFilterList) if (!mFilterList)
GetFilterList(nsnull, getter_AddRefs(filterList)); GetFilterList(nsnull, getter_AddRefs(filterList));
if (mFilterList) if (mFilterList)
rv = mFilterList->GetShouldDownloadArbitraryHeaders(aResult); rv = mFilterList->GetShouldDownloadAllHeaders(aResult);
else else
*aResult = PR_FALSE; *aResult = PR_FALSE;
return rv; return rv;

Просмотреть файл

@ -231,6 +231,7 @@ nsImapProtocol::nsImapProtocol() :
m_flags = 0; m_flags = 0;
m_urlInProgress = PR_FALSE; m_urlInProgress = PR_FALSE;
m_socketIsOpen = PR_FALSE; m_socketIsOpen = PR_FALSE;
m_ignoreExpunges = PR_FALSE;
m_gotFEEventCompletion = PR_FALSE; m_gotFEEventCompletion = PR_FALSE;
m_connectionStatus = 0; m_connectionStatus = 0;
m_hostSessionList = nsnull; m_hostSessionList = nsnull;
@ -600,7 +601,12 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
GetServerStateParser().SetCapabilityFlag(capability); GetServerStateParser().SetCapabilityFlag(capability);
if (imapServer) if (imapServer)
{
nsXPIDLCString redirectorType;
imapServer->GetRedirectorType(getter_Copies(redirectorType));
m_ignoreExpunges = redirectorType.Equals("aol");
imapServer->GetFetchByChunks(&m_fetchByChunks); imapServer->GetFetchByChunks(&m_fetchByChunks);
}
if ( m_runningUrl && !m_channel /* and we don't have a transport yet */) if ( m_runningUrl && !m_channel /* and we don't have a transport yet */)
{ {
@ -2304,10 +2310,10 @@ nsresult nsImapProtocol::BeginMessageDownLoad(
} }
void void
nsImapProtocol::GetShouldDownloadArbitraryHeaders(PRBool *aResult) nsImapProtocol::GetShouldDownloadAllHeaders(PRBool *aResult)
{ {
if (m_imapServerSink) if (m_imapServerSink)
m_imapServerSink->GetShouldDownloadArbitraryHeaders(aResult); m_imapServerSink->GetShouldDownloadAllHeaders(aResult);
} }
void void
@ -2576,21 +2582,20 @@ nsImapProtocol::FetchMessage(const char * messageIds,
if (GetServerStateParser().ServerHasIMAP4Rev1Capability()) if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
{ {
PRUint32 server_capabilityFlags = GetServerStateParser().GetCapabilityFlag(); PRUint32 server_capabilityFlags = GetServerStateParser().GetCapabilityFlag();
PRBool aolImapServer = ((server_capabilityFlags & kAOLImapCapability) != 0); PRBool aolImapServer = ((server_capabilityFlags & kAOLImapCapability) != 0);
PRBool useArbitraryHeaders = PR_FALSE; PRBool downloadAllHeaders = PR_FALSE; // we don't currently ever need to do this.
GetShouldDownloadArbitraryHeaders(&useArbitraryHeaders); // checks filter headers, etc. // GetShouldDownloadAllHeaders(&downloadAllHeaders); // checks if we're filtering on "any header"
if (/***** Fix me *** gOptimizedHeaders && */// preference -- able to turn it off if (!downloadAllHeaders) // if it's ok -- no filters on any header, etc.
useArbitraryHeaders) // if it's ok -- no filters on any header, etc.
{ {
char *headersToDL = nsnull; char *headersToDL = nsnull;
char *what = nsnull; char *what = nsnull;
const char *dbHeaders = (gUseEnvelopeCmd) ? IMAP_DB_HEADERS : IMAP_ENV_AND_DB_HEADERS; const char *dbHeaders = (gUseEnvelopeCmd) ? IMAP_DB_HEADERS : IMAP_ENV_AND_DB_HEADERS;
nsXPIDLCString arbitraryHeaders; nsXPIDLCString arbitraryHeaders;
GetArbitraryHeadersToDownload(getter_Copies(arbitraryHeaders)); GetArbitraryHeadersToDownload(getter_Copies(arbitraryHeaders));
if (arbitraryHeaders) if (arbitraryHeaders.IsEmpty())
headersToDL = PR_smprintf("%s %s",dbHeaders, arbitraryHeaders.get());
else
headersToDL = nsCRT::strdup(dbHeaders); headersToDL = nsCRT::strdup(dbHeaders);
else
headersToDL = PR_smprintf("%s %s",dbHeaders, arbitraryHeaders.get());
if (aolImapServer) if (aolImapServer)
what = nsCRT::strdup(" XAOL-ENVELOPE INTERNALDATE)"); what = nsCRT::strdup(" XAOL-ENVELOPE INTERNALDATE)");

Просмотреть файл

@ -173,7 +173,7 @@ public:
static void EscapeUserNamePasswordString(const char *strToEscape, nsCString *resultStr); static void EscapeUserNamePasswordString(const char *strToEscape, nsCString *resultStr);
// used to start fetching a message. // used to start fetching a message.
void GetShouldDownloadArbitraryHeaders(PRBool *aResult); void GetShouldDownloadAllHeaders(PRBool *aResult);
void GetArbitraryHeadersToDownload(char **aResult); void GetArbitraryHeadersToDownload(char **aResult);
virtual void AdjustChunkSize(); virtual void AdjustChunkSize();
virtual void FetchMessage(const char * messageIds, virtual void FetchMessage(const char * messageIds,
@ -222,7 +222,7 @@ public:
// Used for MIME parts on demand. // Used for MIME parts on demand.
void SetContentModified(IMAP_ContentModifiedType modified); void SetContentModified(IMAP_ContentModifiedType modified);
PRBool GetShouldFetchAllParts(); PRBool GetShouldFetchAllParts();
PRBool GetIgnoreExpunges() {return m_ignoreExpunges;}
// Generic accessors required by the imap parser // Generic accessors required by the imap parser
char * CreateNewLineFromSocket(); char * CreateNewLineFromSocket();
PRInt32 GetConnectionStatus(); PRInt32 GetConnectionStatus();
@ -544,6 +544,7 @@ private:
PRInt32 m_chunkStartSize; PRInt32 m_chunkStartSize;
PRInt32 m_maxChunkSize; PRInt32 m_maxChunkSize;
PRBool m_fetchByChunks; PRBool m_fetchByChunks;
PRBool m_ignoreExpunges;
PRInt32 m_chunkSize; PRInt32 m_chunkSize;
PRInt32 m_chunkThreshold; PRInt32 m_chunkThreshold;
TLineDownloadCache m_downloadLineCache; TLineDownloadCache m_downloadLineCache;