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.

255 lines
10 KiB

  1. //
  2. // MODULE: APGTSINF.H
  3. //
  4. // PURPOSE: Inference support header
  5. //
  6. // PROJECT: Generic Troubleshooter DLL for Microsoft AnswerPoint
  7. //
  8. // COMPANY: Saltmine Creative, Inc. (206)-284-7511 [email protected]
  9. //
  10. // AUTHOR: Roman Mach, Joe Mabel
  11. //
  12. // ORIGINAL DATE: 8-2-96
  13. //
  14. // NOTES:
  15. // 1. Based on Print Troubleshooter DLL
  16. //
  17. // Version Date By Comments
  18. //--------------------------------------------------------------------
  19. // V0.1 - RM Original
  20. // V3.0 7-21-98 JM Major revision, deprecate IDH in favor of NID, use STL.
  21. //
  22. #if !defined(APGTSINF_H_INCLUDED)
  23. #define APGTSINF_H_INCLUDED
  24. #if _MSC_VER >= 1000
  25. #pragma once
  26. #endif // _MSC_VER >= 1000
  27. #include "propnames.h"
  28. #include "topic.h"
  29. using namespace std;
  30. #define MAXBUF 256 // length of text buffers used for filenames,
  31. // IP adresses (this is plenty big), HTTP response ( like
  32. // "200 OK", again, plenty big), registry keys,
  33. // and occasionally just to format an arbitrary string.
  34. //--------------------------------------------------------------------
  35. // Default Values for localizable text
  36. #define SZ_UNKNOWN _T("Unknown")
  37. #define SZ_NEXT_BTN _T("Next")
  38. #define SZ_START_BTN _T("StartOver")
  39. #define SZ_BACK_BTN _T("Back")
  40. #define SZ_PP_SNIF_BTN _T("Investigate")
  41. //#define SZ_I_NO_RESULT_PAGE _T("<HR>Not Enough Information was available to provide a useful result\n <BR>It is also possible that the information you provided is not correct, please check your entries\n <BR>Please amend your choices\n <P><INPUT TYPE=SUBMIT VALUE=\"Continue\"><BR>")
  42. #define SZ_I_NO_RESULT_PAGE _T("<HR>This troubleshooter can't diagnose the cause of your problem based on the information you have provided.\n <BR>Either start the troubleshooter over, change your answers in the table and continue, or search for other resources.\n <P><INPUT TYPE=SUBMIT VALUE=\"Continue\"><BR>")
  43. #define SZ_HIST_TABLE_SNIFFED_TEXT _T("INVESTIGATED")
  44. #define SZ_ALLOW_SNIFFING_TEXT _T("I want the troubleshooter to investigate settings on this computer")
  45. #define SZ_SNIFF_ONE_NODE _T("Investigate")
  46. #define SZ_SNIFF_FAILED _T("The troubleshooter was unable to investigate the necessary settings. Follow the remaining instructions on this page to complete the task manually.")
  47. #define SZ_INPUT_TAG_NEXT _T("<INPUT tag=next TYPE=SUBMIT VALUE=\"")
  48. #define SZ_INPUT_TAG_STARTOVER _T("<INPUT tag=startover TYPE=BUTTON VALUE=\"")
  49. #define SZ_INPUT_TAG_BACK _T("<INPUT tag=back TYPE=BUTTON VALUE=\"")
  50. #define SZ_INPUT_TAG_SNIFFER _T("<INPUT tag=sniffer TYPE=BUTTON VALUE=\"")
  51. // Text forms of some special state values
  52. #define SZ_ST_FAILED _T("0") // "failed" on fixable node is considered normal
  53. // 101 - Go to "Bye" Page (User succeeded)
  54. #define SZ_ST_WORKED _T("101")
  55. // 102 - Unknown (user doesn't know the correct answer here - applies to Fixable/Unfixable and
  56. // Info nodes only)
  57. #define SZ_ST_UNKNOWN _T("102")
  58. // 103 - "Anything Else?" (effectively, "retry a skiped node?"
  59. #define SZ_ST_ANY _T("103")
  60. //
  61. #define SZ_ST_SNIFFED_MANUALLY_TRUE _T("true")
  62. //
  63. #define SZ_ST_SNIFFED_MANUALLY_FALSE _T("false")
  64. class CSniffConnector;
  65. class CSniff;
  66. //
  67. class CInfer
  68. {
  69. // This class is an instrument to restore m_arrInitial - like order of
  70. // elements in array, passed to its "Restore" function
  71. class CArrayOrderRestorer
  72. {
  73. vector<NID> m_arrInitial;
  74. public:
  75. CArrayOrderRestorer(const vector<NID>& initial) : m_arrInitial(initial) {}
  76. public:
  77. bool Restore(long base_length, vector<NID>& arr_to_restore);
  78. };
  79. public:
  80. CInfer(CSniffConnector* pSniffConnector);
  81. ~CInfer();
  82. int INode(LPCTSTR sz) {return m_pTopic->INode(sz);};
  83. void SetTopic(CTopic *pTopic);
  84. void SetNodeState(NID nid, IST ist);
  85. void AddToSniffed(NID nid, IST ist);
  86. void IdentifyPresumptiveCause();
  87. void FillInHTMLFragments(CHTMLFragmentsTS &frag);
  88. bool AppendBESRedirection(CString & str);
  89. NID NIDFromIDH(IDH idh) const;
  90. NID NIDSelected() const;
  91. CSniff* GetSniff();
  92. void SetLastSniffedManually(bool);
  93. private:
  94. enum ActionButtons {
  95. k_BtnNext = 0x01,
  96. k_BtnBack = 0x02,
  97. k_BtnStartOver = 0x04,
  98. k_BtnPPSniffing = 0x08, // Problem Page sniff button for expensive sniffing
  99. // of multiple nodes
  100. k_BtnManualSniffing = 0x10, // for manual sniffing of a single node
  101. };
  102. typedef UINT ActionButtonSet; // should be an OR of 0 or more ActionButtons
  103. private:
  104. bool IsProblemNode(NID nid) const;
  105. void AddToBasisForInference(NID nid, IST ist);
  106. void GetRecommendations();
  107. void RecycleSkippedNode();
  108. bool AllCauseNodesNormal();
  109. bool IsInSniffedArray(NID nid) const;
  110. bool IsPresumptiveCause(NID nid) const;
  111. void CreateUnknownButtonText(CString & strUnknown) const;
  112. void AppendNextButtonText(CString & str) const;
  113. void AppendBackButtonText(CString & str) const;
  114. void AppendPPSnifferButtonText(CString & str) const;
  115. void AppendStartOverButtonText(CString & str) const;
  116. void AppendManualSniffButtonText(CString & str) const;
  117. void AppendHistTableSniffedText(CString & str) const;
  118. void AppendAllowSniffingText(CString & str) const;
  119. void AppendSniffFailedText(CString & str) const;
  120. void AppendActionButtons(CString & str, ActionButtonSet btns, NID nid = -1) const;
  121. void AppendNextButton(CString & str) const;
  122. void AppendStartOverButton(CString & str) const;
  123. void AppendBackButton(CString & str) const;
  124. void AppendPPSnifferButton(CString & str) const;
  125. void AppendManualSniffButton(CString & str, NID nid) const;
  126. void AppendMultilineNetProp(CString & str, LPCTSTR szPropName, LPCTSTR szFormat);
  127. void AppendMultilineNodeProp(CString & str, NID nid, LPCTSTR szPropName, LPCTSTR szFormat);
  128. void AppendCurrentRadioButtons(NID nid, CString & str);
  129. static void AppendRadioButtonCurrentNode(
  130. CString &str, LPCTSTR szName, LPCTSTR szValue, LPCTSTR szLabel, bool bChecked =false);
  131. void AppendRadioButtonVisited(CString &str, NID nid, UINT value, bool bSet,
  132. LPCTSTR szLabel, bool bShowHistory) const;
  133. void CreateProblemVisitedText(CString & str, NID nidProblem, bool bShowHistory);
  134. bool AppendVisitedNodeText(CString & str, NID nid, bool bShowHistory) const;
  135. void AppendStateText(CString & str, NID nid, UINT state, bool bSet, bool bSkipped,
  136. bool bShowHistory, int nStateSet);
  137. void AppendHiddenFieldSniffed(CString &str, NID nid) const;
  138. void AddAllowAutomaticSniffingHiddenField(CString &str) const;
  139. void AppendCurrentNodeText(CString & str);
  140. void AppendByeMsg(CString & str);
  141. void AppendFailMsg(CString & str);
  142. void AppendServiceMsg(CString & str);
  143. void AppendNIDPage(NID nid, CString & str);
  144. void AppendImpossiblePage(CString & str);
  145. void AppendSniffAllCausesNormalPage(CString & str);
  146. void AppendProblemPage(CString & str);
  147. void AppendProblemNodes(CString & str);
  148. void AppendLinkAsButton(
  149. CString & str,
  150. const CString & strTarget,
  151. const CString & strLabel) const;
  152. // JSM V3.2 wrapper for AppendMultilineNetProp() used by FillInHTMLFragments()
  153. CString ConvertNetProp(const CString &strNetPropName);
  154. bool ShowFullBES();
  155. bool TimeForBES();
  156. void OutputBackend(CString & str);
  157. static bool HideState(LPCTSTR szStateName);
  158. bool SymbolicFromNID(CString & str, NID nid) const;
  159. static bool IsCause (ESTDLBL lbl);
  160. bool IsSkipped(NID nid) const;
  161. bool ManuallySniffedNodeExists() const;
  162. bool IsManuallySniffedNode(NID nid) const;
  163. private:
  164. CTopic *m_pTopic; // associated belief network
  165. CSniff *m_pSniff; // associated sniffing object
  166. // History, extracted from the query from the user.
  167. // All this is known _before_ we seek a recommendation.
  168. CBasisForInference m_BasisForInference; // tie together nodes & their states; excludes
  169. // skipped nodes
  170. CBasisForInference m_SniffedStates; // tie together successfully sniffed nodes & their states
  171. vector<NID> m_arrnidSkipped; // nodes for which the user has been unable to give
  172. // a yes or no answer (or, in the case of multistate,
  173. // any useful answer at all).
  174. vector<NID> m_arrnidVisited; // node numbers of recommendations the user has visited
  175. // This includes skipped nodes, but excludes the selected problem
  176. // and excludes pseudo-nodes like the FAIL node.
  177. NID m_nidProblem; // problem node indicated by user request.
  178. // set to nidNil if no problem node yet specified.
  179. bool m_bDone; // TRUE ==> we got back state ST_WORKED (better be
  180. // for the last node in the list!) so it's time to
  181. // show the BYE page
  182. CString m_strStartOverLink; // For Online TS, URL of Problem page
  183. // Recommendations
  184. CRecommendations m_Recommendations; // new recommendations. We only care about the
  185. // first recommendation not already offered and skipped.
  186. bool m_bRecOK; // true ==> m_Recommendations is valid. (Can be valid and
  187. // empty if nothing to recommend).
  188. CNodeStatePair m_SniffedRecommendation; // if a recommendation from a sniffer overrides normal;
  189. // method of getting a recommendation, here's where we store it.
  190. // Otherwise, nidNil.
  191. // Because this is always a Cause node in its abnormal state,
  192. // it is actually redundant (but harmless) to track state as
  193. // well as node ID.
  194. // Back End Search
  195. bool m_bUseBackEndRedirection;// Set true when user asks for Back End Search
  196. CString m_strEncodedForm; // URL-encoded search form (like the contents of a Get-method
  197. // query). This is built as a side effect when we construct
  198. // the full BES page.
  199. // Variables related to re-offering a previously skipped node
  200. bool m_bRecycleSkippedNode; // Set TRUE if user (responding to service node) wants
  201. // to revisit a previously skipped node. May be set false
  202. // if we discover there is no such node to revisit.
  203. NID m_nidRecycled; // Node to use if m_bRecycleSkippedNode is TRUE
  204. bool m_bRecyclingInitialized;// Protects against multiple calls to RecycleSkippedNode()
  205. // ------------- Misc -------------
  206. NID m_nidSelected; // once we work out what node to show the user, we keep this
  207. // around for logging.
  208. bool m_bLastSniffedManually; // identifies that last node was sniffed manually
  209. };
  210. #endif // !defined(APGTSINF_H_INCLUDED)