From 64aec8ec9808de66dfc185dfb82fc9d6cd1f004c Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Fri, 11 Jul 2014 22:25:56 +0200 Subject: Sending the string as it is even if empty, but always \0 terminate all strings. Fixes empty string to get received. Also an empty subject does not occupy space on the pebble notification. --- daemon/watchconnector.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'daemon/watchconnector.cpp') diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp index ff64a02..955ba13 100644 --- a/daemon/watchconnector.cpp +++ b/daemon/watchconnector.cpp @@ -214,8 +214,9 @@ void WatchConnector::buildData(QByteArray &res, QStringList data) for (QString d : data) { QByteArray tmp = d.left(0xF0).toUtf8(); - res.append(tmp.length() & 0xFF); + res.append((tmp.length() + 1) & 0xFF); res.append(tmp); + res.append('\0'); } } @@ -249,10 +250,10 @@ QString WatchConnector::timeStamp() void WatchConnector::sendNotification(unsigned int lead, QString sender, QString data, QString subject) { QStringList tmp; - tmp.append(sender.isEmpty() ? " " : sender); - tmp.append(data.isEmpty() ? " " : data); + tmp.append(sender); + tmp.append(data); tmp.append(timeStamp()); - if (lead == 0) tmp.append(subject.isEmpty() ? " " : subject); + if (lead == 0) tmp.append(subject); QByteArray res = buildMessageData(lead, tmp); -- cgit v1.2.3