[SCM] ktp-filetransfer-handler packaging branch, master, updated. debian/15.12.1-2-226-g825cd93

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:11:39 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-filetransfer-handler.git;a=commitdiff;h=5ef7aaa

The following commit has been merged in the master branch:
commit 5ef7aaa2e01304ce99697bcdad7d3170d3d2a2ec
Author: Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
Date:   Wed Sep 28 19:34:58 2011 +0100

    Make FileTransferJobs killable
    
    FEATURE: 282696
---
 src/handle-incoming-file-transfer-channel-job.cpp | 32 +++++++++++++++++++++++
 src/handle-incoming-file-transfer-channel-job.h   |  2 ++
 src/handle-outgoing-file-transfer-channel-job.cpp | 32 +++++++++++++++++++++++
 src/handle-outgoing-file-transfer-channel-job.h   |  2 ++
 src/telepathy-base-job.h                          |  2 ++
 5 files changed, 70 insertions(+)

diff --git a/src/handle-incoming-file-transfer-channel-job.cpp b/src/handle-incoming-file-transfer-channel-job.cpp
index efe8fc2..c94ba91 100644
--- a/src/handle-incoming-file-transfer-channel-job.cpp
+++ b/src/handle-incoming-file-transfer-channel-job.cpp
@@ -50,6 +50,7 @@ class HandleIncomingFileTransferChannelJobPrivate : public KTelepathy::Telepathy
         void __k__onFileTransferChannelStateChanged(Tp::FileTransferState state, Tp::FileTransferStateChangeReason reason);
         void __k__onFileTransferChannelTransferredBytesChanged(qulonglong count);
         void __k__onAcceptFileFinished(Tp::PendingOperation* op);
+        void __k__onCancelOperationFinished(Tp::PendingOperation* op);
         void __k__onInvalidated();
 
         bool transferCompleted;
@@ -78,6 +79,8 @@ HandleIncomingFileTransferChannelJob::HandleIncomingFileTransferChannelJob(Tp::I
         setErrorText(i18n("Channel is not ready"));
     }
 
+    setCapabilities(KJob::Killable);
+
     d->channel = channel;
     d->downloadDirectory = downloadDirectory;
 }
@@ -93,6 +96,19 @@ void HandleIncomingFileTransferChannelJob::start()
     QTimer::singleShot(0, this, SLOT(__k__start()));
 }
 
+bool HandleIncomingFileTransferChannelJob::doKill()
+{
+    kDebug();
+    Q_D(HandleIncomingFileTransferChannelJob);
+
+    //TODO suspend the transfer?
+    Tp::PendingOperation *cancelOperation = d->channel->cancel();
+    connect(cancelOperation,
+            SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(__k__onCancelOperationFinished(Tp::PendingOperation*)));
+    return true;
+}
+
 HandleIncomingFileTransferChannelJobPrivate::HandleIncomingFileTransferChannelJobPrivate()
     : file(0)
 {
@@ -249,6 +265,22 @@ void HandleIncomingFileTransferChannelJobPrivate::__k__onAcceptFileFinished(Tp::
     }
 }
 
+void HandleIncomingFileTransferChannelJobPrivate::__k__onCancelOperationFinished(Tp::PendingOperation* op)
+{
+    kDebug();
+    Q_Q(HandleIncomingFileTransferChannelJob);
+
+    if (op->isError()) {
+        kWarning() << "Unable to cancel file transfer - " <<
+            op->errorName() << ":" << op->errorMessage();
+        q->setError(KTelepathy::CancelFileTransferError);
+        q->setErrorText(i18n("Cannot cancel file transfer"));
+    }
+
+    kDebug() << "File transfer cancelled";
+    QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
+}
+
 void HandleIncomingFileTransferChannelJobPrivate::__k__onInvalidated()
 {
     kDebug();
diff --git a/src/handle-incoming-file-transfer-channel-job.h b/src/handle-incoming-file-transfer-channel-job.h
index eac51dd..ed2d7f1 100644
--- a/src/handle-incoming-file-transfer-channel-job.h
+++ b/src/handle-incoming-file-transfer-channel-job.h
@@ -42,6 +42,7 @@ class HandleIncomingFileTransferChannelJob : public KTelepathy::TelepathyBaseJob
     Q_PRIVATE_SLOT(d_func(), void __k__onFileTransferChannelStateChanged(Tp::FileTransferState state, Tp::FileTransferStateChangeReason reason))
     Q_PRIVATE_SLOT(d_func(), void __k__onFileTransferChannelTransferredBytesChanged(qulonglong count))
     Q_PRIVATE_SLOT(d_func(), void __k__onAcceptFileFinished(Tp::PendingOperation* op))
+    Q_PRIVATE_SLOT(d_func(), void __k__onCancelOperationFinished(Tp::PendingOperation* op))
     Q_PRIVATE_SLOT(d_func(), void __k__onInvalidated())
 
 public:
@@ -51,6 +52,7 @@ public:
     virtual ~HandleIncomingFileTransferChannelJob();
 
     virtual void start();
+    virtual bool doKill();
 };
 
 
