qatchat.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 QATCHAT_H
  20. #define QATCHAT_H
  21. #include "qatresult.h"
  22. #include <qbytearray.h>
  23. class QAtChatPrivate;
  24. class QAtChatCommand;
  25. class QSerialIODevice;
  26. class QAtChat : public QObject
  27. {
  28. Q_OBJECT
  29. friend class QSerialIODevice;
  30. private:
  31. explicit QAtChat( QSerialIODevice *device );
  32. ~QAtChat();
  33. public:
  34. void chat( const QString& command );
  35. void chat( const QString& command, QObject *target, const char *slot,
  36. QAtResult::UserData *data = 0 );
  37. void chatPDU( const QString& command, const QByteArray& pdu,
  38. QObject *target, const char *slot,
  39. QAtResult::UserData *data = 0 );
  40. void registerNotificationType
  41. ( const QString& type, QObject *target,
  42. const char *slot, bool mayBeCommand = false );
  43. void abortDial();
  44. void suspend();
  45. void resume();
  46. void setDebugChars( char from, char to, char notify, char unknown );
  47. int deadTimeout() const;
  48. void setDeadTimeout( int msec );
  49. int retryOnNonEcho() const;
  50. void setRetryOnNonEcho( int msec );
  51. void setCPINTerminator();
  52. void requestNextLine( QObject *target, const char *slot );
  53. void send( const QString& command );
  54. void registerErrorPrefix( const QString& type );
  55. void registerWakeupCommand( const QString& cmd, int wakeupTime );
  56. signals:
  57. void pduNotification( const QString& type, const QByteArray& pdu );
  58. void callNotification( const QString& type );
  59. void dead();
  60. private slots:
  61. void incoming();
  62. void timeout();
  63. void failCommand();
  64. void retryTimeout();
  65. void performWakeup();
  66. void wakeupFinished();
  67. private:
  68. QAtChatPrivate *d;
  69. void queue( QAtChatCommand *command );
  70. void done();
  71. bool writeLine( const QString& line );
  72. void writePduLine( const QString& line );
  73. bool processLine( const QString& line );
  74. void prime();
  75. void primeIfNecessary();
  76. };
  77. #endif