File indexing completed on 2024-04-28 15:26:13

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2000 Stephan Kulow <coolo@kde.org>
0004     SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef KIO_CONNECTIONSERVER_H
0010 #define KIO_CONNECTIONSERVER_H
0011 
0012 #include "kiocore_export.h"
0013 
0014 #include <QObject>
0015 #include <QUrl>
0016 #include <memory>
0017 
0018 namespace KIO
0019 {
0020 class ConnectionServerPrivate;
0021 class Connection;
0022 
0023 /**
0024  * @private
0025  * @internal
0026  *
0027  * This class provides a way to obtaining KIO::Connection connections.
0028  * Used by klauncher.
0029  * Do not use outside KIO and klauncher!
0030  */
0031 class KIOCORE_EXPORT ConnectionServer : public QObject
0032 {
0033     Q_OBJECT
0034 public:
0035     explicit ConnectionServer(QObject *parent = nullptr);
0036     ~ConnectionServer() override;
0037 
0038     /**
0039      * Sets this connection to listen mode. Use address() to obtain the
0040      * address this is listening on.
0041      */
0042     void listenForRemote();
0043     bool isListening() const;
0044     /// Closes the connection.
0045     void close();
0046 
0047     /**
0048      * Returns the address for this connection if it is listening, an empty
0049      * address if not.
0050      */
0051     QUrl address() const;
0052 
0053     Connection *nextPendingConnection();
0054     void setNextPendingConnection(Connection *conn);
0055 
0056 Q_SIGNALS:
0057     void newConnection();
0058 
0059 private:
0060     friend class ConnectionServerPrivate;
0061     std::unique_ptr<ConnectionServerPrivate> const d;
0062 };
0063 
0064 } // namespace KIO
0065 
0066 #endif