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.

185 lines
4.3 KiB

  1. //***********************************************************************************
  2. //
  3. // Copyright (c) 2001 Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: UrlAgent.h
  6. //
  7. // Description:
  8. //
  9. // This class encapsulates the logic about where to get the right logic
  10. // for various purposes, including the case of running WU in corporate
  11. // environments.
  12. //
  13. // An object based on this class should be created first, then call
  14. // GetOriginalIdentServer() function to get where to download ident,
  15. // then download ident, then call PopulateData() function to read
  16. // all URL related data.
  17. //
  18. //
  19. // Created by:
  20. // Charles Ma
  21. //
  22. // Date Creatd:
  23. // Oct 19, 2001
  24. //
  25. //***********************************************************************************
  26. #pragma once
  27. class CUrlAgent
  28. {
  29. public:
  30. //
  31. // constructor/destructor
  32. //
  33. CUrlAgent();
  34. virtual ~CUrlAgent();
  35. //
  36. // when instantiated, the object is not populated,
  37. // until PopulateData() is called.
  38. //
  39. inline BOOL HasBeenPopulated(void) {return m_fPopulated;}
  40. //
  41. // this function should be called after you downloaded ident, and get
  42. // a fresh copy of ident text file from the cab, after verifying cab was
  43. // signed properly.
  44. //
  45. // this function reads data from ident and registry
  46. //
  47. HRESULT PopulateData(void);
  48. //
  49. // the following are access function to obtain URL's
  50. //
  51. //
  52. // get the original ident server.
  53. // *** this API should be called before PopulateData() is called ***
  54. // *** this API should be called to retrieve the base URL where you download ident ***
  55. //
  56. HRESULT GetOriginalIdentServer(
  57. LPTSTR lpsBuffer,
  58. int nBufferSize,
  59. BOOL* pfInternalServer = NULL);
  60. //
  61. // get the ping/status server
  62. // *** this API should be called after PopulateData() is called ***
  63. //
  64. HRESULT GetLivePingServer(
  65. LPTSTR lpsBuffer,
  66. int nBufferSize);
  67. // *** this API can be called before PopulateData() is called ***
  68. HRESULT GetCorpPingServer(
  69. LPTSTR lpsBuffer,
  70. int nBufferSize);
  71. //
  72. // get the query server. this is per client based
  73. // *** this API should be called after PopulateData() is called ***
  74. //
  75. HRESULT GetQueryServer(
  76. LPCTSTR lpsClientName,
  77. LPTSTR lpsBuffer,
  78. int nBufferSize,
  79. BOOL* pfInternalServer = NULL);
  80. //
  81. // tell if a particular client is controlled by policy in corporate
  82. // returns:
  83. // S_OK = TRUE
  84. // S_FALSE = FALSE
  85. // other = error, so don't know
  86. //
  87. HRESULT IsClientSpecifiedByPolicy(
  88. LPCTSTR lpsClientName
  89. );
  90. //
  91. // when client isn't available, is IU controlled by policy in corporate?
  92. // returns:
  93. // S_OK = TRUE
  94. // S_FALSE = FALSE
  95. // other = error, so don't know
  96. //
  97. HRESULT IsIdentFromPolicy();
  98. private:
  99. typedef struct _ServerPerClient {
  100. LPTSTR pszClientName;
  101. LPTSTR pszQueryServer;
  102. BOOL fInternalServer;
  103. } ServerPerClient, *PServerPerClient;
  104. BOOL m_fPopulated; // whether this object has been populated
  105. LPTSTR m_pszWUServer; // WU server defined in policy, if any
  106. LPTSTR m_pszInternetPingUrl; // ping server
  107. LPTSTR m_pszIntranetPingUrl;
  108. PServerPerClient m_ArrayUrls;
  109. int m_nArrayUrlCount; // how many we data slot we used
  110. int m_nArraySize; // current size of this array
  111. //
  112. // private functions
  113. //
  114. void DesertData(void);
  115. //
  116. // helper function
  117. //
  118. LPTSTR RetrieveIdentStrAlloc(
  119. LPCTSTR pSection,
  120. LPCTSTR pEntry,
  121. LPDWORD lpdwSizeAllocated,
  122. LPCTSTR lpszIdentFile);
  123. //
  124. // helper function
  125. // if there is no empty slot, double the size of url array
  126. //
  127. HRESULT ExpandArrayIfNeeded(void);
  128. protected:
  129. HANDLE m_hProcHeap;
  130. BOOL m_fIdentFromPolicy; // tell if original ident url based on policy setup
  131. LPTSTR m_pszOrigIdentUrl; // this one should always have it, no matter population
  132. int m_nOrigIdentUrlBufSize; // in tchar count
  133. BOOL m_fIsBetaMode;
  134. };
  135. class CIUUrlAgent : public CUrlAgent
  136. {
  137. public:
  138. //
  139. // constructor/destructor
  140. //
  141. CIUUrlAgent();
  142. ~CIUUrlAgent();
  143. // call base class PopulateData() and then populate self-update url
  144. HRESULT PopulateData(void);
  145. //
  146. // get the self-update server.
  147. // *** this API should be called after PopulateData() is called ***
  148. //
  149. HRESULT GetSelfUpdateServer(
  150. LPTSTR lpsBuffer,
  151. int nBufferSize,
  152. BOOL* pfInternalServer = NULL);
  153. private:
  154. LPTSTR m_pszSelfUpdateUrl; // self-update server
  155. BOOL m_fIUPopulated; // whether this object has been populated
  156. };