Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

344 lines
9.8 KiB

  1. #ifndef _FT_MAIN_UI_H_
  2. #define _FT_MAIN_UI_H_
  3. #include "ftres.h"
  4. #include "combotb.h"
  5. #if defined(TEST_PLUGABLE) && defined(_DEBUG)
  6. #include "plugable.h"
  7. #endif
  8. #define WM_SEND_NEXT (WM_APP + 0x201)
  9. #define WM_BRING_TO_FRONT (WM_APP + 0x202)
  10. #define NUM_STATUS_BAR_PARTS 3
  11. #define SBP_TRANSFER_FILE 0
  12. #define SBP_PROGRESS 1
  13. #define SBP_SBICON 2
  14. typedef struct
  15. {
  16. ULONG idString;
  17. ULONG idCommand;
  18. UINT nFlags;
  19. }
  20. UI_MENU_INFO;
  21. typedef enum
  22. {
  23. FTUIMODE_SHOWUI = 0,
  24. FTUIMODE_UIHIDDEN,
  25. FTUIMODE_NOUI,
  26. }
  27. FTUIMode;
  28. class CAppletWindow;
  29. class CUiSendFileInfo
  30. {
  31. public:
  32. CUiSendFileInfo(CAppletWindow *, TCHAR szDir[], TCHAR szFile[], BOOL *pfRet);
  33. ~CUiSendFileInfo(void);
  34. // name
  35. LPTSTR GetFullName(void) { return m_pszFullName; }
  36. LPTSTR GetName(void) { return m_pszFileName; }
  37. // numbers
  38. ULONG GetSize(void) { return m_FileInfo.nFileSizeLow; }
  39. DWORD GetFileAttribute(void) { return m_FileInfo.dwFileAttributes; }
  40. FILETIME GetLastWrite(void) { return m_FileInfo.ftLastWriteTime; }
  41. ULONG GetTotalSend(void) { return m_cbTotalSend; }
  42. void SetTotalSend(ULONG cb) { m_cbTotalSend = cb; }
  43. void SetPercentSent(long percentSent){ m_percentSent = percentSent;}
  44. long GetPercentSent(){return m_percentSent;}
  45. // time
  46. FILETIME *GetLastWriteTime(void) { return &m_FileInfo.ftLastWriteTime; }
  47. FILETIME *GetLastAccessTime(void) { return &m_FileInfo.ftLastAccessTime; }
  48. FILETIME *GetCreationTime(void) { return &m_FileInfo.ftCreationTime; }
  49. // file handle
  50. MBFTFILEHANDLE GetFileHandle(void) { return m_nFileHandle; }
  51. void SetFileHandle(MBFTFILEHANDLE nFileHandle) { m_nFileHandle = nFileHandle; }
  52. // error code
  53. MBFT_ERROR_CODE GetErrorCode(void) { return m_eSendErrorCode; }
  54. void SetErrorCode(MBFT_ERROR_CODE err) { m_eSendErrorCode = err; }
  55. void SetShowUI(void) { m_fAlreadyShowUI = TRUE; }
  56. BOOL HasShownUI(void) { return m_fAlreadyShowUI; }
  57. private:
  58. HANDLE GetOpenFile(CAppletWindow *, TCHAR szDir[], TCHAR szFile[], BOOL fResolve);
  59. long m_percentSent;
  60. LPTSTR m_pszFullName; // allocated
  61. LPTSTR m_pszFileName; // handy shortcut
  62. ULONG m_cbTotalSend;
  63. MBFTFILEHANDLE m_nFileHandle;
  64. MBFT_ERROR_CODE m_eSendErrorCode;
  65. BOOL m_fAlreadyShowUI;
  66. BY_HANDLE_FILE_INFORMATION m_FileInfo;
  67. };
  68. class CUiRecvFileInfo
  69. {
  70. public:
  71. CUiRecvFileInfo(FileOfferNotifyMsg *pMsg, HRESULT *pHr);
  72. ~CUiRecvFileInfo(void);
  73. // name
  74. LPTSTR GetFullName(void) { return m_pszFullName; }
  75. LPTSTR GetName(void) { return m_pszFileName; }
  76. LPTSTR GetRecvFolder(void) { return m_pszRecvFolder; }
  77. // numbers
  78. ULONG GetSize(void) { return m_cbFileSize; }
  79. ULONG GetTotalRecvSize(void) { return m_cbTotalRecvSize; }
  80. void SetTotalRecvSize(ULONG cbTotalRecvSize) { m_cbTotalRecvSize = cbTotalRecvSize; }
  81. // file handle
  82. MBFTFILEHANDLE GetFileHandle(void) { return m_nFileHandle; }
  83. void SetFileHandle(MBFTFILEHANDLE nFileHandle) { m_nFileHandle = nFileHandle; }
  84. private:
  85. LPTSTR m_pszFullName; // allocated
  86. LPTSTR m_pszFileName; // handy shortcut
  87. MBFTFILEHANDLE m_nFileHandle;
  88. time_t m_FileDateTime;
  89. ULONG m_cbFileSize;
  90. ULONG m_cbTotalRecvSize;
  91. LPTSTR m_pszRecvFolder;
  92. };
  93. class CRecvDlg : public CRefCount
  94. {
  95. public:
  96. CRecvDlg(CAppletWindow*, T120ConfID, T120NodeID, MBFTEVENTHANDLE, CUiRecvFileInfo *, HRESULT *);
  97. ~CRecvDlg(void);
  98. void OnOpen(void);
  99. void OnDelete(void);
  100. void OnAccept(void);
  101. void StopAnimation(void);
  102. ULONG GetPercent(void);
  103. void OnProgressUpdate(FileTransmitMsg *pMsg = NULL);
  104. void OnCanceled(void);
  105. void OnRejectedFile(void);
  106. CUiRecvFileInfo *GetRecvFileInfo(void) { return m_pRecvFileInfo; }
  107. MBFTEVENTHANDLE GetEventHandle(void) { return m_nEventHandle; }
  108. MBFTFILEHANDLE GetFileHandle(void) { return m_pRecvFileInfo->GetFileHandle(); }
  109. HWND GetHwnd(void) { return m_hwndRecvDlg; }
  110. T120ConfID GetConfID(void) { return m_nConfID; }
  111. T120NodeID GetSenderID(void) { return m_nidSender; }
  112. ULONG GetTotalRecvSize(void) { return m_pRecvFileInfo->GetTotalRecvSize(); }
  113. BOOL IsRecvComplete(void) { return m_fRecvComplete; }
  114. private:
  115. HWND m_hwndRecvDlg;
  116. UINT m_idResult;
  117. CAppletWindow *m_pWindow;
  118. T120ConfID m_nConfID;
  119. T120NodeID m_nidSender;
  120. MBFTEVENTHANDLE m_nEventHandle;
  121. CUiRecvFileInfo *m_pRecvFileInfo;
  122. BOOL m_fRecvComplete;
  123. BOOL m_fShownRecvCompleteUI;
  124. HRESULT m_hr;
  125. DWORD m_dwEstTimeLeft;
  126. DWORD m_dwPreviousTime;
  127. DWORD m_dwPreviousTransferred;
  128. DWORD m_dwBytesPerSec;
  129. DWORD m_dwStartTime;
  130. };
  131. class CRecvDlgList : public CQueue
  132. {
  133. DEFINE_CQUEUE(CRecvDlgList, CRecvDlg*)
  134. };
  135. class CErrorDlgList : public CList
  136. {
  137. DEFINE_CLIST(CErrorDlgList, HWND);
  138. };
  139. class CAppletWindow : public CRefCount
  140. {
  141. friend LRESULT OnCreate(HWND hwnd, WPARAM wParam, LPARAM lParam);
  142. public:
  143. CAppletWindow(BOOL fNoUI, HRESULT *);
  144. ~CAppletWindow(void);
  145. public:
  146. BOOL FilterMessage(MSG *msg);
  147. //
  148. // Applet operation
  149. //
  150. void RegisterEngine(MBFTEngine *);
  151. void UnregisterEngine(void);
  152. void RegisterRecvDlg(CRecvDlg *);
  153. void UnregisterRecvDlg(CRecvDlg *);
  154. CRecvDlg *FindDlgByHandles(MBFTEVENTHANDLE, MBFTFILEHANDLE);
  155. BOOL IsInConference(void) { return (NULL != m_pEngine); }
  156. HWND GetHwnd(void) { return m_hwndMainUI; }
  157. HWND GetListView(void) { return m_hwndListView; }
  158. MBFTEngine *GetEngine(void) { return m_pEngine; }
  159. void OnEngineNotify(MBFTMsg *);
  160. BOOL QueryShutdown(BOOL fShutdown = TRUE);
  161. //
  162. // Windows message derivatives
  163. //
  164. // WM_CREATE
  165. BOOL CreateToolBar(void);
  166. BOOL CreateStatusBar(void);
  167. BOOL CreateListView(void);
  168. BOOL CreateProgressBar(void);
  169. // WM_NOTIFY
  170. void OnNotifyListView(LPARAM);
  171. // WM_DROPFILES
  172. LRESULT OnDropFiles(HANDLE hDrop);
  173. // WM_CONTEXTMENU
  174. void SetContextMenuStates(void);
  175. void OnContextMenuForMainUI(LPARAM lParam);
  176. void OnContextMenuForListView(LPARAM lParam);
  177. void CreateMenu(LPARAM lParam, ULONG cItems, UI_MENU_INFO aMenuInfo[]);
  178. // WM_SIZE
  179. void OnSizeToolBar(void);
  180. void OnSizeStatusBar(void);
  181. void OnSizeListView(void);
  182. // WM_GETMINMAXINFO
  183. void OnGetMinMaxInfo(LPMINMAXINFO);
  184. // WM_DRAWITEM
  185. void OnDrawItem(void);
  186. //
  187. // OnCommand
  188. //
  189. void OnAddFiles(void);
  190. void OnRemoveFiles(void);
  191. void OnRemoveAllFiles(void);
  192. void OnSendAll(void);
  193. void OnSendOne(void);
  194. void OnStopSending(void);
  195. void OnOpenRecvFolder(void);
  196. void OnExit(BOOL fNoQuery = FALSE); // exit point
  197. void OnHelp(void);
  198. void OnAbout(void);
  199. void OnMenuSelect(UINT uiItemID, UINT uiFlags, HMENU hSysMenu);
  200. //
  201. // OnEngineNotify
  202. //
  203. void HandleFileOfferNotify(FileOfferNotifyMsg *);
  204. void HandleProgressNotify(FileTransmitMsg *);
  205. void HandleErrorNotify(FileErrorMsg *);
  206. void HandleInitUninitNotification(InitUnInitNotifyMsg *);
  207. void HandleFileEventEndNotification(FileEventEndNotifyMsg *);
  208. void HandlePeerNotification(PeerMsg *pMdg);
  209. //
  210. // Other methods
  211. //
  212. void BringToFront(void);
  213. void ClearSendInfo(BOOL fUpdateMenu);
  214. void ClearRecvInfo(void);
  215. void UpdateUI(void); // UpdateMenu && UpdateToolBar
  216. void UpdateTitle(void);
  217. void UpdateMenu(void);
  218. void UpdateToolBar(void);
  219. void UpdateStatusBar(void);
  220. void UpdateListView(CUiSendFileInfo *);
  221. void ResolveShortcut(LPTSTR pszFile, LPTSTR pszFileDest);
  222. BOOL DrawItem(LPDRAWITEMSTRUCT);
  223. void OnCommand(WORD wId, HWND hwndCtl, WORD codeNotify);
  224. void SetSendMode(BOOL fSendALL) { m_fSendALL = fSendALL; };
  225. void FocusNextRecvDlg(void);
  226. void FocusNextErrorDlg(void);
  227. CUiSendFileInfo *ChooseFirstUnSentFile(void);
  228. CUiSendFileInfo *ChooseSelectedFile(void);
  229. BOOL UIHidden(void) { return m_UIMode != FTUIMODE_SHOWUI; }
  230. FTUIMode GetUIMode(void) { return m_UIMode; }
  231. void AddErrorDlg(HWND hwndErrorDlg) { m_ErrorDlgList.Prepend(hwndErrorDlg); }
  232. void RemoveErrorDlg(HWND hwndErrorDlg) { m_ErrorDlgList.Remove(hwndErrorDlg); }
  233. void SetListViewFocus(void){ListView_SetItemState(m_hwndListView, 0, LVIS_SELECTED | LVIS_FOCUSED,LVIS_SELECTED | LVIS_FOCUSED);}
  234. protected:
  235. void SetHwnd(HWND hwnd) { ASSERT(NULL == m_hwndMainUI); m_hwndMainUI = hwnd; }
  236. void SaveWindowPosition(void);
  237. BOOL HasUnSentFiles(BOOL fUnSentOnly = TRUE);
  238. BOOL SendNow(CUiSendFileInfo *pFileInfo);
  239. BOOL FBrowseForFolder(LPTSTR pszFolder, UINT cchMax, LPCTSTR pszTitle);
  240. BOOL IsReceiving(void);
  241. private:
  242. HWND m_hwndMainUI;
  243. HWND m_hwndStatusBar;
  244. HWND m_hwndListView;
  245. HWND m_hwndProgressBar; // progress bar
  246. CComboToolbar *m_pToolbar;
  247. HACCEL m_hAccel;
  248. HACCEL m_hLVAccel;
  249. TCHAR m_szDefaultDir[MAX_PATH];
  250. HICON m_hIconInCall; // Incall icon
  251. HICON m_hIconNotInCall; // Not incall icon
  252. MBFTEngine *m_pEngine;
  253. CRecvDlgList m_RecvDlgList;
  254. CErrorDlgList m_ErrorDlgList;
  255. BOOL m_fInFileOpenDialog;
  256. BOOL m_fSendALL; // flag indicating whether to send one file only
  257. FTUIMode m_UIMode; // whether the UI is hidden
  258. CUiSendFileInfo*m_pCurrSendFileInfo;
  259. MBFTEVENTHANDLE m_nCurrSendEventHandle;
  260. TCHAR m_szFtMainWndClassName[32];
  261. };
  262. HRESULT GetRecvFolder(LPTSTR pszInFldr, LPTSTR pszOutFldr);
  263. #endif // _FT_MAIN_UI_H_