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.

78 lines
1.8 KiB

  1. // UploadEventsWrapper.cpp : Implementation of CUploadEventsWrapper
  2. #include "stdafx.h"
  3. #include "EventWrapper.h"
  4. #include "UploadEventsWrapper.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CUploadEventsWrapper
  7. HRESULT CUploadEventsWrapper::FinalConstruct()
  8. {
  9. return CoCreateFreeThreadedMarshaler( GetControllingUnknown(), &m_pUnkMarshaler.p );
  10. }
  11. void CUploadEventsWrapper::FinalRelease()
  12. {
  13. UnregisterForEvents();
  14. m_pUnkMarshaler.Release();
  15. }
  16. void CUploadEventsWrapper::UnregisterForEvents()
  17. {
  18. if(m_dwUploadEventsCookie)
  19. {
  20. if(AtlUnadvise( m_mpcujJob, IID_IMPCUploadEvents, m_dwUploadEventsCookie ) == S_OK)
  21. {
  22. m_dwUploadEventsCookie = 0;
  23. }
  24. }
  25. if(m_mpcujJob)
  26. {
  27. m_mpcujJob->Release(); m_mpcujJob = NULL;
  28. }
  29. }
  30. STDMETHODIMP CUploadEventsWrapper::Register( IMPCUploadJob* mpcujJob )
  31. {
  32. HRESULT hr = S_OK;
  33. CComPtr<IMPCUploadEvents> pCallback;
  34. UnregisterForEvents();
  35. if(mpcujJob)
  36. {
  37. m_mpcujJob = mpcujJob; m_mpcujJob->AddRef();
  38. if(SUCCEEDED(hr = QueryInterface( IID_IMPCUploadEvents, (void**)&pCallback )))
  39. {
  40. hr = AtlAdvise( m_mpcujJob, pCallback, IID_IMPCUploadEvents, &m_dwUploadEventsCookie );
  41. }
  42. }
  43. return hr;
  44. }
  45. ////////////////////////////////////////////////
  46. STDMETHODIMP CUploadEventsWrapper::onStatusChange( IMPCUploadJob* mpcujJob, UL_STATUS fStatus )
  47. {
  48. return Fire_onStatusChange ( mpcujJob, fStatus );
  49. }
  50. STDMETHODIMP CUploadEventsWrapper::onProgressChange( IMPCUploadJob* mpcujJob, long lCurrentSize, long lTotalSize )
  51. {
  52. return Fire_onProgressChange( mpcujJob, lCurrentSize, lTotalSize );
  53. }