7#include "generateglobalscriptjob.h"
9#include "kmanagesieve/sievejob.h"
11#include <KLocalizedString>
13using namespace KSieveCore;
14GenerateGlobalScriptJob::GenerateGlobalScriptJob(
const QUrl &url,
QObject *parent)
20GenerateGlobalScriptJob::~GenerateGlobalScriptJob()
25void GenerateGlobalScriptJob::kill()
39void GenerateGlobalScriptJob::addUserActiveScripts(
const QStringList &lstScript)
41 mListUserActiveScripts = lstScript;
44void GenerateGlobalScriptJob::setForceActivateUserScript(
bool f)
46 mForceActivateUserScript = f;
49void GenerateGlobalScriptJob::start()
59void GenerateGlobalScriptJob::writeMasterScript()
61 const QString masterScript = QStringLiteral(
64 "# This file is authoritative for your system and MUST BE KEPT ACTIVE.\n"
66 "# Altering it is likely to render your account dysfunctional and may\n"
67 "# be violating your organizational or corporate policies.\n"
69 "# For more information on the mechanism and the conventions behind\n"
70 "# this script, see http://wiki.kolab.org/KEP:14\n"
73 "require [\"include\"];\n"
75 "# OPTIONAL: Includes for all or a group of users\n"
76 "# include :global \"all-users\";\n"
77 "# include :global \"this-group-of-users\";\n"
79 "# The script maintained by the general management system\n"
80 "include :personal :optional \"MANAGEMENT\";\n"
82 "# The script(s) maintained by one or more editors available to the user\n"
83 "include :personal :optional \"USER\";\n");
85 QUrl url(mCurrentUrl);
96 i18n(
"Error writing \"MASTER\" script on server.\n"
97 "The server responded:\n%1",
101 mMasterJob =
nullptr;
105void GenerateGlobalScriptJob::writeUserScript()
107 QString userScript = QStringLiteral(
108 "# USER Management Script\n"
110 "# This script includes the various active sieve scripts\n"
111 "# it is AUTOMATICALLY GENERATED. DO NOT EDIT MANUALLY!\n"
113 "# For more information, see http://wiki.kolab.org/KEP:14#USER\n"
116 "require [\"include\"];\n");
118 for (
const QString &activeScript : std::as_const(mListUserActiveScripts)) {
119 userScript += QStringLiteral(
"\ninclude :personal \"%1\";").
arg(activeScript);
122 QUrl url(mCurrentUrl);
134 i18n(
"Error writing \"User\" script on server.\n"
135 "The server responded:\n%1",
139 disableAllOtherScripts();
142void GenerateGlobalScriptJob::disableAllOtherScripts()
148#include "moc_generateglobalscriptjob.cpp"
A job to manage sieve scripts.
void kill(KJob::KillVerbosity verbosity=KJob::Quietly)
Kills the sieve job.
QString errorString() const
A human-readable error message.
void result(KManageSieve::SieveJob *job, bool success, const QString &script, bool active)
This signal is emitted for all kind of jobs when they have finished.
static SieveJob * put(const QUrl &destination, const QString &script, bool makeActive, bool wasActive)
Stores a sieve script on an IMAP server.
QString i18n(const char *text, const TYPE &arg...)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString arg(Args &&... args) const const
bool isEmpty() const const