[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:27:20 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=42b927b

The following commit has been merged in the master branch:
commit 42b927bcab99c33bcf245796f897789107017823
Author: Samoilenko Yuri <kinnalru at gmail.com>
Date:   Wed Jan 29 02:22:59 2014 +0400

    hard experiments..
---
 plasmoid/declarativeplugin/CMakeLists.txt          |   8 ++
 .../kdeconnectdeclarativeplugin.cpp                |  59 +++-------
 .../kdeconnectdeclarativeplugin.h                  |  50 ---------
 plasmoid/declarativeplugin/objectfactory.h         |  46 ++++++++
 plasmoid/declarativeplugin/responsewaiter.cpp      | 123 +++++++++++++++++++++
 plasmoid/declarativeplugin/responsewaiter.h        |  70 ++++++++++++
 plasmoid/package/contents/ui/DeviceDelegate.qml    |  23 +++-
 7 files changed, 277 insertions(+), 102 deletions(-)

diff --git a/plasmoid/declarativeplugin/CMakeLists.txt b/plasmoid/declarativeplugin/CMakeLists.txt
index 9e5f10a..3b7b5d6 100644
--- a/plasmoid/declarativeplugin/CMakeLists.txt
+++ b/plasmoid/declarativeplugin/CMakeLists.txt
@@ -2,11 +2,19 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}
                     ${CMAKE_CURRENT_SOURCE_DIR}
                     ${CMAKE_SOURCE_DIR}
                     ${CMAKE_BINARY_DIR})
+
 set(kdeconnectdeclarativeplugin_SRC
     batteryinterface.cpp
     kdeconnectdeclarativeplugin.cpp
+    responsewaiter.cpp
+)
+
+set(kdeconnectdeclarativeplugin_MOC
+  objectfactory.h
 )
 
+qt4_wrap_cpp(kdeconnectdeclarativeplugin_SRC ${kdeconnectdeclarativeplugin_MOC})    
+
 kde4_add_library(kdeconnectdeclarativeplugin SHARED ${kdeconnectdeclarativeplugin_SRC})
 add_dependencies(kdeconnectdeclarativeplugin libkdeconnect)
 target_link_libraries(kdeconnectdeclarativeplugin
diff --git a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
index 0391650..4038c9e 100644
--- a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
+++ b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.cpp
@@ -26,83 +26,50 @@
 #include <QDBusPendingCall>
 #include <QDBusPendingReply>
 
+#include "objectfactory.h"
+#include "responsewaiter.h"
+
 #include "libkdeconnect/devicesmodel.h"
 #include "libkdeconnect/notificationsmodel.h"
 #include "batteryinterface.h"
 
 Q_EXPORT_PLUGIN2(kdeconnectdeclarativeplugin, KdeConnectDeclarativePlugin);
 
-// Q_DECLARE_METATYPE(QDBusPendingCall)
-
-Q_DECLARE_METATYPE(QDBusPendingReply<>)
-Q_DECLARE_METATYPE(QDBusPendingReply<QVariant>)
-Q_DECLARE_METATYPE(QDBusPendingReply<bool>)
-Q_DECLARE_METATYPE(QDBusPendingReply<QString>)
-
 QObject* createSftpInterface(QVariant deviceId)
 {
     return new SftpDbusInterface(deviceId.toString());
 }
 
-const QDBusPendingCall* extractPendingCall(QVariant& variant)
-{
-    if (variant.canConvert<QDBusPendingReply<> >())
-    {}
-    else if (variant.canConvert<QDBusPendingReply<QVariant> >())
-    {}
-    else if (variant.canConvert<QDBusPendingReply<bool> >())
-    {}
-    else if (variant.canConvert<QDBusPendingReply<QString> >())
-    {}
-    else
-    {
-        return 0;
-    }
-    
-    return reinterpret_cast<const QDBusPendingCall*>(variant.constData());
-}
+QDeclarativeEngine* engine_;
 
-QVariant DBusResponseWaiter::waitForReply(QVariant variant) const
+QObject* createDBusResponse()
 {
-    if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(extractPendingCall(variant)))
-    {
-        call->waitForFinished();
-        QDBusMessage reply = call->reply();
-
-        if (reply.arguments().count() > 0)
-        {
-            qDebug() <<reply.arguments().first(); 
-            return reply.arguments().first();
-        }
-        else
-        {
-            return QVariant();
-        }
-    }
-    return QVariant();
+    return new DBusResponse(engine_);
 }
 
 void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
 {
     Q_UNUSED(uri);
     
-    qRegisterMetaType<QDBusPendingReply<> >("QDBusPendingReply<>");
-    qRegisterMetaType<QDBusPendingReply<QVariant> >("QDBusPendingReply<QVariant>");
-    qRegisterMetaType<QDBusPendingReply<bool> >("QDBusPendingReply<bool>");
-    qRegisterMetaType<QDBusPendingReply<QString> >("QDBusPendingReply<QString>");
-
     qmlRegisterType<DevicesModel>("org.kde.kdeconnect", 1, 0, "DevicesModel");
     qmlRegisterType<NotificationsModel>("org.kde.kdeconnect", 1, 0, "NotificationsModel");
     qmlRegisterType<BatteryInterface>("org.kde.kdeconnect", 1, 0, "BatteryInterface");
+    
+    qmlRegisterType<DBusResponse>("org.kde.kdeconnect", 1, 0, "DBusResponse");
 }
 
 void KdeConnectDeclarativePlugin::initializeEngine(QDeclarativeEngine* engine, const char* uri)
 {
+    engine_ = engine;
     QDeclarativeExtensionPlugin::initializeEngine(engine, uri);
     
     engine->rootContext()->setContextProperty("SftpDbusInterfaceFactory"
       , new ObjectFactory(engine, createSftpInterface));
     
+    
+    engine->rootContext()->setContextProperty("DBusResponseFactory"
+      , new ObjectFactory(engine, createDBusResponse));    
+    
     engine->rootContext()->setContextProperty("ResponseWaiter"
       , new DBusResponseWaiter());    
 }
