Added check on QT_NO_NETWORKPROXY to include proxy functionality only when required
[contrib/qtwebsockets.git] / src / dataprocessor_p.h
1 #ifndef DATAPROCESSOR_P_H
2 #define DATAPROCESSOR_P_H
3
4 //
5 //  W A R N I N G
6 //  -------------
7 //
8 // This file is not part of the Qt API.  It exists purely as an
9 // implementation detail.  This header file may change from version to
10 // version without notice, or even be removed.
11 //
12 // We mean it.
13 //
14
15 #include <QObject>
16 #include <QByteArray>
17 #include <QString>
18 #include <QTextCodec>
19 #include "qwebsocketprotocol.h"
20
21 QT_BEGIN_NAMESPACE
22
23 class QTcpSocket;
24
25 /**
26  * @internal
27  * @brief The DataProcessor class
28  */
29 class DataProcessor: public QObject
30 {
31         Q_OBJECT
32 public:
33         explicit DataProcessor(QObject *parent = 0);
34         virtual ~DataProcessor();
35
36 Q_SIGNALS:
37         void controlFrameReceived(QWebSocketProtocol::OpCode opCode, QByteArray frame);
38         void textFrameReceived(QString frame, bool lastFrame);
39         void binaryFrameReceived(QByteArray frame, bool lastFrame);
40         void textMessageReceived(QString message);
41         void binaryMessageReceived(QByteArray message);
42         void errorEncountered(QWebSocketProtocol::CloseCode code, QString description);
43
44 public Q_SLOTS:
45         void process(QTcpSocket *pSocket);
46         void clear();
47
48 private:
49         Q_DISABLE_COPY(DataProcessor)
50         enum
51         {
52                 PS_READ_HEADER,
53                 PS_READ_PAYLOAD_LENGTH,
54                 PS_READ_BIG_PAYLOAD_LENGTH,
55                 PS_READ_MASK,
56                 PS_READ_PAYLOAD,
57                 PS_DISPATCH_RESULT
58         } m_processingState;
59
60         bool m_isFinalFrame;
61         bool m_isFragmented;
62         QWebSocketProtocol::OpCode m_opCode;
63         bool m_isControlFrame;
64         bool m_hasMask;
65         quint32 m_mask;
66         QByteArray m_binaryMessage;
67         QString m_textMessage;
68         quint64 m_payloadLength;
69         QTextCodec::ConverterState *m_pConverterState;
70         QTextCodec *m_pTextCodec;
71 };
72
73 QT_END_NAMESPACE
74
75 #endif // DATAPROCESSOR_P_H