Bug 1562158 - Remove xpidl [array] use from nsIMsgTraitService. r=jorgk
This commit is contained in:
Родитель
6ac0670a6e
Коммит
a3914ac40b
|
@ -129,17 +129,26 @@ interface nsIMsgTraitService : nsISupports
|
|||
ACString getAntiId(in ACString id);
|
||||
|
||||
/**
|
||||
* get an array of traits to be analyzed by the bayesian code. This is
|
||||
* a pair of traits: a "pro" trait of messages that match the trait (and is
|
||||
* set enabled) and an "anti" trait of messages that do not match the trait.
|
||||
* Get an array of "pro" traits to be analyzed by the bayesian code. This is
|
||||
* a "pro" trait of messages that match the trait.
|
||||
* Only enabled traits are returned.
|
||||
* This should return the same number of indices as the corresponding call to
|
||||
* getEnabledAntiIndices().
|
||||
*
|
||||
* @param count length of proIndices and antiIndices arrays
|
||||
* @param proIndices trait internal index for "pro" trait to analyze
|
||||
* @param antiIndices trait internal index for corresponding "anti" traits
|
||||
* @return array of trait internal indices for "pro" trait to analyze
|
||||
*/
|
||||
void getEnabledIndices(out unsigned long count,
|
||||
[array, size_is(count)] out unsigned long proIndices,
|
||||
[array, size_is(count)] out unsigned long antiIndices);
|
||||
Array<unsigned long> getEnabledProIndices();
|
||||
|
||||
/**
|
||||
* Get an array of "anti" traits to be analyzed by the bayesian code. This is
|
||||
* a "anti" trait of messages that do not match the trait.
|
||||
* Only enabled traits are returned.
|
||||
* This should return the same number of indices as the corresponding call to
|
||||
* getEnabledProIndices().
|
||||
*
|
||||
* @return array of trait internal indices for "anti" trait to analyze
|
||||
*/
|
||||
Array<unsigned long> getEnabledAntiIndices();
|
||||
|
||||
/**
|
||||
* Add a trait as an alias of another trait. An alias is a trait whose
|
||||
|
|
|
@ -103,18 +103,24 @@ nsMsgTraitService.prototype = {
|
|||
return _traits[aId].antiId;
|
||||
},
|
||||
|
||||
getEnabledIndices(aCount, aProIndices, aAntiIndices) {
|
||||
getEnabledProIndices() {
|
||||
let proIndices = [];
|
||||
let antiIndices = [];
|
||||
for (let id in _traits) {
|
||||
if (_traits[id].enabled) {
|
||||
proIndices.push(_traits[id].index);
|
||||
}
|
||||
}
|
||||
return proIndices;
|
||||
},
|
||||
|
||||
getEnabledAntiIndices() {
|
||||
let antiIndices = [];
|
||||
for (let id in _traits) {
|
||||
if (_traits[id].enabled) {
|
||||
antiIndices.push(_traits[_traits[id].antiId].index);
|
||||
}
|
||||
}
|
||||
aCount.value = proIndices.length;
|
||||
aProIndices.value = proIndices;
|
||||
aAntiIndices.value = antiIndices;
|
||||
return antiIndices;
|
||||
},
|
||||
|
||||
addAlias(aTraitIndex, aTraitAliasIndex) {
|
||||
|
|
|
@ -57,13 +57,12 @@ function run_test() {
|
|||
Assert.ok(ts.getEnabled(proId));
|
||||
ts.setAntiId(proId, antiId);
|
||||
Assert.equal(antiId, ts.getAntiId(proId));
|
||||
var proArray = {};
|
||||
var antiArray = {};
|
||||
ts.getEnabledIndices({}, proArray, antiArray);
|
||||
Assert.equal(proArray.value.length, 2);
|
||||
Assert.equal(antiArray.value.length, 2);
|
||||
Assert.equal(proArray.value[1], proIndex);
|
||||
Assert.equal(antiArray.value[1], antiIndex);
|
||||
let proArray = ts.getEnabledProIndices();
|
||||
let antiArray = ts.getEnabledAntiIndices();
|
||||
Assert.equal(proArray.length, 2);
|
||||
Assert.equal(antiArray.length, 2);
|
||||
Assert.equal(proArray[1], proIndex);
|
||||
Assert.equal(antiArray[1], antiIndex);
|
||||
|
||||
// check of aliases
|
||||
// add three random aliases
|
||||
|
|
|
@ -2090,16 +2090,16 @@ nsresult nsMsgDBFolder::SpamFilterClassifyMessage(
|
|||
do_GetService("@mozilla.org/msg-trait-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
uint32_t count;
|
||||
uint32_t *proIndices;
|
||||
uint32_t *antiIndices;
|
||||
rv = traitService->GetEnabledIndices(&count, &proIndices, &antiIndices);
|
||||
nsTArray<uint32_t> proIndices;
|
||||
rv = traitService->GetEnabledProIndices(proIndices);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsTArray<uint32_t> antiIndices;
|
||||
rv = traitService->GetEnabledAntiIndices(antiIndices);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = aJunkMailPlugin->ClassifyTraitsInMessage(
|
||||
aURI, count, proIndices, antiIndices, this, aMsgWindow, this);
|
||||
free(proIndices);
|
||||
free(antiIndices);
|
||||
aURI, proIndices.Length(), proIndices.Elements(), antiIndices.Elements(),
|
||||
this, aMsgWindow, this);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2114,17 +2114,16 @@ nsresult nsMsgDBFolder::SpamFilterClassifyMessages(
|
|||
do_GetService("@mozilla.org/msg-trait-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
uint32_t count;
|
||||
uint32_t *proIndices;
|
||||
uint32_t *antiIndices;
|
||||
rv = traitService->GetEnabledIndices(&count, &proIndices, &antiIndices);
|
||||
nsTArray<uint32_t> proIndices;
|
||||
rv = traitService->GetEnabledProIndices(proIndices);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsTArray<uint32_t> antiIndices;
|
||||
rv = traitService->GetEnabledAntiIndices(antiIndices);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = aJunkMailPlugin->ClassifyTraitsInMessages(aURICount, aURIArray, count,
|
||||
proIndices, antiIndices, this,
|
||||
aMsgWindow, this);
|
||||
free(proIndices);
|
||||
free(antiIndices);
|
||||
rv = aJunkMailPlugin->ClassifyTraitsInMessages(
|
||||
aURICount, aURIArray, proIndices.Length(), proIndices.Elements(),
|
||||
antiIndices.Elements(), this, aMsgWindow, this);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2386,12 +2385,12 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow *aMsgWindow, bool *aFiltersRun) {
|
|||
do_GetService("@mozilla.org/msg-trait-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
uint32_t count = 0, *proIndices, *antiIndices;
|
||||
rv = traitService->GetEnabledIndices(&count, &proIndices, &antiIndices);
|
||||
nsTArray<uint32_t> proIndices;
|
||||
rv = traitService->GetEnabledProIndices(proIndices);
|
||||
bool filterForOther = false;
|
||||
// We just skip this on failure, since it is rarely used.
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
for (uint32_t i = 0; i < proIndices.Length(); ++i) {
|
||||
// The trait service determines which traits are globally enabled or
|
||||
// disabled. If a trait is enabled, it can still be made inactive
|
||||
// on a particular folder using an inherited property. To do that,
|
||||
|
@ -2415,8 +2414,6 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow *aMsgWindow, bool *aFiltersRun) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
free(proIndices);
|
||||
free(antiIndices);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
|
Загрузка…
Ссылка в новой задаче