[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:24:42 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=c76714a

The following commit has been merged in the master branch:
commit c76714a65c9b73894bd8c9b26610efc71bd31fc5
Author: Marcin Ziemiński <zieminn at gmail.com>
Date:   Thu Jul 31 21:26:45 2014 +0200

    Add buddy authentication through manual fingerprint verification.
    Fixed bug with wrong initialization of OTR trust level.
---
 lib/channel-adapter.cpp |  33 +++++++++++++
 lib/channel-adapter.h   |   3 ++
 lib/chat-widget.cpp     |  26 ++++++++++-
 lib/proxy-service.cpp   |   2 +
 lib/proxy-service.h     | 122 +++++++++++++++++++++++++++++++++++++++++++++++-
 5 files changed, 184 insertions(+), 2 deletions(-)

diff --git a/lib/channel-adapter.cpp b/lib/channel-adapter.cpp
index 237dbaf..c2f5d32 100644
--- a/lib/channel-adapter.cpp
+++ b/lib/channel-adapter.cpp
@@ -56,6 +56,7 @@ struct ChannelAdapter::Private
 
     bool otrConnected;
     Tp::OTRTrustLevel trustLevel;
+    QString remoteFp;
 
     QMap<uint, OTRMessage> messages;
 };
@@ -172,6 +173,9 @@ void ChannelAdapter::setupOTRChannel()
     // initialize trust level property
     connect(d->otrProxy->requestPropertyTrustLevel(), SIGNAL(finished(Tp::PendingOperation*)),
             SLOT(onTrustLevelPropertyGet(Tp::PendingOperation*)));
+    // initialize remote fingerprint property
+    connect(d->otrProxy->requestPropertyRemoteFingerprint(), SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(onRemoteFingerprintPropertyGet(Tp::PendingOperation*)));
 }
 
 Tp::OTRTrustLevel ChannelAdapter::otrTrustLevel() const
@@ -187,6 +191,7 @@ void ChannelAdapter::onTrustLevelPropertyGet(Tp::PendingOperation *op)
     }
     Tp::PendingVariant *pv = dynamic_cast<Tp::PendingVariant*>(op);
     d->trustLevel = static_cast<Tp::OTRTrustLevel>(pv->result().toUInt(NULL));
+    Q_EMIT otrTrustLevelChanged(d->trustLevel, Tp::OTRTrustLevelNotPrivate);
 }
 
 bool ChannelAdapter::isOTRsuppored() const
@@ -206,6 +211,16 @@ void ChannelAdapter::stopOTR()
     d->otrProxy->Stop();
 }
 
+QString ChannelAdapter::remoteFingerprint() const
+{
+    return d->remoteFp;
+}
+
+QDBusPendingReply<> ChannelAdapter::trustFingerprint(const QString &fingerprint, bool trust)
+{
+    return d->otrProxy->TrustFingerprint(fingerprint, trust);
+}
+
 void ChannelAdapter::acknowledge(const QList<Tp::ReceivedMessage> &messages)
 {
     if(messages.isEmpty()) {
@@ -306,6 +321,19 @@ void ChannelAdapter::onPendingMessagesPropertyGet(Tp::PendingOperation *op)
     }
 }
 
