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


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

The following commit has been merged in the master branch:
commit b2a15072e5b93ed273366cd7f2786fa782c4f8a0
Author: Martin Klapetek <mklapetek at kde.org>
Date:   Wed Nov 13 11:14:00 2013 +0100

    Check for contact's text capabilities before starting a chat
    
    Reviewed-by: David Edmundson
    BUG: 324567
---
 KTp/Widgets/start-chat-dialog.cpp | 31 ++++++++++++++++++++++++++++---
 KTp/Widgets/start-chat-dialog.h   |  1 +
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/KTp/Widgets/start-chat-dialog.cpp b/KTp/Widgets/start-chat-dialog.cpp
index 083da50..e7629f2 100644
--- a/KTp/Widgets/start-chat-dialog.cpp
+++ b/KTp/Widgets/start-chat-dialog.cpp
@@ -31,10 +31,13 @@
 #include <TelepathyQt/AccountManager>
 #include <TelepathyQt/Account>
 #include <TelepathyQt/Connection>
+#include <TelepathyQt/ContactManager>
 #include <TelepathyQt/PendingChannelRequest>
+#include <TelepathyQt/PendingContacts>
 #include <TelepathyQt/AccountSet>
 
 #include <KTp/actions.h>
+#include <KTp/contact.h>
 
 namespace KTp {
 
@@ -47,6 +50,7 @@ struct KTP_NO_EXPORT StartChatDialog::Private
 
     Ui::StartChatDialog *ui;
     bool acceptInProgress;
+    QPointer<Tp::PendingContacts> pendingContact;
 };
 
 StartChatDialog::StartChatDialog(const Tp::AccountManagerPtr &accountManager, QWidget *parent) :
@@ -83,14 +87,35 @@ void StartChatDialog::accept()
     } else if (contactIdentifier.isEmpty()) {
         KMessageBox::sorry(this, i18n("You did not specify the name of the contact to start a chat with."));
     } else {
-        Tp::PendingChannelRequest *op = KTp::Actions::startChat(account, contactIdentifier, true);
-        connect(op, SIGNAL(finished(Tp::PendingOperation*)),
-                SLOT(_k_onStartChatFinished(Tp::PendingOperation*)));
+        d->pendingContact = account->connection()->contactManager()->contactsForIdentifiers(
+            QStringList() << contactIdentifier, Tp::Contact::FeatureCapabilities);
+
+        connect(d->pendingContact, SIGNAL(finished(Tp::PendingOperation*)),
+                SLOT(_k_onPendingContactFinished(Tp::PendingOperation*)));
 
         setInProgress(true);
     }
 }
 
+void StartChatDialog::_k_onPendingContactFinished(Tp::PendingOperation *op)
+{
+    Tp::PendingContacts *pc = qobject_cast<Tp::PendingContacts*>(op);
+    Q_ASSERT(pc);
+
+    if (pc->isError()) {
+        KMessageBox::sorry(this, i18n("The contact Screen Name you provided is invalid or does not accept text chats."));
+        return;
+    }
+
+    if (pc == d->pendingContact && !pc->isError() && pc->contacts().size() > 0) {
+        KTp::ContactPtr currentContact = KTp::ContactPtr::qObjectCast(pc->contacts().at(0));
+
+        Tp::PendingChannelRequest *op = KTp::Actions::startChat(d->ui->accountCombo->currentAccount(), currentContact, true);
+        connect(op, SIGNAL(finished(Tp::PendingOperation*)),
+                SLOT(_k_onStartChatFinished(Tp::PendingOperation*)));
+    }
+}
+
 void StartChatDialog::closeEvent(QCloseEvent *e)
 {
     // ignore close event if we are in the middle of an operation
diff --git a/KTp/Widgets/start-chat-dialog.h b/KTp/Widgets/start-chat-dialog.h
index 2155b24..ee9ee96 100644
--- a/KTp/Widgets/start-chat-dialog.h
+++ b/KTp/Widgets/start-chat-dialog.h
@@ -48,6 +48,7 @@ protected:
 
 private Q_SLOTS:
     KTP_NO_EXPORT void _k_onStartChatFinished(Tp::PendingOperation *op);
+    KTP_NO_EXPORT void _k_onPendingContactFinished(Tp::PendingOperation *op);
 
 private:
     KTP_NO_EXPORT void setInProgress(bool inProgress);

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list