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.

296 lines
5.7 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1998 - 1998
  3. Module Name:
  4. location.hxx
  5. Abstract:
  6. This module provides all the functions for determining the
  7. machines current physical location.
  8. Author:
  9. Steve Kiraly (SteveKi) 13-July-1998
  10. Revision History:
  11. Steve Kiraly (SteveKi) 13-July-1998 Genesis
  12. --*/
  13. #ifndef _PHYSLOC_HXX_
  14. #define _PHYSLOC_HXX_
  15. #include "asyncdlg.hxx"
  16. /********************************************************************
  17. Physical location class.
  18. ********************************************************************/
  19. class TPhysicalLocation
  20. {
  21. public:
  22. enum EPhysicalLocations
  23. {
  24. kMaxPhysicalLocation = MAX_PATH,
  25. };
  26. TPhysicalLocation::
  27. TPhysicalLocation(
  28. VOID
  29. );
  30. TPhysicalLocation::
  31. ~TPhysicalLocation(
  32. VOID
  33. );
  34. BOOL
  35. TPhysicalLocation::
  36. bValid(
  37. VOID
  38. ) const;
  39. BOOL
  40. TPhysicalLocation::
  41. Discover(
  42. VOID
  43. );
  44. BOOL
  45. TPhysicalLocation::
  46. GetExact(
  47. IN TString &strLocation
  48. ) const;
  49. BOOL
  50. TPhysicalLocation::
  51. GetSearch(
  52. IN TString &strLocation
  53. ) const;
  54. VOID
  55. TPhysicalLocation::
  56. Invalidate(
  57. VOID
  58. );
  59. BOOL
  60. TPhysicalLocation::
  61. ReadGroupPolicyLocationSetting(
  62. IN OUT TString &strLocation
  63. );
  64. BOOL
  65. TPhysicalLocation::
  66. ReadUserLocationProperty(
  67. IN OUT TString &strLocation
  68. );
  69. BOOL
  70. TPhysicalLocation::
  71. ReadMachinesLocationProperty(
  72. IN OUT TString &strLocation
  73. );
  74. BOOL
  75. TPhysicalLocation::
  76. ReadSubnetLocationProperty(
  77. IN OUT TString &strLocation
  78. );
  79. BOOL
  80. TPhysicalLocation::
  81. ReadSiteLocationProperty(
  82. IN OUT TString &strLocation
  83. );
  84. static
  85. VOID
  86. TPhysicalLocation::
  87. vTrimSlash(
  88. IN OUT TString &strLocation
  89. );
  90. static
  91. BOOL
  92. TPhysicalLocation::
  93. bLocationEnabled(
  94. VOID
  95. );
  96. private:
  97. class TSubnets
  98. {
  99. public:
  100. TSubnets::
  101. TSubnets(
  102. VOID
  103. );
  104. TSubnets::
  105. ~TSubnets(
  106. VOID
  107. );
  108. VOID
  109. TSubnets::
  110. ClearAll(
  111. VOID
  112. );
  113. BOOL
  114. TSubnets::
  115. AddEntry(
  116. IN LPCTSTR pszNew
  117. );
  118. UINT
  119. TSubnets::
  120. NumEntries(
  121. VOID
  122. );
  123. TString &
  124. TSubnets::
  125. Table(
  126. UINT Index
  127. );
  128. private:
  129. //
  130. // Operator = and copy are not defined.
  131. //
  132. TSubnets &
  133. TSubnets::
  134. operator =(
  135. const TSubnets &rhs
  136. );
  137. TSubnets::
  138. TSubnets(
  139. const TSubnets &rhs
  140. );
  141. UINT m_uNumEntries;
  142. TString *m_pstrTable;
  143. };
  144. enum EDiscoveryType
  145. {
  146. kDiscoveryTypeUnknown,
  147. kDiscoveryTypePolicy,
  148. kDiscoveryTypeMachine,
  149. kDiscoveryTypeSubnet,
  150. kDiscoveryTypeSite,
  151. };
  152. typedef DWORD (WINAPI *pfGetIpAddrTable)( PMIB_IPADDRTABLE, PULONG, BOOL );
  153. typedef BOOLEAN (SEC_ENTRY *pfGetComputerObjectName)( EXTENDED_NAME_FORMAT, LPTSTR, PULONG );
  154. typedef BOOLEAN (SEC_ENTRY *pfGetUserNameEx)( EXTENDED_NAME_FORMAT, LPTSTR, PULONG );
  155. typedef DWORD (WINAPI *pfDsAddressToSiteNames)( LPCTSTR, DWORD, PSOCKET_ADDRESS, LPTSTR **, LPTSTR ** );
  156. typedef VOID (WINAPI *pfNetApiBufferFree)( PVOID );
  157. typedef char *(WSAAPI *LPFN_INET_NTOA)( struct in_addr );
  158. //
  159. // Operator = and copy are not defined.
  160. //
  161. TPhysicalLocation &
  162. TPhysicalLocation::
  163. operator =(
  164. const TPhysicalLocation &rhs
  165. );
  166. TPhysicalLocation::
  167. TPhysicalLocation(
  168. const TPhysicalLocation &rhs
  169. );
  170. BOOL
  171. TPhysicalLocation::
  172. AddrToSite(
  173. IN DWORD dwAddr,
  174. IN TString &strSiteName,
  175. IN TString &strSubnetName
  176. );
  177. BOOL
  178. TPhysicalLocation::
  179. GetIpAddressTable(
  180. IN OUT PMIB_IPADDRTABLE *ppAddrTable
  181. );
  182. VOID
  183. TPhysicalLocation::
  184. DisplayLocation(
  185. VOID
  186. );
  187. BOOL
  188. TPhysicalLocation::
  189. GetSubnetObjectNames(
  190. IN TSubnets &Subnets
  191. );
  192. BOOL
  193. TPhysicalLocation::
  194. GetSubnetNames(
  195. IN TSubnets &Subnets
  196. );
  197. UINT
  198. TPhysicalLocation::
  199. NumSetBits(
  200. DWORD Value
  201. );
  202. BOOL
  203. TPhysicalLocation::
  204. GetSiteLocationString(
  205. IN LPCTSTR strSiteName,
  206. IN OUT TString &strSiteLocation
  207. );
  208. BOOL
  209. TPhysicalLocation::
  210. GetSubnetLocationString(
  211. IN LPCTSTR pszSubnetName,
  212. IN OUT TString &strSubnetLocation
  213. );
  214. BOOL
  215. TPhysicalLocation::
  216. WidenScope(
  217. IN LPCTSTR pszString,
  218. IN UINT uCount,
  219. IN OUT TString &strString
  220. ) const;
  221. BOOL m_fInitalized;
  222. TString m_strLocation;
  223. TString m_strConfigurationContainer;
  224. EDiscoveryType m_eDiscoveryType;
  225. TLibrary m_IpHlpApi;
  226. pfGetIpAddrTable m_GetIpAddrTable;
  227. TLibrary m_SecExt;
  228. pfGetComputerObjectName m_GetComputerObjectName;
  229. pfGetUserNameEx m_GetUserNameEx;
  230. TLibrary m_NetApi;
  231. pfDsAddressToSiteNames m_DsAddressToSiteNames;
  232. pfNetApiBufferFree m_NetApiBufferFree;
  233. TLibrary m_WinSock;
  234. LPFN_INET_NTOA m_inet_ntoa;
  235. TDirectoryService m_Ds;
  236. };
  237. #endif // _PHYSLOC_HXX_