diff --git a/mail/base/content/commandglue.js b/mail/base/content/commandglue.js
index 043f1ae5b647..d5328fc6d1d4 100644
--- a/mail/base/content/commandglue.js
+++ b/mail/base/content/commandglue.js
@@ -476,6 +476,9 @@ function ConvertColumnIDToSortType(columnID)
case "locationCol":
sortKey = nsMsgViewSortType.byLocation;
break;
+ case "accountCol":
+ sortKey = nsMsgViewSortType.byAccount;
+ break;
case "unreadButtonColHeader":
sortKey = nsMsgViewSortType.byUnread;
break;
@@ -538,6 +541,9 @@ function ConvertSortTypeToColumnID(sortKey)
case nsMsgViewSortType.byLocation:
columnID = "locationCol";
break;
+ case nsMsgViewSortType.byAccount:
+ columnID = "accountCol";
+ break;
case nsMsgViewSortType.byUnread:
columnID = "unreadButtonColHeader";
break;
diff --git a/mail/base/content/messenger.xul b/mail/base/content/messenger.xul
index e7cb42d2284e..05f99697b1ed 100644
--- a/mail/base/content/messenger.xul
+++ b/mail/base/content/messenger.xul
@@ -333,6 +333,9 @@
+
+
diff --git a/mail/base/locale/SearchDialog.dtd b/mail/base/locale/SearchDialog.dtd
index 524c65a5aa6e..336701ac9dde 100644
--- a/mail/base/locale/SearchDialog.dtd
+++ b/mail/base/locale/SearchDialog.dtd
@@ -41,6 +41,7 @@
+
@@ -61,6 +62,7 @@
+
diff --git a/mail/base/locale/messenger.dtd b/mail/base/locale/messenger.dtd
index 0bf6f655562e..e57e41a46877 100644
--- a/mail/base/locale/messenger.dtd
+++ b/mail/base/locale/messenger.dtd
@@ -501,6 +501,7 @@
+
@@ -522,6 +523,7 @@
+
diff --git a/mailnews/base/public/nsIMsgDBView.idl b/mailnews/base/public/nsIMsgDBView.idl
index aee9e1ed1f55..e8fd557ccdf2 100644
--- a/mailnews/base/public/nsIMsgDBView.idl
+++ b/mailnews/base/public/nsIMsgDBView.idl
@@ -99,6 +99,7 @@ interface nsMsgViewSortType
const nsMsgViewSortTypeValue byLabel = 0x1e;
const nsMsgViewSortTypeValue byJunkStatus = 0x1f;
const nsMsgViewSortTypeValue byAttachments = 0x20;
+ const nsMsgViewSortTypeValue byAccount = 0x21;
};
[scriptable, uuid(255d1c1e-fde7-11d4-a5be-0060b0fc04b7)]
diff --git a/mailnews/base/public/nsIMsgHdr.idl b/mailnews/base/public/nsIMsgHdr.idl
index fb6bff02a0ef..5acd2b427f20 100644
--- a/mailnews/base/public/nsIMsgHdr.idl
+++ b/mailnews/base/public/nsIMsgHdr.idl
@@ -47,7 +47,7 @@
interface nsIMsgFolder;
-[scriptable, uuid(4e994f60-c317-11d2-8cc9-0060b0fc14a3)]
+[scriptable, uuid(89b3cc7e-1f50-4f6a-8576-e5aaf71f00b1)]
interface nsIMsgHdr : nsISupports
{
/* general property routines - I think this can retrieve any
@@ -117,6 +117,7 @@ interface nsIMsgHdr : nsISupports
attribute string Charset;
attribute nsMsgLabelValue label;
+ attribute string accountKey;
readonly attribute nsIMsgFolder folder;
};
diff --git a/mailnews/base/resources/content/commandglue.js b/mailnews/base/resources/content/commandglue.js
index a7d805037830..de7bbfb47279 100644
--- a/mailnews/base/resources/content/commandglue.js
+++ b/mailnews/base/resources/content/commandglue.js
@@ -486,6 +486,9 @@ function ConvertColumnIDToSortType(columnID)
case "locationCol":
sortKey = nsMsgViewSortType.byLocation;
break;
+ case "accountCol":
+ sortKey = nsMsgViewSortType.byAccount;
+ break;
case "unreadButtonColHeader":
sortKey = nsMsgViewSortType.byUnread;
break;
@@ -545,6 +548,9 @@ function ConvertSortTypeToColumnID(sortKey)
case nsMsgViewSortType.byLocation:
columnID = "locationCol";
break;
+ case nsMsgViewSortType.byAccount:
+ columnID = "accountCol";
+ break;
case nsMsgViewSortType.byUnread:
columnID = "unreadButtonColHeader";
break;
diff --git a/mailnews/base/resources/content/threadPane.js b/mailnews/base/resources/content/threadPane.js
index 68a496764aa0..c48bd6a101f3 100644
--- a/mailnews/base/resources/content/threadPane.js
+++ b/mailnews/base/resources/content/threadPane.js
@@ -241,6 +241,10 @@ function MsgSortByLocation()
MsgSortThreadPane(nsMsgViewSortType.byLocation);
}
+function msgSortByAccount()
+{
+ MsgSortThreadPane(nsMsgViewSortType.byAccount);
+}
function MsgSortByFlagged()
{
diff --git a/mailnews/base/resources/content/threadPane.xul b/mailnews/base/resources/content/threadPane.xul
index b6a0f406a282..51219cd9587e 100644
--- a/mailnews/base/resources/content/threadPane.xul
+++ b/mailnews/base/resources/content/threadPane.xul
@@ -83,7 +83,10 @@
display="&flagColumn.label;" tooltiptext="&flagColumn.tooltip;"/>
+ label="&labelColumn.label;" tooltiptext="&labelColumn.tooltip;"/>
+
+
diff --git a/mailnews/base/resources/locale/en-US/threadpane.dtd b/mailnews/base/resources/locale/en-US/threadpane.dtd
index c00b553ba200..48a66bc709ba 100644
--- a/mailnews/base/resources/locale/en-US/threadpane.dtd
+++ b/mailnews/base/resources/locale/en-US/threadpane.dtd
@@ -42,6 +42,7 @@
+
@@ -62,6 +63,7 @@
+
diff --git a/mailnews/base/src/nsMsgDBView.cpp b/mailnews/base/src/nsMsgDBView.cpp
index cf529a8eefdd..632d878e6b9d 100644
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -525,6 +525,34 @@ nsresult nsMsgDBView::FetchAuthor(nsIMsgHdr * aHdr, PRUnichar ** aSenderString)
return NS_OK;
}
+nsresult nsMsgDBView::FetchAccount(nsIMsgHdr * aHdr, PRUnichar ** aAccount)
+{
+ nsXPIDLCString accountKey;
+
+ nsresult rv = aHdr->GetAccountKey(getter_Copies(accountKey));
+
+ // Cache the account manager?
+ nsCOMPtr accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv,rv);
+ nsCOMPtr account;
+ if (accountKey.IsEmpty())
+ {
+ }
+ else
+ {
+ rv = accountManager->GetAccount(accountKey, getter_AddRefs(account));
+ }
+ if (account)
+ {
+ nsCOMPtr server;
+ account->GetIncomingServer(getter_AddRefs(server));
+ if (server)
+ server->GetPrettyName(aAccount);
+ }
+ return NS_OK;
+}
+
+
nsresult nsMsgDBView::FetchRecipients(nsIMsgHdr * aHdr, PRUnichar ** aRecipientsString)
{
nsXPIDLString unparsedRecipients;
@@ -1549,6 +1577,13 @@ NS_IMETHODIMP nsMsgDBView::GetCellText(PRInt32 aRow, nsITreeColumn* aCol, nsAStr
rv = FetchLabel(msgHdr, getter_Copies(valueText));
aValue.Assign(valueText);
break;
+ case 'a': // account
+ if (colID[1] == 'c') // account
+ {
+ rv = FetchAccount(msgHdr, getter_Copies(valueText));
+ aValue.Assign(valueText);
+ }
+ break;
case 't':
// total msgs in thread column
if (colID[1] == 'o' && (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay))
@@ -3173,9 +3208,9 @@ FnSortIdDWord(const void *pItem1, const void *pItem2, void *privateData)
//systems such as HP-UX these values must be 4 bytes
//aligned. Don't break this when modify the constants
const int kMaxSubjectKey = 160;
-const int kMaxLocationKey = 160;
+const int kMaxLocationKey = 160; // also used for account
const int kMaxAuthorKey = 160;
-const int kMaxRecipientKey = 80;
+const int kMaxRecipientKey = 80;
nsresult nsMsgDBView::GetFieldTypeAndLenForSort(nsMsgViewSortTypeValue sortType, PRUint16 *pMaxLen, eFieldType *pFieldType)
{
@@ -3187,6 +3222,7 @@ nsresult nsMsgDBView::GetFieldTypeAndLenForSort(nsMsgViewSortTypeValue sortType,
*pFieldType = kCollationKey;
*pMaxLen = kMaxSubjectKey;
break;
+ case nsMsgViewSortType::byAccount:
case nsMsgViewSortType::byLocation:
*pFieldType = kCollationKey;
*pMaxLen = kMaxLocationKey;
@@ -3365,6 +3401,19 @@ nsMsgDBView::GetCollationKey(nsIMsgHdr *msgHdr, nsMsgViewSortTypeValue sortType,
case nsMsgViewSortType::byAuthor:
rv = msgHdr->GetAuthorCollationKey(result, len);
break;
+ case nsMsgViewSortType::byAccount:
+ {
+ nsXPIDLString accountName;
+ nsCOMPtr dbToUse = m_db;
+
+ if (!dbToUse) // probably search view
+ GetDBForViewIndex(0, getter_AddRefs(dbToUse));
+
+ rv = FetchAccount(msgHdr, getter_Copies(accountName));
+ if (NS_SUCCEEDED(rv) && dbToUse)
+ rv = dbToUse->CreateCollationKey(accountName, result, len);
+ }
+ break;
default:
rv = NS_ERROR_UNEXPECTED;
break;
diff --git a/mailnews/base/src/nsMsgDBView.h b/mailnews/base/src/nsMsgDBView.h
index 64d1b300a347..52b28a2e39ee 100644
--- a/mailnews/base/src/nsMsgDBView.h
+++ b/mailnews/base/src/nsMsgDBView.h
@@ -22,6 +22,7 @@
* Contributor(s):
* Seth Spitzer
* Dan Mosedale
+ * David Bienvenu
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@@ -164,6 +165,7 @@ protected:
nsresult FetchSize(nsIMsgHdr * aHdr, PRUnichar ** aSizeString);
nsresult FetchPriority(nsIMsgHdr *aHdr, PRUnichar ** aPriorityString);
nsresult FetchLabel(nsIMsgHdr *aHdr, PRUnichar ** aLabelString);
+ nsresult FetchAccount(nsIMsgHdr * aHdr, PRUnichar ** aAccount);
nsresult CycleThreadedColumn(nsIDOMElement * aElement);
// Save and Restore Selection are a pair of routines you should
diff --git a/mailnews/db/msgdb/src/nsMsgHdr.cpp b/mailnews/db/msgdb/src/nsMsgHdr.cpp
index a011f049f883..d9379049e291 100644
--- a/mailnews/db/msgdb/src/nsMsgHdr.cpp
+++ b/mailnews/db/msgdb/src/nsMsgHdr.cpp
@@ -178,8 +178,7 @@ NS_IMETHODIMP nsMsgHdr::GetThreadId(nsMsgKey *result)
NS_IMETHODIMP nsMsgHdr::SetThreadId(nsMsgKey inKey)
{
m_threadId = inKey;
- SetUInt32Column(m_threadId, m_mdb->m_messageThreadIdColumnToken);
- return NS_OK;
+ return SetUInt32Column(m_threadId, m_mdb->m_messageThreadIdColumnToken);
}
NS_IMETHODIMP nsMsgHdr::SetMessageKey(nsMsgKey value)
@@ -217,8 +216,7 @@ NS_IMETHODIMP nsMsgHdr::SetFlags(PRUint32 flags)
#endif
m_flags = flags;
// don't write out MSG_FLAG_NEW to MDB.
- SetUInt32Column(m_flags & ~MSG_FLAG_NEW, m_mdb->m_flagsColumnToken);
- return NS_OK;
+ return SetUInt32Column(m_flags & ~MSG_FLAG_NEW, m_mdb->m_flagsColumnToken);
}
NS_IMETHODIMP nsMsgHdr::OrFlags(PRUint32 flags, PRUint32 *result)
@@ -492,24 +490,23 @@ NS_IMETHODIMP nsMsgHdr::SetCCListArray(const char *names, const char *addresses,
NS_IMETHODIMP nsMsgHdr::SetMessageSize(PRUint32 messageSize)
{
- SetUInt32Column(messageSize, m_mdb->m_messageSizeColumnToken);
- m_messageSize = messageSize;
- return NS_OK;
+ SetUInt32Column(messageSize, m_mdb->m_messageSizeColumnToken);
+ m_messageSize = messageSize;
+ return NS_OK;
}
NS_IMETHODIMP nsMsgHdr::GetOfflineMessageSize(PRUint32 *result)
{
- PRUint32 size;
- nsresult res = GetUInt32Column(m_mdb->m_offlineMessageSizeColumnToken, &size);
+ PRUint32 size;
+ nsresult res = GetUInt32Column(m_mdb->m_offlineMessageSizeColumnToken, &size);
- *result = size;
- return res;
+ *result = size;
+ return res;
}
NS_IMETHODIMP nsMsgHdr::SetOfflineMessageSize(PRUint32 messageSize)
{
- SetUInt32Column(messageSize, m_mdb->m_offlineMessageSizeColumnToken);
- return NS_OK;
+ return SetUInt32Column(messageSize, m_mdb->m_offlineMessageSizeColumnToken);
}
@@ -573,6 +570,24 @@ NS_IMETHODIMP nsMsgHdr::GetLabel(nsMsgLabelValue *result)
return GetUInt32Column(m_mdb->m_labelColumnToken, result);
}
+// I'd like to not store the account key, if the msg is in
+// the same account as it was received in, to save disk space and memory.
+// This might be problematic when a message gets moved...
+// And I'm not sure if we should short circuit it here,
+// or at a higher level where it might be more efficient.
+NS_IMETHODIMP nsMsgHdr::SetAccountKey(const char *aAccountKey)
+{
+ return SetStringProperty("account", aAccountKey);
+}
+
+NS_IMETHODIMP nsMsgHdr::GetAccountKey(char **aResult)
+{
+ NS_ENSURE_ARG_POINTER(aResult);
+
+ return GetStringProperty("account", aResult);
+}
+
+
NS_IMETHODIMP nsMsgHdr::GetMessageOffset(PRUint32 *result)
{
NS_ENSURE_ARG(result);
diff --git a/mailnews/local/src/nsParseMailbox.cpp b/mailnews/local/src/nsParseMailbox.cpp
index b6e1f7ad2ad8..60eed8e94806 100644
--- a/mailnews/local/src/nsParseMailbox.cpp
+++ b/mailnews/local/src/nsParseMailbox.cpp
@@ -73,6 +73,7 @@
#include "nsIMimeHeaders.h"
#include "nsIMsgMdnGenerator.h"
#include "nsMsgSearchCore.h"
+#include "nsMailHeaders.h"
static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
@@ -204,7 +205,7 @@ NS_IMETHODIMP nsMsgMailboxParser::OnAnnouncerGoingAway(nsIDBChangeAnnouncer *ins
m_newMsgHdr = nsnull;
m_mailDB = nsnull;
- return NS_OK;
+ return NS_OK;
}
/* void OnReadChanged (in nsIDBChangeListener instigator); */
@@ -393,8 +394,8 @@ PRInt32 nsMsgMailboxParser::PublishMsgHeader(nsIMsgWindow *msgWindow)
void nsMsgMailboxParser::AbortNewHeader()
{
- if (m_newMsgHdr && m_mailDB)
- m_newMsgHdr = nsnull;
+ if (m_newMsgHdr && m_mailDB)
+ m_newMsgHdr = nsnull;
}
PRInt32 nsMsgMailboxParser::HandleLine(char *line, PRUint32 lineLength)
@@ -512,6 +513,7 @@ NS_IMETHODIMP nsParseMailMessageState::Clear()
m_priority.length = 0;
m_mdn_dnt.length = 0;
m_return_path.length = 0;
+ m_account_key.length = 0;
m_in_reply_to.length = 0;
m_content_type.length = 0;
m_mdn_original_recipient.length = 0;
@@ -920,6 +922,8 @@ int nsParseMailMessageState::ParseHeaders ()
else if ( X_MOZILLA_STATUS_LEN == end - buf &&
!nsCRT::strncasecmp(X_MOZILLA_STATUS, buf, end - buf) && !m_IgnoreXMozillaStatus)
header = &m_mozstatus;
+ else if (!nsCRT::strncasecmp(HEADER_X_MOZILLA_ACCOUNT_KEY, buf, end - buf))
+ header = &m_account_key;
// we could very well care what the priority header was when we
// remember its value. If so, need to remember it here. Also,
// different priority headers can appear in the same message,
@@ -1122,6 +1126,7 @@ int nsParseMailMessageState::FinalizeHeaders()
struct message_header *mozstatus;
struct message_header *mozstatus2;
struct message_header *priority;
+ struct message_header *account_key;
struct message_header *ccList;
struct message_header *mdn_dnt;
struct message_header md5_header;
@@ -1165,6 +1170,7 @@ int nsParseMailMessageState::FinalizeHeaders()
mdn_dnt = (m_mdn_dnt.length ? &m_mdn_dnt : 0);
inReplyTo = (m_in_reply_to.length ? &m_in_reply_to : 0);
content_type = (m_content_type.length ? &m_content_type : 0);
+ account_key = (m_account_key.length ? &m_account_key :0);
if (mozstatus)
{
@@ -1349,7 +1355,9 @@ int nsParseMailMessageState::FinalizeHeaders()
}
}
}
-
+
+ if (account_key != nsnull)
+ m_newMsgHdr->SetAccountKey(account_key->value);
// use in-reply-to header as references, if there's no references header
if (references != nsnull)
m_newMsgHdr->SetReferences(references->value);
diff --git a/mailnews/local/src/nsParseMailbox.h b/mailnews/local/src/nsParseMailbox.h
index ca08639babf3..7acd9287f485 100644
--- a/mailnews/local/src/nsParseMailbox.h
+++ b/mailnews/local/src/nsParseMailbox.h
@@ -137,6 +137,7 @@ public:
struct message_header m_envelope_from;
struct message_header m_envelope_date;
struct message_header m_priority;
+ struct message_header m_account_key;
// Mdn support
struct message_header m_mdn_original_recipient;
struct message_header m_return_path;