48 #include <QtCore/private/qcore_unix_p.h> 52 #include <QSocketNotifier> 57 #include <sys/types.h> 60 #define NAV_CONTROL_PATH "/pps/services/navigator/control" 61 #define PPS_BUFFER_SIZE 4096 65 mEventHandler(eventHandler),
78 #if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG) 79 qDebug() <<
"QBB: navigator event notifier stopped";
85 #if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG) 86 qDebug() <<
"QBB: navigator event notifier started";
93 qWarning(
"QBB: failed to open navigator pps, errno=%d",
errno);
103 #if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG) 104 qDebug() <<
"PPS: data=" << ppsData;
111 if (lines.
size() == 0 || lines.
at(0) !=
"@control")
115 for (
int i = 1; i < lines.
size(); i++) {
120 #if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG) 121 qDebug() <<
"PPS: attr=" << attr;
124 int firstColon = attr.
indexOf(
':');
125 if (firstColon == -1) {
130 int secondColon = attr.
indexOf(
':', firstColon + 1);
131 if (secondColon == -1) {
139 #if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG) 141 qDebug() <<
"PPS: val=" << value;
147 else if (key ==
"dat")
149 else if (key ==
"id")
164 ppsData +=
"\ndat::";
169 #if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG) 170 qDebug() <<
"PPS reply=" << ppsData;
177 qFatal(
"QBB: failed to write navigator pps, errno=%d",
errno);
182 #if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG) 183 qDebug() <<
"PPS: msg=" << msg <<
", dat=" << dat <<
", id=" << id;
187 if (msg ==
"orientationCheck") {
189 replyPPS(msg,
id, result ?
"true":
"false");
190 }
else if (msg ==
"orientation") {
193 }
else if (msg ==
"SWIPE_DOWN") {
195 }
else if (msg ==
"exit") {
197 }
else if (msg ==
"windowActive") {
199 }
else if (msg ==
"windowInactive") {
206 #if defined(QBBNAVIGATOREVENTNOTIFIER_DEBUG) 207 qDebug() <<
"QBB: reading navigator data";
217 qFatal(
"QBB: failed to read navigator pps, errno=%d",
errno);
223 buffer[bytes] =
'\0';
~QBBNavigatorEventNotifier()
void handleWindowGroupActivated(const QByteArray &id)
The QByteArray class provides an array of bytes.
QBBNavigatorEventHandler * mEventHandler
void handleWindowGroupDeactivated(const QByteArray &id)
static int qt_safe_close(int fd)
The QObject class is the base class of all Qt objects.
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
void parsePPS(const QByteArray &ppsData, QByteArray &msg, QByteArray &dat, QByteArray &id)
Q_CORE_EXPORT void qDebug(const char *,...)
static int qt_safe_open(const char *pathname, int flags, mode_t mode=0777)
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
const T & at(int i) const
Returns the item at index position i in the list.
Q_CORE_EXPORT void qWarning(const char *,...)
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
QBBNavigatorEventNotifier(QBBNavigatorEventHandler *eventHandler, QObject *parent=0)
const char * constData() const
Returns a pointer to the data stored in the byte array.
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays...
Q_CORE_EXPORT void qFatal(const char *,...)
void handleMessage(const QByteArray &msg, const QByteArray &dat, const QByteArray &id)
bool handleOrientationCheck(int angle)
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
int size() const
Returns the number of items in the list.
int size() const
Returns the number of bytes in this byte array.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
void replyPPS(const QByteArray &res, const QByteArray &id, const QByteArray &dat)
QSocketNotifier * mReadNotifier
void handleOrientationChange(int angle)
static qint64 qt_safe_read(int fd, void *data, qint64 maxlen)