From e20adde7fd8f9cc0db7a0413ab01f28a5f319d65 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Tue, 24 Sep 2013 14:10:25 +0200 Subject: [PATCH] Moved filetransferjob from filetransfer plugin to networkpackage --- kded/CMakeLists.txt | 1 + kded/{plugins/filetransfer => }/filetransferjob.cpp | 0 kded/{plugins/filetransfer => }/filetransferjob.h | 0 kded/networkpackage.cpp | 7 +++++++ kded/networkpackage.h | 5 +++++ kded/plugins/battery/CMakeLists.txt | 2 ++ kded/plugins/clipboard/CMakeLists.txt | 2 ++ kded/plugins/filetransfer/CMakeLists.txt | 2 +- kded/plugins/filetransfer/filetransferplugin.cpp | 7 +++---- kded/plugins/mpriscontrol/CMakeLists.txt | 2 ++ kded/plugins/notifications/CMakeLists.txt | 2 ++ 11 files changed, 25 insertions(+), 5 deletions(-) rename kded/{plugins/filetransfer => }/filetransferjob.cpp (100%) rename kded/{plugins/filetransfer => }/filetransferjob.h (100%) diff --git a/kded/CMakeLists.txt b/kded/CMakeLists.txt index c6ecb2625..53ad3e04e 100644 --- a/kded/CMakeLists.txt +++ b/kded/CMakeLists.txt @@ -22,6 +22,7 @@ set(kded_kdeconnect_SRCS plugins/pluginloader.cpp networkpackage.cpp + filetransferjob.cpp daemon.cpp device.cpp ) diff --git a/kded/plugins/filetransfer/filetransferjob.cpp b/kded/filetransferjob.cpp similarity index 100% rename from kded/plugins/filetransfer/filetransferjob.cpp rename to kded/filetransferjob.cpp diff --git a/kded/plugins/filetransfer/filetransferjob.h b/kded/filetransferjob.h similarity index 100% rename from kded/plugins/filetransfer/filetransferjob.h rename to kded/filetransferjob.h diff --git a/kded/networkpackage.cpp b/kded/networkpackage.cpp index 2f20220eb..86b691eac 100644 --- a/kded/networkpackage.cpp +++ b/kded/networkpackage.cpp @@ -33,6 +33,8 @@ #include #include +#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); +} + diff --git a/kded/networkpackage.h b/kded/networkpackage.h index 61e83306c..37433eca7 100644 --- a/kded/networkpackage.h +++ b/kded/networkpackage.h @@ -23,6 +23,8 @@ #include "networkpackagetypes.h" +#include + #include #include #include @@ -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; } diff --git a/kded/plugins/battery/CMakeLists.txt b/kded/plugins/battery/CMakeLists.txt index 405bdcec3..e38fec2a4 100644 --- a/kded/plugins/battery/CMakeLists.txt +++ b/kded/plugins/battery/CMakeLists.txt @@ -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} diff --git a/kded/plugins/clipboard/CMakeLists.txt b/kded/plugins/clipboard/CMakeLists.txt index 3309097d6..9cf8179d1 100644 --- a/kded/plugins/clipboard/CMakeLists.txt +++ b/kded/plugins/clipboard/CMakeLists.txt @@ -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} diff --git a/kded/plugins/filetransfer/CMakeLists.txt b/kded/plugins/filetransfer/CMakeLists.txt index f75b4a1fd..58370f64f 100644 --- a/kded/plugins/filetransfer/CMakeLists.txt +++ b/kded/plugins/filetransfer/CMakeLists.txt @@ -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 ) diff --git a/kded/plugins/filetransfer/filetransferplugin.cpp b/kded/plugins/filetransfer/filetransferplugin.cpp index 7533f7388..088d7c53c 100644 --- a/kded/plugins/filetransfer/filetransferplugin.cpp +++ b/kded/plugins/filetransfer/filetransferplugin.cpp @@ -28,7 +28,7 @@ #include #include -#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("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(); } diff --git a/kded/plugins/mpriscontrol/CMakeLists.txt b/kded/plugins/mpriscontrol/CMakeLists.txt index 03a0b0bb8..04965f69a 100644 --- a/kded/plugins/mpriscontrol/CMakeLists.txt +++ b/kded/plugins/mpriscontrol/CMakeLists.txt @@ -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} diff --git a/kded/plugins/notifications/CMakeLists.txt b/kded/plugins/notifications/CMakeLists.txt index c7f4afa04..37bf9dd92 100644 --- a/kded/plugins/notifications/CMakeLists.txt +++ b/kded/plugins/notifications/CMakeLists.txt @@ -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}