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.

513 lines
11 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. useropt.h
  5. Abstract:
  6. Global user options class and help classes declarations. This class
  7. can only instantiate by CLinkCheckerMgr. Therefore, a single instance
  8. of this class will live inside CLinkCheckerMgr. You can access
  9. the this instance by calling GetLinkCheckMgr().GetUserOptions().
  10. Author:
  11. Michael Cheuk (mcheuk)
  12. Project:
  13. Link Checker
  14. Revision History:
  15. --*/
  16. #ifndef _USEROPT_H_
  17. #define _USEROPT_H_
  18. //------------------------------------------------------------------
  19. // IIS Virtual directory information
  20. //
  21. class CVirtualDirInfo
  22. {
  23. // Public Funtions
  24. public:
  25. // Constructor
  26. CVirtualDirInfo() {}
  27. // Constructor
  28. inline CVirtualDirInfo(
  29. const CString& strAlias, // virtual directory alias
  30. const CString& strPath // virtual directory path
  31. ) :
  32. m_strAlias(strAlias), m_strPath(strPath)
  33. {
  34. PreProcessAlias();
  35. PreProcessPath();
  36. }
  37. // Get the virtual directory alias
  38. const CString& GetAlias() const
  39. {
  40. return m_strAlias;
  41. }
  42. // Set the virtual directory alias
  43. void SetAlias(
  44. const CString& strAlias
  45. )
  46. {
  47. m_strAlias = strAlias;
  48. PreProcessAlias();
  49. }
  50. // Get the virtual directory path
  51. const CString& GetPath() const
  52. {
  53. return m_strPath;
  54. }
  55. // Set the virtual directory path
  56. void SetPath(
  57. const CString& strPath
  58. )
  59. {
  60. m_strPath = strPath;
  61. PreProcessPath();
  62. }
  63. // Protected funtions
  64. protected:
  65. // Preprocess the current virtual directory alias
  66. void PreProcessAlias();
  67. // Preprocess the current virtual directory path
  68. void PreProcessPath();
  69. // Protected members
  70. protected:
  71. CString m_strAlias; // virtual directory alias
  72. CString m_strPath; // virtual directory path
  73. }; // class CVirtualDirInfo
  74. //------------------------------------------------------------------
  75. // CVirtualDirInfo (IIS Virtual directory information) link list
  76. //
  77. typedef
  78. class CList<CVirtualDirInfo, const CVirtualDirInfo&>
  79. CVirtualDirInfoList;
  80. //------------------------------------------------------------------
  81. // Browser information. Link checker uses this class to store
  82. // the avaiable browser emulation.
  83. //
  84. class CBrowserInfo
  85. {
  86. // Public Funtions
  87. public:
  88. // Constructor
  89. CBrowserInfo()
  90. {
  91. m_fSelected = FALSE;
  92. }
  93. // Constructor
  94. CBrowserInfo(
  95. LPCTSTR lpszName, // user friendly name
  96. LPCTSTR lpszUserAgent, // HTTP user agent name
  97. BOOL fSelect // select this browser to emulate
  98. ):
  99. m_strName(lpszName),
  100. m_strUserAgent(lpszUserAgent)
  101. {
  102. m_fSelected = fSelect;
  103. }
  104. // Get the user friendly browser name
  105. const CString& GetName() const
  106. {
  107. return m_strName;
  108. }
  109. // Set the user friendly browser name
  110. void SetName(
  111. const CString& strName
  112. )
  113. {
  114. m_strName = strName;
  115. }
  116. // Get the HTTP user agent name
  117. const CString& GetUserAgent() const
  118. {
  119. return m_strUserAgent;
  120. }
  121. // Set the HTTP user agent name
  122. void SetUserAgent(
  123. const CString& strUserAgent
  124. )
  125. {
  126. m_strUserAgent = strUserAgent;
  127. }
  128. // Select or unselect this browser
  129. void SetSelect(BOOL fSelect)
  130. {
  131. m_fSelected = fSelect;
  132. }
  133. // Select or unselect this browser
  134. BOOL IsSelected() const
  135. {
  136. return m_fSelected;
  137. }
  138. // Protected members
  139. protected:
  140. CString m_strName; // user friendly browser name (eg. Microsoft Internet Explorer 4.0)
  141. CString m_strUserAgent; // HTTP user agent name
  142. BOOL m_fSelected; // is browser selected ?
  143. }; // class CBrowserInfo
  144. //------------------------------------------------------------------
  145. // CBrowserInfo (browser informations) link list
  146. //
  147. class CBrowserInfoList : public CList<CBrowserInfo, const CBrowserInfo&>
  148. {
  149. // Public interfaces
  150. public:
  151. // Get the first selected browser. It works like GetHeadPosition()
  152. POSITION GetHeadSelectedPosition() const;
  153. // Get next selected browser. It works like GetNext()
  154. CBrowserInfo& GetNextSelected(
  155. POSITION& Pos
  156. );
  157. };
  158. //------------------------------------------------------------------
  159. // Language informations. Link checker uses this class to store
  160. // the avaiable language emulation.
  161. //
  162. class CLanguageInfo
  163. {
  164. // Public funtions
  165. public:
  166. // Constructor
  167. CLanguageInfo()
  168. {
  169. m_fSelected = FALSE;
  170. }
  171. // Constructor
  172. CLanguageInfo(
  173. LPCTSTR lpszName, // language name
  174. LPCTSTR lpszAcceptName, // HTTP accept language name
  175. BOOL fSelect // select this language to emulate
  176. ) :
  177. m_strName(lpszName),
  178. m_strAcceptName(lpszAcceptName),
  179. m_fSelected(fSelect) {}
  180. // Get the language name
  181. const CString& GetName() const
  182. {
  183. return m_strName;
  184. }
  185. // Set the language name
  186. void SetName(
  187. const CString& strName
  188. )
  189. {
  190. m_strName = strName;
  191. }
  192. // Get the HTTP accept language name
  193. const CString& GetAcceptName() const
  194. {
  195. return m_strAcceptName;
  196. }
  197. // Get the HTTP accept language name
  198. void SetAcceptName(
  199. const CString& strAcceptName
  200. )
  201. {
  202. m_strAcceptName = strAcceptName;
  203. }
  204. // Select or unselect this language
  205. void SetSelect(BOOL fSelect)
  206. {
  207. m_fSelected = fSelect;
  208. }
  209. // Select or unselect this language
  210. BOOL IsSelected() const
  211. {
  212. return m_fSelected;
  213. }
  214. // Protected members
  215. protected:
  216. CString m_strName; // Language name (eg. Western English)
  217. CString m_strAcceptName; // HTTP accept language name (eg. en)
  218. BOOL m_fSelected; // is language selected ?
  219. }; // class CLanguageInfo
  220. //------------------------------------------------------------------
  221. // CLanguageInfo (Language informations) link list
  222. //
  223. class CLanguageInfoList : public CList<CLanguageInfo, const CLanguageInfo&>
  224. {
  225. // Public interfaces
  226. public:
  227. // Get the first selected browser. It works like GetHeadPosition()
  228. POSITION GetHeadSelectedPosition() const;
  229. // Get next selected language. It works like GetNext()
  230. CLanguageInfo& GetNextSelected(
  231. POSITION& Pos
  232. );
  233. };
  234. //------------------------------------------------------------------
  235. // Forward declaration
  236. //
  237. class CLinkCheckerMgr;
  238. //------------------------------------------------------------------
  239. // Global user options class
  240. //
  241. class CUserOptions
  242. {
  243. // Protected interfaces
  244. protected:
  245. // This class can only instantiate by CLinkCheckerMgr
  246. friend CLinkCheckerMgr;
  247. // Protected constructor & destructor
  248. CUserOptions() {}
  249. ~CUserOptions() {}
  250. // Public interfaces
  251. public:
  252. // Set the user options in the main dialog
  253. void SetOptions(
  254. BOOL fCheckLocalLinks, // check local link?
  255. BOOL fCheckRemoteLinks, // check remote link?
  256. BOOL fLogToFile, // log to file
  257. const CString& strLogFilename, // log filename
  258. BOOL fLogToEventMgr // log to event manager
  259. );
  260. // Check local links
  261. BOOL IsCheckLocalLinks() const
  262. {
  263. return m_fCheckLocalLinks;
  264. }
  265. // Check remote links
  266. BOOL IsCheckRemoteLinks() const
  267. {
  268. return m_fCheckRemoteLinks;
  269. }
  270. // Is log to file ?
  271. BOOL IsLogToFile() const
  272. {
  273. return m_fLogToFile;
  274. }
  275. // Get log filename
  276. const CString& GetLogFilename() const
  277. {
  278. return m_strLogFilename;
  279. }
  280. // The following link lists are used
  281. // for transversing the server
  282. //
  283. // User can only have
  284. // a list of virtual directory or a list of URL
  285. // Add this virtual directory to the link list
  286. void AddDirectory(
  287. const CVirtualDirInfo& Info
  288. );
  289. // Get virtual directory link list
  290. const CVirtualDirInfoList& GetDirectoryList() const
  291. {
  292. return m_VirtualDirInfoList;
  293. }
  294. // Add this URL to the link list
  295. void AddURL(
  296. LPCTSTR lpszURL
  297. );
  298. // Get the URL link list
  299. const CStringList& GetURLList() const
  300. {
  301. return m_strURLList;
  302. }
  303. // The following link lists are used
  304. // to store the available browswers and languages
  305. // for user selection
  306. //
  307. // Add this browser to the available list
  308. void AddAvailableBrowser(
  309. const CBrowserInfo& Info
  310. );
  311. // Get the browser available list
  312. CBrowserInfoList& GetAvailableBrowsers()
  313. {
  314. return m_BrowserInfoList;
  315. }
  316. // Add this language information to available list
  317. void AddAvailableLanguage(
  318. const CLanguageInfo& Info
  319. );
  320. // Get the language available list
  321. CLanguageInfoList& GetAvailableLanguages()
  322. {
  323. return m_LanguageInfoList;
  324. }
  325. // Log to event manager?
  326. BOOL IsLogToEventMgr()
  327. {
  328. return m_fLogToEventMgr;
  329. }
  330. // Set NTLM & basic athenications
  331. void SetAthenication(
  332. const CString& strNTUsername,
  333. const CString& strNTPassword,
  334. const CString& strBasicUsername,
  335. const CString& strBasicPassword
  336. );
  337. // Get NTLM athenication password username
  338. const CString& GetNTUsername() const
  339. {
  340. return m_strNTUsername;
  341. }
  342. // Get NTLM athenication password
  343. const CString& GetNTPassword() const
  344. {
  345. return m_strNTPassword;
  346. }
  347. // Get HTTP basic athenication username
  348. const CString& GetBasicUsername() const
  349. {
  350. return m_strBasicUsername;
  351. }
  352. // Get HTTP basic athenication password
  353. const CString& GetBasicPassword() const
  354. {
  355. return m_strBasicPassword;
  356. }
  357. // Set the server name
  358. void SetServerName(
  359. const CString& strServerName
  360. )
  361. {
  362. m_strHostName = strServerName;
  363. PreProcessServerName();
  364. }
  365. // Get the server name
  366. const CString& GetServerName()
  367. {
  368. return CString(_T("\\\\")) + GetHostName();
  369. }
  370. // Set the hostname
  371. void SetHostName(
  372. const CString& strHostName
  373. )
  374. {
  375. m_strHostName = strHostName;
  376. PreProcessServerName();
  377. }
  378. // Get the hostname
  379. const CString& GetHostName();
  380. // Protected funtions
  381. protected:
  382. // Preprocess the server name such that for server "\\hostname"
  383. // GetServerName() return \\hostname
  384. // GetHostName() return hostname
  385. void PreProcessServerName();
  386. // Protected members
  387. protected:
  388. CString m_strLogFilename; // log filename
  389. CVirtualDirInfoList m_VirtualDirInfoList; // virtual link list
  390. CStringList m_strURLList; // URL link list
  391. CBrowserInfoList m_BrowserInfoList; // browswer infomation link list
  392. CLanguageInfoList m_LanguageInfoList; // language information link list
  393. CString m_strNTUsername; // NTLM athenication username
  394. CString m_strNTPassword; // NTLM athenication password
  395. CString m_strBasicUsername; // HTTP basic athenication username
  396. CString m_strBasicPassword; // HTTP basic athenication password
  397. CString m_strHostName; // hostname
  398. BOOL m_fCheckLocalLinks; // check local links?
  399. BOOL m_fCheckRemoteLinks; // check remote links?
  400. BOOL m_fLogToFile; // log to file
  401. BOOL m_fLogToEventMgr; // log to event manager
  402. };
  403. #endif // _USEROPT_H_