File indexing completed on 2023-09-24 04:08:28
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 int port; 0041 bool signalEmitted; 0042 quint8 mode; 0043 0044 static const int HeaderSize = 10; 0045 static const int StandardBufferSize = 32 * 1024; 0046 0047 Q_SIGNALS: 0048 void disconnected(); 0049 // TODO KF6: fix clazy warning by using fully-qualified signal argument 0050 void commandReceived(const Task &task); // clazy:exclude=fully-qualified-moc-types 0051 void newConnection(); 0052 0053 public: 0054 explicit ConnectionBackend(QObject *parent = nullptr); 0055 ~ConnectionBackend() override; 0056 0057 void setSuspended(bool enable); 0058 bool connectToRemote(const QUrl &url); 0059 bool listenForRemote(); 0060 bool waitForIncomingTask(int ms); 0061 bool sendCommand(int command, const QByteArray &data) const; 0062 ConnectionBackend *nextPendingConnection(); 0063 0064 public Q_SLOTS: 0065 void socketReadyRead(); 0066 void socketDisconnected(); 0067 }; 0068 } 0069 0070 #endif