[go: up one dir, main page]

Menu

[r25]: / Worker.h  Maximize  Restore  History

Download this file

144 lines (119 with data), 3.3 kB

  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
#pragma once
#include <windows.h>
#include <commctrl.h>
#include "Error.h"
#include "Token.h"
typedef enum NetResType {
NRT_WORKER,
NRT_NETWORK,
NRT_DOMAIN,
NRT_COMPUTER,
NRT_SHARE
} NetResType;
typedef struct COLUMNS {
unsigned count;
struct {
int left;
int width;
} item[10];
} COLUMNS, *PCOLUMNS;
extern const DWORD MSG_NETNOTIFY;
typedef enum NetNotifyMessages {
NNM_ENUMSTARTED,
NNM_ENUMFINISHED,
NNM_ITEMADDED, // lParam : item ptr
NNM_THREADCNTCHANGED, // lParam : lo = active / hi = total
NNM_EMPTYDETECTED // lParam : this
} NetNotifyMessages;
// Thread count limiting
extern LONG ThreadCount; // currently running threads (including waiting for start)
extern LONG ActiveThreads;
extern HANDLE semThreadLimit; // semaphore for limiting simulatneous threads
extern CRITICAL_SECTION secLogin; // only one thread can login at once
extern LPCTSTR semName;
class CWorker;
typedef void (*OnItemSelect)(CWorker* obj);
class CWorker {
public:
typedef enum _ThreadState{
STOPPED,
WAITING,
RUNNING,
COMPLETED,
FAIL_RUN,
FAIL_FINISHED
} ThreadState;
// GUI
LRESULT OnNotifyMsg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, OnItemSelect selproc);
virtual int Filter(CToken *filter, int col);
void Sort(bool recurse);
virtual bool Save(HANDLE file);
virtual void Draw(LPNMTVCUSTOMDRAW nmcd, PCOLUMNS cols);
void Unfold();
void Expand();
//
void SetState(ThreadState newstate);
void DebugWrite(LPCTSTR str);
CWorker( HWND control );
CWorker( HANDLE file, CWorker* parentnode, HWND control );
virtual ~CWorker();
virtual bool Search(LPCTSTR mask, DWORD minSizeMB, DWORD maxSizeMB);
void Start(bool AutoRecurse);// = false);
void Stop(unsigned timeout, bool recursive = false);
// List manage
CWorker* AddItem(CWorker *item); // return -1 on error;
CWorker* AddNoCheck(CWorker *item, bool TreeOnly = false);
bool RemoveItem(unsigned index); // false on error
bool RemoveItem(CWorker *item); // false on error
void ClearList();
unsigned GetItemIndex(CWorker *ptr);
CWorker* GetParentNode();
NetResType GetType();
virtual inline bool HasAnything();
virtual inline unsigned GetCount();
virtual inline CWorker* operator[](unsigned index);
LPTSTR m_Name;
bool expanded;
HTREEITEM tvItem;
const NetResType type;
protected:
typedef struct NETPROPBAG {
NetResType type;
unsigned children;
unsigned NameLen;
} NETPROPBAG;
struct LOCK {
HANDLE event;
DWORD ThreadID;
DWORD locks;
} lock;
bool ExclusiveLock(DWORD timeout = INFINITE);
void ExclusiveRelease();
void PostNotify(NetNotifyMessages code, LPARAM lParam);
virtual void UpdateStatus();
virtual void Work();
CWorker* parent;
HWND hwndNotify;
bool cancelWork;
bool AutoStart;
Error err;
unsigned children_to_load;
HANDLE hEnum;
HANDLE hThread;
DWORD idThread;
private:
CRITICAL_SECTION exclusive1;
bool AllocList(unsigned size);
void SignalRecursive(bool value);
unsigned allocated;
unsigned count;
CWorker **lpList;
ThreadState state;
struct {
int col;
CToken *token;
} filter;
RECT rcItem;
static DWORD WINAPI AsyncFilterThread( void * This );
static DWORD WINAPI AsyncStartThread( void * This );
};