diff --git a/src/handle-outgoing-file-transfer-channel-job.cpp b/src/handle-outgoing-file-transfer-channel-job.cpp
index 37aac16..b40b42b 100644
--- a/src/handle-outgoing-file-transfer-channel-job.cpp
+++ b/src/handle-outgoing-file-transfer-channel-job.cpp
@@ -46,6 +46,7 @@ class HandleOutgoingFileTransferChannelJobPrivate : public KTelepathy::Telepathy
         void __k__provideFile();
         void __k__onFileTransferChannelTransferredBytesChanged(qulonglong count);
         void __k__onProvideFileFinished(Tp::PendingOperation* op);
+        void __k__onCancelOperationFinished(Tp::PendingOperation* op);
         void __k__onInvalidated();
 };
 
@@ -75,6 +76,8 @@ HandleOutgoingFileTransferChannelJob::HandleOutgoingFileTransferChannelJob(Tp::O
             SIGNAL(invalidated(Tp::DBusProxy *, const QString &, const QString &)),
             SLOT(__k__onInvalidated()));
 
+    setCapabilities(KJob::Killable);
+
     d->channel = channel;
 }
 
@@ -89,6 +92,19 @@ void HandleOutgoingFileTransferChannelJob::start()
     QTimer::singleShot(0, this, SLOT(__k__start()));
 }
 
+bool HandleOutgoingFileTransferChannelJob::doKill()
+{
+    kDebug();
+    Q_D(HandleOutgoingFileTransferChannelJob);
+
+    //TODO suspend the transfer?
+    Tp::PendingOperation *cancelOperation = d->channel->cancel();
+    connect(cancelOperation,
+            SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(__k__onCancelOperationFinished(Tp::PendingOperation*)));
+    return true;
+}
+
 HandleOutgoingFileTransferChannelJobPrivate::HandleOutgoingFileTransferChannelJobPrivate()
     : file(0)
 {
@@ -216,6 +232,22 @@ void HandleOutgoingFileTransferChannelJobPrivate::__k__onProvideFileFinished(Tp:
     }
 }
 
+void HandleOutgoingFileTransferChannelJobPrivate::__k__onCancelOperationFinished(Tp::PendingOperation* op)
+{
+    kDebug();
+    Q_Q(HandleOutgoingFileTransferChannelJob);
+
+    if (op->isError()) {
+        kWarning() << "Unable to cancel file transfer - " <<
+            op->errorName() << ":" << op->errorMessage();
+        q->setError(KTelepathy::CancelFileTransferError);
+        q->setErrorText(i18n("Cannot cancel file transfer"));
+    }
+
+    kDebug() << "File transfer cancelled";
+    QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
+}
+
 void HandleOutgoingFileTransferChannelJobPrivate::__k__onInvalidated()
 {
     kDebug();
diff --git a/src/handle-outgoing-file-transfer-channel-job.h b/src/handle-outgoing-file-transfer-channel-job.h
index 6084658..cde516c 100644
--- a/src/handle-outgoing-file-transfer-channel-job.h
+++ b/src/handle-outgoing-file-transfer-channel-job.h
@@ -42,6 +42,7 @@ class HandleOutgoingFileTransferChannelJob : public KTelepathy::TelepathyBaseJob
     Q_PRIVATE_SLOT(d_func(), void __k__provideFile())
     Q_PRIVATE_SLOT(d_func(), void __k__onFileTransferChannelTransferredBytesChanged(qulonglong count))
     Q_PRIVATE_SLOT(d_func(), void __k__onProvideFileFinished(Tp::PendingOperation* op))
+    Q_PRIVATE_SLOT(d_func(), void __k__onCancelOperationFinished(Tp::PendingOperation* op))
     Q_PRIVATE_SLOT(d_func(), void __k__onInvalidated())
 
 public:
@@ -50,6 +51,7 @@ public:
     virtual ~HandleOutgoingFileTransferChannelJob();
 
     virtual void start();
+    virtual bool doKill();
 };
 
 
diff --git a/src/telepathy-base-job.h b/src/telepathy-base-job.h
index a613c5a..b58e115 100644
--- a/src/telepathy-base-job.h
+++ b/src/telepathy-base-job.h
@@ -73,6 +73,8 @@ namespace KTelepathy {
         NotALocalFile = 114,
         /** Cannot provide file */
         ProvideFileError = 115,
+        /** Cannot cancel file transfer */
+        CancelFileTransferError = 116,
         /** Telepathy triggered an error */
         TelepathyErrorError = 200,
         /** KTelepathy Error */

-- 
ktp-filetransfer-handler packaging



More information about the pkg-kde-commits mailing list