summaryrefslogtreecommitdiffstats
path: root/responsemessage.h
diff options
context:
space:
mode:
authorRaquel Medina <raquel.medina@konsulko.com>2020-03-18 23:56:31 +0100
committerRaquel Medina <raquel.medina@konsulko.com>2020-03-23 14:02:28 +0100
commit0ed292d3ccf93c889734960676a321d1166d3f66 (patch)
treeb8d64d1685d2f4bf599ab3867a0d3ff557ff0479 /responsemessage.h
parent5c750385d02116a92fa4c120ccc26abb8267bc97 (diff)
rework message hierarchy
Rework message hierarchy with the final objective of splitting libqtappfw into several libraries. This commit carries the following changes: - Simplify message hierarchy, keeping abstract Message class, adding specialization for call and event messages, keeping ResponseMessage, and removing all module specific specializations. - Add MessageFactory class to create message objects. - Change messages life cycle: using smart pointers and removing QObject from message hierarchy (a Message is not a QObject anymore and thus 'deleteLater()' is not available). - Adapt all modules to use new message hierarchy. - Keep ResponseMessage original constructor to avoid breaking TaskManager. - Message constructors have been kept public, but will go private on a follow-up patch (once TaskManager class has been modified to use new MessageFactory). Bug-AGL: SPEC-3112 Signed-off-by: Raquel Medina <raquel.medina@konsulko.com> Change-Id: I3a7a6325209ddeca2293f1ac745371861a947bfb
Diffstat (limited to 'responsemessage.h')
-rw-r--r--responsemessage.h69
1 files changed, 56 insertions, 13 deletions
diff --git a/responsemessage.h b/responsemessage.h
index dd85150..edad3b1 100644
--- a/responsemessage.h
+++ b/responsemessage.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Konsulko Group
+ * Copyright (C) 2018-2020 Konsulko Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,26 +17,69 @@
#ifndef RESPONSEMESSAGE_H
#define RESPONSEMESSAGE_H
-#include <QObject>
#include "message.h"
class ResponseMessage : public Message
{
- Q_OBJECT
- public:
- explicit ResponseMessage(QByteArray request = nullptr);
- inline QString requestVerb() const
- {
- return m_request["verb"].toString();
- }
+ public:
+ //deprecated:
+ explicit ResponseMessage(QByteArray request = nullptr);
- inline QVariantMap requestParameters() const
- {
- return m_request["parameter"].toMap();
- }
+ explicit ResponseMessage(QJsonDocument data);
+
+ inline QString requestApi() const
+ {
+ return m_request["api"].toString();
+ }
+
+ inline QString requestVerb() const
+ {
+ return m_request["verb"].toString();
+ }
+
+ inline QVariantMap requestParameters() const
+ {
+ return m_request["parameter"].toMap();
+ }
+
+ inline QString replyStatus() const
+ {
+ return m_reply_status;
+ }
+
+ inline QString replyInfo() const
+ {
+ return m_reply_info;
+ }
+
+ inline QJsonObject replyData() const
+ {
+ return m_reply_data;
+ }
+
+ bool isEvent() override
+ {
+ return false;
+ }
+
+ bool isReply() override
+ {
+ return true;
+ }
+
+ bool setAdditionalData(QByteArray data);
+ bool copyCallId(unsigned int *id);
+
+ QByteArray serialize(QJsonDocument::JsonFormat format = QJsonDocument::Compact) override;
+
+ private:
+ QString m_reply_info, m_reply_status, m_reply_uuid;
+ unsigned int m_reply_callid;
+ QJsonObject m_reply_data;
+ QMap<QString, QVariant> m_request;
};
#endif // RESPONSEMESSAGE_H