kdeconnect-kde/core/backends/bluetooth/multiplexchannel.h

60 lines
1.3 KiB
C
Raw Normal View History

2019-01-20 11:23:50 +00:00
/**
* SPDX-FileCopyrightText: 2019 Matthijs Tijink <matthijstijink@gmail.com>
2019-01-20 11:23:50 +00:00
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
2019-01-20 11:23:50 +00:00
*/
#ifndef MULTIPLEXCHANNEL_H
#define MULTIPLEXCHANNEL_H
#include <QIODevice>
#include <QSharedPointer>
class ConnectionMultiplexer;
class MultiplexChannelState;
/**
* Represents a single channel in a multiplexed connection
*
* @see ConnectionMultiplexer
* @see ConnectionMultiplexer::getChannel
*/
class MultiplexChannel : public QIODevice
{
2019-01-20 11:23:50 +00:00
Q_OBJECT
private:
/**
* You cannot construct a MultiplexChannel yourself, use the ConnectionMultiplexer
*/
MultiplexChannel(QSharedPointer<MultiplexChannelState> state);
2019-01-20 11:23:50 +00:00
public:
~MultiplexChannel();
constexpr static int BUFFER_SIZE = 4096;
bool canReadLine() const override;
bool atEnd() const override;
qint64 bytesAvailable() const override;
qint64 bytesToWrite() const override;
bool isSequential() const override;
protected:
qint64 readData(char *data, qint64 maxlen) override;
qint64 writeData(const char *data, qint64 len) override;
2019-01-20 11:23:50 +00:00
private:
QSharedPointer<MultiplexChannelState> state;
/**
* Disconnects the channel
*/
void disconnect();
friend class ConnectionMultiplexer;
};
#endif