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.

167 lines
5.2 KiB

  1. //
  2. // MODULE: LaunchTS.cpp
  3. //
  4. // PURPOSE: The interface that TSHOOT.OCX uses to get network and node information
  5. // from the LaunchServ.
  6. //
  7. // PROJECT: Local Troubleshooter Launcher for the Device Manager
  8. //
  9. // COMPANY: Saltmine Creative, Inc. (206)-633-4743 [email protected]
  10. //
  11. // AUTHOR: Richard Meadows
  12. // COMMENTS BY: Joe Mabel
  13. //
  14. // ORIGINAL DATE: 2-26-98
  15. //
  16. //
  17. // Version Date By Comments
  18. //--------------------------------------------------------------------
  19. // V0.1 - RM Original
  20. ///////////////////////
  21. #include "stdafx.h"
  22. #include "LaunchServ.h"
  23. #include "StateInfo.h"
  24. #include "LaunchTS.h"
  25. #include "ComGlobals.h"
  26. extern CSMStateInfo g_StateInfo;
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CLaunchTS - Created as a plain apartment model interface.
  29. // This fills in m_refedLaunchState from TSLaunchServ's global memory.
  30. // The resulting values tell us what troubleshooting network to use and can
  31. // indicate a problem node and even indicate states to set for other nodes.
  32. STDMETHODIMP CLaunchTS::GetShooterStates(DWORD * pdwResult)
  33. {
  34. HRESULT hRes;
  35. m_csThreadSafeBr.Lock();
  36. hRes = g_StateInfo.GetShooterStates(m_refedLaunchState, pdwResult);
  37. m_csThreadSafeBr.Unlock();
  38. return hRes;
  39. }
  40. // OUTPUT pbstrShooter is the name of the Troubleshooting network to launch to
  41. // Note that this string is allocated by this function
  42. // Returns true if there is a Troubleshooting network to launch to
  43. // Must be called after CLaunchTS::GetShooterStates, since it assumes
  44. // m_refedLaunchState contains good values
  45. STDMETHODIMP CLaunchTS::GetTroubleShooter(BSTR * pbstrShooter)
  46. {
  47. LPTSTR pszCmd;
  48. LPTSTR pszVal;
  49. m_csThreadSafeBr.Lock();
  50. if (!m_refedLaunchState.GetNetwork(&pszCmd, &pszVal))
  51. {
  52. m_csThreadSafeBr.Unlock();
  53. return S_FALSE;
  54. }
  55. *pbstrShooter = SysAllocString((BSTR) CComBSTR(pszVal));
  56. m_csThreadSafeBr.Unlock();
  57. return S_OK;
  58. }
  59. // OUTPUT pbstrProblem is the symbolic name of the selected problem node
  60. // Note that this string is allocated by this function
  61. // Returns true if there is a selected problem node
  62. // Must be called after CLaunchTS::GetShooterStates, since it assumes
  63. // m_refedLaunchState contains good values
  64. STDMETHODIMP CLaunchTS::GetProblem(BSTR * pbstrProblem)
  65. {
  66. LPTSTR pszCmd;
  67. LPTSTR pszVal;
  68. m_csThreadSafeBr.Lock();
  69. if (!m_refedLaunchState.GetProblem(&pszCmd, &pszVal))
  70. {
  71. m_csThreadSafeBr.Unlock();
  72. return S_FALSE;
  73. }
  74. *pbstrProblem = SysAllocString((BSTR) CComBSTR(pszVal));
  75. m_csThreadSafeBr.Unlock();
  76. return S_OK;
  77. }
  78. STDMETHODIMP CLaunchTS::GetMachine(BSTR * pbstrMachine)
  79. {
  80. m_csThreadSafeBr.Lock();
  81. *pbstrMachine = ::SysAllocString((BSTR) CComBSTR(m_refedLaunchState.m_szMachineID));
  82. m_csThreadSafeBr.Unlock();
  83. return S_OK;
  84. }
  85. STDMETHODIMP CLaunchTS::GetPNPDevice(BSTR *pbstrPNPDevice)
  86. {
  87. m_csThreadSafeBr.Lock();
  88. *pbstrPNPDevice = ::SysAllocString((BSTR) CComBSTR(m_refedLaunchState.m_szPNPDeviceID));
  89. m_csThreadSafeBr.Unlock();
  90. return S_OK;
  91. }
  92. STDMETHODIMP CLaunchTS::GetGuidClass(BSTR *pbstrGuidClass)
  93. {
  94. m_csThreadSafeBr.Lock();
  95. *pbstrGuidClass = ::SysAllocString((BSTR) CComBSTR(m_refedLaunchState.m_szGuidClass));
  96. m_csThreadSafeBr.Unlock();
  97. return S_OK;
  98. }
  99. STDMETHODIMP CLaunchTS::GetDeviceInstance(BSTR *pbstrDeviceInstance)
  100. {
  101. m_csThreadSafeBr.Lock();
  102. *pbstrDeviceInstance = ::SysAllocString((BSTR) CComBSTR(m_refedLaunchState.m_szDeviceInstanceID));
  103. m_csThreadSafeBr.Unlock();
  104. return S_OK;
  105. }
  106. // INPUT iNode - index of (non-problem) node. Typically, this function should be called
  107. // in a loop where we first see if there is a pbstrNode value for iNode == 0 and then
  108. // increment iNode until we reach a value for which pbstrNode is undefined.
  109. // OUTPUT pbstrNode is the symbolic name of a (non-problem) node whose state we want to set
  110. // Note that this string is allocated by this function
  111. // Returns true if there is a selected problem node
  112. // Must be called after CLaunchTS::GetShooterStates, since it assumes
  113. // m_refedLaunchState contains good values
  114. STDMETHODIMP CLaunchTS::GetNode(short iNode, BSTR * pbstrNode)
  115. {
  116. LPTSTR pszCmd;
  117. LPTSTR pszVal;
  118. m_csThreadSafeBr.Lock();
  119. if (!m_refedLaunchState.GetNodeState(iNode, &pszCmd, &pszVal))
  120. {
  121. m_csThreadSafeBr.Unlock();
  122. return S_FALSE;
  123. }
  124. *pbstrNode = SysAllocString((BSTR) CComBSTR(pszCmd));
  125. m_csThreadSafeBr.Unlock();
  126. return S_OK;
  127. }
  128. // see comments on CLaunchTS::GetNode; this returns the node state rather than
  129. // the symbolic node name
  130. STDMETHODIMP CLaunchTS::GetState(short iNode, BSTR * pbstrState)
  131. {
  132. LPTSTR pszCmd;
  133. LPTSTR pszVal;
  134. m_csThreadSafeBr.Lock();
  135. if (!m_refedLaunchState.GetNodeState(iNode, &pszCmd, &pszVal))
  136. {
  137. m_csThreadSafeBr.Unlock();
  138. return S_FALSE;
  139. }
  140. *pbstrState = SysAllocString((BSTR) CComBSTR(pszVal));
  141. m_csThreadSafeBr.Unlock();
  142. return S_OK;
  143. }
  144. // Test: Used to get network and node information from the server without
  145. // launching the browser. Use the TShootATL::Test method before ILaunchTS::Test.
  146. STDMETHODIMP CLaunchTS::Test()
  147. {
  148. extern CSMStateInfo g_StateInfo;
  149. m_csThreadSafeBr.Lock();
  150. g_StateInfo.TestGet(m_refedLaunchState);
  151. m_csThreadSafeBr.Unlock();
  152. return S_OK;
  153. }