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.

1569 lines
47 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. aggwrap.cpp
  7. Router aggregation wrappers.
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "infoi.h"
  12. /*---------------------------------------------------------------------------
  13. RouterInfoAggregationWrapper
  14. This class is provided to use in an aggregation.
  15. ---------------------------------------------------------------------------*/
  16. class RouterInfoAggregationWrapper :
  17. public IRouterInfo,
  18. public IRouterAdminAccess
  19. {
  20. public:
  21. RouterInfoAggregationWrapper(IRouterInfo *pInfo, IUnknown *punkOuter);
  22. virtual ~RouterInfoAggregationWrapper()
  23. { DEBUG_DECREMENT_INSTANCE_COUNTER(RouterInfoAggregationWrapper); };
  24. // override the QI, we will use the AddRef/Release implementation
  25. // in the CDataObject
  26. DeclareIUnknownMembers(IMPL)
  27. DeclareIRouterRefreshAccessMembers(IMPL)
  28. DeclareIRouterInfoMembers(IMPL)
  29. DeclareIRouterAdminAccessMembers(IMPL)
  30. IUnknown * GetNonDelegatingIUnknown() { return &m_ENonDelegatingIUnknown; }
  31. protected:
  32. LONG m_cRef;
  33. SPIRouterInfo m_spRouterInfo;
  34. DECLARE_AGGREGATION_NONDELEGATING_IUNKNOWN(RouterInfoAggregationWrapper)
  35. };
  36. IMPLEMENT_AGGREGATION_IUNKNOWN(RouterInfoAggregationWrapper)
  37. IMPLEMENT_AGGREGATION_NONDELEGATING_ADDREFRELEASE(RouterInfoAggregationWrapper, IRouterInfo)
  38. STDMETHODIMP RouterInfoAggregationWrapper::ENonDelegatingIUnknown::QueryInterface(REFIID riid, LPVOID *ppv)
  39. {
  40. InitPThis(RouterInfoAggregationWrapper, ENonDelegatingIUnknown);
  41. if (ppv == NULL)
  42. return E_INVALIDARG;
  43. *ppv = NULL;
  44. if (riid == IID_IUnknown)
  45. *ppv = (IUnknown *) this;
  46. else if (riid == IID_IRouterInfo)
  47. *ppv = (IRouterInfo *) pThis;
  48. else if (riid == IID_IRouterRefreshAccess)
  49. *ppv = (IRouterRefreshAccess *) pThis;
  50. else if (riid == IID_IRouterAdminAccess)
  51. *ppv = (IRouterAdminAccess *) pThis;
  52. else
  53. return E_NOINTERFACE;
  54. ((IUnknown *)*ppv)->AddRef();
  55. return hrOK;
  56. }
  57. DEBUG_DECLARE_INSTANCE_COUNTER(RouterInfoAggregationWrapper);
  58. RouterInfoAggregationWrapper::RouterInfoAggregationWrapper(IRouterInfo *pInfo, IUnknown *punkOuter)
  59. : m_cRef(1)
  60. {
  61. m_spRouterInfo.Set(pInfo);
  62. DEBUG_INCREMENT_INSTANCE_COUNTER(RouterInfoAggregationWrapper);
  63. if (punkOuter)
  64. m_pUnknownOuter = punkOuter;
  65. else
  66. m_pUnknownOuter = &m_ENonDelegatingIUnknown;
  67. }
  68. STDMETHODIMP_(DWORD) RouterInfoAggregationWrapper::GetFlags()
  69. {
  70. Assert(m_spRouterInfo);
  71. return m_spRouterInfo->GetFlags();
  72. }
  73. STDMETHODIMP RouterInfoAggregationWrapper::SetFlags(DWORD dwFlags)
  74. {
  75. Assert(m_spRouterInfo);
  76. return m_spRouterInfo->SetFlags(dwFlags);
  77. }
  78. HRESULT RouterInfoAggregationWrapper::Load(LPCOLESTR pszMachine,
  79. HANDLE hMachine)
  80. {
  81. Assert(m_spRouterInfo);
  82. return m_spRouterInfo->Load(pszMachine, hMachine);
  83. }
  84. HRESULT RouterInfoAggregationWrapper::Save(LPCOLESTR pszMachine,
  85. HANDLE hMachine )
  86. {
  87. Assert(m_spRouterInfo);
  88. return m_spRouterInfo->Save(pszMachine, hMachine);
  89. }
  90. HRESULT RouterInfoAggregationWrapper::Unload( )
  91. {
  92. Assert(m_spRouterInfo);
  93. return m_spRouterInfo->Unload();
  94. }
  95. HRESULT RouterInfoAggregationWrapper::Merge(IRouterInfo *pNewRouterInfo)
  96. {
  97. Assert(m_spRouterInfo);
  98. return m_spRouterInfo->Merge(pNewRouterInfo);
  99. }
  100. HRESULT RouterInfoAggregationWrapper::GetRefreshObject(IRouterRefresh **ppRefresh)
  101. {
  102. Assert(m_spRouterInfo);
  103. return m_spRouterInfo->GetRefreshObject(ppRefresh);
  104. }
  105. HRESULT RouterInfoAggregationWrapper::SetExternalRefreshObject(IRouterRefresh *pRefresh)
  106. {
  107. Assert(m_spRouterInfo);
  108. return m_spRouterInfo->SetExternalRefreshObject(pRefresh);
  109. }
  110. HRESULT RouterInfoAggregationWrapper::CopyCB(RouterCB *pRouterCB)
  111. {
  112. Assert(m_spRouterInfo);
  113. return m_spRouterInfo->CopyCB(pRouterCB);
  114. }
  115. LPCOLESTR RouterInfoAggregationWrapper::GetMachineName()
  116. {
  117. Assert(m_spRouterInfo);
  118. return m_spRouterInfo->GetMachineName();
  119. }
  120. HRESULT RouterInfoAggregationWrapper::SetMachineName(LPCOLESTR pszMachine)
  121. {
  122. Assert(m_spRouterInfo);
  123. return m_spRouterInfo->SetMachineName(pszMachine);
  124. }
  125. DWORD RouterInfoAggregationWrapper::GetRouterType()
  126. {
  127. Assert(m_spRouterInfo);
  128. return m_spRouterInfo->GetRouterType();
  129. }
  130. HRESULT RouterInfoAggregationWrapper::GetRouterVersionInfo(RouterVersionInfo *pVerInfo)
  131. {
  132. Assert(m_spRouterInfo);
  133. return m_spRouterInfo->GetRouterVersionInfo(pVerInfo);
  134. }
  135. HRESULT RouterInfoAggregationWrapper::EnumRtrMgrCB( IEnumRtrMgrCB **ppEnumRtrMgrCB)
  136. {
  137. Assert(m_spRouterInfo);
  138. return m_spRouterInfo->EnumRtrMgrCB(ppEnumRtrMgrCB);
  139. }
  140. HRESULT RouterInfoAggregationWrapper::EnumInterfaceCB( IEnumInterfaceCB **ppEnumInterfaceCB)
  141. {
  142. Assert(m_spRouterInfo);
  143. return m_spRouterInfo->EnumInterfaceCB(ppEnumInterfaceCB);
  144. }
  145. HRESULT RouterInfoAggregationWrapper::EnumRtrMgrProtocolCB( IEnumRtrMgrProtocolCB **ppEnumRmProtCB)
  146. {
  147. Assert(m_spRouterInfo);
  148. return m_spRouterInfo->EnumRtrMgrProtocolCB(ppEnumRmProtCB);
  149. }
  150. HRESULT RouterInfoAggregationWrapper::EnumRtrMgrInterfaceCB( IEnumRtrMgrInterfaceCB **ppEnumRmIfCB)
  151. {
  152. Assert(m_spRouterInfo);
  153. return m_spRouterInfo->EnumRtrMgrInterfaceCB(ppEnumRmIfCB);
  154. }
  155. HRESULT RouterInfoAggregationWrapper::EnumRtrMgrProtocolInterfaceCB( IEnumRtrMgrProtocolInterfaceCB **ppEnumRmProtIfCB)
  156. {
  157. Assert(m_spRouterInfo);
  158. return m_spRouterInfo->EnumRtrMgrProtocolInterfaceCB(ppEnumRmProtIfCB);
  159. }
  160. HRESULT RouterInfoAggregationWrapper::EnumRtrMgr( IEnumRtrMgrInfo **ppEnumRtrMgr)
  161. {
  162. Assert(m_spRouterInfo);
  163. return m_spRouterInfo->EnumRtrMgr(ppEnumRtrMgr);
  164. }
  165. HRESULT RouterInfoAggregationWrapper::FindRtrMgr( DWORD dwTransportId,
  166. IRtrMgrInfo **ppInfo)
  167. {
  168. Assert(m_spRouterInfo);
  169. return m_spRouterInfo->FindRtrMgr(dwTransportId, ppInfo);
  170. }
  171. HRESULT RouterInfoAggregationWrapper::AddRtrMgr( IRtrMgrInfo *pInfo,
  172. IInfoBase *pGlobalInfo,
  173. IInfoBase *pClientInfo)
  174. {
  175. Assert(m_spRouterInfo);
  176. return m_spRouterInfo->AddRtrMgr(pInfo, pGlobalInfo, pClientInfo);
  177. }
  178. HRESULT RouterInfoAggregationWrapper::DeleteRtrMgr( DWORD dwTransportId, BOOL fRemove)
  179. {
  180. Assert(m_spRouterInfo);
  181. return m_spRouterInfo->DeleteRtrMgr(dwTransportId, fRemove);
  182. }
  183. HRESULT RouterInfoAggregationWrapper::ReleaseRtrMgr( DWORD dwTransportId)
  184. {
  185. Assert(m_spRouterInfo);
  186. return m_spRouterInfo->ReleaseRtrMgr(dwTransportId);
  187. }
  188. HRESULT RouterInfoAggregationWrapper::EnumInterface( IEnumInterfaceInfo **ppEnumInterface)
  189. {
  190. Assert(m_spRouterInfo);
  191. return m_spRouterInfo->EnumInterface(ppEnumInterface);
  192. }
  193. HRESULT RouterInfoAggregationWrapper::FindInterface( LPCOLESTR pszInterface,
  194. IInterfaceInfo **ppInfo)
  195. {
  196. Assert(m_spRouterInfo);
  197. return m_spRouterInfo->FindInterface(pszInterface, ppInfo);
  198. }
  199. HRESULT RouterInfoAggregationWrapper::AddInterface( IInterfaceInfo *pInfo)
  200. {
  201. Assert(m_spRouterInfo);
  202. return m_spRouterInfo->AddInterface(pInfo);
  203. }
  204. HRESULT RouterInfoAggregationWrapper::DeleteInterface( LPCOLESTR pszInterface, BOOL fRemove)
  205. {
  206. Assert(m_spRouterInfo);
  207. return m_spRouterInfo->DeleteInterface(pszInterface, fRemove);
  208. }
  209. HRESULT RouterInfoAggregationWrapper::ReleaseInterface( LPCOLESTR pszInterface)
  210. {
  211. Assert(m_spRouterInfo);
  212. return m_spRouterInfo->ReleaseInterface(pszInterface);
  213. }
  214. HRESULT RouterInfoAggregationWrapper::RtrAdvise( IRtrAdviseSink *pRtrAdviseSink,
  215. LONG_PTR *pulConnection, LPARAM lUserParam)
  216. {
  217. Assert(m_spRouterInfo);
  218. return m_spRouterInfo->RtrAdvise(pRtrAdviseSink, pulConnection, lUserParam);
  219. }
  220. HRESULT RouterInfoAggregationWrapper::RtrNotify(DWORD dwChangeType, DWORD dwObjectType, LPARAM lParam)
  221. {
  222. Assert(m_spRouterInfo);
  223. return m_spRouterInfo->RtrNotify(dwChangeType, dwObjectType, lParam);
  224. }
  225. HRESULT RouterInfoAggregationWrapper::RtrUnadvise( LONG_PTR ulConnection)
  226. {
  227. Assert(m_spRouterInfo);
  228. return m_spRouterInfo->RtrUnadvise(ulConnection);
  229. }
  230. HRESULT RouterInfoAggregationWrapper::DoDisconnect()
  231. {
  232. Assert(m_spRouterInfo);
  233. return m_spRouterInfo->DoDisconnect();
  234. }
  235. HRESULT RouterInfoAggregationWrapper::AddWeakRef()
  236. {
  237. Panic0("Should not be calling AddWeakRef from the Data object!");
  238. return E_FAIL;
  239. }
  240. HRESULT RouterInfoAggregationWrapper::ReleaseWeakRef()
  241. {
  242. Panic0("Should not be calling ReleaseWeakRef from the Data object!");
  243. return E_FAIL;
  244. }
  245. HRESULT RouterInfoAggregationWrapper::Destruct()
  246. {
  247. Panic0("Should not be calling Destruct from the Data object!");
  248. return E_FAIL;
  249. }
  250. BOOL RouterInfoAggregationWrapper::IsAdminInfoSet()
  251. {
  252. Assert(m_spRouterInfo);
  253. SPIRouterAdminAccess spAdmin;
  254. spAdmin.HrQuery(m_spRouterInfo);
  255. Assert(spAdmin);
  256. return spAdmin->IsAdminInfoSet();
  257. }
  258. LPCOLESTR RouterInfoAggregationWrapper::GetUserName()
  259. {
  260. Assert(m_spRouterInfo);
  261. SPIRouterAdminAccess spAdmin;
  262. spAdmin.HrQuery(m_spRouterInfo);
  263. Assert(spAdmin);
  264. return spAdmin->GetUserName();
  265. }
  266. LPCOLESTR RouterInfoAggregationWrapper::GetDomainName()
  267. {
  268. Assert(m_spRouterInfo);
  269. SPIRouterAdminAccess spAdmin;
  270. spAdmin.HrQuery(m_spRouterInfo);
  271. Assert(spAdmin);
  272. return spAdmin->GetUserName();
  273. }
  274. HRESULT RouterInfoAggregationWrapper::GetUserPassword(BYTE *pByte,
  275. int *pcPassword)
  276. {
  277. Assert(m_spRouterInfo);
  278. SPIRouterAdminAccess spAdmin;
  279. spAdmin.HrQuery(m_spRouterInfo);
  280. Assert(spAdmin);
  281. return spAdmin->GetUserPassword(pByte, pcPassword);
  282. }
  283. HRESULT RouterInfoAggregationWrapper::SetInfo(LPCOLESTR pszName,
  284. LPCOLESTR pszDomain,
  285. BYTE *pPassword,
  286. int cPassword)
  287. {
  288. Assert(m_spRouterInfo);
  289. SPIRouterAdminAccess spAdmin;
  290. spAdmin.HrQuery(m_spRouterInfo);
  291. Assert(spAdmin);
  292. return spAdmin->SetInfo(pszName, pszDomain, pPassword,
  293. cPassword);
  294. }
  295. /*!--------------------------------------------------------------------------
  296. CreateRouterInfoAggregation
  297. Takes an existing IRouterInfo and aggregates that with the
  298. passed-in object. It returns a pointer to the non-delegating
  299. IUnknown on the IRouterInfo. This pointer is held by the
  300. controlling IUnknown.
  301. Author: KennT
  302. ---------------------------------------------------------------------------*/
  303. TFSCORE_API(HRESULT) CreateRouterInfoAggregation(IRouterInfo *pInfo,
  304. IUnknown *punk, IUnknown **ppNonDelegatingIUnknown)
  305. {
  306. RouterInfoAggregationWrapper * pAgg = NULL;
  307. HRESULT hr = hrOK;
  308. COM_PROTECT_TRY
  309. {
  310. pAgg = new RouterInfoAggregationWrapper(pInfo, punk);
  311. *ppNonDelegatingIUnknown = pAgg->GetNonDelegatingIUnknown();
  312. }
  313. COM_PROTECT_CATCH;
  314. return hr;
  315. }
  316. /*---------------------------------------------------------------------------
  317. InterfaceInfoAggregationWrapper implementation
  318. ---------------------------------------------------------------------------*/
  319. class InterfaceInfoAggregationWrapper :
  320. public IInterfaceInfo
  321. {
  322. public:
  323. InterfaceInfoAggregationWrapper(IInterfaceInfo *pInfo, IUnknown *punkOuter);
  324. virtual ~InterfaceInfoAggregationWrapper()
  325. { DEBUG_DECREMENT_INSTANCE_COUNTER(InterfaceInfoAggregationWrapper); };
  326. // override the QI, we will use the AddRef/Release implementation
  327. // in the CDataObject
  328. DeclareIUnknownMembers(IMPL)
  329. DeclareIInterfaceInfoMembers(IMPL)
  330. IUnknown * GetNonDelegatingIUnknown() { return &m_ENonDelegatingIUnknown; }
  331. protected:
  332. LONG m_cRef;
  333. SPIInterfaceInfo m_spInterfaceInfo;
  334. DECLARE_AGGREGATION_NONDELEGATING_IUNKNOWN(InterfaceInfoAggregationWrapper)
  335. };
  336. IMPLEMENT_AGGREGATION_IUNKNOWN(InterfaceInfoAggregationWrapper)
  337. IMPLEMENT_AGGREGATION_NONDELEGATING_IUNKNOWN(InterfaceInfoAggregationWrapper, IInterfaceInfo)
  338. DEBUG_DECLARE_INSTANCE_COUNTER(InterfaceInfoAggregationWrapper);
  339. InterfaceInfoAggregationWrapper::InterfaceInfoAggregationWrapper(IInterfaceInfo *pInfo, IUnknown *punkOuter)
  340. : m_cRef(1)
  341. {
  342. m_spInterfaceInfo.Set(pInfo);
  343. DEBUG_INCREMENT_INSTANCE_COUNTER(InterfaceInfoAggregationWrapper);
  344. if (punkOuter)
  345. m_pUnknownOuter = punkOuter;
  346. else
  347. m_pUnknownOuter = &m_ENonDelegatingIUnknown;
  348. }
  349. STDMETHODIMP_(DWORD) InterfaceInfoAggregationWrapper::GetFlags()
  350. {
  351. Assert(m_spInterfaceInfo);
  352. return m_spInterfaceInfo->GetFlags();
  353. }
  354. STDMETHODIMP InterfaceInfoAggregationWrapper::SetFlags(DWORD dwFlags)
  355. {
  356. Assert(m_spInterfaceInfo);
  357. return m_spInterfaceInfo->SetFlags(dwFlags);
  358. }
  359. STDMETHODIMP InterfaceInfoAggregationWrapper::Load(LPCOLESTR pszMachine,
  360. HANDLE hMachine,
  361. HANDLE hInterface)
  362. {
  363. Assert(m_spInterfaceInfo);
  364. return m_spInterfaceInfo->Load(pszMachine, hMachine, hInterface);
  365. }
  366. STDMETHODIMP InterfaceInfoAggregationWrapper::Save(LPCOLESTR pszMachine,
  367. HANDLE hMachine,
  368. HANDLE hInterface)
  369. {
  370. Assert(m_spInterfaceInfo);
  371. return m_spInterfaceInfo->Save(pszMachine, hMachine, hInterface);
  372. }
  373. STDMETHODIMP InterfaceInfoAggregationWrapper::Delete(LPCOLESTR pszMachine,
  374. HANDLE hMachine)
  375. {
  376. Assert(m_spInterfaceInfo);
  377. return m_spInterfaceInfo->Delete(pszMachine, hMachine);
  378. }
  379. STDMETHODIMP InterfaceInfoAggregationWrapper::Unload( )
  380. {
  381. Assert(m_spInterfaceInfo);
  382. return m_spInterfaceInfo->Unload();
  383. }
  384. STDMETHODIMP InterfaceInfoAggregationWrapper::Merge(IInterfaceInfo *pIf)
  385. {
  386. Assert(m_spInterfaceInfo);
  387. return m_spInterfaceInfo->Merge(pIf);
  388. }
  389. STDMETHODIMP_(LPCOLESTR) InterfaceInfoAggregationWrapper::GetId()
  390. {
  391. Assert(m_spInterfaceInfo);
  392. return m_spInterfaceInfo->GetId();
  393. }
  394. STDMETHODIMP_(DWORD) InterfaceInfoAggregationWrapper::GetInterfaceType()
  395. {
  396. Assert(m_spInterfaceInfo);
  397. return m_spInterfaceInfo->GetInterfaceType();
  398. }
  399. STDMETHODIMP_(LPCOLESTR) InterfaceInfoAggregationWrapper::GetDeviceName()
  400. {
  401. Assert(m_spInterfaceInfo);
  402. return m_spInterfaceInfo->GetDeviceName();
  403. }
  404. STDMETHODIMP_(LPCOLESTR) InterfaceInfoAggregationWrapper::GetTitle()
  405. {
  406. Assert(m_spInterfaceInfo);
  407. return m_spInterfaceInfo->GetTitle();
  408. }
  409. STDMETHODIMP InterfaceInfoAggregationWrapper::SetTitle( LPCOLESTR pszTitle)
  410. {
  411. Assert(m_spInterfaceInfo);
  412. return m_spInterfaceInfo->SetTitle(pszTitle);
  413. }
  414. STDMETHODIMP_(BOOL) InterfaceInfoAggregationWrapper::IsInterfaceEnabled()
  415. {
  416. Assert(m_spInterfaceInfo);
  417. return m_spInterfaceInfo->IsInterfaceEnabled();
  418. }
  419. STDMETHODIMP InterfaceInfoAggregationWrapper::SetInterfaceEnabledState( BOOL bEnabled)
  420. {
  421. Assert(m_spInterfaceInfo);
  422. return m_spInterfaceInfo->SetInterfaceEnabledState(bEnabled);
  423. }
  424. STDMETHODIMP InterfaceInfoAggregationWrapper::CopyCB(InterfaceCB *pifcb)
  425. {
  426. Assert(m_spInterfaceInfo);
  427. return m_spInterfaceInfo->CopyCB(pifcb);
  428. }
  429. STDMETHODIMP_(LPCOLESTR) InterfaceInfoAggregationWrapper::GetMachineName()
  430. {
  431. Assert(m_spInterfaceInfo);
  432. return m_spInterfaceInfo->GetMachineName();
  433. }
  434. STDMETHODIMP InterfaceInfoAggregationWrapper::SetMachineName( LPCOLESTR pszMachine)
  435. {
  436. Assert(m_spInterfaceInfo);
  437. return m_spInterfaceInfo->SetMachineName(pszMachine);
  438. }
  439. STDMETHODIMP InterfaceInfoAggregationWrapper::EnumRtrMgrInterface( IEnumRtrMgrInterfaceInfo **ppEnumRMIf)
  440. {
  441. Assert(m_spInterfaceInfo);
  442. return m_spInterfaceInfo->EnumRtrMgrInterface(ppEnumRMIf);
  443. }
  444. STDMETHODIMP InterfaceInfoAggregationWrapper::AddRtrMgrInterface( IRtrMgrInterfaceInfo *pInfo,
  445. IInfoBase *pInterfaceInfo)
  446. {
  447. Assert(m_spInterfaceInfo);
  448. return m_spInterfaceInfo->AddRtrMgrInterface(pInfo, pInterfaceInfo);
  449. }
  450. STDMETHODIMP InterfaceInfoAggregationWrapper::DeleteRtrMgrInterface( DWORD dwTransportId, BOOL fRemove)
  451. {
  452. Assert(m_spInterfaceInfo);
  453. return m_spInterfaceInfo->DeleteRtrMgrInterface(dwTransportId, fRemove);
  454. }
  455. STDMETHODIMP InterfaceInfoAggregationWrapper::ReleaseRtrMgrInterface( DWORD dwTransportId)
  456. {
  457. Assert(m_spInterfaceInfo);
  458. return m_spInterfaceInfo->ReleaseRtrMgrInterface(dwTransportId);
  459. }
  460. STDMETHODIMP InterfaceInfoAggregationWrapper::FindRtrMgrInterface( DWORD dwTransportId,
  461. IRtrMgrInterfaceInfo **ppInfo)
  462. {
  463. Assert(m_spInterfaceInfo);
  464. return m_spInterfaceInfo->FindRtrMgrInterface(dwTransportId, ppInfo);
  465. }
  466. STDMETHODIMP InterfaceInfoAggregationWrapper::RtrAdvise( IRtrAdviseSink *pRtrAdviseSink,
  467. LONG_PTR *pulConnection, LPARAM lUserParam)
  468. {
  469. Assert(m_spInterfaceInfo);
  470. return m_spInterfaceInfo->RtrAdvise(pRtrAdviseSink, pulConnection, lUserParam);
  471. }
  472. STDMETHODIMP InterfaceInfoAggregationWrapper::RtrNotify(DWORD dwChangeType,
  473. DWORD dwObjectType, LPARAM lParam)
  474. {
  475. Assert(m_spInterfaceInfo);
  476. return m_spInterfaceInfo->RtrNotify(dwChangeType, dwObjectType, lParam);
  477. }
  478. STDMETHODIMP InterfaceInfoAggregationWrapper::RtrUnadvise( LONG_PTR ulConnection)
  479. {
  480. Assert(m_spInterfaceInfo);
  481. return m_spInterfaceInfo->RtrUnadvise(ulConnection);
  482. }
  483. STDMETHODIMP InterfaceInfoAggregationWrapper::GetParentRouterInfo( IRouterInfo **ppRouterInfo)
  484. {
  485. Assert(m_spInterfaceInfo);
  486. return m_spInterfaceInfo->GetParentRouterInfo(ppRouterInfo);
  487. }
  488. STDMETHODIMP InterfaceInfoAggregationWrapper::SetParentRouterInfo( IRouterInfo *pRouterInfo)
  489. {
  490. Assert(m_spInterfaceInfo);
  491. return m_spInterfaceInfo->SetParentRouterInfo(pRouterInfo);
  492. }
  493. HRESULT InterfaceInfoAggregationWrapper::DoDisconnect()
  494. {
  495. Assert(m_spInterfaceInfo);
  496. return m_spInterfaceInfo->DoDisconnect();
  497. }
  498. HRESULT InterfaceInfoAggregationWrapper::AddWeakRef()
  499. {
  500. Panic0("Should not be calling AddWeakRef from the Data object!");
  501. return E_FAIL;
  502. }
  503. HRESULT InterfaceInfoAggregationWrapper::ReleaseWeakRef()
  504. {
  505. Panic0("Should not be calling ReleaseWeakRef from the Data object!");
  506. return E_FAIL;
  507. }
  508. HRESULT InterfaceInfoAggregationWrapper::Destruct()
  509. {
  510. Panic0("Should not be calling Destruct from the Data object!");
  511. return E_FAIL;
  512. }
  513. /*!--------------------------------------------------------------------------
  514. CreateInterfaceInfoAggregation
  515. Takes an existing IInterfaceInfo and aggregates that with the
  516. passed-in object. It returns a pointer to the non-delegating
  517. IUnknown on the IInterfaceInfo. This pointer is held by the
  518. controlling IUnknown.
  519. Author: KennT
  520. ---------------------------------------------------------------------------*/
  521. TFSCORE_API(HRESULT) CreateInterfaceInfoAggregation(IInterfaceInfo *pInfo,
  522. IUnknown *punk, IUnknown **ppNonDelegatingIUnknown)
  523. {
  524. InterfaceInfoAggregationWrapper * pAgg = NULL;
  525. HRESULT hr = hrOK;
  526. COM_PROTECT_TRY
  527. {
  528. pAgg = new InterfaceInfoAggregationWrapper(pInfo, punk);
  529. *ppNonDelegatingIUnknown = pAgg->GetNonDelegatingIUnknown();
  530. }
  531. COM_PROTECT_CATCH;
  532. return hr;
  533. }
  534. /*---------------------------------------------------------------------------
  535. RtrMgrInfoAggregationWrapper
  536. This class is provided to use in an aggregation.
  537. ---------------------------------------------------------------------------*/
  538. class RtrMgrInfoAggregationWrapper :
  539. public IRtrMgrInfo
  540. {
  541. public:
  542. RtrMgrInfoAggregationWrapper(IRtrMgrInfo *pInfo, IUnknown *punkOuter);
  543. virtual ~RtrMgrInfoAggregationWrapper()
  544. { DEBUG_DECREMENT_INSTANCE_COUNTER(RtrMgrInfoAggregationWrapper); };
  545. // override the QI, we will use the AddRef/Release implementation
  546. // in the CDataObject
  547. DeclareIUnknownMembers(IMPL)
  548. DeclareIRtrMgrInfoMembers(IMPL)
  549. IUnknown * GetNonDelegatingIUnknown() { return &m_ENonDelegatingIUnknown; }
  550. protected:
  551. LONG m_cRef;
  552. SPIRtrMgrInfo m_spRtrMgrInfo;
  553. DECLARE_AGGREGATION_NONDELEGATING_IUNKNOWN(RtrMgrInfoAggregationWrapper)
  554. };
  555. IMPLEMENT_AGGREGATION_IUNKNOWN(RtrMgrInfoAggregationWrapper)
  556. IMPLEMENT_AGGREGATION_NONDELEGATING_IUNKNOWN(RtrMgrInfoAggregationWrapper, IRtrMgrInfo)
  557. DEBUG_DECLARE_INSTANCE_COUNTER(RtrMgrInfoAggregationWrapper);
  558. RtrMgrInfoAggregationWrapper::RtrMgrInfoAggregationWrapper(IRtrMgrInfo *pInfo, IUnknown *punkOuter)
  559. : m_cRef(1)
  560. {
  561. m_spRtrMgrInfo.Set(pInfo);
  562. DEBUG_INCREMENT_INSTANCE_COUNTER(RtrMgrInfoAggregationWrapper);
  563. if (punkOuter)
  564. m_pUnknownOuter = punkOuter;
  565. else
  566. m_pUnknownOuter = &m_ENonDelegatingIUnknown;
  567. }
  568. STDMETHODIMP_(DWORD) RtrMgrInfoAggregationWrapper::GetFlags()
  569. {
  570. Assert(m_spRtrMgrInfo);
  571. return m_spRtrMgrInfo->GetFlags();
  572. }
  573. STDMETHODIMP RtrMgrInfoAggregationWrapper::SetFlags(DWORD dwFlags)
  574. {
  575. Assert(m_spRtrMgrInfo);
  576. return m_spRtrMgrInfo->SetFlags(dwFlags);
  577. }
  578. STDMETHODIMP RtrMgrInfoAggregationWrapper::Load(LPCOLESTR pszMachine,
  579. HANDLE hMachine,
  580. HANDLE hTransport)
  581. {
  582. Assert(m_spRtrMgrInfo);
  583. return m_spRtrMgrInfo->Load(pszMachine, hMachine, hTransport);
  584. }
  585. STDMETHODIMP RtrMgrInfoAggregationWrapper::Save(LPCOLESTR pszMachine,
  586. HANDLE hMachine,
  587. HANDLE hTransport,
  588. IInfoBase *pGlobal,
  589. IInfoBase *pClient,
  590. DWORD dwDeleteProtocolId)
  591. {
  592. Assert(m_spRtrMgrInfo);
  593. return m_spRtrMgrInfo->Save(pszMachine, hMachine, hTransport,
  594. pGlobal, pClient, dwDeleteProtocolId);
  595. }
  596. STDMETHODIMP RtrMgrInfoAggregationWrapper::Unload( )
  597. {
  598. Assert(m_spRtrMgrInfo);
  599. return m_spRtrMgrInfo->Unload();
  600. }
  601. STDMETHODIMP RtrMgrInfoAggregationWrapper::Delete(LPCOLESTR pszMachine,
  602. HANDLE hMachine)
  603. {
  604. Assert(m_spRtrMgrInfo);
  605. return m_spRtrMgrInfo->Delete(pszMachine, hMachine);
  606. }
  607. STDMETHODIMP RtrMgrInfoAggregationWrapper::Merge(IRtrMgrInfo *pNewRm)
  608. {
  609. Assert(m_spRtrMgrInfo);
  610. return m_spRtrMgrInfo->Merge(pNewRm);
  611. }
  612. STDMETHODIMP RtrMgrInfoAggregationWrapper::SetInfoBase(IInfoBase *pGlobal,
  613. IInfoBase *pClient)
  614. {
  615. Assert(m_spRtrMgrInfo);
  616. return m_spRtrMgrInfo->SetInfoBase(pGlobal, pClient);
  617. }
  618. STDMETHODIMP RtrMgrInfoAggregationWrapper::GetInfoBase(HANDLE hMachine,
  619. HANDLE hTransport, IInfoBase **ppGlobal, IInfoBase **ppClient)
  620. {
  621. Assert(m_spRtrMgrInfo);
  622. return m_spRtrMgrInfo->GetInfoBase(hMachine, hTransport, ppGlobal, ppClient);
  623. }
  624. STDMETHODIMP_(LPCOLESTR) RtrMgrInfoAggregationWrapper::GetId()
  625. {
  626. Assert(m_spRtrMgrInfo);
  627. return m_spRtrMgrInfo->GetId();
  628. }
  629. STDMETHODIMP RtrMgrInfoAggregationWrapper::SetId(LPCOLESTR pszId)
  630. {
  631. Assert(m_spRtrMgrInfo);
  632. return m_spRtrMgrInfo->SetId(pszId);
  633. }
  634. STDMETHODIMP_(DWORD) RtrMgrInfoAggregationWrapper::GetTransportId()
  635. {
  636. Assert(m_spRtrMgrInfo);
  637. return m_spRtrMgrInfo->GetTransportId();
  638. }
  639. STDMETHODIMP_(LPCOLESTR) RtrMgrInfoAggregationWrapper::GetTitle()
  640. {
  641. Assert(m_spRtrMgrInfo);
  642. return m_spRtrMgrInfo->GetTitle();
  643. }
  644. STDMETHODIMP RtrMgrInfoAggregationWrapper::CopyRtrMgrCB(RtrMgrCB *pRtrMgrCB)
  645. {
  646. Assert(m_spRtrMgrInfo);
  647. return m_spRtrMgrInfo->CopyRtrMgrCB(pRtrMgrCB);
  648. }
  649. LPCOLESTR RtrMgrInfoAggregationWrapper::GetMachineName()
  650. {
  651. Assert(m_spRtrMgrInfo);
  652. return m_spRtrMgrInfo->GetMachineName();
  653. }
  654. STDMETHODIMP RtrMgrInfoAggregationWrapper::EnumRtrMgrProtocol( IEnumRtrMgrProtocolInfo **ppEnumRtrMgrProtocol)
  655. {
  656. Assert(m_spRtrMgrInfo);
  657. return m_spRtrMgrInfo->EnumRtrMgrProtocol(ppEnumRtrMgrProtocol);
  658. }
  659. STDMETHODIMP RtrMgrInfoAggregationWrapper::FindRtrMgrProtocol(DWORD dwProtocolId,
  660. IRtrMgrProtocolInfo **ppInfo)
  661. {
  662. Assert(m_spRtrMgrInfo);
  663. return m_spRtrMgrInfo->FindRtrMgrProtocol(dwProtocolId, ppInfo);
  664. }
  665. STDMETHODIMP RtrMgrInfoAggregationWrapper::AddRtrMgrProtocol(IRtrMgrProtocolInfo *pInfo,
  666. IInfoBase *pGlobalInfo,
  667. IInfoBase *pClientInfo)
  668. {
  669. Assert(m_spRtrMgrInfo);
  670. return m_spRtrMgrInfo->AddRtrMgrProtocol(pInfo, pGlobalInfo, pClientInfo);
  671. }
  672. STDMETHODIMP RtrMgrInfoAggregationWrapper::SetParentRouterInfo(IRouterInfo *pRouterInfo)
  673. {
  674. Assert(m_spRtrMgrInfo);
  675. return m_spRtrMgrInfo->SetParentRouterInfo(pRouterInfo);
  676. }
  677. STDMETHODIMP RtrMgrInfoAggregationWrapper::GetParentRouterInfo(IRouterInfo **ppRouterInfo)
  678. {
  679. Assert(m_spRtrMgrInfo);
  680. return m_spRtrMgrInfo->GetParentRouterInfo(ppRouterInfo);
  681. }
  682. STDMETHODIMP RtrMgrInfoAggregationWrapper::DeleteRtrMgrProtocol( DWORD dwProtocolId, BOOL fRemove)
  683. {
  684. Assert(m_spRtrMgrInfo);
  685. return m_spRtrMgrInfo->DeleteRtrMgrProtocol(dwProtocolId, fRemove);
  686. }
  687. STDMETHODIMP RtrMgrInfoAggregationWrapper::ReleaseRtrMgrProtocol( DWORD dwProtocolId)
  688. {
  689. Assert(m_spRtrMgrInfo);
  690. return m_spRtrMgrInfo->ReleaseRtrMgrProtocol(dwProtocolId);
  691. }
  692. STDMETHODIMP RtrMgrInfoAggregationWrapper::RtrAdvise( IRtrAdviseSink *pRtrAdviseSink,
  693. LONG_PTR *pulConnection, LPARAM lUserParam)
  694. {
  695. Assert(m_spRtrMgrInfo);
  696. return m_spRtrMgrInfo->RtrAdvise(pRtrAdviseSink, pulConnection, lUserParam);
  697. }
  698. STDMETHODIMP RtrMgrInfoAggregationWrapper::RtrNotify(DWORD dwChangeType, DWORD dwObjectType, LPARAM lParam)
  699. {
  700. Assert(m_spRtrMgrInfo);
  701. return m_spRtrMgrInfo->RtrNotify(dwChangeType, dwObjectType, lParam);
  702. }
  703. STDMETHODIMP RtrMgrInfoAggregationWrapper::RtrUnadvise( LONG_PTR ulConnection)
  704. {
  705. Assert(m_spRtrMgrInfo);
  706. return m_spRtrMgrInfo->RtrUnadvise(ulConnection);
  707. }
  708. HRESULT RtrMgrInfoAggregationWrapper::DoDisconnect()
  709. {
  710. Assert(m_spRtrMgrInfo);
  711. return m_spRtrMgrInfo->DoDisconnect();
  712. }
  713. STDMETHODIMP RtrMgrInfoAggregationWrapper::AddWeakRef()
  714. {
  715. Panic0("Should not be calling AddWeakRef from the Data object!");
  716. return E_FAIL;
  717. }
  718. STDMETHODIMP RtrMgrInfoAggregationWrapper::ReleaseWeakRef()
  719. {
  720. Panic0("Should not be calling ReleaseWeakRef from the Data object!");
  721. return E_FAIL;
  722. }
  723. STDMETHODIMP RtrMgrInfoAggregationWrapper::Destruct()
  724. {
  725. Panic0("Should not be calling Destruct from the Data object!");
  726. return E_FAIL;
  727. }
  728. /*!--------------------------------------------------------------------------
  729. CreateRtrMgrInfoAggregation
  730. Takes an existing IRtrMgrInfo and aggregates that with the
  731. passed-in object. It returns a pointer to the non-delegating
  732. IUnknown on the IRtrMgrInfo. This pointer is held by the
  733. controlling IUnknown.
  734. Author: KennT
  735. ---------------------------------------------------------------------------*/
  736. TFSCORE_API(HRESULT) CreateRtrMgrInfoAggregation(IRtrMgrInfo *pInfo,
  737. IUnknown *punk, IUnknown **ppNonDelegatingIUnknown)
  738. {
  739. RtrMgrInfoAggregationWrapper * pAgg = NULL;
  740. HRESULT hr = hrOK;
  741. COM_PROTECT_TRY
  742. {
  743. pAgg = new RtrMgrInfoAggregationWrapper(pInfo, punk);
  744. *ppNonDelegatingIUnknown = pAgg->GetNonDelegatingIUnknown();
  745. }
  746. COM_PROTECT_CATCH;
  747. return hr;
  748. }
  749. /*---------------------------------------------------------------------------
  750. RtrMgrProtocolInfoAggregationWrapper
  751. This class is provided to use in an aggregation.
  752. ---------------------------------------------------------------------------*/
  753. class RtrMgrProtocolInfoAggregationWrapper :
  754. public IRtrMgrProtocolInfo
  755. {
  756. public:
  757. RtrMgrProtocolInfoAggregationWrapper(IRtrMgrProtocolInfo *pInfo, IUnknown *punkOuter);
  758. virtual ~RtrMgrProtocolInfoAggregationWrapper()
  759. { DEBUG_DECREMENT_INSTANCE_COUNTER(RtrMgrProtocolInfoAggregationWrapper); };
  760. // override the QI, we will use the AddRef/Release implementation
  761. // in the CDataObject
  762. DeclareIUnknownMembers(IMPL)
  763. DeclareIRtrMgrProtocolInfoMembers(IMPL)
  764. IUnknown * GetNonDelegatingIUnknown() { return &m_ENonDelegatingIUnknown; }
  765. protected:
  766. LONG m_cRef;
  767. SPIRtrMgrProtocolInfo m_spRtrMgrProtocolInfo;
  768. DECLARE_AGGREGATION_NONDELEGATING_IUNKNOWN(RtrMgrProtocolInfoAggregationWrapper)
  769. };
  770. IMPLEMENT_AGGREGATION_IUNKNOWN(RtrMgrProtocolInfoAggregationWrapper)
  771. IMPLEMENT_AGGREGATION_NONDELEGATING_IUNKNOWN(RtrMgrProtocolInfoAggregationWrapper, IRtrMgrProtocolInfo)
  772. DEBUG_DECLARE_INSTANCE_COUNTER(RtrMgrProtocolInfoAggregationWrapper);
  773. RtrMgrProtocolInfoAggregationWrapper::RtrMgrProtocolInfoAggregationWrapper(IRtrMgrProtocolInfo *pInfo, IUnknown *punkOuter)
  774. : m_cRef(1)
  775. {
  776. m_spRtrMgrProtocolInfo.Set(pInfo);
  777. DEBUG_INCREMENT_INSTANCE_COUNTER(RtrMgrProtocolInfoAggregationWrapper);
  778. if (punkOuter)
  779. m_pUnknownOuter = punkOuter;
  780. else
  781. m_pUnknownOuter = &m_ENonDelegatingIUnknown;
  782. }
  783. STDMETHODIMP_(DWORD) RtrMgrProtocolInfoAggregationWrapper::GetFlags()
  784. {
  785. Assert(m_spRtrMgrProtocolInfo);
  786. return m_spRtrMgrProtocolInfo->GetFlags();
  787. }
  788. STDMETHODIMP RtrMgrProtocolInfoAggregationWrapper::SetFlags(DWORD dwFlags)
  789. {
  790. Assert(m_spRtrMgrProtocolInfo);
  791. return m_spRtrMgrProtocolInfo->SetFlags(dwFlags);
  792. }
  793. STDMETHODIMP_(DWORD) RtrMgrProtocolInfoAggregationWrapper::GetProtocolId()
  794. {
  795. Assert(m_spRtrMgrProtocolInfo);
  796. return m_spRtrMgrProtocolInfo->GetProtocolId();
  797. }
  798. STDMETHODIMP_(DWORD) RtrMgrProtocolInfoAggregationWrapper::GetTransportId()
  799. {
  800. Assert(m_spRtrMgrProtocolInfo);
  801. return m_spRtrMgrProtocolInfo->GetTransportId();
  802. }
  803. STDMETHODIMP_(LPCOLESTR) RtrMgrProtocolInfoAggregationWrapper::GetTitle()
  804. {
  805. Assert(m_spRtrMgrProtocolInfo);
  806. return m_spRtrMgrProtocolInfo->GetTitle();
  807. }
  808. STDMETHODIMP RtrMgrProtocolInfoAggregationWrapper::CopyCB(RtrMgrProtocolCB *pRtrMgrProtCB)
  809. {
  810. Assert(m_spRtrMgrProtocolInfo);
  811. return m_spRtrMgrProtocolInfo->CopyCB(pRtrMgrProtCB);
  812. }
  813. STDMETHODIMP RtrMgrProtocolInfoAggregationWrapper::RtrAdvise( IRtrAdviseSink *pRtrAdviseSink,
  814. LONG_PTR *pulConnection, LPARAM lUserParam)
  815. {
  816. Assert(m_spRtrMgrProtocolInfo);
  817. return m_spRtrMgrProtocolInfo->RtrAdvise(pRtrAdviseSink, pulConnection, lUserParam);
  818. }
  819. STDMETHODIMP RtrMgrProtocolInfoAggregationWrapper::RtrNotify(DWORD dwChangeType, DWORD dwObjectType, LPARAM lParam)
  820. {
  821. Assert(m_spRtrMgrProtocolInfo);
  822. return m_spRtrMgrProtocolInfo->RtrNotify(dwChangeType, dwObjectType, lParam);
  823. }
  824. STDMETHODIMP RtrMgrProtocolInfoAggregationWrapper::RtrUnadvise( LONG_PTR ulConnection)
  825. {
  826. Assert(m_spRtrMgrProtocolInfo);
  827. return m_spRtrMgrProtocolInfo->RtrUnadvise(ulConnection);
  828. }
  829. STDMETHODIMP RtrMgrProtocolInfoAggregationWrapper::GetParentRtrMgrInfo(IRtrMgrInfo **ppRm)
  830. {
  831. Assert(m_spRtrMgrProtocolInfo);
  832. return m_spRtrMgrProtocolInfo->GetParentRtrMgrInfo(ppRm);
  833. }
  834. STDMETHODIMP RtrMgrProtocolInfoAggregationWrapper::SetParentRtrMgrInfo(IRtrMgrInfo *pRm)
  835. {
  836. Assert(m_spRtrMgrProtocolInfo);
  837. return m_spRtrMgrProtocolInfo->SetParentRtrMgrInfo(pRm);
  838. }
  839. HRESULT RtrMgrProtocolInfoAggregationWrapper::DoDisconnect()
  840. {
  841. Assert(m_spRtrMgrProtocolInfo);
  842. return m_spRtrMgrProtocolInfo->DoDisconnect();
  843. }
  844. STDMETHODIMP RtrMgrProtocolInfoAggregationWrapper::AddWeakRef()
  845. {
  846. Panic0("Should not be calling AddWeakRef from the Data object!");
  847. return E_FAIL;
  848. }
  849. STDMETHODIMP RtrMgrProtocolInfoAggregationWrapper::ReleaseWeakRef()
  850. {
  851. Panic0("Should not be calling ReleaseWeakRef from the Data object!");
  852. return E_FAIL;
  853. }
  854. STDMETHODIMP RtrMgrProtocolInfoAggregationWrapper::Destruct()
  855. {
  856. Panic0("Should not be calling Destruct from the Data object!");
  857. return E_FAIL;
  858. }
  859. /*!--------------------------------------------------------------------------
  860. CreateRtrMgrProtocolInfoAggregation
  861. Takes an existing IRtrMgrProtocolInfo and aggregates that with the
  862. passed-in object. It returns a pointer to the non-delegating
  863. IUnknown on the IRtrMgrProtocolInfo. This pointer is held by the
  864. controlling IUnknown.
  865. Author: KennT
  866. ---------------------------------------------------------------------------*/
  867. TFSCORE_API(HRESULT) CreateRtrMgrProtocolInfoAggregation(IRtrMgrProtocolInfo *pInfo,
  868. IUnknown *punk, IUnknown **ppNonDelegatingIUnknown)
  869. {
  870. RtrMgrProtocolInfoAggregationWrapper * pAgg = NULL;
  871. HRESULT hr = hrOK;
  872. COM_PROTECT_TRY
  873. {
  874. pAgg = new RtrMgrProtocolInfoAggregationWrapper(pInfo, punk);
  875. *ppNonDelegatingIUnknown = pAgg->GetNonDelegatingIUnknown();
  876. }
  877. COM_PROTECT_CATCH;
  878. return hr;
  879. }
  880. /*---------------------------------------------------------------------------
  881. RtrMgrInterfaceInfoAggregationWrapper
  882. This class is provided to use in an aggregation.
  883. ---------------------------------------------------------------------------*/
  884. class RtrMgrInterfaceInfoAggregationWrapper :
  885. public IRtrMgrInterfaceInfo
  886. {
  887. public:
  888. RtrMgrInterfaceInfoAggregationWrapper(IRtrMgrInterfaceInfo *pInfo, IUnknown *punkOuter);
  889. virtual ~RtrMgrInterfaceInfoAggregationWrapper()
  890. { DEBUG_DECREMENT_INSTANCE_COUNTER(RtrMgrInterfaceInfoAggregationWrapper); };
  891. // override the QI, we will use the AddRef/Release implementation
  892. // in the CDataObject
  893. DeclareIUnknownMembers(IMPL)
  894. DeclareIRtrMgrInterfaceInfoMembers(IMPL)
  895. IUnknown * GetNonDelegatingIUnknown() { return &m_ENonDelegatingIUnknown; }
  896. protected:
  897. LONG m_cRef;
  898. SPIRtrMgrInterfaceInfo m_spRtrMgrInterfaceInfo;
  899. DECLARE_AGGREGATION_NONDELEGATING_IUNKNOWN(RtrMgrInterfaceInfoAggregationWrapper)
  900. };
  901. IMPLEMENT_AGGREGATION_IUNKNOWN(RtrMgrInterfaceInfoAggregationWrapper)
  902. IMPLEMENT_AGGREGATION_NONDELEGATING_IUNKNOWN(RtrMgrInterfaceInfoAggregationWrapper, IRtrMgrInterfaceInfo)
  903. DEBUG_DECLARE_INSTANCE_COUNTER(RtrMgrInterfaceInfoAggregationWrapper);
  904. RtrMgrInterfaceInfoAggregationWrapper::RtrMgrInterfaceInfoAggregationWrapper(IRtrMgrInterfaceInfo *pInfo, IUnknown *punkOuter)
  905. : m_cRef(1)
  906. {
  907. m_spRtrMgrInterfaceInfo.Set(pInfo);
  908. DEBUG_INCREMENT_INSTANCE_COUNTER(RtrMgrInterfaceInfoAggregationWrapper);
  909. if (punkOuter)
  910. m_pUnknownOuter = punkOuter;
  911. else
  912. m_pUnknownOuter = &m_ENonDelegatingIUnknown;
  913. }
  914. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::Load(LPCOLESTR pszMachine,
  915. HANDLE hMachine,
  916. HANDLE hInterface,
  917. HANDLE hTransport)
  918. {
  919. Assert(m_spRtrMgrInterfaceInfo);
  920. return m_spRtrMgrInterfaceInfo->Load(pszMachine, hMachine, hInterface, hTransport);
  921. }
  922. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::Save(LPCOLESTR pszMachine,
  923. HANDLE hMachine,
  924. HANDLE hInterface,
  925. HANDLE hTransport,
  926. IInfoBase *pInterface,
  927. DWORD dwDeleteProtocolId)
  928. {
  929. Assert(m_spRtrMgrInterfaceInfo);
  930. return m_spRtrMgrInterfaceInfo->Save(pszMachine, hMachine, hInterface,
  931. hTransport, pInterface,
  932. dwDeleteProtocolId);
  933. }
  934. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::Unload( )
  935. {
  936. Assert(m_spRtrMgrInterfaceInfo);
  937. return m_spRtrMgrInterfaceInfo->Unload();
  938. }
  939. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::Delete(LPCOLESTR pszMachine,
  940. HANDLE hMachine,
  941. HANDLE hInterface)
  942. {
  943. Assert(m_spRtrMgrInterfaceInfo);
  944. return m_spRtrMgrInterfaceInfo->Delete(pszMachine, hMachine, hInterface);
  945. }
  946. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::SetInfo(DWORD dwSize,
  947. PBYTE pbData)
  948. {
  949. Assert(m_spRtrMgrInterfaceInfo);
  950. return m_spRtrMgrInterfaceInfo->SetInfo(dwSize, pbData);
  951. }
  952. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::GetInfoBase(HANDLE hMachine,
  953. HANDLE hInterface, HANDLE hTransport, IInfoBase **ppInterface)
  954. {
  955. Assert(m_spRtrMgrInterfaceInfo);
  956. return m_spRtrMgrInterfaceInfo->GetInfoBase(hMachine, hInterface, hTransport, ppInterface);
  957. }
  958. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::SetInfoBase(HANDLE hMachine,
  959. HANDLE hInterface, HANDLE hTransport, IInfoBase *pInterface)
  960. {
  961. Assert(m_spRtrMgrInterfaceInfo);
  962. return m_spRtrMgrInterfaceInfo->SetInfoBase(hMachine, hInterface, hTransport, pInterface);
  963. }
  964. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::Merge(IRtrMgrInterfaceInfo *pNewRmIf)
  965. {
  966. Assert(m_spRtrMgrInterfaceInfo);
  967. return m_spRtrMgrInterfaceInfo->Merge(pNewRmIf);
  968. }
  969. STDMETHODIMP_(LPCOLESTR) RtrMgrInterfaceInfoAggregationWrapper::GetId()
  970. {
  971. Assert(m_spRtrMgrInterfaceInfo);
  972. return m_spRtrMgrInterfaceInfo->GetId();
  973. }
  974. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::SetId(LPCOLESTR pszId)
  975. {
  976. Assert(m_spRtrMgrInterfaceInfo);
  977. return m_spRtrMgrInterfaceInfo->SetId(pszId);
  978. }
  979. STDMETHODIMP_(DWORD) RtrMgrInterfaceInfoAggregationWrapper::GetTransportId()
  980. {
  981. Assert(m_spRtrMgrInterfaceInfo);
  982. return m_spRtrMgrInterfaceInfo->GetTransportId();
  983. }
  984. STDMETHODIMP_(LPCOLESTR) RtrMgrInterfaceInfoAggregationWrapper::GetInterfaceId()
  985. {
  986. Assert(m_spRtrMgrInterfaceInfo);
  987. return m_spRtrMgrInterfaceInfo->GetInterfaceId();
  988. }
  989. STDMETHODIMP_(DWORD) RtrMgrInterfaceInfoAggregationWrapper::GetInterfaceType()
  990. {
  991. Assert(m_spRtrMgrInterfaceInfo);
  992. return m_spRtrMgrInterfaceInfo->GetInterfaceType();
  993. }
  994. STDMETHODIMP_(LPCOLESTR) RtrMgrInterfaceInfoAggregationWrapper::GetTitle()
  995. {
  996. Assert(m_spRtrMgrInterfaceInfo);
  997. return m_spRtrMgrInterfaceInfo->GetTitle();
  998. }
  999. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::SetTitle(LPCOLESTR pszTitle)
  1000. {
  1001. Assert(m_spRtrMgrInterfaceInfo);
  1002. return m_spRtrMgrInterfaceInfo->SetTitle(pszTitle);
  1003. }
  1004. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::CopyCB(RtrMgrInterfaceCB *pRtrMgrIfCB)
  1005. {
  1006. Assert(m_spRtrMgrInterfaceInfo);
  1007. return m_spRtrMgrInterfaceInfo->CopyCB(pRtrMgrIfCB);
  1008. }
  1009. STDMETHODIMP_(LPCOLESTR) RtrMgrInterfaceInfoAggregationWrapper::GetMachineName()
  1010. {
  1011. Assert(m_spRtrMgrInterfaceInfo);
  1012. return m_spRtrMgrInterfaceInfo->GetMachineName();
  1013. }
  1014. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::SetMachineName(LPCOLESTR pszMachineName)
  1015. {
  1016. Assert(m_spRtrMgrInterfaceInfo);
  1017. return m_spRtrMgrInterfaceInfo->SetMachineName(pszMachineName);
  1018. }
  1019. STDMETHODIMP_(DWORD) RtrMgrInterfaceInfoAggregationWrapper::GetFlags()
  1020. {
  1021. Assert(m_spRtrMgrInterfaceInfo);
  1022. return m_spRtrMgrInterfaceInfo->GetFlags();
  1023. }
  1024. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::SetFlags(DWORD dwFlags)
  1025. {
  1026. Assert(m_spRtrMgrInterfaceInfo);
  1027. return m_spRtrMgrInterfaceInfo->SetFlags(dwFlags);
  1028. }
  1029. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::EnumRtrMgrProtocolInterface( IEnumRtrMgrProtocolInterfaceInfo **ppEnumRmProtIf)
  1030. {
  1031. Assert(m_spRtrMgrInterfaceInfo);
  1032. return m_spRtrMgrInterfaceInfo->EnumRtrMgrProtocolInterface(ppEnumRmProtIf);
  1033. }
  1034. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::FindRtrMgrProtocolInterface(DWORD dwProtocolId,
  1035. IRtrMgrProtocolInterfaceInfo **ppInfo)
  1036. {
  1037. Assert(m_spRtrMgrInterfaceInfo);
  1038. return m_spRtrMgrInterfaceInfo->FindRtrMgrProtocolInterface(dwProtocolId, ppInfo);
  1039. }
  1040. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::AddRtrMgrProtocolInterface(IRtrMgrProtocolInterfaceInfo *pInfo,
  1041. IInfoBase *pInterfaceInfo)
  1042. {
  1043. Assert(m_spRtrMgrInterfaceInfo);
  1044. return m_spRtrMgrInterfaceInfo->AddRtrMgrProtocolInterface(pInfo, pInterfaceInfo);
  1045. }
  1046. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::DeleteRtrMgrProtocolInterface( DWORD dwProtocolId, BOOL fRemove)
  1047. {
  1048. Assert(m_spRtrMgrInterfaceInfo);
  1049. return m_spRtrMgrInterfaceInfo->DeleteRtrMgrProtocolInterface(dwProtocolId, fRemove);
  1050. }
  1051. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::ReleaseRtrMgrProtocolInterface( DWORD dwProtocolId)
  1052. {
  1053. Assert(m_spRtrMgrInterfaceInfo);
  1054. return m_spRtrMgrInterfaceInfo->ReleaseRtrMgrProtocolInterface(dwProtocolId);
  1055. }
  1056. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::SetParentInterfaceInfo(IInterfaceInfo *pInterfaceInfo)
  1057. {
  1058. Assert(m_spRtrMgrInterfaceInfo);
  1059. return m_spRtrMgrInterfaceInfo->SetParentInterfaceInfo(pInterfaceInfo);
  1060. }
  1061. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::GetParentInterfaceInfo(IInterfaceInfo **ppInterfaceInfo)
  1062. {
  1063. Assert(m_spRtrMgrInterfaceInfo);
  1064. return m_spRtrMgrInterfaceInfo->GetParentInterfaceInfo(ppInterfaceInfo);
  1065. }
  1066. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::RtrAdvise( IRtrAdviseSink *pRtrAdviseSink,
  1067. LONG_PTR *pulConnection, LPARAM lUserParam)
  1068. {
  1069. Assert(m_spRtrMgrInterfaceInfo);
  1070. return m_spRtrMgrInterfaceInfo->RtrAdvise(pRtrAdviseSink, pulConnection, lUserParam);
  1071. }
  1072. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::RtrNotify(DWORD dwChangeType, DWORD dwObjectType, LPARAM lParam)
  1073. {
  1074. Assert(m_spRtrMgrInterfaceInfo);
  1075. return m_spRtrMgrInterfaceInfo->RtrNotify(dwChangeType, dwObjectType, lParam);
  1076. }
  1077. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::RtrUnadvise( LONG_PTR ulConnection)
  1078. {
  1079. Assert(m_spRtrMgrInterfaceInfo);
  1080. return m_spRtrMgrInterfaceInfo->RtrUnadvise(ulConnection);
  1081. }
  1082. HRESULT RtrMgrInterfaceInfoAggregationWrapper::DoDisconnect()
  1083. {
  1084. Assert(m_spRtrMgrInterfaceInfo);
  1085. return m_spRtrMgrInterfaceInfo->DoDisconnect();
  1086. }
  1087. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::AddWeakRef()
  1088. {
  1089. Panic0("Should not be calling AddWeakRef from the Data object!");
  1090. return E_FAIL;
  1091. }
  1092. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::ReleaseWeakRef()
  1093. {
  1094. Panic0("Should not be calling ReleaseWeakRef from the Data object!");
  1095. return E_FAIL;
  1096. }
  1097. STDMETHODIMP RtrMgrInterfaceInfoAggregationWrapper::Destruct()
  1098. {
  1099. Panic0("Should not be calling Destruct from the Data object!");
  1100. return E_FAIL;
  1101. }
  1102. /*!--------------------------------------------------------------------------
  1103. CreateRtrMgrInterfaceInfoAggregation
  1104. Takes an existing IRtrMgrInterfaceInfo and aggregates that with the
  1105. passed-in object. It returns a pointer to the non-delegating
  1106. IUnknown on the IRtrMgrInterfaceInfo. This pointer is held by the
  1107. controlling IUnknown.
  1108. Author: KennT
  1109. ---------------------------------------------------------------------------*/
  1110. TFSCORE_API(HRESULT) CreateRtrMgrInterfaceInfoAggregation(IRtrMgrInterfaceInfo *pInfo,
  1111. IUnknown *punk, IUnknown **ppNonDelegatingIUnknown)
  1112. {
  1113. RtrMgrInterfaceInfoAggregationWrapper * pAgg = NULL;
  1114. HRESULT hr = hrOK;
  1115. COM_PROTECT_TRY
  1116. {
  1117. pAgg = new RtrMgrInterfaceInfoAggregationWrapper(pInfo, punk);
  1118. *ppNonDelegatingIUnknown = pAgg->GetNonDelegatingIUnknown();
  1119. }
  1120. COM_PROTECT_CATCH;
  1121. return hr;
  1122. }
  1123. /*---------------------------------------------------------------------------
  1124. RtrMgrProtocolInterfaceInfoAggregationWrapper
  1125. This class is provided to use in an aggregation.
  1126. ---------------------------------------------------------------------------*/
  1127. class RtrMgrProtocolInterfaceInfoAggregationWrapper :
  1128. public IRtrMgrProtocolInterfaceInfo
  1129. {
  1130. public:
  1131. RtrMgrProtocolInterfaceInfoAggregationWrapper(IRtrMgrProtocolInterfaceInfo *pInfo, IUnknown *punkOuter);
  1132. virtual ~RtrMgrProtocolInterfaceInfoAggregationWrapper()
  1133. { DEBUG_DECREMENT_INSTANCE_COUNTER(RtrMgrProtocolInterfaceInfoAggregationWrapper); };
  1134. // override the QI, we will use the AddRef/Release implementation
  1135. // in the CDataObject
  1136. DeclareIUnknownMembers(IMPL)
  1137. DeclareIRtrMgrProtocolInterfaceInfoMembers(IMPL)
  1138. IUnknown * GetNonDelegatingIUnknown() { return &m_ENonDelegatingIUnknown; }
  1139. protected:
  1140. LONG m_cRef;
  1141. SPIRtrMgrProtocolInterfaceInfo m_spRtrMgrProtocolInterfaceInfo;
  1142. DECLARE_AGGREGATION_NONDELEGATING_IUNKNOWN(RtrMgrProtocolInterfaceInfoAggregationWrapper)
  1143. };
  1144. IMPLEMENT_AGGREGATION_IUNKNOWN(RtrMgrProtocolInterfaceInfoAggregationWrapper)
  1145. IMPLEMENT_AGGREGATION_NONDELEGATING_IUNKNOWN(RtrMgrProtocolInterfaceInfoAggregationWrapper, IRtrMgrProtocolInterfaceInfo)
  1146. DEBUG_DECLARE_INSTANCE_COUNTER(RtrMgrProtocolInterfaceInfoAggregationWrapper);
  1147. RtrMgrProtocolInterfaceInfoAggregationWrapper::RtrMgrProtocolInterfaceInfoAggregationWrapper(IRtrMgrProtocolInterfaceInfo *pInfo, IUnknown *punkOuter)
  1148. : m_cRef(1)
  1149. {
  1150. m_spRtrMgrProtocolInterfaceInfo.Set(pInfo);
  1151. DEBUG_INCREMENT_INSTANCE_COUNTER(RtrMgrProtocolInterfaceInfoAggregationWrapper);
  1152. if (punkOuter)
  1153. m_pUnknownOuter = punkOuter;
  1154. else
  1155. m_pUnknownOuter = &m_ENonDelegatingIUnknown;
  1156. }
  1157. STDMETHODIMP_(DWORD) RtrMgrProtocolInterfaceInfoAggregationWrapper::GetFlags()
  1158. {
  1159. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1160. return m_spRtrMgrProtocolInterfaceInfo->GetFlags();
  1161. }
  1162. STDMETHODIMP RtrMgrProtocolInterfaceInfoAggregationWrapper::SetFlags(DWORD dwFlags)
  1163. {
  1164. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1165. return m_spRtrMgrProtocolInterfaceInfo->SetFlags(dwFlags);
  1166. }
  1167. STDMETHODIMP_(DWORD) RtrMgrProtocolInterfaceInfoAggregationWrapper::GetProtocolId()
  1168. {
  1169. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1170. return m_spRtrMgrProtocolInterfaceInfo->GetProtocolId();
  1171. }
  1172. STDMETHODIMP_(DWORD) RtrMgrProtocolInterfaceInfoAggregationWrapper::GetTransportId()
  1173. {
  1174. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1175. return m_spRtrMgrProtocolInterfaceInfo->GetTransportId();
  1176. }
  1177. STDMETHODIMP_(LPCOLESTR) RtrMgrProtocolInterfaceInfoAggregationWrapper::GetTitle()
  1178. {
  1179. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1180. return m_spRtrMgrProtocolInterfaceInfo->GetTitle();
  1181. }
  1182. STDMETHODIMP RtrMgrProtocolInterfaceInfoAggregationWrapper::SetTitle(LPCOLESTR pszTitle)
  1183. {
  1184. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1185. return m_spRtrMgrProtocolInterfaceInfo->SetTitle(pszTitle);
  1186. }
  1187. STDMETHODIMP_(LPCOLESTR) RtrMgrProtocolInterfaceInfoAggregationWrapper::GetInterfaceId()
  1188. {
  1189. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1190. return m_spRtrMgrProtocolInterfaceInfo->GetInterfaceId();
  1191. }
  1192. STDMETHODIMP_(DWORD) RtrMgrProtocolInterfaceInfoAggregationWrapper::GetInterfaceType()
  1193. {
  1194. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1195. return m_spRtrMgrProtocolInterfaceInfo->GetInterfaceType();
  1196. }
  1197. STDMETHODIMP RtrMgrProtocolInterfaceInfoAggregationWrapper::CopyCB(RtrMgrProtocolInterfaceCB *pRtrMgrProtIfCB)
  1198. {
  1199. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1200. return m_spRtrMgrProtocolInterfaceInfo->CopyCB(pRtrMgrProtIfCB);
  1201. }
  1202. STDMETHODIMP RtrMgrProtocolInterfaceInfoAggregationWrapper::RtrAdvise( IRtrAdviseSink *pRtrAdviseSink,
  1203. LONG_PTR *pulConnection, LPARAM lUserParam)
  1204. {
  1205. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1206. return m_spRtrMgrProtocolInterfaceInfo->RtrAdvise(pRtrAdviseSink, pulConnection, lUserParam);
  1207. }
  1208. STDMETHODIMP RtrMgrProtocolInterfaceInfoAggregationWrapper::RtrNotify(DWORD dwChangeType, DWORD dwObjectType, LPARAM lParam)
  1209. {
  1210. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1211. return m_spRtrMgrProtocolInterfaceInfo->RtrNotify(dwChangeType, dwObjectType, lParam);
  1212. }
  1213. STDMETHODIMP RtrMgrProtocolInterfaceInfoAggregationWrapper::RtrUnadvise( LONG_PTR ulConnection)
  1214. {
  1215. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1216. return m_spRtrMgrProtocolInterfaceInfo->RtrUnadvise(ulConnection);
  1217. }
  1218. STDMETHODIMP RtrMgrProtocolInterfaceInfoAggregationWrapper::GetParentRtrMgrInterfaceInfo(IRtrMgrInterfaceInfo **ppRm)
  1219. {
  1220. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1221. return m_spRtrMgrProtocolInterfaceInfo->GetParentRtrMgrInterfaceInfo(ppRm);
  1222. }
  1223. STDMETHODIMP RtrMgrProtocolInterfaceInfoAggregationWrapper::SetParentRtrMgrInterfaceInfo(IRtrMgrInterfaceInfo *pRm)
  1224. {
  1225. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1226. return m_spRtrMgrProtocolInterfaceInfo->SetParentRtrMgrInterfaceInfo(pRm);
  1227. }
  1228. HRESULT RtrMgrProtocolInterfaceInfoAggregationWrapper::DoDisconnect()
  1229. {
  1230. Assert(m_spRtrMgrProtocolInterfaceInfo);
  1231. return m_spRtrMgrProtocolInterfaceInfo->DoDisconnect();
  1232. }
  1233. STDMETHODIMP RtrMgrProtocolInterfaceInfoAggregationWrapper::AddWeakRef()
  1234. {
  1235. Panic0("Should not be calling AddWeakRef from the Data object!");
  1236. return E_FAIL;
  1237. }
  1238. STDMETHODIMP RtrMgrProtocolInterfaceInfoAggregationWrapper::ReleaseWeakRef()
  1239. {
  1240. Panic0("Should not be calling ReleaseWeakRef from the Data object!");
  1241. return E_FAIL;
  1242. }
  1243. STDMETHODIMP RtrMgrProtocolInterfaceInfoAggregationWrapper::Destruct()
  1244. {
  1245. Panic0("Should not be calling Destruct from the Data object!");
  1246. return E_FAIL;
  1247. }
  1248. /*!--------------------------------------------------------------------------
  1249. CreateRtrMgrProtocolInterfaceInfoAggregation
  1250. Takes an existing IRtrMgrProtocolInterfaceInfo and aggregates that with the
  1251. passed-in object. It returns a pointer to the non-delegating
  1252. IUnknown on the IRtrMgrProtocolInterfaceInfo. This pointer is held by the
  1253. controlling IUnknown.
  1254. Author: KennT
  1255. ---------------------------------------------------------------------------*/
  1256. TFSCORE_API(HRESULT) CreateRtrMgrProtocolInterfaceInfoAggregation(IRtrMgrProtocolInterfaceInfo *pInfo,
  1257. IUnknown *punk, IUnknown **ppNonDelegatingIUnknown)
  1258. {
  1259. RtrMgrProtocolInterfaceInfoAggregationWrapper * pAgg = NULL;
  1260. HRESULT hr = hrOK;
  1261. COM_PROTECT_TRY
  1262. {
  1263. pAgg = new RtrMgrProtocolInterfaceInfoAggregationWrapper(pInfo, punk);
  1264. *ppNonDelegatingIUnknown = pAgg->GetNonDelegatingIUnknown();
  1265. }
  1266. COM_PROTECT_CATCH;
  1267. return hr;
  1268. }