1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2007 Thiago Macieira <thiago@kde.org>
4 SPDX-FileCopyrightText: 2024 Harald Sitter <sitter@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef KIO_CONNECTIONBACKEND_P_H
10#define KIO_CONNECTIONBACKEND_P_H
11
12#include <QObject>
13#include <QUrl>
14
15class QLocalServer;
16class QLocalSocket;
17
18class QTcpServer;
19
20namespace KIO
21{
22struct Task {
23 int cmd = -1;
24 long len = 0;
25 QByteArray data{};
26};
27
28class ConnectionBackend : public QObject
29{
30 Q_OBJECT
31
32public:
33 enum { Idle, Listening, Connected } state;
34 QUrl address;
35 QString errorString;
36
37 static const int HeaderSize = 10;
38 static const int StandardBufferSize = 32 * 1024;
39
40private:
41 QLocalSocket *socket;
42 QLocalServer *localServer;
43 std::optional<Task> pendingTask = std::nullopt;
44 bool signalEmitted;
45
46Q_SIGNALS:
47 void disconnected();
48 void commandReceived(const KIO::Task &task);
49 void newConnection();
50
51public:
52 explicit ConnectionBackend(QObject *parent = nullptr);
53 ~ConnectionBackend() override;
54
55 void setSuspended(bool enable);
56 bool connectToRemote(const QUrl &url);
57 bool listenForRemote();
58 bool waitForIncomingTask(int ms);
59 bool sendCommand(int command, const QByteArray &data) const;
60 ConnectionBackend *nextPendingConnection();
61
62public Q_SLOTS:
63 void socketReadyRead();
64 void socketDisconnected();
65};
66}
67
68#endif
69

source code of kio/src/core/connectionbackend_p.h