1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
/** \file copyEngine.h
\brief Define the copy engine
\author alpha_one_x86
\licence GPL3, see the file COPYING */
#include <QWidget>
#include <QObject>
#include <QList>
#include <vector>
#include <string>
#include <QFile>
#include <QFileDialog>
#include <QMessageBox>
#include "../../../interface/PluginInterface_CopyEngine.h"
#include "FileErrorDialog.h"
#include "FileExistsDialog.h"
#include "FolderExistsDialog.h"
#include "FileIsSameDialog.h"
#include "ui_copyEngineOptions.h"
#include "Environment.h"
#include "ListThread.h"
#include "Filters.h"
#include "RenamingRules.h"
#ifdef ULTRACOPIER_PLUGIN_DEBUG_WINDOW
#include "DebugDialog.h"
#include <QTimer>
#endif
#ifndef COPY_ENGINE_H
#define COPY_ENGINE_H
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(FacilityInterface * facilityEngine);
~CopyEngine();
void connectTheSignalsSlots();
private:
ListThread * listThread;
#ifdef ULTRACOPIER_PLUGIN_DEBUG_WINDOW
DebugDialog debugDialogWindow;
#endif
QWidget * tempWidget;
Ui::copyEngineOptions * ui;
bool uiIsInstalled;
QWidget * uiinterface;
Filters * filters;
RenamingRules * renamingRules;
FacilityInterface * facilityEngine;
bool doRightTransfer;
bool keepDate;
bool os_spec_flags;
bool native_copy;
bool followTheStrictOrder;
bool deletePartiallyTransferredFiles;
int inodeThreads;
bool renameTheOriginalDestination;
bool moveTheWholeFolder;
bool autoStart;
#ifdef ULTRACOPIER_PLUGIN_RSYNC
bool rsync;
#endif
bool checkDestinationFolderExists;
bool mkFullPath;
bool checksum;
FileExistsAction alwaysDoThisActionForFileExists;
FileErrorAction alwaysDoThisActionForFileError;
FileErrorAction alwaysDoThisActionForFolderError;
FolderExistsAction alwaysDoThisActionForFolderExists;
bool dialogIsOpen;
volatile bool stopIt;
std::string defaultDestinationFolder;
/// \brief error queue
struct errorQueueItem
{
TransferThreadAsync * transfer; ///< NULL if send by scan thread
ScanFileOrFolder * scan; ///< NULL if send by transfer thread
bool mkPath;
bool rmPath;
INTERNALTYPEPATH inode;
std::string errorString;
ErrorType errorType;
};
std::vector<errorQueueItem> errorQueue;
/// \brief already exists queue
struct alreadyExistsQueueItem
{
TransferThreadAsync * transfer; ///< NULL if send by scan thread
ScanFileOrFolder * scan; ///< NULL if send by transfer thread
INTERNALTYPEPATH source;
INTERNALTYPEPATH destination;
bool isSame;
};
std::vector<alreadyExistsQueueItem> alreadyExistsQueue;
uint64_t size_for_speed;//because direct access to list thread into the main thread can't be do
Ultracopier::CopyMode mode;
bool forcedMode;
bool checkDiskSpace;
bool buffer;
unsigned int osBufferLimit;
std::vector<std::string> includeStrings,includeOptions,excludeStrings,excludeOptions;
std::string firstRenamingRule;
std::string otherRenamingRule;
uint64_t errorPutAtEnd;
//send action done timer
QTimer timerActionDone;
//send progression timer
QTimer timerProgression;
QTimer timerUpdateMount;
int putAtBottom;//to keep how many automatic put at bottom have been used
private slots:
#ifdef ULTRACOPIER_PLUGIN_DEBUG_WINDOW
void updateTheDebugInfo(const std::vector<std::string> &newList, const std::vector<std::string> &newList2, const int &numberOfInodeOperation);
friend class DebugDialog;
#endif
/************* External call ********************/
//dialog message
/// \note Can be call without queue because all call will be serialized
void fileAlreadyExistsSlot(INTERNALTYPEPATH source, INTERNALTYPEPATH destination, bool isSame, TransferThreadAsync * thread);
/// \note Can be call without queue because all call will be serialized
void errorOnFileSlot(INTERNALTYPEPATH fileInfo, std::string errorString, TransferThreadAsync * thread, const ErrorType &errorType);
/// \note Can be call without queue because all call will be serialized
void folderAlreadyExistsSlot(INTERNALTYPEPATH source,INTERNALTYPEPATH destination,bool isSame,ScanFileOrFolder * thread);
/// \note Can be call without queue because all call will be serialized
void errorOnFolderSlot(INTERNALTYPEPATH fileInfo, std::string errorString, ScanFileOrFolder * thread, ErrorType errorType);
//mkpath event
void mkPathErrorOnFolderSlot(INTERNALTYPEPATH, std::string, ErrorType errorType);
//dialog message
/// \note Can be call without queue because all call will be serialized
void fileAlreadyExists(INTERNALTYPEPATH source, INTERNALTYPEPATH destination, bool isSame, TransferThreadAsync * thread, bool isCalledByShowOneNewDialog=false);
/// \note Can be call without queue because all call will be serialized
void errorOnFile(INTERNALTYPEPATH fileInfo, std::string errorString, TransferThreadAsync * thread, const ErrorType &errorType, bool isCalledByShowOneNewDialog=false);
/// \note Can be call without queue because all call will be serialized
void folderAlreadyExists(INTERNALTYPEPATH source,INTERNALTYPEPATH destination,bool isSame,ScanFileOrFolder * thread,bool isCalledByShowOneNewDialog=false);
/// \note Can be call without queue because all call will be serialized
void errorOnFolder(INTERNALTYPEPATH fileInfo, std::string errorString, ScanFileOrFolder * thread, ErrorType errorType, bool isCalledByShowOneNewDialog=false);
//mkpath event
void mkPathErrorOnFolder(INTERNALTYPEPATH, std::string, const ErrorType &errorType, bool isCalledByShowOneNewDialog=false);
//show one new dialog if needed
void showOneNewDialog();
void sendNewFilters();
void showFilterDialog();
void sendNewRenamingRules(std::string firstRenamingRule,std::string otherRenamingRule);
void showRenamingRules();
void get_realBytesTransfered(quint64 realBytesTransfered);
void newActionInProgess(Ultracopier::EngineActionInProgress);
void haveNeedPutAtBottom(bool needPutAtBottom, const INTERNALTYPEPATH &fileInfo, const std::string &errorString, TransferThreadAsync *thread, const ErrorType &errorType);
void missingDiskSpace(std::vector<Diskspace> list);
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;
void set_setFilters(std::vector<std::string> includeStrings,std::vector<std::string> includeOptions,std::vector<std::string> excludeStrings,std::vector<std::string> excludeOptions);
void setRenamingRules(std::string firstRenamingRule,std::string otherRenamingRule);
#ifdef ULTRACOPIER_PLUGIN_RSYNC
void setRsync(const bool rsync);
#endif
void setCheckDiskSpace(const bool &checkDiskSpace);
void setDefaultDestinationFolder(const std::string &defaultDestinationFolder);
void defaultDestinationFolderBrowse();
std::string askDestination();
static std::string stringimplode(const std::vector<std::string>& elems, const std::string &delim);
void setBuffer(const bool &buffer);
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;
// specific to this copy engine
/// \brief set if the rights shoul be keep
void setRightTransfer(const bool doRightTransfer);
/// \brief set keep date
void setKeepDate(const bool keepDate);
void setOsSpecFlags(bool os_spec_flags);
void setNativeCopy(bool native_copy);
void setMoveTheWholeFolder(const bool &moveTheWholeFolder);
void setFollowTheStrictOrder(const bool &followTheStrictOrder);
void setDeletePartiallyTransferredFiles(const bool &deletePartiallyTransferredFiles);
void setInodeThreads(const int &inodeThreads);
void setRenameTheOriginalDestination(const bool &renameTheOriginalDestination);
void inodeThreadsFinished();
/// \brief set auto start
void setAutoStart(const bool autoStart);
/// \brief set if need check if the destination folder exists
void setCheckDestinationFolderExists(const bool checkDestinationFolderExists);
void setMkFullPath(const bool mkFullPath);
void setChecksum(const bool checksum);
/// \brief reset widget
void resetTempWidget();
//autoconnect
void setFolderCollision(int index);
void setFolderError(int index);
void setFileCollision(int index);
void setFileError(int index);
/// \brief need retranslate the insterface
void newLanguageLoaded();
private slots:
void setComboBoxFolderCollision(FolderExistsAction action,bool changeComboBox=true);
void setComboBoxFolderError(FileErrorAction action,bool changeComboBox=true);
void warningTransferList(const std::string &warning);
void errorTransferList(const std::string &error);
signals:
//action on the copy
void signal_pause() const;
void signal_resume() const;
void signal_skip(const uint64_t &id) const;
void signal_setSpeedLimitation(const int64_t &speedLimitation);
//edit the transfer list
void signal_removeItems(const std::vector<uint64_t> &ids) const;
void signal_moveItemsOnTop(const std::vector<uint64_t> &ids) const;
void signal_moveItemsUp(const std::vector<uint64_t> &ids) const;
void signal_moveItemsDown(const std::vector<uint64_t> &ids) const;
void signal_moveItemsOnBottom(const std::vector<uint64_t> &ids) const;
void signal_forceMode(const Ultracopier::CopyMode &mode) const;
void signal_exportTransferList(const std::string &fileName) const;
void signal_importTransferList(const std::string &fileName) const;
void signal_exportErrorIntoTransferList(const std::string &fileName) const;
//action
void signal_setCollisionAction(FileExistsAction alwaysDoThisActionForFileExists) const;
//void signal_setComboBoxFolderCollision(FolderExistsAction action) const;// -> duplicate with signal_setFolderCollision ?
void signal_setFolderCollision(FolderExistsAction action) const;
//internal cancel
void tryCancel() const;
void getNeedPutAtBottom(const INTERNALTYPEPATH &fileInfo,const std::string &errorString,TransferThreadAsync * thread,const ErrorType &errorType) const;
#ifdef ULTRACOPIER_PLUGIN_DEBUG
/// \brief To debug source
void debugInformation(const Ultracopier::DebugLevel &level,std::string fonction,std::string text,std::string file,int ligne) const;
#endif
//other signals
void queryOneNewDialog() const;
void send_setFilters(const std::vector<Filters_rules> &include,const std::vector<Filters_rules> &exclude) const;
void send_sendNewRenamingRules(std::string firstRenamingRule,std::string otherRenamingRule) const;
void send_followTheStrictOrder(const bool &followTheStrictOrder) const;
void send_deletePartiallyTransferredFiles(const bool &deletePartiallyTransferredFiles) const;
void send_setInodeThreads(const int &inodeThreads) const;
void send_moveTheWholeFolder(const bool &moveTheWholeFolder) const;
void send_setRenameTheOriginalDestination(const bool &renameTheOriginalDestination) const;
};
#endif // COPY_ENGINE_H
|