Commit e20adde7 authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Moved filetransferjob from filetransfer plugin to networkpackage

parent acac5c36
......@@ -22,6 +22,7 @@ set(kded_kdeconnect_SRCS
plugins/pluginloader.cpp
networkpackage.cpp
filetransferjob.cpp
daemon.cpp
device.cpp
)
......
......@@ -33,6 +33,8 @@
#include <qjson/serializer.h>
#include <qjson/qobjecthelper.h>
#include "filetransferjob.h"
const QCA::EncryptionAlgorithm NetworkPackage::EncryptionAlgorithm = QCA::EME_PKCS1v15;
const int NetworkPackage::ProtocolVersion = 5;
......@@ -172,3 +174,8 @@ bool NetworkPackage::decrypt(QCA::PrivateKey& key, NetworkPackage* out) const
}
FileTransferJob* NetworkPackage::createPayloadTransferJob(const KUrl& destination) const
{
return new FileTransferJob(payload(), payloadSize(), destination);
}
......@@ -23,6 +23,8 @@
#include "networkpackagetypes.h"
#include <KUrl>
#include <QObject>
#include <QDebug>
#include <QString>
......@@ -35,6 +37,8 @@
#include "default_args.h"
class FileTransferJob;
class NetworkPackage : public QObject
{
Q_OBJECT
......@@ -74,6 +78,7 @@ public:
void setPayload(QIODevice* device, int payloadSize) { mPayload = device; mPayloadSize = payloadSize; Q_ASSERT(mPayloadSize >= -1); }
bool hasPayload() const { return (mPayloadSize != 0); }
int payloadSize() const { return mPayloadSize; } //-1 means it is an endless stream
FileTransferJob* createPayloadTransferJob(const KUrl& destination) const;
//To be called by a particular DeviceLink
QVariantMap payloadTransferInfo() const { return mPayloadTransferInfo; }
......
......@@ -16,6 +16,7 @@ set(kdeconnect_battery_SRCS
../kdeconnectplugin.cpp
../pluginloader.cpp
../../networkpackage.cpp
../../filetransferjob.cpp
../../device.cpp
)
......@@ -24,6 +25,7 @@ kde4_add_plugin(kdeconnect_battery ${kdeconnect_battery_SRCS})
target_link_libraries(kdeconnect_battery
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
......
......@@ -15,6 +15,7 @@ set(kdeconnect_clipboard_SRCS
../kdeconnectplugin.cpp
../pluginloader.cpp
../../networkpackage.cpp
../../filetransferjob.cpp
../../device.cpp
)
......@@ -23,6 +24,7 @@ kde4_add_plugin(kdeconnect_clipboard ${kdeconnect_clipboard_SRCS})
target_link_libraries(kdeconnect_clipboard
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
......
......@@ -13,10 +13,10 @@ include_directories(${KDE4_INCLUDES})
set(kdeconnect_filetransfer_SRCS
filetransferplugin.cpp
filetransferjob.cpp
autoclosingqfile.cpp
../kdeconnectplugin.cpp
../pluginloader.cpp
../../filetransferjob.cpp
../../networkpackage.cpp
../../device.cpp
)
......
......@@ -28,7 +28,7 @@
#include <QFile>
#include <QDesktopServices>
#include "filetransferjob.h"
#include "../../filetransferjob.h"
#include "autoclosingqfile.h"
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< FileTransferPlugin >(); )
......@@ -70,9 +70,8 @@ bool FileTransferPlugin::receivePackage(const NetworkPackage& np)
if (np.hasPayload()) {
qDebug() << "receiving file";
QString filename = np.get<QString>("filename", mDestinationDir + QString::number(QDateTime::currentMSecsSinceEpoch()));
QIODevice* incoming = np.payload();
FileTransferJob* job = new FileTransferJob(incoming, np.payloadSize(), filename);
connect(job,SIGNAL(result(KJob*)), this, SLOT(finished(KJob*)));
FileTransferJob* job = np.createPayloadTransferJob(filename);
connect(job, SIGNAL(result(KJob*)), this, SLOT(finished(KJob*)));
job->start();
}
......
......@@ -15,6 +15,7 @@ set(kdeconnect_mpriscontrol_SRCS
../kdeconnectplugin.cpp
../pluginloader.cpp
../../networkpackage.cpp
../../filetransferjob.cpp
../../device.cpp
)
......@@ -35,6 +36,7 @@ kde4_add_plugin(kdeconnect_mpriscontrol ${kdeconnect_mpriscontrol_SRCS})
target_link_libraries(kdeconnect_mpriscontrol
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
......
......@@ -17,6 +17,7 @@ set(kdeconnect_notifications_SRCS
../kdeconnectplugin.cpp
../pluginloader.cpp
../../networkpackage.cpp
../../filetransferjob.cpp
../../device.cpp
)
......@@ -25,6 +26,7 @@ kde4_add_plugin(kdeconnect_notifications ${kdeconnect_notifications_SRCS})
target_link_libraries(kdeconnect_notifications
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment