diff options
Diffstat (limited to 'plugins/CopyEngine/Random')
-rwxr-xr-x | plugins/CopyEngine/Random/CopyEngine.cpp | 253 | ||||
-rwxr-xr-x | plugins/CopyEngine/Random/CopyEngine.h | 128 | ||||
-rwxr-xr-x | plugins/CopyEngine/Random/CopyEngine.pro | 26 | ||||
-rwxr-xr-x | plugins/CopyEngine/Random/CopyEngineFactory.cpp | 78 | ||||
-rwxr-xr-x | plugins/CopyEngine/Random/CopyEngineFactory.h | 58 | ||||
-rwxr-xr-x | plugins/CopyEngine/Random/README.md | 3 | ||||
-rwxr-xr-x | plugins/CopyEngine/Random/informations.xml | 24 | ||||
-rwxr-xr-x | plugins/CopyEngine/Random/plugin.json | 1 |
8 files changed, 571 insertions, 0 deletions
diff --git a/plugins/CopyEngine/Random/CopyEngine.cpp b/plugins/CopyEngine/Random/CopyEngine.cpp new file mode 100755 index 0000000..662fb5b --- /dev/null +++ b/plugins/CopyEngine/Random/CopyEngine.cpp @@ -0,0 +1,253 @@ +/** \file copyEngine.cpp +\brief Define the copy engine +\author alpha_one_x86 */ + +#include "CopyEngine.h" +#include "../../../interface/PluginInterface_CopyEngine.h" +#include <QCoreApplication> + +CopyEngine::CopyEngine() +{ + timer=new QTimer(); + connect(timer,&QTimer::timeout,this,&CopyEngine::timerSlot); + timer->start(1000); + send=false; +} + +CopyEngine::~CopyEngine() +{ +} + +//to send the options panel +bool CopyEngine::getOptionsEngine(QWidget * tempWidget) +{ + (void)tempWidget; + return true; +} + +//to have interface widget to do modal dialog +void CopyEngine::setInterfacePointer(QWidget * uiinterface) +{ + (void)uiinterface; + syncTransferList(); +} + +bool CopyEngine::haveSameSource(const std::vector<std::string> &) +{ + return false; +} + +bool CopyEngine::haveSameDestination(const std::string &) +{ + return false; +} + +bool CopyEngine::newCopy(const std::vector<std::string> &sources) +{ + (void)sources; + return true; +} + +bool CopyEngine::newCopy(const std::vector<std::string> &sources,const std::string &destination) +{ + (void)sources; + (void)destination; + return true; +} + +bool CopyEngine::newMove(const std::vector<std::string> &sources) +{ + (void)sources; + return true; +} + +bool CopyEngine::newMove(const std::vector<std::string> &sources,const std::string &destination) +{ + (void)sources; + (void)destination; + return true; +} + +void CopyEngine::newTransferList(const std::string &file) +{ + (void)file; +} + +//because direct access to list thread into the main thread can't be do +uint64_t CopyEngine::realByteTransfered() +{ + return rand()%200000000; +} + +void CopyEngine::timerSlot() +{ + emit pushGeneralProgression(rand()%200000000,200000000); + + { + std::vector<std::pair<uint64_t,uint32_t> > progressionList; + progressionList.push_back(std::pair<uint64_t,uint32_t>(100, 2)); + progressionList.push_back(std::pair<uint64_t,uint32_t>(1000, 2)); + progressionList.push_back(std::pair<uint64_t,uint32_t>(10000, 2+ rand()%2)); + progressionList.push_back(std::pair<uint64_t,uint32_t>(100000, 5+ rand()%3)); + progressionList.push_back(std::pair<uint64_t,uint32_t>(1000000, 15+ rand()%3)); + progressionList.push_back(std::pair<uint64_t,uint32_t>(10000000, 50+ rand()%10)); + progressionList.push_back(std::pair<uint64_t,uint32_t>(100000000, 800+ rand()%100)); + progressionList.push_back(std::pair<uint64_t,uint32_t>(1000000000, 6000+ rand()%500)); + progressionList.push_back(std::pair<uint64_t,uint32_t>(10000000000, 50000+ rand()%1000)); + emit doneTime(progressionList); + } + + { + std::vector<Ultracopier::ProgressionItem> progressionList; + Ultracopier::ProgressionItem entry; + entry.currentRead=60*1024*1024+rand()%20*1024*1024; + entry.currentWrite=40*1024*1024+rand()%20*1024*1024; + entry.id=1; + entry.total=100*1024*1024; + progressionList.push_back(entry); + emit pushFileProgression(progressionList); + } +} + +//speed limitation +bool CopyEngine::supportSpeedLimitation() const +{ + return false; +} + +/** \brief to sync the transfer list + * Used when the interface is changed, useful to minimize the memory size */ +void CopyEngine::syncTransferList() +{ + emit syncReady(); + if(send) + return; + send=true; + + emit actionInProgess(Ultracopier::Copying); + + std::vector<Ultracopier::ReturnActionOnCopyList> actionsList; + Ultracopier::ReturnActionOnCopyList newAction; + newAction.type = Ultracopier::AddingItem; + + newAction.addAction.id = 1; + newAction.addAction.sourceFullPath = "/folder1/file.iso"; + newAction.addAction.sourceFileName = "file.iso"; + newAction.addAction.destinationFullPath = "/dest/folder1/file.iso"; + newAction.addAction.destinationFileName = "file.iso"; + newAction.addAction.size = 100*1024*1024; + newAction.addAction.mode = Ultracopier::CopyMode::Copy; + actionsList.push_back(newAction); + + newAction.addAction.id = 2; + newAction.addAction.sourceFullPath = "/file.mp3"; + newAction.addAction.sourceFileName = "file.mp3"; + newAction.addAction.destinationFullPath = "/dest/file.mp3"; + newAction.addAction.destinationFileName = "file.mp3"; + newAction.addAction.size = 10*1024*1024; + newAction.addAction.mode = Ultracopier::CopyMode::Copy; + actionsList.push_back(newAction); + + newAction.addAction.id = 3; + newAction.addAction.sourceFullPath = "/file.mp4"; + newAction.addAction.sourceFileName = "file.mp4"; + newAction.addAction.destinationFullPath = "/dest/file.mp4"; + newAction.addAction.destinationFileName = "file.mp4"; + newAction.addAction.size = 50*1024*1024; + newAction.addAction.mode = Ultracopier::CopyMode::Copy; + actionsList.push_back(newAction); + + newAction.addAction.id = 1; + newAction.addAction.sourceFullPath = "/folder1/file.iso"; + newAction.addAction.sourceFileName = "file.iso"; + newAction.addAction.destinationFullPath = "/dest/folder1/file.iso"; + newAction.addAction.destinationFileName = "file.iso"; + newAction.addAction.size = 100*1024*1024; + newAction.addAction.mode = Ultracopier::CopyMode::Copy; + newAction.type = Ultracopier::PreOperation; + actionsList.push_back(newAction); + newAction.type = Ultracopier::Transfer; + actionsList.push_back(newAction); + + emit newActionOnList(actionsList); +} + +bool CopyEngine::userAddFolder(const Ultracopier::CopyMode &mode) +{ + (void)mode; + return true; +} + +bool CopyEngine::userAddFile(const Ultracopier::CopyMode &mode) +{ + (void)mode; + return true; +} + +void CopyEngine::pause() +{ +} + +void CopyEngine::resume() +{ +} + +void CopyEngine::skip(const uint64_t &id) +{ + (void)id; +} + +void CopyEngine::cancel() +{ + emit canBeDeleted(); +} + +void CopyEngine::removeItems(const std::vector<uint64_t> &ids) +{ + (void)ids; +} + +void CopyEngine::moveItemsOnTop(const std::vector<uint64_t> &ids) +{ + (void)ids; +} + +void CopyEngine::moveItemsUp(const std::vector<uint64_t> &ids) +{ + (void)ids; +} + +void CopyEngine::moveItemsDown(const std::vector<uint64_t> &ids) +{ + (void)ids; +} + +void CopyEngine::moveItemsOnBottom(const std::vector<uint64_t> &ids) +{ + (void)ids; +} + +/** \brief give the forced mode, to export/import transfer list */ +void CopyEngine::forceMode(const Ultracopier::CopyMode &mode) +{ + (void)mode; +} + +void CopyEngine::exportTransferList() +{ +} + +void CopyEngine::importTransferList() +{ +} + +bool CopyEngine::setSpeedLimitation(const int64_t &speedLimitation) +{ + (void)speedLimitation; + //ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"maxSpeed: "+std::to_string(speedLimitation)); + return false; +} + +void CopyEngine::exportErrorIntoTransferList() +{ +} diff --git a/plugins/CopyEngine/Random/CopyEngine.h b/plugins/CopyEngine/Random/CopyEngine.h new file mode 100755 index 0000000..2da5da5 --- /dev/null +++ b/plugins/CopyEngine/Random/CopyEngine.h @@ -0,0 +1,128 @@ +/** \file copyEngine.h +\brief Define the copy engine +\author alpha_one_x86 +\licence GPL3, see the file COPYING */ + +#include "../../../interface/PluginInterface_CopyEngine.h" + +#ifndef COPY_ENGINE_H +#define COPY_ENGINE_H + +#include <QTimer> + +namespace Ui { + class copyEngineOptions; +} + +/// \brief the implementation of copy engine plugin, manage directly few stuff, else pass to ListThread class. +class CopyEngine : public PluginInterface_CopyEngine +{ + Q_OBJECT +public: + CopyEngine(); + ~CopyEngine(); + void exportErrorIntoTransferList() override; +public: + /** \brief to send the options panel + * \return return false if have not the options + * \param tempWidget the widget to generate on it the options */ + bool getOptionsEngine(QWidget * tempWidget) override; + /** \brief to have interface widget to do modal dialog + * \param interface to have the widget of the interface, useful for modal dialog */ + void setInterfacePointer(QWidget * uiinterface) override; + //return empty if multiple + /** \brief compare the current sources of the copy, with the passed arguments + * \param sources the sources list to compares with the current sources list + * \return true if have same sources, else false (or empty) */ + bool haveSameSource(const std::vector<std::string> &sources) override; + /** \brief compare the current destination of the copy, with the passed arguments + * \param destination the destination to compares with the current destination + * \return true if have same destination, else false (or empty) */ + bool haveSameDestination(const std::string &destination) override; + //external soft like file browser have send copy/move list to do + /** \brief send copy without destination, ask the destination + * \param sources the sources list to copy + * \return true if the copy have been accepted */ + bool newCopy(const std::vector<std::string> &sources) override; + /** \brief send copy with destination + * \param sources the sources list to copy + * \param destination the destination to copy + * \return true if the copy have been accepted */ + bool newCopy(const std::vector<std::string> &sources,const std::string &destination) override; + /** \brief send move without destination, ask the destination + * \param sources the sources list to move + * \return true if the move have been accepted */ + bool newMove(const std::vector<std::string> &sources) override; + /** \brief send move without destination, ask the destination + * \param sources the sources list to move + * \param destination the destination to move + * \return true if the move have been accepted */ + bool newMove(const std::vector<std::string> &sources,const std::string &destination) override; + /** \brief send the new transfer list + * \param file the transfer list */ + void newTransferList(const std::string &file) override; + + /** \brief to get byte read, use by Ultracopier for the speed calculation + * real size transfered to right speed calculation */ + uint64_t realByteTransfered() override; + /** \brief support speed limitation */ + bool supportSpeedLimitation() const override; + + /** \brief to set drives detected + * specific to this copy engine */ + + /** \brief to sync the transfer list + * Used when the interface is changed, useful to minimize the memory size */ + void syncTransferList() override; +public slots: + //user ask ask to add folder (add it with interface ask source/destination) + /** \brief add folder called on the interface + * Used by manual adding */ + bool userAddFolder(const Ultracopier::CopyMode &mode) override; + /** \brief add file called on the interface + * Used by manual adding */ + bool userAddFile(const Ultracopier::CopyMode &mode) override; + //action on the copy + /// \brief put the transfer in pause + void pause() override; + /// \brief resume the transfer + void resume() override; + /** \brief skip one transfer entry + * \param id id of the file to remove */ + void skip(const uint64_t &id) override; + /// \brief cancel all the transfer + void cancel() override; + //edit the transfer list + /** \brief remove the selected item + * \param ids ids is the id list of the selected items */ + void removeItems(const std::vector<uint64_t> &ids) override; + /** \brief move on top of the list the selected item + * \param ids ids is the id list of the selected items */ + void moveItemsOnTop(const std::vector<uint64_t> &ids) override; + /** \brief move up the list the selected item + * \param ids ids is the id list of the selected items */ + void moveItemsUp(const std::vector<uint64_t> &ids) override; + /** \brief move down the list the selected item + * \param ids ids is the id list of the selected items */ + void moveItemsDown(const std::vector<uint64_t> &ids) override; + /** \brief move on bottom of the list the selected item + * \param ids ids is the id list of the selected items */ + void moveItemsOnBottom(const std::vector<uint64_t> &ids) override; + + /** \brief give the forced mode, to export/import transfer list */ + void forceMode(const Ultracopier::CopyMode &mode) override; + /// \brief export the transfer list into a file + void exportTransferList() override; + /// \brief import the transfer list into a file + void importTransferList() override; + + /** \brief to set the speed limitation + * -1 if not able, 0 if disabled */ + bool setSpeedLimitation(const int64_t &speedLimitation) override; +private: + bool send; + QTimer *timer; + void timerSlot(); +}; + +#endif // COPY_ENGINE_H diff --git a/plugins/CopyEngine/Random/CopyEngine.pro b/plugins/CopyEngine/Random/CopyEngine.pro new file mode 100755 index 0000000..f65ce88 --- /dev/null +++ b/plugins/CopyEngine/Random/CopyEngine.pro @@ -0,0 +1,26 @@ +CONFIG += c++11 +QMAKE_CXXFLAGS+="-std=c++0x -Wall -Wextra" +mac:QMAKE_CXXFLAGS+="-stdlib=libc++" + +QT += widgets xml +DEFINES += UNICODE _UNICODE +TEMPLATE = lib +CONFIG += plugin + +HEADERS += \ + $$PWD/../../../interface/PluginInterface_CopyEngine.h \ + $$PWD/../../../interface/OptionInterface.h \ + $$PWD/../../../interface/FacilityInterface.h \ + $$PWD/../../../cpp11addition.h \ + $$PWD/CopyEngine.h \ + $$PWD/CopyEngineFactory.h +SOURCES += \ + $$PWD/../../../cpp11addition.cpp \ + $$PWD/../../../cpp11additionstringtointcpp.cpp \ + $$PWD/CopyEngine.cpp \ + $$PWD/CopyEngineFactory.cpp +TARGET = $$qtLibraryTarget(copyEngine) + +win32 { + LIBS += -ladvapi32 +} diff --git a/plugins/CopyEngine/Random/CopyEngineFactory.cpp b/plugins/CopyEngine/Random/CopyEngineFactory.cpp new file mode 100755 index 0000000..8fe5ad6 --- /dev/null +++ b/plugins/CopyEngine/Random/CopyEngineFactory.cpp @@ -0,0 +1,78 @@ +/** \file factory.cpp +\brief Define the factory to create new instance +\author alpha_one_x86 */ + +#include "../../../cpp11addition.h" +#include "CopyEngineFactory.h" + +CopyEngineFactory::CopyEngineFactory() +{ +} + +CopyEngineFactory::~CopyEngineFactory() +{ +} + +PluginInterface_CopyEngine * CopyEngineFactory::getInstance() +{ + CopyEngine *realObject=new CopyEngine(); + return realObject; +} + +void CopyEngineFactory::setResources(OptionInterface * options,const std::string &writePath,const std::string &pluginPath, + FacilityInterface * facilityInterface,const bool &portableVersion) +{ + (void)options; + (void)writePath; + (void)pluginPath; + (void)facilityInterface; + (void)portableVersion; +} + +std::vector<std::string> CopyEngineFactory::supportedProtocolsForTheSource() const +{ + std::vector<std::string> l; + l.push_back("file"); + return l; +} + +std::vector<std::string> CopyEngineFactory::supportedProtocolsForTheDestination() const +{ + std::vector<std::string> l; + l.push_back("file"); + return l; +} + +Ultracopier::CopyType CopyEngineFactory::getCopyType() +{ + return Ultracopier::FileAndFolder; +} + +Ultracopier::TransferListOperation CopyEngineFactory::getTransferListOperation() +{ + return Ultracopier::TransferListOperation_ImportExport; +} + +bool CopyEngineFactory::canDoOnlyCopy() const +{ + return false; +} + +void CopyEngineFactory::resetOptions() +{ +} + +QWidget * CopyEngineFactory::options() +{ + return nullptr; +} + +/// \brief to get if have pause +bool CopyEngineFactory::havePause() +{ + return false; +} + +void CopyEngineFactory::newLanguageLoaded() +{ +} diff --git a/plugins/CopyEngine/Random/CopyEngineFactory.h b/plugins/CopyEngine/Random/CopyEngineFactory.h new file mode 100755 index 0000000..b1bad6a --- /dev/null +++ b/plugins/CopyEngine/Random/CopyEngineFactory.h @@ -0,0 +1,58 @@ +/** \file factory.h +\brief Define the factory to create new instance +\author alpha_one_x86 +\licence GPL3, see the file COPYING */ + +#include <QObject> +#include <QList> +#include <QStringList> +#include <QFileInfo> +#include <QProcess> +#include <QTimer> + +#include "../../../interface/PluginInterface_CopyEngine.h" +#include "CopyEngine.h" + +#ifndef FACTORY_H +#define FACTORY_H + +namespace Ui { + class copyEngineOptions; +} + +/** \brief to generate copy engine instance */ +class CopyEngineFactory : public PluginInterface_CopyEngineFactory +{ + Q_OBJECT + #ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE_DIRECT + Q_PLUGIN_METADATA(IID "first-world.info.ultracopier.PluginInterface.CopyEngineFactory/2.0.0.0" FILE "plugin.json") + Q_INTERFACES(PluginInterface_CopyEngineFactory) + #endif +public: + CopyEngineFactory(); + ~CopyEngineFactory(); + /// \brief to return the instance of the copy engine + PluginInterface_CopyEngine * getInstance(); + /// \brief set the resources, to store options, to have facilityInterface + void setResources(OptionInterface * options,const std::string &writePath,const std::string &pluginPath,FacilityInterface * facilityInterface,const bool &portableVersion) override; + //get mode allowed + /// \brief define if can copy file, folder or both + Ultracopier::CopyType getCopyType() override; + /// \brief to return which kind of transfer list operation is supported + Ultracopier::TransferListOperation getTransferListOperation() override; + /// \brief define if can only copy, or copy and move + bool canDoOnlyCopy() const override; + /// \brief to get the supported protocols for the source + std::vector<std::string> supportedProtocolsForTheSource() const override; + /// \brief to get the supported protocols for the destination + std::vector<std::string> supportedProtocolsForTheDestination() const override; + /// \brief to get the options of the copy engine + QWidget * options() override; + /// \brief to get if have pause + bool havePause() override; +public slots: + void resetOptions() override; + void newLanguageLoaded() override; +}; + +#endif // FACTORY_H diff --git a/plugins/CopyEngine/Random/README.md b/plugins/CopyEngine/Random/README.md new file mode 100755 index 0000000..a15b943 --- /dev/null +++ b/plugins/CopyEngine/Random/README.md @@ -0,0 +1,3 @@ +# Copy Engine: Ultracopier + +This is the default copy engine. diff --git a/plugins/CopyEngine/Random/informations.xml b/plugins/CopyEngine/Random/informations.xml new file mode 100755 index 0000000..490980f --- /dev/null +++ b/plugins/CopyEngine/Random/informations.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<package> + <title xml:lang="en"><![CDATA[Random copy engine]]></title><!-- english is required --> + <!-- What kind of plugin this is --> + <category>CopyEngine</category> + <!-- Who wrote this plugin --> + <author><![CDATA[BRULE Herman, alpha_one_x86 (alpha_one_x86@first-world.info)]]></author> + <!-- URL of page or site for this plugin (may provide additional information, bug reports, feature requests). --> + <website xml:lang="en"><![CDATA[http://ultracopier.first-world.info/]]></website><!-- not required --> + <website xml:lang="fr"><![CDATA[http://ultracopier-fr.first-world.info/]]></website><!-- not required --> + <!-- the date-time format should be in timestamps format --> + <pubDate>1287496800</pubDate> + <!-- the architecture code of this plugin, found PlatformMacro.h into ultracopier source --> + <architecture>windows-x86</architecture> + <!-- Detailed description --> + <description xml:lang="en"><![CDATA[TODO]]></description> + <!-- Version of this release of this plugin, need be like that's: A.B.C.D, where A, B, C and D is number --> + <version>2.2.4.4</version> + <!-- This internal name should never change, because it is used to detect when a particular plugin is updated. It must comprise only lower case ASCII characters (a-z), numerical digits (0-9), "-", "." or "_", and it must be be unique within the category. And have size lower than 64 char. --> + <name>Random</name> + <!-- Dependency checking. This is used to check when a plugin may not be compatible with an updated version of either Ultracopier or another plugin. This example only checks Ultracopier. --> + <dependencies><![CDATA[ + ]]></dependencies> +</package> diff --git a/plugins/CopyEngine/Random/plugin.json b/plugins/CopyEngine/Random/plugin.json new file mode 100755 index 0000000..9e26dfe --- /dev/null +++ b/plugins/CopyEngine/Random/plugin.json @@ -0,0 +1 @@ +{}
\ No newline at end of file |