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.

183 lines
4.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998.
  5. //
  6. // File: ac_sink.cpp
  7. //
  8. // Contents: Home Networking Auto Config Sink object code.
  9. //
  10. // Author: jeffsp 9/27/00
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "pch.h"
  14. #pragma hdrstop
  15. #ifdef PROVIDE_AUTO_CONFIG_SERVICES
  16. #include "ac_sink.h"
  17. #include "ac_CTrayUi.h"
  18. HRESULT STDMETHODCALLTYPE CAutoConfigUISink::DisplayHomeNetWizardHint()
  19. {
  20. HRESULT hr;
  21. hr = ac_CreateHnAcTrayUIWindow();
  22. return S_OK;
  23. }
  24. void ac_CreateHomeNetAutoConfigSink()
  25. {
  26. HRESULT hr = S_OK;
  27. DWORD mTmp_dwAutoAdviseCookie; // HACKHACK
  28. IHomeNetAutoConfigService *pI = NULL;
  29. IConnectionPointContainer *pContainer = NULL;
  30. IConnectionPoint *pIMyConnPoint = NULL;
  31. IAutoConfigUISink *pSink = NULL;
  32. CAutoConfigUISink *pObj = NULL;
  33. hr = CoCreateInstance( CLSID_HomeNetAutoConfigService, NULL, CLSCTX_ALL, IID_IHomeNetAutoConfigService, (void **)&pI );
  34. if( !SUCCEEDED(hr) ){
  35. // this->SetDlgItemText(IDC_EDIT2, "CoCreateInstance Failed!");
  36. goto done;
  37. }
  38. if( pI == NULL ){
  39. // this->SetDlgItemText(IDC_EDIT2, "pI NULL!");
  40. goto done;
  41. }
  42. hr = pI->QueryInterface( IID_IConnectionPointContainer, (void **)&pContainer );
  43. if( !SUCCEEDED(hr) ){
  44. // this->SetDlgItemText(IDC_EDIT2, "QI for container fialed!");
  45. goto done;
  46. }
  47. hr = pContainer->FindConnectionPoint(IID_IAutoConfigUISink, &pIMyConnPoint);
  48. pContainer->Release();
  49. pContainer = NULL;
  50. if( !SUCCEEDED(hr) ){
  51. // this->SetDlgItemText(IDC_EDIT2, "Find connection point failed!");
  52. goto done;
  53. }
  54. // this->SetDlgItemText(IDC_EDIT2, "Looks Good");
  55. pObj = new CComObject <CAutoConfigUISink>;
  56. if( !pObj ){
  57. // this->SetDlgItemText(IDC_EDIT2, "New failed" );
  58. goto done;
  59. }
  60. // pObj->Init(this);
  61. hr = pObj->QueryInterface(IID_IAutoConfigUISink, (void **)&pSink);
  62. if( !SUCCEEDED(hr) ){
  63. // this->SetDlgItemText(IDC_EDIT2, "QI for IID_IAutoConfigUISink failed" );
  64. delete pObj;
  65. goto done;
  66. }
  67. hr = pIMyConnPoint->Advise(pSink, &mTmp_dwAutoAdviseCookie );
  68. if( SUCCEEDED(hr)){
  69. // this->SetDlgItemText(IDC_EDIT2, "Advise Succeeded" );
  70. }else{
  71. // this->SetDlgItemText(IDC_EDIT2, "Advise Failed" );
  72. pSink->Release();
  73. }
  74. return;
  75. done:
  76. if( pContainer ){
  77. pContainer->Release();
  78. }
  79. if( pIMyConnPoint ){
  80. pIMyConnPoint->Release();
  81. }
  82. if( pI ){
  83. pI->Release();
  84. }
  85. return;
  86. }
  87. void ac_DestroyHomeNetAutoConfigSink(void)
  88. {
  89. HRESULT hr;
  90. IHomeNetAutoConfigService *pI = NULL;
  91. IConnectionPointContainer *pContainer = NULL;
  92. IConnectionPoint *pIMyConnPoint = NULL;
  93. IAutoConfigUISink *pSink = NULL;
  94. CAutoConfigUISink *pObj = NULL;
  95. hr = CoCreateInstance( CLSID_HomeNetAutoConfigService, NULL, CLSCTX_ALL, IID_IHomeNetAutoConfigService, (void **)&pI );
  96. if( !SUCCEEDED(hr) ){
  97. // this->SetDlgItemText(IDC_EDIT2, "CoCreateInstance Failed!");
  98. return;
  99. }
  100. if( pI == NULL ){
  101. // this->SetDlgItemText(IDC_EDIT2, "pI NULL!");
  102. return;
  103. }
  104. hr = pI->QueryInterface( IID_IConnectionPointContainer, (void **)&pContainer );
  105. if( !SUCCEEDED(hr) ){
  106. // this->SetDlgItemText(IDC_EDIT2, "QI for container fialed!");
  107. goto done;
  108. }
  109. hr = pContainer->FindConnectionPoint(IID_IAutoConfigUISink, &pIMyConnPoint);
  110. pContainer->Release();
  111. pContainer = NULL;
  112. if( !SUCCEEDED(hr) ){
  113. // this->SetDlgItemText(IDC_EDIT2, "Find connection point failed!");
  114. goto done;
  115. }
  116. // this->SetDlgItemText(IDC_EDIT2, "Looks Good");
  117. // HACKHACK hr = pIMyConnPoint->Unadvise(m_dwAutoAdviseCookie );
  118. // HACKHACK hr = pIMyConnPoint->Unadvise(m_dwAutoAdviseCookie );
  119. // HACKHACK hr = pIMyConnPoint->Unadvise(m_dwAutoAdviseCookie );
  120. // HACKHACK hr = pIMyConnPoint->Unadvise(m_dwAutoAdviseCookie );
  121. // HACKHACK hr = pIMyConnPoint->Unadvise(m_dwAutoAdviseCookie );
  122. // HACKHACK hr = pIMyConnPoint->Unadvise(m_dwAutoAdviseCookie );
  123. // HACKHACK hr = pIMyConnPoint->Unadvise(m_dwAutoAdviseCookie );
  124. // HACKHACK hr = pIMyConnPoint->Unadvise(m_dwAutoAdviseCookie );
  125. if( SUCCEEDED(hr)){
  126. // this->SetDlgItemText(IDC_EDIT2, "Unadvise Succeeded" );
  127. }else{
  128. // this->SetDlgItemText(IDC_EDIT2, "Unadvise Failed" );
  129. pSink->Release();
  130. }
  131. return;
  132. done:
  133. if( pContainer ){
  134. pContainer->Release();
  135. }
  136. if( pIMyConnPoint ){
  137. pIMyConnPoint->Release();
  138. }
  139. if( pI ){
  140. pI->Release();
  141. }
  142. return;
  143. }
  144. #endif //#ifdef PROVIDE_AUTO_CONFIG_SERVICES