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.

315 lines
8.3 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // FILE : AllFaxDevices.cpp //
  3. // //
  4. // DESCRIPTION : Fax Server MMC node creation. //
  5. // //
  6. // AUTHOR : yossg //
  7. // //
  8. // HISTORY : //
  9. // Sep 22 1999 yossg Create //
  10. // Dec 9 1999 yossg Reorganize Populate ChildrenList, //
  11. // and the call to InitDisplayName //
  12. // Oct 17 2000 yossg //
  13. // //
  14. // Copyright (C) 1999 Microsoft Corporation All Rights Reserved //
  15. /////////////////////////////////////////////////////////////////////////////
  16. #include "StdAfx.h"
  17. #include "DevicesAndProviders.h"
  18. #include "Devices.h"
  19. #include "Providers.h"
  20. //here to #include Dialog H files
  21. #include "Icons.h"
  22. #include "oaidl.h"
  23. /////////////////////////////////////////////////////////////////////////////
  24. // {CCC43AB5-C788-46df-9268-BB96CA5E3DAC}
  25. static const GUID CFaxDevicesAndProvidersNodeGUID_NODETYPE =
  26. { 0xccc43ab5, 0xc788, 0x46df, { 0x92, 0x68, 0xbb, 0x96, 0xca, 0x5e, 0x3d, 0xac } };
  27. const GUID* CFaxDevicesAndProvidersNode::m_NODETYPE = &CFaxDevicesAndProvidersNodeGUID_NODETYPE;
  28. const OLECHAR* CFaxDevicesAndProvidersNode::m_SZNODETYPE = OLESTR("CCC43AB5-C788-46df-9268-BB96CA5E3DAC");
  29. const CLSID* CFaxDevicesAndProvidersNode::m_SNAPIN_CLASSID = &CLSID_Snapin;
  30. CColumnsInfo CFaxDevicesAndProvidersNode::m_ColsInfo;
  31. /*
  32. - CFaxDevicesAndProvidersNode::InsertColumns
  33. -
  34. * Purpose:
  35. * Adds columns to the default result pane.
  36. *
  37. * Arguments:
  38. * [in] pHeaderCtrl - IHeaderCtrl in the console-provided default result view pane
  39. *
  40. * Return:
  41. * OLE error code
  42. */
  43. HRESULT
  44. CFaxDevicesAndProvidersNode::InsertColumns(IHeaderCtrl *pHeaderCtrl)
  45. {
  46. SCODE hRc;
  47. DEBUG_FUNCTION_NAME( _T("CFaxDevicesAndProvidersNode::InsertColumns"));
  48. static ColumnsInfoInitData ColumnsInitData[] =
  49. {
  50. {IDS_FAX_COL_HEAD, FXS_LARGE_COLUMN_WIDTH},
  51. {LAST_IDS, 0}
  52. };
  53. hRc = m_ColsInfo.InsertColumnsIntoMMC(pHeaderCtrl,
  54. _Module.GetResourceInstance(),
  55. ColumnsInitData);
  56. if (hRc != S_OK)
  57. {
  58. DebugPrintEx(DEBUG_ERR,_T("m_ColsInfo.InsertColumnsIntoMMC"));
  59. goto Cleanup;
  60. }
  61. Cleanup:
  62. return(hRc);
  63. }
  64. /*
  65. - CFaxDevicesAndProvidersNode::PopulateScopeChildrenList
  66. -
  67. * Purpose:
  68. * Create all the Fax Devices nodes
  69. *
  70. * Arguments:
  71. *
  72. * Return:
  73. * OLE error code
  74. * Actually it is the last OLE error code that ocoured
  75. * during processing this method.
  76. */
  77. HRESULT CFaxDevicesAndProvidersNode::PopulateScopeChildrenList()
  78. {
  79. DEBUG_FUNCTION_NAME( _T("CFaxDevicesAndProvidersNode::PopulateScopeChildrenList"));
  80. HRESULT hRc = S_OK;
  81. CFaxDevicesNode * pDevices = NULL;
  82. CFaxProvidersNode * pProviders = NULL;
  83. //
  84. // Fax Devices
  85. //
  86. pDevices = new CFaxDevicesNode(this, m_pComponentData);
  87. if (!pDevices)
  88. {
  89. hRc = E_OUTOFMEMORY;
  90. NodeMsgBox(IDS_MEMORY);
  91. DebugPrintEx(
  92. DEBUG_ERR,
  93. TEXT("Out of memory"));
  94. goto Error;
  95. }
  96. else
  97. {
  98. pDevices->InitParentNode(this);
  99. pDevices->SetIcons(IMAGE_DEVICE, IMAGE_DEVICE);
  100. hRc = pDevices->InitDisplayName();
  101. if ( FAILED(hRc) )
  102. {
  103. DebugPrintEx(DEBUG_ERR,_T("Failed to display devices node name. (hRc: %08X)"), hRc);
  104. NodeMsgBox(IDS_FAILTOADD_DEVICES);
  105. goto Error;
  106. }
  107. hRc = AddChild(pDevices, &pDevices->m_scopeDataItem);
  108. if (FAILED(hRc))
  109. {
  110. DebugPrintEx(
  111. DEBUG_ERR,
  112. TEXT("Fail to add Devices node. (hRc: %08X)"),
  113. hRc);
  114. NodeMsgBox(IDS_FAILTOADD_DEVICES);
  115. goto Error;
  116. }
  117. }
  118. //
  119. // Fax Providers
  120. //
  121. pProviders = new CFaxProvidersNode(this, m_pComponentData);
  122. if (!pProviders)
  123. {
  124. hRc = E_OUTOFMEMORY;
  125. NodeMsgBox(IDS_MEMORY);
  126. DebugPrintEx(
  127. DEBUG_ERR,
  128. TEXT("Out of memory"));
  129. goto Error;
  130. }
  131. else
  132. {
  133. pProviders->InitParentNode(this);
  134. pProviders->SetIcons(IMAGE_FSP, IMAGE_FSP);
  135. hRc = pProviders->InitDisplayName();
  136. if ( FAILED(hRc) )
  137. {
  138. DebugPrintEx(DEBUG_ERR,_T("Failed to display providers node name. (hRc: %08X)"), hRc);
  139. NodeMsgBox(IDS_FAILTOADD_PROVIDERS);
  140. goto Error;
  141. }
  142. hRc = AddChild(pProviders, &pProviders->m_scopeDataItem);
  143. if (FAILED(hRc))
  144. {
  145. DebugPrintEx(
  146. DEBUG_ERR,
  147. TEXT("Fail to add providers node. (hRc: %08X)"),
  148. hRc);
  149. NodeMsgBox(IDS_FAILTOADD_PROVIDERS);
  150. goto Error;
  151. }
  152. }
  153. ATLASSERT(S_OK == hRc);
  154. goto Exit;
  155. Error:
  156. ATLASSERT(S_OK != hRc);
  157. if ( NULL != pDevices )
  158. {
  159. if (0 != pDevices->m_scopeDataItem.ID )
  160. {
  161. HRESULT hr = RemoveChild(pDevices);
  162. if (FAILED(hr))
  163. {
  164. DebugPrintEx(DEBUG_ERR,
  165. _T("Fail to RemoveChild() devices node from node list. (hRc: %08X)"),
  166. hr);
  167. }
  168. }
  169. delete pDevices;
  170. pDevices = NULL;
  171. }
  172. if ( NULL != pProviders )
  173. {
  174. if (0 != pProviders->m_scopeDataItem.ID )
  175. {
  176. HRESULT hr = RemoveChild(pProviders);
  177. if (FAILED(hr))
  178. {
  179. DebugPrintEx(DEBUG_ERR,
  180. _T("Fail to RemoveChild() Providers node from node list. (hRc: %08X)"),
  181. hr);
  182. }
  183. }
  184. delete pProviders;
  185. pProviders = NULL;
  186. }
  187. // Empty the list
  188. //m_ScopeChildrenList.RemoveAll(); done step by step from RemoveChild
  189. m_bScopeChildrenListPopulated = FALSE;
  190. Exit:
  191. return hRc;
  192. }
  193. /*
  194. - CFaxDevicesAndProvidersNode::SetVerbs
  195. -
  196. * Purpose:
  197. * What verbs to enable/disable when this object is selected
  198. *
  199. * Arguments:
  200. * [in] pConsoleVerb - MMC ConsoleVerb interface
  201. *
  202. * Return:
  203. * OLE Error code
  204. */
  205. HRESULT CFaxDevicesAndProvidersNode::SetVerbs(IConsoleVerb *pConsoleVerb)
  206. {
  207. HRESULT hRc = S_OK;
  208. //
  209. // We want the default verb to be expand node children
  210. //
  211. hRc = pConsoleVerb->SetDefaultVerb(MMC_VERB_OPEN);
  212. return hRc;
  213. }
  214. /*
  215. - CFaxDevicesAndProvidersNode::InitDisplayName
  216. -
  217. * Purpose:
  218. * To load the node's Displaed-Name string.
  219. *
  220. * Arguments:
  221. *
  222. * Return:
  223. * OLE error code
  224. */
  225. HRESULT CFaxDevicesAndProvidersNode::InitDisplayName()
  226. {
  227. DEBUG_FUNCTION_NAME(_T("CFaxDevicesAndProvidersNode::InitDisplayName"));
  228. HRESULT hRc = S_OK;
  229. if (!m_bstrDisplayName.LoadString(_Module.GetResourceInstance(),
  230. IDS_DISPLAY_STR_DEVICESANDPROVIDERSNODE))
  231. {
  232. hRc = E_OUTOFMEMORY;
  233. goto Error;
  234. }
  235. ATLASSERT( S_OK == hRc);
  236. goto Exit;
  237. Error:
  238. ATLASSERT( S_OK != hRc);
  239. m_bstrDisplayName = L"";
  240. DebugPrintEx(
  241. DEBUG_ERR,
  242. TEXT("Fail to Load server name string."));
  243. NodeMsgBox(IDS_MEMORY);
  244. Exit:
  245. return hRc;
  246. }
  247. /*
  248. +
  249. + CFaxDevicesAndProvidersNode::OnShowContextHelp
  250. *
  251. * Purpose:
  252. * Overrides CSnapinNode::OnShowContextHelp.
  253. *
  254. * Arguments:
  255. *
  256. * Return:
  257. - OLE error code
  258. -
  259. */
  260. HRESULT CFaxDevicesAndProvidersNode::OnShowContextHelp(
  261. IDisplayHelp* pDisplayHelp, LPOLESTR helpFile)
  262. {
  263. return DisplayContextHelp(pDisplayHelp, helpFile, HLP_DEVICES);
  264. }
  265. ///////////////////////////////////////////////////////////////////