[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ktp-common-internals/mklapetek/SpaceBar] KTp/Declarative: [declarative] Add "ready" property to Tel
From:       Martin Klapetek <mklapetek () kde ! org>
Date:       2016-03-16 0:16:18
Message-ID: E1afz8M-0005bD-L8 () scm ! kde ! org
[Download RAW message or body]

Git commit d4466e99607d27759c6e1ddb42514491706f7906 by Martin Klapetek.
Committed on 16/03/2016 at 00:15.
Pushed by mklapetek into branch 'mklapetek/SpaceBar'.

[declarative] Add "ready" property to TelepathyManager and call becomeReady() in ctor

There is really no situation where the account manager should not become
ready right after it is created, so call becomeReady() on it right away

M  +18   -0    KTp/Declarative/telepathy-manager.cpp
M  +8    -0    KTp/Declarative/telepathy-manager.h

http://commits.kde.org/telepathy-common-internals/d4466e99607d27759c6e1ddb42514491706f7906


diff --git a/KTp/Declarative/telepathy-manager.cpp \
b/KTp/Declarative/telepathy-manager.cpp index 57b1150..b2ed151 100644
--- a/KTp/Declarative/telepathy-manager.cpp
+++ b/KTp/Declarative/telepathy-manager.cpp
@@ -30,6 +30,7 @@
 #include <TelepathyQt/AbstractClient>
 #include <TelepathyQt/TextChannel>
 #include <TelepathyQt/PendingChannelRequest>
+#include <TelepathyQt/PendingReady>
 
 #include <QQmlEngine>
 
@@ -38,6 +39,8 @@ TelepathyManager::TelepathyManager(QObject *parent)
 {
     Tp::registerTypes();
 
+    m_isReady = false;
+
     m_accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
                                                   Tp::Features() << \
                Tp::Account::FeatureCore
                                                                  << \
Tp::Account::FeatureProfile @@ -53,6 +56,16 @@ \
                TelepathyManager::TelepathyManager(QObject *parent)
     m_channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
 
     m_accountManager = Tp::AccountManager::create(m_accountFactory, \
m_connectionFactory, m_channelFactory, m_contactFactory); +    \
connect(m_accountManager->becomeReady(), &Tp::PendingReady::finished, \
[=](Tp::PendingOperation *op) { +        if (op->isError()) {
+            qWarning() << "AccountManager failed to become ready!" << \
op->errorMessage(); +            return;
+        }
+
+        m_isReady = true;
+
+        Q_EMIT ready();
+    });
 }
 
 TelepathyManager::~TelepathyManager()
@@ -172,6 +185,11 @@ bool TelepathyManager::canSendFiles() const
     return !QStandardPaths::findExecutable(QLatin1String("ktp-send-file")).isEmpty();
  }
 
+bool TelepathyManager::isReady() const
+{
+    return m_isReady;
+}
+
 void TelepathyManager::openDialUi() const
 {
     KToolInvocation::kdeinitExec(QLatin1String("ktp-dialout-ui"));
diff --git a/KTp/Declarative/telepathy-manager.h \
b/KTp/Declarative/telepathy-manager.h index d9ad24a..97c71b0 100644
--- a/KTp/Declarative/telepathy-manager.h
+++ b/KTp/Declarative/telepathy-manager.h
@@ -44,6 +44,8 @@ class TelepathyManager : public QObject
     /** @returns whether there's a ktp-send-file executable */
     Q_PROPERTY(bool canSendFiles READ canSendFiles)
 
+    Q_PROPERTY(bool ready READ isReady NOTIFY ready)
+
 public:
     TelepathyManager(QObject *parent=0);
     virtual ~TelepathyManager();
@@ -87,6 +89,7 @@ public:
 
     bool canDial() const;
     bool canSendFiles() const;
+    bool isReady() const;
 
     /** Opens UI to start an audio call */
     Q_INVOKABLE void openDialUi() const;
@@ -156,6 +159,9 @@ public Q_SLOTS:
 private Q_SLOTS:
     void contactlistDBusAccessed(QDBusPendingCallWatcher*);
 
+Q_SIGNALS:
+    void ready();
+
 private:
     Tp::AccountManagerPtr m_accountManager;
     Tp::ClientRegistrarPtr m_clientRegistrar;
@@ -165,6 +171,8 @@ private:
     Tp::ConnectionFactoryPtr m_connectionFactory;
     Tp::ChannelFactoryPtr m_channelFactory;
 
+    bool m_isReady;
+
 };
 
 #endif // DECLARATIVEKTPACTIONS_H


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic