add account column to thread pane for global inbox, 30057, sr=mscott

This commit is contained in:
bienvenu%nventure.com 2004-05-20 23:41:30 +00:00
Родитель f70b3f2c3e
Коммит d4cf4b5ff4
15 изменённых файлов: 126 добавлений и 21 удалений

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

@ -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;

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

@ -333,6 +333,9 @@
<treecol id="labelCol" persist="hidden ordinal width" flex="1" hidden="true"
label="&labelColumn.label;" tooltiptext="&labelColumn.tooltip;"/>
<splitter class="tree-splitter"/>
<treecol id="accountCol" persist="hidden ordinal width" flex="1" hidden="true"
label="&accountColumn.label;" tooltiptext="&accountColumn.tooltip;"/>
<splitter class="tree-splitter"/>
<treecol id="priorityCol" persist="hidden ordinal width" flex="1" hidden="true"
label="&priorityColumn.label;" tooltiptext="&priorityColumn.tooltip;"/>
<splitter class="tree-splitter"/>

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

@ -41,6 +41,7 @@
<!ENTITY dateColumn.label "Date">
<!ENTITY priorityColumn.label "Priority">
<!ENTITY labelColumn.label "Label">
<!ENTITY accountColumn.label "Account">
<!ENTITY statusColumn.label "Status">
<!ENTITY sizeColumn.label "Size">
<!ENTITY junkStatusColumn.label "Junk Status">
@ -61,6 +62,7 @@
<!ENTITY dateColumn.tooltip "Click to sort by date">
<!ENTITY priorityColumn.tooltip "Click to sort by priority">
<!ENTITY labelColumn.tooltip "Click to sort by label">
<!ENTITY accountColumn.tooltip "Click to sort by account">
<!ENTITY statusColumn.tooltip "Click to sort by status">
<!ENTITY sizeColumn.tooltip "Click to sort by size">
<!ENTITY junkStatusColumn.tooltip "Click to sort by junk status">

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

@ -501,6 +501,7 @@
<!ENTITY dateColumn.label "Date">
<!ENTITY priorityColumn.label "Priority">
<!ENTITY labelColumn.label "Label">
<!ENTITY accountColumn.label "Account">
<!ENTITY statusColumn.label "Status">
<!ENTITY sizeColumn.label "Size">
<!ENTITY junkStatusColumn.label "Junk Status">
@ -522,6 +523,7 @@
<!ENTITY dateColumn.tooltip "Click to sort by date">
<!ENTITY priorityColumn.tooltip "Click to sort by priority">
<!ENTITY labelColumn.tooltip "Click to sort by label">
<!ENTITY accountColumn.tooltip "Click to sort by account">
<!ENTITY statusColumn.tooltip "Click to sort by status">
<!ENTITY sizeColumn.tooltip "Click to sort by size">
<!ENTITY junkStatusColumn.tooltip "Click to sort by junk status">

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

@ -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)]

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

@ -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;
};

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

@ -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;

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

@ -241,6 +241,10 @@ function MsgSortByLocation()
MsgSortThreadPane(nsMsgViewSortType.byLocation);
}
function msgSortByAccount()
{
MsgSortThreadPane(nsMsgViewSortType.byAccount);
}
function MsgSortByFlagged()
{

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

@ -83,7 +83,10 @@
display="&flagColumn.label;" tooltiptext="&flagColumn.tooltip;"/>
<splitter class="tree-splitter"/>
<treecol id="labelCol" persist="hidden ordinal width" flex="1" hidden="true"
label="&labelColumn.label;" tooltiptext="&labelColumn.tooltip;"/>
label="&labelColumn.label;" tooltiptext="&labelColumn.tooltip;"/>
<splitter class="tree-splitter"/>
<treecol id="accountCol" persist="hidden ordinal width" flex="1" hidden="true"
label="&accountColumn.label;" tooltiptext="&accountColumn.tooltip;"/>
<splitter class="tree-splitter"/>
<treecol id="priorityCol" persist="hidden ordinal width" flex="1"
label="&priorityColumn.label;" tooltiptext="&priorityColumn.tooltip;"/>

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

@ -42,6 +42,7 @@
<!ENTITY dateColumn.label "Date">
<!ENTITY priorityColumn.label "Priority">
<!ENTITY labelColumn.label "Label">
<!ENTITY accountColumn.label "Account">
<!ENTITY statusColumn.label "Status">
<!ENTITY sizeColumn.label "Size">
<!ENTITY junkStatusColumn.label "Junk Status">
@ -62,6 +63,7 @@
<!ENTITY dateColumn.tooltip "Click to sort by date">
<!ENTITY priorityColumn.tooltip "Click to sort by priority">
<!ENTITY labelColumn.tooltip "Click to sort by label">
<!ENTITY accountColumn.tooltip "Click to sort by account">
<!ENTITY statusColumn.tooltip "Click to sort by status">
<!ENTITY sizeColumn.tooltip "Click to sort by size">
<!ENTITY junkStatusColumn.tooltip "Click to sort by junk status">

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

@ -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 <nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr <nsIMsgAccount> account;
if (accountKey.IsEmpty())
{
}
else
{
rv = accountManager->GetAccount(accountKey, getter_AddRefs(account));
}
if (account)
{
nsCOMPtr <nsIMsgIncomingServer> 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 <nsIMsgDatabase> 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;

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

@ -22,6 +22,7 @@
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
* Dan Mosedale <dmose@netscape.com>
* David Bienvenu <bienvenu@mozilla.org>
*
* 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

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

@ -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);

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

@ -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);

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

@ -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;