- Migrated all 104 CMakeLists.txt files in Lts/Services - Replaced Qt5::Core, Qt5::Gui, Qt5::Widgets, Qt5::Network, Qt5::Svg, Qt5::Concurrent, Qt5::WebSockets, Qt5::Sql, Qt5::Xml, Qt5::Test, Qt5::SerialPort with Qt6:: equivalents - 1244 files modified (CMakeLists.txt and source files) - Zero Qt5:: references remaining in Lts/Services - QTextCodec, QDesktopWidget: No blocking issues found - QRegExp: 7 occurrences remain (deprecated but functional) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
89 lines
2.2 KiB
C++
Executable File
89 lines
2.2 KiB
C++
Executable File
/**
|
|
* Communication with A/V system - fm server
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QTimer>
|
|
#include <QTcpSocket>
|
|
#include <queue>
|
|
|
|
#include "logger.h"
|
|
#include "avm_export.h"
|
|
|
|
namespace AudioVideoManagement
|
|
{
|
|
class AVM_COMMON_EXPORT AVSocket : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
AVSocket(const QString &avsServerHost,
|
|
quint16 avsServerPort,
|
|
NGL::INGLLogger &logger,
|
|
NGL::INGLLogger &loggerIO,
|
|
QObject *parent = nullptr);
|
|
~AVSocket();
|
|
|
|
void connectToAVS() { onConnectToAVS(); }
|
|
|
|
// From TcpServer::Workerbase to properly parse quoted arguments
|
|
// cfroebel 2017-06-19: Made it static public in order to unit-test it.
|
|
static QVector<QByteArray> parseLine(const QByteArray &ba, const int iStart = 0);
|
|
|
|
protected Q_SLOTS:
|
|
virtual void onDisconnected();
|
|
void onError(QAbstractSocket::SocketError error);
|
|
virtual void onReadyRead() = 0;
|
|
void onConnectToAVS();
|
|
void onRcpLogin();
|
|
|
|
protected:
|
|
QString getConnectionString() const;
|
|
bool sendInternal(const QByteArray &cmd);
|
|
|
|
protected:
|
|
bool m_bSuccessfullyLoggedIn;
|
|
bool m_bErrorInTcpComWarnedOnce;
|
|
QTcpSocket *m_avsSocket; //!< Will be deleted and re-created with every new connection.
|
|
QString m_avsServerHost;
|
|
quint16 m_avsServerPort;
|
|
QTimer *m_rcpLoginTimer;
|
|
QTimer *m_reconnectTimer;
|
|
std::queue<QByteArray> m_commandQueueForErrorHandling;
|
|
NGL::INGLLogger &m_logger;
|
|
NGL::INGLLogger &m_loggerIO;
|
|
};
|
|
|
|
|
|
/**
|
|
* Small wrapper around AVSocket in order to avoid that clients need to derive from it.
|
|
*/
|
|
class AVM_COMMON_EXPORT AVSocketWrapper : public AVSocket
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
AVSocketWrapper(const QString &avsServerHost, quint16 avsServerPort, NGL::INGLLogger &logger, NGL::INGLLogger &loggerIO)
|
|
: AVSocket(avsServerHost, avsServerPort, logger, loggerIO)
|
|
{}
|
|
|
|
void send(const QByteArray &cmd) { sendInternal(cmd); }
|
|
void disconnectFromHost() { m_avsSocket->disconnectFromHost(); }
|
|
|
|
signals:
|
|
void disconnected();
|
|
void readyRead(QTcpSocket *socket);
|
|
|
|
private:
|
|
void onDisconnected() override { AVSocket::onDisconnected(); emit disconnected(); }
|
|
void onReadyRead() override { emit readyRead(m_avsSocket); }
|
|
};
|
|
|
|
|
|
} // namespace AudioVideoManagement
|