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.

340 lines
6.2 KiB

  1. //
  2. // MODULE: TShootATL.cpp
  3. //
  4. // PURPOSE: The interface that device manager uses to launch troubleshooters.
  5. //
  6. // PROJECT: Local Troubleshooter Launcher for the Device Manager
  7. //
  8. // COMPANY: Saltmine Creative, Inc. (206)-633-4743 [email protected]
  9. //
  10. // AUTHOR: Richard Meadows
  11. //
  12. // ORIGINAL DATE: 2-26-98
  13. //
  14. //
  15. // Version Date By Comments
  16. //--------------------------------------------------------------------
  17. // V0.1 - RM Original
  18. ///////////////////////
  19. #include "stdafx.h"
  20. #include "LaunchServ.h"
  21. #include "StateInfo.h"
  22. #include "RSSTACK.H"
  23. #include "Launch.h"
  24. #include "TShootATL.h"
  25. #include "TSLError.h"
  26. #include "ComGlobals.h"
  27. #include <atlimpl.cpp>
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CTShootATL - Created as an internet explorer object with a dual interface
  30. STDMETHODIMP CTShootATL::SpecifyProblem(BSTR bstrNetwork, BSTR bstrProblem, DWORD * pdwResult)
  31. {
  32. HRESULT hRes = S_OK;
  33. *pdwResult = TSL_ERROR_GENERAL;
  34. TCHAR szProblem[CLaunch::SYM_LEN];
  35. TCHAR szNetwork[CLaunch::SYM_LEN];
  36. if (!BSTRToTCHAR(szNetwork, bstrNetwork, CLaunch::SYM_LEN))
  37. {
  38. *pdwResult = TSL_E_MEM_EXCESSIVE;
  39. return TSL_E_FAIL;
  40. }
  41. if (!BSTRToTCHAR(szProblem, bstrProblem, CLaunch::SYM_LEN))
  42. {
  43. *pdwResult = TSL_E_MEM_EXCESSIVE;
  44. return TSL_E_FAIL;
  45. }
  46. m_csThreadSafe.Lock();
  47. try
  48. {
  49. if (!m_Launcher.SpecifyProblem(szNetwork, szProblem))
  50. {
  51. *pdwResult = TSL_ERROR_GENERAL;
  52. hRes = TSL_E_FAIL;
  53. }
  54. else
  55. {
  56. *pdwResult = TSL_OK;
  57. }
  58. }
  59. catch(...)
  60. {
  61. m_csThreadSafe.Unlock();
  62. throw;
  63. }
  64. m_csThreadSafe.Unlock();
  65. return hRes;
  66. }
  67. STDMETHODIMP CTShootATL::SetNode(BSTR bstrName, BSTR bstrState, DWORD *pdwResult)
  68. {
  69. HRESULT hRes = S_OK;
  70. *pdwResult = TSL_ERROR_GENERAL;
  71. TCHAR szName[CLaunch::SYM_LEN];
  72. TCHAR szState[CLaunch::SYM_LEN];
  73. if (!BSTRToTCHAR(szName, bstrName, CLaunch::SYM_LEN))
  74. {
  75. *pdwResult = TSL_E_MEM_EXCESSIVE;
  76. return TSL_E_FAIL;
  77. }
  78. if (!BSTRToTCHAR(szState, bstrState, CLaunch::SYM_LEN))
  79. {
  80. *pdwResult = TSL_E_MEM_EXCESSIVE;
  81. return TSL_E_FAIL;
  82. }
  83. m_csThreadSafe.Lock();
  84. try
  85. {
  86. if (!m_Launcher.SetNode(szName, szState))
  87. {
  88. *pdwResult = TSL_ERROR_GENERAL;
  89. hRes = TSL_E_FAIL;
  90. }
  91. else
  92. {
  93. *pdwResult = TSL_OK;
  94. }
  95. }
  96. catch(...)
  97. {
  98. m_csThreadSafe.Unlock();
  99. throw;
  100. }
  101. m_csThreadSafe.Unlock();
  102. return hRes;
  103. }
  104. STDMETHODIMP CTShootATL::Language(BSTR bstrLanguage, DWORD * pdwResult)
  105. {
  106. HRESULT hRes = S_OK;
  107. *pdwResult = TSL_ERROR_GENERAL;
  108. m_csThreadSafe.Lock();
  109. try
  110. {
  111. //hRes =
  112. }
  113. catch(...)
  114. {
  115. m_csThreadSafe.Unlock();
  116. throw;
  117. }
  118. m_csThreadSafe.Unlock();
  119. return hRes;
  120. }
  121. STDMETHODIMP CTShootATL::MachineID(BSTR bstrMachineID, DWORD * pdwResult)
  122. {
  123. HRESULT hRes = S_OK;
  124. *pdwResult = TSL_ERROR_GENERAL;
  125. m_csThreadSafe.Lock();
  126. try
  127. {
  128. hRes = m_Launcher.MachineID(bstrMachineID, pdwResult);
  129. }
  130. catch(...)
  131. {
  132. m_csThreadSafe.Unlock();
  133. throw;
  134. }
  135. m_csThreadSafe.Unlock();
  136. return hRes;
  137. }
  138. // Test: Call Test after setting the device and caller information.
  139. // Test will return S_OK if the mapping worked. The result of the mapping
  140. // can then be obtained through the ILaunchTS interface. Use the Test method
  141. // of ILaunchTS before calling the other ILaunchTS methods.
  142. STDMETHODIMP CTShootATL::Test()
  143. {
  144. HRESULT hRes;
  145. m_csThreadSafe.Lock();
  146. try
  147. {
  148. if (m_Launcher.TestPut()) // Does the mapping and copies the information to global memory.
  149. hRes = S_OK;
  150. else
  151. hRes = TSL_E_FAIL;
  152. }
  153. catch(...)
  154. {
  155. m_csThreadSafe.Unlock();
  156. throw;
  157. }
  158. m_csThreadSafe.Unlock();
  159. return hRes;
  160. }
  161. STDMETHODIMP CTShootATL::DeviceInstanceID(BSTR bstrDeviceInstanceID, DWORD * pdwResult)
  162. {
  163. HRESULT hRes = S_OK;
  164. *pdwResult = TSL_ERROR_GENERAL;
  165. m_csThreadSafe.Lock();
  166. try
  167. {
  168. hRes = m_Launcher.DeviceInstanceID(bstrDeviceInstanceID, pdwResult);
  169. }
  170. catch(...)
  171. {
  172. m_csThreadSafe.Unlock();
  173. throw;
  174. }
  175. m_csThreadSafe.Unlock();
  176. return hRes;
  177. }
  178. STDMETHODIMP CTShootATL::ReInit()
  179. {
  180. m_csThreadSafe.Lock();
  181. try
  182. {
  183. m_Launcher.ReInit();
  184. }
  185. catch(...)
  186. {
  187. m_csThreadSafe.Unlock();
  188. throw;
  189. }
  190. m_csThreadSafe.Unlock();
  191. return S_OK;
  192. }
  193. STDMETHODIMP CTShootATL::LaunchKnown(DWORD * pdwResult)
  194. {
  195. HRESULT hRes;
  196. m_csThreadSafe.Lock();
  197. try
  198. {
  199. hRes = m_Launcher.LaunchKnown(pdwResult);
  200. }
  201. catch(...)
  202. {
  203. m_csThreadSafe.Unlock();
  204. throw;
  205. }
  206. m_csThreadSafe.Unlock();
  207. return hRes;
  208. }
  209. STDMETHODIMP CTShootATL::get_LaunchWaitTimeOut(long * pVal)
  210. {
  211. HRESULT hRes = S_OK;
  212. m_csThreadSafe.Lock();
  213. try
  214. {
  215. *pVal = m_Launcher.m_lLaunchWaitTimeOut;
  216. }
  217. catch(...)
  218. {
  219. m_csThreadSafe.Unlock();
  220. throw;
  221. }
  222. m_csThreadSafe.Unlock();
  223. return hRes;
  224. }
  225. STDMETHODIMP CTShootATL::put_LaunchWaitTimeOut(long newVal)
  226. {
  227. HRESULT hRes = S_OK;
  228. m_csThreadSafe.Lock();
  229. try
  230. {
  231. m_Launcher.m_lLaunchWaitTimeOut = newVal;
  232. }
  233. catch(...)
  234. {
  235. m_csThreadSafe.Unlock();
  236. throw;
  237. }
  238. m_csThreadSafe.Unlock();
  239. return hRes;
  240. }
  241. STDMETHODIMP CTShootATL::Launch(BSTR bstrCallerName, BSTR bstrCallerVersion, BSTR bstrAppProblem, short bLaunch, DWORD * pdwResult)
  242. {
  243. HRESULT hRes;
  244. m_csThreadSafe.Lock();
  245. try
  246. {
  247. hRes = m_Launcher.Launch(bstrCallerName, bstrCallerVersion, bstrAppProblem, bLaunch, pdwResult);
  248. }
  249. catch(...)
  250. {
  251. m_csThreadSafe.Unlock();
  252. throw;
  253. }
  254. m_csThreadSafe.Unlock();
  255. return hRes;
  256. }
  257. STDMETHODIMP CTShootATL::LaunchDevice(BSTR bstrCallerName, BSTR bstrCallerVersion, BSTR bstrPNPDeviceID, BSTR bstrDeviceClassGUID, BSTR bstrAppProblem, short bLaunch, DWORD * pdwResult)
  258. {
  259. HRESULT hRes;
  260. m_csThreadSafe.Lock();
  261. try
  262. {
  263. hRes = m_Launcher.LaunchDevice(bstrCallerName, bstrCallerVersion, bstrPNPDeviceID, bstrDeviceClassGUID, bstrAppProblem, bLaunch, pdwResult);
  264. }
  265. catch(...)
  266. {
  267. m_csThreadSafe.Unlock();
  268. throw;
  269. }
  270. m_csThreadSafe.Unlock();
  271. return hRes;
  272. }
  273. STDMETHODIMP CTShootATL::get_PreferOnline(BOOL * pVal)
  274. {
  275. m_csThreadSafe.Lock();
  276. try
  277. {
  278. if (m_Launcher.m_bPreferOnline)
  279. *pVal = 1;
  280. else
  281. *pVal = 0;
  282. }
  283. catch(...)
  284. {
  285. m_csThreadSafe.Unlock();
  286. throw;
  287. }
  288. m_csThreadSafe.Unlock();
  289. return S_OK;
  290. }
  291. STDMETHODIMP CTShootATL::put_PreferOnline(BOOL newVal)
  292. {
  293. m_csThreadSafe.Lock();
  294. try
  295. {
  296. m_Launcher.m_bPreferOnline = (0 != newVal);
  297. }
  298. catch(...)
  299. {
  300. m_csThreadSafe.Unlock();
  301. throw;
  302. }
  303. m_csThreadSafe.Unlock();
  304. return S_OK;
  305. }
  306. STDMETHODIMP CTShootATL::GetStatus(DWORD * pdwStatus)
  307. {
  308. m_csThreadSafe.Lock();
  309. try
  310. {
  311. *pdwStatus = m_Launcher.GetStatus();
  312. }
  313. catch(...)
  314. {
  315. m_csThreadSafe.Unlock();
  316. throw;
  317. }
  318. m_csThreadSafe.Unlock();
  319. return S_OK;
  320. }