blob: 96b27fd0f3c24314e86c91ca95b322425a4ee29e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
// Copyright (C) 2017-2016 Ford Motor Company
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QQNXNATIVEIO_H
#define QQNXNATIVEIO_H
#include <QtNetwork/qabstractsocket.h>
#include <QtRemoteObjects/qtremoteobjectglobal.h>
QT_BEGIN_NAMESPACE
/*
* The implementation of the Source and Replica
* side QIODevice look like they will be fairly
* different, including different APIs. So
* creating a 2nd derived type for the source.
*
* TODO: revisit if these can be combined into a
* single type.
*
* With two types, QQnxNativeIo will need to get
* Source or Replica added. Not sure what intuitive
* names are yet. So for now, QQnxNativeIo is the
* Replica side, QIOQnxSourcePrivate is the Source
* side. Revisit the name as this matures.
*
*/
class QQnxNativeIoPrivate;
class QIOQnxSourcePrivate;
class Q_REMOTEOBJECTS_EXPORT QQnxNativeIo : public QIODevice
{
Q_OBJECT
Q_DECLARE_PRIVATE(QQnxNativeIo)
public:
explicit QQnxNativeIo(QObject *parent = nullptr);
~QQnxNativeIo() override;
bool connectToServer(OpenMode openMode = ReadWrite);
bool connectToServer(const QString &name, OpenMode openMode = ReadWrite);
void disconnectFromServer();
void setServerName(const QString &name);
QString serverName() const;
void abort();
bool isSequential() const override;
qint64 bytesAvailable() const override;
qint64 bytesToWrite() const override;
bool open(OpenMode openMode = ReadWrite) override;
void close() override;
QAbstractSocket::SocketError error() const;
bool flush();
bool isValid() const;
QAbstractSocket::SocketState state() const;
bool waitForBytesWritten(int msecs = 30000) override;
bool waitForConnected(int msecs = 30000);
bool waitForDisconnected(int msecs = 30000);
bool waitForReadyRead(int msecs = 30000) override;
Q_SIGNALS:
void connected();
void disconnected();
void error(QAbstractSocket::SocketError socketError);
void stateChanged(QAbstractSocket::SocketState socketState);
protected:
qint64 readData(char*, qint64) override;
qint64 writeData(const char*, qint64) override;
private:
Q_DISABLE_COPY(QQnxNativeIo)
};
class Q_REMOTEOBJECTS_EXPORT QIOQnxSource : public QIODevice
{
Q_OBJECT
Q_DECLARE_PRIVATE(QIOQnxSource)
public:
explicit QIOQnxSource(int rcvid, QObject *parent = nullptr);
~QIOQnxSource() override;
bool isSequential() const override;
qint64 bytesAvailable() const override;
qint64 bytesToWrite() const override;
void close() override;
QAbstractSocket::SocketError error() const;
bool isValid() const;
QAbstractSocket::SocketState state() const;
bool waitForBytesWritten(int msecs = 30000) override;
bool waitForConnected(int msecs = 30000);
bool waitForDisconnected(int msecs = 30000);
bool waitForReadyRead(int msecs = 30000) override;
Q_SIGNALS:
void disconnected();
void error(QAbstractSocket::SocketError socketError);
void stateChanged(QAbstractSocket::SocketState socketState);
protected:
qint64 readData(char*, qint64) override;
qint64 writeData(const char*, qint64) override;
bool open(OpenMode openMode) override;
private Q_SLOTS:
void onDisconnected();
private:
Q_DISABLE_COPY(QIOQnxSource)
friend class QQnxNativeServerPrivate;
friend class QnxServerIo;
};
QT_END_NAMESPACE
#endif // QQNXNATIVEIO_H
|