AdminSession.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*-------------------------------------------------------------------------
  2. * fedsrv\AdminSession.H
  3. *
  4. * This houses the definition of AdminSession Class. This class
  5. * exposes log-on methods allowing a Admin Session (using COM) with AllSrv.
  6. *
  7. * Owner:
  8. *
  9. * Copyright 1986-1998 Microsoft Corporation, All Rights Reserved
  10. *-----------------------------------------------------------------------*/
  11. #ifndef _ADMINSESSION_H_
  12. #define _ADMINSESSION_H_
  13. #include <objsafe.h> // For CATID_SafeForScripting
  14. #include <..\TCLib\AutoCriticalSection.h>
  15. #include <..\TCLib\ObjectLock.h>
  16. #include <..\TCAtl\DualEventsCP.h>
  17. #include "AdminSessionClass.h"
  18. /////////////////////////////////////////////////////////////////////////////
  19. // External Declarations
  20. extern "C" const IID DIID__IAdminSessionEvents;
  21. /////////////////////////////////////////////////////////////////////////////
  22. // Forward Declarations
  23. class CAdminSessionEventSink;
  24. /////////////////////////////////////////////////////////////////////////////
  25. // IAdminSessionEventsCP
  26. //
  27. BEGIN_TCComDualEventsCP(IAdminSessionEventsCP, IAdminSessionEvents, DIID__IAdminSessionEvents)
  28. TCComDualEventCP_Fn1(OnEvent, dispid_OnEvent, IAGCEventPtr, VT_DISPATCH)
  29. END_TCComDualEventsCP()
  30. /////////////////////////////////////////////////////////////////////////////
  31. //
  32. class ATL_NO_VTABLE CAdminSession :
  33. public IDispatchImpl<IAdminSession, &IID_IAdminSession, &LIBID_ALLEGIANCESERVERLib>,
  34. public IProvideClassInfo2Impl<&CLSID_AdminSession, &DIID__IAdminSessionEvents, &LIBID_ALLEGIANCESERVERLib>,
  35. public IConnectionPointContainerImpl<CAdminSession>,
  36. public IAdminSessionEventsCP<CAdminSession>,
  37. public CComObjectRootEx<CComMultiThreadModel>,
  38. public CComCoClass<CAdminSession, &CLSID_AdminSession>
  39. {
  40. // Declarations
  41. public:
  42. DECLARE_REGISTRY_RESOURCEID(IDR_ADMINSESSION)
  43. DECLARE_PROTECT_FINAL_CONSTRUCT()
  44. DECLARE_CLASSFACTORY_EX(CAdminSessionClass)
  45. // Interface Map
  46. public:
  47. BEGIN_COM_MAP(CAdminSession)
  48. COM_INTERFACE_ENTRY(IAdminSession)
  49. COM_INTERFACE_ENTRY(IDispatch)
  50. COM_INTERFACE_ENTRY(IProvideClassInfo)
  51. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  52. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  53. END_COM_MAP()
  54. // Category Map
  55. public:
  56. BEGIN_CATEGORY_MAP(CAdminSession)
  57. IMPLEMENTED_CATEGORY(CATID_AllegianceAdmin)
  58. IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
  59. END_CATEGORY_MAP()
  60. // Connection Point Map
  61. public:
  62. BEGIN_CONNECTION_POINT_MAP(CAdminSession)
  63. CONNECTION_POINT_ENTRY(DIID__IAdminSessionEvents)
  64. CONNECTION_POINT_ENTRY(IID_IAdminSessionEvents)
  65. END_CONNECTION_POINT_MAP()
  66. // Construction / Destruction
  67. public:
  68. CAdminSession();
  69. virtual ~CAdminSession();
  70. HRESULT FinalConstruct();
  71. void FinalRelease();
  72. // Operations
  73. public:
  74. static void DestroyAllSessions();
  75. // Overrides
  76. protected:
  77. virtual IUnknown* OnGetUnknown();
  78. // Implementation
  79. public:
  80. static int GetSessionCount();
  81. static CAdminSession* GetLastSession();
  82. static CAdminSession* GetWhoStartedServer();
  83. // IAdminSession Interface Methods
  84. public:
  85. STDMETHODIMP put_SessionInfo(ITCSessionInfo* pSessionInfo);
  86. STDMETHODIMP get_SessionInfo(ITCSessionInfo** ppSessionInfo);
  87. STDMETHODIMP get_SessionInfos(ITCSessionInfos** ppSessionInfos);
  88. STDMETHODIMP get_Server(IAdminServer** ppAdminServer);
  89. STDMETHODIMP get_IsEventActivated(AGCEventID event, AGCUniqueID uniqueID, BOOL *pVal);
  90. STDMETHODIMP ActivateEvents(AGCEventID AGCEvent, AGCUniqueID uniqueID = -1);
  91. STDMETHODIMP DeactivateEvents(AGCEventID AGCEvent, AGCUniqueID uniqueID = -1);
  92. STDMETHODIMP ActivateAllEvents();
  93. STDMETHODIMP DeactivateAllEvents();
  94. STDMETHODIMP get_ProcessID(long* pdwProcessID);
  95. STDMETHODIMP get_Version(IAGCVersionInfo** ppVersion);
  96. STDMETHODIMP Stop();
  97. STDMETHODIMP Pause();
  98. STDMETHODIMP get_WhoStartedServer(IAdminSession** IAdminSession);
  99. STDMETHODIMP get_EventLog(IAGCEventLogger** ppEventLogger);
  100. STDMETHODIMP get_PerfCounters(IAGCEvent** ppPerfCounters);
  101. STDMETHODIMP SendAdminChat(BSTR bstrText, long nUserID, DATE dateOriginal);
  102. STDMETHODIMP Continue();
  103. // Types
  104. protected:
  105. typedef TCObjectLock<CAdminSession> XLock;
  106. typedef TCObjectLock<TCAutoCriticalSection> XLockStatic;
  107. typedef std::vector<CAdminSession*> XSessions;
  108. typedef XSessions::iterator XSessionsIt;
  109. // Data Members
  110. protected:
  111. CAdminSessionEventSink* m_pEventSink;
  112. static TCAutoCriticalSection s_cs;
  113. static XSessions s_vecSessions;
  114. // this is temporary until launcher obj gets done
  115. static CAdminSession* s_pWhoStartedServer; // This is NULL unless a session started the server
  116. };
  117. /////////////////////////////////////////////////////////////////////////////
  118. // Implementation
  119. inline int CAdminSession::GetSessionCount()
  120. {
  121. XLockStatic lock(&s_cs);
  122. return s_vecSessions.size();
  123. }
  124. inline CAdminSession* CAdminSession::GetLastSession()
  125. {
  126. XLockStatic lock(&s_cs);
  127. return *s_vecSessions.rbegin();
  128. }
  129. inline CAdminSession* CAdminSession::GetWhoStartedServer()
  130. {
  131. XLockStatic lock(&s_cs);
  132. return s_pWhoStartedServer;
  133. }
  134. /////////////////////////////////////////////////////////////////////////////
  135. #endif // _ADMINSESSION_H_