This commit is contained in:
bienvenu%netscape.com 1999-05-17 02:07:13 +00:00
Родитель 19a23b87e7
Коммит 12e7faae84
4 изменённых файлов: 71 добавлений и 12 удалений

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

@ -23,6 +23,9 @@
#include "nsISupports.h" #include "nsISupports.h"
#include "nsMsgFilterCore.h" #include "nsMsgFilterCore.h"
class nsOutputStream;
class nsIMsgDBHdr;
// 605db0f8-04a1-11d3-a50a-0060b0fc04b7 // 605db0f8-04a1-11d3-a50a-0060b0fc04b7
#define NS_IMSGFILTER_IID \ #define NS_IMSGFILTER_IID \
{ 0x605db0f8, 0x04a1, 0x11d3, \ { 0x605db0f8, 0x04a1, 0x11d3, \
@ -66,7 +69,7 @@ public:
*/ */
NS_IMETHOD SetAction(nsMsgRuleActionType type, void *value)= 0; NS_IMETHOD SetAction(nsMsgRuleActionType type, void *value)= 0;
NS_IMETHOD GetAction(nsMsgRuleActionType *type, void **value) = 0; NS_IMETHOD GetAction(nsMsgRuleActionType *type, void **value) = 0;
NS_IMETHOD LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *header) = 0;
}; };
#endif #endif

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

