2013-10-30 00:18:25 +00:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
|
|
|
|
* SPDX-FileCopyrightText: 2014 Alejandro Fiestas Olivares <afiestas@kde.org>
|
2013-10-30 00:18:25 +00:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2013-10-30 00:18:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "socketlinereader.h"
|
|
|
|
|
2015-07-05 14:23:53 +01:00
|
|
|
SocketLineReader::SocketLineReader(QSslSocket* socket, QObject* parent)
|
2013-10-30 00:18:25 +00:00
|
|
|
: QObject(parent)
|
2017-09-03 20:39:44 +01:00
|
|
|
, m_socket(socket)
|
2013-10-30 00:18:25 +00:00
|
|
|
{
|
2017-09-03 20:39:44 +01:00
|
|
|
connect(m_socket, &QIODevice::readyRead,
|
2016-11-26 14:12:38 +00:00
|
|
|
this, &SocketLineReader::dataReceived);
|
2013-10-30 00:18:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SocketLineReader::dataReceived()
|
|
|
|
{
|
2017-09-03 20:39:44 +01:00
|
|
|
while (m_socket->canReadLine()) {
|
|
|
|
const QByteArray line = m_socket->readLine();
|
2015-10-19 05:49:29 +01:00
|
|
|
if (line.length() > 1) { //we don't want a single \n
|
2018-03-04 19:48:51 +00:00
|
|
|
m_packets.enqueue(line);
|
2013-10-30 00:18:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-04 19:48:51 +00:00
|
|
|
//If we have any packets, tell it to the world.
|
|
|
|
if (!m_packets.isEmpty()) {
|
2014-04-14 20:49:47 +01:00
|
|
|
Q_EMIT readyRead();
|
2013-11-06 17:35:40 +00:00
|
|
|
}
|
2013-10-30 00:18:25 +00:00
|
|
|
}
|