[SCM] ktp-approver packaging branch, master, updated. debian/15.12.1-1-299-g62cbbd7
Maximiliano Curia
maxy at moszumanska.debian.org
Fri May 27 09:13:45 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-approver.git;a=commitdiff;h=e44c775
The following commit has been merged in the master branch:
commit e44c775b4679e68c603a47d460e28ed84843cf6e
Author: Dan Vrátil <dvratil at redhat.com>
Date: Wed Feb 6 16:55:13 2013 +0100
.desktop-based tubes channel approver
Every application using tubes should now install a ,desktop
file to `kde4-config --prefix`/share/kde4/services/ktp.
Approver will pick the .desktop file on incoming tube, show
message and icon as specified in the file and 'Accept' and
'Reject' buttons.
REVIEW: 108780
BUG: 301331
---
CMakeLists.txt | 2 +
ktp-approver.service | 19 +++
src/CMakeLists.txt | 2 +-
src/approverdaemon.cpp | 3 +-
src/channelapprover.cpp | 8 +-
src/ktpapprovermodule.cpp | 4 +
src/streamtubechannelapprover.cpp | 123 ----------------
src/tubechannelapprover.cpp | 158 +++++++++++++++++++++
...tubechannelapprover.h => tubechannelapprover.h} | 37 +++--
9 files changed, 212 insertions(+), 144 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8b29de7..690d8f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,3 +9,5 @@ include_directories(${KDE4_INCLUDES} ${TELEPATHY_QT4_INCLUDE_DIR})
add_definitions(${KDE4_DEFINITIONS})
add_subdirectory(src)
+
+install(FILES ktp-approver.service DESTINATION ${SERVICETYPES_INSTALL_DIR})
diff --git a/ktp-approver.service b/ktp-approver.service
new file mode 100644
index 0000000..bbbfefa
--- /dev/null
+++ b/ktp-approver.service
@@ -0,0 +1,19 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=KTpApprover
+Comment=KTp Approver
+
+[PropertyDef::X-KTp-ChannelType]
+Type=QString
+
+[PropertyDef::X-KTp-Service]
+Type=QString
+
+[PropertyDef::X-KTp-Preferred-Incoming-Handler]
+Type=QString
+
+[PropertyDef::X-KTp-Preferred-Outgoing-Handler]
+Type=QString
+
+[PropertyDef::X-KTp-Cancellable]
+Type=bool
\ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a1ce660..60609d8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,8 +5,8 @@ set(ktp_approver_SRCS
handlewithcaller.cpp
channelapprover.cpp
textchannelapprover.cpp
+ tubechannelapprover.cpp
filetransferchannelapprover.cpp
- streamtubechannelapprover.cpp
)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/src/approverdaemon.cpp b/src/approverdaemon.cpp
index 776a0a2..ee4687c 100644
--- a/src/approverdaemon.cpp
+++ b/src/approverdaemon.cpp
@@ -27,7 +27,8 @@ static inline Tp::ChannelClassSpecList channelClassSpecList()
<< Tp::ChannelClassSpec::unnamedTextChat()
<< Tp::ChannelClassSpec::textChatroom()
<< Tp::ChannelClassSpec::incomingFileTransfer()
- << Tp::ChannelClassSpec::incomingStreamTube("x-ssh-contact")
+ << Tp::ChannelClassSpec::incomingStreamTube()
+ << Tp::ChannelClassSpec::incomingDBusTube()
;
}
diff --git a/src/channelapprover.cpp b/src/channelapprover.cpp
index 5d4b02b..ab4e25e 100644
--- a/src/channelapprover.cpp
+++ b/src/channelapprover.cpp
@@ -19,7 +19,7 @@
#include "textchannelapprover.h"
#include "filetransferchannelapprover.h"
-#include "streamtubechannelapprover.h"
+#include "tubechannelapprover.h"
ChannelApprover *ChannelApprover::create(const Tp::ChannelPtr & channel, QObject *parent)
{
@@ -33,9 +33,9 @@ ChannelApprover *ChannelApprover::create(const Tp::ChannelPtr & channel, QObject
parent);
}
- if (channel->channelType() == TP_QT_IFACE_CHANNEL_TYPE_STREAM_TUBE) {
- return new StreamTubeChannelApprover(Tp::StreamTubeChannelPtr::dynamicCast(channel),
- parent);
+ if ((channel->channelType() == TP_QT_IFACE_CHANNEL_TYPE_STREAM_TUBE) ||
+ (channel->channelType() == TP_QT_IFACE_CHANNEL_TYPE_DBUS_TUBE)) {
+ return new TubeChannelApprover(Tp::TubeChannelPtr::dynamicCast(channel), parent);
}
Q_ASSERT(false);
diff --git a/src/ktpapprovermodule.cpp b/src/ktpapprovermodule.cpp
index db5c005..9d6166e 100644
--- a/src/ktpapprovermodule.cpp
+++ b/src/ktpapprovermodule.cpp
@@ -30,6 +30,7 @@
#include <TelepathyQt/TextChannel>
#include <TelepathyQt/IncomingFileTransferChannel>
#include <TelepathyQt/IncomingStreamTubeChannel>
+#include <TelepathyQt/IncomingDBusTubeChannel>
class KTpApproverModule : public KDEDModule
@@ -61,6 +62,9 @@ public:
channelFactory->addFeaturesForIncomingStreamTubes(
Tp::IncomingStreamTubeChannel::FeatureCore);
+ channelFactory->addFeaturesForIncomingDBusTubes(
+ Tp::IncomingDBusTubeChannel::FeatureCore);
+
Tp::ContactFactoryPtr contactFactory =
Tp::ContactFactory::create(Tp::Features()
<< Tp::Contact::FeatureAlias
diff --git a/src/streamtubechannelapprover.cpp b/src/streamtubechannelapprover.cpp
deleted file mode 100644
index f7d34df..0000000
--- a/src/streamtubechannelapprover.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- Copyright (C) 2012 David Edmundson <kde at davidedmundson.co.uk>
-
- 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 "streamtubechannelapprover.h"
-
-#include <KNotification>
-#include <KStatusNotifierItem>
-#include <KLocale>
-#include <KDebug>
-#include <KAboutData>
-#include <KActionCollection>
-#include <KMenu>
-#include <KIcon>
-
-#include <TelepathyQt/AvatarData>
-#include <TelepathyQt/Contact>
-
-StreamTubeChannelApprover::StreamTubeChannelApprover(
- const Tp::StreamTubeChannelPtr & channel,
- QObject *parent)
- : ChannelApprover(0), //set parent to 0. I.e don't delete when the dispatch operation finishes. Instead we delete when the channel becomes invalidated.
-
- m_channel(channel)
-{
- Q_UNUSED(parent);
- kDebug();
-
- connect(m_channel.data(), SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)), SLOT(onChannelInvalidated()));
-
- if (m_channel->service() == QLatin1String("x-ssh-contact")) {
- m_serviceName = i18nc("Acronym for the secure shell service","SSH");
- } else {
- m_serviceName = m_channel->service();
- }
-
- //notification
- m_notification = new KNotification("incoming_file_transfer");
- KAboutData aboutData("ktelepathy",0,KLocalizedString(),0);
- m_notification.data()->setComponentData(KComponentData(aboutData));
- m_notification.data()->setTitle(i18n("Incoming %1 share request", m_serviceName));
-
- Tp::ContactPtr sender = channel->initiatorContact();
- m_notification.data()->setText(i18n("<p>%1 wants to start a %2 sharing session with you</p>",
- sender->alias(),
- m_serviceName));
-
- QPixmap pixmap;
- if (pixmap.load(sender->avatarData().fileName)) {
- m_notification.data()->setPixmap(pixmap);
- }
-
- m_notification.data()->setActions(QStringList() << i18n("Accept") << i18n("Reject"));
- connect(m_notification.data(), SIGNAL(action1Activated()), SIGNAL(channelAccepted()));
- connect(m_notification.data(), SIGNAL(action2Activated()), SIGNAL(channelRejected()));
-
- m_notification.data()->sendEvent();
-
- //tray icon
- m_notifierItem = new KStatusNotifierItem;
- m_notifierItem->setCategory(KStatusNotifierItem::Communications);
- m_notifierItem->setStatus(KStatusNotifierItem::NeedsAttention);
- m_notifierItem->setIconByName(QLatin1String("utilities-terminal"));
- m_notifierItem->setStandardActionsEnabled(false);
- m_notifierItem->setTitle(i18n("Incoming share request"));
- m_notifierItem->setToolTip(QLatin1String("document-save"),
- i18n("Incoming share request from %1", sender->alias()),
- QString());
- m_notifierItem->contextMenu()->addAction(i18n("Accept"), this, SIGNAL(channelAccepted()));
- m_notifierItem->contextMenu()->addAction(i18n("Reject"), this, SIGNAL(channelRejected()));
-// connect(m_notifierItem, SIGNAL(activateRequested(bool,QPoint)), SIGNAL(channelAccepted())); //do we want clicking the approver to be auto-accept? I think not.
- connect(this, SIGNAL(channelAccepted()), SLOT(onChannelAccepted()));
-}
-
-StreamTubeChannelApprover::~StreamTubeChannelApprover()
-{
- kDebug();
-
- //destroy the notification
- if (m_notification) {
- m_notification.data()->close();
- }
-
- //destroy the tray icon
- m_notifierItem->deleteLater();
-}
-
-void StreamTubeChannelApprover::onChannelAccepted()
-{
- //destroy the notification
- if (m_notification) {
- m_notification.data()->close();
- }
-
- m_notifierItem->setTitle(i18n("%1 share with %2", m_serviceName, m_channel->initiatorContact()->alias()));
- //set new menu to an entry to close the channel
- m_notifierItem->contextMenu()->clear();
- m_notifierItem->contextMenu()->addAction(KIcon("dialog-close"), i18n("Stop %1 Sharing", m_serviceName), this, SLOT(onChannelCloseRequested()));
-}
-
-void StreamTubeChannelApprover::onChannelCloseRequested()
-{
- m_channel->requestClose();
-}
-
-void StreamTubeChannelApprover::onChannelInvalidated()
-{
- deleteLater();
-}
-
-#include "streamtubechannelapprover.moc"
diff --git a/src/tubechannelapprover.cpp b/src/tubechannelapprover.cpp
new file mode 100644
index 0000000..fd2ff08
--- /dev/null
+++ b/src/tubechannelapprover.cpp
@@ -0,0 +1,158 @@
+/*
+ Copyright (C) 2012 David Edmundson <kde at davidedmundson.co.uk>
+ Copyright (C) 2013 Dan Vrátil <dvratil at redhat.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 "tubechannelapprover.h"
+
+#include <KService>
+#include <KServiceTypeTrader>
+#include <KStatusNotifierItem>
+#include <KDebug>
+#include <KAboutData>
+#include <KIcon>
+#include <KMenu>
+
+#include <TelepathyQt/TubeChannel>
+#include <TelepathyQt/StreamTubeChannel>
+#include <TelepathyQt/DBusTubeChannel>
+#include <TelepathyQt/Contact>
+
+#include "approverdaemon.h"
+
+TubeChannelApprover::TubeChannelApprover(const Tp::TubeChannelPtr& channel, QObject* parent):
+ ChannelApprover(0),
+ m_channel(channel)
+{
+ Q_UNUSED(parent);
+
+ kDebug() << "Incomming tube channel";
+ kDebug() << " Tube Type:" << channel->channelType();
+
+ connect(m_channel.data(), SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)), SLOT(onChannelInvalidated()));
+
+ QString serviceName;
+ if (Tp::StreamTubeChannelPtr streamTube = Tp::StreamTubeChannelPtr::dynamicCast(channel)) {
+ kDebug() << " Service:" << streamTube->service();
+ serviceName = streamTube->service();
+ } else if (Tp::DBusTubeChannelPtr dbusTube = Tp::DBusTubeChannelPtr::dynamicCast(channel)) {
+ kDebug() << " Service name:" << dbusTube->serviceName();
+ serviceName = dbusTube->serviceName();
+ }
+
+ KService::List services = KServiceTypeTrader::self()->query(QLatin1String("KTpApprover"));
+ kDebug() << "Found" << services.count() << "KTpApprover services";
+ if (services.isEmpty()) {
+ showNotification(i18n("Unknown Incoming Tube"), i18n("Incoming tube from %1 of an unknown type"),
+ QLatin1String("dialog-warning"), channel->initiatorContact());
+ return;
+ }
+
+ Q_FOREACH(const KService::Ptr &service, services) {
+ if ((service->property(QLatin1String("X-KTp-ChannelType")) != channel->channelType()) ||
+ (service->property(QLatin1String("X-KTp-Service")) != serviceName)) {
+ continue;
+ }
+
+ m_service = service;
+ }
+
+ if (!m_service) {
+ kDebug() << "No service to match" << channel->channelType() << "," << serviceName;
+ showNotification(i18n("Incoming Request"), i18n("%1 wants to start a remote service with you"),
+ QLatin1String("dialog-warning"), channel->initiatorContact());
+ return;
+ }
+
+ showNotification(m_service->name(), m_service->comment(), m_service->icon(), channel->initiatorContact());
+}
+
+TubeChannelApprover::~TubeChannelApprover()
+{
+ kDebug();
+
+ //destroy the notification
+ if (m_notification) {
+ m_notification.data()->close();
+ }
+
+ if (m_notifierItem) {
+ m_notifierItem.data()->deleteLater();
+ }
+}
+
+void TubeChannelApprover::showNotification(const QString& title, const QString& comment, const QString& icon, const Tp::ContactPtr& sender)
+{
+ // incoming_file_transfer = defines notification sound & user preferences
+ m_notification = new KNotification(QLatin1String("incoming_file_transfer"));
+ KAboutData aboutData("ktelepathy", 0, KLocalizedString(), 0);
+ m_notification.data()->setComponentData(KComponentData(aboutData));
+ m_notification.data()->setTitle(title);
+ if (comment.contains(QLatin1String("%1"))) {
+ Q_ASSERT(sender);
+ m_notification.data()->setText(comment.arg(sender->alias()));
+ } else {
+ m_notification.data()->setText(comment);
+ }
+ m_notification.data()->setPixmap(KIcon(icon).pixmap(32, 32));
+ m_notification.data()->setActions(QStringList() << i18n("Accept") << i18n("Reject"));
+ connect(m_notification.data(), SIGNAL(action1Activated()), SIGNAL(channelAccepted()));
+ connect(m_notification.data(), SIGNAL(action2Activated()), SIGNAL(channelRejected()));
+
+ m_notification.data()->sendEvent();
+
+ //tray icon
+ m_notifierItem = new KStatusNotifierItem;
+ m_notifierItem.data()->setCategory(KStatusNotifierItem::Communications);
+ m_notifierItem.data()->setStatus(KStatusNotifierItem::NeedsAttention);
+ m_notifierItem.data()->setIconByName(icon);
+ m_notifierItem.data()->setStandardActionsEnabled(false);
+ m_notifierItem.data()->setTitle(title);
+ m_notifierItem.data()->setToolTip(QLatin1String("document-save"),
+ i18n("Incoming %1 request from %2", title, sender->alias()),
+ QString());
+ m_notifierItem.data()->contextMenu()->addAction(i18n("Accept"), this, SIGNAL(channelAccepted()));
+ m_notifierItem.data()->contextMenu()->addAction(i18n("Reject"), this, SIGNAL(channelRejected()));
+ connect(this, SIGNAL(channelAccepted()), SLOT(onChannelAccepted()));
+}
+
+void TubeChannelApprover::onChannelAccepted()
+{
+ //destroy the notification
+ if (m_notification) {
+ m_notification.data()->close();
+ }
+
+ if (m_service->property(QLatin1String("X-KTp-Cancellable")).toBool()) {
+ m_notifierItem.data()->setTitle(i18n("%1 share with %2", m_service->name(), m_channel->initiatorContact()->alias()));
+ //set new menu to an entry to close the channel
+ m_notifierItem.data()->contextMenu()->clear();
+ m_notifierItem.data()->contextMenu()->addAction(KIcon("dialog-close"), i18n("Stop %1 Sharing", m_service->name()),
+ this, SLOT(onChannelCloseRequested()));
+ } else {
+ m_notifierItem.data()->deleteLater();
+ }
+}
+
+void TubeChannelApprover::onChannelCloseRequested()
+{
+ m_channel->requestClose();
+}
+
+void TubeChannelApprover::onChannelInvalidated()
+{
+ deleteLater();
+}
\ No newline at end of file
diff --git a/src/streamtubechannelapprover.h b/src/tubechannelapprover.h
similarity index 57%
rename from src/streamtubechannelapprover.h
rename to src/tubechannelapprover.h
index aefe992..a4dbab6 100644
--- a/src/streamtubechannelapprover.h
+++ b/src/tubechannelapprover.h
@@ -1,5 +1,6 @@
/*
Copyright (C) 2012 David Edmundson <kde at davidedmundson.co.uk>
+ Copyright (C) 2013 Dan Vrátil <dvratil at redhat.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
@@ -14,32 +15,38 @@
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 STREAMTUBECHANNELAPPROVER_H
-#define STREAMTUBECHANNELAPPROVER_H
+#ifndef TUBECHANNELAPPROVER_H
+#define TUBECHANNELAPPROVER_H
#include "channelapprover.h"
-#include <QtCore/QSharedPointer>
-#include <TelepathyQt/StreamTubeChannel>
+
+#include <KNotification>
+#include <KService>
+#include <TelepathyQt/TubeChannel>
class KStatusNotifierItem;
-class KNotification;
-class StreamTubeChannelApprover : public ChannelApprover
+class TubeChannelApprover : public ChannelApprover
{
Q_OBJECT
-public:
- StreamTubeChannelApprover(const Tp::StreamTubeChannelPtr & channel, QObject *parent);
- virtual ~StreamTubeChannelApprover();
-private Q_SLOTS:
+
+ public:
+ TubeChannelApprover(const Tp::TubeChannelPtr &channel, QObject* parent);
+ virtual ~TubeChannelApprover();
+
+ private Q_SLOTS:
void onChannelAccepted();
void onChannelCloseRequested();
void onChannelInvalidated();
-private:
+ private:
+ void showNotification(const QString &title, const QString &comment, const QString &icon,
+ const Tp::ContactPtr &sender);
+
+ Tp::TubeChannelPtr m_channel;
QWeakPointer<KNotification> m_notification;
- KStatusNotifierItem *m_notifierItem;
- Tp::StreamTubeChannelPtr m_channel;
- QString m_serviceName;
+ QWeakPointer<KStatusNotifierItem> m_notifierItem;
+ KService::Ptr m_service;
};
-#endif //STREAMTUBECHANNELAPPROVER_H
+#endif // TUBECHANNELAPPROVER_H
--
ktp-approver packaging
More information about the pkg-kde-commits
mailing list