diff options
author | Javier <dev.git@javispedro.com> | 2015-12-14 01:52:17 +0100 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2015-12-14 01:52:17 +0100 |
commit | 702e018ca9e780bb076033ce5d1d370d4eb7319e (patch) | |
tree | 2012493213c630d7281718aadd1a6fa9a2c92885 /hostmanagerconn.cc | |
parent | ce8a092a235c8d59f01631c80786f920eb6a777b (diff) | |
download | sapd-702e018ca9e780bb076033ce5d1d370d4eb7319e.tar.gz sapd-702e018ca9e780bb076033ce5d1d370d4eb7319e.zip |
properly handle data frames with sequence numbers
Diffstat (limited to 'hostmanagerconn.cc')
-rw-r--r-- | hostmanagerconn.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/hostmanagerconn.cc b/hostmanagerconn.cc index e4f5edc..b8d1d31 100644 --- a/hostmanagerconn.cc +++ b/hostmanagerconn.cc @@ -26,7 +26,7 @@ void HostManagerConn::sendMessage(const QJsonObject &msg) QJsonDocument doc(msg); QByteArray data = doc.toJson(QJsonDocument::Compact); qDebug() << "Send JSON:" << data; - _socket->send(QByteArray(3,0) + doc.toJson(QJsonDocument::Compact)); + _socket->send(doc.toJson(QJsonDocument::Compact)); } void HostManagerConn::handleMessage(const QJsonObject &msg) @@ -75,11 +75,13 @@ void HostManagerConn::performTimeSync() msg["usingCamera"] = QLatin1String("false"); msg["safety_cam"] = QLatin1String("0"); - msg["locale"] = QLocale::system().name(); // ie es_ES - msg["data1224"] = QLatin1String("24"); // TODO + QLocale l = QLocale::system(); + msg["locale"] = l.name(); // i.e. es_ES + msg["data1224"] = l.timeFormat().contains('a', Qt::CaseInsensitive) ? QLatin1String("12") : QLatin1String("24"); msg["dateformat"] = QLocale::system().dateFormat(QLocale::ShortFormat); #if SAILFISH + // QTimeZone does not seem to work on Sailfish; use timed. msg["timezone"] = monitor->timezone(); #else msg["timezone"] = QString::fromLatin1(QTimeZone::systemTimeZoneId()); @@ -159,13 +161,11 @@ void HostManagerConn::handleMessageReceived() { QByteArray data = _socket->receive(); - if (data.size() < 5) { + if (data.size() < 4) { qWarning() << "Invalid HostManager message received"; return; } - data.remove(0, 3); // What are those first three bytes??? They seem to be always NUL. - qDebug() << "Got JSON:" << QString::fromUtf8(data); QJsonParseError error; |