KIO::Connection Class
Header: | #include <Connection> |
CMake: | find_package(KF6 REQUIRED COMPONENTS KIO) target_link_libraries(mytarget PRIVATE KF6::KIOCore) |
Public Functions
Connection(KIO::Connection::Type type, QObject *parent = nullptr) | |
void | connectToRemote(const QUrl &address) |
bool | hasTaskAvailable() const |
bool | inited() const |
int | read(int *_cmd, QByteArray &data) |
void | resume() |
bool | send(int cmd, const QByteArray &arr = QByteArray()) |
bool | sendnow(int _cmd, const QByteArray &data) |
void | suspend() |
bool | suspended() const |
bool | waitForIncomingTask(int ms = 30000) |
Detailed Description
@private
This class provides a simple means for IPC between two applications via a pipe. It handles a queue of commands to be sent which makes it possible to queue data before an actual connection has been established.
Member Function Documentation
[explicit]
Connection::Connection(KIO::Connection::Type type, QObject *parent = nullptr)
Creates a new connection. @see connectToRemote, listenForRemote
void Connection::connectToRemote(const QUrl &address)
Connects to the remote address. @param address a local:// or tcp:// URL.
bool Connection::hasTaskAvailable() const
Returns true if there are packets to be read immediately, false if waitForIncomingTask must be called before more data is available.
bool Connection::inited() const
Checks whether the connection has been initialized. @return true if the initialized @see init()
int Connection::read(int *_cmd, QByteArray &data)
* Receive data. * * @param _cmd the received command will be written here * @param data the received data will be written here
* @return >=0 indicates the received data size upon success * -1 indicates error
void Connection::resume()
Resume handling of incoming data.
bool Connection::send(int cmd, const QByteArray &arr = QByteArray())
Sends/queues the given command to be sent. @param cmd the command to set @param arr the bytes to send @return true if successful, false otherwise
bool Connection::sendnow(int _cmd, const QByteArray &data)
Sends the given command immediately. @param _cmd the command to set @param data the bytes to send @return true if successful, false otherwise
void Connection::suspend()
Don't handle incoming data until resumed.
bool Connection::suspended() const
Returns status of connection. @return true if suspended, false otherwise
bool Connection::waitForIncomingTask(int ms = 30000)
Waits for one more command to be handled and ready.
@param ms the time to wait in milliseconds @returns true if one command can be read, false if we timed out