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.

163 lines
3.4 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. blbtime.h
  5. Abstract:
  6. Definition of the TIME class
  7. Author:
  8. */
  9. #if !defined(AFX_BLBTIME_H__0CC1F05A_CAEB_11D0_8D58_00C04FD91AC0__INCLUDED_)
  10. #define AFX_BLBTIME_H__0CC1F05A_CAEB_11D0_8D58_00C04FD91AC0__INCLUDED_
  11. #if _MSC_VER >= 1000
  12. #pragma once
  13. #endif // _MSC_VER >= 1000
  14. #include "resource.h" // main symbols
  15. #include "sdpblb.h"
  16. #include "blbcoen.h"
  17. /////////////////////////////////////////////////////////////////////////////
  18. // Time
  19. const USHORT MAX_NTP_TIME_STRLEN = 10;
  20. const SHORT FIRST_POSSIBLE_YEAR = 1970;
  21. const DWORD NTP_OFFSET = 0x83aa7e80;
  22. // return the current Ntp time
  23. inline DWORD_PTR
  24. GetCurrentNtpTime(
  25. )
  26. {
  27. return (time(NULL) + NTP_OFFSET);
  28. }
  29. class ATL_NO_VTABLE TIME :
  30. public ENUM_ELEMENT<SDP_TIME>,
  31. public CComObjectRootEx<CComObjectThreadModel>,
  32. public CComDualImpl<ITTime, &IID_ITTime, &LIBID_SDPBLBLib>,
  33. public CObjectSafeImpl
  34. {
  35. friend class MY_COLL_IMPL<TIME>;
  36. public:
  37. typedef ITTime ELEM_IF;
  38. typedef IEnumTime ENUM_IF;
  39. typedef ITTimeCollection COLL_IF;
  40. typedef SDP_TIME SDP_TYPE;
  41. typedef SDP_TIME_LIST SDP_LIST;
  42. static const IID &ELEM_IF_ID;
  43. public:
  44. inline TIME();
  45. inline ~TIME();
  46. inline HRESULT FinalConstruct(void);
  47. HRESULT Init(
  48. IN CSdpConferenceBlob &ConfBlob
  49. );
  50. HRESULT Init(
  51. IN CSdpConferenceBlob &ConfBlob,
  52. IN DWORD StartTime,
  53. IN DWORD StopTime
  54. );
  55. inline void SuccessInit(
  56. IN CSdpConferenceBlob &ConfBlob,
  57. IN SDP_TIME &SdpTime
  58. );
  59. inline void ClearSdpBlobRefs();
  60. BEGIN_COM_MAP(TIME)
  61. COM_INTERFACE_ENTRY(IDispatch)
  62. COM_INTERFACE_ENTRY(ITTime)
  63. COM_INTERFACE_ENTRY(IObjectSafety)
  64. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  65. END_COM_MAP()
  66. DECLARE_NOT_AGGREGATABLE(TIME)
  67. DECLARE_GET_CONTROLLING_UNKNOWN()
  68. // ITTime
  69. public:
  70. STDMETHOD(get_StopTime)(/*[out, retval]*/ DOUBLE *pTime);
  71. STDMETHOD(put_StopTime)(/*[in]*/ DOUBLE Time);
  72. STDMETHOD(get_StartTime)(/*[out, retval]*/ DOUBLE *pTime);
  73. STDMETHOD(put_StartTime)(/*[in]*/ DOUBLE Time);
  74. protected:
  75. CSdpConferenceBlob * m_ConfBlob;
  76. IUnknown * m_pFTM; // pointer to the free threaded marshaler
  77. };
  78. inline
  79. TIME::TIME(
  80. )
  81. : m_ConfBlob(NULL),
  82. m_pFTM(NULL)
  83. {
  84. }
  85. inline
  86. HRESULT TIME::FinalConstruct(void)
  87. {
  88. HRESULT HResult = CoCreateFreeThreadedMarshaler( GetControllingUnknown(),
  89. & m_pFTM );
  90. if ( FAILED(HResult) )
  91. {
  92. return HResult;
  93. }
  94. return S_OK;
  95. }
  96. inline
  97. TIME::~TIME()
  98. {
  99. if ( m_pFTM )
  100. {
  101. m_pFTM->Release();
  102. }
  103. }
  104. inline void
  105. TIME::SuccessInit(
  106. IN CSdpConferenceBlob &ConfBlob,
  107. IN SDP_TIME &SdpTime
  108. )
  109. {
  110. m_ConfBlob = &ConfBlob;
  111. // don't free the sdptime instance on destruction
  112. ENUM_ELEMENT<SDP_TIME>::SuccessInit(SdpTime, FALSE);
  113. }
  114. inline void
  115. TIME::ClearSdpBlobRefs(
  116. )
  117. {
  118. m_ConfBlob = NULL;
  119. }
  120. #endif // !defined(AFX_BLBTIME_H__0CC1F05A_CAEB_11D0_8D58_00C04FD91AC0__INCLUDED_)