aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.cpp29
-rw-r--r--src/config.h22
2 files changed, 51 insertions, 0 deletions
diff --git a/src/config.cpp b/src/config.cpp
index 0f0caf1..0fa3c85 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -158,6 +158,11 @@ QString Account::trashQuery() const
return folderQuery(maildir, trash);
}
+QString Account::spamQuery() const
+{
+ return folderQuery(maildir, spam);
+}
+
QString Account::inboxFolder() const
{
// Never empty: Restore needs a folder to name, and "Inbox" is both the
@@ -192,6 +197,11 @@ QString Config::allTrashQuery() const
return joinAccountQueries(m_accounts, &Account::trashQuery);
}
+QString Config::allSpamQuery() const
+{
+ return joinAccountQueries(m_accounts, &Account::spamQuery);
+}
+
QString Config::defaultPath()
{
const QString base =
@@ -528,6 +538,12 @@ void Config::load(const QString &path)
account.trash =
settings.value(QStringLiteral("trash")).toString().trimmed();
+ // Mandatory, unlike sent: Mark spam moves a file into this folder, so
+ // an account without one cannot mark spam at all. Trimmed for the same
+ // reason as sent, above.
+ account.spam =
+ settings.value(QStringLiteral("spam")).toString().trimmed();
+
// Optional, unlike trash: inboxFolder() defaults it to "Inbox", which
// is right for any ordinary Maildir. Read so an account whose inbox is
// named otherwise can say so, rather than having Restore create a
@@ -585,6 +601,19 @@ void Config::load(const QString &path)
.arg(account.key));
}
+ // Mandatory, unlike sent: Mark spam moves a file into this folder, so
+ // an account without one cannot mark spam at all. Reported rather than
+ // silently disabled, so the user finds out from a warning rather than
+ // from a Mark spam that quietly does nothing. The account still loads;
+ // only Mark spam is unusable.
+ if (account.spam.isEmpty()) {
+ addProblem(
+ tr("Account '%1' has no spam folder configured; add a "
+ "'spam' key to its section. Mark spam will not work for "
+ "this account until it does.")
+ .arg(account.key));
+ }
+
m_accounts.append(account);
}
diff --git a/src/config.h b/src/config.h
index 1ab923d..aa3c332 100644
--- a/src/config.h
+++ b/src/config.h
@@ -80,6 +80,14 @@ struct Account
/// reports a missing key through the warnings path.
QString trash;
+ /// The account's spam folder, relative to maildir.
+ ///
+ /// MANDATORY, unlike `sent` and `drafts`. Mark spam moves a file into this
+ /// folder, so an account without one cannot mark spam at all, and the user
+ /// chose a config error over a per-account disabled state. Config::load()
+ /// reports a missing key through the warnings path.
+ QString spam;
+
/// The command that sends mail from this account, receiving the complete
/// RFC822 message on stdin. Optional, and its ABSENCE is meaningful:
/// an account without one is receive-only by construction.
@@ -160,6 +168,13 @@ struct Account
/// uniformly; it is Config::load() that reports the problem.
QString trashQuery() const;
+ /// Matches this account's spam folder, or empty when `spam` is unset.
+ ///
+ /// Empty is a config error rather than a legitimate state, unlike
+ /// sentQuery(). The query helper still returns empty so callers compose
+ /// uniformly; it is Config::load() that reports the problem.
+ QString spamQuery() const;
+
/// Matches this account's inbox folder, using inboxFolder().
QString inboxQuery() const;
@@ -408,6 +423,13 @@ public:
/// silently answers a different question.
QString allTrashQuery() const;
+ /// Matches every configured account's spam, or empty when none has one.
+ ///
+ /// Joins only the NON-EMPTY spamQuery() results, for the same reason
+ /// allTrashQuery() does: notmuch accepts a bare "or" without complaint and
+ /// silently answers a different question.
+ QString allSpamQuery() const;
+
/// Matches every configured account's drafts, or empty when none has one.
///
/// Joins only the NON-EMPTY draftsQuery() results, for the same reason