9#include <QtCore/QByteArray>
10#include <QtCore/QDebug>
11#include <QtCore/QList>
12#include <QtCore/QSocketNotifier>
13#include <QtCore/private/qcore_unix_p.h>
30 m_eventHandler(eventHandler)
36 delete m_readNotifier;
42 qCDebug(lcQpaQnxNavigatorEvents) <<
"Navigator event notifier stopped";
47 qCDebug(lcQpaQnxNavigatorEvents) <<
"Navigator event notifier started";
51 m_fd = open(navigatorControlPath, O_RDWR);
53 qCDebug(lcQpaQnxNavigatorEvents,
"Failed to open navigator pps: %s", strerror(errno));
57 m_readNotifier =
new QSocketNotifier(m_fd, QSocketNotifier::Read);
58 connect(m_readNotifier, SIGNAL(activated(QSocketDescriptor)),
this, SLOT(readData()));
63 qCDebug(lcQpaQnxNavigatorEvents) << Q_FUNC_INFO <<
"data=" << ppsData;
66 QList<QByteArray> lines = ppsData.split(
'\n');
69 if (Q_UNLIKELY(lines.empty() || lines.at(0) !=
"@control"))
70 qFatal(
"QQNX: unrecognized pps object, data=%s", ppsData.constData());
73 for (
int i = 1; i < lines.size(); ++i) {
76 const QByteArray &attr = lines.at(i);
77 qCDebug(lcQpaQnxNavigatorEvents) << Q_FUNC_INFO <<
"attr=" << attr;
79 int firstColon = attr.indexOf(
':');
80 if (firstColon == -1) {
85 int secondColon = attr.indexOf(
':', firstColon + 1);
86 if (secondColon == -1) {
91 QByteArray key = attr.left(firstColon);
92 QByteArray value = attr.mid(secondColon + 1);
94 qCDebug(lcQpaQnxNavigatorEvents) << Q_FUNC_INFO <<
"key =" << key <<
"value =" << value;
99 else if (key ==
"dat")
101 else if (key ==
"id")
104 qFatal(
"QQNX: unrecognized pps attribute, attr=%s", key.constData());
111 QByteArray ppsData =
"res::";
115 if (!dat.isEmpty()) {
116 ppsData +=
"\ndat::";
121 qCDebug(lcQpaQnxNavigatorEvents) << Q_FUNC_INFO <<
"reply=" << ppsData;
125 int bytes = write(m_fd, ppsData.constData(), ppsData.size());
126 if (Q_UNLIKELY(bytes == -1))
127 qFatal(
"QQNX: failed to write navigator pps, errno=%d", errno);
132 qCDebug(lcQpaQnxNavigatorEvents) << Q_FUNC_INFO <<
"msg=" << msg <<
", dat=" << dat <<
", id=" << id;
135 if (msg ==
"orientationCheck") {
139 replyPPS(msg, id, response ?
"true" :
"false");
140 }
else if (msg ==
"orientation") {
142 replyPPS(msg, id,
"");
143 }
else if (msg ==
"SWIPE_DOWN") {
145 }
else if (msg ==
"exit") {
147 }
else if (msg ==
"windowActive") {
148 m_eventHandler->handleWindowGroupActivated(dat);
149 }
else if (msg ==
"windowInactive") {
150 m_eventHandler->handleWindowGroupDeactivated(dat);
156 qCDebug(lcQpaQnxNavigatorEvents) <<
"Reading navigator data";
159 char buffer[ppsBufferSize];
163 int bytes = qt_safe_read(m_fd, buffer, ppsBufferSize - 1);
164 if (Q_UNLIKELY(bytes == -1))
165 qFatal(
"QQNX: failed to read navigator pps, errno=%d", errno);
171 buffer[bytes] =
'\0';
174 QByteArray ppsData(buffer);
178 parsePPS(ppsData, msg, dat, id);
179 handleMessage(msg, dat, id);
void handleOrientationChange(int angle)
bool handleOrientationCheck(int angle)
~QQnxNavigatorEventNotifier()