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


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

The following commit has been merged in the master branch:
commit 07cb4007ddf96324e78203d90a7d391989bf4fd3
Author: George Kiagiadakis <george.kiagiadakis at collabora.co.uk>
Date:   Mon May 2 18:16:06 2011 +0300

    Add support for approving incoming file transfer channels.
---
 src/CMakeLists.txt                                 |  1 +
 src/channelapprover.cpp                            |  7 ++
 src/filetransferchannelapprover.cpp                | 89 ++++++++++++++++++++++
 ...nelapprover.h => filetransferchannelapprover.h} | 26 +++----
 src/tpkdeapprovermodule.cpp                        |  3 +
 5 files changed, 109 insertions(+), 17 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 498b4da..05956d4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,6 +5,7 @@ set(telepathy_kde_approver_SRCS
     handlewithcaller.cpp
     channelapprover.cpp
     textchannelapprover.cpp
+    filetransferchannelapprover.cpp
 )
 
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/src/channelapprover.cpp b/src/channelapprover.cpp
index 917058e..310405c 100644
--- a/src/channelapprover.cpp
+++ b/src/channelapprover.cpp
@@ -17,6 +17,7 @@
 */
 #include "channelapprover.h"
 #include "textchannelapprover.h"
+#include "filetransferchannelapprover.h"
 
 ChannelApprover *ChannelApprover::create(const Tp::ChannelPtr & channel, QObject *parent)
 {
@@ -24,6 +25,12 @@ ChannelApprover *ChannelApprover::create(const Tp::ChannelPtr & channel, QObject
         return new TextChannelApprover(Tp::TextChannelPtr::dynamicCast(channel), parent);
     }
 
+    if (channel->channelType() == TP_QT4_IFACE_CHANNEL_TYPE_FILE_TRANSFER) {
+        return new FileTransferChannelApprover(
+                Tp::FileTransferChannelPtr::dynamicCast(channel),
+                parent);
+    }
+
     Q_ASSERT(false);
     return NULL;
 }
diff --git a/src/filetransferchannelapprover.cpp b/src/filetransferchannelapprover.cpp
new file mode 100644
index 0000000..2e2e070
--- /dev/null
+++ b/src/filetransferchannelapprover.cpp
@@ -0,0 +1,89 @@
+/*
+    Copyright (C) 2010-2011 Collabora Ltd. <info at collabora.co.uk>
+      @author George Kiagiadakis <george.kiagiadakis at collabora.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 "filetransferchannelapprover.h"
+#include <KNotification>
+#include <KStatusNotifierItem>
+#include <KLocale>
+#include <KDebug>
+#include <KAboutData>
+#include <KActionCollection>
+#include <KMenu>
+#include <TelepathyQt4/AvatarData>
+#include <TelepathyQt4/Contact>
+
+FileTransferChannelApprover::FileTransferChannelApprover(
+        const Tp::FileTransferChannelPtr & channel,
+        QObject *parent)
+    : ChannelApprover(parent)
+{
+    kDebug();
+
+    //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"));
+
+    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>",
+                                        sender->alias(),
+                                        channel->fileName()));
+
+    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("document-save"));
+    m_notifierItem->setAttentionIconByName(QLatin1String("mail-unread-new"));
+    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()),
+                               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()));
+}
+
+FileTransferChannelApprover::~FileTransferChannelApprover()
+{
+    kDebug();
+
+    //destroy the notification
+    if (m_notification) {
+        m_notification.data()->close();
+    }
+
+    //destroy the tray icon
+    delete m_notifierItem;
+}
+
+#include "filetransferchannelapprover.moc"
diff --git a/src/textchannelapprover.h b/src/filetransferchannelapprover.h
similarity index 58%
copy from src/textchannelapprover.h
copy to src/filetransferchannelapprover.h
index b6301f7..003dcd8 100644
--- a/src/textchannelapprover.h
+++ b/src/filetransferchannelapprover.h
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2010 Collabora Ltd. <info at collabora.co.uk>
+    Copyright (C) 2010-2011 Collabora Ltd. <info at collabora.co.uk>
       @author George Kiagiadakis <george.kiagiadakis at collabora.co.uk>
 
     This library is free software; you can redistribute it and/or modify
@@ -15,34 +15,26 @@
     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 TEXTCHANNELAPPROVER_H
-#define TEXTCHANNELAPPROVER_H
+#ifndef FILETRANSFERCHANNELAPPROVER_H
+#define FILETRANSFERCHANNELAPPROVER_H
 
 #include "channelapprover.h"
-#include <QtCore/QSet>
 #include <QtCore/QSharedPointer>
-#include <TelepathyQt4/TextChannel>
-#include <TelepathyQt4/ReceivedMessage>
+#include <TelepathyQt4/IncomingFileTransferChannel>
 
 class KStatusNotifierItem;
 class KNotification;
 
-class TextChannelApprover : public ChannelApprover
+class FileTransferChannelApprover : public ChannelApprover
 {
     Q_OBJECT
 public:
-    TextChannelApprover(const Tp::TextChannelPtr & channel, QObject *parent);
-    virtual ~TextChannelApprover();
-
-private Q_SLOTS:
-    void onMessageReceived(const Tp::ReceivedMessage & msg);
+    FileTransferChannelApprover(const Tp::FileTransferChannelPtr & channel, QObject *parent);
+    virtual ~FileTransferChannelApprover();
 
 private:
-    static QSharedPointer<KStatusNotifierItem> getNotifierItem();
-    void updateNotifierItemTooltip();
-
     QWeakPointer<KNotification> m_notification;
-    QSharedPointer<KStatusNotifierItem> m_notifierItem;
+    KStatusNotifierItem *m_notifierItem;
 };
 
-#endif //TEXTCHANNELAPPROVER_H
+#endif //FILETRANSFERCHANNELAPPROVER_H
diff --git a/src/tpkdeapprovermodule.cpp b/src/tpkdeapprovermodule.cpp
index 5c95066..b9fcf72 100644
--- a/src/tpkdeapprovermodule.cpp
+++ b/src/tpkdeapprovermodule.cpp
@@ -28,6 +28,7 @@
 #include <TelepathyQt4/ClientRegistrar>
 #include <TelepathyQt4/Channel>
 #include <TelepathyQt4/TextChannel>
+#include <TelepathyQt4/IncomingFileTransferChannel>
 
 class TpKDEApproverModule : public KDEDModule
 {
@@ -52,6 +53,8 @@ public:
         channelFactory->addFeaturesForTextChats(Tp::Features()
                                                     << Tp::TextChannel::FeatureCore
                                                     << Tp::TextChannel::FeatureMessageQueue);
+        channelFactory->addFeaturesForIncomingFileTransfers(
+                Tp::IncomingFileTransferChannel::FeatureCore);
 
         Tp::ContactFactoryPtr contactFactory =
             Tp::ContactFactory::create(Tp::Features()

-- 
ktp-approver packaging



More information about the pkg-kde-commits mailing list