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.

203 lines
4.8 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Wrapper.cpp
  5. Abstract:
  6. This file contains the implementation of the COM wrapper classes,
  7. used for interfacing with the Custom Providers.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 04/25/2000
  10. created
  11. ******************************************************************************/
  12. #include "stdafx.h"
  13. ////////////////////////////////////////////////////////////////////////////////
  14. MPCServerCOMWrapper::MPCServerCOMWrapper( /*[in]*/ MPCServer* mpcsServer )
  15. {
  16. m_mpcsServer = mpcsServer; // MPCServer* m_mpcsServer;
  17. }
  18. MPCServerCOMWrapper::~MPCServerCOMWrapper()
  19. {
  20. }
  21. STDMETHODIMP MPCServerCOMWrapper::GetRequestVariable( /*[in]*/ BSTR bstrName, /*[out]*/ BSTR *pbstrVal )
  22. {
  23. __ULT_FUNC_ENTRY( "MPCServerCOMWrapper::GetRequestVariable" );
  24. USES_CONVERSION;
  25. HRESULT hr;
  26. MPC::wstring szValue;
  27. __MPC_PARAMCHECK_BEGIN(hr)
  28. __MPC_PARAMCHECK_STRING_NOT_EMPTY(bstrName);
  29. __MPC_PARAMCHECK_POINTER_AND_SET(pbstrVal,NULL);
  30. __MPC_PARAMCHECK_END();
  31. __MPC_EXIT_IF_METHOD_FAILS(hr, m_mpcsServer->m_hcCallback->GetServerVariable( W2A( bstrName ), szValue ));
  32. hr = MPC::GetBSTR( szValue.c_str(), pbstrVal );
  33. __ULT_FUNC_CLEANUP;
  34. __ULT_FUNC_EXIT(hr);
  35. }
  36. STDMETHODIMP MPCServerCOMWrapper::AbortTransfer()
  37. {
  38. __ULT_FUNC_ENTRY( "MPCServerCOMWrapper::AbortTransfer" );
  39. m_mpcsServer->SetResponse( UploadLibrary::UL_RESPONSE_DENIED );
  40. m_mpcsServer->m_fTerminated = true;
  41. __ULT_FUNC_EXIT(S_OK);
  42. }
  43. STDMETHODIMP MPCServerCOMWrapper::CompleteTransfer( /*[in]*/ IStream* data )
  44. {
  45. __ULT_FUNC_ENTRY( "MPCServerCOMWrapper::CompleteTransfer" );
  46. HRESULT hr;
  47. __MPC_EXIT_IF_METHOD_FAILS(hr, m_mpcsServer->CustomProvider_SetResponse( data ));
  48. m_mpcsServer->m_fTerminated = true;
  49. hr = S_OK;
  50. __ULT_FUNC_CLEANUP;
  51. __ULT_FUNC_EXIT(hr);
  52. }
  53. ////////////////////////////////////////////////////////////////////////////////
  54. MPCSessionCOMWrapper::MPCSessionCOMWrapper( /*[in]*/ MPCSession* mpcsSession )
  55. {
  56. m_mpcsSession = mpcsSession; // MPCSession* m_mpcsSession;
  57. }
  58. MPCSessionCOMWrapper::~MPCSessionCOMWrapper()
  59. {
  60. }
  61. ////////////////////
  62. STDMETHODIMP MPCSessionCOMWrapper::get_Client( /*[out]*/ BSTR *pVal )
  63. {
  64. CComBSTR tmp( m_mpcsSession->GetClient()->GetServer()->m_crClientRequest.sigClient.guidMachineID );
  65. return MPC::GetBSTR( tmp, pVal );
  66. }
  67. STDMETHODIMP MPCSessionCOMWrapper::get_Command( /*[out]*/ DWORD *pVal )
  68. {
  69. if(pVal == NULL) return E_POINTER;
  70. *pVal = m_mpcsSession->GetClient()->GetServer()->m_crClientRequest.dwCommand;
  71. return S_OK;
  72. }
  73. STDMETHODIMP MPCSessionCOMWrapper::get_ProviderID( /*[out]*/ BSTR *pVal )
  74. {
  75. return MPC::GetBSTR( m_mpcsSession->m_szProviderID.c_str(), pVal );
  76. }
  77. STDMETHODIMP MPCSessionCOMWrapper::get_Username( /*[out]*/ BSTR *pVal )
  78. {
  79. return MPC::GetBSTR( m_mpcsSession->m_szUsername.c_str(), pVal );
  80. }
  81. STDMETHODIMP MPCSessionCOMWrapper::get_JobID( /*[out]*/ BSTR *pVal )
  82. {
  83. return MPC::GetBSTR( m_mpcsSession->m_szJobID.c_str(), pVal );
  84. }
  85. STDMETHODIMP MPCSessionCOMWrapper::get_SizeAvailable( /*[out]*/ DWORD *pVal )
  86. {
  87. if(pVal == NULL) return E_POINTER;
  88. *pVal = m_mpcsSession->m_dwCurrentSize;
  89. return S_OK;
  90. }
  91. STDMETHODIMP MPCSessionCOMWrapper::get_SizeTotal( /*[out]*/ DWORD *pVal )
  92. {
  93. if(pVal == NULL) return E_POINTER;
  94. *pVal = m_mpcsSession->m_dwTotalSize;
  95. return S_OK;
  96. }
  97. STDMETHODIMP MPCSessionCOMWrapper::get_SizeOriginal( /*[out]*/ DWORD *pVal )
  98. {
  99. if(pVal == NULL) return E_POINTER;
  100. *pVal = m_mpcsSession->m_dwOriginalSize;
  101. return S_OK;
  102. }
  103. STDMETHODIMP MPCSessionCOMWrapper::get_Data( /*[out]*/ IStream* *pStm )
  104. {
  105. __ULT_FUNC_ENTRY( "MPCServerCOMWrapper::GetRequestVariable" );
  106. HRESULT hr;
  107. HANDLE hfFile = NULL;
  108. CComPtr<MPC::FileStream> stream;
  109. __MPC_PARAMCHECK_BEGIN(hr)
  110. __MPC_PARAMCHECK_POINTER_AND_SET(pStm,NULL);
  111. __MPC_PARAMCHECK_END();
  112. __MPC_EXIT_IF_METHOD_FAILS(hr, m_mpcsSession->OpenFile( hfFile, 0, false ));
  113. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::CreateInstance( &stream ));
  114. __MPC_EXIT_IF_METHOD_FAILS(hr, stream->InitForRead( L"", hfFile ));
  115. __MPC_EXIT_IF_METHOD_FAILS(hr, stream.QueryInterface( pStm ));
  116. __ULT_FUNC_CLEANUP;
  117. if(hfFile) ::CloseHandle( hfFile );
  118. __ULT_FUNC_EXIT(hr);
  119. }
  120. STDMETHODIMP MPCSessionCOMWrapper::get_ProviderData( /*[out]*/ DWORD *pVal )
  121. {
  122. if(pVal == NULL) return E_POINTER;
  123. *pVal = m_mpcsSession->m_dwProviderData;
  124. return S_OK;
  125. }
  126. STDMETHODIMP MPCSessionCOMWrapper::put_ProviderData( /*[in]*/ DWORD newVal )
  127. {
  128. m_mpcsSession->m_dwProviderData = newVal;
  129. m_mpcsSession->m_fDirty = true;
  130. return S_OK;
  131. }