summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-31 12:37:45 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-31 12:37:45 (GMT)
commite9d264720e630e12df6f9bdc8be84c888224a2fd (patch)
tree81aad468f7e023c8b9b52bb04c5fd76ceb74524d
parent50b38658ce59f577b1f2c321b71ecd05ace7bc87 (diff)
Add job for renaming script
-rw-r--r--src/kmanagesieve/sievejob.cpp20
-rw-r--r--src/kmanagesieve/sievejob.h5
-rw-r--r--src/kmanagesieve/sievejob_p.h4
3 files changed, 28 insertions, 1 deletions
diff --git a/src/kmanagesieve/sievejob.cpp b/src/kmanagesieve/sievejob.cpp
index d8e7680..29e111e 100644
--- a/src/kmanagesieve/sievejob.cpp
+++ b/src/kmanagesieve/sievejob.cpp
@@ -95,6 +95,12 @@ void SieveJob::Private::run(Session *session)
session->sendData("DELETESCRIPT \"" + filename.toUtf8() + "\"");
break;
}
+ case Rename: {
+ const QString filename = mUrl.fileName(/*QUrl::ObeyTrailingSlash*/);
+ session->sendData("RENAMESCRIPT \"" + filename.toUtf8() + "\" \"" + mNewName.toUtf8() + "\"");
+ break;
+ }
+
default:
Q_ASSERT(false);
}
@@ -344,6 +350,20 @@ SieveJob *SieveJob::deactivate(const QUrl &url)
return job;
}
+SieveJob *SieveJob::rename(const QUrl &url, const QString &newName)
+{
+ QStack<Private::Command> commands;
+ commands.push(Private::Rename);
+
+ SieveJob *job = new SieveJob;
+ job->d->mUrl = url;
+ job->d->mNewName = newName;
+ job->d->mCommands = commands;
+
+ Private::sessionForUrl(url)->scheduleJob(job);
+ return job;
+}
+
SieveJob *SieveJob::activate(const QUrl &url)
{
QStack<Private::Command> commands;
diff --git a/src/kmanagesieve/sievejob.h b/src/kmanagesieve/sievejob.h
index 4b161e4..0fc77da 100644
--- a/src/kmanagesieve/sievejob.h
+++ b/src/kmanagesieve/sievejob.h
@@ -86,6 +86,11 @@ public:
static SieveJob *deactivate(const QUrl &url);
/**
+ * Rename the script with the given sieve @p url and new name @p newName.
+ */
+ static SieveJob *rename(const QUrl &url, const QString &newName);
+
+ /**
* Kills the sieve job.
*/
void kill(KJob::KillVerbosity verbosity = KJob::Quietly);
diff --git a/src/kmanagesieve/sievejob_p.h b/src/kmanagesieve/sievejob_p.h
index 6bd397e..b9c0ca2 100644
--- a/src/kmanagesieve/sievejob_p.h
+++ b/src/kmanagesieve/sievejob_p.h
@@ -39,7 +39,8 @@ public:
Deactivate,
SearchActive,
List,
- Delete
+ Delete,
+ Rename
};
enum Existence {
@@ -59,6 +60,7 @@ public:
QString mScript;
QString mActiveScriptName;
QString mErrorMessage;
+ QString mNewName;
QStack<Command> mCommands;
// List of Sieve scripts on the server, used by @ref list()