QXmpp  Version: 1.7.1
QXmppStream.h
1 // SPDX-FileCopyrightText: 2009 Manjeet Dahiya <manjeetdahiya@gmail.com>
2 // SPDX-FileCopyrightText: 2010 Jeremy LainĂ© <jeremy.laine@m4x.org>
3 // SPDX-FileCopyrightText: 2021 Linus Jahn <lnj@kaidan.im>
4 //
5 // SPDX-License-Identifier: LGPL-2.1-or-later
6 
7 #ifndef QXMPPSTREAM_H
8 #define QXMPPSTREAM_H
9 
10 #include "QXmppLogger.h"
11 
12 #include <memory>
13 
14 class QDomElement;
15 class QSslSocket;
16 class QXmppNonza;
17 class QXmppStreamPrivate;
18 
19 namespace QXmpp::Private {
20 class XmppSocket;
21 }
22 
26 class QXMPP_EXPORT QXmppStream : public QXmppLoggable
27 {
28  Q_OBJECT
29 
30 public:
31  QXmppStream(QObject *parent);
32  ~QXmppStream() override;
33 
34  virtual bool isConnected() const;
35 
36  bool sendPacket(const QXmppNonza &);
37 
38  QXmpp::Private::XmppSocket &xmppSocket() const;
39 
40 Q_SIGNALS:
42  void connected();
43 
45  void disconnected();
46 
47 protected:
48  // Access to underlying socket
49  QSslSocket *socket() const;
50  void setSocket(QSslSocket *socket);
51 
52  // Overridable methods
53  virtual void handleStart();
54 
58  virtual void handleStanza(const QDomElement &element) = 0;
59 
63  virtual void handleStream(const QDomElement &element) = 0;
64 
65 public Q_SLOTS:
66  virtual void disconnectFromHost();
67  virtual bool sendData(const QByteArray &);
68 
69 private:
70  friend class tst_QXmppStream;
71 
72  const std::unique_ptr<QXmppStreamPrivate> d;
73 };
74 
75 #endif // QXMPPSTREAM_H
The QXmppLoggable class represents a source of logging messages.
Definition: QXmppLogger.h:110
Definition: QXmppNonza.h:14
The QXmppStream class is the base class for all XMPP streams.
Definition: QXmppStream.h:27
void connected()
This signal is emitted when the stream is connected.
void disconnected()
This signal is emitted when the stream is disconnected.
virtual void handleStream(const QDomElement &element)=0
virtual void handleStanza(const QDomElement &element)=0