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.

393 lines
6.7 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1998 - 1998
  3. All rights reserved.
  4. Module Name:
  5. findloc.cxx
  6. Abstract:
  7. This module provides all the functions for browsing the
  8. physical location tree stored in an Active Directory
  9. Author:
  10. Lazar Ivanov (Lazari) 23-Nov-1998
  11. Steve Kiraly (SteveKi) 24-Nov-1998
  12. Revision History:
  13. --*/
  14. #ifndef _FINDLOC_HXX_
  15. #define _FINDLOC_HXX_
  16. /******************************************************************************
  17. Data structures for communication between UI thread and
  18. the background DS query thread
  19. ******************************************************************************/
  20. class TLocData : public MRefCom
  21. {
  22. SIGNATURE('fldt')
  23. public:
  24. TLocData(
  25. IN LPCTSTR pszClassName,
  26. IN LPCTSTR pszPropertyName,
  27. IN UINT uMsgDataReady,
  28. IN BOOL bFindPhysicalLocation
  29. );
  30. ~TLocData(
  31. VOID
  32. );
  33. BOOL
  34. bValid(
  35. VOID
  36. ) const;
  37. VOID
  38. vNotifyUIDataIsReady(
  39. VOID
  40. );
  41. static VOID
  42. FindLocationsThread(
  43. IN TLocData *pLocData
  44. );
  45. class TLoc
  46. {
  47. SIGNATURE('tlda')
  48. ALWAYS_VALID
  49. public:
  50. TLoc(
  51. VOID
  52. );
  53. ~TLoc(
  54. VOID
  55. );
  56. TString strLocation;
  57. DLINK (TLoc, _Location);
  58. private:
  59. //
  60. // Operator = and copy are not defined.
  61. //
  62. TLoc &
  63. TLoc::operator = (
  64. IN const TLoc &rhs
  65. );
  66. TLoc::
  67. TLoc(
  68. IN const TLoc &rhs
  69. );
  70. };
  71. TString _strDefault; // Default location string
  72. TString _strDSName; // The directory service name
  73. //
  74. // linked list from all the locations
  75. //
  76. DLINK_BASE( TLoc, _LocationList, _Location );
  77. private:
  78. //
  79. // Operator = and copy are not defined.
  80. //
  81. TLocData &
  82. TLocData::operator =(
  83. IN const TLocData &rhs
  84. );
  85. TLocData::
  86. TLocData(
  87. IN const TLocData &rhs
  88. );
  89. VOID
  90. vDoTheWork(
  91. VOID
  92. );
  93. VOID
  94. vRefZeroed(
  95. VOID
  96. );
  97. BOOL
  98. bSearchLocations(
  99. IN TDirectoryService &ds
  100. );
  101. //
  102. // Private data members
  103. //
  104. UINT _uMsgDataReady; // The registered message for data ready
  105. TString _strWindowClass; // TFindLocDlg window class name
  106. TString _strPropertyName; // Property of the window we should look for
  107. BOOL _bValid; // Is the class valid and usable
  108. BOOL _bFindPhysicalLocation; // Should we find out the exact location of the current machine
  109. BOOL _bIsDataReady; // Should be set TRUE from the worker thread when
  110. // the work is done & thread is about to dismis
  111. };
  112. /******************************************************************************
  113. Tree Control class wrapper.
  114. Displays the location hierarchy.
  115. ******************************************************************************/
  116. class TLocTree
  117. {
  118. SIGNATURE('floc')
  119. ALWAYS_VALID
  120. public:
  121. TLocTree (
  122. IN HWND hWnd
  123. );
  124. ~TLocTree (
  125. VOID
  126. );
  127. VOID
  128. vResetTree(
  129. VOID
  130. );
  131. VOID
  132. vBuildTree(
  133. IN const TLocData *pLocData
  134. );
  135. VOID
  136. vInsertRootString(
  137. IN const TLocData *pLocData
  138. );
  139. BOOL
  140. bInsertLocString (
  141. IN const TString &strLoc
  142. ) const;
  143. BOOL
  144. bGetSelectedLocation(
  145. OUT TString &strLoc
  146. ) const;
  147. VOID
  148. vExpandTree(
  149. IN const TString &strExpand
  150. ) const;
  151. VOID
  152. vFillTree(
  153. IN const TLocData *pLocData
  154. ) const;
  155. private:
  156. // copy and assignment are prohibited
  157. TLocTree &
  158. operator =(
  159. IN const TLocTree &
  160. );
  161. TLocTree(
  162. IN const TLocTree &
  163. );
  164. HTREEITEM
  165. IsAChild(
  166. IN LPCTSTR szLoc,
  167. IN HTREEITEM hParent
  168. ) const;
  169. static
  170. LRESULT CALLBACK
  171. ThunkProc(
  172. IN HWND hwnd,
  173. IN UINT uMsg,
  174. IN WPARAM wParam,
  175. IN LPARAM lParam
  176. );
  177. LRESULT
  178. nHandleMessage(
  179. IN UINT uMsg,
  180. IN WPARAM wParam,
  181. IN LPARAM lParam
  182. );
  183. //
  184. // Private data members
  185. //
  186. HWND _hwndTree;
  187. HTREEITEM _hRoot;
  188. HIMAGELIST _hIml;
  189. // imagelist offsets
  190. INT _iGlobe;
  191. INT _iSite;
  192. // subclassing for wait cursor
  193. HCURSOR _hCursorWait;
  194. BOOL _bWaitData;
  195. WNDPROC _DefProc;
  196. };
  197. /******************************************************************************
  198. Find Location Dialog - exposes UI for traversing
  199. the physical location hierarchy stored in the Active Directory
  200. ******************************************************************************/
  201. class TFindLocDlg : public MGenericDialog
  202. {
  203. SIGNATURE('floc')
  204. ALWAYS_VALID
  205. public:
  206. static
  207. BOOL
  208. bGenerateGUIDAsString(
  209. OUT TString *pstrGUID
  210. );
  211. //
  212. // Some flags to control the UI
  213. //
  214. enum ELocationUI
  215. {
  216. kLocationDefaultUI = 0,
  217. kLocationShowHelp = 1 << 0,
  218. };
  219. TFindLocDlg(
  220. IN ELocationUI flags = kLocationDefaultUI
  221. );
  222. ~TFindLocDlg(
  223. VOID
  224. );
  225. BOOL
  226. bDoModal(
  227. IN HWND hParent,
  228. OUT TString *pstrDefault = NULL
  229. );
  230. BOOL
  231. bGetLocation(
  232. OUT TString &strLocation
  233. );
  234. private:
  235. // copy and assignment are undefined
  236. TFindLocDlg &
  237. operator =(
  238. IN const TFindLocDlg &
  239. );
  240. TFindLocDlg(
  241. IN const TFindLocDlg &
  242. );
  243. BOOL
  244. bInitTree(
  245. VOID
  246. );
  247. BOOL
  248. bHandleMessage(
  249. IN UINT uMsg,
  250. IN WPARAM wParam,
  251. IN LPARAM lParam
  252. );
  253. VOID
  254. vDataIsReady(
  255. VOID
  256. );
  257. BOOL
  258. bOnInitDialog(
  259. VOID
  260. );
  261. BOOL
  262. bOnTreeNotify (
  263. IN LPNMTREEVIEW pTreeNotify
  264. );
  265. VOID
  266. vOnOK(
  267. VOID
  268. );
  269. VOID
  270. vOnDestroy(
  271. VOID
  272. );
  273. VOID
  274. vStartAnim(
  275. VOID
  276. );
  277. VOID
  278. vStopAnim(
  279. VOID
  280. );
  281. BOOL
  282. bOnCtlColorStatic(
  283. IN HDC hdc,
  284. IN HWND hStatic
  285. );
  286. BOOL
  287. bStartTheBackgroundThread(
  288. VOID
  289. );
  290. BOOL
  291. bOnCommand(
  292. IN UINT uCmdID
  293. );
  294. //
  295. // Private data members
  296. //
  297. TLocTree* _pTree;
  298. TString _strSelLocation;
  299. TString _strPropertyName;
  300. TLocData* _pLocData;
  301. BOOL _bValid;
  302. TString _strDefault;
  303. ELocationUI _UIFlags;
  304. UINT _uMsgDataReady;
  305. };
  306. #endif