diff --git a/CellFrameDashboardGUI/DapApplication.cpp b/CellFrameDashboardGUI/DapApplication.cpp index 31530e1a44bde7e2537cd90d36929c04564b6665..f0b6e889a0592919a9a258e98e8842691bf11537 100644 --- a/CellFrameDashboardGUI/DapApplication.cpp +++ b/CellFrameDashboardGUI/DapApplication.cpp @@ -18,12 +18,16 @@ DapApplication::DapApplication(int &argc, char **argv) qRegisterMetaType<DapNetwork::State>("DapNetwork::State"); connect(&DapServiceController::getInstance(), &DapServiceController::networksListReceived, this->networks(), &DapNetworksList::fill); - connect(&DapServiceController::getInstance(), &DapServiceController::networkStatusReceived, [this](const QVariant & a_stateJson){ - networks()->setNetworkProperties(a_stateJson.toMap()); + connect(&DapServiceController::getInstance(), &DapServiceController::networkStatusReceived, [this](const QVariant & a_stateMap){ + networks()->setNetworkProperties(a_stateMap.toMap()); }); connect(this->networks(), &DapNetworksList::networkAdded, [](DapNetwork* network){ - DapServiceController::getInstance().requestNetworkState(network->name()); + DapServiceController::getInstance().requestNetworkStatus(network->name()); + }); + + connect(&DapServiceController::getInstance(), &DapServiceController::newTargetNetworkStateReceived, [this](const QVariant & a_state){ + qDebug() << "newTargetNetworkStateReceived" << a_state; }); } diff --git a/CellFrameDashboardGUI/DapServiceController.cpp b/CellFrameDashboardGUI/DapServiceController.cpp index f3f598666630554f599d890231180feb01ba9f47..633bccd83e723578fa5fd5f6fae9a1a0d39f2bc5 100644 --- a/CellFrameDashboardGUI/DapServiceController.cpp +++ b/CellFrameDashboardGUI/DapServiceController.cpp @@ -1,5 +1,7 @@ #include "DapServiceController.h" +#include "DapNetwork.h" + /// Standard constructor. /// @param apParent Parent. DapServiceController::DapServiceController(QObject *apParent) @@ -62,9 +64,19 @@ QString DapServiceController::getCurrentChain() const return (m_sCurrentNetwork == "private") ? "gdb" : "plasma"; } -void DapServiceController::requestNetworkState(QString a_networkName) +void DapServiceController::requestNetworkStatus(QString a_networkName) +{ + this->requestToService("DapGetNetworkStatusCommand", a_networkName); +} + +void DapServiceController::changeNetworkStateToOffline(QString a_networkName) +{ + this->requestToService("DapGetNetworkStatusCommand", a_networkName, "offline"); +} + +void DapServiceController::changeNetworkStateToOnline(QString a_networkName) { - this->requestToService("DapGetListNetworksCommand", a_networkName); + this->requestToService("DapNetworkGoToCommand", a_networkName, "online"); } /// Get an instance of a class. @@ -135,6 +147,8 @@ void DapServiceController::registerCommand() m_transceivers.append(qMakePair(dynamic_cast<DapAbstractCommand*>(m_DAPRpcSocket->addService(new DapGetListNetworksCommand("DapGetListNetworksCommand", m_DAPRpcSocket))), QString("networksListReceived"))); // The command to get a network status m_transceivers.append(qMakePair(dynamic_cast<DapAbstractCommand*>(m_DAPRpcSocket->addService(new DapGetNetworkStatusCommand("DapGetNetworkStatusCommand", m_DAPRpcSocket))), QString("networkStatusReceived"))); + // The command to change network state + m_transceivers.append(qMakePair(dynamic_cast<DapAbstractCommand*>(m_DAPRpcSocket->addService(new DapNetworkGoToCommand("DapNetworkGoToCommand", m_DAPRpcSocket))), QString("newTargetNetworkStateReceived"))); m_transceivers.append(qMakePair(dynamic_cast<DapAbstractCommand*>(m_DAPRpcSocket->addService(new DapGetWalletAddressesCommand("DapGetWalletAddressesCommand", m_DAPRpcSocket))), QString("walletAddressesReceived"))); diff --git a/CellFrameDashboardGUI/DapServiceController.h b/CellFrameDashboardGUI/DapServiceController.h index ccf39f5e2d6e008fef4e3bb02d52a7cdd786b7ab..885790d7ae647950a2b37b740f9ae24591d2a925 100644 --- a/CellFrameDashboardGUI/DapServiceController.h +++ b/CellFrameDashboardGUI/DapServiceController.h @@ -19,6 +19,7 @@ #include "handlers/DapAddWalletCommand.h" #include "handlers/DapGetWalletsInfoCommand.h" #include "handlers/DapGetNetworkStatusCommand.h" +#include "handlers/DapNetworkGoToCommand.h" #include "handlers/DapGetListNetworksCommand.h" #include "handlers/DapExportLogCommand.h" #include "handlers/DapGetWalletAddressesCommand.h" @@ -112,7 +113,9 @@ public: Q_INVOKABLE QString getCurrentChain() const; public slots: - void requestNetworkState(QString a_networkName); + void requestNetworkStatus(QString a_networkName); + void changeNetworkStateToOnline(QString a_networkName); + void changeNetworkStateToOffline(QString a_networkName); signals: /// The signal is emitted when the Brand company property changes. @@ -147,6 +150,7 @@ signals: void networksListReceived(const QVariant& networkList); void networkStatusReceived(const QVariant& networkStatus); + void newTargetNetworkStateReceived(const QVariant& targetStateString); void walletAddressesReceived(const QVariant& walletAddresses); diff --git a/CellFrameDashboardService/DapServiceController.cpp b/CellFrameDashboardService/DapServiceController.cpp index b7753a0d6ba488941eb1eeb5bba1fa8e172d7f5c..9e0394c207b87bc98720039a5027491ccab579d7 100755 --- a/CellFrameDashboardService/DapServiceController.cpp +++ b/CellFrameDashboardService/DapServiceController.cpp @@ -66,6 +66,8 @@ void DapServiceController::registerCommand() m_pServer->addService(new DapGetListNetworksCommand("DapGetListNetworksCommand", m_pServer, CLI_PATH)); // The command to get a network status m_pServer->addService(new DapGetNetworkStatusCommand("DapGetNetworkStatusCommand", m_pServer, CLI_PATH)); + // The command to get a network status + m_pServer->addService(new DapNetworkGoToCommand("DapNetworkGoToCommand", m_pServer, CLI_PATH)); // Saving the file with the logs m_pServer->addService(new DapExportLogCommand("DapExportLogCommand", m_pServer)); diff --git a/CellFrameDashboardService/DapServiceController.h b/CellFrameDashboardService/DapServiceController.h index 3c242b7a5e7174fd4198c4f05418ac1fe77c5d9c..3970277d58faeabb54cb0dfaf6b396456006df32 100755 --- a/CellFrameDashboardService/DapServiceController.h +++ b/CellFrameDashboardService/DapServiceController.h @@ -30,6 +30,7 @@ typedef class DapRpcLocalServer DapUiService; #include "handlers/DapAddWalletCommand.h" #include "handlers/DapGetListNetworksCommand.h" #include "handlers/DapGetNetworkStatusCommand.h" +#include "handlers/DapNetworkGoToCommand.h" #include "handlers/DapGetWalletsInfoCommand.h" #include "handlers/DapGetWalletAddressesCommand.h" #include "handlers/DapExportLogCommand.h" diff --git a/cellframe-ui-sdk b/cellframe-ui-sdk index edd63bd392ec870bea6bc7d37708b46320529c20..2d2759312365ec355e82384c3fb8ccf64ca9abfa 160000 --- a/cellframe-ui-sdk +++ b/cellframe-ui-sdk @@ -1 +1 @@ -Subproject commit edd63bd392ec870bea6bc7d37708b46320529c20 +Subproject commit 2d2759312365ec355e82384c3fb8ccf64ca9abfa