summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorRaquel Medina <raquel.medina@konsulko.com>2020-04-06 23:33:46 +0200
committerRaquel Medina <raquel.medina@konsulko.com>2020-04-07 05:58:52 +0200
commitb70605f802e7d9454629bb856dbe0157d47fb24a (patch)
tree42e109c34a21e090e03b7599937d3fe292315617 /app
parent228e9cea6cbb48025f5f5b38560edc4fc69d1d55 (diff)
use new libqtappfw Message hierarchy
Completes work to use new libqtappfw Message hierarchy started by commit 228e9cea6cbb48025f5f5b38560edc4fc69d1d55 : Rework TaskManager to use new libqtappfw Message hierarchy in 2 steps: i) add changes maintaining build compatibility with current and next libqtappfw versions; ii) complete changes once libqtappfw rolls to next version. This commit covers step ii). Bug-AGL: SPEC-3112 Signed-off-by: Raquel Medina <raquel.medina@konsulko.com> Change-Id: Ia6aff761067ddb05168681060590fecc4b4e8ff1
Diffstat (limited to 'app')
-rw-r--r--app/taskmanager.cpp13
-rw-r--r--app/taskmanager.h2
2 files changed, 13 insertions, 2 deletions
diff --git a/app/taskmanager.cpp b/app/taskmanager.cpp
index f880b6b..97c376f 100644
--- a/app/taskmanager.cpp
+++ b/app/taskmanager.cpp
@@ -6,6 +6,8 @@
#include <iostream>
#include <QtCore>
#include <responsemessage.h>
+#include <callmessage.h>
+#include <messagefactory.h>
#include "taskmanager.h"
TaskManager::TaskManager(QObject* parent) : QObject(parent), m_loop(nullptr) {
@@ -19,6 +21,7 @@ void TaskManager::open(const QUrl &bindingAddress)
{
m_loop = new MessageEngine(bindingAddress);
QObject::connect(m_loop, &MessageEngine::connected, this, &TaskManager::onConnected);
+ QObject::connect(m_loop, &MessageEngine::messageReceived, this, &TaskManager::onMessageReceived, Qt::QueuedConnection);
}
void TaskManager::onConnected()
@@ -51,7 +54,14 @@ void TaskManager::query() {
callService("get_netstat", QJsonValue());
}
-void TaskManager::callService(const QString&, QJsonValue) {
+void TaskManager::callService(const QString& command, QJsonValue value) {
+ std::unique_ptr<Message> message = MessageFactory::getInstance().createOutboundMessage(MessageId::Call);
+ if (!message)
+ return;
+ CallMessage* msg = static_cast<CallMessage*>(message.get());
+ msg->createRequest("taskmanager", command, value);
+ qDebug() << "sending message " << msg->serialize();
+ m_loop->sendMessage(std::move(message));
}
void TaskManager::onMessageReceived(std::shared_ptr<Message> message)
@@ -66,6 +76,7 @@ void TaskManager::onMessageReceived(std::shared_ptr<Message> message)
void TaskManager::ProcessResponse(std::shared_ptr<Message> message)
{
std::shared_ptr<ResponseMessage> rmsg = std::static_pointer_cast<ResponseMessage>(message);
+ qDebug() << "got message ";
QString msgType = rmsg->replyData()["msgType"].toString();
if (msgType.isNull())
return; // no type supplied, ignoring
diff --git a/app/taskmanager.h b/app/taskmanager.h
index 87ca4b2..8926639 100644
--- a/app/taskmanager.h
+++ b/app/taskmanager.h
@@ -35,7 +35,7 @@ signals:
private slots:
void query();
- void callService(const QString&, QJsonValue);
+ void callService(const QString& command, QJsonValue value);
void onConnected();
void onMessageReceived(std::shared_ptr<Message>);
void loadAvg();