Source code of Windows XP (NT5)
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
5.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: A U T O M A T I O N P R O X Y . H
  7. //
  8. // Contents: Header file for the Automation Proxy class.
  9. //
  10. // Notes:
  11. //
  12. // Author: spather 2000/09/25
  13. //
  14. //----------------------------------------------------------------------------
  15. #ifndef __AUTOMATIONPROXY_H
  16. #define __AUTOMATIONPROXY_H
  17. #pragma once
  18. #include "uhres.h"
  19. #include "hostp.h"
  20. typedef struct tagUPNP_STATE_VARIABLE
  21. {
  22. BSTR bstrName;
  23. BSTR bstrDataType;
  24. BOOL fNonEvented;
  25. DISPID dispid;
  26. } UPNP_STATE_VARIABLE;
  27. typedef struct tagUPNP_ARGUMENT
  28. {
  29. BSTR bstrName;
  30. UPNP_STATE_VARIABLE * pusvRelated;
  31. } UPNP_ARGUMENT;
  32. typedef struct tagUPNP_ACTION
  33. {
  34. BSTR bstrName;
  35. DISPID dispid;
  36. DWORD cInArgs;
  37. UPNP_ARGUMENT * rgInArgs;
  38. DWORD cOutArgs;
  39. UPNP_ARGUMENT * rgOutArgs;
  40. UPNP_ARGUMENT * puaRetVal;
  41. } UPNP_ACTION;
  42. class ATL_NO_VTABLE CUPnPAutomationProxy :
  43. public CComObjectRootEx<CComMultiThreadModel>,
  44. public CComCoClass<CUPnPAutomationProxy, &CLSID_UPnPAutomationProxy>,
  45. public IUPnPAutomationProxy,
  46. public IUPnPServiceDescriptionInfo
  47. {
  48. public:
  49. DECLARE_PROTECT_FINAL_CONSTRUCT()
  50. DECLARE_REGISTRY_RESOURCEID(IDR_AUTOMATION_PROXY)
  51. DECLARE_NOT_AGGREGATABLE(CUPnPAutomationProxy)
  52. BEGIN_COM_MAP(CUPnPAutomationProxy)
  53. COM_INTERFACE_ENTRY(IUPnPAutomationProxy)
  54. COM_INTERFACE_ENTRY(IUPnPServiceDescriptionInfo)
  55. END_COM_MAP()
  56. CUPnPAutomationProxy();
  57. ~CUPnPAutomationProxy();
  58. // ATL methods
  59. HRESULT FinalConstruct();
  60. HRESULT FinalRelease();
  61. // IUPnPAutomationProxy
  62. public:
  63. STDMETHOD(Initialize)(
  64. /*[in]*/ IUnknown * punkSvcObject,
  65. /*[in]*/ LPWSTR pszSvcDescription,
  66. /*[in]*/ LPWSTR pszSvcType,
  67. /*[in]*/ BOOL bRunning);
  68. STDMETHOD(GetDispIdsOfEventedVariables)(
  69. /*[out]*/ DWORD * pcEventedVars,
  70. /*[out]*/ DISPID ** prgdispidEventedVars);
  71. STDMETHOD(QueryStateVariablesByDispIds)(
  72. /*[in]*/ DWORD cDispIds,
  73. /*[in]*/ DISPID * rgDispIds,
  74. /*[out]*/ DWORD * pcVariables,
  75. /*[out]*/ LPWSTR ** prgszVariableNames,
  76. /*[out]*/ VARIANT ** prgvarVariableValues,
  77. /*[out]*/ LPWSTR ** prgszVariableDataTypes);
  78. STDMETHOD(ExecuteRequest)(
  79. /*[in]*/ UPNP_CONTROL_REQUEST * pucreq,
  80. /*[out]*/ UPNP_CONTROL_RESPONSE * pucresp);
  81. STDMETHOD(GetServiceType)(
  82. /*[out]*/ LPWSTR * pszSvcType);
  83. // IUPnPServiceDescriptionInfo
  84. public:
  85. STDMETHOD(GetVariableType)(
  86. /*[in]*/ LPWSTR pszVarName,
  87. /*[out]*/ BSTR * pbstrType);
  88. STDMETHOD(GetInputArgumentNamesAndTypes)(
  89. /*[in]*/ LPWSTR pszActionName,
  90. /*[out]*/ DWORD * pcInArguments,
  91. /*[out]*/ BSTR ** prgbstrNames,
  92. /*[out]*/ BSTR ** prgbstrTypes);
  93. STDMETHOD(GetOutputArgumentNamesAndTypes)(
  94. /*[in]*/ LPWSTR pszActionName,
  95. /*[out]*/ DWORD * pcOutArguments,
  96. /*[out]*/ BSTR ** prgbstrNames,
  97. /*[out]*/ BSTR ** prgbstrTypes);
  98. // Helper functions
  99. private:
  100. VOID FreeVariable(UPNP_STATE_VARIABLE * pVariable);
  101. VOID FreeAction(UPNP_ACTION * pAction);
  102. VOID FreeArgument(UPNP_ARGUMENT * pArg);
  103. VOID FreeVariableTable();
  104. VOID FreeActionTable();
  105. VOID FreeControlResponse(UPNP_CONTROL_RESPONSE * pucresp);
  106. HRESULT HrProcessServiceDescription(LPWSTR pszSvcDescription);
  107. HRESULT HrValidateServiceDescription(IXMLDOMElement * pxdeRoot);
  108. HRESULT HrBuildTablesFromServiceDescription(IXMLDOMElement * pxdeRoot);
  109. HRESULT HrBuildVariableTable(IXMLDOMNodeList * pxdnlStateVars);
  110. HRESULT HrBuildActionTable(IXMLDOMNodeList * pxdnlActions);
  111. HRESULT HrBuildArgumentLists(IXMLDOMNode * pxdnAction, UPNP_ACTION * pAction);
  112. HRESULT HrCountInAndOutArgs(IXMLDOMNodeList * pxdnlArgs,
  113. DWORD * pcInArgs,
  114. DWORD * pcOutArgs);
  115. HRESULT HrInitializeArguments(IXMLDOMNodeList * pxdnlArgs, UPNP_ACTION * pAction);
  116. UPNP_STATE_VARIABLE *LookupVariableByDispID(DISPID dispid);
  117. UPNP_STATE_VARIABLE *LookupVariableByName(LPCWSTR pcszName);
  118. UPNP_ACTION *LookupActionByName(LPCWSTR pcszName);
  119. HRESULT HrBuildFaultResponse(UPNP_CONTROL_RESPONSE_DATA * pucrd,
  120. LPCWSTR pcszFaultCode,
  121. LPCWSTR pcszFaultString,
  122. LPCWSTR pcszUPnPErrorCode,
  123. LPCWSTR pcszUPnPErrorString);
  124. HRESULT HrVariantInitForXMLType(VARIANT * pvar,
  125. LPCWSTR pcszDataTypeString);
  126. HRESULT HrInvokeAction(UPNP_CONTROL_REQUEST * pucreq,
  127. UPNP_CONTROL_RESPONSE * pucresp);
  128. HRESULT HrQueryStateVariable(UPNP_CONTROL_REQUEST * pucreq,
  129. UPNP_CONTROL_RESPONSE * pucresp);
  130. // State
  131. private:
  132. BOOL m_fInitialized;
  133. IDispatch * m_pdispService;
  134. DWORD m_cVariables;
  135. DWORD m_cEventedVariables;
  136. UPNP_STATE_VARIABLE * m_rgVariables;
  137. DWORD m_cActions;
  138. UPNP_ACTION * m_rgActions;
  139. LPWSTR m_wszServiceType;
  140. };
  141. #endif //!__AUTOMATIONPROXY_H