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.

231 lines
7.3 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // SpamUI.h
  4. //
  5. ///////////////////////////////////////////////////////////////////////////////
  6. // Bring in only once
  7. #pragma once
  8. #include "oerules.h"
  9. #include "rulesui.h"
  10. #include "addrrule.h"
  11. enum SENDER_FLAGS
  12. {
  13. SNDF_NONE = 0x00000000,
  14. SNDF_MAIL = 0x00000001,
  15. SNDF_NEWS = 0x00000002
  16. };
  17. enum EXCPTLIST_FLAGS
  18. {
  19. ELF_NONE = 0x00000000,
  20. ELF_WAB = 0x00000001
  21. };
  22. // Type definitions
  23. typedef struct tagCOLUMNITEM
  24. {
  25. UINT uidsName;
  26. UINT uiWidth;
  27. } COLUMNITEM, * PCLOUMNITEM;
  28. typedef struct tagEDIT_SENDER
  29. {
  30. DWORD dwFlags;
  31. LONG lSelected;
  32. LPSTR pszSender;
  33. } EDIT_SENDER, * PEDIT_SENDER;
  34. // Class definitions
  35. class CEditSenderUI
  36. {
  37. private:
  38. enum
  39. {
  40. STATE_UNINIT = 0x00000000,
  41. STATE_INITIALIZED = 0x00000001,
  42. STATE_DIRTY = 0x00000002
  43. };
  44. private:
  45. HWND m_hwndOwner;
  46. DWORD m_dwFlags;
  47. DWORD m_dwState;
  48. HWND m_hwndDlg;
  49. HWND m_hwndSender;
  50. EDIT_SENDER * m_pEditSender;
  51. public:
  52. CEditSenderUI() : m_hwndOwner(NULL), m_dwFlags(0), m_dwState(STATE_UNINIT),
  53. m_hwndDlg(NULL), m_hwndSender(NULL), m_pEditSender(NULL) {}
  54. ~CEditSenderUI();
  55. HRESULT HrInit(HWND hwndOwner, DWORD dwFlags, EDIT_SENDER * pEditSender);
  56. HRESULT HrShow(VOID);
  57. static INT_PTR CALLBACK FEditSendersDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
  58. // Message handling methods
  59. BOOL FOnInitDialog(HWND hwndDlg);
  60. BOOL FOnCommand(UINT uiNotify, INT iCtl, HWND hwndCtl);
  61. };
  62. class CExceptionsListUI
  63. {
  64. private:
  65. enum
  66. {
  67. STATE_UNINIT = 0x00000000,
  68. STATE_INITIALIZED = 0x00000001,
  69. STATE_DIRTY = 0x00000002
  70. };
  71. private:
  72. HWND m_hwndOwner;
  73. DWORD m_dwFlags;
  74. DWORD m_dwState;
  75. HWND m_hwndDlg;
  76. HWND m_hwndList;
  77. ULONG m_cchLabelMax;
  78. IOERule * m_pIRule;
  79. public:
  80. CExceptionsListUI() : m_hwndOwner(NULL), m_dwFlags(0), m_dwState(STATE_UNINIT),
  81. m_hwndList(NULL), m_hwndDlg(NULL), m_cchLabelMax(0),
  82. m_pIRule(NULL) {}
  83. ~CExceptionsListUI();
  84. HRESULT HrInit(HWND hwndOwner, DWORD dwFlags);
  85. HRESULT HrShow(IOERule * pIRule);
  86. static INT_PTR CALLBACK FExceptionsListDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
  87. // Message handling methods
  88. BOOL FOnInitDialog(HWND hwndDlg);
  89. BOOL FOnCommand(UINT uiNotify, INT iCtl, HWND hwndCtl);
  90. BOOL FOnNotify(INT iCtl, NMHDR * pnmhdr);
  91. private:
  92. // Functions to deal with the basic actions
  93. VOID _NewException(VOID);
  94. VOID _EditException(INT iSelected);
  95. VOID _RemoveException(INT iSelected);
  96. BOOL _FOnOK(VOID);
  97. // Utility functions
  98. BOOL _FInitCtrls(VOID);
  99. BOOL _FLoadListCtrl(VOID);
  100. BOOL _FSaveListCtrl(VOID);
  101. BOOL _FAddExceptionToList(LPSTR pszExcpt, ULONG * pulIndex);
  102. void _EnableButtons(INT iSelected);
  103. };
  104. class COEJunkRulesPageUI : public COERulesPageUI
  105. {
  106. private:
  107. enum
  108. {
  109. STATE_CTRL_INIT = 0x00000010
  110. };
  111. enum {
  112. ID_JUNK_SCALE = 0,
  113. ID_JUNK_DELETE,
  114. ID_MAX
  115. };
  116. private:
  117. HWND m_hwndOwner;
  118. HWND m_hwndDlg;
  119. HIMAGELIST m_himl;
  120. CExceptionsListUI * m_pExceptionsUI;
  121. IOERule * m_pIRuleJunk;
  122. public:
  123. COEJunkRulesPageUI() : COERulesPageUI(iddRulesJunk, idsRulesJunk, 0, 0), m_hwndOwner(NULL),
  124. m_hwndDlg(NULL), m_himl(NULL), m_pExceptionsUI(NULL), m_pIRuleJunk(NULL) {}
  125. virtual ~COEJunkRulesPageUI();
  126. virtual HRESULT HrInit(HWND hwndOwner, DWORD dwFlags);
  127. virtual HRESULT HrCommitChanges(DWORD dwFlags, BOOL fClearDirty);
  128. static INT_PTR CALLBACK FJunkRulesPageDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
  129. DLGPROC DlgProcGetPageDlgProc(VOID) {return FJunkRulesPageDlgProc;}
  130. BOOL FGetRules(RULE_TYPE typeRule, RULENODE ** pprnode);
  131. // Message handling methods
  132. BOOL FOnInitDialog(HWND hwndDlg);
  133. BOOL FOnCommand(UINT uiNotify, INT iCtl, HWND hwndCtl);
  134. BOOL FOnNotify(INT iCtl, NMHDR * pnmhdr);
  135. BOOL FOnHScroll(INT iScrollCode, short int iPos, HWND hwndCtl);
  136. BOOL FOnDestroy(VOID) {return FALSE;}
  137. private:
  138. BOOL _FInitCtrls(VOID);
  139. BOOL _FLoadJunkSettings();
  140. BOOL _FSaveJunkSettings();
  141. VOID _EnableButtons(VOID);
  142. };
  143. class COESendersRulesPageUI : public COERulesPageUI
  144. {
  145. private:
  146. enum BLOCK_TYPE
  147. {
  148. BLOCK_NONE = 0x00000000,
  149. BLOCK_MAIL = 0x00000001,
  150. BLOCK_NEWS = 0x00000002
  151. };
  152. private:
  153. HWND m_hwndOwner;
  154. HWND m_hwndDlg;
  155. HWND m_hwndList;
  156. IOERule * m_pIRuleMail;
  157. IOERule * m_pIRuleNews;
  158. ULONG m_cchLabelMax;
  159. static const COLUMNITEM m_rgcitem[];
  160. static const UINT m_crgcitem;
  161. public:
  162. COESendersRulesPageUI() : COERulesPageUI(iddRulesSenders, idsRulesSenders, 0, 0),
  163. m_hwndOwner(NULL), m_hwndDlg(NULL), m_hwndList(NULL),
  164. m_pIRuleMail(NULL), m_pIRuleNews(NULL), m_cchLabelMax(0) {};
  165. virtual ~COESendersRulesPageUI();
  166. virtual HRESULT HrInit(HWND hwndOwner, DWORD dwFlags);
  167. virtual HRESULT HrCommitChanges(DWORD dwFlags, BOOL fClearDirty);
  168. static INT_PTR CALLBACK FSendersRulesPageDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
  169. DLGPROC DlgProcGetPageDlgProc(VOID) {return FSendersRulesPageDlgProc;}
  170. BOOL FGetRules(RULE_TYPE typeRule, RULENODE ** pprnode);
  171. // Message handling methods
  172. BOOL FOnInitDialog(HWND hwndDlg);
  173. BOOL FOnCommand(UINT uiNotify, INT iCtl, HWND hwndCtl);
  174. BOOL FOnNotify(INT iCtl, NMHDR * pnmhdr);
  175. BOOL FOnDestroy(VOID) {return FALSE;}
  176. BOOL FFindItem(LPCSTR pszFind, LONG lSkip);
  177. private:
  178. BOOL _FInitListCtrl(VOID);
  179. BOOL _FLoadListCtrl(VOID);
  180. BOOL _FAddSenderToList(RULE_TYPE type, LPSTR pszSender);
  181. void _EnableButtons(INT iSelected);
  182. void _EnableSender(RULE_TYPE type, INT iSelected);
  183. BOOL _FLoadSenders(RULE_TYPE type, IOERule * pIRule);
  184. BOOL _FSaveSenders(RULE_TYPE type);
  185. BOOL _FFindSender(LPCSTR pszSender, LONG lSkip, LONG * plSender);
  186. // Functions to deal with the basic actions
  187. VOID _NewSender(VOID);
  188. VOID _EditSender(INT iSelected);
  189. VOID _RemoveSender(INT iSelected);
  190. };