QXmpp  Version:1.3.1
QXmppStream.h
1 /*
2  * Copyright (C) 2008-2020 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 #ifndef QXMPPSTREAM_H
26 #define QXMPPSTREAM_H
27 
28 #include "QXmppLogger.h"
29 
30 #include <QAbstractSocket>
31 #include <QObject>
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() override;
48 
49  virtual bool isConnected() const;
50  bool sendPacket(const QXmppStanza &);
51 
52 Q_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 
77  // XEP-0198: Stream Management
78  void enableStreamManagement(bool resetSequenceNumber);
79  unsigned lastIncomingSequenceNumber() const;
80  void setAcknowledgedSequenceNumber(unsigned sequenceNumber);
81 
82 private:
83  // XEP-0198: Stream Management
84  void handleAcknowledgement(QDomElement &element);
85  void sendAcknowledgement();
86  void sendAcknowledgementRequest();
87 
88 public Q_SLOTS:
89  virtual void disconnectFromHost();
90  virtual bool sendData(const QByteArray &);
91 
92 private Q_SLOTS:
93  void _q_socketConnected();
94  void _q_socketEncrypted();
95  void _q_socketError(QAbstractSocket::SocketError error);
96  void _q_socketReadyRead();
97 
98 private:
99  QXmppStreamPrivate *const d;
100 };
101 
102 #endif // QXMPPSTREAM_H
QXmppStanza
The QXmppStanza class is the base class for all XMPP stanzas.
Definition: QXmppStanza.h:99
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:123