File indexing completed on 2024-10-06 03:39:22
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2007 Thiago Macieira <thiago@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KIO_CONNECTIONBACKEND_P_H 0009 #define KIO_CONNECTIONBACKEND_P_H 0010 0011 #include <QObject> 0012 #include <QUrl> 0013 0014 class QLocalServer; 0015 class QLocalSocket; 0016 0017 class QTcpServer; 0018 0019 namespace KIO 0020 { 0021 struct Task { 0022 int cmd; 0023 QByteArray data; 0024 }; 0025 0026 class ConnectionBackend : public QObject 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 enum { Idle, Listening, Connected } state; 0032 QUrl address; 0033 QString errorString; 0034 0035 private: 0036 QLocalSocket *socket; 0037 QLocalServer *localServer; 0038 long len; 0039 int cmd; 0040 bool signalEmitted; 0041 0042 static const int HeaderSize = 10; 0043 static const int StandardBufferSize = 32 * 1024; 0044 0045 Q_SIGNALS: 0046 void disconnected(); 0047 void commandReceived(const KIO::Task &task); 0048 void newConnection(); 0049 0050 public: 0051 explicit ConnectionBackend(QObject *parent = nullptr); 0052 ~ConnectionBackend() override; 0053 0054 void setSuspended(bool enable); 0055 bool connectToRemote(const QUrl &url); 0056 bool listenForRemote(); 0057 bool waitForIncomingTask(int ms); 0058 bool sendCommand(int command, const QByteArray &data) const; 0059 ConnectionBackend *nextPendingConnection(); 0060 0061 public Q_SLOTS: 0062 void socketReadyRead(); 0063 void socketDisconnected(); 0064 }; 0065 } 0066 0067 #endif