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


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

The following commit has been merged in the master branch:
commit 5ccf1301a47914b8e8368505b4a94a204c022629
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Tue May 28 03:07:59 2013 +0100

    Reconnect to text channels in declarative lib when user reconnects
    
    REVIEW: 110682
---
 KTp/Declarative/conversation.cpp | 31 +++++++++++++++++++++++++++++++
 KTp/Declarative/conversation.h   |  2 ++
 2 files changed, 33 insertions(+)

diff --git a/KTp/Declarative/conversation.cpp b/KTp/Declarative/conversation.cpp
index d7a8826..e0b1893 100644
--- a/KTp/Declarative/conversation.cpp
+++ b/KTp/Declarative/conversation.cpp
@@ -21,6 +21,10 @@
 #include "messages-model.h"
 
 #include <TelepathyQt/TextChannel>
+#include <TelepathyQt/Account>
+#include <TelepathyQt/PendingChannelRequest>
+#include <TelepathyQt/PendingChannel>
+
 #include <KDebug>
 #include "conversation-target.h"
 
@@ -47,6 +51,7 @@ Conversation::Conversation(const Tp::TextChannelPtr &channel,
     kDebug();
 
     d->account = account;
+    connect(d->account.data(), SIGNAL(connectionChanged(Tp::ConnectionPtr)), SLOT(onAccountConnectionChanged(Tp::ConnectionPtr)));
 
     d->messages = new MessagesModel(account, this);
     setTextChannel(channel);
@@ -100,6 +105,32 @@ void Conversation::onChannelInvalidated(Tp::DBusProxy *proxy, const QString &err
     Q_EMIT validityChanged(d->valid);
 }
 
+void Conversation::onAccountConnectionChanged(const Tp::ConnectionPtr& connection)
+{
+    //if we have reconnected and we were handling the channel
+    if (connection && ! d->delegated) {
+
+        //general convention is to never use ensureAndHandle when we already have a client registrar
+        //ensureAndHandle will implicity create a new temporary client registrar which is a waste
+        //it's also more code to get the new channel
+
+        //However, we cannot use use ensureChannel as normal because without being able to pass a preferredHandler
+        //we need a preferredHandler so that this handler is the one that ends up with the channel if multi handlers are active
+        //we do not know the name that this handler is currently registered with
+        Tp::PendingChannel *pendingChannel = d->account->ensureAndHandleTextChat(textChannel()->targetId());
+        connect(pendingChannel, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onCreateChannelFinished(Tp::PendingOperation*)));
+    }
+}
+
+void Conversation::onCreateChannelFinished(Tp::PendingOperation* op)
+{
+    Tp::PendingChannel *pendingChannelOp = qobject_cast<Tp::PendingChannel*>(op);
+    Tp::TextChannelPtr textChannel = Tp::TextChannelPtr::dynamicCast(pendingChannelOp->channel());
+    if (textChannel) {
+        setTextChannel(textChannel);
+    }
+}
+
 void Conversation::delegateToProperClient()
 {
     ChannelDelegator::delegateChannel(d->account, d->messages->textChannel());
diff --git a/KTp/Declarative/conversation.h b/KTp/Declarative/conversation.h
index fcd02f6..6f50709 100644
--- a/KTp/Declarative/conversation.h
+++ b/KTp/Declarative/conversation.h
@@ -62,6 +62,8 @@ public Q_SLOTS:
 
 private Q_SLOTS:
     void onChannelInvalidated(Tp::DBusProxy *proxy, const QString &errorName, const QString &errorMessage);
+    void onAccountConnectionChanged(const Tp::ConnectionPtr &connection);
+    void onCreateChannelFinished(Tp::PendingOperation *op);
 
 private:
     class ConversationPrivate;

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list