summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-31 19:43:24 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-31 19:43:24 (GMT)
commit93c937e8313e87fe1f7538d4e891ed5b566b1068 (patch)
tree3b2fee69bfaf2572e23e417ca26495aa3ff8ef25
parentce1d6dbdd89d60b7afe03e32ff2f01f6d5006297 (diff)
Add method to renamescript + check script.
But too bad no all server support it :( So I need to reimplement by hand
-rw-r--r--src/kmanagesieve/sessionthread.cpp1
-rw-r--r--src/kmanagesieve/sievejob.cpp20
-rw-r--r--src/kmanagesieve/sievejob.h7
3 files changed, 26 insertions, 2 deletions
diff --git a/src/kmanagesieve/sessionthread.cpp b/src/kmanagesieve/sessionthread.cpp
index 081d1d8..3a228bd 100644
--- a/src/kmanagesieve/sessionthread.cpp
+++ b/src/kmanagesieve/sessionthread.cpp
@@ -167,7 +167,6 @@ void SessionThread::doSendData(const QByteArray &data)
void SessionThread::slotDataReceived()
{
Q_ASSERT(QThread::currentThread() == thread());
-
if (m_pendingQuantity > 0) {
const QByteArray buffer = m_socket->read(qMin(m_pendingQuantity, m_socket->bytesAvailable()));
m_data += buffer;
diff --git a/src/kmanagesieve/sievejob.cpp b/src/kmanagesieve/sievejob.cpp
index 118dea4..3906415 100644
--- a/src/kmanagesieve/sievejob.cpp
+++ b/src/kmanagesieve/sievejob.cpp
@@ -102,7 +102,11 @@ void SieveJob::Private::run(Session *session)
break;
}
case Check: {
- //TODO
+ const QString filename = mUrl.fileName(/*QUrl::ObeyTrailingSlash*/);
+ QByteArray encodedData;
+ append_lf2crlf(encodedData, mScript.toUtf8());
+ session->sendData("RENAMESCRIPT {" + QByteArray::number(encodedData.size()) + "+}");
+ session->sendData(encodedData);
break;
}
@@ -368,6 +372,20 @@ SieveJob *SieveJob::rename(const QUrl &url, const QString &newName)
return job;
}
+SieveJob *SieveJob::check(const QUrl &url, const QString &script)
+{
+ QStack<Private::Command> commands;
+ commands.push(Private::Check);
+
+ SieveJob *job = new SieveJob;
+ job->d->mUrl = url;
+ job->d->mScript = script;
+ 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 0fc77da..8b44e69 100644
--- a/src/kmanagesieve/sievejob.h
+++ b/src/kmanagesieve/sievejob.h
@@ -87,10 +87,17 @@ public:
/**
* Rename the script with the given sieve @p url and new name @p newName.
+ * Not supported by all sieve server
*/
static SieveJob *rename(const QUrl &url, const QString &newName);
/**
+ * Check the script with the given sieve @p url.
+ * Not supported by all sieve server
+ */
+ static SieveJob *check(const QUrl &url, const QString &script);
+
+ /**
* Kills the sieve job.
*/
void kill(KJob::KillVerbosity verbosity = KJob::Quietly);