Bug 1739903 - Change filter-related URI APIs to AUTF8String. r=mkmelin
This commit is contained in:
Родитель
d6c4953f09
Коммит
dbc4af4f95
|
@ -28,13 +28,14 @@ interface nsISpamSettings: nsISupports {
|
|||
attribute long moveTargetMode;
|
||||
const long MOVE_TARGET_MODE_ACCOUNT = 0;
|
||||
const long MOVE_TARGET_MODE_FOLDER = 1;
|
||||
attribute string actionTargetAccount;
|
||||
attribute string actionTargetFolder;
|
||||
// Despite their name the following are URIs.
|
||||
attribute AUTF8String actionTargetAccount;
|
||||
attribute AUTF8String actionTargetFolder;
|
||||
|
||||
/**
|
||||
* built from moveTargetMode, actionTargetAccount, actionTargetFolder
|
||||
*/
|
||||
readonly attribute string spamFolderURI;
|
||||
readonly attribute AUTF8String spamFolderURI;
|
||||
|
||||
attribute boolean purge;
|
||||
/**
|
||||
|
@ -43,7 +44,7 @@ interface nsISpamSettings: nsISupports {
|
|||
attribute long purgeInterval;
|
||||
|
||||
attribute boolean useWhiteList;
|
||||
attribute string whiteListAbURI;
|
||||
attribute AUTF8String whiteListAbURI;
|
||||
|
||||
/**
|
||||
* Should we do something when the user manually marks a message as junk?
|
||||
|
|
|
@ -2113,13 +2113,13 @@ nsMsgDBFolder::GetInheritedStringProperty(const char* aPropertyName,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgDBFolder::OnMessageClassified(const char* aMsgURI,
|
||||
nsMsgDBFolder::OnMessageClassified(const nsACString& aMsgURI,
|
||||
nsMsgJunkStatus aClassification,
|
||||
uint32_t aJunkPercent) {
|
||||
nsresult rv = GetDatabase();
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
|
||||
if (!aMsgURI) // This signifies end of batch.
|
||||
if (aMsgURI.IsEmpty()) // This signifies end of batch.
|
||||
{
|
||||
// Apply filters if needed.
|
||||
if (!mPostBayesMessagesToFilter.IsEmpty()) {
|
||||
|
@ -2159,7 +2159,7 @@ nsMsgDBFolder::OnMessageClassified(const char* aMsgURI,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr;
|
||||
rv = GetMsgDBHdrFromURI(nsDependentCString(aMsgURI), getter_AddRefs(msgHdr));
|
||||
rv = GetMsgDBHdrFromURI(aMsgURI, getter_AddRefs(msgHdr));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsMsgKey msgKey;
|
||||
|
@ -2207,17 +2207,17 @@ nsMsgDBFolder::OnMessageClassified(const char* aMsgURI,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgDBFolder::OnMessageTraitsClassified(const char* aMsgURI,
|
||||
nsMsgDBFolder::OnMessageTraitsClassified(const nsACString& aMsgURI,
|
||||
const nsTArray<uint32_t>& aTraits,
|
||||
const nsTArray<uint32_t>& aPercents) {
|
||||
if (!aMsgURI) // This signifies end of batch
|
||||
if (aMsgURI.IsEmpty()) // This signifies end of batch
|
||||
return NS_OK; // We are not handling batching
|
||||
|
||||
MOZ_ASSERT(aTraits.Length() == aPercents.Length());
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr;
|
||||
rv = GetMsgDBHdrFromURI(nsDependentCString(aMsgURI), getter_AddRefs(msgHdr));
|
||||
rv = GetMsgDBHdrFromURI(aMsgURI, getter_AddRefs(msgHdr));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsMsgKey msgKey;
|
||||
|
@ -2569,7 +2569,7 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow* aMsgWindow, bool* aFiltersRun) {
|
|||
// post analysis filters will run consistently on a folder, even if
|
||||
// disabled junk processing, which could be dynamic through whitelisting,
|
||||
// makes the bayes analysis unnecessary.
|
||||
OnMessageClassified(nullptr, nsIJunkMailPlugin::UNCLASSIFIED, 0);
|
||||
OnMessageClassified(EmptyCString(), nsIJunkMailPlugin::UNCLASSIFIED, 0);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -3287,7 +3287,7 @@ nsresult nsMsgDBView::SetMsgHdrJunkStatus(nsIJunkMailPlugin* aJunkPlugin,
|
|||
// adjust its database appropriately.
|
||||
nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(mMsgWindowWeak));
|
||||
rv = aJunkPlugin->SetMessageClassification(
|
||||
uri.get(), oldUserClassification, aNewClassification, msgWindow, this);
|
||||
uri, oldUserClassification, aNewClassification, msgWindow, this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// This routine is only reached if the user someone touched the UI
|
||||
|
@ -3308,14 +3308,14 @@ nsresult nsMsgDBView::SetMsgHdrJunkStatus(nsIJunkMailPlugin* aJunkPlugin,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsMsgDBView::GetFolderFromMsgURI(const char* aMsgURI,
|
||||
nsresult nsMsgDBView::GetFolderFromMsgURI(const nsACString& aMsgURI,
|
||||
nsIMsgFolder** aFolder) {
|
||||
NS_IF_ADDREF(*aFolder = m_folder);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgDBView::OnMessageClassified(const char* aMsgURI,
|
||||
nsMsgDBView::OnMessageClassified(const nsACString& aMsgURI,
|
||||
nsMsgJunkStatus aClassification,
|
||||
uint32_t aJunkPercent)
|
||||
|
||||
|
@ -3527,7 +3527,7 @@ nsresult nsMsgDBView::DetermineActionsForJunkChange(
|
|||
if (folderFlags & nsMsgFolderFlags::Junk) return NS_OK;
|
||||
|
||||
nsCString spamFolderURI;
|
||||
rv = spamSettings->GetSpamFolderURI(getter_Copies(spamFolderURI));
|
||||
rv = spamSettings->GetSpamFolderURI(spamFolderURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ASSERTION(!spamFolderURI.IsEmpty(),
|
||||
|
|
|
@ -283,7 +283,7 @@ class nsMsgDBView : public nsIMsgDBView,
|
|||
virtual nsMsgViewIndex FindKey(nsMsgKey key, bool expand);
|
||||
virtual nsresult GetDBForViewIndex(nsMsgViewIndex index, nsIMsgDatabase** db);
|
||||
virtual nsCOMArray<nsIMsgFolder>* GetFolders();
|
||||
virtual nsresult GetFolderFromMsgURI(const char* aMsgURI,
|
||||
virtual nsresult GetFolderFromMsgURI(const nsACString& aMsgURI,
|
||||
nsIMsgFolder** aFolder);
|
||||
|
||||
virtual nsresult ListIdsInThread(nsIMsgThread* threadHdr,
|
||||
|
|
|
@ -1784,7 +1784,7 @@ nsresult nsMsgIncomingServer::ConfigureTemporaryServerSpamFilters(
|
|||
spamSettings->GetMoveOnSpam(&moveOnSpam);
|
||||
if (moveOnSpam) {
|
||||
nsCString spamFolderURI;
|
||||
rv = spamSettings->GetSpamFolderURI(getter_Copies(spamFolderURI));
|
||||
rv = spamSettings->GetSpamFolderURI(spamFolderURI);
|
||||
if (NS_SUCCEEDED(rv) && (!spamFolderURI.IsEmpty())) {
|
||||
nsCOMPtr<nsIMsgRuleAction> moveAction;
|
||||
rv = newFilter->CreateAction(getter_AddRefs(moveAction));
|
||||
|
|
|
@ -237,7 +237,7 @@ nsresult nsMsgPurgeService::PerformPurge() {
|
|||
// check if the spam folder uri is set for this server
|
||||
// if not skip it.
|
||||
nsCString junkFolderURI;
|
||||
rv = spamSettings->GetSpamFolderURI(getter_Copies(junkFolderURI));
|
||||
rv = spamSettings->GetSpamFolderURI(junkFolderURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
MOZ_LOG(MsgPurgeLogModule, mozilla::LogLevel::Info,
|
||||
|
|
|
@ -1094,16 +1094,15 @@ nsMsgSearchDBView::OpenWithHdrs(nsIMsgEnumerator* aHeaders,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsMsgSearchDBView::GetFolderFromMsgURI(const char* aMsgURI,
|
||||
nsresult nsMsgSearchDBView::GetFolderFromMsgURI(const nsACString& aMsgURI,
|
||||
nsIMsgFolder** aFolder) {
|
||||
nsCOMPtr<nsIMsgMessageService> msgMessageService;
|
||||
nsresult rv = GetMessageServiceFromURI(nsDependentCString(aMsgURI),
|
||||
getter_AddRefs(msgMessageService));
|
||||
nsresult rv =
|
||||
GetMessageServiceFromURI(aMsgURI, getter_AddRefs(msgMessageService));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr;
|
||||
rv = msgMessageService->MessageURIToMsgHdr(nsDependentCString(aMsgURI),
|
||||
getter_AddRefs(msgHdr));
|
||||
rv = msgMessageService->MessageURIToMsgHdr(aMsgURI, getter_AddRefs(msgHdr));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return msgHdr->GetFolder(aFolder);
|
||||
|
|
|
@ -78,7 +78,7 @@ class nsMsgSearchDBView : public nsMsgGroupView,
|
|||
NS_IMETHOD OnAnnouncerGoingAway(nsIDBChangeAnnouncer* instigator) override;
|
||||
|
||||
virtual nsCOMArray<nsIMsgFolder>* GetFolders() override;
|
||||
virtual nsresult GetFolderFromMsgURI(const char* aMsgURI,
|
||||
virtual nsresult GetFolderFromMsgURI(const nsACString& aMsgURI,
|
||||
nsIMsgFolder** aFolder) override;
|
||||
|
||||
NS_IMETHOD GetThreadContainingMsgHdr(nsIMsgDBHdr* msgHdr,
|
||||
|
|
|
@ -123,38 +123,36 @@ NS_IMPL_GETSET(nsSpamSettings, Purge, bool, mPurge)
|
|||
NS_IMPL_GETSET(nsSpamSettings, UseWhiteList, bool, mUseWhiteList)
|
||||
NS_IMPL_GETSET(nsSpamSettings, UseServerFilter, bool, mUseServerFilter)
|
||||
|
||||
NS_IMETHODIMP nsSpamSettings::GetWhiteListAbURI(char** aWhiteListAbURI) {
|
||||
NS_ENSURE_ARG_POINTER(aWhiteListAbURI);
|
||||
*aWhiteListAbURI = ToNewCString(mWhiteListAbURI);
|
||||
NS_IMETHODIMP nsSpamSettings::GetWhiteListAbURI(nsACString& aWhiteListAbURI) {
|
||||
aWhiteListAbURI = mWhiteListAbURI;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsSpamSettings::SetWhiteListAbURI(const char* aWhiteListAbURI) {
|
||||
NS_IMETHODIMP nsSpamSettings::SetWhiteListAbURI(
|
||||
const nsACString& aWhiteListAbURI) {
|
||||
mWhiteListAbURI = aWhiteListAbURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSpamSettings::GetActionTargetAccount(
|
||||
char** aActionTargetAccount) {
|
||||
NS_ENSURE_ARG_POINTER(aActionTargetAccount);
|
||||
*aActionTargetAccount = ToNewCString(mActionTargetAccount);
|
||||
nsACString& aActionTargetAccount) {
|
||||
aActionTargetAccount = mActionTargetAccount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSpamSettings::SetActionTargetAccount(
|
||||
const char* aActionTargetAccount) {
|
||||
const nsACString& aActionTargetAccount) {
|
||||
mActionTargetAccount = aActionTargetAccount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSpamSettings::GetActionTargetFolder(
|
||||
char** aActionTargetFolder) {
|
||||
NS_ENSURE_ARG_POINTER(aActionTargetFolder);
|
||||
*aActionTargetFolder = ToNewCString(mActionTargetFolder);
|
||||
nsACString& aActionTargetFolder) {
|
||||
aActionTargetFolder = mActionTargetFolder;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSpamSettings::SetActionTargetFolder(
|
||||
const char* aActionTargetFolder) {
|
||||
const nsACString& aActionTargetFolder) {
|
||||
mActionTargetFolder = aActionTargetFolder;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -248,13 +246,13 @@ NS_IMETHODIMP nsSpamSettings::Initialize(nsIMsgIncomingServer* aServer) {
|
|||
rv =
|
||||
aServer->GetCharValue("spamActionTargetAccount", spamActionTargetAccount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = SetActionTargetAccount(spamActionTargetAccount.get());
|
||||
rv = SetActionTargetAccount(spamActionTargetAccount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCString spamActionTargetFolder;
|
||||
rv = aServer->GetCharValue("spamActionTargetFolder", spamActionTargetFolder);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = SetActionTargetFolder(spamActionTargetFolder.get());
|
||||
rv = SetActionTargetFolder(spamActionTargetFolder);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool useWhiteList;
|
||||
|
@ -266,7 +264,7 @@ NS_IMETHODIMP nsSpamSettings::Initialize(nsIMsgIncomingServer* aServer) {
|
|||
nsCString whiteListAbURI;
|
||||
rv = aServer->GetCharValue("whiteListAbURI", whiteListAbURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = SetWhiteListAbURI(whiteListAbURI.get());
|
||||
rv = SetWhiteListAbURI(whiteListAbURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool purgeSpam;
|
||||
|
@ -394,7 +392,7 @@ nsresult nsSpamSettings::UpdateJunkFolderState() {
|
|||
// if the spam folder uri changed on us, we need to unset the junk flag
|
||||
// on the old spam folder
|
||||
nsCString newJunkFolderURI;
|
||||
rv = GetSpamFolderURI(getter_Copies(newJunkFolderURI));
|
||||
rv = GetSpamFolderURI(newJunkFolderURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!mCurrentJunkFolderURI.IsEmpty() &&
|
||||
|
@ -447,18 +445,17 @@ NS_IMETHODIMP nsSpamSettings::Clone(nsISpamSettings* aSpamSettings) {
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCString actionTargetAccount;
|
||||
rv =
|
||||
aSpamSettings->GetActionTargetAccount(getter_Copies(actionTargetAccount));
|
||||
rv = aSpamSettings->GetActionTargetAccount(actionTargetAccount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mActionTargetAccount = actionTargetAccount;
|
||||
|
||||
nsCString actionTargetFolder;
|
||||
rv = aSpamSettings->GetActionTargetFolder(getter_Copies(actionTargetFolder));
|
||||
rv = aSpamSettings->GetActionTargetFolder(actionTargetFolder);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mActionTargetFolder = actionTargetFolder;
|
||||
|
||||
nsCString whiteListAbURI;
|
||||
rv = aSpamSettings->GetWhiteListAbURI(getter_Copies(whiteListAbURI));
|
||||
rv = aSpamSettings->GetWhiteListAbURI(whiteListAbURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mWhiteListAbURI = whiteListAbURI;
|
||||
|
||||
|
@ -468,16 +465,14 @@ NS_IMETHODIMP nsSpamSettings::Clone(nsISpamSettings* aSpamSettings) {
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSpamSettings::GetSpamFolderURI(char** aSpamFolderURI) {
|
||||
NS_ENSURE_ARG_POINTER(aSpamFolderURI);
|
||||
|
||||
NS_IMETHODIMP nsSpamSettings::GetSpamFolderURI(nsACString& aSpamFolderURI) {
|
||||
if (mMoveTargetMode == nsISpamSettings::MOVE_TARGET_MODE_FOLDER)
|
||||
return GetActionTargetFolder(aSpamFolderURI);
|
||||
|
||||
// if the mode is nsISpamSettings::MOVE_TARGET_MODE_ACCOUNT
|
||||
// the spam folder URI = account uri + "/Junk"
|
||||
nsCString folderURI;
|
||||
nsresult rv = GetActionTargetAccount(getter_Copies(folderURI));
|
||||
nsresult rv = GetActionTargetAccount(folderURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// we might be trying to get the old spam folder uri
|
||||
|
@ -518,11 +513,8 @@ NS_IMETHODIMP nsSpamSettings::GetSpamFolderURI(char** aSpamFolderURI) {
|
|||
if (!folderUriWithNamespace.IsEmpty()) folderURI = folderUriWithNamespace;
|
||||
}
|
||||
|
||||
*aSpamFolderURI = ToNewCString(folderURI);
|
||||
if (!*aSpamFolderURI)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
else
|
||||
return rv;
|
||||
aSpamFolderURI = folderURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSpamSettings::GetServerFilterName(nsACString& aFilterName) {
|
||||
|
@ -643,7 +635,7 @@ NS_IMETHODIMP nsSpamSettings::LogJunkHit(nsIMsgDBHdr* aMsgHdr,
|
|||
aMsgHdr->GetMessageId(getter_Copies(msgId));
|
||||
|
||||
nsCString junkFolderURI;
|
||||
rv = GetSpamFolderURI(getter_Copies(junkFolderURI));
|
||||
rv = GetSpamFolderURI(junkFolderURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
AutoTArray<nsString, 2> logMoveFormatStrings;
|
||||
|
@ -725,7 +717,7 @@ NS_IMETHODIMP nsSpamSettings::OnStartRunningUrl(nsIURI* aURL) {
|
|||
NS_IMETHODIMP nsSpamSettings::OnStopRunningUrl(nsIURI* aURL,
|
||||
nsresult exitCode) {
|
||||
nsCString junkFolderURI;
|
||||
nsresult rv = GetSpamFolderURI(getter_Copies(junkFolderURI));
|
||||
nsresult rv = GetSpamFolderURI(junkFolderURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (junkFolderURI.IsEmpty()) return NS_ERROR_UNEXPECTED;
|
||||
|
|
|
@ -955,7 +955,7 @@ class TokenAnalyzer {
|
|||
mTokenListener = aTokenListener;
|
||||
}
|
||||
|
||||
void setSource(const char* sourceURI) { mTokenSource = sourceURI; }
|
||||
void setSource(const nsACString& sourceURI) { mTokenSource = sourceURI; }
|
||||
|
||||
nsCOMPtr<nsIStreamListener> mTokenListener;
|
||||
nsCString mTokenSource;
|
||||
|
@ -1312,9 +1312,8 @@ class MessageClassifier : public TokenAnalyzer {
|
|||
|
||||
virtual ~MessageClassifier() {}
|
||||
virtual void analyzeTokens(Tokenizer& tokenizer) {
|
||||
mFilter->classifyMessage(tokenizer, mTokenSource.get(), mProTraits,
|
||||
mAntiTraits, mJunkListener, mTraitListener,
|
||||
mDetailListener);
|
||||
mFilter->classifyMessage(tokenizer, mTokenSource, mProTraits, mAntiTraits,
|
||||
mJunkListener, mTraitListener, mDetailListener);
|
||||
tokenizer.clearTokens();
|
||||
classifyNextMessage();
|
||||
}
|
||||
|
@ -1324,17 +1323,17 @@ class MessageClassifier : public TokenAnalyzer {
|
|||
MOZ_LOG(BayesianFilterLogModule, LogLevel::Warning,
|
||||
("classifyNextMessage(%s)",
|
||||
mMessageURIs[mCurMessageToClassify].get()));
|
||||
mFilter->tokenizeMessage(mMessageURIs[mCurMessageToClassify].get(),
|
||||
mMsgWindow, this);
|
||||
mFilter->tokenizeMessage(mMessageURIs[mCurMessageToClassify], mMsgWindow,
|
||||
this);
|
||||
} else {
|
||||
// call all listeners with null parameters to signify end of batch
|
||||
if (mJunkListener)
|
||||
mJunkListener->OnMessageClassified(nullptr,
|
||||
mJunkListener->OnMessageClassified(EmptyCString(),
|
||||
nsIJunkMailPlugin::UNCLASSIFIED, 0);
|
||||
if (mTraitListener) {
|
||||
nsTArray<uint32_t> nullTraits;
|
||||
nsTArray<uint32_t> nullPercents;
|
||||
mTraitListener->OnMessageTraitsClassified(nullptr, nullTraits,
|
||||
mTraitListener->OnMessageTraitsClassified(EmptyCString(), nullTraits,
|
||||
nullPercents);
|
||||
}
|
||||
mTokenListener =
|
||||
|
@ -1356,22 +1355,19 @@ class MessageClassifier : public TokenAnalyzer {
|
|||
uint32_t mCurMessageToClassify; // 0-based index
|
||||
};
|
||||
|
||||
nsresult nsBayesianFilter::tokenizeMessage(const char* aMessageURI,
|
||||
nsresult nsBayesianFilter::tokenizeMessage(const nsACString& aMessageURI,
|
||||
nsIMsgWindow* aMsgWindow,
|
||||
TokenAnalyzer* aAnalyzer) {
|
||||
NS_ENSURE_ARG_POINTER(aMessageURI);
|
||||
|
||||
nsCOMPtr<nsIMsgMessageService> msgService;
|
||||
nsresult rv = GetMessageServiceFromURI(nsDependentCString(aMessageURI),
|
||||
getter_AddRefs(msgService));
|
||||
nsresult rv =
|
||||
GetMessageServiceFromURI(aMessageURI, getter_AddRefs(msgService));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aAnalyzer->setSource(aMessageURI);
|
||||
nsCOMPtr<nsIURI> dummyNull;
|
||||
return msgService->StreamMessage(
|
||||
nsDependentCString(aMessageURI), aAnalyzer->mTokenListener, aMsgWindow,
|
||||
nullptr, true /* convert data */, "filter"_ns, false,
|
||||
getter_AddRefs(dummyNull));
|
||||
aMessageURI, aAnalyzer->mTokenListener, aMsgWindow, nullptr,
|
||||
true /* convert data */, "filter"_ns, false, getter_AddRefs(dummyNull));
|
||||
}
|
||||
|
||||
// a TraitAnalysis is the per-token representation of the statistical
|
||||
|
@ -1420,7 +1416,7 @@ static inline double chi2P(double chi2, double nu, int32_t* error) {
|
|||
}
|
||||
|
||||
void nsBayesianFilter::classifyMessage(
|
||||
Tokenizer& tokenizer, const char* messageURI,
|
||||
Tokenizer& tokenizer, const nsACString& messageURI,
|
||||
nsTArray<uint32_t>& aProTraits, nsTArray<uint32_t>& aAntiTraits,
|
||||
nsIJunkMailClassificationListener* listener,
|
||||
nsIMsgTraitClassificationListener* aTraitListener,
|
||||
|
@ -1677,7 +1673,7 @@ void nsBayesianFilter::classifyMessage(
|
|||
bool isJunk = (prob >= mJunkProbabilityThreshold);
|
||||
MOZ_LOG(BayesianFilterLogModule, LogLevel::Info,
|
||||
("%s is junk probability = (%f) HAM SCORE:%f SPAM SCORE:%f",
|
||||
messageURI, prob, H, S));
|
||||
PromiseFlatCString(messageURI).get(), prob, H, S));
|
||||
|
||||
// the algorithm in "A Plan For Spam" assumes that you have a large good
|
||||
// corpus and a large junk corpus.
|
||||
|
@ -1724,7 +1720,7 @@ void nsBayesianFilter::classifyMessage(
|
|||
}
|
||||
|
||||
void nsBayesianFilter::classifyMessage(
|
||||
Tokenizer& tokens, const char* messageURI,
|
||||
Tokenizer& tokens, const nsACString& messageURI,
|
||||
nsIJunkMailClassificationListener* aJunkListener) {
|
||||
AutoTArray<uint32_t, 1> proTraits;
|
||||
AutoTArray<uint32_t, 1> antiTraits;
|
||||
|
@ -1760,9 +1756,9 @@ NS_IMETHODIMP nsBayesianFilter::GetShouldDownloadAllHeaders(
|
|||
/* void classifyMessage (in string aMsgURL, in nsIJunkMailClassificationListener
|
||||
* aListener); */
|
||||
NS_IMETHODIMP nsBayesianFilter::ClassifyMessage(
|
||||
const char* aMessageURL, nsIMsgWindow* aMsgWindow,
|
||||
const nsACString& aMessageURL, nsIMsgWindow* aMsgWindow,
|
||||
nsIJunkMailClassificationListener* aListener) {
|
||||
AutoTArray<nsCString, 1> urls = {nsDependentCString(aMessageURL)};
|
||||
AutoTArray<nsCString, 1> urls = {PromiseFlatCString(aMessageURL)};
|
||||
MessageClassifier* analyzer =
|
||||
new MessageClassifier(this, aListener, aMsgWindow, urls);
|
||||
NS_ENSURE_TRUE(analyzer, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
@ -1784,7 +1780,7 @@ NS_IMETHODIMP nsBayesianFilter::ClassifyMessages(
|
|||
TokenStreamListener* tokenListener = new TokenStreamListener(analyzer);
|
||||
NS_ENSURE_TRUE(tokenListener, NS_ERROR_OUT_OF_MEMORY);
|
||||
analyzer->setTokenListener(tokenListener);
|
||||
return tokenizeMessage(aMsgURLs[0].get(), aMsgWindow, analyzer);
|
||||
return tokenizeMessage(aMsgURLs[0], aMsgWindow, analyzer);
|
||||
}
|
||||
|
||||
nsresult nsBayesianFilter::setAnalysis(Token& token, uint32_t aTraitIndex,
|
||||
|
@ -1867,7 +1863,7 @@ NS_IMETHODIMP nsBayesianFilter::ClassifyTraitsInMessages(
|
|||
TokenStreamListener* tokenListener = new TokenStreamListener(analyzer);
|
||||
|
||||
analyzer->setTokenListener(tokenListener);
|
||||
return tokenizeMessage(aMsgURIs[0].get(), aMsgWindow, analyzer);
|
||||
return tokenizeMessage(aMsgURIs[0], aMsgWindow, analyzer);
|
||||
}
|
||||
|
||||
class MessageObserver : public TokenAnalyzer {
|
||||
|
@ -1885,7 +1881,7 @@ class MessageObserver : public TokenAnalyzer {
|
|||
mNewClassifications(aNewClassifications.Clone()) {}
|
||||
|
||||
virtual void analyzeTokens(Tokenizer& tokenizer) {
|
||||
mFilter->observeMessage(tokenizer, mTokenSource.get(), mOldClassifications,
|
||||
mFilter->observeMessage(tokenizer, mTokenSource, mOldClassifications,
|
||||
mNewClassifications, mJunkListener, mTraitListener);
|
||||
// release reference to listener, which will allow us to go away as well.
|
||||
mTokenListener = nullptr;
|
||||
|
@ -1901,7 +1897,7 @@ class MessageObserver : public TokenAnalyzer {
|
|||
};
|
||||
|
||||
NS_IMETHODIMP nsBayesianFilter::SetMsgTraitClassification(
|
||||
const char* aMsgURI, const nsTArray<uint32_t>& aOldTraits,
|
||||
const nsACString& aMsgURI, const nsTArray<uint32_t>& aOldTraits,
|
||||
const nsTArray<uint32_t>& aNewTraits,
|
||||
nsIMsgTraitClassificationListener* aTraitListener, nsIMsgWindow* aMsgWindow,
|
||||
nsIJunkMailClassificationListener* aJunkListener) {
|
||||
|
@ -1918,7 +1914,7 @@ NS_IMETHODIMP nsBayesianFilter::SetMsgTraitClassification(
|
|||
|
||||
// set new message classifications for a message
|
||||
void nsBayesianFilter::observeMessage(
|
||||
Tokenizer& tokenizer, const char* messageURL,
|
||||
Tokenizer& tokenizer, const nsACString& messageURL,
|
||||
nsTArray<uint32_t>& oldClassifications,
|
||||
nsTArray<uint32_t>& newClassifications,
|
||||
nsIJunkMailClassificationListener* aJunkListener,
|
||||
|
@ -2010,7 +2006,7 @@ NS_IMETHODIMP nsBayesianFilter::GetUserHasClassified(bool* aResult) {
|
|||
|
||||
// Set message classification (only allows junk and good)
|
||||
NS_IMETHODIMP nsBayesianFilter::SetMessageClassification(
|
||||
const char* aMsgURL, nsMsgJunkStatus aOldClassification,
|
||||
const nsACString& aMsgURL, nsMsgJunkStatus aOldClassification,
|
||||
nsMsgJunkStatus aNewClassification, nsIMsgWindow* aMsgWindow,
|
||||
nsIJunkMailClassificationListener* aListener) {
|
||||
AutoTArray<uint32_t, 1> oldClassifications;
|
||||
|
@ -2042,11 +2038,11 @@ NS_IMETHODIMP nsBayesianFilter::ResetTrainingData() {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP nsBayesianFilter::DetailMessage(
|
||||
const char* aMsgURI, uint32_t aProTrait, uint32_t aAntiTrait,
|
||||
const nsACString& aMsgURI, uint32_t aProTrait, uint32_t aAntiTrait,
|
||||
nsIMsgTraitDetailListener* aDetailListener, nsIMsgWindow* aMsgWindow) {
|
||||
AutoTArray<uint32_t, 1> proTraits = {aProTrait};
|
||||
AutoTArray<uint32_t, 1> antiTraits = {aAntiTrait};
|
||||
AutoTArray<nsCString, 1> uris = {nsDependentCString(aMsgURI)};
|
||||
AutoTArray<nsCString, 1> uris = {PromiseFlatCString(aMsgURI)};
|
||||
|
||||
MessageClassifier* analyzer =
|
||||
new MessageClassifier(this, nullptr, nullptr, aDetailListener, proTraits,
|
||||
|
|
|
@ -345,19 +345,19 @@ class nsBayesianFilter : public nsIJunkMailPlugin,
|
|||
|
||||
nsresult Init();
|
||||
|
||||
nsresult tokenizeMessage(const char* messageURI, nsIMsgWindow* aMsgWindow,
|
||||
TokenAnalyzer* analyzer);
|
||||
void classifyMessage(Tokenizer& tokens, const char* messageURI,
|
||||
nsresult tokenizeMessage(const nsACString& messageURI,
|
||||
nsIMsgWindow* aMsgWindow, TokenAnalyzer* analyzer);
|
||||
void classifyMessage(Tokenizer& tokens, const nsACString& messageURI,
|
||||
nsIJunkMailClassificationListener* listener);
|
||||
|
||||
void classifyMessage(Tokenizer& tokenizer, const char* messageURI,
|
||||
void classifyMessage(Tokenizer& tokenizer, const nsACString& messageURI,
|
||||
nsTArray<uint32_t>& aProTraits,
|
||||
nsTArray<uint32_t>& aAntiTraits,
|
||||
nsIJunkMailClassificationListener* listener,
|
||||
nsIMsgTraitClassificationListener* aTraitListener,
|
||||
nsIMsgTraitDetailListener* aDetailListener);
|
||||
|
||||
void observeMessage(Tokenizer& tokens, const char* messageURI,
|
||||
void observeMessage(Tokenizer& tokens, const nsACString& messageURI,
|
||||
nsTArray<uint32_t>& oldClassifications,
|
||||
nsTArray<uint32_t>& newClassifications,
|
||||
nsIJunkMailClassificationListener* listener,
|
||||
|
|
|
@ -1372,11 +1372,11 @@ NS_IMETHODIMP nsImapIncomingServer::DiscoveryDone() {
|
|||
rv = GetSpamSettings(getter_AddRefs(spamSettings));
|
||||
if (NS_SUCCEEDED(rv) && spamSettings) {
|
||||
nsCString spamFolderUri, existingUri;
|
||||
spamSettings->GetSpamFolderURI(getter_Copies(spamFolderUri));
|
||||
spamSettings->GetSpamFolderURI(spamFolderUri);
|
||||
if (CheckSpecialFolder(spamFolderUri, nsMsgFolderFlags::Junk,
|
||||
existingUri)) {
|
||||
// This only sets the cached values in the spam settings object.
|
||||
spamSettings->SetActionTargetFolder(existingUri.get());
|
||||
spamSettings->SetActionTargetFolder(existingUri);
|
||||
spamSettings->SetMoveTargetMode(
|
||||
nsISpamSettings::MOVE_TARGET_MODE_FOLDER);
|
||||
// Set the preferences too so that the values persist.
|
||||
|
|
|
@ -8242,18 +8242,17 @@ nsImapMailFolder::SetJunkScoreForMessages(
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMailFolder::OnMessageClassified(const char* aMsgURI,
|
||||
nsImapMailFolder::OnMessageClassified(const nsACString& aMsgURI,
|
||||
nsMsgJunkStatus aClassification,
|
||||
uint32_t aJunkPercent) {
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
nsresult rv = GetServer(getter_AddRefs(server));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aMsgURI) // not end of batch
|
||||
if (!aMsgURI.IsEmpty()) // not end of batch
|
||||
{
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr;
|
||||
rv =
|
||||
GetMsgDBHdrFromURI(nsDependentCString(aMsgURI), getter_AddRefs(msgHdr));
|
||||
rv = GetMsgDBHdrFromURI(aMsgURI, getter_AddRefs(msgHdr));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsMsgKey msgKey;
|
||||
|
@ -8298,7 +8297,7 @@ nsImapMailFolder::OnMessageClassified(const char* aMsgURI,
|
|||
(void)spamSettings->GetMoveOnSpam(&moveOnSpam);
|
||||
if (moveOnSpam) {
|
||||
nsCString spamFolderURI;
|
||||
rv = spamSettings->GetSpamFolderURI(getter_Copies(spamFolderURI));
|
||||
rv = spamSettings->GetSpamFolderURI(spamFolderURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!spamFolderURI.IsEmpty()) {
|
||||
|
@ -8335,8 +8334,8 @@ nsImapMailFolder::OnMessageClassified(const char* aMsgURI,
|
|||
else // end of batch
|
||||
{
|
||||
// Parent will apply post bayes filters.
|
||||
nsMsgDBFolder::OnMessageClassified(nullptr, nsIJunkMailPlugin::UNCLASSIFIED,
|
||||
0);
|
||||
nsMsgDBFolder::OnMessageClassified(EmptyCString(),
|
||||
nsIJunkMailPlugin::UNCLASSIFIED, 0);
|
||||
|
||||
if (!m_junkMessagesToMarkAsRead.IsEmpty()) {
|
||||
rv = MarkMessagesRead(m_junkMessagesToMarkAsRead, true);
|
||||
|
|
|
@ -3062,7 +3062,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Shutdown(bool shutdownChildren) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgLocalMailFolder::OnMessageClassified(const char* aMsgURI,
|
||||
nsMsgLocalMailFolder::OnMessageClassified(const nsACString& aMsgURI,
|
||||
nsMsgJunkStatus aClassification,
|
||||
uint32_t aJunkPercent)
|
||||
|
||||
|
@ -3076,14 +3076,13 @@ nsMsgLocalMailFolder::OnMessageClassified(const char* aMsgURI,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCString spamFolderURI;
|
||||
rv = spamSettings->GetSpamFolderURI(getter_Copies(spamFolderURI));
|
||||
rv = spamSettings->GetSpamFolderURI(spamFolderURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aMsgURI) // not end of batch
|
||||
if (!aMsgURI.IsEmpty()) // not end of batch
|
||||
{
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr;
|
||||
rv =
|
||||
GetMsgDBHdrFromURI(nsDependentCString(aMsgURI), getter_AddRefs(msgHdr));
|
||||
rv = GetMsgDBHdrFromURI(aMsgURI, getter_AddRefs(msgHdr));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsMsgKey msgKey;
|
||||
|
@ -3141,8 +3140,8 @@ nsMsgLocalMailFolder::OnMessageClassified(const char* aMsgURI,
|
|||
else // end of batch
|
||||
{
|
||||
// Parent will apply post bayes filters.
|
||||
nsMsgDBFolder::OnMessageClassified(nullptr, nsIJunkMailPlugin::UNCLASSIFIED,
|
||||
0);
|
||||
nsMsgDBFolder::OnMessageClassified(EmptyCString(),
|
||||
nsIJunkMailPlugin::UNCLASSIFIED, 0);
|
||||
nsTArray<RefPtr<nsIMsgDBHdr>> messages;
|
||||
if (!mSpamKeysToMove.IsEmpty()) {
|
||||
nsCOMPtr<nsIMsgFolder> folder;
|
||||
|
|
|
@ -82,7 +82,7 @@ interface nsIMsgFilterList : nsISupports {
|
|||
void writeStrAttr(in nsMsgFilterFileAttribValue attrib, in string value, in nsIOutputStream stream);
|
||||
void writeWstrAttr(in nsMsgFilterFileAttribValue attrib, in wstring value, in nsIOutputStream stream);
|
||||
void writeBoolAttr(in nsMsgFilterFileAttribValue attrib, in boolean value, in nsIOutputStream stream);
|
||||
boolean matchOrChangeFilterTarget(in ACString oldUri, in ACString newUri, in boolean caseInsensitive);
|
||||
boolean matchOrChangeFilterTarget(in AUTF8String oldUri, in AUTF8String newUri, in boolean caseInsensitive);
|
||||
|
||||
/**
|
||||
* Turn filter logging on or off. Turning logging off will close any
|
||||
|
|
|
@ -53,7 +53,7 @@ interface nsIJunkMailClassificationListener : nsISupports
|
|||
* @param aJunkPercent indicator of degree of uncertainty, with 100 being
|
||||
* probably junk, and 0 probably good
|
||||
*/
|
||||
void onMessageClassified(in string aMsgURI,
|
||||
void onMessageClassified(in AUTF8String aMsgURI,
|
||||
in nsMsgJunkStatus aClassification,
|
||||
in uint32_t aJunkPercent);
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ interface nsIMsgTraitClassificationListener : nsISupports
|
|||
* matched) of the trait with the corresponding array
|
||||
* index in aTraits
|
||||
*/
|
||||
void onMessageTraitsClassified(in string aMsgURI,
|
||||
void onMessageTraitsClassified(in AUTF8String aMsgURI,
|
||||
in Array<unsigned long> aTraits,
|
||||
in Array<unsigned long> aPercents);
|
||||
};
|
||||
|
@ -98,7 +98,7 @@ interface nsIMsgTraitDetailListener : nsISupports
|
|||
* @param runningPercents calculated probability that the message matches the
|
||||
* trait, accounting for this token and all stronger tokens.
|
||||
*/
|
||||
void onMessageTraitDetails(in string aMsgUri,
|
||||
void onMessageTraitDetails(in AUTF8String aMsgUri,
|
||||
in unsigned long aProTrait,
|
||||
in Array<AString> tokenStrings,
|
||||
in Array<unsigned long> tokenPercents,
|
||||
|
@ -135,10 +135,10 @@ interface nsIJunkMailPlugin : nsIMsgFilterPlugin
|
|||
* Given a message URI, determine what its current classification is
|
||||
* according to the current training set.
|
||||
*/
|
||||
void classifyMessage(in string aMsgURI, in nsIMsgWindow aMsgWindow,
|
||||
void classifyMessage(in AUTF8String aMsgURI, in nsIMsgWindow aMsgWindow,
|
||||
in nsIJunkMailClassificationListener aListener);
|
||||
|
||||
void classifyMessages(in Array<ACString> aMsgURIs,
|
||||
void classifyMessages(in Array<AUTF8String> aMsgURIs,
|
||||
in nsIMsgWindow aMsgWindow,
|
||||
in nsIJunkMailClassificationListener aListener);
|
||||
|
||||
|
@ -159,7 +159,7 @@ interface nsIJunkMailPlugin : nsIMsgFilterPlugin
|
|||
*/
|
||||
|
||||
void classifyTraitsInMessage(
|
||||
in ACString aMsgURI,
|
||||
in AUTF8String aMsgURI,
|
||||
in Array<unsigned long> aProTraits,
|
||||
in Array<unsigned long> aAntiTraits,
|
||||
in nsIMsgTraitClassificationListener aTraitListener,
|
||||
|
@ -183,7 +183,7 @@ interface nsIJunkMailPlugin : nsIMsgFilterPlugin
|
|||
*/
|
||||
|
||||
void classifyTraitsInMessages(
|
||||
in Array<ACString> aMsgURIs,
|
||||
in Array<AUTF8String> aMsgURIs,
|
||||
in Array<unsigned long> aProTraits,
|
||||
in Array<unsigned long> aAntiTraits,
|
||||
in nsIMsgTraitClassificationListener aTraitListener,
|
||||
|
@ -201,7 +201,7 @@ interface nsIJunkMailPlugin : nsIMsgFilterPlugin
|
|||
* @arg aListener Callback (may be null)
|
||||
*/
|
||||
void setMessageClassification(
|
||||
in string aMsgURI, in nsMsgJunkStatus aOldUserClassification,
|
||||
in AUTF8String aMsgURI, in nsMsgJunkStatus aOldUserClassification,
|
||||
in nsMsgJunkStatus aNewClassification,
|
||||
in nsIMsgWindow aMsgWindow,
|
||||
in nsIJunkMailClassificationListener aListener);
|
||||
|
@ -220,7 +220,7 @@ interface nsIJunkMailPlugin : nsIMsgFilterPlugin
|
|||
* @param aJunkListener junk-oriented listener (may be null)
|
||||
*/
|
||||
void setMsgTraitClassification(
|
||||
in string aMsgURI,
|
||||
in AUTF8String aMsgURI,
|
||||
in Array<unsigned long> aOldTraits,
|
||||
in Array<unsigned long> aNewTraits,
|
||||
[optional] in nsIMsgTraitClassificationListener aTraitListener,
|
||||
|
@ -250,7 +250,7 @@ interface nsIJunkMailPlugin : nsIMsgFilterPlugin
|
|||
* @param aMsgWindow current message window (may be null)
|
||||
*/
|
||||
void detailMessage(
|
||||
in string aMsgURI,
|
||||
in AUTF8String aMsgURI,
|
||||
in unsigned long aProTrait,
|
||||
in unsigned long aAntiTrait,
|
||||
in nsIMsgTraitDetailListener aListener,
|
||||
|
|
Загрузка…
Ссылка в новой задаче