9#include <private/qcore_unix_p.h>
13const char *
QQnxNavigatorPps::navigatorControlPath =
"/pps/services/navigator/control";
36 m_fd = qt_safe_open(navigatorControlPath, O_RDWR);
38 qWarning(
"QQNX: failed to open navigator pps, errno=%d", errno);
42 qCDebug(lcQpaQnxNavigator) <<
"successfully connected to Navigator. fd=" << m_fd;
49 if (!openPpsConnection())
52 return sendPpsMessage(
"invoke", encodedUrl);
55bool QQnxNavigatorPps::sendPpsMessage(
const QByteArray &message,
const QByteArray &data)
57 QByteArray ppsMessage =
"msg::" + message;
60 ppsMessage +=
"\ndat::" + data;
64 qCDebug(lcQpaQnxNavigator) <<
"sending PPS message:\n" << ppsMessage;
68 int bytes = qt_safe_write(m_fd, ppsMessage.constData(), ppsMessage.size());
69 if (Q_UNLIKELY(bytes == -1))
70 qFatal(
"QQNX: failed to write navigator pps, errno=%d", errno);
73 char buffer[ppsBufferSize];
78 bytes = qt_safe_read(m_fd, buffer, ppsBufferSize - 1);
79 if (Q_UNLIKELY(bytes == -1))
80 qFatal(
"QQNX: failed to read navigator pps, errno=%d", errno);
86 qCDebug(lcQpaQnxNavigator) <<
"received PPS message:\n" << buffer;
89 QByteArray ppsData(buffer);
90 QHash<QByteArray, QByteArray> responseFields;
91 parsePPS(ppsData, responseFields);
93 if (responseFields.contains(
"res") && responseFields.value(
"res") == message) {
94 if (Q_UNLIKELY(responseFields.contains(
"err"))) {
95 qCritical() <<
"navigator responded with error: " << responseFields.value(
"err");
103void QQnxNavigatorPps::parsePPS(
const QByteArray &ppsData, QHash<QByteArray, QByteArray> &messageFields)
105 qCDebug(lcQpaQnxNavigator) <<
"data=" << ppsData;
108 QList<QByteArray> lines = ppsData.split(
'\n');
111 if (Q_UNLIKELY(lines.empty() || lines.at(0) !=
"@control"))
112 qFatal(
"QQNX: unrecognized pps object, data=%s", ppsData.constData());
115 for (
int i = 1; i < lines.size(); i++) {
118 const QByteArray &attr = lines.at(i);
120 qCDebug(lcQpaQnxNavigator) <<
"attr=" << attr;
122 int firstColon = attr.indexOf(
':');
123 if (firstColon == -1) {
128 int secondColon = attr.indexOf(
':', firstColon + 1);
129 if (secondColon == -1) {
134 QByteArray key = attr.left(firstColon);
135 QByteArray value = attr.mid(secondColon + 1);
137 qCDebug(lcQpaQnxNavigator) <<
"key=" << key <<
"value=" << value;
138 messageFields[key] = value;
bool requestInvokeUrl(const QByteArray &encodedUrl) override