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.

111 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. All Rights Reserved
  4. Module Name:
  5. BasePort.h
  6. Abstract:
  7. Interface for the CBasePort class.
  8. Author: M. Fenelon
  9. Revision History:
  10. --*/
  11. //
  12. //////////////////////////////////////////////////////////////////////
  13. #if !defined(AFX_BASEPORT_H__9B0AE97A_9ADB_4B48_846F_29D41B1263C9__INCLUDED_)
  14. #define AFX_BASEPORT_H__9B0AE97A_9ADB_4B48_846F_29D41B1263C9__INCLUDED_
  15. #if _MSC_VER > 1000
  16. #pragma once
  17. #endif // _MSC_VER > 1000
  18. class CBasePort
  19. {
  20. public:
  21. CBasePort();
  22. CBasePort( BOOL bActive, LPTSTR pszPortName, LPTSTR pszDevicePath, LPTSTR pszPortDesc );
  23. virtual ~CBasePort();
  24. BOOL startDoc( LPTSTR pPrinterName, DWORD dwJobId, DWORD dwLevel, LPBYTE pDocInfo );
  25. BOOL endDoc();
  26. BOOL write( LPBYTE pBuffer, DWORD cbBuffer, LPDWORD pcbWritten );
  27. BOOL read( LPBYTE pBuffer, DWORD cbBuffer, LPDWORD pcbRead );
  28. virtual BOOL getPrinterDataFromPort( DWORD dwControlID, LPTSTR pValueName, LPWSTR lpInBuffer, DWORD cbInBuffer,
  29. LPWSTR lpOutBuffer, DWORD cbOutBuffer, LPDWORD lpcbReturned );
  30. virtual BOOL setPortTimeOuts( LPCOMMTIMEOUTS lpCTO );
  31. void ClearCS();
  32. void InitCS();
  33. virtual PORTTYPE getPortType( void );
  34. LPTSTR getPortDesc();
  35. virtual void setPortDesc( LPTSTR pszPortDesc );
  36. // DWORD getDeviceFlags( void );
  37. // void setDeviceFlags(DWORD dwFlags, DWORD dwType = SET_FLAGS);
  38. // BOOL compDeviceFlags( DWORD dwFlags );
  39. BOOL isActive( void );
  40. void setActive( BOOL bValue );
  41. BOOL compActiveState( BOOL bValue );
  42. LPTSTR getDevicePath( void );
  43. void setDevicePath( LPTSTR pszDevicePath );
  44. INT compDevicePath( LPTSTR pszDevicePath );
  45. LPTSTR getPortName( void );
  46. void setPortName( LPTSTR pszPortName );
  47. INT compPortName( LPTSTR pszPortName );
  48. DWORD getEnumInfoSize( DWORD Level );
  49. LPBYTE copyEnumInfo( DWORD dwLevel, LPBYTE pPort, LPBYTE pEnd );
  50. void setMaxBuffer(DWORD dwMaxBufferSize);
  51. protected:
  52. DWORD m_cRef;
  53. DWORD m_dwFlags;
  54. BOOL m_bActive; // Is this port currently Active
  55. DWORD m_dwJobId;
  56. DWORD m_dwMaxBufferSize;
  57. HANDLE m_hDeviceHandle;
  58. HANDLE m_hPrinter;
  59. LPBYTE m_pWriteBuffer;
  60. DWORD m_dwBufferSize, // dwBufferSize : size of buffer
  61. m_dwDataSize, // dwDataSize : size of data in buffer
  62. // (could be smaller than dwBufferSize)
  63. m_dwDataCompleted, // dwDataCompleted : size of data sent and acknowledged
  64. m_dwDataScheduled; // dwScheduledData : size of data we have scheduled using WriteFile
  65. OVERLAPPED m_Ov;
  66. CRITICAL_SECTION m_CritSec;
  67. DWORD m_dwReadTimeoutMultiplier;
  68. DWORD m_dwReadTimeoutConstant;
  69. DWORD m_dwWriteTimeoutMultiplier;
  70. DWORD m_dwWriteTimeoutConstant;
  71. TCHAR m_szPortName[MAX_PORT_LEN];
  72. TCHAR m_szPortDescription[MAX_PORT_DESC_LEN];
  73. TCHAR m_szDevicePath[MAX_PATH];
  74. virtual BOOL checkPnP();
  75. BOOL getLPTStatus(HANDLE hDeviceHandle,BYTE *Status );
  76. DWORD getTimeLeft( DWORD dwStartTime,DWORD dwTimeout );
  77. void freeWriteBuffer();
  78. BOOL needToResubmitJob( DWORD dwError );
  79. DWORD getWriteStatus( DWORD dwTimeOut );
  80. BOOL abortThisJob();
  81. virtual DWORD adjustWriteSize( DWORD dwBytesToWrite );
  82. void invalidatePortHandle();
  83. DWORD sendQueuedData();
  84. DWORD writeData();
  85. BOOL close();
  86. void closePrinter();
  87. BOOL open();
  88. BOOL openPrinter( LPTSTR pPrinterName );
  89. void setJobStatus( DWORD dwJobStatus );
  90. DWORD getJobID();
  91. void setJobID( DWORD dwJobID );
  92. BOOL notInWrite( void );
  93. private:
  94. };
  95. #endif // !defined(AFX_BASEPORT_H__9B0AE97A_9ADB_4B48_846F_29D41B1263C9__INCLUDED_)