[OpenDocString] kdeconnect-kde (cpp)
server.cpp
Server::Server(QObject *parent)
    : QTcpServer(parent)
{
    connect(this, &QTcpServer::acceptError, this, &Server::errorFound);
}
This constructor builds a server object from an existing one. It connects the acceptError signal to the errorFound signal.
void Server::incomingConnection(qintptr socketDescriptor)
{
    QSslSocket *serverSocket = new QSslSocket(parent());
    if (serverSocket->setSocketDescriptor(socketDescriptor)) {
        QObject::connect(this, &Server::closed, serverSocket, &QSslSocket::abort);
        addPendingConnection(serverSocket);
    } else {
        qWarning() << "setSocketDescriptor failed" << serverSocket->errorString();
        delete serverSocket;
    }
}
This adds a socket descriptor to the list of sockets that the server wants to accept. It sets the socket descriptor on the server socket and sets the signal pendingConnection to false.
QSslSocket *Server::nextPendingConnection()
{
    return qobject_cast(QTcpServer::nextPendingConnection());
}
Returns a copy of the internal list, which uses implicit sharing for its data.
void Server::errorFound(QAbstractSocket::SocketError socketError)
{
    qDebug() << "error:" << socketError;
}
This implements a socket error message.
void Server::close()
{
    QTcpServer::close();
    Q_EMIT closed();
}
This closes the server object. It terminates the internal state machine and emits the signal closed.