qserialiodevice.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /****************************************************************************
  2. **
  3. ** This file is part of the Qt Extended Opensource Package.
  4. **
  5. ** Copyright (C) 2009 Trolltech ASA.
  6. **
  7. ** Contact: Qt Extended Information (info@qtextended.org)
  8. **
  9. ** This file may be used under the terms of the GNU General Public License
  10. ** version 2.0 as published by the Free Software Foundation and appearing
  11. ** in the file LICENSE.GPL included in the packaging of this file.
  12. **
  13. ** Please review the following information to ensure GNU General Public
  14. ** Licensing requirements will be met:
  15. ** http://www.fsf.org/licensing/licenses/info/GPLv2.html.
  16. **
  17. **
  18. ****************************************************************************/
  19. #ifndef QSERIALIODEVICE_H
  20. #define QSERIALIODEVICE_H
  21. #include <qobject.h>
  22. #include <qiodevice.h>
  23. #include <qstring.h>
  24. #include <qstringlist.h>
  25. #include <qprocess.h>
  26. class QPseudoTtyProcess;
  27. class QAtChat;
  28. class QSerialIODevice : public QIODevice
  29. {
  30. Q_OBJECT
  31. friend class QPseudoTtyProcess;
  32. public:
  33. explicit QSerialIODevice( QObject *parent = 0 );
  34. ~QSerialIODevice();
  35. bool isSequential() const;
  36. virtual int rate() const;
  37. virtual bool dtr() const = 0;
  38. virtual void setDtr( bool value ) = 0;
  39. virtual bool dsr() const = 0;
  40. virtual bool carrier() const = 0;
  41. virtual bool setCarrier( bool value );
  42. virtual bool rts() const = 0;
  43. virtual void setRts( bool value ) = 0;
  44. virtual bool cts() const = 0;
  45. virtual void discard() = 0;
  46. virtual bool waitForReady() const;
  47. virtual QProcess *run( const QStringList& arguments, bool addPPPdOptions );
  48. virtual QAtChat *atchat();
  49. virtual void abortDial();
  50. virtual bool isValid() const;
  51. signals:
  52. void dsrChanged( bool value );
  53. void carrierChanged( bool value );
  54. void ctsChanged( bool value );
  55. void ready();
  56. protected slots:
  57. void internalReadyRead();
  58. private:
  59. QPseudoTtyProcess *process;
  60. QAtChat *chat;
  61. };
  62. class QNullSerialIODevice : public QSerialIODevice
  63. {
  64. Q_OBJECT
  65. public:
  66. explicit QNullSerialIODevice( QObject *parent = 0 );
  67. ~QNullSerialIODevice();
  68. bool open( OpenMode mode );
  69. void close();
  70. qint64 bytesAvailable() const;
  71. int rate() const;
  72. bool dtr() const;
  73. void setDtr( bool value );
  74. bool dsr() const;
  75. bool carrier() const;
  76. bool rts() const;
  77. void setRts( bool value );
  78. bool cts() const;
  79. void discard();
  80. bool isValid() const;
  81. protected:
  82. qint64 readData( char *data, qint64 maxlen );
  83. qint64 writeData( const char *data, qint64 len );
  84. };
  85. #endif