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.

141 lines
5.5 KiB

  1. /*****************************************************************************\
  2. * MODULE: asphelp.h
  3. *
  4. * PURPOSE: Declaration of the Casphelp
  5. *
  6. * Copyright (C) 1997-1998 Microsoft Corporation
  7. *
  8. * History:
  9. *
  10. * 09/12/97 weihaic Created
  11. *
  12. \*****************************************************************************/
  13. #ifndef __ASPHELP_H_
  14. #define __ASPHELP_H_
  15. #include <asptlb.h> // Active Server Pages Definitions
  16. #define LENGTHOFPAPERNAMES 64 // From DeviceCapabilities DC_PAPERNAMES
  17. #define STANDARD_SNMP_MONITOR_NAME L"TCPMON.DLL" // The dll name of the Universal SNMP monitor.
  18. #define PAGEPERJOB 1
  19. #define BYTEPERJOB 2
  20. typedef struct ErrorMapping {
  21. DWORD dwError;
  22. DWORD dwErrorDscpID;
  23. } ErrorMapping;
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Casphelp
  26. class ATL_NO_VTABLE Casphelp :
  27. public CComObjectRootEx<CComMultiThreadModel>,
  28. public CComCoClass<Casphelp, &CLSID_asphelp>,
  29. public ISupportErrorInfoImpl<&IID_Iasphelp>,
  30. public IDispatchImpl<Iasphelp, &IID_Iasphelp, &LIBID_OLEPRNLib>
  31. {
  32. public:
  33. Casphelp();
  34. public:
  35. DECLARE_REGISTRY_RESOURCEID(IDR_ASPHELP)
  36. BEGIN_COM_MAP(Casphelp)
  37. COM_INTERFACE_ENTRY(Iasphelp)
  38. COM_INTERFACE_ENTRY(IDispatch)
  39. END_COM_MAP()
  40. // Iasphelp
  41. public:
  42. ~Casphelp();
  43. // These properties do not require calling Open at first
  44. STDMETHOD(get_ErrorDscp) (long lErrCode, /*[out, retval]*/ BSTR *pVal);
  45. STDMETHOD(get_MediaReady) (/*[out, retval]*/ VARIANT *pVal);
  46. STDMETHOD(get_MibErrorDscp) (DWORD dwError, /*[out, retval]*/ BSTR *pVal);
  47. STDMETHOD(Open) (BSTR bstrPrinterName);
  48. STDMETHOD(Close)();
  49. // Printer information
  50. STDMETHOD(get_AspPage) (DWORD dwPage, /*[out, retval]*/ BSTR *pbstrVal);
  51. STDMETHOD(get_Color) (/*[out, retval]*/ BOOL *pVal);
  52. STDMETHOD(get_Community) (/*[out, retval]*/ BSTR *pbstrVal);
  53. STDMETHOD(get_ComputerName) (/*[out, retval]*/ BSTR *pVal);
  54. STDMETHOD(get_DriverName) (/*[out, retval]*/ BSTR * pbstrVal);
  55. STDMETHOD(get_Duplex) (/*[out, retval]*/ BOOL *pVal);
  56. STDMETHOD(get_IPAddress) (/*[out, retval]*/ BSTR *pbstrVal);
  57. STDMETHOD(get_IsHTTP) (/*[out, retval]*/ BOOL *pbVal);
  58. STDMETHOD(get_IsTCPMonSupported)(/*[out, retval]*/ BOOL *pVal);
  59. STDMETHOD(get_LongPaperName) (BSTR bstrShortName, /*[out, retval]*/ BSTR *pVal);
  60. STDMETHOD(get_MaximumResolution)(/*[out, retval]*/ long *pVal);
  61. STDMETHOD(get_PageRate) (/*[out, retval]*/ long *pVal);
  62. STDMETHOD(get_PageRateUnit) (/*[out, retval]*/ long *pVal);
  63. STDMETHOD(get_PaperNames) (/*[out, retval]*/ VARIANT *pVal);
  64. STDMETHOD(get_PortName) (/*[out, retval]*/ BSTR *pVal);
  65. STDMETHOD(get_SNMPDevice) (/*[out, retval]*/ DWORD *pdwVal);
  66. STDMETHOD(get_SNMPSupported) (/*[out, retval]*/ BOOL *pbVal);
  67. STDMETHOD(get_Status) (/*[out, retval]*/ long *pVal);
  68. STDMETHOD(get_ShareName) (/*[out, retval]*/ BSTR *pVal);
  69. STDMETHOD(get_IsCluster) (/*[out, retval]*/ BOOL *pbVal);
  70. // Job completion time estimate
  71. STDMETHOD(CalcJobETA) ();
  72. STDMETHOD(get_AvgJobSize) (/*[out, retval]*/ long *pVal);
  73. STDMETHOD(get_AvgJobSizeUnit) (/*[out, retval]*/ long *pVal);
  74. STDMETHOD(get_JobCompletionMinute)(/*[out, retval]*/ long *pVal);
  75. STDMETHOD(get_PendingJobCount) (/*[out, retval]*/ long *pVal);
  76. //Active Server Pages Methods
  77. STDMETHOD(OnStartPage)(IUnknown* IUnk);
  78. STDMETHOD(OnEndPage)();
  79. private:
  80. void Cleanup();
  81. BOOL DecodeString (LPTSTR pPrinterName, LPTSTR pDecodedName, TCHAR chMark);
  82. BOOL DecodeStringA (LPSTR pPrinterName, LPSTR pDecodedName, char chMark);
  83. DWORD GetPPM();
  84. DWORD GetWaitingMinutesPPM (DWORD dwPPM, PJOB_INFO_2 pJobInfo, DWORD dwNumJob);
  85. HRESULT AllocGetPrinterInfo2(PPRINTER_INFO_2 *ppInfo2);
  86. HRESULT GetPaperAndMedia(VARIANT * pVal, WORD wDCFlag);
  87. HRESULT GetXcvDataBstr(LPCTSTR pszId, BSTR *bStr);
  88. HRESULT GetXcvDataDword (LPCTSTR pszId, DWORD *dwVal);
  89. HRESULT SetAspHelpScriptingError(DWORD dwError);
  90. // The following block is for ASP customization.
  91. BOOL GetMonitorName( LPTSTR pMonitorName );
  92. BOOL GetModel( LPTSTR pModel );
  93. BOOL GetManufacturer( LPTSTR pManufacturer );
  94. BOOL IsCustomASP( BOOL bDeviceASP, LPTSTR pASPPage );
  95. BOOL IsSnmpSupportedASP( LPTSTR pASPPage );
  96. BOOL GetASPPageForUniversalMonitor( LPTSTR pASPPage );
  97. BOOL GetASPPageForOtherMonitors( LPTSTR pMonitorName, LPTSTR pASPPage );
  98. BOOL GetASPPage( LPTSTR pASPPage );
  99. static const DWORD cdwBufSize = 512;
  100. CComPtr<IRequest> m_piRequest; //Request Object
  101. CComPtr<IResponse> m_piResponse; //Response Object
  102. CComPtr<ISessionObject> m_piSession; //Session Object
  103. CComPtr<IServer> m_piServer; //Server Object
  104. CComPtr<IApplicationObject> m_piApplication; //Application Object
  105. BOOL m_bOnStartPageCalled; //OnStartPage successful?
  106. TCHAR m_szComputerName[MAX_COMPUTERNAME_LENGTH+1];
  107. HANDLE m_hPrinter; //Handle to the printer
  108. HANDLE m_hXcvPrinter;
  109. DWORD m_dwAvgJobSize;
  110. DWORD m_dwAvgJobSizeUnit;
  111. DWORD m_dwJobCompletionMinute;
  112. DWORD m_dwPendingJobCount;
  113. DWORD m_dwSizePerJob;
  114. BOOL m_bCalcJobETA;
  115. BOOL m_bTCPMonSupported;
  116. class CPrinter *m_pPrinter;
  117. PPRINTER_INFO_2 m_pInfo2;
  118. };
  119. #endif //__ASPHELP_H_