[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:07:37 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=3f73c4a
The following commit has been merged in the master branch:
commit 3f73c4aae740febde740640709f2e998b2465282
Author: George Kiagiadakis <george.kiagiadakis at collabora.com>
Date: Mon Sep 19 20:45:50 2011 +0300
Add a new class to watch for the availability of krfb.
This is because the self contact capabilities do not advertise
the availability of krfb; they only advertise the availability of krdc.
---
CMakeLists.txt | 4 +-
models/contact-model-item.cpp | 13 ++++-
service-availability-checker.cpp | 107 +++++++++++++++++++++++++++++++++++++++
service-availability-checker.h | 50 ++++++++++++++++++
4 files changed, 171 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7c463ff..1ff1c6b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,8 @@ include_directories (${KDE4_INCLUDES}
${TELEPATHY_QT4_INCLUDE_DIR}
)
-set (contactlist_SRCS avatar-button.cpp
+set (contactlist_SRCS
+ avatar-button.cpp
abstract-contact-delegate.cpp
contact-list-application.cpp
contact-view-hover-button.cpp
@@ -33,6 +34,7 @@ set (contactlist_SRCS avatar-button.cpp
main.cpp
main-widget.cpp
fetch-avatar-job.cpp
+ service-availability-checker.cpp
dialogs/add-contact-dialog.cpp
dialogs/join-chat-room-dialog.cpp
dialogs/remove-contact-dialog.cpp
diff --git a/models/contact-model-item.cpp b/models/contact-model-item.cpp
index b35d69e..d453956 100644
--- a/models/contact-model-item.cpp
+++ b/models/contact-model-item.cpp
@@ -21,15 +21,23 @@
*/
#include "contact-model-item.h"
+#include "accounts-model.h"
+#include "../service-availability-checker.h"
#include <QImage>
+#include <KGlobal>
+
#include <TelepathyQt4/AvatarData>
#include <TelepathyQt4/ContactCapabilities>
#include <TelepathyQt4/ContactManager>
#include <TelepathyQt4/RequestableChannelClassSpec>
-#include "accounts-model.h"
+
+
+K_GLOBAL_STATIC_WITH_ARGS(ServiceAvailabilityChecker, s_krfbAvailableChecker,
+ (QLatin1String("org.freedesktop.Telepathy.Client.krfb_rfb_handler")));
+
struct ContactModelItem::Private
{
@@ -44,6 +52,7 @@ struct ContactModelItem::Private
ContactModelItem::ContactModelItem(const Tp::ContactPtr &contact)
: mPriv(new Private(contact))
{
+ (void) s_krfbAvailableChecker.operator->(); //start the d-bus query the first time this is called
connect(contact.data(),
SIGNAL(aliasChanged(QString)),
@@ -198,7 +207,7 @@ bool ContactModelItem::fileTransferCapability() const
bool ContactModelItem::desktopSharingCapability() const
{
bool contactCanHandleRfb = mPriv->mContact->capabilities().streamTubes("rfb");
- bool selfCanHandleRfb = mPriv->mContact->manager()->connection()->selfContact()->capabilities().streamTubes("rfb");
+ bool selfCanHandleRfb = s_krfbAvailableChecker->isAvailable();
return contactCanHandleRfb && selfCanHandleRfb;
}
diff --git a/service-availability-checker.cpp b/service-availability-checker.cpp
new file mode 100644
index 0000000..bed93b3
--- /dev/null
+++ b/service-availability-checker.cpp
@@ -0,0 +1,107 @@
+/*
+ Copyright (C) 2011 Collabora Ltd. <info at collabora.com>
+ @author George Kiagiadakis <george.kiagiadakis at collabora.com>
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "service-availability-checker.h"
+
+#include <QtDBus/QDBusConnectionInterface>
+#include <QtDBus/QDBusServiceWatcher>
+#include <QtDBus/QDBusPendingCall>
+#include <QtDBus/QDBusReply>
+
+#include <KDebug>
+
+struct ServiceAvailabilityChecker::Private
+{
+ QString serviceName;
+ bool serviceAvailable;
+ bool serviceActivatable;
+};
+
+ServiceAvailabilityChecker::ServiceAvailabilityChecker(const QString & serviceName, QObject *parent)
+ : QObject(parent), d(new Private)
+{
+ d->serviceName = serviceName;
+ d->serviceAvailable = false;
+ d->serviceActivatable = false;
+
+ QDBusServiceWatcher *serviceWatcher = new QDBusServiceWatcher(serviceName,
+ QDBusConnection::sessionBus(),
+ QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration,
+ this);
+ connect(serviceWatcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
+ this, SLOT(onServiceOwnerChanged(QString,QString,QString)));
+
+ introspect();
+}
+
+ServiceAvailabilityChecker::~ServiceAvailabilityChecker()
+{
+ delete d;
+}
+
+bool ServiceAvailabilityChecker::isAvailable() const
+{
+ return d->serviceAvailable || d->serviceActivatable;
+}
+
+void ServiceAvailabilityChecker::introspect()
+{
+ QDBusConnectionInterface *dbusIface = QDBusConnection::sessionBus().interface();
+
+ QDBusPendingCall call = dbusIface->asyncCall(QLatin1String("ListActivatableNames"));
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
+ connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ this, SLOT(onCallFinished(QDBusPendingCallWatcher*)));
+ watcher->setObjectName(QLatin1String("ListActivatableNamesWatcher"));
+
+ call = dbusIface->asyncCall(QLatin1String("ListNames"));
+ watcher = new QDBusPendingCallWatcher(call, this);
+ connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ this, SLOT(onCallFinished(QDBusPendingCallWatcher*)));
+}
+
+void ServiceAvailabilityChecker::onCallFinished(QDBusPendingCallWatcher *watcher)
+{
+ QDBusReply<QStringList> reply = *watcher;
+ if (!reply.isValid()) {
+ kDebug() << "Got error while introspecting service availability:" << reply.error();
+ } else {
+ bool *var = (watcher->objectName() == QLatin1String("ListActivatableNamesWatcher"))
+ ? &d->serviceActivatable : &d->serviceAvailable;
+
+ if (!*var) {
+ *var = reply.value().contains(d->serviceName);
+ } else {
+ Q_ASSERT(var == &d->serviceAvailable); //this is the serviceAvailable variable
+ //... and onServiceOwnerChanged() got there first...
+ }
+ }
+
+ watcher->deleteLater();
+}
+
+void ServiceAvailabilityChecker::onServiceOwnerChanged(const QString & service,
+ const QString & oldOwner, const QString & newOwner)
+{
+ Q_UNUSED(oldOwner);
+
+ if (service == d->serviceName) {
+ d->serviceAvailable = !newOwner.isEmpty();
+ }
+}
+
+#include "service-availability-checker.moc"
diff --git a/service-availability-checker.h b/service-availability-checker.h
new file mode 100644
index 0000000..8883fe6
--- /dev/null
+++ b/service-availability-checker.h
@@ -0,0 +1,50 @@
+/*
+ Copyright (C) 2011 Collabora Ltd. <info at collabora.com>
+ @author George Kiagiadakis <george.kiagiadakis at collabora.com>
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef SERVICE_AVAILABILITY_CHECKER_H
+#define SERVICE_AVAILABILITY_CHECKER_H
+
+#include <QtCore/QObject>
+
+class QDBusPendingCallWatcher;
+
+/**
+ * This class watches if a given d-bus service is either
+ * available on the bus or can be activated on demand.
+ */
+class ServiceAvailabilityChecker : public QObject
+{
+ Q_OBJECT
+public:
+ ServiceAvailabilityChecker(const QString & serviceName, QObject *parent = 0);
+ virtual ~ServiceAvailabilityChecker();
+
+ bool isAvailable() const;
+
+private Q_SLOTS:
+ void introspect();
+ void onCallFinished(QDBusPendingCallWatcher *watcher);
+ void onServiceOwnerChanged(const QString & service,
+ const QString & oldOwner,
+ const QString & newOwner);
+
+private:
+ struct Private;
+ Private * const d;
+};
+
+#endif // SERVICE_AVAILABILITY_CHECKER_H
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list