summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2021-12-16 15:07:44 -0500
committerScott Murray <scott.murray@konsulko.com>2021-12-16 16:03:51 -0500
commitfad93b42c285ffb463e9494070f40d3b339d732f (patch)
tree6ae60914c578bd34b8ebbde9b271859e8b87ab65 /core
parentfe20f1b029f67dee1f790ade7a9114086f2abd38 (diff)
Initial rework to replace app framework usage
Changes: - Remove "core" code related to WebSocket messaging for the app framework. - Stub out hvac, navigation, network, and weather interfaces. This allows building several of the demo applications without modification for now. The network interface will definitely be reused to plumb in a new connman-glib library derived from the previous network binding. The others may potentially be reused to plumb in other new backend implementations. - Update the Network interface object constructor arguments to add a agent registration flag. This prepares for the connman-glib switch and means users will not need to be updated twice. - Update the Bluetooth interface to use a new bluez-glib library that is derived from the previous Bluetooth binding. This has been successfully tested with a the Settings application. - Remove signal-composer and voice API interface code as there are no direct replacements planned. The signal-composer interface was effectively exposing the binding events, so has little reuse potential with a new backend. For the voice interface, if some form of Alexa support becomes desirable, it can potentially be brought back for adaptation if required. - Disable compilation of the remaining interfaces for now. Some like map, pbap, and mediaplayer are very likely to be used as the basis for updating their associated applications, so keeping the code for the planned iterative development seems easier. - Updated copyright lines in all touched files. Bug-AGL: SPEC-4182 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: Ib717ac8ac68ec457eaee74755dcf9d4f36b79d12
Diffstat (limited to 'core')
-rw-r--r--core/CMakeLists.txt28
-rw-r--r--core/callmessage.cpp55
-rw-r--r--core/callmessage.h52
-rw-r--r--core/eventmessage.cpp67
-rw-r--r--core/eventmessage.h61
-rw-r--r--core/message.cpp79
-rw-r--r--core/message.h71
-rw-r--r--core/messageengine.cpp90
-rw-r--r--core/messageengine.h55
-rw-r--r--core/messageenginefactory.cpp39
-rw-r--r--core/messageenginefactory.h41
-rw-r--r--core/messagefactory.cpp39
-rw-r--r--core/messagefactory.h42
-rw-r--r--core/qtappfw-core.pc.in12
-rw-r--r--core/responsemessage.cpp101
-rw-r--r--core/responsemessage.h88
16 files changed, 0 insertions, 920 deletions
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
deleted file mode 100644
index 3102f3b..0000000
--- a/core/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-
-CONFIGURE_FILE("qtappfw-core.pc.in" "qtappfw-core.pc" @ONLY)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qtappfw-core.pc
- DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
-
-add_library(qtappfw-core SHARED message.cpp
- messagefactory.cpp
- messageengine.cpp
- messageenginefactory.cpp
- responsemessage.cpp
- callmessage.cpp
- eventmessage.cpp)
-
-target_include_directories(qtappfw-core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
-target_include_directories(qtappfw-core PUBLIC "${CMAKE_INSTALL_INCLUDEDIR}")
-
-target_link_libraries(qtappfw-core Qt5::WebSockets)
-
-set_target_properties(qtappfw-core PROPERTIES
- VERSION ${PROJECT_VERSION}
- SOVERSION 1
- PUBLIC_HEADER "message.h;messagefactory.h;messageengine.h;messageenginefactory.h;responsemessage.h;callmessage.h;eventmessage.h")
-
-
-install(TARGETS qtappfw-core
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qtappfw-core)
-
diff --git a/core/callmessage.cpp b/core/callmessage.cpp
deleted file mode 100644
index 1dfa72e..0000000
--- a/core/callmessage.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <QDebug>
-#include <QJsonArray>
-#include <QJsonDocument>
-#include <QJsonValue>
-
-#include "callmessage.h"
-#include "message.h"
-
-
-bool CallMessage::createRequest(QString api, QString verb, QJsonValue parameter)
-{
- if (!m_request.isEmpty()){
- qWarning("Message instance has already been used. Cannot send another request.");
- return false;
- }
-
- m_request["msgid"] = static_cast<unsigned int>(MessageId::Call);
- m_request["callid"] = 0;
- m_request["api"] = api;
- m_request["verb"] = verb;
- m_request["parameter"] = parameter;
-
- m_init = true;
-
- return m_init;
-}
-
-QByteArray CallMessage::serialize(QJsonDocument::JsonFormat format)
-{
- QJsonArray array;
- array.append(m_request["msgid"].toInt());
- array.append(m_request["callid"].toInt());
- array.append(m_request["api"].toString() + "/" + m_request["verb"].toString());
- array.append(m_request["parameter"].toJsonValue());
-
- m_jdoc.setArray(array);
-
- return m_jdoc.toJson(format).data();
-}
diff --git a/core/callmessage.h b/core/callmessage.h
deleted file mode 100644
index d08024e..0000000
--- a/core/callmessage.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CALLMESSAGE_H
-#define CALLMESSAGE_H
-
-#include "message.h"
-
-
-class CallMessage : public Message
-{
- public:
- bool createRequest(QString api, QString verb, QJsonValue parameter = "None");
-
- bool isEvent() override
- {
- return false;
- }
-
- bool isReply() override
- {
- return false;
- }
-
- void updateCallId(unsigned int id) override
- {
- m_request["callid"] = qint32(id);
- }
-
- QByteArray serialize(QJsonDocument::JsonFormat format = QJsonDocument::Compact) override;
-
- private:
- QMap<QString, QVariant> m_request;
-
- CallMessage() = default;
- friend class MessageFactory;
-};
-
-#endif // CALLMESSAGE_H
diff --git a/core/eventmessage.cpp b/core/eventmessage.cpp
deleted file mode 100644
index 818830f..0000000
--- a/core/eventmessage.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <QDebug>
-#include <QJsonArray>
-#include <QJsonDocument>
-#include <QJsonObject>
-#include <QJsonValue>
-
-#include "eventmessage.h"
-
-EventMessage::EventMessage(QJsonDocument content): Message()
-{
- QJsonArray msg = content.array();
- if (!msg[2].isObject()) {
- qWarning("Invalid appfw payload: no JSON object");
- return;
- }
-
- //deserialize:
- QJsonObject payload = msg[2].toObject();
-
- auto data_iter = payload.find("data");
- m_event_data = data_iter.value().toObject();
-
- auto event_iter = payload.find("event");
- auto event_string = event_iter.value().toString();
- if (event_string.isEmpty()) {
- qWarning("Invalid appfw event message: empty event name");
- return;
- }
- QStringList event_strings = event_string.split(QRegExp("/"));
- if (event_strings.size() != 2) {
- qWarning("Invalid appfw event message: malformed event name");
- return;
- }
- m_event_api = event_strings[0];
- m_event_name = event_strings[1];
- m_init = true;
-}
-
-QByteArray EventMessage::serialize(QJsonDocument::JsonFormat format)
-{
- QJsonArray array;
- array.append(static_cast<int>(MessageId::Event));
- array.append(0); //unused field
- array.append(m_event_api + "/" + m_event_name);
- array.append(m_event_data);
-
- QJsonDocument jdoc;
- jdoc.setArray(array);
-
- return jdoc.toJson(format).data();
-}
diff --git a/core/eventmessage.h b/core/eventmessage.h
deleted file mode 100644
index 133574c..0000000
--- a/core/eventmessage.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef EVENTMESSAGE_H
-#define EVENTMESSAGE_H
-
-#include "message.h"
-
-
-class EventMessage : public Message
-{
- public:
- inline QString eventApi() const
- {
- return m_event_api;
- }
-
- inline QString eventName() const
- {
- return m_event_name;
- }
-
- inline QJsonObject eventData() const
- {
- return m_event_data;
- }
-
- bool isEvent() override
- {
- return true;
- }
-
- bool isReply() override
- {
- return false;
- }
-
- QByteArray serialize(QJsonDocument::JsonFormat format = QJsonDocument::Compact) override;
-
- private:
- QString m_event_api, m_event_name;
- QJsonObject m_event_data;
-
- explicit EventMessage(QJsonDocument data);
- friend class MessageFactory;
-};
-
-#endif // EVENTMESSAGE_H
diff --git a/core/message.cpp b/core/message.cpp
deleted file mode 100644
index 1865f14..0000000
--- a/core/message.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2017-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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <QDebug>
-#include <QJsonArray>
-#include <QJsonDocument>
-#include <QWebSocket>
-
-#include "message.h"
-
-MessageId Message::isValid(QJsonDocument candidate)
-{
- MessageId id = MessageId::Invalid;
-
- // Validate message is array
- if (!candidate.isArray()) {
- qWarning("Invalid appfw message: not an array");
- return id;
- }
- QJsonArray msg = candidate.array();
-
- // Validate array is proper length
- if ((msg.size() < 3) || (msg.size() > 4)) {
- qWarning("Invalid appfw message: invalid array size");
- return id;
- }
-
- // Validate msgid type
- double msgid;
- if (msg[0].isDouble()) {
- msgid = msg[0].toDouble();
- } else {
- qWarning("Invalid appfw message: invalid msgid type");
- return id;
- }
-
- // Validate msgid element
- if ((msgid >= static_cast<double>(MessageId::Call)) && (msgid <= static_cast<double>(MessageId::Event)))
- id = static_cast<MessageId>(msgid);
-
- return id;
-}
-
-Message::Message()
- : m_init(false)
-{
-}
-
-QByteArray Message::serialize(QJsonDocument::JsonFormat format)
-{
- QByteArray dummy;
- return dummy;
- }
-
-QByteArray Message::send(QWebSocket& transport, unsigned int id)
-{
- QByteArray blob;
- qint64 size = 0;
- updateCallId(id);
- if (m_init)
- blob = serialize().data();
- if (!blob.isEmpty())
- size = transport.sendTextMessage(blob);
-
- return blob;
-}
diff --git a/core/message.h b/core/message.h
deleted file mode 100644
index acbbefd..0000000
--- a/core/message.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2017-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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef MESSAGE_H
-#define MESSAGE_H
-
-#include <memory>
-#include <QObject>
-#include <QMap>
-#include <QVariant>
-#include <QJsonDocument>
-#include <QJsonObject>
-
-enum class MessageId {
- Invalid = 0,
- Call = 2,
- RetOk = 3,
- RetErr = 4,
- Event = 5,
-};
-
-class QWebSocket;
-
-class Message
-{
- public:
- Message();
- virtual bool setAdditionalData(QByteArray data)
- {
- return false;
- }
- QByteArray send(QWebSocket& transport, unsigned int callid);
-
- inline bool isComplete() const
- {
- return m_init;
- }
-
- virtual bool getCallId(unsigned int *id) const
- {
- return false;
- }
-
- static MessageId isValid(QJsonDocument );
-
- virtual bool isEvent() = 0;
- virtual bool isReply() = 0;
-
- protected:
- virtual void updateCallId(unsigned int id) {};
- virtual QByteArray serialize(QJsonDocument::JsonFormat format = QJsonDocument::Compact);
-
- bool m_init;
- QJsonDocument m_jdoc;
-};
-Q_DECLARE_METATYPE(std::shared_ptr<Message>)
-
-#endif // MESSAGE_H
diff --git a/core/messageengine.cpp b/core/messageengine.cpp
deleted file mode 100644
index 42fe95b..0000000
--- a/core/messageengine.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2017-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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <QJsonArray>
-#include <QDebug>
-
-#include "message.h"
-#include "messagefactory.h"
-#include "messageengine.h"
-
-
-MessageEngine::MessageEngine(const QUrl &url) :
- QObject(Q_NULLPTR),
- m_callid(0),
- m_url(url)
-{
- connect(&m_websocket, &QWebSocket::connected, this, &MessageEngine::onConnected);
- connect(&m_websocket, &QWebSocket::disconnected, this, &MessageEngine::onDisconnected);
-
- m_websocket.open(url);
-}
-
-bool MessageEngine::sendMessage(std::unique_ptr<Message> msg)
-{
- if (!msg)
- return false;
-
- unsigned int callid = m_callid++;
- QByteArray forkeeps = msg->send(m_websocket, callid);
- if (forkeeps.isEmpty())
- return false;
-
- std::lock_guard<std::mutex> localguard(m_mutex);
- m_calls.insert(callid, forkeeps);
-
- return true;
-}
-
-void MessageEngine::onConnected()
-{
- connect(&m_websocket, &QWebSocket::textMessageReceived, this, &MessageEngine::onTextMessageReceived);
- emit connected();
-}
-
-void MessageEngine::onDisconnected()
-{
- disconnect(&m_websocket, &QWebSocket::textMessageReceived, this, &MessageEngine::onTextMessageReceived);
- emit disconnected();
-}
-
-void MessageEngine::onTextMessageReceived(QString jsonStr)
-{
- jsonStr = jsonStr.simplified();
- QJsonDocument jdoc(QJsonDocument::fromJson(jsonStr.toUtf8()));
- if (jdoc.isEmpty()) {
- qWarning() << "Received invalid JSON: empty appfw message";
- return;
- }
-
- MessageId id = Message::isValid(jdoc);
- if (id == MessageId::Invalid) {
- qWarning() << "Received unknown message, discarding";
- return;
- }
-
- std::shared_ptr<Message> message = MessageFactory::getInstance().createInboundMessage(id, jdoc);
-
- unsigned int callid;
- if (message->isReply() && message->getCallId(&callid)) {
- message->setAdditionalData(m_calls[callid]);
- std::lock_guard<std::mutex> localguard(m_mutex);
- m_calls.remove(callid);
- }
-
- if (message->isComplete())
- emit messageReceived(message);
-}
diff --git a/core/messageengine.h b/core/messageengine.h
deleted file mode 100644
index 12aa5e9..0000000
--- a/core/messageengine.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2017-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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef MESSAGEENGINE_H
-#define MESSAGEENGINE_H
-
-#include <memory>
-#include <atomic>
-#include <mutex>
-#include <QUrl>
-#include <QWebSocket>
-
-#include "message.h"
-
-class MessageEngine : public QObject
-{
- Q_OBJECT
- public:
- bool sendMessage(std::unique_ptr<Message> message);
-
- Q_SIGNALS:
- void disconnected();
- void connected();
- void messageReceived(std::shared_ptr<Message> message);
-
- private Q_SLOTS:
- void onConnected();
- void onDisconnected();
- void onTextMessageReceived(QString message);
-
- private:
- QWebSocket m_websocket;
- std::mutex m_mutex;
- QMap<qint32, QByteArray> m_calls;
- QUrl m_url;
- std::atomic<unsigned int> m_callid;
-
- explicit MessageEngine(const QUrl &url);
- friend class MessageEngineFactory;
-};
-
-#endif // MESSAGEENGINE_H
diff --git a/core/messageenginefactory.cpp b/core/messageenginefactory.cpp
deleted file mode 100644
index 04fb741..0000000
--- a/core/messageenginefactory.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <unordered_map>
-#include <mutex>
-#include <QDebug>
-#include <QUrl>
-#include "messageenginefactory.h"
-#include "messageengine.h"
-
-std::shared_ptr<MessageEngine> MessageEngineFactory::getMessageEngine(const QUrl& url)
-{
- static std::unordered_map<QString, std::shared_ptr<MessageEngine>> lut;
- static std::mutex m;
-
- std::lock_guard<std::mutex> localguard(m);
- auto urlstr = url.toString();
- auto pme = lut[urlstr];
- if (!pme){
- pme = std::shared_ptr<MessageEngine>{new MessageEngine(url)};
- lut[urlstr] = pme;
- }
-
- return pme;
-}
diff --git a/core/messageenginefactory.h b/core/messageenginefactory.h
deleted file mode 100644
index 1ce107b..0000000
--- a/core/messageenginefactory.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef MESSAGEENGINEFACTORY_H
-#define MESSAGEENGINEFACTORY_H
-
-#include <memory>
-
-class MessageEngine;
-class QUrl;
-
-
-class MessageEngineFactory {
- public:
- static MessageEngineFactory& getInstance() {
- static MessageEngineFactory instance;
- return instance;
- }
- std::shared_ptr<MessageEngine> getMessageEngine(const QUrl &ur);
- MessageEngineFactory(MessageEngineFactory const&) = delete;
- void operator=(MessageEngineFactory const&) = delete;
-
- private:
- MessageEngineFactory() = default;
- ~MessageEngineFactory() = default;
-};
-
-#endif // MESSAGENGINEEFACTORY_H
diff --git a/core/messagefactory.cpp b/core/messagefactory.cpp
deleted file mode 100644
index 6740e25..0000000
--- a/core/messagefactory.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "messagefactory.h"
-#include "message.h"
-#include "responsemessage.h"
-#include "eventmessage.h"
-#include "callmessage.h"
-
-std::unique_ptr<Message> MessageFactory::createInboundMessage(MessageId id, QJsonDocument data)
-{
- std::unique_ptr<Message> msg(nullptr);
- if ((id == MessageId::RetOk) || (id == MessageId::RetErr))
- msg.reset(new ResponseMessage(data));
- else if (id == MessageId::Event)
- msg.reset(new EventMessage(data));
- return msg;
-}
-
-std::unique_ptr<Message> MessageFactory::createOutboundMessage(MessageId id)
-{
- std::unique_ptr<Message> msg(nullptr);
- if (id == MessageId::Call)
- msg.reset(new CallMessage());
- return msg;
-}
diff --git a/core/messagefactory.h b/core/messagefactory.h
deleted file mode 100644
index f826483..0000000
--- a/core/messagefactory.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef MESSAGEFACTORY_H
-#define MESSAGEFACTORY_H
-
-#include <memory>
-#include <QJsonDocument>
-
-class Message;
-enum class MessageId;
-
-class MessageFactory {
- public:
- static MessageFactory& getInstance() {
- static MessageFactory instance;
- return instance;
- }
- std::unique_ptr<Message> createInboundMessage(MessageId id, QJsonDocument content);
- std::unique_ptr<Message> createOutboundMessage(MessageId);
- MessageFactory(MessageFactory const&) = delete;
- void operator=(MessageFactory const&) = delete;
-
- private:
- MessageFactory() = default;
- ~MessageFactory() = default;
-};
-
-#endif // MESSAGEFACTORY_H
diff --git a/core/qtappfw-core.pc.in b/core/qtappfw-core.pc.in
deleted file mode 100644
index bfef2e0..0000000
--- a/core/qtappfw-core.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=@DEST_DIR@
-exec_prefix=${prefix}
-libdir=${prefix}/lib
-includedir=${prefix}/include
-
-Name: qtappfw-core
-Description: Library wrapping AGL AppFW messages and bindings in Qt objects
-Version: 1.0.0
-
-Requires: Qt5WebSockets
-Libs: -L${libdir} -lqtappfw-core
-Cflags: -I${includedir}/qtappfw-core
diff --git a/core/responsemessage.cpp b/core/responsemessage.cpp
deleted file mode 100644
index 9f8e6f2..0000000
--- a/core/responsemessage.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <QDebug>
-#include <QJsonArray>
-#include <QJsonDocument>
-#include <QJsonObject>
-#include <QJsonValue>
-
-#include "responsemessage.h"
-
-
-ResponseMessage::ResponseMessage(QJsonDocument content)
-{
- m_jdoc = content;
- QJsonArray msg = content.array();
- if (!msg[2].isObject()) {
- qWarning("Invalid appfw payload: no JSON object");
- return;
- }
-
- //deserialize:
- auto callid = msg[1].toString().toInt();
- QJsonObject payload = msg[2].toObject();
-
- auto request_iter = payload.find("request");
- auto request = request_iter.value().toObject();
- if (request.empty()) {
- qWarning("Invalid appfw reply message: empty request data");
- return;
- }
-
- auto status_iter = request.find("status");
- auto info_iter = request.find("info");
- auto response_iter = payload.find("response");
- auto response = response_iter.value().toObject();
- m_reply_status = status_iter.value().toString();
- m_reply_info = info_iter.value().toString();
- m_reply_data = response;
- m_reply_callid = callid;
- m_init = false; //not complete yet, missing matching request data
-}
-
-bool ResponseMessage::setAdditionalData(QByteArray data)
-{
- QJsonDocument jdoc(QJsonDocument::fromJson(data));
- if (!jdoc.isArray()) {
- qWarning("Invalid data: not an array");
- return false;
- }
-
- QJsonArray content = jdoc.array();
- if (content.size() != 4) {
- qWarning("Invalid data: invalid array size");
- return false;
- }
-
- QStringList api_str_list = content[2].toString().split(QRegExp("/"));
- m_request["msgid"] = content.at(0);
- m_request["callid"] = content.at(1);
- m_request["api"] = api_str_list[0];
- m_request["verb"] = api_str_list[1];
- m_request["parameter"] = content.at(3);
- m_init = true;
- return true;
-}
-
-bool ResponseMessage::copyCallId(unsigned int *id)
-{
- *id = m_reply_callid;
- return true;
-}
-
-QByteArray ResponseMessage::serialize(QJsonDocument::JsonFormat format)
-{
- QJsonArray array;
- (m_reply_status == "failed")?
- array.append(static_cast<int>(MessageId::RetErr)) :
- array.append(static_cast<int>(MessageId::RetOk));
- array.append(static_cast<int>(m_reply_callid));
- array.append(m_request["api"].toString() + "/" + m_request["verb"].toString());
- array.append(m_reply_data);
-
- QJsonDocument jdoc;
- jdoc.setArray(array);
-
- return jdoc.toJson(format).data();
-}
diff --git a/core/responsemessage.h b/core/responsemessage.h
deleted file mode 100644
index af6bda5..0000000
--- a/core/responsemessage.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef RESPONSEMESSAGE_H
-#define RESPONSEMESSAGE_H
-
-
-#include "message.h"
-
-class ResponseMessage : public Message
-{
-
-
- public:
- 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 getCallId(unsigned int *id) const override
- {
- *id = m_reply_callid;
- return true;
- }
- bool isEvent() override
- {
- return false;
- }
-
- bool isReply() override
- {
- return true;
- }
-
- bool setAdditionalData(QByteArray data) override;
- 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;
-
- explicit ResponseMessage(QJsonDocument data);
- friend class MessageFactory;
-};
-
-#endif // RESPONSEMESSAGE_H