pass uris, not urls to spam filter plugin, not part of build, r/sr=sspitzer
git-svn-id: svn://10.0.0.236/trunk@131366 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -457,8 +457,7 @@ function analyze(aMessage, aNextFunction)
|
||||
|
||||
// XXX TODO jumping through hoops here.
|
||||
var messageURI = aMessage.folder.generateMessageURI(aMessage.messageKey) + "?fetchCompleteMessage=true";
|
||||
var messageURL = mailSession.ConvertMsgURIToMsgURL(messageURI, msgWindow);
|
||||
gJunkmailComponent.classifyMessage(messageURL, listener);
|
||||
gJunkmailComponent.classifyMessage(messageURI, listener);
|
||||
}
|
||||
|
||||
function analyzeFolder()
|
||||
@@ -541,7 +540,6 @@ function mark(aMessage, aSpam, aNextFunction)
|
||||
var newClassification = (aSpam ? nsIJunkMailPlugin.JUNK : nsIJunkMailPlugin.GOOD);
|
||||
|
||||
var messageURI = aMessage.folder.generateMessageURI(aMessage.messageKey) + "?fetchCompleteMessage=true";
|
||||
var messageURL = mailSession.ConvertMsgURIToMsgURL(messageURI, msgWindow);
|
||||
|
||||
var listener = (aNextFunction == null ? null :
|
||||
{
|
||||
@@ -551,7 +549,7 @@ function mark(aMessage, aSpam, aNextFunction)
|
||||
}
|
||||
});
|
||||
|
||||
gJunkmailComponent.setMessageClassification(messageURL, oldClassification, newClassification, listener);
|
||||
gJunkmailComponent.setMessageClassification(messageURI, oldClassification, newClassification, listener);
|
||||
}
|
||||
|
||||
function JunkSelectedMessages(setAsJunk)
|
||||
|
||||
@@ -129,18 +129,18 @@ interface nsIJunkMailPlugin : nsIMsgFilterPlugin
|
||||
* Given a message URL, determine what its current classification is
|
||||
* according to the current training set.
|
||||
*/
|
||||
void classifyMessage(in string aMsgURL,
|
||||
void classifyMessage(in string aMsgURI,
|
||||
in nsIJunkMailClassificationListener aListener);
|
||||
|
||||
void classifyMessages(in unsigned long aCount,
|
||||
[array, size_is(aCount)] in string aMsgURLs,
|
||||
[array, size_is(aCount)] in string aMsgURIs,
|
||||
in nsIJunkMailClassificationListener aListener);
|
||||
|
||||
/**
|
||||
* Called when a user forces the classification of a message. Should
|
||||
* cause the training set to be updated appropriately.
|
||||
*/
|
||||
void setMessageClassification(in string aMsgURL,
|
||||
void setMessageClassification(in string aMsgURI,
|
||||
in long aOldClassification,
|
||||
in long aNewClassification,
|
||||
in nsIJunkMailClassificationListener aListener);
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#include "nsQuickSort.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIMsgMailSession.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "prnetdb.h"
|
||||
|
||||
static const char* kBayesianFilterTokenDelimiters = " \t\n\r\f!\"#%&()*+,./:;<=>?@[\\]^_`{|}~";
|
||||
@@ -373,19 +375,23 @@ private:
|
||||
};
|
||||
|
||||
/* void filterMessage (in string aMsgURL, in nsIMsgDBHdr aMsgHdr, in unsigned long aCount, [array, size_is (aCount)] in string aHeaders, in nsIMsgFilterHitNotify aListener, in nsIMsgWindow aMsgWindow); */
|
||||
NS_IMETHODIMP nsBayesianFilter::FilterMessage(const char *aMsgURL, nsIMsgDBHdr *aMsgHdr, PRUint32 aCount,
|
||||
NS_IMETHODIMP nsBayesianFilter::FilterMessage(const char *aMsgURI, nsIMsgDBHdr *aMsgHdr, PRUint32 aCount,
|
||||
const char **aHeaders, nsIMsgFilterHitNotify *aListener, nsIMsgWindow *aMsgWindow)
|
||||
{
|
||||
TokenAnalyzer* analyzer = new MessageClassifier(this, NULL);
|
||||
return tokenizeMessage(aMsgURL, analyzer);
|
||||
return tokenizeMessage(aMsgURI, analyzer);
|
||||
}
|
||||
|
||||
nsresult nsBayesianFilter::tokenizeMessage(const char* messageURL, TokenAnalyzer* analyzer)
|
||||
nsresult nsBayesianFilter::tokenizeMessage(const char* messageURI, TokenAnalyzer* analyzer)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsXPIDLCString messageURL;
|
||||
|
||||
nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mailSession->ConvertMsgURIToMsgURL(messageURI, nsnull, getter_Copies(messageURL));
|
||||
// Tell mime we just want to scan the message data
|
||||
nsCAutoString aUrl(messageURL);
|
||||
aUrl.FindChar('?') == kNotFound ? aUrl += "?" : aUrl += "&";
|
||||
@@ -395,7 +401,7 @@ nsresult nsBayesianFilter::tokenizeMessage(const char* messageURL, TokenAnalyzer
|
||||
rv = ioService->NewChannel(aUrl, NULL, NULL, getter_AddRefs(channel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIStreamListener> tokenListener = new TokenStreamListener(messageURL, analyzer);
|
||||
nsCOMPtr<nsIStreamListener> tokenListener = new TokenStreamListener(messageURI, analyzer);
|
||||
|
||||
static NS_DEFINE_CID(kIStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
nsCOMPtr<nsIStreamConverterService> streamConverter = do_GetService(kIStreamConverterServiceCID, &rv);
|
||||
@@ -423,7 +429,7 @@ static int compareTokens(const void* p1, const void* p2, void* /* data */)
|
||||
inline double max(double x, double y) { return (x > y ? x : y); }
|
||||
inline double min(double x, double y) { return (x < y ? x : y); }
|
||||
|
||||
void nsBayesianFilter::classifyMessage(Tokenizer& messageTokens, const char* messageURL,
|
||||
void nsBayesianFilter::classifyMessage(Tokenizer& messageTokens, const char* messageURI,
|
||||
nsIJunkMailClassificationListener* listener)
|
||||
{
|
||||
/* run the kernel of the Graham filter algorithm here. */
|
||||
@@ -477,7 +483,7 @@ void nsBayesianFilter::classifyMessage(Tokenizer& messageTokens, const char* mes
|
||||
delete[] tokens;
|
||||
|
||||
if (listener)
|
||||
listener->OnMessageClassified(messageURL, isJunk ? PRInt32(nsIJunkMailPlugin::JUNK) : PRInt32(nsIJunkMailPlugin::GOOD));
|
||||
listener->OnMessageClassified(messageURI, isJunk ? PRInt32(nsIJunkMailPlugin::JUNK) : PRInt32(nsIJunkMailPlugin::GOOD));
|
||||
}
|
||||
|
||||
/* void shutdown (); */
|
||||
@@ -489,7 +495,8 @@ NS_IMETHODIMP nsBayesianFilter::Shutdown()
|
||||
/* readonly attribute boolean shouldDownloadAllHeaders; */
|
||||
NS_IMETHODIMP nsBayesianFilter::GetShouldDownloadAllHeaders(PRBool *aShouldDownloadAllHeaders)
|
||||
{
|
||||
*aShouldDownloadAllHeaders = PR_TRUE;
|
||||
// bayesian filters work on the whole msg body currently.
|
||||
*aShouldDownloadAllHeaders = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,9 +87,9 @@ public:
|
||||
nsBayesianFilter();
|
||||
virtual ~nsBayesianFilter();
|
||||
|
||||
nsresult tokenizeMessage(const char* messageURL, TokenAnalyzer* analyzer);
|
||||
void classifyMessage(Tokenizer& messageTokens, const char* messageURL, nsIJunkMailClassificationListener* listener);
|
||||
void observeMessage(Tokenizer& messageTokens, const char* messageURL, PRInt32 oldClassification, PRInt32 newClassification, nsIJunkMailClassificationListener* listener);
|
||||
nsresult tokenizeMessage(const char* messageURI, TokenAnalyzer* analyzer);
|
||||
void classifyMessage(Tokenizer& messageTokens, const char* messageURI, nsIJunkMailClassificationListener* listener);
|
||||
void observeMessage(Tokenizer& messageTokens, const char* messageURI, PRInt32 oldClassification, PRInt32 newClassification, nsIJunkMailClassificationListener* listener);
|
||||
|
||||
void writeTrainingData();
|
||||
void readTrainingData();
|
||||
|
||||
Reference in New Issue
Block a user