[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=546902e

The following commit has been merged in the master branch:
commit 546902eeec276b5e8369120906171301c3483209
Author: Marcin Ziemiński <zieminn at gmail.com>
Date:   Tue Jul 22 19:53:20 2014 +0200

    Implemented some OTR ops functions
    
    Signed-off-by: Marcin Ziemiński <zieminn at gmail.com>
---
 otr-proxy/CMakeLists.txt                           |   3 +-
 .../KTpProxy/{otr-message.h => otr-constants.h}    |  25 +-
 otr-proxy/KTpProxy/otr-handler.h                   |  40 ++-
 otr-proxy/KTpProxy/otr-manager.cpp                 | 274 +++++++++++++++++++--
 otr-proxy/KTpProxy/otr-manager.h                   |   7 +-
 otr-proxy/KTpProxy/otr-session.cpp                 |   7 +-
 otr-proxy/KTpProxy/otr-session.h                   |  14 +-
 .../KTpProxy/{otr-handler.h => otr-value-types.h}  |  60 +++--
 8 files changed, 344 insertions(+), 86 deletions(-)

diff --git a/otr-proxy/CMakeLists.txt b/otr-proxy/CMakeLists.txt
index 1f03a56..b5e0c19 100644
--- a/otr-proxy/CMakeLists.txt
+++ b/otr-proxy/CMakeLists.txt
@@ -3,7 +3,7 @@ set(KTP_PROXY_VERSION "0.1.1")
 
 set(KDE_MIN_VERSION "4.13.1")
 
-set(CMAKE_MODULE_PATH 
+set(CMAKE_MODULE_PATH
     "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
     ${CMAKE_MODULE_PATH}
 )
@@ -11,7 +11,6 @@ set(CMAKE_MODULE_PATH
 find_package (KDE4 ${KDE_MIN_VERSION} REQUIRED)
 find_package (TelepathyQt4 0.9.1 REQUIRED)
 find_package (TelepathyQt4Service 0.9.2.1 REQUIRED)
-find_package (TelepathyQt4Service 0.9.2.1 REQUIRED)
 find_package (LibOTR 4.0.0 REQUIRED)
 
 include_directories (${KDE4_INCLUDES}
diff --git a/otr-proxy/KTpProxy/otr-message.h b/otr-proxy/KTpProxy/otr-constants.h
similarity index 76%
rename from otr-proxy/KTpProxy/otr-message.h
rename to otr-proxy/KTpProxy/otr-constants.h
index 9c79926..24724f9 100644
--- a/otr-proxy/KTpProxy/otr-message.h
+++ b/otr-proxy/KTpProxy/otr-constants.h
@@ -17,19 +17,30 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-#ifndef KTP_PROXY_OTR_MESSAGE_HEADER
-#define KTP_PROXY_OTR_MESSAGE_HEADER
-
-#include <TelepathyQt/Message>
+#ifndef KTP_PROXY_OTR_CONSTANTS_HEADER
+#define KTP_PROXY_OTR_CONSTANTS_HEADER
 
 namespace OTR
 {
-    class Message
+    enum class TrustLevel : unsigned int
     {
+        NOT_PRIVATE = 0,
+        UNVERIFIED  = 1,
+        VERIFIED    = 2,
+        FINISHED    = 3
+    };
 
-        private:
-            Tp::MessagePartList message;
+    enum class MessageDirection : unsigned int
+    {
+        TO_PEER,
+        FROM_PEER,
+        INTERNAL
     };
+
+    template <typename T> unsigned int toUInt(T &&t)
+    {
+        return static_cast<unsigned int>(t);
+    }
 }
 
 #endif
diff --git a/otr-proxy/KTpProxy/otr-handler.h b/otr-proxy/KTpProxy/otr-handler.h
index 4a669ee..e8fd9e5 100644
--- a/otr-proxy/KTpProxy/otr-handler.h
+++ b/otr-proxy/KTpProxy/otr-handler.h
@@ -20,47 +20,41 @@
 #ifndef KTP_PROXY_OTR_HANDLER_HEADER
 #define KTP_PROXY_OTR_HANDLER_HEADER
 
-#include "otr-message.h"
+#include "otr-value-types.h"
 
 #include <QSharedPointer>
 
+extern "C" {
+#include <gcrypt.h>
+#include <libotr/privkey.h>
+#include <libotr/proto.h>
+#include <libotr/message.h>
+#include <libotr/userstate.h>
+}
+
 namespace OTR
 {
-    struct SessionContext
-    {
-        const QString accountId;
-        const QString accountName;
-        const QString recipientName;
-        const QString protocol;
-    };
-
-    class Handler : public QObject
+    class Handler
     {
-        Q_OBJECT
-
         public:
             virtual ~Handler();
             virtual const SessionContext& context() const = 0;
 
-            virtual void injectMessage(const Message &message) = 0;
-            virtual void handleSmpEvent() = 0;
-            virtual void handleMsgEvent() = 0;
-            virtual void handleError() = 0;
+            virtual void sendMessage(const Message &message) = 0;
+            virtual void handleSmpEvent(OtrlSMPEvent smpEvent) = 0;
             /**
              * State of the recipient
              * 1 - logged in
              * 0 - not logged in
              * -1 - not sure if logged in
              */
-            virtual int recipientStatus() = 0;
-            virtual void goneSecure() = 0;
-            virtual void goneInsecure() = 0;
-
-        Q_SIGNALS:
-            void invalidated(SessionContext *context);
+            virtual int recipientStatus() const = 0;
+            virtual unsigned int maxMessageSize() const = 0;
 
+            virtual void onTrustLevelChanged(TrustLevel trustLevel) = 0;
+            virtual void onSessionRefreshed() = 0;
+            virtual void onNewFingeprintReceived(const QString &fingeprint) = 0;
     };
-
     typedef QSharedPointer<Handler> HandlerPtr;
 }
 
diff --git a/otr-proxy/KTpProxy/otr-manager.cpp b/otr-proxy/KTpProxy/otr-manager.cpp
index 1c6f5f3..70242b3 100644
--- a/otr-proxy/KTpProxy/otr-manager.cpp
+++ b/otr-proxy/KTpProxy/otr-manager.cpp
@@ -18,21 +18,39 @@
  ***************************************************************************/
 
 #include "otr-manager.h"
-#include "otr-session.h"
-
-extern "C" {
-#include <gcrypt.h>
-#include <libotr/privkey.h>
-#include <libotr/proto.h>
-#include <libotr/message.h>
-#include <libotr/userstate.h>
-}
 
 namespace OTR
 {
 
 namespace {
 
+    void updateTrustLevel(Session *session, ConnContext *context)
+    {
+        if(context == NULL) return;
+
+        TrustLevel level;
+        switch(context->msgstate) {
+            case OTRL_MSGSTATE_PLAINTEXT:
+                level = TrustLevel::NOT_PRIVATE;
+                break;
+            case OTRL_MSGSTATE_ENCRYPTED:
+                {
+                    if(otrl_context_is_fingerprint_trusted(context->active_fingerprint)) {
+                        level = TrustLevel::UNVERIFIED;
+                    } else {
+                        level = TrustLevel::VERIFIED;
+                    }
+                    break;
+                }
+            case OTRL_MSGSTATE_FINISHED:
+                level = TrustLevel::FINISHED;
+                break;
+        }
+
+        session->setTrustLevel(level);
+        session->handler()->onTrustLevelChanged(level);
+    }
+
     /** OTR ops functions ------------------------------------------------------------------------- */
     OtrlPolicy policy(void *opdata, ConnContext *context)
     {
@@ -60,91 +78,283 @@ namespace {
     void inject_message(void *opdata, const char *accountname,
             const char *protocol, const char *recipient, const char *message)
     {
+        Q_UNUSED(accountname);
+        Q_UNUSED(protocol);
+        Q_UNUSED(recipient);
+
+        Message msg;
+        msg.setText(QString::fromLocal8Bit(message));
+        msg.setType(Tp::ChannelTextMessageTypeNormal);
+        msg.setDirection(MessageDirection::TO_PEER);
 
+        Session *session = reinterpret_cast<Session*>(opdata);
+        session->handler()->sendMessage(msg);
     }
 
     void update_context_list(void *opdata)
     {
-
+        Q_UNUSED(opdata);
+        // FIXME - all changes in state are caught gone_secure/gone_insecure
     }
 
     void new_fingerprint(void *opdata, OtrlUserState us,
             const char *accountname, const char *protocol,
             const char *username, unsigned char fingerprint[20])
     {
+        Q_UNUSED(us);
+        Q_UNUSED(accountname);
+        Q_UNUSED(protocol);
+        Q_UNUSED(username);
 
+        char human[OTRL_PRIVKEY_FPRINT_HUMAN_LEN];
+        otrl_privkey_hash_to_human(human, fingerprint);
+
+        Session *session = reinterpret_cast<Session*>(opdata);
+        session->handler()->onNewFingeprintReceived(QString::fromLocal8Bit(human, OTRL_PRIVKEY_FPRINT_HUMAN_LEN));
     }
 
     void write_fingerprints(void *opdata)
     {
-
+        Session *session = reinterpret_cast<Session*>(opdata);
+        session->parent()->saveFingerprints(session);
     }
 
     void gone_secure(void *opdata, ConnContext *context)
     {
-
+        Session *session = reinterpret_cast<Session*>(opdata);
+        updateTrustLevel(session, context);
     }
 
     void gone_insecure(void *opdata, ConnContext *context)
     {
-
+        Session *session = reinterpret_cast<Session*>(opdata);
+        updateTrustLevel(session, context);
     }
 
     void still_secure(void *opdata, ConnContext *context, int is_reply)
     {
+        Q_UNUSED(context);
+        Q_UNUSED(is_reply);
 
+        Session *session = reinterpret_cast<Session*>(opdata);
+        session->handler()->onSessionRefreshed();
     }
 
     int max_message_size(void *opdata, ConnContext *context)
     {
-        return 0;
+        Q_UNUSED(context);
+
+        Session *session = reinterpret_cast<Session*>(opdata);
+        return session->handler()->maxMessageSize();
     }
 
     const char* otr_error_message(void *opdata, ConnContext *context,
             OtrlErrorCode err_code)
     {
-        return 0;
+        Q_UNUSED(opdata);
+
+        char *err_msg = 0;
+        switch (err_code)
+        {
+            case OTRL_ERRCODE_NONE :
+                break;
+            case OTRL_ERRCODE_ENCRYPTION_ERROR : 
+                {
+                    QString message = QLatin1String("Error occurred encrypting message.");
+                    err_msg = new char[message.length() + 1];
+                    err_msg[message.length()] = 0;
+                    memcpy(err_msg, message.toUtf8().data(), message.length());
+                    break;
+                }
+            case OTRL_ERRCODE_MSG_NOT_IN_PRIVATE :
+                if (context) {
+                    QString message = QString::fromLatin1("You sent encrypted data to %1, who wasn't expecting it.").
+                        arg(QLatin1String(context->accountname));
+                    err_msg = new char[message.length() + 1];
+                    err_msg[message.length()] = 0;
+                    memcpy(err_msg, message.toUtf8().data(), message.length());
+                }
+                break;
+            case OTRL_ERRCODE_MSG_UNREADABLE : 
+                {
+                    QString message = QLatin1String("You transmitted an unreadable encrypted message.");
+                    err_msg = new char[message.length() + 1];
+                    err_msg[message.length()] = 0;
+                    memcpy(err_msg, message.toUtf8().data(), message.length());
+                    break;
+                }
+            case OTRL_ERRCODE_MSG_MALFORMED : 
+                {
+                    QString message = QLatin1String("You transmitted a malformed data message.");
+                    err_msg = new char[message.length() + 1];
+                    err_msg[message.length()] = 0;
+                    memcpy(err_msg, message.toUtf8().data(), message.length());
+                    break;
+                }
+        }
+
+        return err_msg;
     }
 
     void otr_error_message_free(void *opdata, const char *err_msg)
     {
+        Q_UNUSED(opdata);
 
+        if(err_msg) {
+            delete [] const_cast<char*>(err_msg);
+        }
     }
 
     const char* resent_msg_prefix(void *opdata, ConnContext *context)
     {
-        return 0;
+        Q_UNUSED(opdata);
+        Q_UNUSED(context);
+
+        return "[resent]";
     }
 
     void resent_msg_prefix_free(void *opdata, const char *prefix)
     {
+        Q_UNUSED(opdata);
+        Q_UNUSED(prefix);
 
+        return;
     }
 
     void handle_smp_event(void *opdata, OtrlSMPEvent smp_event,
             ConnContext *context, unsigned short progress_percent,
             char *question)
     {
-
+        Q_UNUSED(opdata);
+        Q_UNUSED(smp_event);
+        Q_UNUSED(context);
+        Q_UNUSED(progress_percent);
+        Q_UNUSED(question);
+        // TODO
     }
 
     void handle_msg_event(void *opdata, OtrlMessageEvent msg_event,
             ConnContext *context, const char *message,
             gcry_error_t err)
     {
+        Message msg;
+        msg.setType(Tp::ChannelTextMessageTypeNotice);
+        msg.setOTRevent(msg_event);
+
+        switch (msg_event)
+        {
+            case OTRL_MSGEVENT_NONE:
+                return;
+            case OTRL_MSGEVENT_ENCRYPTION_REQUIRED:
+                msg.setText(QString::fromLatin1("You attempted to send an unencrypted message to %1.")
+                        .arg(QLatin1String(context->username)));
+                msg.setDirection(MessageDirection::INTERNAL);
+                break;
+            case OTRL_MSGEVENT_ENCRYPTION_ERROR:
+                msg.setText(QString::fromLatin1("An error occurred when encrypting your message. "
+                            "The message was not sent."));
+                msg.setDirection(MessageDirection::INTERNAL);
+                break;
+            case OTRL_MSGEVENT_CONNECTION_ENDED:
+                msg.setText(QString::fromLatin1("%1 has already closed his/her private connection to you. "
+                            "Your message was not sent. "
+                            "Either end your private conversation, or restart it.")
+                        .arg(QLatin1String(context->username)));
+                msg.setDirection(MessageDirection::INTERNAL);
+                break;
+            case OTRL_MSGEVENT_SETUP_ERROR:
+                if(!err) {
+                    err = GPG_ERR_INV_VALUE;
+                }
+                switch (gcry_err_code(err))
+                {
+                    case GPG_ERR_INV_VALUE:
+                        {
+                            msg.setOTRHeader(QLatin1String("otr-error"), QLatin1String("Malformed message received"));
+                            msg.setText(QLatin1String("Error setting up private conversation: "
+                                        "Malformed message received"));
+                            break;
+                        }
+                    default:
+                        {
+                            msg.setOTRHeader(QLatin1String("otr-error"), QLatin1String(gcry_strerror(err)));
+                            msg.setText(QString::fromLatin1("Error setting up private conversation: %1")
+                                    .arg(QLatin1String(gcry_strerror(err))));
+                            break;
+                        }
+                }
+                msg.setDirection(MessageDirection::INTERNAL);
+                break;
+            case OTRL_MSGEVENT_MSG_REFLECTED:
+                msg.setText(QLatin1String("We are receiving our own OTR messages. "
+                            "You are either trying to talk to yourself, "
+                            "or someone is reflecting your messages back at you."));
+                msg.setDirection(MessageDirection::INTERNAL);
+                break;
+            case OTRL_MSGEVENT_MSG_RESENT:
+                msg.setText(QString::fromLatin1("The last message to %1 was resent.")
+                        .arg(QLatin1String(context->username)));
+                msg.setDirection(MessageDirection::INTERNAL);
+                break;
+            case OTRL_MSGEVENT_RCVDMSG_NOT_IN_PRIVATE:
+                msg.setText(QString::fromLatin1("The encrypted message received from %1 is unreadable, "
+                            "as you are not currently communicating privately.")
+                        .arg(QLatin1String(context->username)));
+                msg.setDirection(MessageDirection::FROM_PEER);
+                break;
+            case OTRL_MSGEVENT_RCVDMSG_UNREADABLE:
+                msg.setText(QString::fromLatin1("We received an unreadable encrypted message from %1.")
+                        .arg(QLatin1String(context->username)));
+                msg.setDirection(MessageDirection::INTERNAL);
+                break;
+            case OTRL_MSGEVENT_RCVDMSG_MALFORMED:
+                msg.setText(QString::fromLatin1("We received a malformed data message from %1.")
+                        .arg(QLatin1String(context->username)));
+                msg.setDirection(MessageDirection::INTERNAL);
+                break;
+            case OTRL_MSGEVENT_LOG_HEARTBEAT_RCVD:
+                return;
+            case OTRL_MSGEVENT_LOG_HEARTBEAT_SENT:
+                break;
+            case OTRL_MSGEVENT_RCVDMSG_GENERAL_ERR:
+                msg.setOTRHeader(QLatin1String("otr-error"), QLatin1String(message));
+                msg.setText(QString::fromLatin1("OTR error: %1").arg(QLatin1String(message)));
+                msg.setDirection(MessageDirection::INTERNAL);
+                break;
+            case OTRL_MSGEVENT_RCVDMSG_UNENCRYPTED:
+                msg.setOTRHeader(QLatin1String("otr-unencrypted-message"), QLatin1String(message));
+                msg.setText(QString::fromLatin1("The following message received from %1 was not encrypted: [%2]")
+                        .arg(QLatin1String(context->username), QLatin1String(message)));
+                msg.setDirection(MessageDirection::FROM_PEER);
+                break;
+            case OTRL_MSGEVENT_RCVDMSG_UNRECOGNIZED:
+                break;
+            case OTRL_MSGEVENT_RCVDMSG_FOR_OTHER_INSTANCE:
+                msg.setText(QString::fromLatin1("%1 has sent an encrypted message intended for a different session. "
+                            "If you are logged in multiple times, another session may have received the message.")
+                        .arg(QLatin1String(context->username)));
+                msg.setDirection(MessageDirection::FROM_PEER);
+                break;
+        }
 
+        Session *session = reinterpret_cast<Session*>(opdata);
+        session->handler()->sendMessage(msg);
     }
 
     void create_instag(void *opdata, const char *accountname,
             const char *protocol)
     {
+        Q_UNUSED(accountname);
+        Q_UNUSED(protocol);
 
+        Session *session = reinterpret_cast<Session*>(opdata);
+        session->parent()->createInstag(session);
     }
 
     void timer_control(void *opdata, unsigned int interval)
     {
         Session *session = reinterpret_cast<Session*>(opdata);
-        session->userState()->setInterval(interval);
+        session->userStateBox()->setInterval(interval);
     }
 
     /** OTR ops struct ---------------------------------------------------------------------------- */
@@ -180,9 +390,8 @@ namespace {
 
 /** Manager implementation -------------------------------------------------------------------- */
 Manager::Manager(Config *otrConfig)
-    : config(config)
+    : config(otrConfig)
 {
-
 }
 
 SessionPtr Manager::createSession(const HandlerPtr &handler)
@@ -209,4 +418,29 @@ SessionPtr Manager::createSession(const HandlerPtr &handler)
     }
 }
 
+OtrlPolicy Manager::getPolicy() const
+{
+    return config->getPolicy();
+}
+
+void Manager::setPolicy(OtrlPolicy policy)
+{
+    config->setPolicy(policy);
+}
+
+void Manager::saveFingerprints(Session *session)
+{
+    const QString path = config->saveLocation() + session->handler()->context().accountId + QLatin1String("_fingerprints");
+	otrl_privkey_write_fingerprints(session->userStateBox()->userState(), path.toLocal8Bit());
+}
+
+void Manager::createInstag(Session *session)
+{
+    const QString path = config->saveLocation() + session->handler()->context().accountId + QLatin1String("_instags");
+	otrl_instag_generate(session->userStateBox()->userState(), 
+            path.toLocal8Bit(), 
+            session->handler()->context().accountName.toLocal8Bit(), 
+            session->handler()->context().protocol.toLocal8Bit());
+}
+
 } /* namespace OTR */
diff --git a/otr-proxy/KTpProxy/otr-manager.h b/otr-proxy/KTpProxy/otr-manager.h
index 1d54f90..7628f44 100644
--- a/otr-proxy/KTpProxy/otr-manager.h
+++ b/otr-proxy/KTpProxy/otr-manager.h
@@ -21,10 +21,12 @@
 #define KTP_PROXY_OTR_MANAGER_HEADER
 
 #include "otr-config.h"
-#include "otr-session.h"
 #include "otr-handler.h"
+#include "otr-session.h"
 
 extern "C" {
+#include <gcrypt.h>
+#include <libotr/privkey.h>
 #include <libotr/proto.h>
 #include <libotr/message.h>
 #include <libotr/userstate.h>
@@ -44,6 +46,9 @@ namespace OTR
             OtrlPolicy getPolicy() const;
             void setPolicy(OtrlPolicy policy);
 
+            void saveFingerprints(Session *session);
+            void createInstag(Session *session);
+
         private:
             Config *config;
             // TODO - consider clearing states when not in use
diff --git a/otr-proxy/KTpProxy/otr-session.cpp b/otr-proxy/KTpProxy/otr-session.cpp
index 98bd632..827b342 100644
--- a/otr-proxy/KTpProxy/otr-session.cpp
+++ b/otr-proxy/KTpProxy/otr-session.cpp
@@ -41,6 +41,11 @@ namespace OTR
         otrl_userstate_free(us);
     }
 
+    OtrlUserState UserStateBox::userState()
+    {
+        return us;
+    }
+
     void UserStateBox::setInterval(uint interval)
     {
         if(interval) {
@@ -67,7 +72,7 @@ namespace OTR
         return hd;
     }
 
-    UserStateBox* Session::userState()
+    UserStateBox* Session::userStateBox()
     {
         return userstate;
     }
diff --git a/otr-proxy/KTpProxy/otr-session.h b/otr-proxy/KTpProxy/otr-session.h
index 2a46181..bf267d3 100644
--- a/otr-proxy/KTpProxy/otr-session.h
+++ b/otr-proxy/KTpProxy/otr-session.h
@@ -20,7 +20,8 @@
 #ifndef KTP_PROXY_OTR_SESSION_HEADER
 #define KTP_PROXY_OTR_SESSION_HEADER
 
-#include "otr-message.h"
+#include "otr-value-types.h"
+#include "otr-constants.h"
 #include "otr-handler.h"
 
 #include <QString>
@@ -45,6 +46,7 @@ namespace OTR
             OtrlUserState userState();
             /** if zero timer is stopped */
             void setInterval(uint interval);
+            QString remoteFingerprint() const;
 
         private Q_SLOTS:
             void otrlMessagePoll();
@@ -53,7 +55,6 @@ namespace OTR
             OtrlUserState us;
             QTimer periodicTimer;
     };
-
     typedef QSharedPointer<UserStateBox> UserStateBoxPtr;
 
     class Session : public QObject
@@ -64,13 +65,15 @@ namespace OTR
             Session(const HandlerPtr &handler, UserStateBox *userstate, Manager *parent);
 
             const HandlerPtr& handler();
-            UserStateBox* userState();
+            UserStateBox* userStateBox();
             Manager* parent();
+            TrustLevel trustLevel() const;
+            void setTrustLevel(TrustLevel level);
 
             void startSession();
             void stopSession();
-            void encrypt();
-            void decrypt();
+            void encrypt(Message &message);
+            void decrypt(Message &message);
             void verifyFingerprint();
             void initSMPQuery();
             void initSMPSecret();
@@ -80,7 +83,6 @@ namespace OTR
             UserStateBox *userstate;
             Manager *pr;
     };
-
     typedef QSharedPointer<Session> SessionPtr;
 
 } /* namespace OTR */
diff --git a/otr-proxy/KTpProxy/otr-handler.h b/otr-proxy/KTpProxy/otr-value-types.h
similarity index 59%
copy from otr-proxy/KTpProxy/otr-handler.h
copy to otr-proxy/KTpProxy/otr-value-types.h
index 4a669ee..7468f2c 100644
--- a/otr-proxy/KTpProxy/otr-handler.h
+++ b/otr-proxy/KTpProxy/otr-value-types.h
@@ -17,12 +17,19 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-#ifndef KTP_PROXY_OTR_HANDLER_HEADER
-#define KTP_PROXY_OTR_HANDLER_HEADER
+#ifndef KTP_PROXY_OTR_VALUE_TYPES_HEADER
+#define KTP_PROXY_OTR_VALUE_TYPES_HEADER
 
-#include "otr-message.h"
+#include "otr-constants.h"
 
-#include <QSharedPointer>
+#include <TelepathyQt/Message>
+
+extern "C" {
+#include <libotr/privkey.h>
+#include <libotr/proto.h>
+#include <libotr/message.h>
+#include <libotr/userstate.h>
+}
 
 namespace OTR
 {
@@ -34,34 +41,35 @@ namespace OTR
         const QString protocol;
     };
 
-    class Handler : public QObject
+    class Message
     {
-        Q_OBJECT
-
         public:
-            virtual ~Handler();
-            virtual const SessionContext& context() const = 0;
+            Message();
+            Message(const Tp::MessagePartList &message);
+
+            const Tp::MessagePartList& parts() const;
 
-            virtual void injectMessage(const Message &message) = 0;
-            virtual void handleSmpEvent() = 0;
-            virtual void handleMsgEvent() = 0;
-            virtual void handleError() = 0;
-            /**
-             * State of the recipient
-             * 1 - logged in
-             * 0 - not logged in
-             * -1 - not sure if logged in
-             */
-            virtual int recipientStatus() = 0;
-            virtual void goneSecure() = 0;
-            virtual void goneInsecure() = 0;
+            QString text() const;
+            void setText(const QString &text);
 
-        Q_SIGNALS:
-            void invalidated(SessionContext *context);
+            void setType(Tp::ChannelTextMessageType msgType);
+            Tp::ChannelTextMessageType type() const;
 
+            MessageDirection direction() const;
+            void setDirection(MessageDirection direction);
+
+            bool isOTRevent() const;
+            void setOTRevent(OtrlMessageEvent msgEvent);
+            OtrlMessageEvent messageEvent() const;
+
+            void setOTRHeader(const QString &header, const QString &text);
+            QString getOTRHeader(const QString &header);
+
+        private:
+            MessageDirection dir;
+            Tp::MessagePartList message;
     };
 
-    typedef QSharedPointer<Handler> HandlerPtr;
-}
+} /* namespace OTR */
 
 #endif

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list