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


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

The following commit has been merged in the master branch:
commit 7a7aeb041b00a319a7557bc45a6191f4f58eb82f
Author: Dario Freddi <dario.freddi at collabora.co.uk>
Date:   Thu Apr 21 15:19:53 2011 +0200

    Make contact-list aware of any incoming presence publication requests
---
 main-widget.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 main-widget.h   |  4 ++++
 2 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/main-widget.cpp b/main-widget.cpp
index 442dbdc..4144791 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -64,6 +64,11 @@
 
 #define PREFERRED_TEXTCHAT_HANDLER "org.freedesktop.Telepathy.Client.KDE.TextUi"
 
+bool kde_tp_filter_contacts_by_publication_status(const Tp::ContactPtr &contact)
+{
+    return contact->publishState() == Tp::Contact::PresenceStateAsk;
+}
+
 MainWidget::MainWidget(QWidget *parent)
     : KMainWindow(parent),
    m_model(0),
@@ -269,6 +274,7 @@ void MainWidget::onAccountConnectionStatusChanged(Tp::ConnectionStatus status)
     case Tp::ConnectionStatusConnected:
         //FIXME: Get the account (sender()) index and expand only that index
         m_contactsListView->expandAll();
+        monitorPresence(Tp::AccountPtr(qobject_cast< Tp::Account* >(sender())));
         break;
     case Tp::ConnectionStatusDisconnected:
         //Fall through
@@ -280,7 +286,11 @@ void MainWidget::onAccountConnectionStatusChanged(Tp::ConnectionStatus status)
 
 void MainWidget::onNewAccountAdded(const Tp::AccountPtr& account)
 {
-    account->becomeReady();
+    Tp::PendingReady *ready = account->becomeReady();
+
+    connect(ready,
+            SIGNAL(finished(Tp::PendingOperation*)),
+            this, SLOT(onAccountReady(Tp::PendingOperation*)));
 
     connect(account.data(),
             SIGNAL(connectionChanged(Tp::ConnectionPtr)),
@@ -316,6 +326,28 @@ void MainWidget::onNewAccountAdded(const Tp::AccountPtr& account)
     }
 }
 
+void MainWidget::onAccountReady(Tp::PendingOperation *operation)
+{
+    Tp::AccountPtr account = Tp::AccountPtr::dynamicCast(operation->object());
+
+    if (account->connectionStatus() == Tp::ConnectionStatusConnected) {
+        monitorPresence(account);
+    }
+}
+
+void MainWidget::monitorPresence(const Tp::AccountPtr &account)
+{
+    connect(account->connection()->contactManager().data(), SIGNAL(presencePublicationRequested(Tp::Contacts)),
+            this, SLOT(onPresencePublicationRequested(Tp::Contacts)));
+
+    QFutureWatcher< Tp::ContactPtr > watcher;
+    connect(&watcher, SIGNAL(finished()), this, SLOT(onAccountsPresenceStatusFiltered()));
+    watcher.setFuture(QtConcurrent::filtered(account->connection()->contactManager()->allKnownContacts(),
+                                             kde_tp_filter_contacts_by_publication_status));
+
+    kDebug() << "Watcher is on";
+}
+
 void MainWidget::onAccountStateChanged(bool enabled)
 {
     Tp::AccountPtr account(static_cast<Tp::Account*>(sender()));
@@ -875,3 +907,32 @@ void MainWidget::onAvatarFetched(KJob *job)
         avatarGroup.config()->sync();
     }
 }
+
+void MainWidget::onAccountsPresenceStatusFiltered()
+{
+    kDebug() << "Watcher is here";
+    QFutureWatcher< Tp::ContactPtr > *watcher = dynamic_cast< QFutureWatcher< Tp::ContactPtr > * >(sender());
+    kDebug() << "Watcher is casted";
+    Tp::Contacts contacts = watcher->future().results().toSet();
+    kDebug() << "Watcher is used";
+    if (!contacts.isEmpty()) {
+        onPresencePublicationRequested(contacts);
+    }
+}
+
+void MainWidget::onPresencePublicationRequested(const Tp::Contacts& contacts)
+{
+    foreach (const Tp::ContactPtr &contact, contacts) {
+        if (KMessageBox::questionYesNo(this, i18n("The contact %1 added you to their contact list. "
+                                                  "Do you want to allow this person to see your presence "
+                                                  "and add them to your contact list?", contact->id()),
+                                       i18n("Subscription request")) == KDialog::Yes) {
+            Tp::ContactManagerPtr manager = contact->manager();
+            manager->authorizePresencePublication(QList< Tp::ContactPtr >() << contact);
+
+            if (manager->canRequestPresenceSubscription() && contact->subscriptionState() == Tp::Contact::PresenceStateNo) {
+                manager->requestPresenceSubscription(QList< Tp::ContactPtr >() << contact);
+            }
+        }
+    }
+}
diff --git a/main-widget.h b/main-widget.h
index 9180d64..b83a8aa 100644
--- a/main-widget.h
+++ b/main-widget.h
@@ -96,6 +96,10 @@ private Q_SLOTS:
     void slotStartTextChat();
     void slotUnblockContactTriggered();
     void onAvatarFetched(KJob*);
+    void onAccountReady(Tp::PendingOperation *operation);
+    void onAccountsPresenceStatusFiltered();
+    void onPresencePublicationRequested(const Tp::Contacts &contacts);
+    void monitorPresence(const Tp::AccountPtr &account);
 
 private:
     AccountsModel          *m_model;

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list