From 2c7746fcdc0d27d7b88ba5ed05a3ca6c74ea319a Mon Sep 17 00:00:00 2001 From: "bienvenu%netscape.com" Date: Mon, 3 Apr 2000 03:22:56 +0000 Subject: [PATCH] remove unused view attachments as links option, work on in-reply-to header, r=sspitzer --- mailnews/base/public/nsIMsgHdr.idl | 1 + mailnews/base/util/nsMessage.cpp | 17 ++++++ mailnews/db/msgdb/src/nsMsgHdr.cpp | 15 ++++++ .../imap/public/nsIImapMiscellaneousSink.h | 2 - mailnews/imap/src/nsIMAPBodyShell.cpp | 21 +------- mailnews/imap/src/nsIMAPBodyShell.h | 3 -- mailnews/imap/src/nsImapMailFolder.cpp | 13 ----- mailnews/imap/src/nsImapMailFolder.h | 2 - mailnews/imap/src/nsImapProtocol.cpp | 22 +------- mailnews/imap/src/nsImapProtocol.h | 1 - mailnews/imap/src/nsImapProxyEvent.cpp | 53 ------------------- mailnews/imap/src/nsImapProxyEvent.h | 12 ----- mailnews/local/src/nsParseMailbox.cpp | 7 +++ mailnews/local/src/nsParseMailbox.h | 1 + 14 files changed, 44 insertions(+), 126 deletions(-) diff --git a/mailnews/base/public/nsIMsgHdr.idl b/mailnews/base/public/nsIMsgHdr.idl index 523b35866e27..20d2624904f5 100644 --- a/mailnews/base/public/nsIMsgHdr.idl +++ b/mailnews/base/public/nsIMsgHdr.idl @@ -80,6 +80,7 @@ interface nsIMsgHdr : nsISupports attribute string subject; attribute string recipients; attribute boolean recipientsIsNewsgroup; + attribute string inReplyTo; /* anything below here still has to be fixed */ void setReferences(in string references); diff --git a/mailnews/base/util/nsMessage.cpp b/mailnews/base/util/nsMessage.cpp index 7227e16d0f89..f57c4b98641d 100644 --- a/mailnews/base/util/nsMessage.cpp +++ b/mailnews/base/util/nsMessage.cpp @@ -145,6 +145,15 @@ NS_IMETHODIMP nsMessage::SetMessageId(const char *messageId) return NS_ERROR_FAILURE; } +NS_IMETHODIMP nsMessage::SetInReplyTo(const char *inReplyTo) +{ + if(mMsgHdr) + return mMsgHdr->SetInReplyTo(inReplyTo); + else + return NS_ERROR_FAILURE; +} + + NS_IMETHODIMP nsMessage::SetReferences(const char *references) { if(mMsgHdr) @@ -266,6 +275,14 @@ NS_IMETHODIMP nsMessage::GetMessageId(char **resultMessageId) return NS_ERROR_FAILURE; } +NS_IMETHODIMP nsMessage::GetInReplyTo(char **resultInReplyTo) +{ + if(mMsgHdr) + return mMsgHdr->GetInReplyTo(resultInReplyTo); + else + return NS_ERROR_FAILURE; +} + NS_IMETHODIMP nsMessage::GetMime2DecodedAuthor(PRUnichar **resultAuthor) { diff --git a/mailnews/db/msgdb/src/nsMsgHdr.cpp b/mailnews/db/msgdb/src/nsMsgHdr.cpp index d97863faeb96..d4cc80d28e09 100644 --- a/mailnews/db/msgdb/src/nsMsgHdr.cpp +++ b/mailnews/db/msgdb/src/nsMsgHdr.cpp @@ -356,6 +356,13 @@ NS_IMETHODIMP nsMsgHdr::SetMessageId(const char *messageId) return SetStringColumn(messageId, m_mdb->m_messageIdColumnToken); } +NS_IMETHODIMP nsMsgHdr::SetInReplyTo(const char *inReplyTo) +{ + // not sure how to implement this - it doesn't need to be persistent, + // but we don't need to take up extra space for this header either. + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsMsgHdr::SetSubject(const char *subject) { return SetStringColumn(subject, m_mdb->m_subjectColumnToken); @@ -584,6 +591,14 @@ NS_IMETHODIMP nsMsgHdr::GetMessageId(char * *resultMessageId) return m_mdb->RowCellColumnToCharPtr(GetMDBRow(), m_mdb->m_messageIdColumnToken, resultMessageId); } +NS_IMETHODIMP nsMsgHdr::GetInReplyTo(char * *resultInReplyTo) +{ + // not sure how to implement this yet. + return NS_ERROR_NOT_IMPLEMENTED; +// return m_mdb->RowCellColumnToCharPtr(GetMDBRow(), m_mdb->m_messageIdColumnToken, resultMessageId); +} + + NS_IMETHODIMP nsMsgHdr::GetMime2DecodedAuthor(PRUnichar* *resultAuthor) { return m_mdb->RowCellColumnToMime2DecodedString(GetMDBRow(), m_mdb->m_senderColumnToken, resultAuthor); diff --git a/mailnews/imap/public/nsIImapMiscellaneousSink.h b/mailnews/imap/public/nsIImapMiscellaneousSink.h index 435ace683394..0bef9d419c8c 100644 --- a/mailnews/imap/public/nsIImapMiscellaneousSink.h +++ b/mailnews/imap/public/nsIImapMiscellaneousSink.h @@ -54,8 +54,6 @@ public: GenericInfo* aInfo) = 0; NS_IMETHOD GetShouldDownloadArbitraryHeaders(nsIImapProtocol* aProtocol, GenericInfo* aInfo) = 0; - NS_IMETHOD GetShowAttachmentsInline(nsIImapProtocol* aProtocol, - PRBool* aBool) = 0; NS_IMETHOD HeaderFetchCompleted(nsIImapProtocol* aProtocol) = 0; NS_IMETHOD UpdateSecurityStatus(nsIImapProtocol* aProtocol) = 0; // **** diff --git a/mailnews/imap/src/nsIMAPBodyShell.cpp b/mailnews/imap/src/nsIMAPBodyShell.cpp index a67a746fbbf1..74dc08b4e6a2 100644 --- a/mailnews/imap/src/nsIMAPBodyShell.cpp +++ b/mailnews/imap/src/nsIMAPBodyShell.cpp @@ -77,7 +77,6 @@ nsIMAPBodyShell::nsIMAPBodyShell(nsImapProtocol *protocolConnection, const char m_cached = PR_FALSE; m_gotAttachmentPref = PR_FALSE; m_generatingWholeMessage = PR_FALSE; - m_showAttachmentsInline = PR_TRUE; m_generatingPart = NULL; m_protocolConnection = protocolConnection; NS_ASSERTION(m_protocolConnection, "non null connection"); @@ -99,10 +98,7 @@ nsIMAPBodyShell::nsIMAPBodyShell(nsImapProtocol *protocolConnection, const char m_folderName = nsCRT::strdup(folderName); if (!m_folderName) return; - if (GetShowAttachmentsInline()) - SetContentModified(IMAP_CONTENT_MODIFIED_VIEW_INLINE); - else - SetContentModified(IMAP_CONTENT_MODIFIED_VIEW_AS_LINKS); + SetContentModified(IMAP_CONTENT_MODIFIED_VIEW_INLINE); // Turn the BODYSTRUCTURE response into a form that the nsIMAPBodypartMessage can be constructed from. char *doctoredBuf = PR_smprintf("(\"message\" \"rfc822\" NIL NIL NIL NIL 0 () %s 0)", buf); if (!doctoredBuf) @@ -129,18 +125,6 @@ void nsIMAPBodyShell::SetIsValid(PRBool valid) } -PRBool nsIMAPBodyShell::GetShowAttachmentsInline() -{ - if (!m_gotAttachmentPref) - { - m_showAttachmentsInline = m_protocolConnection->GetShowAttachmentsInline(); - m_gotAttachmentPref = PR_TRUE; - } - - return m_showAttachmentsInline; -} - - // Fills in buffer (and adopts storage) for header object void nsIMAPBodyShell::AdoptMessageHeaders(char *headers, const char *partNum) { @@ -1138,9 +1122,6 @@ PRBool nsIMAPBodypartMessage::ShouldFetchInline() return PR_FALSE; - if (!m_shell->GetShowAttachmentsInline()) - return PR_FALSE; - // Message types are inline, by default. return PR_TRUE; } diff --git a/mailnews/imap/src/nsIMAPBodyShell.h b/mailnews/imap/src/nsIMAPBodyShell.h index 7703b84abf24..f618401c5770 100644 --- a/mailnews/imap/src/nsIMAPBodyShell.h +++ b/mailnews/imap/src/nsIMAPBodyShell.h @@ -255,8 +255,6 @@ public: // If partNum is not NULL, then this works to generates a MIME part that hasn't been downloaded yet // and leaves out all other parts. By default, to generate a normal message, partNum should be NULL. - PRBool GetShowAttachmentsInline(); // Returns PR_TRUE if the user has the pref "Show Attachments Inline" set. - // Returns PR_FALSE if the setting is "Show Attachments as Links" PRBool PreflightCheckAllInline(); // Returns PR_TRUE if all parts are inline, PR_FALSE otherwise. Does not generate anything. // Helpers @@ -286,7 +284,6 @@ protected: char *m_folderName; // folder that contains this message char *m_generatingPart; // If a specific part is being generated, this is it. Otherwise, NULL. PRBool m_isBeingGenerated; // PR_TRUE if this body shell is in the process of being generated - PRBool m_showAttachmentsInline; PRBool m_gotAttachmentPref; PRBool m_cached; // Whether or not this shell is cached PRBool m_generatingWholeMessage; // whether or not we are generating the whole (non-MPOD) message diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index 8d6fe3e91ec8..abfd19b914f9 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -3343,19 +3343,6 @@ nsImapMailFolder::GetShouldDownloadArbitraryHeaders(nsIImapProtocol* aProtocol, return NS_ERROR_FAILURE; } -NS_IMETHODIMP -nsImapMailFolder::GetShowAttachmentsInline(nsIImapProtocol* aProtocol, - PRBool* aBool) -{ - if (!aBool) - return NS_ERROR_NULL_POINTER; - nsresult rv; - NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv); - if (NS_SUCCEEDED(rv) && prefs) - prefs->GetBoolPref("mail.inline_attachments", aBool); - return rv; -} - NS_IMETHODIMP nsImapMailFolder::HeaderFetchCompleted(nsIImapProtocol* aProtocol) { diff --git a/mailnews/imap/src/nsImapMailFolder.h b/mailnews/imap/src/nsImapMailFolder.h index cb16afbeea11..9c93064b7cb4 100644 --- a/mailnews/imap/src/nsImapMailFolder.h +++ b/mailnews/imap/src/nsImapMailFolder.h @@ -218,8 +218,6 @@ public: GenericInfo* aInfo); NS_IMETHOD GetShouldDownloadArbitraryHeaders(nsIImapProtocol* aProtocol, GenericInfo* aInfo); - NS_IMETHOD GetShowAttachmentsInline(nsIImapProtocol* aProtocol, - PRBool* aBool); NS_IMETHOD HeaderFetchCompleted(nsIImapProtocol* aProtocol); NS_IMETHOD UpdateSecurityStatus(nsIImapProtocol* aProtocol); // **** diff --git a/mailnews/imap/src/nsImapProtocol.cpp b/mailnews/imap/src/nsImapProtocol.cpp index 4b64d46bb39e..08b63024cca2 100644 --- a/mailnews/imap/src/nsImapProtocol.cpp +++ b/mailnews/imap/src/nsImapProtocol.cpp @@ -1677,9 +1677,7 @@ void nsImapProtocol::ProcessSelectedStateURL() // We actually want a specific MIME part of the message. // The Body Shell will generate it, even though we haven't downloaded it yet. - IMAP_ContentModifiedType modType = GetShowAttachmentsInline() ? - IMAP_CONTENT_MODIFIED_VIEW_INLINE : - IMAP_CONTENT_MODIFIED_VIEW_AS_LINKS; + IMAP_ContentModifiedType modType = IMAP_CONTENT_MODIFIED_VIEW_INLINE ; nsIMAPBodyShell *foundShell = nsnull; res = m_hostSessionList->FindShellInCacheForHost(GetImapServerKey(), @@ -1738,9 +1736,7 @@ void nsImapProtocol::ProcessSelectedStateURL() // Before fetching the bodystructure, let's check our body shell cache to see if // we already have it around. nsIMAPBodyShell *foundShell = NULL; - IMAP_ContentModifiedType modType = GetShowAttachmentsInline() ? - IMAP_CONTENT_MODIFIED_VIEW_INLINE : - IMAP_CONTENT_MODIFIED_VIEW_AS_LINKS; + IMAP_ContentModifiedType modType = IMAP_CONTENT_MODIFIED_VIEW_INLINE; nsCOMPtr mailurl = do_QueryInterface(m_runningUrl); if (mailurl) @@ -3336,20 +3332,6 @@ PRUint32 nsImapProtocol::GetMessageSize(const char * messageId, return 0; } - -PRBool nsImapProtocol::GetShowAttachmentsInline() -{ - PRBool *rv = (PRBool*) new PRBool(PR_FALSE); - - if (m_imapMiscellaneousSink && rv) - { - m_imapMiscellaneousSink->GetShowAttachmentsInline(this, rv); - WaitForFEEventCompletion(); - return *rv; - } - return PR_FALSE; -} - // message id string utility functions /* static */PRBool nsImapProtocol::HandlingMultipleMessages(const char *messageIdString) { diff --git a/mailnews/imap/src/nsImapProtocol.h b/mailnews/imap/src/nsImapProtocol.h index a93d0753a9e6..bfffe8d3ac3a 100644 --- a/mailnews/imap/src/nsImapProtocol.h +++ b/mailnews/imap/src/nsImapProtocol.h @@ -182,7 +182,6 @@ public: // Comment from 4.5: We really need to break out the thread synchronizer from the // connection class...Not sure what this means - PRBool GetShowAttachmentsInline(); PRBool GetPseudoInterrupted(); void PseudoInterrupt(PRBool the_interrupt); diff --git a/mailnews/imap/src/nsImapProxyEvent.cpp b/mailnews/imap/src/nsImapProxyEvent.cpp index f1f70aeb4b6a..b741166bbe36 100644 --- a/mailnews/imap/src/nsImapProxyEvent.cpp +++ b/mailnews/imap/src/nsImapProxyEvent.cpp @@ -440,38 +440,6 @@ nsImapMiscellaneousSinkProxy::GetShouldDownloadArbitraryHeaders( return res; } -NS_IMETHODIMP -nsImapMiscellaneousSinkProxy::GetShowAttachmentsInline( - nsIImapProtocol* aProtocol, PRBool* aBool) -{ - nsresult res = NS_OK; - NS_PRECONDITION (aBool, "Oops... null aBool"); - if(!aBool) - return NS_ERROR_NULL_POINTER; - NS_ASSERTION (m_protocol == aProtocol, "Ooh ooh, wrong protocol"); - - if (PR_GetCurrentThread() == m_thread) - { - GetShowAttachmentsInlineProxyEvent *ev = - new GetShowAttachmentsInlineProxyEvent(this, aBool); - if(nsnull == ev) - res = NS_ERROR_OUT_OF_MEMORY; - else - { - ev->SetNotifyCompletion(PR_TRUE); - ev->PostEvent(m_eventQueue); - } - } - else - { - res = - m_realImapMiscellaneousSink->GetShowAttachmentsInline(aProtocol, - aBool); - aProtocol->NotifyFEEventCompletion(); - } - return res; -} - NS_IMETHODIMP nsImapMiscellaneousSinkProxy::HeaderFetchCompleted(nsIImapProtocol* aProtocol) { @@ -1110,27 +1078,6 @@ GetShouldDownloadArbitraryHeadersProxyEvent::HandleEvent() return res; } -GetShowAttachmentsInlineProxyEvent::GetShowAttachmentsInlineProxyEvent( - nsImapMiscellaneousSinkProxy* aProxy, PRBool* aBool) : - nsImapMiscellaneousSinkProxyEvent(aProxy) -{ - NS_ASSERTION (aBool, "Oops... a null bool pointer"); - m_bool = aBool; -} - -GetShowAttachmentsInlineProxyEvent::~GetShowAttachmentsInlineProxyEvent() -{ -} - -NS_IMETHODIMP -GetShowAttachmentsInlineProxyEvent::HandleEvent() -{ - nsresult res = m_proxy->m_realImapMiscellaneousSink->GetShowAttachmentsInline( - m_proxy->m_protocol, m_bool); - if (m_notifyCompletion) - m_proxy->m_protocol->NotifyFEEventCompletion(); - return res; -} HeaderFetchCompletedProxyEvent::HeaderFetchCompletedProxyEvent( nsImapMiscellaneousSinkProxy* aProxy) : diff --git a/mailnews/imap/src/nsImapProxyEvent.h b/mailnews/imap/src/nsImapProxyEvent.h index 1ad1fd4e49ee..e10e5bed3392 100644 --- a/mailnews/imap/src/nsImapProxyEvent.h +++ b/mailnews/imap/src/nsImapProxyEvent.h @@ -103,8 +103,6 @@ public: GenericInfo* aInfo); NS_IMETHOD GetShouldDownloadArbitraryHeaders(nsIImapProtocol* aProtocol, GenericInfo* aInfo); - NS_IMETHOD GetShowAttachmentsInline(nsIImapProtocol* aProtocol, - PRBool* aBool); NS_IMETHOD HeaderFetchCompleted(nsIImapProtocol* aProtocol); NS_IMETHOD UpdateSecurityStatus(nsIImapProtocol* aProtocol); // **** @@ -260,16 +258,6 @@ struct GetShouldDownloadArbitraryHeadersProxyEvent : GenericInfo *m_info; // pass in handle we don't own it }; -struct GetShowAttachmentsInlineProxyEvent : - public nsImapMiscellaneousSinkProxyEvent -{ - GetShowAttachmentsInlineProxyEvent( - nsImapMiscellaneousSinkProxy* aProxy, PRBool* aBool); - virtual ~GetShowAttachmentsInlineProxyEvent(); - NS_IMETHOD HandleEvent(); - PRBool *m_bool; // pass in handle we don't own it -}; - struct HeaderFetchCompletedProxyEvent : public nsImapMiscellaneousSinkProxyEvent { HeaderFetchCompletedProxyEvent(nsImapMiscellaneousSinkProxy* aProxy); diff --git a/mailnews/local/src/nsParseMailbox.cpp b/mailnews/local/src/nsParseMailbox.cpp index c1ef615118d9..fb420d1e2978 100644 --- a/mailnews/local/src/nsParseMailbox.cpp +++ b/mailnews/local/src/nsParseMailbox.cpp @@ -472,6 +472,7 @@ NS_IMETHODIMP nsParseMailMessageState::Clear() m_priority.length = 0; m_mdn_dnt.length = 0; m_return_path.length = 0; + m_in_reply_to.length = 0; m_mdn_original_recipient.length = 0; m_body_lines = 0; m_newMsgHdr = null_nsCOMPtr(); @@ -797,6 +798,10 @@ int nsParseMailMessageState::ParseHeaders () if (!nsCRT::strncasecmp ("From", buf, end - buf)) header = &m_from; break; + case 'I' : case 'i': + if (!nsCRT::strncasecmp ("In-Reply-To", buf, end - buf)) + header = &m_in_reply_to; + break; case 'M': case 'm': if (!nsCRT::strncasecmp ("Message-ID", buf, end - buf)) header = &m_message_id; @@ -1073,6 +1078,7 @@ int nsParseMailMessageState::FinalizeHeaders() struct message_header *recipient; struct message_header *subject; struct message_header *id; + struct message_header *inReplyTo; struct message_header *references; struct message_header *date; struct message_header *statush; @@ -1118,6 +1124,7 @@ int nsParseMailMessageState::FinalizeHeaders() 0); priority = (m_priority.length ? &m_priority : 0); mdn_dnt = (m_mdn_dnt.length ? &m_mdn_dnt : 0); + inReplyTo = (m_in_reply_to.length ? &m_in_reply_to : 0); if (mozstatus) { diff --git a/mailnews/local/src/nsParseMailbox.h b/mailnews/local/src/nsParseMailbox.h index 54252f67cf32..cea0e0b12df1 100644 --- a/mailnews/local/src/nsParseMailbox.h +++ b/mailnews/local/src/nsParseMailbox.h @@ -108,6 +108,7 @@ public: struct message_header m_status; struct message_header m_mozstatus; struct message_header m_mozstatus2; + struct message_header m_in_reply_to; // Support for having multiple To or CC header lines in a message nsVoidArray m_toList;