[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:05:19 UTC 2016


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

The following commit has been merged in the master branch:
commit 0197e134168a152b847e6d9ebdebd46aad9ed93a
Author: George Kiagiadakis <kiagiadakis.george at gmail.com>
Date:   Sat Jul 14 14:58:30 2012 +0300

    Models: Add a hack to workaround a bug in gabble's advertised call capabilities
---
 KTp/Models/CMakeLists.txt                |  1 +
 KTp/Models/accounts-model-item.cpp       | 13 +++--
 KTp/Models/capabilities-hack-private.cpp | 93 ++++++++++++++++++++++++++++++++
 KTp/Models/capabilities-hack-private.h   | 39 ++++++++++++++
 KTp/Models/contact-model-item.cpp        | 19 ++++---
 5 files changed, 155 insertions(+), 10 deletions(-)

diff --git a/KTp/Models/CMakeLists.txt b/KTp/Models/CMakeLists.txt
index 7c8d93d..e6a65b4 100644
--- a/KTp/Models/CMakeLists.txt
+++ b/KTp/Models/CMakeLists.txt
@@ -7,6 +7,7 @@ set (ktp_models_private_SRCS
     accounts-filter-model.cpp
     accounts-model-item.cpp
     accounts-model.cpp
+    capabilities-hack-private.cpp
     contact-model-item.cpp
     groups-model-item.cpp
     groups-model.cpp
diff --git a/KTp/Models/accounts-model-item.cpp b/KTp/Models/accounts-model-item.cpp
index fa26edc..1279417 100644
--- a/KTp/Models/accounts-model-item.cpp
+++ b/KTp/Models/accounts-model-item.cpp
@@ -27,6 +27,7 @@
 
 #include "accounts-model.h"
 #include "contact-model-item.h"
+#include "capabilities-hack-private.h"
 
 #include <KIcon>
 #include <KTp/presence.h>
@@ -196,12 +197,16 @@ QVariant AccountsModelItem::data(int role) const
     case AccountsModel::TextChatCapabilityRole:
         return mPriv->mAccount->capabilities().textChats();
     case AccountsModel::MediaCallCapabilityRole:
-        return mPriv->mAccount->capabilities().audioCalls()
-                || mPriv->mAccount->capabilities().videoCalls();
+        return CapabilitiesHackPrivate::audioCalls(mPriv->mAccount->capabilities(),
+                                                   mPriv->mAccount->cmName())
+            || CapabilitiesHackPrivate::videoCalls(mPriv->mAccount->capabilities(),
+                                                   mPriv->mAccount->cmName());
     case AccountsModel::AudioCallCapabilityRole:
-        return mPriv->mAccount->capabilities().audioCalls();
+        return CapabilitiesHackPrivate::audioCalls(mPriv->mAccount->capabilities(),
+                                                   mPriv->mAccount->cmName());
     case AccountsModel::VideoCallCapabilityRole:
-        return mPriv->mAccount->capabilities().videoCalls();
+        return CapabilitiesHackPrivate::videoCalls(mPriv->mAccount->capabilities(),
+                                                   mPriv->mAccount->cmName());
     case AccountsModel::UpgradeCallCapabilityRole:
         return mPriv->mAccount->capabilities().upgradingCalls();
     case AccountsModel::FileTransferCapabilityRole:
diff --git a/KTp/Models/capabilities-hack-private.cpp b/KTp/Models/capabilities-hack-private.cpp
new file mode 100644
index 0000000..46ba34e
--- /dev/null
+++ b/KTp/Models/capabilities-hack-private.cpp
@@ -0,0 +1,93 @@
+/*
+    Copyright (C) 2012 George Kiagiadakis <kiagiadakis.george at gmail.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 "capabilities-hack-private.h"
+
+/*
+ * This is a hack to workaround a gabble bug.
+ * https://bugs.freedesktop.org/show_bug.cgi?id=51978
+ */
+
+namespace CapabilitiesHackPrivate {
+
+static Tp::RequestableChannelClassSpec gabbleAudioCallRCC()
+{
+    static Tp::RequestableChannelClassSpec spec;
+
+    if (!spec.isValid()) {
+        Tp::RequestableChannelClass rcc;
+        rcc.fixedProperties.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"),
+                TP_QT_IFACE_CHANNEL_TYPE_CALL);
+        rcc.fixedProperties.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType"),
+                (uint) Tp::HandleTypeContact);
+        rcc.allowedProperties.append(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialAudio"));
+        rcc.allowedProperties.append(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialAudioName"));
+        spec = Tp::RequestableChannelClassSpec(rcc);
+    }
+
+    return spec;
+}
+
+static Tp::RequestableChannelClassSpec gabbleVideoCallRCC()
+{
+    static Tp::RequestableChannelClassSpec spec;
+
+    if (!spec.isValid()) {
+        Tp::RequestableChannelClass rcc;
+        rcc.fixedProperties.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"),
+                TP_QT_IFACE_CHANNEL_TYPE_CALL);
+        rcc.fixedProperties.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType"),
+                (uint) Tp::HandleTypeContact);
+        rcc.allowedProperties.append(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialVideo"));
+        rcc.allowedProperties.append(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String(".InitialVideoName"));
+        spec = Tp::RequestableChannelClassSpec(rcc);
+    }
+
+    return spec;
+}
+
+bool audioCalls(const Tp::CapabilitiesBase &caps, const QString &cmName)
+{
+    bool gabbleResult = false;
+    if (cmName == QLatin1String("gabble")) {
+        Q_FOREACH (const Tp::RequestableChannelClassSpec &rccSpec, caps.allClassSpecs()) {
+            if (rccSpec.supports(gabbleAudioCallRCC())) {
+                gabbleResult = true;
+                break;
+            }
+        }
+    }
+
+    return gabbleResult || caps.audioCalls();
+}
+
+bool videoCalls(const Tp::CapabilitiesBase &caps, const QString &cmName)
+{
+    bool gabbleResult = false;
+    if (cmName == QLatin1String("gabble")) {
+        Q_FOREACH (const Tp::RequestableChannelClassSpec &rccSpec, caps.allClassSpecs()) {
+            if (rccSpec.supports(gabbleVideoCallRCC())) {
+                gabbleResult = true;
+                break;
+            }
+        }
+    }
+
+    return gabbleResult || caps.videoCalls();
+}
+
+}
diff --git a/KTp/Models/capabilities-hack-private.h b/KTp/Models/capabilities-hack-private.h
new file mode 100644
index 0000000..aa3478f
--- /dev/null
+++ b/KTp/Models/capabilities-hack-private.h
@@ -0,0 +1,39 @@
+/*
+    Copyright (C) 2012 George Kiagiadakis <kiagiadakis.george at gmail.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 CAPABILITIES_HACK_PRIVATE_H
+#define CAPABILITIES_HACK_PRIVATE_H
+
+#include <KTp/ktp-export.h>
+#include <TelepathyQt/CapabilitiesBase>
+
+/*
+ * This is a hack to workaround a gabble bug.
+ * https://bugs.freedesktop.org/show_bug.cgi?id=51978
+ */
+
+namespace CapabilitiesHackPrivate {
+
+/* Equivalent to caps.audioCalls() */
+KTP_NO_EXPORT bool audioCalls(const Tp::CapabilitiesBase &caps, const QString &cmName);
+
+/* Equivalent to caps.videoCalls() */
+KTP_NO_EXPORT bool videoCalls(const Tp::CapabilitiesBase &caps, const QString &cmName);
+
+}
+
+#endif
diff --git a/KTp/Models/contact-model-item.cpp b/KTp/Models/contact-model-item.cpp
index 6f4fe0b..1bf32d7 100644
--- a/KTp/Models/contact-model-item.cpp
+++ b/KTp/Models/contact-model-item.cpp
@@ -22,6 +22,7 @@
 
 #include "contact-model-item.h"
 #include "accounts-model.h"
+#include "capabilities-hack-private.h"
 #include "../service-availability-checker.h"
 #include "presence.h"
 
@@ -200,9 +201,12 @@ Tp::ContactPtr ContactModelItem::contact() const
 //return true if both you and the contact can handle audio calls.
 bool ContactModelItem::audioCallCapability() const
 {
-    if (mPriv->mContact->manager()->connection()) {
-        bool contactCanStreamAudio = mPriv->mContact->capabilities().audioCalls();
-        bool selfCanStreamAudio = mPriv->mContact->manager()->connection()->selfContact()->capabilities().audioCalls();
+    Tp::ConnectionPtr connection = mPriv->mContact->manager()->connection();
+    if (connection) {
+        bool contactCanStreamAudio = CapabilitiesHackPrivate::audioCalls(
+                mPriv->mContact->capabilities(), connection->cmName());
+        bool selfCanStreamAudio = CapabilitiesHackPrivate::audioCalls(
+                connection->selfContact()->capabilities(), connection->cmName());
         return contactCanStreamAudio && selfCanStreamAudio;
     }
 
@@ -211,9 +215,12 @@ bool ContactModelItem::audioCallCapability() const
 
 bool ContactModelItem::videoCallCapability() const
 {
-    if (mPriv->mContact->manager()->connection()) {
-        bool contactCanStreamVideo = mPriv->mContact->capabilities().videoCalls();
-        bool selfCanStreamVideo = mPriv->mContact->manager()->connection()->selfContact()->capabilities().videoCalls();
+    Tp::ConnectionPtr connection = mPriv->mContact->manager()->connection();
+    if (connection) {
+        bool contactCanStreamVideo = CapabilitiesHackPrivate::videoCalls(
+                mPriv->mContact->capabilities(), connection->cmName());
+        bool selfCanStreamVideo = CapabilitiesHackPrivate::videoCalls(
+                connection->selfContact()->capabilities(), connection->cmName());
         return contactCanStreamVideo && selfCanStreamVideo;
     }
 

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list