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.

175 lines
4.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: machine.h
  7. //
  8. // Contents: IConnectedMachine class definition
  9. //
  10. //----------------------------------------------------------------------------
  11. //****************************************************************************
  12. //
  13. // Forward declarations
  14. //
  15. //****************************************************************************
  16. class CMTScript;
  17. class CScriptHost;
  18. //****************************************************************************
  19. //
  20. // Classes
  21. //
  22. //****************************************************************************
  23. //+---------------------------------------------------------------------------
  24. //
  25. // Class: CMachine (cm)
  26. //
  27. // Purpose: Contains all useful info about a machine and what it's
  28. // doing.
  29. //
  30. // Notes: This class is manipulated from multiple threads. All
  31. // member functions must be thread safe!
  32. //
  33. // This is the class that is created by the class factory and
  34. // handed out as a remote object to other machines. It has no
  35. // real code in itself but merely provides a way to talk to the
  36. // already running script engines.
  37. //
  38. //----------------------------------------------------------------------------
  39. class CMachine : public CThreadComm,
  40. public IConnectedMachine,
  41. public IConnectionPointContainer
  42. {
  43. friend class CMachConnectPoint;
  44. public:
  45. DECLARE_MEMCLEAR_NEW_DELETE();
  46. CMachine(CMTScript *pMT, ITypeInfo *pTIMachine);
  47. ~CMachine();
  48. DECLARE_STANDARD_IUNKNOWN(CMachine);
  49. // IDispatch interface
  50. STDMETHOD(GetTypeInfoCount)(UINT FAR* pctinfo);
  51. STDMETHOD(GetTypeInfo)(
  52. UINT itinfo,
  53. LCID lcid,
  54. ITypeInfo FAR* FAR* pptinfo);
  55. STDMETHOD(GetIDsOfNames)(
  56. REFIID riid,
  57. OLECHAR FAR* FAR* rgszNames,
  58. UINT cNames,
  59. LCID lcid,
  60. DISPID FAR* rgdispid);
  61. STDMETHOD(Invoke)(
  62. DISPID dispidMember,
  63. REFIID riid,
  64. LCID lcid,
  65. WORD wFlags,
  66. DISPPARAMS FAR* pdispparams,
  67. VARIANT FAR* pvarResult,
  68. EXCEPINFO FAR* pexcepinfo,
  69. UINT FAR* puArgErr);
  70. // IConnectionPointContainer methods
  71. STDMETHOD(EnumConnectionPoints)(LPENUMCONNECTIONPOINTS*);
  72. STDMETHOD(FindConnectionPoint)(REFIID, LPCONNECTIONPOINT*);
  73. // IConnectedMachine interface
  74. STDMETHOD(Exec)(BSTR bstrCmd, BSTR bstrParams, VARIANT *pvData);
  75. STDMETHOD(get_PublicData)(VARIANT *pvData);
  76. STDMETHOD(get_Name)(BSTR *pbstrName);
  77. STDMETHOD(get_Platform)(BSTR *pbstrPlat);
  78. STDMETHOD(get_OS)(BSTR *pbstrOS);
  79. STDMETHOD(get_MajorVer)(long *plMajorVer);
  80. STDMETHOD(get_MinorVer)(long *plMinorVer);
  81. STDMETHOD(get_BuildNum)(long *plBuildNum);
  82. STDMETHOD(get_PlatformIsNT)(VARIANT_BOOL *pfIsNT);
  83. STDMETHOD(get_ServicePack)(BSTR *pbstrSP);
  84. STDMETHOD(get_HostMajorVer)(long *plMajorVer);
  85. STDMETHOD(get_HostMinorVer)(long *plMajorVer);
  86. STDMETHOD(get_StatusValue)(long nIndex, long *pnStatus);
  87. HRESULT FireScriptNotify(BSTR bstrIdent, VARIANT vInfoF);
  88. #define LOCK_MACH_LOCALS(pObj) CMachLock local_lock(pObj);
  89. protected:
  90. virtual BOOL Init();
  91. virtual DWORD ThreadMain();
  92. BOOL HandleThreadMessage();
  93. private:
  94. class CMachLock
  95. {
  96. public:
  97. CMachLock(CMachine *pThis);
  98. ~CMachLock();
  99. private:
  100. CMachine *_pThis;
  101. };
  102. friend class CMachLock;
  103. CMTScript * _pMT;
  104. ITypeInfo * _pTypeInfoIMachine;
  105. CRITICAL_SECTION _cs;
  106. CStackPtrAry<IDispatch*, 5> _aryDispSink;
  107. };
  108. inline
  109. CMachine::CMachLock::CMachLock(CMachine *pThis)
  110. : _pThis(pThis)
  111. {
  112. EnterCriticalSection(&_pThis->_cs);
  113. }
  114. inline
  115. CMachine::CMachLock::~CMachLock()
  116. {
  117. LeaveCriticalSection(&_pThis->_cs);
  118. }
  119. //+---------------------------------------------------------------------------
  120. //
  121. // Class: CMachConnectPoint (mcp)
  122. //
  123. // Purpose: Implements IConnectionPoint for CMachine
  124. //
  125. //----------------------------------------------------------------------------
  126. class CMachConnectPoint : public IConnectionPoint
  127. {
  128. public:
  129. CMachConnectPoint(CMachine *pMach);
  130. ~CMachConnectPoint();
  131. DECLARE_STANDARD_IUNKNOWN(CMachConnectPoint);
  132. STDMETHOD(GetConnectionInterface)(IID * pIID);
  133. STDMETHOD(GetConnectionPointContainer)(IConnectionPointContainer ** ppCPC);
  134. STDMETHOD(Advise)(LPUNKNOWN pUnkSink, DWORD * pdwCookie);
  135. STDMETHOD(Unadvise)(DWORD dwCookie);
  136. STDMETHOD(EnumConnections)(LPENUMCONNECTIONS * ppEnum);
  137. CMachine *_pMachine;
  138. };