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.

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