7#include "filterimportersylpheed.h"
8#include "filter/mailfilter.h"
9#include "mailcommon_debug.h"
16FilterImporterSylpheed::FilterImporterSylpheed(
QFile *file)
17 : FilterImporterAbstract()
20 if (!loadDomElement(doc, file)) {
26 qCDebug(MAILCOMMON_LOG) <<
"No filters defined";
31 const QString tag = e.tagName();
32 if (tag == QLatin1StringView(
"rule")) {
35 qCDebug(MAILCOMMON_LOG) <<
" unknown tag " << tag;
40FilterImporterSylpheed::~FilterImporterSylpheed() =
default;
42QString FilterImporterSylpheed::defaultFiltersSettingsPath()
52 filter->pattern()->setOp(SearchPattern::OpAnd);
54 filter->pattern()->setOp(SearchPattern::OpOr);
56 qCDebug(MAILCOMMON_LOG) <<
" bool not defined: " << attr;
64 const QString nexttag = ruleFilter.tagName();
66 if (ruleFilter.hasAttribute(QStringLiteral(
"name"))) {
67 const QString attr = ruleFilter.attribute(QStringLiteral(
"name"));
75 fieldName =
"reply-to";
77 fieldName =
"subject";
79 fieldName =
"list-id";
81 fieldName =
"x-mailing-list";
84 qCDebug(MAILCOMMON_LOG) <<
" match-header not implemented " << attr;
87 contentsName = ruleFilter.text();
89 fieldName =
"<any header>";
90 contentsName = ruleFilter.text();
92 fieldName =
"<recipients>";
93 contentsName = ruleFilter.text();
96 contentsName = ruleFilter.text();
101 fieldName =
"<size>";
104 fieldName =
"<age in days>";
105 contentsName = ruleFilter.text();
107 fieldName =
"<status>";
108 contentsName = QStringLiteral(
"Unread");
120 qCDebug(MAILCOMMON_LOG) <<
" tag not recognize " << nexttag;
123 qCDebug(MAILCOMMON_LOG) <<
" field not implemented " << nexttag;
126 if (ruleFilter.hasAttribute(QStringLiteral(
"type"))) {
127 const QString attr = ruleFilter.attribute(QStringLiteral(
"type"));
129 functionName = SearchRule::FuncContainsNot;
131 functionName = SearchRule::FuncContains;
133 functionName = SearchRule::FuncNotEqual;
135 functionName = SearchRule::FuncEquals;
137 functionName = SearchRule::FuncNotRegExp;
139 functionName = SearchRule::FuncRegExp;
141 functionName = SearchRule::FuncIsNotInAddressbook;
143 functionName = SearchRule::FuncIsInAddressbook;
145 functionName = SearchRule::FuncIsGreater;
147 functionName = SearchRule::FuncIsLess;
149 qCDebug(MAILCOMMON_LOG) <<
" Attr type not implemented :" << attr;
153 filter->pattern()->append(rule);
161 const QString nexttag = ruleFilter.tagName();
162 QString value = ruleFilter.text();
164 actionName = QStringLiteral(
"transfer");
165 value = ruleFilter.text();
167 actionName = QStringLiteral(
"copy");
168 value = ruleFilter.text();
172 actionName = QStringLiteral(
"delete");
174 actionName = QStringLiteral(
"execute");
175 value = ruleFilter.text();
177 actionName = QStringLiteral(
"filter app");
178 value = ruleFilter.text();
184 actionName = QStringLiteral(
"set status");
185 value = QStringLiteral(
"R");
187 actionName = QStringLiteral(
"forward");
188 value = ruleFilter.text();
192 actionName = QStringLiteral(
"redirect");
193 value = ruleFilter.text();
195 filter->setStopProcessingHere(
true);
200 qCDebug(MAILCOMMON_LOG) <<
" tag not recognize " << nexttag;
202 createFilterAction(filter, actionName, value);
206void FilterImporterSylpheed::parseFilters(
const QDomElement &e)
212 filter->setEnabled(
false);
218 filter->pattern()->setName(attr);
219 filter->setToolbarName(attr);
225 filter->setApplyOnInbound(
true);
226 filter->setApplyOnExplicit(
true);
228 filter->setApplyOnInbound(
true);
230 filter->setApplyOnInbound(
false);
231 filter->setApplyOnExplicit(
true);
233 qCDebug(MAILCOMMON_LOG) <<
" timing not defined: " << attr;
237 const QString nexttag = ruleFilter.tagName();
239 parseConditions(ruleFilter, filter);
241 parseActions(ruleFilter, filter);
243 qCDebug(MAILCOMMON_LOG) <<
" next tag not implemented " << nexttag;
247 appendFilter(filter);
std::shared_ptr< SearchRule > Ptr
Defines a pointer to a search rule.
Function
Describes operators for comparison of field and contents.
static SearchRule::Ptr createInstance(const QByteArray &field=QByteArray(), Function function=FuncContains, const QString &contents=QString())
Creates a new search rule of a certain type by instantiating the appropriate subclass depending on th...
bool isEmpty() const const
QDomElement documentElement() const const
QString attribute(const QString &name, const QString &defValue) const const
bool hasAttribute(const QString &name) const const
QDomElement firstChildElement(const QString &tagName, const QString &namespaceURI) const const
bool isNull() const const
QString arg(Args &&... args) const const
bool isEmpty() const const
QString number(double n, char format, int precision)
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)