Commit b03ec1c2 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix export rules

parent bec8a4ae
Pipeline #53017 canceled with stage
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(PIM_VERSION "5.16.49")
set(PIM_VERSION "5.16.50")
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
......
......@@ -102,12 +102,12 @@ int DKIMManagerRules::importRules(const QString &fileName)
return loadRules(fileName);
}
void DKIMManagerRules::exportRules(const QString &fileName)
void DKIMManagerRules::exportRules(const QString &fileName, const QVector<DKIMRule> &lst)
{
save(fileName);
}
void DKIMManagerRules::save(const QString &fileName)
void DKIMManagerRules::save(const QString &fileName, const QVector<DKIMRule> &lst)
{
const KSharedConfig::Ptr &config =
KSharedConfig::openConfig(fileName.isEmpty() ? MessageViewer::DKIMUtil::defaultConfigFileName() : fileName, KConfig::NoGlobals);
......@@ -116,10 +116,14 @@ void DKIMManagerRules::save(const QString &fileName)
for (const QString &group : rulesGroups) {
config->deleteGroup(group);
}
for (int i = 0, total = mRules.count(); i < total; ++i) {
QVector<DKIMRule> rules = lst;
if (lst.isEmpty()) {
rules = mRules;
}
for (int i = 0, total = rules.count(); i < total; ++i) {
const QString groupName = QStringLiteral("DKIM Rule #%1").arg(i);
KConfigGroup group = config->group(groupName);
const DKIMRule &rule = mRules.at(i);
const DKIMRule &rule = rules.at(i);
group.writeEntry(QStringLiteral("SignedDomainIdentifier"), rule.signedDomainIdentifier());
group.writeEntry(QStringLiteral("From"), rule.from());
......
......@@ -35,13 +35,13 @@ public:
void clear();
Q_REQUIRED_RESULT int importRules(const QString &fileName);
void exportRules(const QString &fileName);
void exportRules(const QString &fileName, const QVector<DKIMRule> &lst = {});
Q_REQUIRED_RESULT bool isEmpty() const;
private:
Q_REQUIRED_RESULT int loadRules(const QString &fileName = QString());
void save(const QString &fileName = QString());
void save(const QString &fileName = QString(), const QVector<DKIMRule> &lst = {});
Q_REQUIRED_RESULT QStringList ruleGroups(const KSharedConfig::Ptr &config) const;
QVector<DKIMRule> mRules;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment