10#include <private/qcore_unix_p.h>
14const char *
QQnxNavigatorPps::navigatorControlPath =
"/pps/services/navigator/control";
37 m_fd = qt_safe_open(navigatorControlPath, O_RDWR);
39 qWarning(
"QQNX: failed to open navigator pps, errno=%d", errno);
43 qCDebug(lcQpaQnxNavigator) <<
"successfully connected to Navigator. fd=" << m_fd;
50 if (!openPpsConnection())
53 return sendPpsMessage(
"invoke", encodedUrl);
56bool QQnxNavigatorPps::sendPpsMessage(
const QByteArray &message,
const QByteArray &data)
58 QByteArray ppsMessage =
"msg::" + message;
61 ppsMessage +=
"\ndat::" + data;
65 qCDebug(lcQpaQnxNavigator) <<
"sending PPS message:\n" << ppsMessage;
69 int bytes = qt_safe_write(m_fd, ppsMessage.constData(), ppsMessage.size());
70 if (Q_UNLIKELY(bytes == -1))
71 qFatal(
"QQNX: failed to write navigator pps, errno=%d", errno);
74 char buffer[ppsBufferSize];
79 bytes = qt_safe_read(m_fd, buffer, ppsBufferSize - 1);
80 if (Q_UNLIKELY(bytes == -1))
81 qFatal(
"QQNX: failed to read navigator pps, errno=%d", errno);
87 qCDebug(lcQpaQnxNavigator) <<
"received PPS message:\n" << buffer;
90 QByteArray ppsData(buffer);
91 QHash<QByteArray, QByteArray> responseFields;
92 parsePPS(ppsData, responseFields);
94 if (responseFields.contains(
"res") && responseFields.value(
"res") == message) {
95 if (Q_UNLIKELY(responseFields.contains(
"err"))) {
96 qCritical() <<
"navigator responded with error: " << responseFields.value(
"err");
104void QQnxNavigatorPps::parsePPS(
const QByteArray &ppsData, QHash<QByteArray, QByteArray> &messageFields)
106 qCDebug(lcQpaQnxNavigator) <<
"data=" << ppsData;
109 QList<QByteArray> lines = ppsData.split(
'\n');
112 if (Q_UNLIKELY(lines.empty() || lines.at(0) !=
"@control"))
113 qFatal(
"QQNX: unrecognized pps object, data=%s", ppsData.constData());
116 for (
int i = 1; i < lines.size(); i++) {
119 const QByteArray &attr = lines.at(i);
121 qCDebug(lcQpaQnxNavigator) <<
"attr=" << attr;
123 int firstColon = attr.indexOf(
':');
124 if (firstColon == -1) {
129 int secondColon = attr.indexOf(
':', firstColon + 1);
130 if (secondColon == -1) {
135 QByteArray key = attr.left(firstColon);
136 QByteArray value = attr.mid(secondColon + 1);
138 qCDebug(lcQpaQnxNavigator) <<
"key=" << key <<
"value=" << value;
139 messageFields[key] = value;
bool requestInvokeUrl(const QByteArray &encodedUrl) override
Combined button and popup list for selecting options.