diff options
Diffstat (limited to 'daemon/appmsgmanager.cpp')
| -rw-r--r-- | daemon/appmsgmanager.cpp | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/daemon/appmsgmanager.cpp b/daemon/appmsgmanager.cpp index eda1eb4..1a4a424 100644 --- a/daemon/appmsgmanager.cpp +++ b/daemon/appmsgmanager.cpp @@ -7,7 +7,8 @@ // TODO D-Bus server for non JS kit apps!!!! AppMsgManager::AppMsgManager(AppManager *apps, WatchConnector *watch, QObject *parent) - : QObject(parent), apps(apps), watch(watch), _lastTransactionId(0), _timeout(new QTimer(this)) + : QObject(parent), l(metaObject()->className()), apps(apps), + watch(watch), _lastTransactionId(0), _timeout(new QTimer(this)) { connect(watch, &WatchConnector::connectedChanged, this, &AppMsgManager::handleWatchConnectedChanged); @@ -45,7 +46,7 @@ AppMsgManager::AppMsgManager(AppManager *apps, WatchConnector *watch, QObject *p handleAckMessage(data, false); break; default: - logger()->warn() << "Unknown application message type:" << int(data.at(0)); + qCWarning(l) << "Unknown application message type:" << int(data.at(0)); break; } @@ -62,7 +63,7 @@ void AppMsgManager::send(const QUuid &uuid, const QVariantMap &data, const std:: trans.ackCallback = ackCallback; trans.nackCallback = nackCallback; - logger()->debug() << "Queueing appmsg" << trans.transactionId << "to" << trans.uuid + qCDebug(l) << "Queueing appmsg" << trans.transactionId << "to" << trans.uuid << "with dict" << trans.dict; _pending.enqueue(trans); @@ -104,7 +105,7 @@ void AppMsgManager::launchApp(const QUuid &uuid) WatchConnector::Dict dict; dict.insert(1, WatchConnector::launcherSTARTED); - logger()->debug() << "Sending message to launcher" << uuid << dict; + qCDebug(l) << "Sending message to launcher" << uuid << dict; QByteArray msg = buildPushMessage(++_lastTransactionId, uuid, dict); watch->sendMessage(WatchConnector::watchLAUNCHER, msg); @@ -115,7 +116,7 @@ void AppMsgManager::closeApp(const QUuid &uuid) WatchConnector::Dict dict; dict.insert(1, WatchConnector::launcherSTOPPED); - logger()->debug() << "Sending message to launcher" << uuid << dict; + qCDebug(l) << "Sending message to launcher" << uuid << dict; QByteArray msg = buildPushMessage(++_lastTransactionId, uuid, dict); watch->sendMessage(WatchConnector::watchLAUNCHER, msg); @@ -125,7 +126,7 @@ WatchConnector::Dict AppMsgManager::mapAppKeys(const QUuid &uuid, const QVariant { AppInfo info = apps->info(uuid); if (info.uuid() != uuid) { - logger()->warn() << "Unknown app GUID while sending message:" << uuid; + qCWarning(l) << "Unknown app GUID while sending message:" << uuid; } WatchConnector::Dict d; @@ -141,7 +142,7 @@ WatchConnector::Dict AppMsgManager::mapAppKeys(const QUuid &uuid, const QVariant if (ok) { d.insert(num, it.value()); } else { - logger()->warn() << "Unknown appKey" << it.key() << "for app with GUID" << uuid; + qCWarning(l) << "Unknown appKey" << it.key() << "for app with GUID" << uuid; } } } @@ -153,7 +154,7 @@ QVariantMap AppMsgManager::mapAppKeys(const QUuid &uuid, const WatchConnector::D { AppInfo info = apps->info(uuid); if (info.uuid() != uuid) { - logger()->warn() << "Unknown app GUID while sending message:" << uuid; + qCWarning(l) << "Unknown app GUID while sending message:" << uuid; } QVariantMap data; @@ -162,7 +163,7 @@ QVariantMap AppMsgManager::mapAppKeys(const QUuid &uuid, const WatchConnector::D if (info.hasAppKeyValue(it.key())) { data.insert(info.appKeyForValue(it.key()), it.value()); } else { - logger()->warn() << "Unknown appKey value" << it.key() << "for app with GUID" << uuid; + qCWarning(l) << "Unknown appKey value" << it.key() << "for app with GUID" << uuid; data.insert(QString::number(it.key()), it.value()); } } @@ -174,6 +175,7 @@ bool AppMsgManager::unpackPushMessage(const QByteArray &msg, quint8 *transaction { Unpacker u(msg); quint8 code = u.read<quint8>(); + Q_UNUSED(code); Q_ASSERT(code == WatchConnector::appmsgPUSH); *transaction = u.read<quint8>(); @@ -225,29 +227,29 @@ void AppMsgManager::handleLauncherPushMessage(const QByteArray &data) // Failed to parse! // Since we're the only one handling this endpoint, // all messages must be accepted - logger()->warn() << "Failed to parser LAUNCHER PUSH message"; + qCWarning(l) << "Failed to parser LAUNCHER PUSH message"; return; } if (!dict.contains(1)) { - logger()->warn() << "LAUNCHER message has no item in dict"; + qCWarning(l) << "LAUNCHER message has no item in dict"; return; } switch (dict.value(1).toInt()) { case WatchConnector::launcherSTARTED: - logger()->debug() << "App starting in watch:" << uuid; + qCDebug(l) << "App starting in watch:" << uuid; this->watch->sendMessage(WatchConnector::watchLAUNCHER, buildAckMessage(transaction)); emit appStarted(uuid); break; case WatchConnector::launcherSTOPPED: - logger()->debug() << "App stopping in watch:" << uuid; + qCDebug(l) << "App stopping in watch:" << uuid; this->watch->sendMessage(WatchConnector::watchLAUNCHER, buildAckMessage(transaction)); emit appStopped(uuid); break; default: - logger()->warn() << "LAUNCHER pushed unknown message:" << uuid << dict; + qCWarning(l) << "LAUNCHER pushed unknown message:" << uuid << dict; this->watch->sendMessage(WatchConnector::watchLAUNCHER, buildNackMessage(transaction)); break; @@ -261,16 +263,16 @@ void AppMsgManager::handlePushMessage(const QByteArray &data) WatchConnector::Dict dict; if (!unpackPushMessage(data, &transaction, &uuid, &dict)) { - logger()->warn() << "Failed to parse APP_MSG PUSH"; + qCWarning(l) << "Failed to parse APP_MSG PUSH"; watch->sendMessage(WatchConnector::watchAPPLICATION_MESSAGE, buildNackMessage(transaction)); return; } - logger()->debug() << "Received appmsg PUSH from" << uuid << "with" << dict; + qCDebug(l) << "Received appmsg PUSH from" << uuid << "with" << dict; QVariantMap msg = mapAppKeys(uuid, dict); - logger()->debug() << "Mapped dict" << msg; + qCDebug(l) << "Mapped dict" << msg; bool result; @@ -283,11 +285,11 @@ void AppMsgManager::handlePushMessage(const QByteArray &data) } if (result) { - logger()->debug() << "ACKing transaction" << transaction; + qCDebug(l) << "ACKing transaction" << transaction; watch->sendMessage(WatchConnector::watchAPPLICATION_MESSAGE, buildAckMessage(transaction)); } else { - logger()->info() << "NACKing transaction" << transaction; + qCDebug(l) << "NACKing transaction" << transaction; watch->sendMessage(WatchConnector::watchAPPLICATION_MESSAGE, buildNackMessage(transaction)); } @@ -296,26 +298,26 @@ void AppMsgManager::handlePushMessage(const QByteArray &data) void AppMsgManager::handleAckMessage(const QByteArray &data, bool ack) { if (data.size() < 2) { - logger()->warn() << "invalid ack/nack message size"; + qCWarning(l) << "invalid ack/nack message size"; return; } - const quint8 type = data[0]; + const quint8 type = data[0]; Q_UNUSED(type); const quint8 recv_transaction = data[1]; Q_ASSERT(type == WatchConnector::appmsgACK || type == WatchConnector::appmsgNACK); if (_pending.empty()) { - logger()->warn() << "received an ack/nack for transaction" << recv_transaction << "but no transaction is pending"; + qCWarning(l) << "received an ack/nack for transaction" << recv_transaction << "but no transaction is pending"; return; } PendingTransaction &trans = _pending.head(); if (trans.transactionId != recv_transaction) { - logger()->warn() << "received an ack/nack but for the wrong transaction"; + qCWarning(l) << "received an ack/nack but for the wrong transaction"; } - logger()->debug() << "Got " << (ack ? "ACK" : "NACK") << " to transaction" << trans.transactionId; + qCDebug(l) << "Got " << (ack ? "ACK" : "NACK") << " to transaction" << trans.transactionId; _timeout->stop(); @@ -351,7 +353,7 @@ void AppMsgManager::handleTimeout() Q_ASSERT(!_pending.empty()); PendingTransaction trans = _pending.dequeue(); - logger()->warn() << "timeout on appmsg transaction" << trans.transactionId; + qCWarning(l) << "timeout on appmsg transaction" << trans.transactionId; if (trans.nackCallback) { trans.nackCallback(); |
