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.

350 lines
8.7 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // FILE : OutboundRouting.cpp //
  3. // //
  4. // DESCRIPTION : Fax Server - Fax OutboundRouting node. //
  5. // //
  6. // AUTHOR : yossg //
  7. // //
  8. // HISTORY : //
  9. // Sep 29 1999 yossg create //
  10. // Oct 17 2000 yossg //
  11. // //
  12. // Copyright (C) 1999 Microsoft Corporation All Rights Reserved //
  13. /////////////////////////////////////////////////////////////////////////////
  14. #include "StdAfx.h"
  15. #include "OutboundRouting.h"
  16. #include "OutboundRules.h"
  17. #include "OutboundGroups.h"
  18. #include "Icons.h"
  19. //#include "oaidl.h"
  20. /****************************************************
  21. CFaxOutboundRoutingNode Class
  22. ****************************************************/
  23. // {38B04E8F-9BA6-4a22-BEF3-9AD90E3349B2}
  24. static const GUID CFaxOutboundRoutingNodeGUID_NODETYPE =
  25. { 0x38b04e8f, 0x9ba6, 0x4a22, { 0xbe, 0xf3, 0x9a, 0xd9, 0xe, 0x33, 0x49, 0xb2 } };
  26. const GUID* CFaxOutboundRoutingNode::m_NODETYPE = &CFaxOutboundRoutingNodeGUID_NODETYPE;
  27. const OLECHAR* CFaxOutboundRoutingNode::m_SZNODETYPE = OLESTR("38B04E8F-9BA6-4a22-BEF3-9AD90E3349B2");
  28. const CLSID* CFaxOutboundRoutingNode::m_SNAPIN_CLASSID = &CLSID_Snapin;
  29. CColumnsInfo CFaxOutboundRoutingNode::m_ColsInfo;
  30. /*
  31. - CFaxOutboundRoutingNode::InsertColumns
  32. -
  33. * Purpose:
  34. * Adds columns to the default result pane.
  35. *
  36. * Arguments:
  37. * [in] pHeaderCtrl - IHeaderCtrl in the console-provided default result view pane
  38. *
  39. * Return:
  40. * OLE error code
  41. */
  42. HRESULT
  43. CFaxOutboundRoutingNode::InsertColumns(IHeaderCtrl *pHeaderCtrl)
  44. {
  45. DEBUG_FUNCTION_NAME( _T("CFaxOutboundRoutingNode::InsertColumns"));
  46. HRESULT hRc = S_OK;
  47. static ColumnsInfoInitData ColumnsInitData[] =
  48. {
  49. {IDS_FAX_COL_HEAD, FXS_LARGE_COLUMN_WIDTH},
  50. {LAST_IDS, 0}
  51. };
  52. hRc = m_ColsInfo.InsertColumnsIntoMMC(pHeaderCtrl,
  53. _Module.GetResourceInstance(),
  54. ColumnsInitData);
  55. if (hRc != S_OK)
  56. {
  57. DebugPrintEx(DEBUG_ERR,_T("m_ColsInfo.InsertColumnsIntoMMC. (hRc: %08X)"), hRc);
  58. goto Cleanup;
  59. }
  60. Cleanup:
  61. return(hRc);
  62. }
  63. /*
  64. - CFaxOutboundRoutingNode::PopulateScopeChildrenList
  65. -
  66. * Purpose:
  67. * Create Out bound routing main nodes: Groups and Rules
  68. *
  69. * Arguments:
  70. *
  71. * Return:
  72. * OLE error code
  73. */
  74. HRESULT CFaxOutboundRoutingNode::PopulateScopeChildrenList()
  75. {
  76. DEBUG_FUNCTION_NAME( _T("CFaxOutboundRoutingNode::PopulateScopeChildrenList"));
  77. HRESULT hRc = S_OK;
  78. CFaxOutboundGroupsNode * pGroups = NULL;
  79. CFaxOutboundRoutingRulesNode * pRules = NULL;
  80. //
  81. // Fax OutboundGroups
  82. //
  83. pGroups = new CFaxOutboundGroupsNode(this, m_pComponentData);
  84. if (!pGroups)
  85. {
  86. hRc = E_OUTOFMEMORY;
  87. NodeMsgBox(IDS_MEMORY);
  88. DebugPrintEx(
  89. DEBUG_ERR,
  90. TEXT("Out of memory"));
  91. goto Error;
  92. }
  93. else
  94. {
  95. pGroups->InitParentNode(this);
  96. /*
  97. hRc = pGroups->InitRPC();
  98. if (FAILED(hRc))
  99. {
  100. DebugPrintEx(
  101. DEBUG_ERR,
  102. TEXT("Fail to call RPC to init groups. (hRc: %08X)"),
  103. hRc);
  104. goto Error;
  105. }
  106. */
  107. pGroups->SetIcons(IMAGE_FOLDER_CLOSE, IMAGE_FOLDER_OPEN);
  108. hRc = pGroups->InitDisplayName();
  109. if ( FAILED(hRc) )
  110. {
  111. DebugPrintEx(DEBUG_ERR,_T("Failed to display node name. (hRc: %08X)"), hRc);
  112. NodeMsgBox(IDS_FAILTOADD_ROUTINGGROUPS);
  113. goto Error;
  114. }
  115. hRc = AddChild(pGroups, &pGroups->m_scopeDataItem);
  116. if (FAILED(hRc))
  117. {
  118. DebugPrintEx(
  119. DEBUG_ERR,
  120. TEXT("Fail to add Devices node. (hRc: %08X)"),
  121. hRc);
  122. NodeMsgBox(IDS_FAILTOADD_ROUTINGGROUPS);
  123. goto Error;
  124. }
  125. }
  126. //
  127. // Fax OutboundRules
  128. //
  129. pRules = new CFaxOutboundRoutingRulesNode(this, m_pComponentData);
  130. if (!pRules)
  131. {
  132. hRc = E_OUTOFMEMORY;
  133. NodeMsgBox(IDS_MEMORY);
  134. DebugPrintEx(
  135. DEBUG_ERR,
  136. TEXT("Out of memory"));
  137. goto Error;
  138. }
  139. else
  140. {
  141. pRules->InitParentNode(this);
  142. pRules->SetIcons(IMAGE_RULE, IMAGE_RULE);
  143. hRc = pRules->InitDisplayName();
  144. if ( FAILED(hRc) )
  145. {
  146. DebugPrintEx(DEBUG_ERR,_T("Failed to display node name. (hRc: %08X)"), hRc);
  147. NodeMsgBox(IDS_FAILTOADD_ROUTINGRULES);
  148. goto Error;
  149. }
  150. hRc = AddChild(pRules, &pRules->m_scopeDataItem);
  151. if (FAILED(hRc))
  152. {
  153. DebugPrintEx(
  154. DEBUG_ERR,
  155. TEXT("Fail to add outbound routing rules node. (hRc: %08X)"),
  156. hRc);
  157. NodeMsgBox(IDS_FAILTOADD_ROUTINGRULES);
  158. goto Error;
  159. }
  160. }
  161. ATLASSERT(S_OK == hRc);
  162. goto Exit;
  163. Error:
  164. ATLASSERT(S_OK != hRc);
  165. if ( NULL != pGroups )
  166. {
  167. if (0 != pGroups->m_scopeDataItem.ID )
  168. {
  169. HRESULT hr = RemoveChild(pGroups);
  170. if (FAILED(hr))
  171. {
  172. DebugPrintEx(DEBUG_ERR,
  173. _T("Fail to RemoveChild() Groups node from node list. (hRc: %08X)"),
  174. hr);
  175. }
  176. }
  177. delete pGroups;
  178. pGroups = NULL;
  179. }
  180. if ( NULL != pRules )
  181. {
  182. if (0 != pRules->m_scopeDataItem.ID )
  183. {
  184. HRESULT hr = RemoveChild(pRules);
  185. if (FAILED(hr))
  186. {
  187. DebugPrintEx(DEBUG_ERR,
  188. _T("Fail to RemoveChild() Rules node from node list. (hRc: %08X)"),
  189. hr);
  190. }
  191. }
  192. delete pRules;
  193. pRules = NULL;
  194. }
  195. // Empty the list
  196. //m_ScopeChildrenList.RemoveAll(); //Done by RemoveChild
  197. m_bScopeChildrenListPopulated = FALSE;
  198. Exit:
  199. return hRc;
  200. }
  201. /*
  202. - CFaxOutboundRoutingNode::SetVerbs
  203. -
  204. * Purpose:
  205. * What verbs to enable/disable when this object is selected
  206. *
  207. * Arguments:
  208. * [in] pConsoleVerb - MMC ConsoleVerb interface
  209. *
  210. * Return:
  211. * OLE Error code
  212. */
  213. HRESULT CFaxOutboundRoutingNode::SetVerbs(IConsoleVerb *pConsoleVerb)
  214. {
  215. HRESULT hRc = S_OK;
  216. //
  217. // We want the default verb to be expand node children
  218. //
  219. hRc = pConsoleVerb->SetDefaultVerb(MMC_VERB_OPEN);
  220. return hRc;
  221. }
  222. /*
  223. - CFaxOutboundRoutingNode::OnRefresh
  224. -
  225. * Purpose:
  226. * Called when refreshing the object.
  227. *
  228. * Arguments:
  229. *
  230. * Return:
  231. * OLE error code
  232. */
  233. HRESULT
  234. CFaxOutboundRoutingNode::OnRefresh(LPARAM arg,
  235. LPARAM param,
  236. IComponentData *pComponentData,
  237. IComponent * pComponent,
  238. DATA_OBJECT_TYPES type)
  239. {
  240. DEBUG_FUNCTION_NAME( _T("CFaxOutboundRoutingNode::OnRefresh"));
  241. HRESULT hRc = S_OK;
  242. /*
  243. // TBD
  244. */
  245. return hRc;
  246. }
  247. /*
  248. - CFaxOutboundRoutingNode::InitDisplayName
  249. -
  250. * Purpose:
  251. * To load the node's Displaed-Name string.
  252. *
  253. * Arguments:
  254. *
  255. * Return:
  256. * OLE error code
  257. */
  258. HRESULT CFaxOutboundRoutingNode::InitDisplayName()
  259. {
  260. DEBUG_FUNCTION_NAME(_T("CFaxOutboundRoutingNode::InitDisplayName"));
  261. HRESULT hRc = S_OK;
  262. if (!m_bstrDisplayName.LoadString(_Module.GetResourceInstance(),
  263. IDS_DISPLAY_STR_OUTBOUNDROUTINGNODE) )
  264. {
  265. hRc = E_OUTOFMEMORY;
  266. goto Error;
  267. }
  268. ATLASSERT( S_OK == hRc);
  269. goto Exit;
  270. Error:
  271. ATLASSERT( S_OK != hRc);
  272. m_bstrDisplayName = L"";
  273. DebugPrintEx(
  274. DEBUG_ERR,
  275. TEXT("Fail to Load Outbound routing node name-string."));
  276. NodeMsgBox(IDS_MEMORY);
  277. Exit:
  278. return hRc;
  279. }
  280. /*
  281. +
  282. + CFaxOutboundRoutingNode::OnShowContextHelp
  283. *
  284. * Purpose:
  285. * Overrides CSnapinNode::OnShowContextHelp.
  286. *
  287. * Arguments:
  288. *
  289. * Return:
  290. - OLE error code
  291. -
  292. */
  293. HRESULT CFaxOutboundRoutingNode::OnShowContextHelp(
  294. IDisplayHelp* pDisplayHelp, LPOLESTR helpFile)
  295. {
  296. return DisplayContextHelp(pDisplayHelp, helpFile, HLP_GROUPS);
  297. }