8#include <QtCore/QByteArray>
9#include <QtCore/QDebug>
10#include <QtCore/QList>
11#include <QtCore/QSocketNotifier>
12#include <QtCore/private/qcore_unix_p.h>
31 m_eventHandler(eventHandler)
37 delete m_readNotifier;
43 qCDebug(lcQpaQnxNavigatorEvents) <<
"Navigator event notifier stopped";
48 qCDebug(lcQpaQnxNavigatorEvents) <<
"Navigator event notifier started";
52 m_fd = open(navigatorControlPath, O_RDWR);
54 qCDebug(lcQpaQnxNavigatorEvents,
"Failed to open navigator pps: %s", strerror(errno));
58 m_readNotifier =
new QSocketNotifier(m_fd, QSocketNotifier::Read);
59 connect(m_readNotifier, SIGNAL(activated(QSocketDescriptor)),
this, SLOT(readData()));
64 qCDebug(lcQpaQnxNavigatorEvents) << Q_FUNC_INFO <<
"data=" << ppsData;
67 QList<QByteArray> lines = ppsData.split(
'\n');
70 if (Q_UNLIKELY(lines.empty() || lines.at(0) !=
"@control"))
71 qFatal(
"QQNX: unrecognized pps object, data=%s", ppsData.constData());
74 for (
int i = 1; i < lines.size(); ++i) {
77 const QByteArray &attr = lines.at(i);
78 qCDebug(lcQpaQnxNavigatorEvents) << Q_FUNC_INFO <<
"attr=" << attr;
80 int firstColon = attr.indexOf(
':');
81 if (firstColon == -1) {
86 int secondColon = attr.indexOf(
':', firstColon + 1);
87 if (secondColon == -1) {
92 QByteArray key = attr.left(firstColon);
93 QByteArray value = attr.mid(secondColon + 1);
95 qCDebug(lcQpaQnxNavigatorEvents) << Q_FUNC_INFO <<
"key =" << key <<
"value =" << value;
100 else if (key ==
"dat")
102 else if (key ==
"id")
105 qFatal(
"QQNX: unrecognized pps attribute, attr=%s", key.constData());
112 QByteArray ppsData =
"res::";
116 if (!dat.isEmpty()) {
117 ppsData +=
"\ndat::";
122 qCDebug(lcQpaQnxNavigatorEvents) << Q_FUNC_INFO <<
"reply=" << ppsData;
126 int bytes = write(m_fd, ppsData.constData(), ppsData.size());
127 if (Q_UNLIKELY(bytes == -1))
128 qFatal(
"QQNX: failed to write navigator pps, errno=%d", errno);
133 qCDebug(lcQpaQnxNavigatorEvents) << Q_FUNC_INFO <<
"msg=" << msg <<
", dat=" << dat <<
", id=" << id;
136 if (msg ==
"orientationCheck") {
140 replyPPS(msg, id, response ?
"true" :
"false");
141 }
else if (msg ==
"orientation") {
143 replyPPS(msg, id,
"");
144 }
else if (msg ==
"SWIPE_DOWN") {
146 }
else if (msg ==
"exit") {
148 }
else if (msg ==
"windowActive") {
149 m_eventHandler->handleWindowGroupActivated(dat);
150 }
else if (msg ==
"windowInactive") {
151 m_eventHandler->handleWindowGroupDeactivated(dat);
157 qCDebug(lcQpaQnxNavigatorEvents) <<
"Reading navigator data";
160 char buffer[ppsBufferSize];
164 int bytes = qt_safe_read(m_fd, buffer, ppsBufferSize - 1);
165 if (Q_UNLIKELY(bytes == -1))
166 qFatal(
"QQNX: failed to read navigator pps, errno=%d", errno);
172 buffer[bytes] =
'\0';
175 QByteArray ppsData(buffer);
179 parsePPS(ppsData, msg, dat, id);
180 handleMessage(msg, dat, id);
void handleOrientationChange(int angle)
bool handleOrientationCheck(int angle)
~QQnxNavigatorEventNotifier()