summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2016-11-03 15:34:37 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-11-03 15:34:37 (GMT)
commit1f34e48610033a307856587b10728cc18c98de86 (patch)
treea071f44cd771dc83bb9c02421dcc47f9b968bfd3
parent3d1187f2ea00eacdf0d9ae5bf35488276eef6508 (diff)
Add silent mode to SentBehaviourAttribute
When set to true, the dispatcher agent won't show the Email Sent notification after successfuly sending the email.
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/sentbehaviourattribute.cpp48
-rw-r--r--src/sentbehaviourattribute.h17
3 files changed, 57 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7bbc751..df6e3a8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,7 +21,7 @@ include(ECMQtDeclareLoggingCategory)
add_definitions(-DTRANSLATION_DOMAIN=\"libmailtransport5\")
-set(PIM_VERSION "5.3.41")
+set(PIM_VERSION "5.3.42")
set(KMAILTRANSPORT_LIB_VERSION ${PIM_VERSION})
diff --git a/src/sentbehaviourattribute.cpp b/src/sentbehaviourattribute.cpp
index 5d2e7a7..fb1f594 100644
--- a/src/sentbehaviourattribute.cpp
+++ b/src/sentbehaviourattribute.cpp
@@ -25,15 +25,18 @@ using namespace MailTransport;
class SentBehaviourAttribute::Private
{
public:
- SentBehaviour mBehaviour;
+ SentBehaviourAttribute::SentBehaviour mBehaviour;
Akonadi::Collection mMoveToCollection;
+ bool mSilent;
};
-SentBehaviourAttribute::SentBehaviourAttribute(SentBehaviour beh, const Collection &moveToCollection)
+SentBehaviourAttribute::SentBehaviourAttribute(SentBehaviour beh, const Collection &moveToCollection,
+ bool sendSilently)
: d(new Private)
{
d->mBehaviour = beh;
d->mMoveToCollection = moveToCollection;
+ d->mSilent = sendSilently;
}
SentBehaviourAttribute::~SentBehaviourAttribute()
@@ -54,10 +57,22 @@ QByteArray SentBehaviourAttribute::type() const
QByteArray SentBehaviourAttribute::serialized() const
{
+ QByteArray out;
+
switch (d->mBehaviour) {
- case Delete: return "delete";
- case MoveToCollection: return "moveTo" + QByteArray::number(d->mMoveToCollection.id());
- case MoveToDefaultSentCollection: return "moveToDefault";
+ case Delete:
+ out = "delete";
+ break;
+ case MoveToCollection:
+ out = "moveTo" + QByteArray::number(d->mMoveToCollection.id());
+ break;
+ case MoveToDefaultSentCollection:
+ out = "moveToDefault";
+ break;
+ }
+
+ if (d->mSilent) {
+ out += ",silent";
}
Q_ASSERT(false);
@@ -66,18 +81,25 @@ QByteArray SentBehaviourAttribute::serialized() const
void SentBehaviourAttribute::deserialize(const QByteArray &data)
{
+ const QByteArrayList in = data.split(',');
+ Q_ASSERT(in.size() > 0);
+
d->mMoveToCollection = Akonadi::Collection(-1);
- if (data == "delete") {
+ if (in[0] == "delete") {
d->mBehaviour = Delete;
- } else if (data == "moveToDefault") {
+ } else if (in[0] == "moveToDefault") {
d->mBehaviour = MoveToDefaultSentCollection;
- } else if (data.startsWith(QByteArray("moveTo"))) {
+ } else if (in[0].startsWith(QByteArray("moveTo"))) {
d->mBehaviour = MoveToCollection;
d->mMoveToCollection = Akonadi::Collection(data.mid(6).toLongLong());
// NOTE: 6 is the strlen of "moveTo".
} else {
Q_ASSERT(false);
}
+
+ if (in.size() == 2 && in[1] == "silent") {
+ d->mSilent = true;
+ }
}
SentBehaviourAttribute::SentBehaviour SentBehaviourAttribute::sentBehaviour() const
@@ -100,3 +122,13 @@ void SentBehaviourAttribute::setMoveToCollection(const Collection &moveToCollect
d->mMoveToCollection = moveToCollection;
}
+bool SentBehaviourAttribute::sendSilently() const
+{
+ return d->mSilent;
+}
+
+void SentBehaviourAttribute::setSendSilently(bool sendSilently)
+{
+ d->mSilent = sendSilently;
+}
+
diff --git a/src/sentbehaviourattribute.h b/src/sentbehaviourattribute.h
index 42d4f1a..76e9b2b 100644
--- a/src/sentbehaviourattribute.h
+++ b/src/sentbehaviourattribute.h
@@ -52,7 +52,8 @@ public:
Creates a new SentBehaviourAttribute.
*/
explicit SentBehaviourAttribute(SentBehaviour beh = MoveToDefaultSentCollection,
- const Akonadi::Collection &moveToCollection = Akonadi::Collection(-1));
+ const Akonadi::Collection &moveToCollection = Akonadi::Collection(-1),
+ bool sendSilently = false);
/**
Destroys the SentBehaviourAttribute.
@@ -92,6 +93,20 @@ public:
*/
void setMoveToCollection(const Akonadi::Collection &moveToCollection);
+ /**
+ * Returns whether a notification should be shown after the email is sent.
+ * @since 5.4
+ */
+ bool sendSilently() const;
+
+ /**
+ * Set whether a notification should be shown after the email is sent.
+ *
+ * Default is false.
+ *
+ * @since 5.4
+ */
+ void setSendSilently(bool sendSilently);
private:
class Private;
Private *const d;