QXmpp  Version:1.0.0
QXmppStream.h
1 /*
2  * Copyright (C) 2008-2019 The QXmpp developers
3  *
4  * Authors:
5  * Manjeet Dahiya
6  * Jeremy LainĂ©
7  *
8  * Source:
9  * https://github.com/qxmpp-project/qxmpp
10  *
11  * This file is a part of QXmpp library.
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2.1 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  * Lesser General Public License for more details.
22  *
23  */
24 
25 
26 #ifndef QXMPPSTREAM_H
27 #define QXMPPSTREAM_H
28 
29 #include <QAbstractSocket>
30 #include <QObject>
31 #include "QXmppLogger.h"
32 
33 class QDomElement;
34 class QSslSocket;
35 class QXmppStanza;
36 class QXmppStreamPrivate;
37 
40 
41 class QXMPP_EXPORT QXmppStream : public QXmppLoggable
42 {
43  Q_OBJECT
44 
45 public:
46  QXmppStream(QObject *parent);
47  ~QXmppStream();
48 
49  virtual bool isConnected() const;
50  bool sendPacket(const QXmppStanza&);
51 
52 signals:
54  void connected();
55 
57  void disconnected();
58 
59 protected:
60  // Access to underlying socket
61  QSslSocket *socket() const;
62  void setSocket(QSslSocket *socket);
63 
64  // Overridable methods
65  virtual void handleStart();
66 
70  virtual void handleStanza(const QDomElement &element) = 0;
71 
75  virtual void handleStream(const QDomElement &element) = 0;
76 
81  void enableStreamManagement(bool resetSequenceNumber);
82 
84  unsigned lastIncomingSequenceNumber() const;
85 
87  void setAcknowledgedSequenceNumber(unsigned sequenceNumber);
88 
89 private:
93  void handleAcknowledgement(QDomElement &element);
94 
96  void sendAcknowledgement();
97 
99  void sendAcknowledgementRequest();
100 
101 public slots:
102  virtual void disconnectFromHost();
103  virtual bool sendData(const QByteArray&);
104 
105 private slots:
106  void _q_socketConnected();
107  void _q_socketEncrypted();
108  void _q_socketError(QAbstractSocket::SocketError error);
109  void _q_socketReadyRead();
110 
111 private:
112  QXmppStreamPrivate * const d;
113 };
114 
115 #endif // QXMPPSTREAM_H
QXmppStanza
The QXmppStanza class is the base class for all XMPP stanzas.
Definition: QXmppStanza.h:90
QXmppStream
The QXmppStream class is the base class for all XMPP streams.
Definition: QXmppStream.h:41
QXmppLoggable
The QXmppLoggable class represents a source of logging messages.
Definition: QXmppLogger.h:111