From 3f189c430b034f7d7a083e27f655e373d716c118 Mon Sep 17 00:00:00 2001 From: Romain LE JEUNE Date: Fri, 29 Jul 2022 22:38:27 +0200 Subject: [PATCH] GODT-1753: implement reset [skip-ci] --- internal/frontend/bridge-gui/GRPC/GRPCClient.cpp | 9 +++++++++ internal/frontend/bridge-gui/GRPC/GRPCClient.h | 1 + internal/frontend/bridge-gui/QMLBackend.cpp | 2 +- internal/frontend/grpc/service.go | 7 +++++++ internal/frontend/grpc/service_methods.go | 4 ++++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/internal/frontend/bridge-gui/GRPC/GRPCClient.cpp b/internal/frontend/bridge-gui/GRPC/GRPCClient.cpp index 7ec08148..3a91b084 100644 --- a/internal/frontend/bridge-gui/GRPC/GRPCClient.cpp +++ b/internal/frontend/bridge-gui/GRPC/GRPCClient.cpp @@ -388,6 +388,15 @@ grpc::Status GRPCClient::restart() return stub_->Restart(&ctx, empty, &empty); } +//**************************************************************************************************************************************************** +/// \return The status for the gRPC call. +//**************************************************************************************************************************************************** +grpc::Status GRPCClient::triggerReset() +{ + grpc::ClientContext ctx; + return stub_->TriggerReset(&ctx, empty, &empty); +} + //**************************************************************************************************************************************************** /// \param[in] port The port to check. diff --git a/internal/frontend/bridge-gui/GRPC/GRPCClient.h b/internal/frontend/bridge-gui/GRPC/GRPCClient.h index 20e932b5..0721f307 100644 --- a/internal/frontend/bridge-gui/GRPC/GRPCClient.h +++ b/internal/frontend/bridge-gui/GRPC/GRPCClient.h @@ -64,6 +64,7 @@ public: // member functions. grpc::Status reportBug(QString const &description, QString const &address, QString const &emailClient, bool includeLogs); ///< Performs the 'ReportBug' gRPC call. grpc::Status quit(); ///< Perform the "Quit" gRPC call. grpc::Status restart(); ///< Performs the Restart gRPC call. + grpc::Status triggerReset(); ///< Performs the triggerReset gRPC call. grpc::Status isPortFree(qint32 port, bool &outFree); ///< Performs the 'IsPortFree' call. grpc::Status showOnStartup(bool &outValue); ///< Performs the 'ShowOnStartup' call. grpc::Status showSplashScreen(bool &outValue); ///< Performs the 'ShowSplashScreen' call. diff --git a/internal/frontend/bridge-gui/QMLBackend.cpp b/internal/frontend/bridge-gui/QMLBackend.cpp index 23233b72..355edcc4 100644 --- a/internal/frontend/bridge-gui/QMLBackend.cpp +++ b/internal/frontend/bridge-gui/QMLBackend.cpp @@ -327,5 +327,5 @@ void QMLBackend::installUpdate() //**************************************************************************************************************************************************** void QMLBackend::triggerReset() { - app().log().error(QString("%1() is not implemented.").arg(__FUNCTION__)); + logGRPCCallStatus(app().grpc().triggerReset(), "triggerReset"); } diff --git a/internal/frontend/grpc/service.go b/internal/frontend/grpc/service.go index 3f1e81a8..cca85cb4 100644 --- a/internal/frontend/grpc/service.go +++ b/internal/frontend/grpc/service.go @@ -338,6 +338,13 @@ func (s *Service) restart() { s.log.Error("Restart is not implemented") // TO-DO GODT-1671 implement restart. } +func (s *Service) triggerReset() { + defer func() { + _ = s.SendEvent(NewResetFinishedEvent()) + }() + s.bridge.FactoryReset() +} + func (s *Service) checkUpdate() { version, err := s.updater.Check() if err != nil { diff --git a/internal/frontend/grpc/service_methods.go b/internal/frontend/grpc/service_methods.go index 1f7dba3f..76b528e0 100644 --- a/internal/frontend/grpc/service_methods.go +++ b/internal/frontend/grpc/service_methods.go @@ -188,6 +188,10 @@ func (s *Service) GoOs(context.Context, *emptypb.Empty) (*wrapperspb.StringValue func (s *Service) TriggerReset(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { s.log.Info("TriggerReset") + go func() { + defer s.panicHandler.HandlePanic() + s.triggerReset() + }() return nil, ErrNotImplemented }