Moved filetransferjob from filetransfer plugin to networkpackage

This commit is contained in:
Albert Vaca 2013-09-24 14:10:25 +02:00
parent acac5c36f2
commit e20adde7fd
11 changed files with 25 additions and 5 deletions

View file

@ -22,6 +22,7 @@ set(kded_kdeconnect_SRCS
plugins/pluginloader.cpp
networkpackage.cpp
filetransferjob.cpp
daemon.cpp
device.cpp
)

View file

@ -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);
}

View file

@ -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; }

View file

@ -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}

View file

@ -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}

View file

@ -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
)

View file

@ -28,7 +28,7 @@
#include <QFile>
#include <QDesktopServices>
#include "filetransferjob.h"
#include "../../filetransferjob.h"
#include "autoclosingqfile.h"
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< FileTransferPlugin >(); )
@ -70,8 +70,7 @@ 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);
FileTransferJob* job = np.createPayloadTransferJob(filename);
connect(job, SIGNAL(result(KJob*)), this, SLOT(finished(KJob*)));
job->start();
}

View file

@ -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}

View file

@ -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}