[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:21 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=be79cdc

The following commit has been merged in the master branch:
commit be79cdcf4a49fe013ca8ea12ddbba880fce46749
Author: Marcin Ziemiński <zieminn at gmail.com>
Date:   Thu Jul 31 20:09:58 2014 +0200

    Add method to get private key fingerprint for account
    
    Signed-off-by: Marcin Ziemiński <zieminn at gmail.com>
---
 otr-proxy/KTpProxy/otr-manager.cpp           | 17 +++++++++++
 otr-proxy/KTpProxy/otr-manager.h             |  1 +
 otr-proxy/KTpProxy/otr-session.cpp           | 13 +--------
 otr-proxy/KTpProxy/proxy-service-adaptee.cpp | 13 ++++++++-
 otr-proxy/KTpProxy/proxy-service-adaptee.h   |  2 ++
 otr-proxy/KTpProxy/proxy-service.cpp         |  5 ++++
 otr-proxy/KTpProxy/proxy-service.h           |  1 +
 otr-proxy/KTpProxy/svc-proxy-service.cpp     | 15 ++++++++++
 otr-proxy/KTpProxy/svc-proxy-service.h       | 43 ++++++++++++++++++++++------
 otr-proxy/spec/ProxyService.xml              | 21 ++++++++++++++
 10 files changed, 109 insertions(+), 22 deletions(-)

diff --git a/otr-proxy/KTpProxy/otr-manager.cpp b/otr-proxy/KTpProxy/otr-manager.cpp
index b9e4535..0c93eb3 100644
--- a/otr-proxy/KTpProxy/otr-manager.cpp
+++ b/otr-proxy/KTpProxy/otr-manager.cpp
@@ -454,6 +454,23 @@ KeyGenerationThread* Manager::createNewPrivateKey(const QString &accountId, cons
             getUserState(accountId)->userState());
 }
 