diff --git a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.h b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.h
index 3589fe7..6324b7a 100644
--- a/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.h
+++ b/plasmoid/declarativeplugin/kdeconnectdeclarativeplugin.h
@@ -21,58 +21,8 @@
 #ifndef ANALITZADECLARATIVEPLUGIN_H
 #define ANALITZADECLARATIVEPLUGIN_H
 
-#include <QVariant>
 #include <QDeclarativeExtensionPlugin>
 
-class DBusResponseWaiter : public QObject
-{
-    Q_OBJECT
-public:
-    DBusResponseWaiter() {}
-    
-    virtual ~DBusResponseWaiter(){};
-    
-    Q_INVOKABLE QVariant waitForReply(QVariant variant) const;
-};
-
-
-class ObjectFactory : public QObject
-{
-    Q_OBJECT
-    
-    typedef QObject* (*Func0)();
-    typedef QObject* (*Func1)(QVariant);
-    typedef QObject* (*Func2)(QVariant, QVariant);
-    
-public:
-    ObjectFactory(QObject* parent, Func0 f0) : QObject(parent), m_f0(f0), m_f1(0), m_f2(0) {}
-    ObjectFactory(QObject* parent, Func1 f1) : QObject(parent), m_f0(0), m_f1(f1), m_f2(0) {}
-    ObjectFactory(QObject* parent, Func2 f2) : QObject(parent), m_f0(0), m_f1(0), m_f2(f2) {}
-    
-    virtual ~ObjectFactory() {};
-    
-    
-    Q_INVOKABLE QObject* create() {
-        if (m_f0) return m_f0(); return 0;
-    }
-    
-    Q_INVOKABLE QObject* create(QVariant arg1) {
-        if (m_f1) return m_f1(arg1);
-        return 0;
-    }
-    
-    Q_INVOKABLE QObject* create(QVariant arg1, QVariant arg2) {
-        if (m_f2) return m_f2(arg1, arg2);
-        return 0;
-    }
-    
-private:
-    Func0 m_f0;
-    Func1 m_f1;
-    Func2 m_f2;
-};
-
-
 class KdeConnectDeclarativePlugin : public QDeclarativeExtensionPlugin
 {
     virtual void registerTypes(const char* uri);
diff --git a/plasmoid/declarativeplugin/objectfactory.h b/plasmoid/declarativeplugin/objectfactory.h
new file mode 100644
index 0000000..a574203
--- /dev/null
+++ b/plasmoid/declarativeplugin/objectfactory.h
@@ -0,0 +1,46 @@
+#ifndef QOBJECT_FACTORY_H
+#define QOBJECT_FACTORY_H
+
+#include <QObject>
+#include <QVariant>
+
+//Wraps a factory function with QObject class to be exposed to qml context as named factory
+
+class ObjectFactory : public QObject
+{
+    Q_OBJECT
+    
+    typedef QObject* (*Func0)();
+    typedef QObject* (*Func1)(QVariant);
+    typedef QObject* (*Func2)(QVariant, QVariant);
+    
+public:
+    ObjectFactory(QObject* parent, Func0 f0) : QObject(parent), m_f0(f0), m_f1(0), m_f2(0) {}
+    ObjectFactory(QObject* parent, Func1 f1) : QObject(parent), m_f0(0), m_f1(f1), m_f2(0) {}
+    ObjectFactory(QObject* parent, Func2 f2) : QObject(parent), m_f0(0), m_f1(0), m_f2(f2) {}
+    
+    virtual ~ObjectFactory() {};
+    
+    
+    Q_INVOKABLE QObject* create() {
+        if (m_f0) return m_f0(); return 0;
+    }
+    
+    Q_INVOKABLE QObject* create(QVariant arg1) {
+        if (m_f1) return m_f1(arg1);
+        return 0;
+    }
+    
+    Q_INVOKABLE QObject* create(QVariant arg1, QVariant arg2) {
+        if (m_f2) return m_f2(arg1, arg2);
+        return 0;
+    }
+    
+private:
+    Func0 m_f0;
+    Func1 m_f1;
+    Func2 m_f2;
+};
+
+
+#endif
diff --git a/plasmoid/declarativeplugin/responsewaiter.cpp b/plasmoid/declarativeplugin/responsewaiter.cpp
new file mode 100644
index 0000000..e86d41b
--- /dev/null
+++ b/plasmoid/declarativeplugin/responsewaiter.cpp
@@ -0,0 +1,123 @@
+
+#include <QDBusPendingCall>
+#include <QDBusPendingReply>
+#include <QDebug>
+#include <QCoreApplication>
+#include <qdeclarativeexpression.h>
+#include <QDeclarativeEngine>
+
+#include "responsewaiter.h"
+
+Q_DECLARE_METATYPE(QDBusPendingReply<>)
+Q_DECLARE_METATYPE(QDBusPendingReply<QVariant>)
+Q_DECLARE_METATYPE(QDBusPendingReply<bool>)
+Q_DECLARE_METATYPE(QDBusPendingReply<int>)
+Q_DECLARE_METATYPE(QDBusPendingReply<QString>)
+
+//Q_DECLARE_METATYPE(DBusResponseWaiter::onComplete)
+//Q_DECLARE_METATYPE(DBusResponseWaiter::onError)
+
+DBusResponseWaiter::DBusResponseWaiter()
+    : QObject()
+{
+    m_registered
+        << qRegisterMetaType<QDBusPendingReply<> >("QDBusPendingReply<>")
+        << qRegisterMetaType<QDBusPendingReply<QVariant> >("QDBusPendingReply<QVariant>")
+        << qRegisterMetaType<QDBusPendingReply<bool> >("QDBusPendingReply<bool>")
+        << qRegisterMetaType<QDBusPendingReply<int> >("QDBusPendingReply<int>")      
+        << qRegisterMetaType<QDBusPendingReply<QString> >("QDBusPendingReply<QString>")
+    ;
+ 
+    //qRegisterMetaType<DBusResponseWaiter::onComplete>("DBusResponseWaiter::onComplete");
+    //qRegisterMetaType<DBusResponseWaiter::onError>("DBusResponseWaiter::onError");
+}
+
+QVariant DBusResponseWaiter::waitForReply(QVariant variant) const
+{
+    if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(extractPendingCall(variant)))
+    {
+        call->waitForFinished();
+        QDBusMessage reply = call->reply();
+
+        if (reply.arguments().count() > 0)
+        {
+            return reply.arguments().first();
+        }
+    }
+    return QVariant();
+}
+
+void DBusResponse::setPendingCall(QVariant variant)
+{
+    qDebug() << "spc1";
+    m_pendingCall = variant;
+    qDebug() << "spc2";
+    if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter().extractPendingCall(m_pendingCall)))
+    {  
+        qDebug() << "spc3";
+        QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(*call);
+        connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(onCallFinished(QDBusPendingCallWatcher*)));
+        connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), watcher, SLOT(deleteLater()));
+    };
+    qDebug() << "spc4";
+}
+
+
+void DBusResponse::onCallFinished(QDBusPendingCallWatcher* watcher)
+{
+    QVariant variant = watcher->property("pengingCall");
+    
+    qDebug() << "ocf 1";
+    if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter().extractPendingCall(m_pendingCall)))
+    {
+        qDebug() << "ocf 2";
+        if (call->isError())
+        {
+              qDebug() << "ocf 3";
+              
+
+//             onError failure = watcher->property("onError").value<onError>();
+//              failure(call->error().message());
+        }
+        else
+        {
+              qDebug() << "ocf 4444";
+    //          onComplete success = watcher->property("onComplete").value<onComplete>();
+             
+              QDeclarativeExpression *expr = new QDeclarativeExpression(e_->rootContext(), this, "console.debug(this.onError)");
+              qDebug() << "ocf 555";
+              expr->evaluate();  // result = 400
+              qDebug() << "ocf 666";
+              
+              QDBusMessage reply = call->reply();
+
+              if (reply.arguments().count() > 0)
+              {
+//                   success(reply.arguments().first());
+                
+                
+                
+              }
+              else
+              {
+//                   success(QVariant());
+              }
+        }
+    }
+}
+
+const QDBusPendingCall* DBusResponseWaiter::extractPendingCall(QVariant& variant) const
+{
+    Q_FOREACH(int type, m_registered) 
+    {
+        if (variant.canConvert(QVariant::Type(type)))
+        {
+            return reinterpret_cast<const QDBusPendingCall*>(variant.constData());  
+        }
+    }
+    
+    return 0;
+}
+
+
+
diff --git a/plasmoid/declarativeplugin/responsewaiter.h b/plasmoid/declarativeplugin/responsewaiter.h
new file mode 100644
index 0000000..0a0af80
--- /dev/null
+++ b/plasmoid/declarativeplugin/responsewaiter.h
@@ -0,0 +1,70 @@
+
+#ifndef RESPONSE_WAITER_H
+#define RESPONSE_WAITER_H
+
+#include <QObject>
+#include <QVariant>
+#include <QDebug>
+
+#include <QDeclarativeEngine>
+
+class QDBusPendingCall;
+class QDBusPendingCallWatcher;
+
+class DBusResponse : public QObject
+{
+    Q_OBJECT
+    
+    Q_PROPERTY(QVariant pendingCall READ pendingCall WRITE setPendingCall NOTIFY pendingCallChanged)
+    Q_PROPERTY(QVariant onError READ onError WRITE setOnError NOTIFY onErrorChanged)
+    Q_PROPERTY(QVariant onSuccess READ onSuccess WRITE setOnSuccess NOTIFY onSuccessChanged)
+    
+public:
+    DBusResponse(QDeclarativeEngine* e = 0) : QObject(e) , e_(e) {qDebug() << "C";};
+    virtual ~DBusResponse() {};
+
+    void setPendingCall(QVariant e);
+    QVariant pendingCall() {return m_pendingCall;}
+    
+    
+    void setOnError(QVariant e) {m_onError = e;}
+    QVariant onError() {return m_onError;}
+    
+    void setOnSuccess(QVariant e) {m_onSuccess = e;}
+    QVariant onSuccess() {return m_onSuccess;}
+
+Q_SIGNALS:
+    void onSuccessChanged();
+    void onErrorChanged();
+    void pendingCallChanged();
+    
+private Q_SLOTS:
+    void onCallFinished(QDBusPendingCallWatcher* watcher);
+   
+private:
+  QVariant m_pendingCall;
+  QVariant m_onError;
+  QVariant m_onSuccess;
+  
+  QDeclarativeEngine* e_;
+};
+
+class DBusResponseWaiter : public QObject
+{
+    Q_OBJECT
+    
+public:
+  
+    DBusResponseWaiter();
+    
+    virtual ~DBusResponseWaiter(){};
+    
+    ///extract QDbusPendingCall from \p variant and blocks untill completed
+    Q_INVOKABLE QVariant waitForReply(QVariant variant) const;
+    
+    const QDBusPendingCall* extractPendingCall(QVariant& variant) const;
+  
+    QList<int> m_registered;
+};
+
+#endif
diff --git a/plasmoid/package/contents/ui/DeviceDelegate.qml b/plasmoid/package/contents/ui/DeviceDelegate.qml
index 35f39c0..e3b28b2 100644
--- a/plasmoid/package/contents/ui/DeviceDelegate.qml
+++ b/plasmoid/package/contents/ui/DeviceDelegate.qml
@@ -30,12 +30,23 @@ PlasmaComponents.ListItem
     property variant sftp: null
     
     Component.onCompleted: {
-        sftp = SftpDbusInterfaceFactory.create(deviceId)
-        if (ResponseWaiter.waitForReply(sftp.isMounted())) {
-            browse.state = "MOUNTED"
-        }
-        
-        console.debug(ResponseWaiter.waitForReply(sftp.mountPoint()))
+      sftp = SftpDbusInterfaceFactory.create(deviceId)
+      
+      var response = DBusResponseFactory.create()
+      response.onSuccess = function(v) {console.log("gggggggggggggggggg", v)}
+      console.log("o3")
+      response.onError = function(v) {console.log("eeeeee")}
+      console.log("o4")
+      response.pendingCall = sftp.isMounted()
+      console.log("o5")
+      
+//         rr.pendingCall = 1;
+//             onCompleted: {
+//                 console.debug("GGGGGGGGGGGGGGGGG")
+//             }
+//         }
+// 
+//         console.debug(ResponseWaiter.waitForReply(sftp.mountPoint()))
         
     }
 

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list