[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9
Maximiliano Curia
maxy at moszumanska.debian.org
Mon May 9 09:08:23 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=2d75a48
The following commit has been merged in the master branch:
commit 2d75a488799e0c3aaf804c225ab9555c9cf29e37
Author: Marcin Ziemiński <zieminn at gmail.com>
Date: Thu Aug 14 17:24:45 2014 +0200
Handle different message content types
Signed-off-by: Marcin Ziemiński <zieminn at gmail.com>
---
otr-proxy/KTpProxy/otr-message.cpp | 15 ++++++++++++---
otr-proxy/KTpProxy/otr-message.h | 3 ++-
otr-proxy/KTpProxy/otr-session.cpp | 12 ++++++++++--
otr-proxy/test/otr-test.cpp | 21 +++++++++++++++++++++
4 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/otr-proxy/KTpProxy/otr-message.cpp b/otr-proxy/KTpProxy/otr-message.cpp
index ca5f980..e1ddf5b 100644
--- a/otr-proxy/KTpProxy/otr-message.cpp
+++ b/otr-proxy/KTpProxy/otr-message.cpp
@@ -55,14 +55,23 @@ namespace OTR
}
}
- void Message::setText(const QString &text)
+ void Message::setText(const QString &text, const QString &contentType)
{
- // FIXME - using only text/plan content-type, what about html?
message[1].insert(QLatin1String("content-type"),
- QDBusVariant(QLatin1String("text/plain")));
+ QDBusVariant(contentType));
message[1].insert(QLatin1String("content"), QDBusVariant(text));
}
+ QString Message::contentType() const
+ {
+ auto it = message[1].find(QLatin1String("content-type"));
+ if(it == message[1].end()) {
+ return QLatin1String("");
+ } else {
+ return it->variant().toString();
+ }
+ }
+
void Message::setType(Tp::ChannelTextMessageType msgType)
{
message[0].insert(QLatin1String("message-type"), QDBusVariant(msgType));
diff --git a/otr-proxy/KTpProxy/otr-message.h b/otr-proxy/KTpProxy/otr-message.h
index ae363d4..cd46f07 100644
--- a/otr-proxy/KTpProxy/otr-message.h
+++ b/otr-proxy/KTpProxy/otr-message.h
@@ -43,7 +43,8 @@ namespace OTR
const Tp::MessagePartList& parts() const;
QString text() const;
- void setText(const QString &text);
+ void setText(const QString &text, const QString &contentType = QLatin1String("text/plain"));
+ QString contentType() const;
void setType(Tp::ChannelTextMessageType msgType);
Tp::ChannelTextMessageType type() const;
diff --git a/otr-proxy/KTpProxy/otr-session.cpp b/otr-proxy/KTpProxy/otr-session.cpp
index 3a61eae..11113f8 100644
--- a/otr-proxy/KTpProxy/otr-session.cpp
+++ b/otr-proxy/KTpProxy/otr-session.cpp
@@ -205,7 +205,11 @@ namespace OTR
return CryptResult::ERROR;
} else if(encMessage != nullptr) {
- message.setText(QString(encMessage));
+ if(message.contentType().isEmpty()) {
+ message.setText(QLatin1String(encMessage));
+ } else {
+ message.setText(QLatin1String(encMessage), message.contentType());
+ }
message.setType(Tp::ChannelTextMessageTypeNormal);
if(context->active_fingerprint != nullptr) {
const QString hrFingerprint = OTR::utils::humanReadable(context->active_fingerprint->fingerprint);
@@ -248,7 +252,11 @@ namespace OTR
if(!ignore) {
if(decMsg != nullptr) {
- message.setText(QString(decMsg));
+ if(message.contentType().isEmpty()) {
+ message.setText(QLatin1String(decMsg));
+ } else {
+ message.setText(QLatin1String(decMsg), message.contentType());
+ }
if(context->active_fingerprint != nullptr) {
const QString hrFingerprint = OTR::utils::humanReadable(context->active_fingerprint->fingerprint);
message.setOTRheader(QLatin1String("otr-remote-fingerprint"), hrFingerprint);
diff --git a/otr-proxy/test/otr-test.cpp b/otr-proxy/test/otr-test.cpp
index 78dd693..3e326ff 100644
--- a/otr-proxy/test/otr-test.cpp
+++ b/otr-proxy/test/otr-test.cpp
@@ -189,6 +189,7 @@ class OTRTest : public QObject
void testSMPSecretFailDistrust();
void testSMPQueryAborted();
void testFingerprintManagement();
+ void testDiffrentContentTypes();
void cleanup();
@@ -917,6 +918,26 @@ void OTRTest::testFingerprintManagement()
QVERIFY(infoList.isEmpty());
}
+void OTRTest::testDiffrentContentTypes()
+{
+ TestSession &alice = aliceEnv->ses;
+ TestSession &bob = bobEnv->ses;
+
+ startSession(alice, bob);
+
+ Message helloMsg;
+ const QString helloText = QLatin1String("No witej chopie!");
+ const QString contentType = QLatin1String("text/html");
+ helloMsg.setText(helloText, contentType);
+ QCOMPARE(bob.encrypt(helloMsg), CryptResult::CHANGED);
+ QVERIFY(bob.eventQueue.empty());
+
+ QCOMPARE(alice.decrypt(helloMsg), CryptResult::CHANGED);
+ QVERIFY(alice.eventQueue.empty());
+ QCOMPARE(helloMsg.text(), helloText);
+ QCOMPARE(helloMsg.contentType(), contentType);
+}
+
void OTRTest::cleanup()
{
delete aliceEnv;
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list