+QString Manager::getFingerprintFor(const QString &accountId, const QString &accountName)
+{
+    OtrlUserState userState = getUserState(accountId)->userState();
+    unsigned char ourRawHash[20];
+    unsigned char *res = otrl_privkey_fingerprint_raw(
+            userState,
+            ourRawHash,
+            accountName.toLocal8Bit(),
+            OTR::utils::protocolFromAccountId(accountId).toLocal8Bit());
+
+    if(res == nullptr) {
+        return QLatin1String("");
+    } else {
+        return utils::humanReadable(ourRawHash);
+    }
+}
+
 void Manager::saveFingerprints(Session *session)
 {
     const QString path = config->saveLocation() + session->context().accountId + QLatin1String(".fingerprints");
diff --git a/otr-proxy/KTpProxy/otr-manager.h b/otr-proxy/KTpProxy/otr-manager.h
index cb63986..4259c44 100644
--- a/otr-proxy/KTpProxy/otr-manager.h
+++ b/otr-proxy/KTpProxy/otr-manager.h
@@ -60,6 +60,7 @@ namespace OTR
             /** return nullptr if thread could not be craeted
               otherwise returns thread which generates a new private key upon calling start method */
             KeyGenerationThread* createNewPrivateKey(const QString &accountId, const QString &accountName);
+            QString getFingerprintFor(const QString &accountId, const QString &accountName);
             void createInstag(Session *session);
 
         private:
diff --git a/otr-proxy/KTpProxy/otr-session.cpp b/otr-proxy/KTpProxy/otr-session.cpp
index e5a412e..03f4900 100644
--- a/otr-proxy/KTpProxy/otr-session.cpp
+++ b/otr-proxy/KTpProxy/otr-session.cpp
@@ -124,18 +124,7 @@ namespace OTR
 
     QString Session::localFingerprint() const
     {
-        unsigned char ourRawHash[20];
-        unsigned char *res = otrl_privkey_fingerprint_raw(
-                userstate->userState(),
-                ourRawHash,
-                ctx.accountName.toLocal8Bit(),
-                ctx.protocol.toLocal8Bit());
-
-        if(res == nullptr) {
-            return QLatin1String("");
-        } else {
-            return utils::humanReadable(ourRawHash);
-        }
+        return parent()->getFingerprintFor(ctx.accountId, ctx.accountName);
     }
 
     Message Session::startSession()
diff --git a/otr-proxy/KTpProxy/proxy-service-adaptee.cpp b/otr-proxy/KTpProxy/proxy-service-adaptee.cpp
index c3c21ca..c431db7 100644
--- a/otr-proxy/KTpProxy/proxy-service-adaptee.cpp
+++ b/otr-proxy/KTpProxy/proxy-service-adaptee.cpp
@@ -88,7 +88,7 @@ void ProxyServiceAdaptee::generatePrivateKey(const QDBusObjectPath &accountPath,
         const Tp::Service::ProxyServiceAdaptor::GeneratePrivateKeyContextPtr &context)
 {
     Tp::AccountPtr ac = ps->accountManager()->accountForObjectPath(accountPath.path());
-    if(ac->isValidAccount() &&
+    if(ac && ac->isValidAccount() &&
             ps->createNewPrivateKey(OTR::utils::accountIdFor(accountPath), ac->normalizedName())) {
         context->setFinished();
     } else {
@@ -97,3 +97,14 @@ void ProxyServiceAdaptee::generatePrivateKey(const QDBusObjectPath &accountPath,
                 QLatin1String("Could not generate private key for given account"));
     }
 }
+
+void ProxyServiceAdaptee::getFingerprintForAccount(QDBusObjectPath accountPath,
+        const Tp::Service::ProxyServiceAdaptor::GetFingerprintForAccountContextPtr &context)
+{
+    Tp::AccountPtr ac = ps->accountManager()->accountForObjectPath(accountPath.path());
+    if(ac && ac->isValidAccount()) {
+        context->setFinished(ps->getFingerprintFor(OTR::utils::accountIdFor(accountPath), ac->normalizedName()));
+    } else {
+        context->setFinishedWithError(TP_QT_ERROR_INVALID_ARGUMENT, QLatin1String("No such valid account"));
+    }
+}
diff --git a/otr-proxy/KTpProxy/proxy-service-adaptee.h b/otr-proxy/KTpProxy/proxy-service-adaptee.h
index a18e8d0..1627f50 100644
--- a/otr-proxy/KTpProxy/proxy-service-adaptee.h
+++ b/otr-proxy/KTpProxy/proxy-service-adaptee.h
@@ -58,6 +58,8 @@ class ProxyServiceAdaptee : public QObject
         void onProxyDisconnected(const QDBusObjectPath &proxyPath);
         void generatePrivateKey(const QDBusObjectPath &accountPath,
                 const Tp::Service::ProxyServiceAdaptor::GeneratePrivateKeyContextPtr &context);
+        void getFingerprintForAccount(QDBusObjectPath accountPath,
+                const Tp::Service::ProxyServiceAdaptor::GetFingerprintForAccountContextPtr &context);
     private Q_SLOTS:
         void onKeyGenerationStarted(const QString &accountId);
         void onKeyGenerationFinished(const QString &accountId, bool error);
diff --git a/otr-proxy/KTpProxy/proxy-service.cpp b/otr-proxy/KTpProxy/proxy-service.cpp
index ae0eb89..ac1904c 100644
--- a/otr-proxy/KTpProxy/proxy-service.cpp
+++ b/otr-proxy/KTpProxy/proxy-service.cpp
@@ -196,6 +196,11 @@ bool ProxyService::createNewPrivateKey(const QString &accountId, const QString &
     }
 }
 
+QString ProxyService::getFingerprintFor(const QString &accountId, const QString &accountName)
+{
+    return manager.getFingerprintFor(accountId, accountName);
+}
+
 void ProxyService::onKeyGenerationThreadFinished()
 {
     OTR::KeyGenerationThread *thread = dynamic_cast<OTR::KeyGenerationThread*>(QObject::sender());
diff --git a/otr-proxy/KTpProxy/proxy-service.h b/otr-proxy/KTpProxy/proxy-service.h
index 5cdb72b..324644e 100644
--- a/otr-proxy/KTpProxy/proxy-service.h
+++ b/otr-proxy/KTpProxy/proxy-service.h
@@ -58,6 +58,7 @@ class ProxyService : public Tp::DBusService
 
         /** returns false if key cannot be generated - i.e. incorrect id */
         bool createNewPrivateKey(const QString &accountId, const QString &accountName);
+        QString getFingerprintFor(const QString &accountId, const QString &accountName);
 
         OTR::Manager* managerOTR();
         Tp::AccountManagerPtr accountManager();
diff --git a/otr-proxy/KTpProxy/svc-proxy-service.cpp b/otr-proxy/KTpProxy/svc-proxy-service.cpp
index 0be1c16..999e951 100644
--- a/otr-proxy/KTpProxy/svc-proxy-service.cpp
+++ b/otr-proxy/KTpProxy/svc-proxy-service.cpp
@@ -45,5 +45,20 @@ void ProxyServiceAdaptor::GeneratePrivateKey(const QDBusObjectPath& account, con
         Q_ARG(Tp::Service::ProxyServiceAdaptor::GeneratePrivateKeyContextPtr, ctx));
 }
 
+QString ProxyServiceAdaptor::GetFingerprintForAccount(const QDBusObjectPath& account, const QDBusMessage& dbusMessage)
+{
+    if (!adaptee()->metaObject()->indexOfMethod("getFingerprintForAccount(QDBusObjectPath,Tp::Service::ProxyServiceAdaptor::GetFingerprintForAccountContextPtr)") == -1) {
+        dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")));
+        return QString();
+    }
+
+    GetFingerprintForAccountContextPtr ctx = GetFingerprintForAccountContextPtr(
+            new Tp::MethodInvocationContext< QString >(dbusConnection(), dbusMessage));
+    QMetaObject::invokeMethod(adaptee(), "getFingerprintForAccount",
+        Q_ARG(QDBusObjectPath, account),
+        Q_ARG(Tp::Service::ProxyServiceAdaptor::GetFingerprintForAccountContextPtr, ctx));
+    return QString();
+}
+
 }
 }
