Make the origin also contain the file name, not only the device name

This commit is contained in:
Albert Vaca 2015-10-17 13:32:57 -07:00
parent 53e6381d30
commit 4574aa3639
3 changed files with 9 additions and 10 deletions

View file

@ -33,7 +33,7 @@ FileTransferJob::FileTransferJob(const QSharedPointer<QIODevice>& origin, qint64
: KJob() : KJob()
, mOrigin(origin) , mOrigin(origin)
, mReply(Q_NULLPTR) , mReply(Q_NULLPTR)
, mDeviceName("KDE Connect") //TODO: Actually fetch the device name , mFrom("KDE Connect")
, mDestination(destination) , mDestination(destination)
, mSpeedBytes(0) , mSpeedBytes(0)
, mWritten(0) , mWritten(0)
@ -47,6 +47,7 @@ FileTransferJob::FileTransferJob(const QSharedPointer<QIODevice>& origin, qint64
if (size >= 0) { if (size >= 0) {
setTotalAmount(Bytes, size); setTotalAmount(Bytes, size);
} }
setCapabilities(Killable); setCapabilities(Killable);
qCDebug(KDECONNECT_CORE) << "FileTransferJob Downloading payload to" << destination; qCDebug(KDECONNECT_CORE) << "FileTransferJob Downloading payload to" << destination;
} }
@ -59,9 +60,8 @@ void FileTransferJob::start()
void FileTransferJob::doStart() void FileTransferJob::doStart()
{ {
description(this, i18n("Receiving file over KDE-Connect"), description(this, i18n("Receiving file over KDE Connect"),
QPair<QString, QString>(i18nc("File transfer origin", "From"), QPair<QString, QString>(i18nc("File transfer origin", "From"), mFrom)
mDeviceName)
); );
if (mDestination.isLocalFile() && QFile::exists(mDestination.toLocalFile())) { if (mDestination.isLocalFile() && QFile::exists(mDestination.toLocalFile())) {
@ -77,9 +77,8 @@ void FileTransferJob::startTransfer()
{ {
setProcessedAmount(Bytes, 0); setProcessedAmount(Bytes, 0);
mTime = QTime::currentTime(); mTime = QTime::currentTime();
description(this, i18n("Receiving file over KDE-Connect"), description(this, i18n("Receiving file over KDE Connect"),
QPair<QString, QString>(i18nc("File transfer origin", "From"), QPair<QString, QString>(i18nc("File transfer origin", "From"), mFrom),
mDeviceName),
QPair<QString, QString>(i18nc("File transfer destination", "To"), mDestination.toLocalFile())); QPair<QString, QString>(i18nc("File transfer destination", "To"), mDestination.toLocalFile()));
QNetworkRequest req(mDestination); QNetworkRequest req(mDestination);

View file

@ -53,7 +53,7 @@ public:
FileTransferJob(const QSharedPointer<QIODevice>& origin, qint64 size, const QUrl &destination); FileTransferJob(const QSharedPointer<QIODevice>& origin, qint64 size, const QUrl &destination);
virtual void start() Q_DECL_OVERRIDE; virtual void start() Q_DECL_OVERRIDE;
QUrl destination() const { return mDestination; } QUrl destination() const { return mDestination; }
void setDeviceName(const QString &deviceName) { mDeviceName = deviceName; } void setOriginName(QString from) { mFrom = from; }
private Q_SLOTS: private Q_SLOTS:
void doStart(); void doStart();
@ -67,7 +67,7 @@ private:
QSharedPointer<QIODevice> mOrigin; QSharedPointer<QIODevice> mOrigin;
QNetworkReply* mReply; QNetworkReply* mReply;
QString mDeviceName; QString mFrom;
QUrl mDestination; QUrl mDestination;
QTime mTime; QTime mTime;
qulonglong mSpeedBytes; qulonglong mSpeedBytes;

View file

@ -96,7 +96,7 @@ bool SharePlugin::receivePackage(const NetworkPackage& np)
} }
FileTransferJob* job = np.createPayloadTransferJob(destination); FileTransferJob* job = np.createPayloadTransferJob(destination);
job->setDeviceName(device()->name()); job->setOriginName(device()->name() + ": " + filename);
connect(job, SIGNAL(result(KJob*)), this, SLOT(finished(KJob*))); connect(job, SIGNAL(result(KJob*)), this, SLOT(finished(KJob*)));
KIO::getJobTracker()->registerJob(job); KIO::getJobTracker()->registerJob(job);
job->start(); job->start();