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.

97 lines
2.0 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. blbtico.cpp
  5. Abstract:
  6. Author:
  7. */
  8. #include "stdafx.h"
  9. #include "blbtico.h"
  10. #include "sdpblob.h"
  11. STDMETHODIMP MY_TIME_COLL_IMPL::Create(
  12. /*[in]*/ ULONG Index,
  13. /*[out, retval]*/ ELEM_IF **Interface
  14. )
  15. {
  16. CLock Lock(g_DllLock);
  17. BAIL_ON_FAILURE(MY_COLL_IMPL<TIME>::Create(Index, Interface));
  18. return S_OK;
  19. }
  20. STDMETHODIMP MY_TIME_COLL_IMPL::Delete(
  21. /*[in]*/ ULONG Index
  22. )
  23. {
  24. CLock Lock(g_DllLock);
  25. BAIL_ON_FAILURE(MY_COLL_IMPL<TIME>::Delete(Index));
  26. return S_OK;
  27. }
  28. HRESULT
  29. MY_TIME_COLL_IMPL::Create(
  30. IN ULONG Index,
  31. IN DWORD StartTime,
  32. IN DWORD StopTime
  33. )
  34. {
  35. ASSERT(NULL != m_IfArray);
  36. BAIL_IF_NULL(m_IfArray, E_FAIL);
  37. // use 1-based index, VB like
  38. // can add at atmost 1 beyond the last element
  39. if ((Index < 1) || (Index > (m_IfArray->GetSize()+1)))
  40. {
  41. return E_INVALIDARG;
  42. }
  43. // if the sdp blob doesn't exist, creation is not allowed
  44. if ( NULL == m_IfArray->GetSdpBlob() )
  45. {
  46. return HRESULT_FROM_ERROR_CODE(SDPBLB_CONF_BLOB_DESTROYED);
  47. }
  48. CComObject<TIME> *TimeComObject;
  49. HRESULT HResult = CComObject<TIME>::CreateInstance(&TimeComObject);
  50. BAIL_ON_FAILURE(HResult);
  51. HResult = TimeComObject->Init(*(m_IfArray->GetSdpBlob()), StartTime, StopTime);
  52. if ( FAILED(HResult) )
  53. {
  54. delete TimeComObject;
  55. return HResult;
  56. }
  57. ELEM_IF *Interface;
  58. HResult = TimeComObject->_InternalQueryInterface(IID_ITTime, (void**)&Interface);
  59. if (FAILED(HResult))
  60. {
  61. delete TimeComObject;
  62. return HResult;
  63. }
  64. // adjust index to c like index value
  65. HResult = m_IfArray->Add(Index-1, Interface);
  66. if (FAILED(HResult))
  67. {
  68. delete TimeComObject;
  69. return HResult;
  70. }
  71. // no need to add another reference count as the interface is not being returned
  72. return S_OK;
  73. }