source: filezilla/trunk/fuentes/src/interface/recursive_operation.h @ 130

Last change on this file since 130 was 130, checked in by jrpelegrina, 3 years ago

First release to xenial

File size: 2.7 KB
Line 
1#ifndef __RECURSIVE_OPERATION_H__
2#define __RECURSIVE_OPERATION_H__
3
4#include "state.h"
5#include <set>
6#include "filter.h"
7
8class CChmodDialog;
9class CQueueView;
10
11class CRecursiveOperation final : public CStateEventHandler
12{
13public:
14        CRecursiveOperation(CState* pState);
15        ~CRecursiveOperation();
16
17        enum OperationMode
18        {
19                recursive_none,
20                recursive_download,
21                recursive_addtoqueue,
22                recursive_download_flatten,
23                recursive_addtoqueue_flatten,
24                recursive_delete,
25                recursive_chmod,
26                recursive_list
27        };
28
29        void StartRecursiveOperation(OperationMode mode, const CServerPath& startDir, std::vector<CFilter> const& filters, bool allowParent = false, const CServerPath& finalDir = CServerPath());
30        void StopRecursiveOperation();
31
32        void AddDirectoryToVisit(const CServerPath& path, const wxString& subdir, const CLocalPath& localDir = CLocalPath(), bool is_link = false);
33        void AddDirectoryToVisitRestricted(const CServerPath& path, const wxString& restrict, bool recurse);
34
35        bool IsActive() const { return GetOperationMode() != recursive_none; }
36        OperationMode GetOperationMode() const { return m_operationMode; }
37        int64_t GetProcessedFiles() const { return m_processedFiles; }
38        int64_t GetProcessedDirectories() const { return m_processedDirectories; }
39
40        // Needed for recursive_chmod
41        void SetChmodDialog(CChmodDialog* pChmodDialog);
42
43        void ListingFailed(int error);
44        void LinkIsNotDir();
45
46        void SetQueue(CQueueView* pQueue);
47
48        bool ChangeOperationMode(OperationMode mode);
49
50protected:
51        // Processes the directory listing in case of a recursive operation
52        void ProcessDirectoryListing(const CDirectoryListing* pDirectoryListing);
53
54        bool NextOperation();
55
56        virtual void OnStateChange(CState* pState, t_statechange_notifications notification, const wxString&, const void* data2);
57
58        OperationMode m_operationMode;
59
60        class CNewDir final
61        {
62        public:
63                CServerPath parent;
64                wxString subdir;
65                CLocalPath localDir;
66                bool doVisit{true};
67
68                bool recurse{true};
69                wxString restrict;
70
71                bool second_try{};
72
73                // 0 = not a link
74                // 1 = link, added by class during the operation
75                // 2 = link, added by user of class
76                int link{};
77
78                // Symlink target might be outside actual start dir. Yet
79                // sometimes user wants to download symlink target contents
80                CServerPath start_dir;
81        };
82
83        bool BelowRecursionRoot(const CServerPath& path, CNewDir &dir);
84
85        CServerPath m_startDir;
86        CServerPath m_finalDir;
87        std::set<CServerPath> m_visitedDirs;
88        std::deque<CNewDir> m_dirsToVisit;
89
90        bool m_allowParent{};
91
92        // Needed for recursive_chmod
93        CChmodDialog* m_pChmodDlg{};
94
95        CQueueView* m_pQueue{};
96
97        std::vector<CFilter> m_filters;
98
99        friend class CCommandQueue;
100
101        uint64_t m_processedFiles{};
102        uint64_t m_processedDirectories{};
103};
104
105#endif //__RECURSIVE_OPERATION_H__
Note: See TracBrowser for help on using the repository browser.