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.

208 lines
5.7 KiB

  1. //**********************************************************************
  2. // File name: connect.cpp
  3. //
  4. // Implementation of connection point sink objects
  5. //
  6. // Functions:
  7. //
  8. // Copyright (c) 1992 - 1998 Microsoft Corporation. All rights reserved.
  9. //**********************************************************************
  10. #include "pre.h"
  11. #include "icwextsn.h"
  12. /*
  13. * CRefDialEvent::CRefDialEvent
  14. * CRefDialEvent::~CRefDialEvent
  15. *
  16. * Parameters (Constructor):
  17. * pSite PCSite of the site we're in.
  18. * pUnkOuter LPUNKNOWN to which we delegate.
  19. */
  20. CRefDialEvent::CRefDialEvent( HWND hWnd )
  21. {
  22. m_hWnd = hWnd;
  23. m_cRef = 0;
  24. }
  25. CRefDialEvent::~CRefDialEvent( void )
  26. {
  27. assert( m_cRef == 0 );
  28. }
  29. /*
  30. * CRefDialEvent::QueryInterface
  31. * CRefDialEvent::AddRef
  32. * CRefDialEvent::Release
  33. *
  34. * Purpose:
  35. * IUnknown members for CRefDialEvent object.
  36. */
  37. STDMETHODIMP CRefDialEvent::QueryInterface( REFIID riid, void **ppv )
  38. {
  39. *ppv = NULL;
  40. if ( IID_IDispatch == riid || DIID__RefDialEvents == riid )
  41. {
  42. *ppv = this;
  43. }
  44. if ( NULL != *ppv )
  45. {
  46. ((LPUNKNOWN)*ppv)->AddRef();
  47. return NOERROR;
  48. }
  49. return E_NOINTERFACE;
  50. }
  51. STDMETHODIMP_(ULONG) CRefDialEvent::AddRef(void)
  52. {
  53. return ++m_cRef;
  54. }
  55. STDMETHODIMP_(ULONG) CRefDialEvent::Release(void)
  56. {
  57. return --m_cRef;
  58. }
  59. //IDispatch
  60. STDMETHODIMP CRefDialEvent::GetTypeInfoCount(UINT* /*pctinfo*/)
  61. {
  62. return E_NOTIMPL;
  63. }
  64. STDMETHODIMP CRefDialEvent::GetTypeInfo(/* [in] */ UINT /*iTInfo*/,
  65. /* [in] */ LCID /*lcid*/,
  66. /* [out] */ ITypeInfo** /*ppTInfo*/)
  67. {
  68. return E_NOTIMPL;
  69. }
  70. STDMETHODIMP CRefDialEvent::GetIDsOfNames(
  71. /* [in] */ REFIID riid,
  72. /* [size_is][in] */ OLECHAR** rgszNames,
  73. /* [in] */ UINT cNames,
  74. /* [in] */ LCID lcid,
  75. /* [size_is][out] */ DISPID* rgDispId)
  76. {
  77. HRESULT hr = ResultFromScode(DISP_E_UNKNOWNNAME);
  78. return hr;
  79. }
  80. STDMETHODIMP CRefDialEvent::Invoke(
  81. /* [in] */ DISPID dispIdMember,
  82. /* [in] */ REFIID /*riid*/,
  83. /* [in] */ LCID /*lcid*/,
  84. /* [in] */ WORD wFlags,
  85. /* [out][in] */ DISPPARAMS* pDispParams,
  86. /* [out] */ VARIANT* pVarResult,
  87. /* [out] */ EXCEPINFO* /*pExcepInfo*/,
  88. /* [out] */ UINT* puArgErr)
  89. {
  90. switch(dispIdMember)
  91. {
  92. case DISPID_RasDialStatus:
  93. {
  94. BSTR bstrDialStatus = NULL;
  95. // Get the Status Text
  96. if (gpWizardState->iRedialCount > 0)
  97. gpWizardState->pRefDial->put_Redial(TRUE);
  98. else
  99. gpWizardState->pRefDial->put_Redial(FALSE);
  100. gpWizardState->pRefDial->get_DialStatusString(&bstrDialStatus);
  101. SetWindowText(GetDlgItem(m_hWnd, IDC_REFSERV_DIALSTATUS), W2A(bstrDialStatus));
  102. SysFreeString(bstrDialStatus);
  103. break;
  104. }
  105. case DISPID_DownloadProgress:
  106. {
  107. long lNewPos;
  108. if (pDispParams)
  109. {
  110. lNewPos = pDispParams->rgvarg[0].lVal;
  111. if (!gpWizardState->bStartRefServDownload)
  112. {
  113. BSTR bstrDialStatus = NULL;
  114. gpWizardState->pRefDial->get_DialStatusString(&bstrDialStatus);
  115. SetWindowText(GetDlgItem(m_hWnd, IDC_REFSERV_DIALSTATUS), W2A(bstrDialStatus));
  116. SysFreeString(bstrDialStatus);
  117. }
  118. gpWizardState->bStartRefServDownload = TRUE;
  119. // Set the Progress Position
  120. SendDlgItemMessage(m_hWnd, IDC_REFSERV_DIALPROGRESS, PBM_SETPOS, (WORD)lNewPos, 0l);
  121. }
  122. break;
  123. }
  124. case DISPID_DownloadComplete:
  125. {
  126. ASSERT(pDispParams);
  127. if(gpWizardState->lRefDialTerminateStatus != ERROR_CANCELLED)
  128. {
  129. if ((gpWizardState->lRefDialTerminateStatus = pDispParams->rgvarg[0].lVal) == ERROR_SUCCESS)
  130. {
  131. gpWizardState->bDoneRefServDownload = TRUE;
  132. BSTR bstrDialStatus = NULL;
  133. gpWizardState->pRefDial->get_DialStatusString(&bstrDialStatus);
  134. SetWindowText(GetDlgItem(m_hWnd, IDC_REFSERV_DIALSTATUS), W2A(bstrDialStatus));
  135. SysFreeString(bstrDialStatus);
  136. }
  137. // Hangup
  138. gpWizardState->pRefDial->DoHangup();
  139. PropSheet_PressButton(GetParent(m_hWnd),PSBTN_NEXT);
  140. }
  141. break;
  142. }
  143. case DISPID_RasConnectComplete:
  144. {
  145. BOOL bRetVal;
  146. if(gpWizardState->lRefDialTerminateStatus != ERROR_CANCELLED)
  147. {
  148. if (pDispParams && pDispParams->rgvarg[0].bVal)
  149. {
  150. // Show the progress bar
  151. ShowWindow(GetDlgItem(m_hWnd, IDC_REFSERV_DIALPROGRESS), SW_SHOW);
  152. gpWizardState->bDoneRefServRAS = TRUE;
  153. // Start the Offer Download
  154. gpWizardState->pRefDial->DoOfferDownload(&bRetVal);
  155. }
  156. else
  157. {
  158. // Simulate the press of the NEXT button
  159. gpWizardState->pRefDial->DoHangup();
  160. PropSheet_PressButton(GetParent(m_hWnd),PSBTN_NEXT);
  161. }
  162. }
  163. break;
  164. }
  165. }
  166. return S_OK;
  167. }