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


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

The following commit has been merged in the master branch:
commit fbccd5e8b96eccebb67669da12dec44326304299
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Mon Apr 2 02:00:12 2012 +0100

    Add a basic approver for streamtubes.
    
    Currently this only handles x-ssh-contact, and it's hardcoded to support just the one tube.
    It shows an icon whilst the session is in progress, so the user can cancel it at any time.
    
    REVIEW: 104465
    BUG: 295916
---
 src/CMakeLists.txt                                 |  1 +
 src/approverdaemon.cpp                             |  1 +
 src/channelapprover.cpp                            |  7 +++
 src/ktpapprovermodule.cpp                          |  5 ++
 ...lapprover.cpp => streamtubechannelapprover.cpp} | 68 ++++++++++++++++------
 ...annelapprover.h => streamtubechannelapprover.h} | 23 +++++---
 6 files changed, 78 insertions(+), 27 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1d6f697..a1ce660 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,6 +6,7 @@ set(ktp_approver_SRCS
     channelapprover.cpp
     textchannelapprover.cpp
     filetransferchannelapprover.cpp
+    streamtubechannelapprover.cpp
 )
 
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/src/approverdaemon.cpp b/src/approverdaemon.cpp
index d8239b7..776a0a2 100644
--- a/src/approverdaemon.cpp
+++ b/src/approverdaemon.cpp
@@ -27,6 +27,7 @@ static inline Tp::ChannelClassSpecList channelClassSpecList()
                 << Tp::ChannelClassSpec::unnamedTextChat()
                 << Tp::ChannelClassSpec::textChatroom()
                 << Tp::ChannelClassSpec::incomingFileTransfer()
+                << Tp::ChannelClassSpec::incomingStreamTube("x-ssh-contact")
                 ;
 }
 
diff --git a/src/channelapprover.cpp b/src/channelapprover.cpp
index 4130a86..5d4b02b 100644
--- a/src/channelapprover.cpp
+++ b/src/channelapprover.cpp
@@ -16,8 +16,10 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "channelapprover.h"
+
 #include "textchannelapprover.h"
 #include "filetransferchannelapprover.h"
+#include "streamtubechannelapprover.h"
 
 ChannelApprover *ChannelApprover::create(const Tp::ChannelPtr & channel, QObject *parent)
 {
@@ -31,6 +33,11 @@ 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);
+    }
+
     Q_ASSERT(false);
     return NULL;
 }
diff --git a/src/ktpapprovermodule.cpp b/src/ktpapprovermodule.cpp
index 307b13e..9dae57e 100644
--- a/src/ktpapprovermodule.cpp
+++ b/src/ktpapprovermodule.cpp
@@ -29,6 +29,8 @@
 #include <TelepathyQt/Channel>
 #include <TelepathyQt/TextChannel>
 #include <TelepathyQt/IncomingFileTransferChannel>