diff --git a/otr-proxy/KTpProxy/svc-proxy-service.h b/otr-proxy/KTpProxy/svc-proxy-service.h
index d083ad5..320045e 100644
--- a/otr-proxy/KTpProxy/svc-proxy-service.h
+++ b/otr-proxy/KTpProxy/svc-proxy-service.h
@@ -15,7 +15,6 @@
 #include <QObject>
 #include <QtDBus>
 
-
 namespace Tp
 {
 namespace Service
@@ -38,6 +37,10 @@ class TP_QT_EXPORT ProxyServiceAdaptor : public Tp::AbstractAdaptor
 "    <method name=\"GeneratePrivateKey\">
"
 "      <arg direction=\"in\" type=\"o\" name=\"account\"/>
"
 "    </method>
"
+"    <method name=\"GetFingerprintForAccount\">
"
+"      <arg direction=\"in\" type=\"o\" name=\"account\"/>
"
+"      <arg direction=\"out\" type=\"s\" name=\"fingerprint\"/>
"
+"    </method>
"
 "    <signal name=\"ProxyConnected\">
"
 "      <arg type=\"o\" name=\"proxy\"/>
"
 "    </signal>
"
@@ -60,6 +63,7 @@ public:
     virtual ~ProxyServiceAdaptor();
 
     typedef Tp::MethodInvocationContextPtr<  > GeneratePrivateKeyContextPtr;
+    typedef Tp::MethodInvocationContextPtr< QString > GetFingerprintForAccountContextPtr;
 
 public: // PROPERTIES
     /**
@@ -68,7 +72,7 @@ public: // PROPERTIES
      * Adaptees should export this property as a Qt property named
      * 'policySettings' with type uint.
      *
-     *
+     * 
      * \htmlonly
      * <p>Set the OTR policy how you like it</p>
      * \endhtmlonly
@@ -82,7 +86,7 @@ public: // PROPERTIES
      * Adaptees should export this property as a writable Qt property named
      * 'policySettings' with type uint.
      *
-     *
+     * 
      * \htmlonly
      * <p>Set the OTR policy how you like it</p>
      * \endhtmlonly
@@ -99,13 +103,34 @@ public Q_SLOTS: // METHODS
      * Implementations should call MethodInvocationContext::setFinished (or setFinishedWithError
      * accordingly) on the received  context object once the method has finished processing.
      *
-     *
+     * 
      * \htmlonly
      * <p> Generate new private key for given account. </p>
      * \endhtmlonly
      *
      */
     void GeneratePrivateKey(const QDBusObjectPath& account, const QDBusMessage& dbusMessage);
+    /**
+     * Begins a call to the exported D-Bus method 
-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list