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

Add job for renaming script

parent 50b38658
......@@ -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;
......
......@@ -85,6 +85,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.
*/
......
......@@ -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()
......
Supports Markdown
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