[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:19 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=773e776
The following commit has been merged in the master branch:
commit 773e77649b7b9ca74f2f1b9134b1ec4637e8b2ff
Author: Marcin Ziemiński <zieminn at gmail.com>
Date: Wed Jul 23 14:16:58 2014 +0200
Implement OTR message
Signed-off-by: Marcin Ziemiński <zieminn at gmail.com>
---
otr-proxy/KTpProxy/CMakeLists.txt | 1 +
otr-proxy/KTpProxy/otr-handler.h | 10 +-
otr-proxy/KTpProxy/otr-message.cpp | 115 +++++++++++++++++++++
.../KTpProxy/{otr-value-types.h => otr-message.h} | 9 +-
otr-proxy/KTpProxy/otr-session.h | 2 +-
5 files changed, 127 insertions(+), 10 deletions(-)
diff --git a/otr-proxy/KTpProxy/CMakeLists.txt b/otr-proxy/KTpProxy/CMakeLists.txt
index 564135a..6b1b684 100644
--- a/otr-proxy/KTpProxy/CMakeLists.txt
+++ b/otr-proxy/KTpProxy/CMakeLists.txt
@@ -10,6 +10,7 @@ set(ktp-proxy_SRCS
pending-curry-operation.cpp
otr-session.cpp
otr-manager.cpp
+ otr-message.cpp
)
set(ktp-proxy_LIBS
diff --git a/otr-proxy/KTpProxy/otr-handler.h b/otr-proxy/KTpProxy/otr-handler.h
index e8fd9e5..74cb36d 100644
--- a/otr-proxy/KTpProxy/otr-handler.h
+++ b/otr-proxy/KTpProxy/otr-handler.h
@@ -20,7 +20,7 @@
#ifndef KTP_PROXY_OTR_HANDLER_HEADER
#define KTP_PROXY_OTR_HANDLER_HEADER
-#include "otr-value-types.h"
+#include "otr-message.h"
#include <QSharedPointer>
@@ -34,6 +34,14 @@ extern "C" {
namespace OTR
{
+ struct SessionContext
+ {
+ const QString accountId;
+ const QString accountName;
+ const QString recipientName;
+ const QString protocol;
+ };
+
class Handler
{
public:
diff --git a/otr-proxy/KTpProxy/otr-message.cpp b/otr-proxy/KTpProxy/otr-message.cpp
new file mode 100644
index 0000000..8e8be17
--- /dev/null
+++ b/otr-proxy/KTpProxy/otr-message.cpp
@@ -0,0 +1,115 @@
+/***************************************************************************
+ * Copyright (C) 2014 by Marcin Ziemiński <zieminn at gmail.com> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2.1 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#include "otr-message.h"
+
+namespace OTR
+{
+ Message::Message()
+ : dir(MessageDirection::TO_PEER)
+ {
+ message << Tp::MessagePart() << Tp::MessagePart();
+ setType(Tp::ChannelTextMessageTypeNormal);
+ }
+
+ Message::Message(const Tp::MessagePartList &message)
+ : dir(MessageDirection::TO_PEER),
+ message(message)
+ {
+ while(this->message.size() < 2) {
+ this->message << Tp::MessagePart();
+ }
+ if(!this->message[0].contains(QLatin1String("message-type"))) {
+ setType(Tp::ChannelTextMessageTypeNormal);
+ }
+ }
+
+ const Tp::MessagePartList& Message::parts() const
+ {
+ return message;
+ }
+
+ QString Message::text() const
+ {
+ auto it = message[1].find(QLatin1String("content"));
+ if(it == message[1].end()) {
+ return QLatin1String("");
+ } else {
+ return it->variant().toString();
+ }
+ }
+
+ void Message::setText(const QString &text)
+ {
+ message[1].insert(QLatin1String("content-type"),
+ QDBusVariant(QLatin1String("text/plain")));
+ message[1].insert(QLatin1String("content"), QDBusVariant(text));
+ }
+
+ void Message::setType(Tp::ChannelTextMessageType msgType)
+ {
+ message[0].insert(QLatin1String("message-type"), QDBusVariant(msgType));
+ }
+
+ Tp::ChannelTextMessageType Message::type() const
+ {
+ return static_cast<Tp::ChannelTextMessageType>(message[0]["message-type"].variant().toUInt(NULL));
+ }
+
+ MessageDirection Message::direction() const
+ {
+ return dir;
+ }
+
+ void Message::setDirection(MessageDirection direction)
+ {
+ dir = direction;
+ }
+
+ bool Message::isOTRevent() const
+ {
+ return message[0].contains(QLatin1String("otr-message-event"));
+ }
+
+ void Message::setOTRevent(OtrlMessageEvent msgEvent)
+ {
+ message[0].insert(QLatin1String("otr-message-event"), QDBusVariant(static_cast<uint>(msgEvent)));
+ }
+
+ OtrlMessageEvent Message::getOTRevent() const
+ {
+ return static_cast<OtrlMessageEvent>(message[0]["otr-message-event"].variant().toUInt(NULL));
+ }
+
+ void Message::setOTRHeader(const QString &header, const QString &text)
+ {
+ message[0].insert(header, QDBusVariant(text));
+ }
+
+ QString Message::getOTRHeader(const QString &header)
+ {
+ auto it = message[0].find(header);
+ if(it == message[0].end()) {
+ return QLatin1String("");
+ } else {
+ return it->variant().toString();
+ }
+ }
+
+} /* namespace OTR */
diff --git a/otr-proxy/KTpProxy/otr-value-types.h b/otr-proxy/KTpProxy/otr-message.h
similarity index 91%
rename from otr-proxy/KTpProxy/otr-value-types.h
rename to otr-proxy/KTpProxy/otr-message.h
index 7468f2c..ddb95d4 100644
--- a/otr-proxy/KTpProxy/otr-value-types.h
+++ b/otr-proxy/KTpProxy/otr-message.h
@@ -33,13 +33,6 @@ extern "C" {
namespace OTR
{
- struct SessionContext
- {
- const QString accountId;
- const QString accountName;
- const QString recipientName;
- const QString protocol;
- };
class Message
{
@@ -60,7 +53,7 @@ namespace OTR
bool isOTRevent() const;
void setOTRevent(OtrlMessageEvent msgEvent);
- OtrlMessageEvent messageEvent() const;
+ OtrlMessageEvent getOTRevent() const;
void setOTRHeader(const QString &header, const QString &text);
QString getOTRHeader(const QString &header);
diff --git a/otr-proxy/KTpProxy/otr-session.h b/otr-proxy/KTpProxy/otr-session.h
index bf267d3..80d7356 100644
--- a/otr-proxy/KTpProxy/otr-session.h
+++ b/otr-proxy/KTpProxy/otr-session.h
@@ -20,7 +20,7 @@
#ifndef KTP_PROXY_OTR_SESSION_HEADER
#define KTP_PROXY_OTR_SESSION_HEADER
-#include "otr-value-types.h"
+#include "otr-message.h"
#include "otr-constants.h"
#include "otr-handler.h"
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list