File indexing completed on 2024-12-01 04:35:45

0001 /*
0002    SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libruqola_private_export.h"
0010 #include <QAbstractSocket>
0011 #include <QObject>
0012 #include <QSslError>
0013 #include <QWebSocketProtocol>
0014 class LIBRUQOLACORE_TESTS_EXPORT AbstractWebSocket : public QObject
0015 {
0016     Q_OBJECT
0017 public:
0018     explicit AbstractWebSocket(QObject *parent = nullptr);
0019     ~AbstractWebSocket() override;
0020 
0021     virtual void openUrl(const QUrl &url) = 0;
0022     [[nodiscard]] virtual qint64 sendTextMessage(const QString &message) = 0;
0023     virtual bool isValid() const = 0;
0024     virtual void flush() = 0;
0025     virtual void close() = 0;
0026     [[nodiscard]] virtual QAbstractSocket::SocketError error() const = 0;
0027     [[nodiscard]] virtual QString errorString() const = 0;
0028     [[nodiscard]] virtual QUrl requestUrl() const = 0;
0029     [[nodiscard]] virtual QWebSocketProtocol::CloseCode closeCode() const = 0;
0030     [[nodiscard]] virtual QString closeReason() const = 0;
0031     virtual qint64 sendBinaryMessage(const QByteArray &data) = 0;
0032     virtual void ignoreSslErrors() = 0;
0033 
0034 Q_SIGNALS:
0035     void disconnected();
0036     void connected();
0037     void textMessageReceived(const QString &message);
0038     void sslErrors(const QList<QSslError> &errors);
0039     void socketError(QAbstractSocket::SocketError error, const QString &errorString);
0040 };