Source code of Windows XP (NT5)
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.

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