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.

73 lines
2.2 KiB

  1. // SPortMap.h : Declaration of the CStaticPortMapping
  2. #ifndef __STATICPORTMAPPING_H_
  3. #define __STATICPORTMAPPING_H_
  4. #include <upnp.h>
  5. #include "dportmap.h"
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CStaticPortMapping
  8. class ATL_NO_VTABLE CStaticPortMapping :
  9. public CComObjectRootEx<CComSingleThreadModel>,
  10. // public CComCoClass<CStaticPortMapping, &CLSID_StaticPortMapping>,
  11. public IDispatchImpl<IStaticPortMapping, &IID_IStaticPortMapping, &LIBID_NATUPNPLib>
  12. {
  13. private:
  14. CComPtr<IDynamicPortMapping> m_spDPM;
  15. public:
  16. CStaticPortMapping()
  17. {
  18. }
  19. //DECLARE_REGISTRY_RESOURCEID(IDR_STATICPORTMAPPING)
  20. DECLARE_PROTECT_FINAL_CONSTRUCT()
  21. BEGIN_COM_MAP(CStaticPortMapping)
  22. COM_INTERFACE_ENTRY(IStaticPortMapping)
  23. COM_INTERFACE_ENTRY(IDispatch)
  24. END_COM_MAP()
  25. // IStaticPortMapping
  26. public:
  27. STDMETHOD(get_ExternalIPAddress)(/*[out, retval]*/ BSTR *pVal);
  28. STDMETHOD(get_ExternalPort)(/*[out, retval]*/ long *pVal);
  29. STDMETHOD(get_Protocol)(/*[out, retval]*/ BSTR *pVal);
  30. STDMETHOD(get_InternalPort)(/*[out, retval]*/ long *pVal);
  31. STDMETHOD(get_InternalClient)(/*[out, retval]*/ BSTR *pVal);
  32. STDMETHOD(get_Enabled)(/*[out, retval]*/ VARIANT_BOOL *pVal);
  33. STDMETHOD(get_Description)(/*[out, retval]*/ BSTR *pVal);
  34. STDMETHOD(EditInternalClient)(/*[in]*/ BSTR bstrInternalClient);
  35. STDMETHOD(Enable)(/*[in]*/ VARIANT_BOOL vb);
  36. STDMETHOD(EditDescription)(/*[in]*/ BSTR bstrDescription);
  37. STDMETHOD(EditInternalPort)(/*[in]*/ long lInternalPort);
  38. // CStaticPortMapping
  39. public:
  40. HRESULT Initialize (IDynamicPortMapping * pDPM)
  41. {
  42. _ASSERT (m_spDPM == NULL);
  43. m_spDPM = pDPM;
  44. return S_OK;
  45. }
  46. static IStaticPortMapping * CreateInstance (IDynamicPortMapping * pDPM)
  47. {
  48. CComObject<CStaticPortMapping> * spm = NULL;
  49. HRESULT hr = CComObject<CStaticPortMapping>::CreateInstance (&spm);
  50. if (!spm)
  51. return NULL;
  52. IStaticPortMapping * pSPM = NULL;
  53. spm->AddRef();
  54. hr = spm->Initialize (pDPM);
  55. if (SUCCEEDED(hr))
  56. spm->QueryInterface (__uuidof(IStaticPortMapping), (void**)&pSPM);
  57. spm->Release();
  58. return pSPM;
  59. }
  60. };
  61. #endif //__STATICPORTMAPPING_H_