@ -22,6 +22,7 @@
#include "nsMsgFilterList.h" #include "nsMsgFilterList.h"
#include "nsMsgFilter.h" #include "nsMsgFilter.h"
#include "nsMsgUtils.h" #include "nsMsgUtils.h"
#include "nsFileStream.h"
static const char *kImapPrefix = "//imap:"; static const char *kImapPrefix = "//imap:";
@ -163,6 +164,61 @@ NS_IMETHODIMP nsMsgFilter::GetAction(nsMsgRuleActionType *type, void **value)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsMsgFilter::LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *msgHdr)
{
char *filterName = "";
time_t date;
char dateStr[40]; /* 30 probably not enough */
nsMsgRuleActionType actionType;
void *value;
nsString author;
nsString subject;
GetFilterName(&filterName);
GetAction(&actionType, &value);
nsresult res = msgHdr->GetDate(&date);
struct tm* tmTime = localtime(&date);
strftime(dateStr, 100, "%m/%d/%Y %I:%M %p", tmTime);
msgHdr->GetAuthor(author);
msgHdr->GetSubject(subject);
if (stream)
{
*stream << "Applied filter \"";
*stream << filterName;
*stream << "\" to message from ";
*stream << nsAutoCString(author);
*stream << " - ";
*stream << nsAutoCString(subject);
*stream << " at ";
*stream << dateStr;
*stream << "\n";
const char *actionStr = GetActionStr(actionType);
char *actionValue = "";
if (actionType == nsMsgFilterActionMoveToFolder)
actionValue = (char *) value;
*stream << "Action = ";
*stream << actionStr;
*stream << " ";
*stream << actionValue;
*stream << "\n\n";
// XP_FilePrintf(*m_logFile, "Action = %s %s\n\n", actionStr, actionValue);
if (actionType == nsMsgFilterActionMoveToFolder)
{
nsString msgId;
msgHdr->GetMessageId(msgId);
*stream << "mailbox:";
*stream << (char *) value;
*stream << "id = ";
*stream << nsAutoCString(msgId);
*stream << "\n";
// XP_FilePrintf(m_logFile, "mailbox:%s?id=%s\n", value, (const char *) msgId);
}
}
return NS_OK;
}
void nsMsgFilter::SetFilterList(nsMsgFilterList *filterList) void nsMsgFilter::SetFilterList(nsMsgFilterList *filterList)
@ -340,19 +396,18 @@ static struct RuleActionsTableEntry ruleActionsTable[] =
{ nsMsgFilterActionWatchThread, nsMsgFilterAll, 0, /*XP_FILTER_WATCH_THREAD */ "Watch thread"} { nsMsgFilterActionWatchThread, nsMsgFilterAll, 0, /*XP_FILTER_WATCH_THREAD */ "Watch thread"}
}; };
#ifdef FILTER_UI const char *nsMsgFilter::GetActionStr(nsMsgRuleActionType action)
/*static */char *MSG_Rule::GetActionStr(MSG_RuleActionType action)
{ {
int numActions = sizeof(ruleActionsTable) / sizeof(ruleActionsTable[0]); int numActions = sizeof(ruleActionsTable) / sizeof(ruleActionsTable[0]);
for (int i = 0; i < numActions; i++) for (int i = 0; i < numActions; i++)
{ {
// ### TODO use string bundle
if (action == ruleActionsTable[i].action) if (action == ruleActionsTable[i].action)
return XP_GetString(ruleActionsTable[i].xp_strIndex); return ruleActionsTable[i].actionFilingStr; // XP_GetString(ruleActionsTable[i].xp_strIndex);
} }
return ""; return "";
} }
#endif
/*static */nsresult nsMsgFilter::GetActionFilingStr(nsMsgRuleActionType action, nsString2 &actionStr) /*static */nsresult nsMsgFilter::GetActionFilingStr(nsMsgRuleActionType action, nsString2 &actionStr)
{ {
int numActions = sizeof(ruleActionsTable) / sizeof(ruleActionsTable[0]); int numActions = sizeof(ruleActionsTable) / sizeof(ruleActionsTable[0]);

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

@ -76,6 +76,7 @@ public:
*/ */
NS_IMETHOD SetAction(nsMsgRuleActionType type, void *value); NS_IMETHOD SetAction(nsMsgRuleActionType type, void *value);
NS_IMETHOD GetAction(nsMsgRuleActionType *type, void **value) ; NS_IMETHOD GetAction(nsMsgRuleActionType *type, void **value) ;
NS_IMETHOD LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *header);
nsMsgFilterType GetType() {return m_type;} nsMsgFilterType GetType() {return m_type;}
@ -106,7 +107,7 @@ public:
#endif #endif
nsresult ConvertMoveToFolderValue(nsString2 &relativePath); nsresult ConvertMoveToFolderValue(nsString2 &relativePath);
static char *GetActionStr(nsMsgRuleActionType action); static const char *GetActionStr(nsMsgRuleActionType action);
static nsresult GetActionFilingStr(nsMsgRuleActionType action, nsString2 &actionStr); static nsresult GetActionFilingStr(nsMsgRuleActionType action, nsString2 &actionStr);
static nsMsgRuleActionType GetActionForFilingStr(nsString2 &actionStr); static nsMsgRuleActionType GetActionForFilingStr(nsString2 &actionStr);
nsMsgRuleAction m_action; nsMsgRuleAction m_action;

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

@ -1368,15 +1368,15 @@ MWContextType nsMsgResultElement::GetContextType ()
MWContextType type=(MWContextType)0; MWContextType type=(MWContextType)0;
switch (m_adapter->m_scope->m_attribute) switch (m_adapter->m_scope->m_attribute)
{ {
case scopeMailFolder: case nsMsgSearchScopeMailFolder:
type = MWContextMailMsg; type = MWContextMailMsg;
break; break;
case scopeOfflineNewsgroup: // added by mscott could be bug fix... case nsMsgSearchScopeOfflineNewsgroup: // added by mscott could be bug fix...
case scopeNewsgroup: case nsMsgSearchScopeNewsgroup:
case scopeAllSearchableGroups: case nsMsgSearchScopeAllSearchableGroups:
type = MWContextNewsMsg; type = MWContextNewsMsg;
break; break;
case scopeLdapDirectory: case nsMsgSearchScopeLdapDirectory:
type = MWContextBrowser; type = MWContextBrowser;
break; break;
default: default:
@ -1394,7 +1394,7 @@ nsresult nsMsgResultElement::Open (void *window)
if (window) if (window)
{ {
if (m_adapter->m_scope->m_attribute != scopeLdapDirectory) if (m_adapter->m_scope->m_attribute != nsMsgSearchScopeLdapDirectory)
{ {
msgPane = (MSG_MessagePane *) window; msgPane = (MSG_MessagePane *) window;
XP_ASSERT (MSG_MESSAGEPANE == msgPane->GetPaneType()); XP_ASSERT (MSG_MESSAGEPANE == msgPane->GetPaneType());