7#include "filterimportergmail.h"
8#include "filter/mailfilter.h"
9#include "mailcommon_debug.h"
11#include <QDomDocument>
16FilterImporterGmail::FilterImporterGmail(
QFile *file)
17 : FilterImporterAbstract()
20 if (!loadDomElement(doc, file)) {
27 qCDebug(MAILCOMMON_LOG) <<
"No filters defined";
31 const QString tag = e.tagName();
32 if (tag == QLatin1StringView(
"entry")) {
33 qCDebug(MAILCOMMON_LOG) <<
" filter found !";
39FilterImporterGmail::~FilterImporterGmail() =
default;
41QString FilterImporterGmail::defaultFiltersSettingsPath()
46QString FilterImporterGmail::createUniqFilterName()
48 return i18n(
"Gmail filter %1", ++mFilterCount);
51void FilterImporterGmail::parseFilters(
const QDomElement &e)
53 auto filter =
new MailCommon::MailFilter();
54 filter->setAutoNaming(
true);
55 const QString uniqName = createUniqFilterName();
56 filter->pattern()->setName(uniqName);
57 filter->setToolbarName(uniqName);
60 for (QDomElement ruleFilter = e.
firstChildElement(); !ruleFilter.
isNull(); ruleFilter = ruleFilter.nextSiblingElement()) {
61 const QString tagName = ruleFilter.tagName();
62 if (tagName == QLatin1StringView(
"category")) {
63 if (ruleFilter.hasAttribute(QStringLiteral(
"term"))) {
64 if (ruleFilter.attribute(QStringLiteral(
"term")) != QLatin1StringView(
"filter")) {
68 }
else if (tagName == QLatin1StringView(
"apps:property")) {
69 if (ruleFilter.hasAttribute(QStringLiteral(
"name"))) {
70 const QString criteriaProperty = ruleFilter.attribute(QStringLiteral(
"name"));
71 qCDebug(MAILCOMMON_LOG) <<
" ruleFilter.attribute" << criteriaProperty;
73 if (criteriaProperty == QLatin1StringView(
"from")) {
75 }
else if (criteriaProperty == QLatin1StringView(
"to")) {
77 }
else if (criteriaProperty == QLatin1StringView(
"subject")) {
78 fieldName =
"subject";
79 }
else if (criteriaProperty == QLatin1StringView(
"hasTheWord")) {
80 }
else if (criteriaProperty == QLatin1StringView(
"doesNotHaveTheWord")) {
81 }
else if (criteriaProperty == QLatin1StringView(
"hasAttachment")) {
85 else if (criteriaProperty == QLatin1StringView(
"shouldArchive")) {
86 }
else if (criteriaProperty == QLatin1StringView(
"shouldMarkAsRead")) {
87 }
else if (criteriaProperty == QLatin1StringView(
"shouldStar")) {
88 }
else if (criteriaProperty == QLatin1StringView(
"label")) {
89 }
else if (criteriaProperty == QLatin1StringView(
"forwardTo")) {
90 }
else if (criteriaProperty == QLatin1StringView(
"shouldTrash")) {
91 }
else if (criteriaProperty == QLatin1StringView(
"neverSpam")) {
93 qCDebug(MAILCOMMON_LOG) <<
" unknown item " << criteriaProperty;
QString i18n(const char *text, const TYPE &arg...)
QDomElement documentElement() const const
QDomElement firstChildElement(const QString &tagName, const QString &namespaceURI) const const
bool isNull() const const
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)