| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
#if !defined(AFX_MWWATCHERDLG_H__2639544C_D040_493C_A9AC_80413B2861E6__INCLUDED_) |
|---|
| 24 |
#define AFX_MWWATCHERDLG_H__2639544C_D040_493C_A9AC_80413B2861E6__INCLUDED_ |
|---|
| 25 |
|
|---|
| 26 |
#if _MSC_VER > 1000 |
|---|
| 27 |
#pragma once |
|---|
| 28 |
#endif // _MSC_VER > 1000 |
|---|
| 29 |
|
|---|
| 30 |
#define WM_SHOWTASK (WM_USER + 201) |
|---|
| 31 |
#define MAX_DIR_WATCH 10 |
|---|
| 32 |
|
|---|
| 33 |
#define IDT_RUN_TIMER 1 |
|---|
| 34 |
#define IDT_GLOBAL_TIMER 2 |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
#include "DirectoryChanges.h" |
|---|
| 39 |
|
|---|
| 40 |
class CDirectoryChangeHandler_ListBox : public CDirectoryChangeHandler |
|---|
| 41 |
{ |
|---|
| 42 |
public: |
|---|
| 43 |
CDirectoryChangeHandler_ListBox(CListBox & list_box); |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
~CDirectoryChangeHandler_ListBox(); |
|---|
| 47 |
protected: |
|---|
| 48 |
|
|---|
| 49 |
void On_FileAdded(const CString & strFileName) |
|---|
| 50 |
{ |
|---|
| 51 |
CString strTemp(_T("File Added: ") + strFileName); |
|---|
| 52 |
AddNotification(strTemp); |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
} |
|---|
| 58 |
void On_FileRemoved(const CString & strFileName) |
|---|
| 59 |
{ |
|---|
| 60 |
CString strTemp(_T("File Removed: ") + strFileName); |
|---|
| 61 |
AddNotification(strTemp); |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
} |
|---|
| 66 |
void On_FileModified(const CString & strFileName) |
|---|
| 67 |
{ |
|---|
| 68 |
CString strTemp(_T("File Modified: ") + strFileName); |
|---|
| 69 |
AddNotification(strTemp); |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
} |
|---|
| 74 |
void On_FileNameChanged(const CString & strOldFileName, const CString & strNewFileName) |
|---|
| 75 |
{ |
|---|
| 76 |
CString strTemp(_T("File name changed from: ") + strOldFileName + _T(" to: ") + strNewFileName); |
|---|
| 77 |
AddNotification(strTemp); |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
} |
|---|
| 82 |
|
|---|
| 83 |
void On_WatchStarted(DWORD dwError, const CString & strDirectoryName) |
|---|
| 84 |
{ |
|---|
| 85 |
if( dwError == 0 ) |
|---|
| 86 |
{ |
|---|
| 87 |
CString strTemp( _T("Directory Watch Started: ") + strDirectoryName); |
|---|
| 88 |
AddNotification(strTemp); |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
} |
|---|
| 93 |
else |
|---|
| 94 |
{ |
|---|
| 95 |
CString strTemp( _T("Directory watch failed: ") + strDirectoryName); |
|---|
| 96 |
AddNotification(strTemp); |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
} |
|---|
| 101 |
} |
|---|
| 102 |
void On_WatchStopped(const CString & strDirectoryName) |
|---|
| 103 |
{ |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
if( ::IsWindow( m_listBox.GetSafeHwnd() ) ) |
|---|
| 111 |
{ |
|---|
| 112 |
CString strTemp(_T("Stopped watching directory: ") + strDirectoryName); |
|---|
| 113 |
AddNotification(strTemp); |
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
} |
|---|
| 118 |
else |
|---|
| 119 |
{ |
|---|
| 120 |
TRACE(_T("NOTE: m_listBox is not a valid window! This has probably been called as the result of program shutdown sometime after CDirWatcherDlg::OnBtnMonitor2() was used to watch a direcotry.\n")); |
|---|
| 121 |
TRACE(_T("NOTE: Be sure that you are careful in your implementation of this function to watch out for the same condition if you are dealing w/ windows.\n")); |
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
} |
|---|
| 131 |
} |
|---|
| 132 |
void On_FileUploaded(const CString & strFileName) |
|---|
| 133 |
{ |
|---|
| 134 |
CString strTemp(_T("File Uploaded: ") + strFileName); |
|---|
| 135 |
AddNotification(strTemp); |
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
} |
|---|
| 140 |
|
|---|
| 141 |
CListBox & m_listBox; |
|---|
| 142 |
HANDLE hLogFile; |
|---|
| 143 |
HANDLE hMutex; |
|---|
| 144 |
BOOL bIsLog; |
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
private: |
|---|
| 148 |
void SetHorizontalBar(); |
|---|
| 149 |
void AddNotification(const CString &strMessage); |
|---|
| 150 |
}; |
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
class CMwWatcherDlg : public CDialog |
|---|
| 156 |
{ |
|---|
| 157 |
|
|---|
| 158 |
public: |
|---|
| 159 |
CMwWatcherDlg(CWnd* pParent = NULL); |
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
enum { IDD = IDD_MWWATCHER_DIALOG }; |
|---|
| 164 |
CListBox m_SettingBox; |
|---|
| 165 |
CListBox m_NotifyBox; |
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
protected: |
|---|
| 172 |
virtual void DoDataExchange(CDataExchange* pDX); |
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
protected: |
|---|
| 177 |
HICON m_hIcon; |
|---|
| 178 |
LONG m_old_cx; |
|---|
| 179 |
LONG m_old_cy; |
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
virtual BOOL OnInitDialog(); |
|---|
| 184 |
afx_msg void OnSysCommand(UINT nID, LPARAM lParam); |
|---|
| 185 |
afx_msg void OnPaint(); |
|---|
| 186 |
afx_msg HCURSOR OnQueryDragIcon(); |
|---|
| 187 |
virtual void OnCancel(); |
|---|
| 188 |
virtual void OnOK(); |
|---|
| 189 |
afx_msg void OnHide(); |
|---|
| 190 |
afx_msg LRESULT OnBtnShowTask(WPARAM wParam,LPARAM lParam); |
|---|
| 191 |
afx_msg void OnRestart(); |
|---|
| 192 |
afx_msg void OnChangeSettings(); |
|---|
| 193 |
afx_msg void OnTimer(UINT nIDEvent); |
|---|
| 194 |
afx_msg void OnClear(); |
|---|
| 195 |
afx_msg void OnSize(UINT nType, int cx, int cy); |
|---|
| 196 |
|
|---|
| 197 |
DECLARE_MESSAGE_MAP() |
|---|
| 198 |
|
|---|
| 199 |
CDirectoryChangeWatcher m_DirWatcher; |
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
DWORD GetChangeFlags(int n); |
|---|
| 203 |
BOOL GetWatchSubDirFlag(int n); |
|---|
| 204 |
void GetDirectoryToMonitor(int n); |
|---|
| 205 |
BOOL GetFilterFlag(void); |
|---|
| 206 |
void GetRebootSetting(void); |
|---|
| 207 |
BOOL GetUploadMethod(void); |
|---|
| 208 |
void GetDelayTime(void); |
|---|
| 209 |
|
|---|
| 210 |
BOOL InitService(int n); |
|---|
| 211 |
void InitFtp(); |
|---|
| 212 |
|
|---|
| 213 |
void FtpInit(); |
|---|
| 214 |
void FtpPut(); |
|---|
| 215 |
|
|---|
| 216 |
void CopyPut(); |
|---|
| 217 |
|
|---|
| 218 |
void Reboot(); |
|---|
| 219 |
|
|---|
| 220 |
BOOL isInWhiteList(const CString &strFileName); |
|---|
| 221 |
|
|---|
| 222 |
CString strInitFilePath; |
|---|
| 223 |
|
|---|
| 224 |
private: |
|---|
| 225 |
CString m_strDirectoryToMonitor[MAX_DIR_WATCH]; |
|---|
| 226 |
CString strInitCommand; |
|---|
| 227 |
CString strGFtpAddress; |
|---|
| 228 |
CString strGFtpUserName; |
|---|
| 229 |
CString strGFtpUserPasswd; |
|---|
| 230 |
CString strGFtpPath; |
|---|
| 231 |
DWORD dwGDelay; |
|---|
| 232 |
LONG lRebootTime; |
|---|
| 233 |
BOOL bSetReboot; |
|---|
| 234 |
BOOL bFtpPut; |
|---|
| 235 |
HANDLE hLogFile; |
|---|
| 236 |
CHAR HomePath[MAX_PATH+1]; |
|---|
| 237 |
}; |
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 |
|
|---|
| 241 |
|
|---|
| 242 |
#endif // !defined(AFX_MWWATCHERDLG_H__2639544C_D040_493C_A9AC_80413B2861E6__INCLUDED_) |
|---|