[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:13:39 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=bca58fb

The following commit has been merged in the master branch:
commit bca58fb7980324a19dd83499a92c4c58c9e38435
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date:   Wed Jul 24 11:33:44 2013 +0200

    Ask to connect account when it's offline and chat is requested
    
    Reviewed-by: David Edmundson
---
 contact-list-widget.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++----
 contact-list-widget.h   |  1 +
 2 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/contact-list-widget.cpp b/contact-list-widget.cpp
index 2b40712..139190b 100644
--- a/contact-list-widget.cpp
+++ b/contact-list-widget.cpp
@@ -236,19 +236,71 @@ void ContactListWidget::onContactListClicked(const QModelIndex& index)
     }
 }
 
-void ContactListWidget::onContactListDoubleClicked(const QModelIndex& index)
+void ContactListWidget::onContactListDoubleClicked(const QModelIndex &index)
 {
     if (!index.isValid()) {
         return;
     }
 
-    if (index.data(KTp::RowTypeRole).toInt() == KTp::ContactRowType) {
-        KTp::ContactPtr contact = index.data(KTp::ContactRole).value<KTp::ContactPtr>();
-        Tp::AccountPtr account = index.data(KTp::AccountRole).value<Tp::AccountPtr>();
+    Tp::AccountPtr account = index.data(KTp::AccountRole).value<Tp::AccountPtr>();
+    KTp::ContactPtr contact = index.data(KTp::ContactRole).value<KTp::ContactPtr>();
+
+    if (account.isNull()) {
+        kWarning() << "Account is null!";
+        return;
+    }
+
+    //contact should be null only if the account is offline
+    if (!contact.isNull()) {
         startTextChannel(account, contact);
+        return;
+    }
+
+    if (!account->isOnline()) {
+        KGuiItem yes(i18nc("Label of a dialog's 'OK' button; %1 is account name, eg. 'Connect account GTalk'",
+                           "Connect account %1", account->displayName()), QLatin1String("dialog-ok"));
+        if (KMessageBox::questionYesNo(this,
+            i18n("The account for this contact is disconnected. Do you want to connect it?"),
+                                        i18n("Account offline"),
+                                        yes,
+                                        KStandardGuiItem::no()) == KMessageBox::Yes) {
+
+            QString contactId = index.data(KTp::RowTypeRole).toUInt() == KTp::PersonRowType
+                                    ? index.data(KTp::IdRole).toList().first().toString()
+                                    : index.data(KTp::IdRole).toString();
+            if (!account->isEnabled()) {
+                Tp::PendingOperation *op = account->setEnabled(true);
+                op->setProperty("contactId", contactId);
+                connect(op, SIGNAL(finished(Tp::PendingOperation*)),
+                        this, SLOT(accountEnablingFinished(Tp::PendingOperation*)));
+            } else {
+                account->ensureTextChat(contactId,
+                                        QDateTime::currentDateTime(),
+                                        QLatin1String("org.freedesktop.Telepathy.Client.KTp.TextUi"));
+            }
+        }
     }
 }
 
+void ContactListWidget::accountEnablingFinished(Tp::PendingOperation *op)
+{
+    if (op->isError()) {
+        kWarning() << "Account enabling failed" << op->errorMessage();
+        return;
+    }
+
+    Tp::AccountPtr account = Tp::AccountPtr(qobject_cast<Tp::Account*>(sender()));
+
+    if (account.isNull()) {
+        kWarning() << "Null account passed!";
+        return;
+    }
+
+    account->ensureTextChat(op->property("contactId").toString(),
+                            QDateTime::currentDateTime(),
+                            QLatin1String("org.freedesktop.Telepathy.Client.KTp.TextUi"));
+}
+
 void ContactListWidget::addOverlayButtons()
 {
     Q_D(ContactListWidget);
diff --git a/contact-list-widget.h b/contact-list-widget.h
index 0ab5449..a0f40e3 100644
--- a/contact-list-widget.h
+++ b/contact-list-widget.h
@@ -71,6 +71,7 @@ private Q_SLOTS:
     void startVideoChannel(const Tp::AccountPtr &account, const Tp::ContactPtr &contact);
     void startDesktopSharing(const Tp::AccountPtr &account, const Tp::ContactPtr &contact);
     void startLogViewer(const Tp::AccountPtr &account, const Tp::ContactPtr &contact);
+    void accountEnablingFinished(Tp::PendingOperation *op);
 
 
 Q_SIGNALS:

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list