[OpenDocString] kdeconnect-kde (cpp)
socketlinereader.cpp
SocketLineReader::SocketLineReader(QSslSocket *socket, QObject *parent)
    : QObject(parent)
    , m_socket(socket)
{
    connect(m_socket, &QIODevice::readyRead, this, &SocketLineReader::dataReceived);
}
Constructs a socket object from an SSL socket object, and connects it to the readyRead signal.
void SocketLineReader::dataReceived()
{
    while (m_socket->canReadLine()) {
        const QByteArray line = m_socket->readLine();
        if (line.length() > 1) { // we don't want a single \n
            m_packets.enqueue(line);
        }
    }

    // If we have any packets, tell it to the world.
    if (!m_packets.isEmpty()) {
        Q_EMIT readyRead();
    }
}
This reads from the socket and queues incoming lines if there are packets.