+void ChannelAdapter::onRemoteFingerprintPropertyGet(Tp::PendingOperation *op)
+{
+    kDebug();
+    Tp::PendingVariant *variant = dynamic_cast<Tp::PendingVariant*>(op);
+
+    if(!variant->isError()) {
+        d->remoteFp = variant->result().toString();
+    } else {
+        kWarning() << "Could not get remote fingerprint: " << variant->errorName() << " - "
+            << variant->errorMessage();
+    }
+}
+
 void ChannelAdapter::onPendingMessagesRemoved(const Tp::UIntList &messageIDs)
 {
     kDebug();
@@ -332,6 +360,11 @@ void ChannelAdapter::onTrustLevelChanged(uint trustLevel)
 {
     Tp::OTRTrustLevel oldLevel = d->trustLevel;
     d->trustLevel = static_cast<Tp::OTRTrustLevel>(trustLevel);
+    // get remote's fingerprint
+    if(oldLevel == Tp::OTRTrustLevelNotPrivate) {
+        connect(d->otrProxy->requestPropertyRemoteFingerprint(), SIGNAL(finished(Tp::PendingOperation*)),
+                SLOT(onRemoteFingerprintPropertyGet(Tp::PendingOperation*)));
+    }
 
     Q_EMIT otrTrustLevelChanged(d->trustLevel, oldLevel);
 }
diff --git a/lib/channel-adapter.h b/lib/channel-adapter.h
index 33af748..8b8d53a 100644
--- a/lib/channel-adapter.h
+++ b/lib/channel-adapter.h
@@ -43,6 +43,8 @@ class ChannelAdapter : public QObject
 
         Tp::OTRTrustLevel otrTrustLevel() const;
         bool isOTRsuppored() const;
+        QString remoteFingerprint() const;
+        QDBusPendingReply<> trustFingerprint(const QString &fingerprint, bool trust);
 
         bool isValid() const;
 
@@ -70,6 +72,7 @@ class ChannelAdapter : public QObject
     private Q_SLOTS:
         void onTrustLevelPropertyGet(Tp::PendingOperation *op);
         void onPendingMessagesPropertyGet(Tp::PendingOperation *op);
+        void onRemoteFingerprintPropertyGet(Tp::PendingOperation *op);
         void onMessageReceived(const Tp::MessagePartList &message);
         void onPendingMessagesRemoved(const Tp::UIntList &messageIDs);
         void onMessageSent(const Tp::MessagePartList &content, uint flags, const QString &messageToken);
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index 5bb2280..8bb6d20 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -674,7 +674,31 @@ void ChatWidget::stopOtrSession()
 void ChatWidget::authenticateBuddy()
 {
     if(!d->channel.isOTRsuppored()) return;
-    // TODO use adapter
+    // TODO add smp
+    const QString fingerprint = d->channel.remoteFingerprint();
+
+    QString question = i18n("Is the following fingerprint for the contact %1 correct?
%2",
+            d->contactName, fingerprint);
+
+    int askResult = KMessageBox::questionYesNoCancel(this, question);
+    QDBusPendingReply<> result;
+    switch(askResult) {
+        case KMessageBox::Yes:
+            result = d->channel.trustFingerprint(fingerprint, true);
+            break;
+        case KMessageBox::No:
+            result = d->channel.trustFingerprint(fingerprint, false);
+            break;
+        default:
+            return;
+    }
+
+    result.waitForFinished();
+    if(result.isError()) {
+        kWarning() << "Could not set fingerprint trusted because of: " << result.error().name()
+            << " -> " << result.error().message();
+        KMessageBox::error(this, i18n("%1", result.error().message()));
+    }
 }
 
 void ChatWidget::setupOTR()
diff --git a/lib/proxy-service.cpp b/lib/proxy-service.cpp
index cc97f09..470818b 100644
--- a/lib/proxy-service.cpp
+++ b/lib/proxy-service.cpp
@@ -36,6 +36,8 @@ void ProxyServiceInterface::invalidate(Tp::DBusProxy *proxy,
 {
     disconnect(this, SIGNAL(ProxyConnected(const QDBusObjectPath&)), NULL, NULL);
     disconnect(this, SIGNAL(ProxyDisconnected(const QDBusObjectPath&)), NULL, NULL);
+    disconnect(this, SIGNAL(KeyGenerationStarted(const QDBusObjectPath&)), NULL, NULL);
+    disconnect(this, SIGNAL(KeyGenerationFinished(const QDBusObjectPath&, bool)), NULL, NULL);
 
     Tp::AbstractInterface::invalidate(proxy, error, message);
 }
diff --git a/lib/proxy-service.h b/lib/proxy-service.h
index 46942da..b447ce0 100644
--- a/lib/proxy-service.h
+++ b/lib/proxy-service.h
@@ -22,6 +22,7 @@
 #include <TelepathyQt/DBusProxy>
 #include <TelepathyQt/Global>
 
+
 namespace Tp
 {
 class PendingVariant;
@@ -111,6 +112,38 @@ public:
     ProxyServiceInterface(const Tp::AbstractInterface& mainInterface, QObject* parent);
 
     /**
+     * Asynchronous getter for the remote object property 
-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list