From fad93b42c285ffb463e9494070f40d3b339d732f Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Thu, 16 Dec 2021 15:07:44 -0500 Subject: 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 Change-Id: Ib717ac8ac68ec457eaee74755dcf9d4f36b79d12 --- network/CMakeLists.txt | 2 +- network/network.cpp | 57 ++++++++++++++++++++++++++++++++++---------------- network/network.h | 12 +++-------- 3 files changed, 43 insertions(+), 28 deletions(-) (limited to 'network') diff --git a/network/CMakeLists.txt b/network/CMakeLists.txt index 162325c..b7ae7a1 100644 --- a/network/CMakeLists.txt +++ b/network/CMakeLists.txt @@ -14,7 +14,7 @@ add_library(qtappfw-network SHARED network.cpp target_include_directories(qtappfw-network PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") target_include_directories(qtappfw-network PUBLIC "${CMAKE_INSTALL_INCLUDEDIR}") -target_link_libraries(qtappfw-network qtappfw-core) +target_link_libraries(qtappfw-network Qt5::Qml) set_target_properties(qtappfw-network PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION 1 diff --git a/network/network.cpp b/network/network.cpp index 46045dc..937266f 100644 --- a/network/network.cpp +++ b/network/network.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2020 Konsulko Group + * Copyright (C) 2018-2021 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,14 @@ #include #include -#include "callmessage.h" -#include "eventmessage.h" -#include "responsemessage.h" -#include "messagefactory.h" -#include "messageengine.h" -#include "messageenginefactory.h" #include "networkadapter.h" #include "network.h" -Network::Network (QUrl &url, QQmlContext *context, QObject * parent) : +Network::Network (bool register_agent, QQmlContext *context, QObject * parent) : QObject(parent) { - m_mloop = MessageEngineFactory::getInstance().getMessageEngine(url); m_adapters.append(new WifiAdapter(this, context, parent)); - - QObject::connect(m_mloop.get(), &MessageEngine::connected, this, &Network::onConnected); - QObject::connect(m_mloop.get(), &MessageEngine::disconnected, this, &Network::onDisconnected); - QObject::connect(m_mloop.get(), &MessageEngine::messageReceived, this, &Network::onMessageReceived); - m_adapters.append(new WiredAdapter(this, context, parent)); } @@ -48,6 +36,7 @@ Network::~Network() void Network::connect(QString service) { +#if 0 std::unique_ptr msg = MessageFactory::getInstance().createOutboundMessage(MessageId::Call); if (!msg) return; @@ -59,10 +48,12 @@ void Network::connect(QString service) nmsg->createRequest("network-manager", "connect_service", parameter); m_mloop->sendMessage(std::move(msg)); +#endif } void Network::disconnect(QString service) { +#if 0 std::unique_ptr msg = MessageFactory::getInstance().createOutboundMessage(MessageId::Call); if (!msg) return; @@ -74,10 +65,12 @@ void Network::disconnect(QString service) nmsg->createRequest("network-manager", "disconnect_service", parameter); m_mloop->sendMessage(std::move(msg)); +#endif } void Network::remove(QString service) { +#if 0 std::unique_ptr msg = MessageFactory::getInstance().createOutboundMessage(MessageId::Call); if (!msg) return; @@ -89,6 +82,7 @@ void Network::remove(QString service) nmsg->createRequest("network-manager", "remove_service", parameter); m_mloop->sendMessage(std::move(msg)); +#endif } void Network::power(bool on, QString type) @@ -101,6 +95,7 @@ void Network::power(bool on, QString type) void Network::input(int id, QString passphrase) { +#if 0 std::unique_ptr msg = MessageFactory::getInstance().createOutboundMessage(MessageId::Call); if (!msg) return; @@ -114,10 +109,12 @@ void Network::input(int id, QString passphrase) nmsg->createRequest("network-manager", "agent_response", parameter); m_mloop->sendMessage(std::move(msg)); +#endif } void Network::configureAddress(QString service, QVariantList paramlist) { +#if 0 std::unique_ptr msg = MessageFactory::getInstance().createOutboundMessage(MessageId::Call); if (!msg) return; @@ -141,10 +138,12 @@ void Network::configureAddress(QString service, QVariantList paramlist) nmsg->createRequest("network-manager", "set_property", parameter); m_mloop->sendMessage(std::move(msg)); +#endif } void Network::configureNameServer(QString service, QVariantList paramlist) { +#if 0 std::unique_ptr msg = MessageFactory::getInstance().createOutboundMessage(MessageId::Call); if (!msg) return; @@ -167,10 +166,12 @@ void Network::configureNameServer(QString service, QVariantList paramlist) nmsg->createRequest("network-manager", "set_property", parameter); m_mloop->sendMessage(std::move(msg)); +#endif } void Network::getServices() { +#if 0 std::unique_ptr msg = MessageFactory::getInstance().createOutboundMessage(MessageId::Call); if (!msg) return; @@ -180,6 +181,7 @@ void Network::getServices() nmsg->createRequest("network-manager", "services", parameter); m_mloop->sendMessage(std::move(msg)); +#endif } AdapterIf* Network::findAdapter(QString type) @@ -193,32 +195,36 @@ AdapterIf* Network::findAdapter(QString type) void Network::updateServiceProperties(QJsonObject data) { +#if 0 QString service = data.value("service").toString(); QJsonObject properties = data.value("properties").toObject(); QList::iterator iter; for (iter = m_adapters.begin(); iter != m_adapters.end(); ++iter) (*iter)->updateProperties(service, properties); - +#endif } bool Network::addService(QJsonObject service) { +#if 0 QString id = service.value("service").toString(); QJsonObject properties = service.value("properties").toObject(); QList::iterator iter; for (iter = m_adapters.begin(); iter != m_adapters.end(); ++iter) if ((*iter)->addService(id, properties)) return true; - +#endif return false; } void Network::removeService(QJsonObject service) { +#if 0 QString id = service.value("service").toString(); QList::iterator iter; for (iter = m_adapters.begin(); iter != m_adapters.end(); ++iter) (*iter)->removeService(id); +#endif } void Network::addServices(QJsonArray services) @@ -229,6 +235,7 @@ void Network::addServices(QJsonArray services) void Network::scanServices(QString type) { +#if 0 std::unique_ptr msg = MessageFactory::getInstance().createOutboundMessage(MessageId::Call); if (!msg) return; @@ -239,10 +246,12 @@ void Network::scanServices(QString type) parameter.insert("technology", type); nmsg->createRequest("network-manager", "scan_services", parameter); m_mloop->sendMessage(std::move(msg)); +#endif } void Network::disableTechnology(QString type) { +#if 0 std::unique_ptr msg = MessageFactory::getInstance().createOutboundMessage(MessageId::Call); if (!msg) return; @@ -253,10 +262,12 @@ void Network::disableTechnology(QString type) parameter.insert("technology", type); nmsg->createRequest("network-manager", "disable_technology", parameter); m_mloop->sendMessage(std::move(msg)); +#endif } void Network::enableTechnology(QString type) { +#if 0 std::unique_ptr msg = MessageFactory::getInstance().createOutboundMessage(MessageId::Call); if (!msg) return; @@ -267,10 +278,12 @@ void Network::enableTechnology(QString type) parameter.insert("technology", type); nmsg->createRequest("network-manager", "enable_technology", parameter); m_mloop->sendMessage(std::move(msg)); +#endif } void Network::parseTechnologies(QJsonArray technologies) { +#if 0 for (auto value : technologies) { QJsonObject technology = value.toObject(); QJsonObject properties = technology.value("properties").toObject(); @@ -280,10 +293,12 @@ void Network::parseTechnologies(QJsonArray technologies) if (adapter) adapter->updateStatus(properties); } +#endif } void Network::getTechnologies() { +#if 0 std::unique_ptr msg = MessageFactory::getInstance().createOutboundMessage(MessageId::Call); if (!msg) return; @@ -293,10 +308,13 @@ void Network::getTechnologies() nmsg->createRequest("network-manager", "technologies", parameter); m_mloop->sendMessage(std::move(msg)); +#endif } +#if 0 void Network::processEvent(std::shared_ptr msg) { + std::shared_ptr emsg = std::static_pointer_cast(msg); QString ename = emsg->eventName(); QString eapi = emsg->eventApi(); @@ -363,9 +381,11 @@ void Network::onMessageReceived(std::shared_ptr msg) else if (msg->isReply()) processReply(msg); } +#endif void Network::onConnected() { +#if 0 QStringListIterator eventIterator(events); while (eventIterator.hasNext()) { @@ -379,12 +399,13 @@ void Network::onConnected() nmsg->createRequest("network-manager", "subscribe", parameter); m_mloop->sendMessage(std::move(msg)); } - +#endif getTechnologies(); } void Network::onDisconnected() { +#if 0 QStringListIterator eventIterator(events); while (eventIterator.hasNext()) { @@ -397,6 +418,6 @@ void Network::onDisconnected() nmsg->createRequest("network-manager", "unsubscribe", parameter); m_mloop->sendMessage(std::move(msg)); } - +#endif getTechnologies(); } diff --git a/network/network.h b/network/network.h index 07ff54d..3321a81 100644 --- a/network/network.h +++ b/network/network.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2020 Konsulko Group + * Copyright (C) 2018-2021 Konsulko Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,21 +20,19 @@ #include #include #include +#include #include #include #include "wifiadapter.h" #include "wiredadapter.h" -class MessageEngine; -class Message; - class Network : public QObject { Q_OBJECT public: - explicit Network(QUrl &url, QQmlContext *context, QObject * parent = Q_NULLPTR); + explicit Network(bool register_agent, QQmlContext *context, QObject * parent = Q_NULLPTR); virtual ~Network(); Q_INVOKABLE void connect(QString service); @@ -54,7 +52,6 @@ class Network : public QObject void searchResults(QString name); private: - std::shared_ptr m_mloop; QQmlContext *m_context; QList m_adapters; @@ -69,11 +66,8 @@ class Network : public QObject void enableTechnology(QString type); void parseTechnologies(QJsonArray technologies); void getTechnologies(); - void processEvent(std::shared_ptr msg); - void processReply(std::shared_ptr msg); // slots - void onMessageReceived(std::shared_ptr); void onConnected(); void onDisconnected(); -- cgit 1.2.3-korg