Moved filetransferjob from filetransfer plugin to networkpackage
This commit is contained in:
parent
acac5c36f2
commit
e20adde7fd
11 changed files with 25 additions and 5 deletions
|
@ -22,6 +22,7 @@ set(kded_kdeconnect_SRCS
|
||||||
plugins/pluginloader.cpp
|
plugins/pluginloader.cpp
|
||||||
|
|
||||||
networkpackage.cpp
|
networkpackage.cpp
|
||||||
|
filetransferjob.cpp
|
||||||
daemon.cpp
|
daemon.cpp
|
||||||
device.cpp
|
device.cpp
|
||||||
)
|
)
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include <qjson/serializer.h>
|
#include <qjson/serializer.h>
|
||||||
#include <qjson/qobjecthelper.h>
|
#include <qjson/qobjecthelper.h>
|
||||||
|
|
||||||
|
#include "filetransferjob.h"
|
||||||
|
|
||||||
const QCA::EncryptionAlgorithm NetworkPackage::EncryptionAlgorithm = QCA::EME_PKCS1v15;
|
const QCA::EncryptionAlgorithm NetworkPackage::EncryptionAlgorithm = QCA::EME_PKCS1v15;
|
||||||
const int NetworkPackage::ProtocolVersion = 5;
|
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 "networkpackagetypes.h"
|
||||||
|
|
||||||
|
#include <KUrl>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -35,6 +37,8 @@
|
||||||
|
|
||||||
#include "default_args.h"
|
#include "default_args.h"
|
||||||
|
|
||||||
|
class FileTransferJob;
|
||||||
|
|
||||||
class NetworkPackage : public QObject
|
class NetworkPackage : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -74,6 +78,7 @@ public:
|
||||||
void setPayload(QIODevice* device, int payloadSize) { mPayload = device; mPayloadSize = payloadSize; Q_ASSERT(mPayloadSize >= -1); }
|
void setPayload(QIODevice* device, int payloadSize) { mPayload = device; mPayloadSize = payloadSize; Q_ASSERT(mPayloadSize >= -1); }
|
||||||
bool hasPayload() const { return (mPayloadSize != 0); }
|
bool hasPayload() const { return (mPayloadSize != 0); }
|
||||||
int payloadSize() const { return mPayloadSize; } //-1 means it is an endless stream
|
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
|
//To be called by a particular DeviceLink
|
||||||
QVariantMap payloadTransferInfo() const { return mPayloadTransferInfo; }
|
QVariantMap payloadTransferInfo() const { return mPayloadTransferInfo; }
|
||||||
|
|
|
@ -16,6 +16,7 @@ set(kdeconnect_battery_SRCS
|
||||||
../kdeconnectplugin.cpp
|
../kdeconnectplugin.cpp
|
||||||
../pluginloader.cpp
|
../pluginloader.cpp
|
||||||
../../networkpackage.cpp
|
../../networkpackage.cpp
|
||||||
|
../../filetransferjob.cpp
|
||||||
../../device.cpp
|
../../device.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ kde4_add_plugin(kdeconnect_battery ${kdeconnect_battery_SRCS})
|
||||||
target_link_libraries(kdeconnect_battery
|
target_link_libraries(kdeconnect_battery
|
||||||
${KDE4_KDECORE_LIBS}
|
${KDE4_KDECORE_LIBS}
|
||||||
${KDE4_KDEUI_LIBS}
|
${KDE4_KDEUI_LIBS}
|
||||||
|
${KDE4_KIO_LIBS}
|
||||||
${QT_QTNETWORK_LIBRARY}
|
${QT_QTNETWORK_LIBRARY}
|
||||||
${QJSON_LIBRARIES}
|
${QJSON_LIBRARIES}
|
||||||
${QCA2_LIBRARIES}
|
${QCA2_LIBRARIES}
|
||||||
|
|
|
@ -15,6 +15,7 @@ set(kdeconnect_clipboard_SRCS
|
||||||
../kdeconnectplugin.cpp
|
../kdeconnectplugin.cpp
|
||||||
../pluginloader.cpp
|
../pluginloader.cpp
|
||||||
../../networkpackage.cpp
|
../../networkpackage.cpp
|
||||||
|
../../filetransferjob.cpp
|
||||||
../../device.cpp
|
../../device.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ kde4_add_plugin(kdeconnect_clipboard ${kdeconnect_clipboard_SRCS})
|
||||||
target_link_libraries(kdeconnect_clipboard
|
target_link_libraries(kdeconnect_clipboard
|
||||||
${KDE4_KDECORE_LIBS}
|
${KDE4_KDECORE_LIBS}
|
||||||
${KDE4_KDEUI_LIBS}
|
${KDE4_KDEUI_LIBS}
|
||||||
|
${KDE4_KIO_LIBS}
|
||||||
${QT_QTNETWORK_LIBRARY}
|
${QT_QTNETWORK_LIBRARY}
|
||||||
${QJSON_LIBRARIES}
|
${QJSON_LIBRARIES}
|
||||||
${QCA2_LIBRARIES}
|
${QCA2_LIBRARIES}
|
||||||
|
|
|
@ -13,10 +13,10 @@ include_directories(${KDE4_INCLUDES})
|
||||||
|
|
||||||
set(kdeconnect_filetransfer_SRCS
|
set(kdeconnect_filetransfer_SRCS
|
||||||
filetransferplugin.cpp
|
filetransferplugin.cpp
|
||||||
filetransferjob.cpp
|
|
||||||
autoclosingqfile.cpp
|
autoclosingqfile.cpp
|
||||||
../kdeconnectplugin.cpp
|
../kdeconnectplugin.cpp
|
||||||
../pluginloader.cpp
|
../pluginloader.cpp
|
||||||
|
../../filetransferjob.cpp
|
||||||
../../networkpackage.cpp
|
../../networkpackage.cpp
|
||||||
../../device.cpp
|
../../device.cpp
|
||||||
)
|
)
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
|
||||||
#include "filetransferjob.h"
|
#include "../../filetransferjob.h"
|
||||||
#include "autoclosingqfile.h"
|
#include "autoclosingqfile.h"
|
||||||
|
|
||||||
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< FileTransferPlugin >(); )
|
K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< FileTransferPlugin >(); )
|
||||||
|
@ -70,9 +70,8 @@ bool FileTransferPlugin::receivePackage(const NetworkPackage& np)
|
||||||
if (np.hasPayload()) {
|
if (np.hasPayload()) {
|
||||||
qDebug() << "receiving file";
|
qDebug() << "receiving file";
|
||||||
QString filename = np.get<QString>("filename", mDestinationDir + QString::number(QDateTime::currentMSecsSinceEpoch()));
|
QString filename = np.get<QString>("filename", mDestinationDir + QString::number(QDateTime::currentMSecsSinceEpoch()));
|
||||||
QIODevice* incoming = np.payload();
|
FileTransferJob* job = np.createPayloadTransferJob(filename);
|
||||||
FileTransferJob* job = new FileTransferJob(incoming, np.payloadSize(), filename);
|
connect(job, SIGNAL(result(KJob*)), this, SLOT(finished(KJob*)));
|
||||||
connect(job,SIGNAL(result(KJob*)), this, SLOT(finished(KJob*)));
|
|
||||||
job->start();
|
job->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ set(kdeconnect_mpriscontrol_SRCS
|
||||||
../kdeconnectplugin.cpp
|
../kdeconnectplugin.cpp
|
||||||
../pluginloader.cpp
|
../pluginloader.cpp
|
||||||
../../networkpackage.cpp
|
../../networkpackage.cpp
|
||||||
|
../../filetransferjob.cpp
|
||||||
../../device.cpp
|
../../device.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ kde4_add_plugin(kdeconnect_mpriscontrol ${kdeconnect_mpriscontrol_SRCS})
|
||||||
target_link_libraries(kdeconnect_mpriscontrol
|
target_link_libraries(kdeconnect_mpriscontrol
|
||||||
${KDE4_KDECORE_LIBS}
|
${KDE4_KDECORE_LIBS}
|
||||||
${KDE4_KDEUI_LIBS}
|
${KDE4_KDEUI_LIBS}
|
||||||
|
${KDE4_KIO_LIBS}
|
||||||
${QT_QTNETWORK_LIBRARY}
|
${QT_QTNETWORK_LIBRARY}
|
||||||
${QJSON_LIBRARIES}
|
${QJSON_LIBRARIES}
|
||||||
${QCA2_LIBRARIES}
|
${QCA2_LIBRARIES}
|
||||||
|
|
|
@ -17,6 +17,7 @@ set(kdeconnect_notifications_SRCS
|
||||||
../kdeconnectplugin.cpp
|
../kdeconnectplugin.cpp
|
||||||
../pluginloader.cpp
|
../pluginloader.cpp
|
||||||
../../networkpackage.cpp
|
../../networkpackage.cpp
|
||||||
|
../../filetransferjob.cpp
|
||||||
../../device.cpp
|
../../device.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ kde4_add_plugin(kdeconnect_notifications ${kdeconnect_notifications_SRCS})
|
||||||
target_link_libraries(kdeconnect_notifications
|
target_link_libraries(kdeconnect_notifications
|
||||||
${KDE4_KDECORE_LIBS}
|
${KDE4_KDECORE_LIBS}
|
||||||
${KDE4_KDEUI_LIBS}
|
${KDE4_KDEUI_LIBS}
|
||||||
|
${KDE4_KIO_LIBS}
|
||||||
${QT_QTNETWORK_LIBRARY}
|
${QT_QTNETWORK_LIBRARY}
|
||||||
${QJSON_LIBRARIES}
|
${QJSON_LIBRARIES}
|
||||||
${QCA2_LIBRARIES}
|
${QCA2_LIBRARIES}
|
||||||
|
|
Loading…
Reference in a new issue