Index: src/ch/Structs.h =================================================================== diff -u -N -rd5c3edd0d167db9b5d47d04248820fda49499a5e -r49b67b7417f8b42ce581ebfe604f47df841f763b --- src/ch/Structs.h (.../Structs.h) (revision d5c3edd0d167db9b5d47d04248820fda49499a5e) +++ src/ch/Structs.h (.../Structs.h) (revision 49b67b7417f8b42ce581ebfe604f47df841f763b) @@ -19,49 +19,10 @@ #ifndef __STRUCTS_H__ #define __STRUCTS_H__ -#include "FileInfo.h" -#include "FileFilter.h" #include "DestPath.h" -#include "DataBuffer.h" //#include "LogFile.h" #include "../libicpf/log.h" -#include "../libchcore/FeedbackHandlerBase.h" -#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_FINISHED 0x00000004 -#define ST_CANCELLED 0x00000005 - -//------------------------------------ -#define ST_OPERATION_MASK 0x00000f00 -#define ST_COPY 0x00000100 -// moving - delete after copying all files -#define ST_MOVE 0x00000200 - -//------------------------------------ -#define ST_SPECIAL_MASK 0x0000f000 -// simultaneous flags -#define ST_IGNORE_DIRS 0x00001000 -#define ST_IGNORE_CONTENT 0x00002000 -#define ST_FORCE_DIRS 0x00004000 - -//------------------------------------ -#define ST_WORKING_MASK 0x000f0000 -#define ST_ERROR 0x000C0000 -#define ST_PAUSED 0x00080000 - -//------------------------------------ -#define ST_WAITING_MASK 0x00f00000 -#define ST_WAITING 0x00100000 - - ///////////////////////////////////////////////////////////////////////////// // priority @@ -78,336 +39,11 @@ #define E_CANCEL 0x02 #define E_PAUSE 0x03 -///////////////////////////////////////////////////////////////////// -// CTask -struct TASK_CREATE_DATA -{ - __int64 *pTasksProcessed; - __int64 *pTasksAll; - - UINT *puiOperationsPending; - LONG *plFinished; - - CCriticalSection* pcs; - - UINT (*pfnTaskProc)(LPVOID pParam); -}; - -// structure for gettings status of a task -struct TASK_DISPLAY_DATA -{ - CFileInfo m_fi; // fi at CurrIndex - int m_iCurrentBufferIndex; - int m_iIndex; - int m_iSize; - - CDestPath* m_pdpDestPath; - CFiltersArray* m_pafFilters; - - UINT m_uiStatus; - DWORD m_dwOsErrorCode; - CString m_strErrorDesc; - - const BUFFERSIZES* m_pbsSizes; - int m_nPriority; - - ull_t m_ullProcessedSize; - ull_t m_ullSizeAll; - int m_nPercent; - - long m_lTimeElapsed; - - unsigned char m_ucCurrentCopy; - unsigned char m_ucCopies; - - const CString* m_pstrUniqueName; // doesn't change from first setting - - TCHAR m_szStatusText[_MAX_PATH]; -}; - -struct TASK_MINI_DISPLAY_DATA -{ - CFileInfo m_fi; // fi at CurrIndex - - UINT m_uiStatus; - int m_nPercent; -}; - -class CTask -{ -public: - CTask(chcore::IFeedbackHandler* piFeedbackHandler, const TASK_CREATE_DATA *pCreateData); - ~CTask(); -public: - -// Attributes -public: - // m_clipboard - int AddClipboardData(CClipboardEntry* pEntry); - CClipboardEntry* GetClipboardData(int nIndex); - int GetClipboardDataSize(); - int ReplaceClipboardStrings(CString strOld, CString strNew); - - // m_files - int FilesAddDir(const CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, - const bool bRecurse, const bool bIncludeDirs); - int FilesAdd(CFileInfo fi); - CFileInfo FilesGetAt(int nIndex); - CFileInfo& FilesGetAtCurrentIndex(); - void FilesRemoveAll(); - int FilesGetSize(); - - // m_nCurrentIndex - void IncreaseCurrentIndex(); - int GetCurrentIndex(); - void SetCurrentIndex(int nIndex); - - // m_strDestPath - void SetDestPath(LPCTSTR lpszPath); - const CDestPath& GetDestPath(); - int GetDestDriveNumber(); - - // m_nStatus - void SetStatus(UINT nStatus, UINT nMask); - UINT GetStatus(UINT nMask=0xffffffff); - - // m_nBufferSize - void SetBufferSizes(const BUFFERSIZES* bsSizes); - const BUFFERSIZES* GetBufferSizes(); - int GetCurrentBufferIndex(); - - // m_pThread - // m_nPriority - int GetPriority(); - void SetPriority(int nPriority); - - // m_nProcessed - void IncreaseProcessedSize(__int64 nSize); - void SetProcessedSize(__int64 nSize); - __int64 GetProcessedSize(); - - // m_nAll - void SetAllSize(__int64 nSize); - __int64 GetAllSize(); - void CalcAllSize(); - - // m_pnTasksProcessed - void IncreaseProcessedTasksSize(__int64 nSize); - void DecreaseProcessedTasksSize(__int64 nSize); - - // m_pnTasksAll - void IncreaseAllTasksSize(__int64 nSize); - void DecreaseAllTasksSize(__int64 nSize); - - // m_bKill - void SetKillFlag(bool bKill=true); - bool GetKillFlag(); - - // m_bKilled - void SetKilledFlag(bool bKilled=true); - bool GetKilledFlag(); - - void KillThread(); - void CleanupAfterKill(); - - // m_strUniqueName - CString GetUniqueName(); - - void Load(icpf::archive& ar, bool bData); - void Store(bool bData); - - void BeginProcessing(); - - void PauseProcessing(); // pause - void ResumeProcessing(); // resume - bool RetryProcessing(bool bOnlyErrors=false, UINT uiInterval=0); // retry - void RestartProcessing(); // from beginning - void CancelProcessing(); // cancel - - void GetSnapshot(TASK_DISPLAY_DATA *pData); - void GetMiniSnapshot(TASK_MINI_DISPLAY_DATA *pData); - - void DeleteProgress(LPCTSTR lpszDirectory); - - void SetOsErrorCode(DWORD dwError, LPCTSTR lpszErrDesc); - void CalcProcessedSize(); - - void DecreaseOperationsPending(UINT uiBy=1); - void IncreaseOperationsPending(UINT uiBy=1); - - bool CanBegin(); - - void UpdateTime(); - - void SetFilters(const CFiltersArray* pFilters); - const CFiltersArray* GetFilters(); - - void SetCopies(unsigned char ucCopies); - unsigned char GetCopies(); - void SetCurrentCopy(unsigned char ucCopy); - unsigned char GetCurrentCopy(); - - CClipboardArray* GetClipboard() { return &m_clipboard; }; - - void SetLastProcessedIndex(int iIndex); - int GetLastProcessedIndex(); - -// CString GetLogName(); - - bool GetRequiredFreeSpace(ull_t *pi64Needed, ull_t *pi64Available); - - void SetTaskPath(const tchar_t* pszDir); - const tchar_t* GetTaskPath() const; - - chcore::IFeedbackHandler* GetFeedbackHandler() const { return m_piFeedbackHandler; } - -// Implementation -protected: - CClipboardArray m_clipboard; - CFileInfoArray m_files; - volatile int m_nCurrentIndex; - int m_iLastProcessedIndex; - - CDestPath m_dpDestPath; - - volatile UINT m_nStatus; - - // info about last error - DWORD m_lOsError; - CString m_strErrorDesc; - - // buffers - BUFFERSIZES m_bsSizes; - - CWinThread *m_pThread; - int m_nPriority; - - __int64 m_nProcessed; - __int64 m_nAll; - - __int64 *m_pnTasksProcessed; - __int64 *m_pnTasksAll; - - bool m_bQueued; // has operations pending for this task been increased ? - UINT *m_puiOperationsPending; - - volatile bool m_bKill; - volatile bool m_bKilled; - - // other stuff - CString m_strUniqueName; - - // mask (filter) - CFiltersArray m_afFilters; - - // copies count - unsigned char m_ucCopies; - unsigned char m_ucCurrentCopy; - - tstring_t m_strTaskBasePath; // base path at which the files will be stored - bool m_bSaved; // has the state been saved ('til next modification) - -public: - UINT m_uiResumeInterval; // works only if the thread is off - // time - long m_lTimeElapsed; // store - long m_lLastTime; // not store - - // feedback - chcore::IFeedbackHandler* m_piFeedbackHandler; - int m_iIdentical; - int m_iDestinationLess; - int m_iDestinationGreater; - int m_iMissingInput; - int m_iOutputError; - int m_iMoveFile; - - // ptr to count of currently started tasks - LONG* m_plFinished; - bool m_bForce; // if the continuation of tasks should be independent of limitation - bool m_bContinue; // used by ClipboardMonitorProc - -protected: - CCriticalSection* m_pcs; // protects *m_pnTasksProcessed & *m_pnTasksAll from external array - - UINT (*m_pfnTaskProc)(LPVOID pParam); // external function that processes this task -public: - void SetForceFlag(bool bFlag=true); - bool GetForceFlag(); - void SetContinueFlag(bool bFlag=true); - bool GetContinueFlag(); - -// CLogFile m_log; - icpf::log_file m_log; - mutable CCriticalSection m_cs; // protection for this class -}; - /////////////////////////////////////////////////////////////////////////// -// CTaskArray - -class CTaskArray : public CArray -{ -public: - CTaskArray(); - ~CTaskArray(); - - void Create(chcore::IFeedbackHandlerFactory* piFeedbackHandlerFactory, UINT (*pfnTaskProc)(LPVOID pParam)); - - CTask* CreateTask(); - - int GetSize( ); - int GetUpperBound( ); - void SetSize( int nNewSize, int nGrowBy = -1 ); - - CTask* GetAt( int nIndex ); -// void SetAt( int nIndex, CTask* newElement ); - int Add( CTask* newElement ); - - void RemoveAt( int nIndex, int nCount = 1 ); - void RemoveAll(); - void RemoveAllFinished(); - void RemoveFinished(CTask** pSelTask); - - void SaveData(); - void SaveProgress(); - void LoadDataProgress(); - - void TasksBeginProcessing(); - void TasksPauseProcessing(); - void TasksResumeProcessing(); - void TasksRestartProcessing(); - bool TasksRetryProcessing(bool bOnlyErrors=false, UINT uiInterval=0); - void TasksCancelProcessing(); - - ull_t GetPosition(); - ull_t GetRange(); - int GetPercent(); - - UINT GetOperationsPending(); - void SetLimitOperations(UINT uiLimit); - UINT GetLimitOperations(); - - bool IsFinished(); - - void SetTasksDir(const tchar_t* pszPath) { m_strTasksDir = pszPath; } - -public: - __int64 m_uhRange, m_uhPosition; - tstring_t m_strTasksDir; - - UINT m_uiOperationsPending; // count of current operations - LONG m_lFinished; // count of finished tasks - - CCriticalSection m_cs; - TASK_CREATE_DATA m_tcd; - -protected: - chcore::IFeedbackHandlerFactory* m_piFeedbackFactory; -}; - -/////////////////////////////////////////////////////////////////////////// // CLIPBOARDMONITORDATA +class CTaskArray; +class CTask; struct CLIPBOARDMONITORDATA {