KIO

connectionserver.cpp
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2000 Stephan Kulow <coolo@kde.org>
4 SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#include "connectionserver.h"
10#include "connection_p.h"
11#include "connectionbackend_p.h"
12#include "kiocoredebug.h"
13
14using namespace KIO;
15
16ConnectionServer::ConnectionServer(QObject *parent)
17 : QObject(parent)
18{
19}
20
21ConnectionServer::~ConnectionServer() = default;
22
23void ConnectionServer::listenForRemote()
24{
25 backend = new ConnectionBackend(this);
26 if (auto result = backend->listenForRemote(); !result.success) {
27 qCWarning(KIO_CORE) << "ConnectionServer::listenForRemote failed:" << result.error;
28 delete backend;
29 backend = nullptr;
30 return;
31 }
32
33 connect(backend, &ConnectionBackend::newConnection, this, &ConnectionServer::newConnection);
34 // qDebug() << "Listening on" << d->backend->address;
35}
36
37QUrl ConnectionServer::address() const
38{
39 if (backend) {
40 return backend->address;
41 }
42 return QUrl();
43}
44
45bool ConnectionServer::isListening() const
46{
47 return backend && backend->state == ConnectionBackend::Listening;
48}
49
50void ConnectionServer::setNextPendingConnection(Connection *conn)
51{
52 ConnectionBackend *newBackend = backend->nextPendingConnection();
53 Q_ASSERT(newBackend);
54
55 conn->d->setBackend(newBackend);
56 newBackend->setParent(conn);
57
58 conn->d->dequeue();
59}
60
61#include "moc_connectionserver.cpp"
A namespace for KIO globals.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.