From 0ed292d3ccf93c889734960676a321d1166d3f66 Mon Sep 17 00:00:00 2001 From: Raquel Medina Date: Wed, 18 Mar 2020 23:56:31 +0100 Subject: 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 Change-Id: I3a7a6325209ddeca2293f1ac745371861a947bfb --- responsemessage.h | 69 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 13 deletions(-) (limited to 'responsemessage.h') 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 #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 m_request; }; #endif // RESPONSEMESSAGE_H -- cgit 1.2.3-korg