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.

268 lines
7.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: snapdata.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _SNAPDATA_H
  11. #define _SNAPDATA_H
  12. ////////////////////////////////////////////////////////////////////////
  13. // defines for test thread messages
  14. #define WM_TIMER_THREAD_ADD_SERVER (WM_USER + 1)
  15. #define WM_TIMER_THREAD_REMOVE_SERVER (WM_USER + 2)
  16. #define WM_TIMER_THREAD_SEND_QUERY (WM_USER + 3)
  17. #define WM_TIMER_THREAD_SEND_QUERY_TEST_NOW (WM_USER + 4)
  18. /////////////////////////////////////////////////////////////////////////
  19. // defines for filtering
  20. // filtering options
  21. #define DNS_QUERY_FILTER_DISABLED 0
  22. #define DNS_QUERY_FILTER_NONE 1
  23. #define DNS_QUERY_FILTER_STARTS 2
  24. #define DNS_QUERY_FILTER_CONTAINS 3
  25. #define DNS_QUERY_FILTER_RANGE 4
  26. // # of items per folder: must be >=0 and <= 0xFFFFFFFF (DWORD) to serialize
  27. #define DNS_QUERY_OBJ_COUNT_DEFAULT 10000 // default value
  28. #define DNS_QUERY_OBJ_COUNT_MIN 10 // min value
  29. #define DNS_QUERY_OBJ_COUNT_MAX 999999 // max value
  30. ///////////////////////////////////////////////////////////////////////////////
  31. // GLOBAL FUNCTIONS
  32. HRESULT SaveStringHelper(LPCWSTR pwsz, IStream* pStm);
  33. HRESULT LoadStringHelper(CString& sz, IStream* pStm);
  34. HRESULT SaveDWordHelper(IStream* pStm, DWORD dw);
  35. HRESULT LoadDWordHelper(IStream* pStm, DWORD* pdw);
  36. ///////////////////////////////////////////////////////////////////////////////
  37. // FORWARD DECLARATIONS
  38. class CDNSServerNode;
  39. class CNewServerDialog;
  40. class CDNSServerWizardHolder;
  41. class CDNSServerTestQueryResult;
  42. class CDNSComponentDataObjectEx;
  43. class CDNSQueryFilterNamePage;
  44. class CDNSQueryFilterAdvancedPage;
  45. //////////////////////////////////////////////////////////////////////
  46. // CDNSQueryFilter
  47. class CDNSQueryFilter
  48. {
  49. public:
  50. CDNSQueryFilter()
  51. {
  52. m_nFilterOption = DNS_QUERY_FILTER_NONE;
  53. m_nMaxObjectCount = DNS_QUERY_OBJ_COUNT_DEFAULT;
  54. m_bGetAll = FALSE;
  55. }
  56. ~CDNSQueryFilter(){}
  57. BOOL EditFilteringOptions(CComponentDataObject* pComponentData);
  58. // accessor methods
  59. UINT GetFilterOption()
  60. { return m_nFilterOption;}
  61. LPCWSTR GetFilterString()
  62. {
  63. if (m_nFilterOption == DNS_QUERY_FILTER_STARTS)
  64. return m_szStartsString;
  65. else if (m_nFilterOption == DNS_QUERY_FILTER_CONTAINS)
  66. return m_szContainsString;
  67. else if (m_nFilterOption == DNS_QUERY_FILTER_RANGE)
  68. return m_szRangeFrom;
  69. return NULL;
  70. }
  71. LPCWSTR GetFilterStringRange()
  72. {
  73. if (m_nFilterOption == DNS_QUERY_FILTER_RANGE)
  74. return m_szRangeTo;
  75. return NULL;
  76. }
  77. ULONG GetMaxObjectCount() { return m_nMaxObjectCount;}
  78. BOOL GetAll() { return m_bGetAll;}
  79. // serialization
  80. HRESULT Load(IStream* pStm);
  81. HRESULT Save(IStream* pStm);
  82. private:
  83. // name filtering
  84. UINT m_nFilterOption;
  85. CString m_szStartsString;
  86. CString m_szContainsString;
  87. CString m_szRangeFrom;
  88. CString m_szRangeTo;
  89. // query limit
  90. ULONG m_nMaxObjectCount;
  91. BOOL m_bGetAll;
  92. friend class CDNSQueryFilterNamePage;
  93. friend class CDNSQueryFilterAdvancedPage;
  94. };
  95. ///////////////////////////////////////////////////////////////////
  96. // CDNSRootData
  97. class CDNSRootData : public CRootData
  98. {
  99. public:
  100. CDNSRootData(CComponentDataObject* pComponentData);
  101. virtual ~CDNSRootData();
  102. // node info
  103. DECLARE_NODE_GUID()
  104. virtual HRESULT OnCommand(long nCommandID,
  105. DATA_OBJECT_TYPES type,
  106. CComponentDataObject* pComponentData,
  107. CNodeList* pNodeList);
  108. virtual void OnDelete(CComponentDataObject*,
  109. CNodeList*)
  110. { ASSERT(FALSE);}
  111. virtual BOOL OnRefresh(CComponentDataObject* pComponentData,
  112. CNodeList* pNodeList);
  113. virtual BOOL OnSetRefreshVerbState(DATA_OBJECT_TYPES type,
  114. BOOL* pbHide,
  115. CNodeList* pNodeList);
  116. virtual int GetImageIndex(BOOL) { return ROOT_IMAGE;}
  117. virtual LPWSTR GetDescriptionBarText();
  118. // filtering
  119. BOOL IsAdvancedView() { return m_bAdvancedView; }
  120. CDNSQueryFilter* GetFilter() { return &m_filterObj;}
  121. virtual BOOL OnEnumerate(CComponentDataObject* pComponentData, BOOL bAsync = TRUE);
  122. // IStream manipulation helpers overrides
  123. virtual HRESULT IsDirty();
  124. virtual HRESULT Load(IStream* pStm);
  125. virtual HRESULT Save(IStream* pStm, BOOL fClearDirty);
  126. virtual CColumnSet* GetColumnSet()
  127. {
  128. if (m_pColumnSet == NULL)
  129. {
  130. m_pColumnSet = ((CDNSComponentDataObjectBase*)GetComponentDataObject())->GetColumnSet(L"---Server Column Set---");
  131. }
  132. return m_pColumnSet;
  133. }
  134. virtual LPCWSTR GetColumnID() { return GetColumnSet()->GetColumnID(); }
  135. HRESULT GetResultViewType(CComponentDataObject* pComponentData,
  136. LPOLESTR *ppViewType,
  137. long *pViewOptions);
  138. HRESULT OnShow(LPCONSOLE lpConsole);
  139. virtual BOOL CanExpandSync() { return TRUE; }
  140. virtual HRESULT OnSetToolbarVerbState(IToolbar* pToolbar, CNodeList* pNodeList);
  141. DECLARE_TOOLBAR_MAP()
  142. protected:
  143. virtual BOOL CanCloseSheets();
  144. virtual LPCONTEXTMENUITEM2 OnGetContextMenuItemTable()
  145. { return CDNSRootDataMenuHolder::GetContextMenuItem(); }
  146. virtual BOOL OnAddMenuItem(LPCONTEXTMENUITEM2 pContextMenuItem2,
  147. long *pInsertionAllowed);
  148. // server testing
  149. public:
  150. void TestServers(DWORD dwCurrTime, DWORD dwTimeInterval,CComponentDataObject* pComponentData);
  151. void OnServerTestData(WPARAM wParam, LPARAM lParam, CComponentDataObject* pComponentData);
  152. private:
  153. void AddServerToThreadList(CDNSServerNode* pServerNode, CComponentDataObject* pComponentData);
  154. void RemoveServerFromThreadList(CDNSServerNode* pServerNode, CComponentDataObject* pComponentData);
  155. private:
  156. BOOL m_bAdvancedView; // view option toggle
  157. CDNSQueryFilter m_filterObj;
  158. // menu message handlers
  159. HRESULT OnConnectToServer(CComponentDataObject* pComponentData, CNodeList* pNodeList = NULL);
  160. public:
  161. BOOL OnViewOptions(CComponentDataObject* pComponentData);
  162. BOOL OnFilteringOptions(CComponentDataObject* pComponentData);
  163. BOOL IsFilteringEnabled();
  164. void SetCreatePTRWithHost(BOOL bCreate = FALSE) { m_bCreatePTRWithHost = bCreate; }
  165. BOOL GetCreatePTRWithHost() { return m_bCreatePTRWithHost; }
  166. private:
  167. BOOL VerifyServerName(LPCTSTR lpszServerName);
  168. void AddServer(CDNSServerNode* p, CComponentDataObject* pComponentData);
  169. friend class CDNSServerWizardHolder;
  170. friend class CNewServerDialog;
  171. friend class CDNSServerNode;
  172. friend class CDNSComponentDataObjectEx;
  173. CString m_szDescriptionBar;
  174. CColumnSet* m_pColumnSet;
  175. BOOL m_bCreatePTRWithHost;
  176. };
  177. ////////////////////////////////////////////////////////////////////////
  178. // CDNSServerTestQueryInfo
  179. class CDNSServerTestQueryInfo
  180. {
  181. public:
  182. CDNSServerTestQueryInfo() { m_serverCookie = 0; }
  183. // data
  184. CString m_szServerName;
  185. MMC_COOKIE m_serverCookie;
  186. };
  187. ////////////////////////////////////////////////////////////////////////
  188. // CDNSServerTestQueryInfoList
  189. class CDNSServerTestQueryInfoList : public
  190. CList< CDNSServerTestQueryInfo*, CDNSServerTestQueryInfo*>
  191. {
  192. public:
  193. ~CDNSServerTestQueryInfoList()
  194. {
  195. while (!IsEmpty())
  196. delete RemoveHead();
  197. }
  198. };
  199. ///////////////////////////////////////////////////////////////////
  200. // CDNSServerTestTimerThread
  201. class CDNSServerTestTimerThread : public CTimerThread
  202. {
  203. public:
  204. virtual int Run();
  205. private:
  206. // message handlers
  207. void OnExecuteQuery(CDNSServerTestQueryInfo* pInfo, DWORD dwQueryFlags,
  208. BOOL bAsyncQuery);
  209. DNS_STATUS FindIP(LPCTSTR lpszServerName, IP_ADDRESS** pipArray, int* pnIPCount);
  210. DNS_STATUS DoNothingQuery(PIP_ARRAY pipArr, BOOL bSimple);
  211. CDNSServerTestQueryInfoList m_serverInfoList;
  212. };
  213. #endif // _SNAPDATA_H
  214.