[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:12:48 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-filetransfer-handler.git;a=commitdiff;h=4c1f4a1
The following commit has been merged in the master branch:
commit 4c1f4a10caf9ad888ba728c3dfb74f47d200a3f4
Author: Àlex Fiestas <afiestas at kde.org>
Date: Mon Oct 28 17:56:53 2013 +0100
Implement speed calculation for incoming/out-going transfers
This is not done automagically by KJob so we have to implement it
by ourselves.
BUG: 326787
---
src/handle-incoming-file-transfer-channel-job.cpp | 6 +++---
src/handle-outgoing-file-transfer-channel-job.cpp | 6 +++---
src/telepathy-base-job.cpp | 23 +++++++++++++++++++++++
src/telepathy-base-job.h | 2 ++
src/telepathy-base-job_p.h | 3 +++
5 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/src/handle-incoming-file-transfer-channel-job.cpp b/src/handle-incoming-file-transfer-channel-job.cpp
index 91ffc73..36b8310 100644
--- a/src/handle-incoming-file-transfer-channel-job.cpp
+++ b/src/handle-incoming-file-transfer-channel-job.cpp
@@ -146,7 +146,7 @@ void HandleIncomingFileTransferChannelJobPrivate::init()
q->setCapabilities(KJob::Killable);
q->setTotalAmount(KJob::Bytes, channel->size());
- q->setProcessedAmount(KJob::Bytes, 0);
+ q->setProcessedAmountAndCalculateSpeed(0);
q->connect(channel.data(),
SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
@@ -424,7 +424,7 @@ void HandleIncomingFileTransferChannelJobPrivate::__k__onInitialOffsetDefined(qu
this->offset = offset;
file->seek(offset);
- q->setProcessedAmount(KJob::Bytes, offset);
+ q->setProcessedAmountAndCalculateSpeed(offset);
}
void HandleIncomingFileTransferChannelJobPrivate::__k__onFileTransferChannelStateChanged(Tp::FileTransferState state,
@@ -484,7 +484,7 @@ void HandleIncomingFileTransferChannelJobPrivate::__k__onFileTransferChannelTran
kDebug().nospace() << "Receiving " << channel->fileName() << " - "
<< "transferred bytes" << " = " << offset + count << " ("
<< ((int)(((double)(offset + count) / channel->size()) * 100)) << "% done)";
- q->setProcessedAmount(KJob::Bytes, offset + count);
+ q->setProcessedAmountAndCalculateSpeed(offset + count);
}
void HandleIncomingFileTransferChannelJobPrivate::__k__onAcceptFileFinished(Tp::PendingOperation* op)
diff --git a/src/handle-outgoing-file-transfer-channel-job.cpp b/src/handle-outgoing-file-transfer-channel-job.cpp
index ce2fc6e..762bd12 100644
--- a/src/handle-outgoing-file-transfer-channel-job.cpp
+++ b/src/handle-outgoing-file-transfer-channel-job.cpp
@@ -145,7 +145,7 @@ void HandleOutgoingFileTransferChannelJobPrivate::init()
q->setCapabilities(KJob::Killable);
q->setTotalAmount(KJob::Bytes, channel->size());
- q->setProcessedAmount(KJob::Bytes, 0);
+ q->setProcessedAmountAndCalculateSpeed(0);
q->connect(channel.data(),
SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
@@ -205,7 +205,7 @@ void HandleOutgoingFileTransferChannelJobPrivate::__k__onInitialOffsetDefined(qu
Q_Q(HandleOutgoingFileTransferChannelJob);
this->offset = offset;
- q->setProcessedAmount(KJob::Bytes, offset);
+ q->setProcessedAmountAndCalculateSpeed(offset);
}
void HandleOutgoingFileTransferChannelJobPrivate::__k__onFileTransferChannelStateChanged(Tp::FileTransferState state,
@@ -266,7 +266,7 @@ void HandleOutgoingFileTransferChannelJobPrivate::__k__onFileTransferChannelTran
kDebug().nospace() << "Sending " << channel->fileName() << " - "
<< "Transferred bytes = " << offset + count << " ("
<< ((int)(((double)(offset + count) / channel->size()) * 100)) << "% done)";
- q->setProcessedAmount(KJob::Bytes, offset + count);
+ q->setProcessedAmountAndCalculateSpeed(offset + count);
}
void HandleOutgoingFileTransferChannelJobPrivate::__k__onProvideFileFinished(Tp::PendingOperation* op)
diff --git a/src/telepathy-base-job.cpp b/src/telepathy-base-job.cpp
index bba1231..3dab71e 100644
--- a/src/telepathy-base-job.cpp
+++ b/src/telepathy-base-job.cpp
@@ -29,6 +29,7 @@ using namespace KTp;
TelepathyBaseJobPrivate::TelepathyBaseJobPrivate()
: q_ptr(0)
+ , alreadyProcessed(0)
{
}
@@ -59,6 +60,28 @@ TelepathyBaseJob::~TelepathyBaseJob()
delete d_ptr;
}
+void TelepathyBaseJob::setProcessedAmountAndCalculateSpeed(qulonglong amount)
+{
+ kDebug() << amount;
+ Q_D(TelepathyBaseJob);
+
+ //If the transfer is starting
+ if (amount == 0) {
+ d->time = QTime::currentTime();
+ }
+
+ //If a least 1 second has passed since last update
+ int secondsSinceLastTime = d->time.secsTo(QTime::currentTime());
+ if (secondsSinceLastTime > 0) {
+ float speed = (amount - d->alreadyProcessed) / secondsSinceLastTime;
+ emitSpeed(speed);
+
+ d->time = QTime::currentTime();
+ d->alreadyProcessed = amount;
+ }
+ setProcessedAmount(Bytes, amount);
+}
+
void TelepathyBaseJobPrivate::__k__tpOperationFinished(Tp::PendingOperation* op)
{
// First of all check if the operation is in our list
diff --git a/src/telepathy-base-job.h b/src/telepathy-base-job.h
index d4d3003..66fab23 100644
--- a/src/telepathy-base-job.h
+++ b/src/telepathy-base-job.h
@@ -96,6 +96,8 @@ protected:
explicit TelepathyBaseJob(TelepathyBaseJobPrivate &dd, QObject *parent = 0);
virtual ~TelepathyBaseJob();
+ void setProcessedAmountAndCalculateSpeed(qulonglong amount);
+
TelepathyBaseJobPrivate * const d_ptr;
};
diff --git a/src/telepathy-base-job_p.h b/src/telepathy-base-job_p.h
index 5840e52..455ac2a 100644
--- a/src/telepathy-base-job_p.h
+++ b/src/telepathy-base-job_p.h
@@ -22,6 +22,7 @@
#include "telepathy-base-job.h"
+#include <QTime>
namespace Tp
{
@@ -42,6 +43,8 @@ public:
TelepathyBaseJobPrivate();
virtual ~TelepathyBaseJobPrivate();
+ QTime time;
+ qulonglong alreadyProcessed;
QList< Tp::PendingOperation* > operations;
QList< QPair< QString, QString > > telepathyErrors;
--
ktp-filetransfer-handler packaging
More information about the pkg-kde-commits
mailing list