+#include <TelepathyQt/IncomingStreamTubeChannel>
+
 
 class KTpApproverModule : public KDEDModule
 {
@@ -56,6 +58,9 @@ public:
         channelFactory->addFeaturesForIncomingFileTransfers(
                 Tp::IncomingFileTransferChannel::FeatureCore);
 
+        channelFactory->addFeaturesForIncomingStreamTubes(
+                    Tp::IncomingStreamTubeChannel::FeatureCore);
+
         Tp::ContactFactoryPtr contactFactory =
             Tp::ContactFactory::create(Tp::Features()
                                         << Tp::Contact::FeatureAlias
diff --git a/src/filetransferchannelapprover.cpp b/src/streamtubechannelapprover.cpp
similarity index 55%
copy from src/filetransferchannelapprover.cpp
copy to src/streamtubechannelapprover.cpp
index f4ddc40..3d113f8 100644
--- a/src/filetransferchannelapprover.cpp
+++ b/src/streamtubechannelapprover.cpp
@@ -1,6 +1,5 @@
 /*
-    Copyright (C) 2010-2011 Collabora Ltd. <info at collabora.co.uk>
-      @author George Kiagiadakis <george.kiagiadakis at collabora.co.uk>
+    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
@@ -15,7 +14,8 @@
     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 "filetransferchannelapprover.h"
+#include "streamtubechannelapprover.h"
+
 #include <KNotification>
 #include <KStatusNotifierItem>
 #include <KLocale>
@@ -23,28 +23,38 @@
 #include <KAboutData>
 #include <KActionCollection>
 #include <KMenu>
+#include <KIcon>
+
 #include <TelepathyQt/AvatarData>
 #include <TelepathyQt/Contact>
 
-FileTransferChannelApprover::FileTransferChannelApprover(
-        const Tp::FileTransferChannelPtr & channel,
+StreamTubeChannelApprover::StreamTubeChannelApprover(
+        const Tp::StreamTubeChannelPtr & channel,
         QObject *parent)
-    : ChannelApprover(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)
 {
     kDebug();
 
+    connect(m_channel.data(), SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)), SLOT(onChannelInvalidated()));
+
+    if (m_channel->service() == QLatin1String("x-ssh-contact")) {
+        m_serviceName = i18n("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 file transfer"));
+    m_notification.data()->setTitle(i18n("Incoming %1 share request", m_serviceName));
 
     Tp::ContactPtr sender = channel->initiatorContact();
-    m_notification.data()->setText(i18n("<p>%1 is sending you a file. "
-                                        "Do you accept the file transfer?</p>"
-                                        "<p><i>Filename:</i> %2</p>",
+    m_notification.data()->setText(i18n("<p>%1 wants to start a %2 sharing session with you</p>",
                                         sender->alias(),
-                                        channel->fileName()));
+                                        m_serviceName));
 
     QPixmap pixmap;
     if (pixmap.load(sender->avatarData().fileName)) {
@@ -61,19 +71,19 @@ FileTransferChannelApprover::FileTransferChannelApprover(
     m_notifierItem = new KStatusNotifierItem;
     m_notifierItem->setCategory(KStatusNotifierItem::Communications);
     m_notifierItem->setStatus(KStatusNotifierItem::NeedsAttention);
-    m_notifierItem->setIconByName(QLatin1String("document-save"));
-    m_notifierItem->setAttentionIconByName(QLatin1String("mail-unread-new"));
+    m_notifierItem->setIconByName(QLatin1String("utilities-terminal"));
     m_notifierItem->setStandardActionsEnabled(false);
     m_notifierItem->setTitle(i18n("Incoming file transfer"));
     m_notifierItem->setToolTip(QLatin1String("document-save"),
-                               i18n("Incoming file transfer from %1", sender->alias()),
+                               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()));
+//    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()));
 }
 
-FileTransferChannelApprover::~FileTransferChannelApprover()
+StreamTubeChannelApprover::~StreamTubeChannelApprover()
 {
     kDebug();
 
@@ -83,7 +93,29 @@ FileTransferChannelApprover::~FileTransferChannelApprover()
     }
 
     //destroy the tray icon
-    delete m_notifierItem;
+    m_notifierItem->deleteLater();
+}
+
+void StreamTubeChannelApprover::onChannelAccepted()
+{
+    //destroy the notification
+    if (m_notification) {
+        m_notification.data()->close();
+    }
+
+    //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 "filetransferchannelapprover.moc"
+#include "streamtubechannelapprover.moc"
diff --git a/src/filetransferchannelapprover.h b/src/streamtubechannelapprover.h
similarity index 60%
copy from src/filetransferchannelapprover.h
copy to src/streamtubechannelapprover.h
index 8b5a1d4..aefe992 100644
--- a/src/filetransferchannelapprover.h
+++ b/src/streamtubechannelapprover.h
@@ -1,6 +1,5 @@
 /*
-    Copyright (C) 2010-2011 Collabora Ltd. <info at collabora.co.uk>
-      @author George Kiagiadakis <george.kiagiadakis at collabora.co.uk>
+    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
@@ -15,26 +14,32 @@
     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 FILETRANSFERCHANNELAPPROVER_H
-#define FILETRANSFERCHANNELAPPROVER_H
+#ifndef STREAMTUBECHANNELAPPROVER_H
+#define STREAMTUBECHANNELAPPROVER_H
 
 #include "channelapprover.h"
 #include <QtCore/QSharedPointer>
-#include <TelepathyQt/IncomingFileTransferChannel>
+#include <TelepathyQt/StreamTubeChannel>
 
 class KStatusNotifierItem;
 class KNotification;
 
-class FileTransferChannelApprover : public ChannelApprover
+class StreamTubeChannelApprover : public ChannelApprover
 {
     Q_OBJECT
 public:
-    FileTransferChannelApprover(const Tp::FileTransferChannelPtr & channel, QObject *parent);
-    virtual ~FileTransferChannelApprover();
+    StreamTubeChannelApprover(const Tp::StreamTubeChannelPtr & channel, QObject *parent);
+    virtual ~StreamTubeChannelApprover();
+private Q_SLOTS:
+    void onChannelAccepted();
+    void onChannelCloseRequested();
+    void onChannelInvalidated();
 
 private:
     QWeakPointer<KNotification> m_notification;
     KStatusNotifierItem *m_notifierItem;
+    Tp::StreamTubeChannelPtr m_channel;
+    QString m_serviceName;
 };
 
-#endif //FILETRANSFERCHANNELAPPROVER_H
+#endif //STREAMTUBECHANNELAPPROVER_H

-- 
ktp-approver packaging



More information about the pkg-kde-commits mailing list