Index: src/ch/task.h =================================================================== diff -u -N -rcac4819aa32d29c9feab400cadc083d713459a82 -r79b981925588ba300cae07d965e12aa590aa7a91 --- src/ch/task.h (.../task.h) (revision cac4819aa32d29c9feab400cadc083d713459a82) +++ src/ch/task.h (.../task.h) (revision 79b981925588ba300cae07d965e12aa590aa7a91) @@ -30,15 +30,7 @@ #define ST_NULL_STATUS 0x00000000 -#define ST_WRITE_MASK 0x000fffff - //------------------------------------ -#define ST_STEP_MASK 0x000000ff -#define ST_SEARCHING 0x00000001 -#define ST_COPYING 0x00000002 -#define ST_DELETING 0x00000003 - -//------------------------------------ #define ST_SPECIAL_MASK 0x0000f000 // simultaneous flags #define ST_IGNORE_DIRS 0x00001000 @@ -63,10 +55,25 @@ // enum represents type of the operation handled by the task enum EOperationType { + eOperation_None, eOperation_Copy, - eOperation_Move + eOperation_Move, + + // add new operation types before this enum value + eOperation_Max }; +enum ESubOperationType +{ + eSubOperation_None, + eSubOperation_Scanning, + eSubOperation_Copying, + eSubOperation_Deleting, + + // add new operation types before this one + eSubOperation_Max +}; + // special value representing no task #define NO_TASK_SESSION_UNIQUE_ID 0 @@ -323,6 +330,10 @@ unsigned long long GetCurrentFileProcessedSize() const; void IncreaseCurrentFileProcessedSize(unsigned long long ullSizeToAdd); + void SetSubOperationIndex(size_t stSubOperationIndex); + size_t GetSubOperationIndex() const; + void IncreaseSubOperationIndex(); + template void load(Archive& ar, unsigned int /*uiVersion*/) { @@ -332,10 +343,14 @@ unsigned long long ullCurrentFileProcessedSize = 0; ar >> ullCurrentFileProcessedSize; + size_t stSubOperationIndex = 0; + ar >> stSubOperationIndex; + boost::unique_lock lock(m_lock); m_stCurrentIndex = stCurrentIndex; m_ullCurrentFileProcessedSize = ullCurrentFileProcessedSize; + m_stSubOperationIndex = stSubOperationIndex; } template @@ -345,24 +360,67 @@ size_t stCurrentIndex = m_stCurrentIndex; unsigned long long ullCurrentFileProcessedSize = m_ullCurrentFileProcessedSize; + size_t stSubOperationIndex = m_stSubOperationIndex; m_lock.unlock_shared(); ar << stCurrentIndex; ar << ullCurrentFileProcessedSize; + ar << stSubOperationIndex; } BOOST_SERIALIZATION_SPLIT_MEMBER(); private: + volatile size_t m_stSubOperationIndex; // index of sub-operation from TOperationDescription volatile size_t m_stCurrentIndex; // index to the m_files array stating currently processed item volatile unsigned long long m_ullCurrentFileProcessedSize; // count of bytes processed for current file mutable boost::shared_mutex m_lock; }; /////////////////////////////////////////////////////////////////////////// +// TOperationDescription + +// class describes the sub-operations to be performed +class TOperationDescription +{ +public: + TOperationDescription(); + ~TOperationDescription(); + + void SetOperationType(EOperationType eOperation); + EOperationType GetOperationType() const; + + size_t GetSubOperationsCount() const; + ESubOperationType GetSubOperationAt(size_t stIndex) const; + + template + void load(Archive& ar, unsigned int /*uiVersion*/) + { + EOperationType eOperation = eOperation_None; + ar >> eOperation; + SetOperationType(eOperation); + } + + template + void save(Archive& ar, unsigned int /*uiVersion*/) const + { + ar << m_eOperation; + } + + BOOST_SERIALIZATION_SPLIT_MEMBER(); + +private: + EOperationType m_eOperation; + std::vector m_vSubOperations; + + mutable boost::shared_mutex m_lock; +}; + +/////////////////////////////////////////////////////////////////////////// // CTask + class CTask { protected: @@ -526,8 +584,6 @@ CClipboardArray m_clipboard; // original paths with which we started operation CDestPath m_dpDestPath; // destination path - EOperationType m_eOperation; // operation which is to be performed by this task object - // task settings int m_nPriority; // task priority (really processing thread priority) @@ -543,6 +599,8 @@ // changing fast volatile ETaskCurrentState m_eCurrentState; // current state of processing this task represents + TOperationDescription m_tOperation; // manages the operation and its suboperations + volatile UINT m_nStatus; // what phase of the operation is this task in TTaskProgressInfo m_tTaskProgressInfo; // task progress information