From 702e018ca9e780bb076033ce5d1d370d4eb7319e Mon Sep 17 00:00:00 2001 From: Javier Date: Mon, 14 Dec 2015 01:52:17 +0100 Subject: properly handle data frames with sequence numbers --- hostmanagerconn.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'hostmanagerconn.cc') 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; -- cgit v1.2.3