From ff1e7f3c9fb947ef1cd8a6077ab267e4b0006e24 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sun, 3 Aug 2025 00:13:43 -0400 Subject: [PATCH] refactor: ClientApp / ServerApp, remove do nothing updateStatus methods and calls --- src/lib/deskflow/ClientApp.cpp | 17 ----------------- src/lib/deskflow/ClientApp.h | 3 --- src/lib/deskflow/ServerApp.cpp | 17 ----------------- src/lib/deskflow/ServerApp.h | 2 -- 4 files changed, 39 deletions(-) diff --git a/src/lib/deskflow/ClientApp.cpp b/src/lib/deskflow/ClientApp.cpp index 3f102ce46..0fdeaa97a 100644 --- a/src/lib/deskflow/ClientApp.cpp +++ b/src/lib/deskflow/ClientApp.cpp @@ -190,16 +190,6 @@ deskflow::Screen *ClientApp::createScreen() #endif } -void ClientApp::updateStatus() const -{ - updateStatus(""); -} - -void ClientApp::updateStatus(const std::string_view &) const -{ - // do nothing -} - deskflow::Screen *ClientApp::openClientScreen() { deskflow::Screen *screen = createScreen(); @@ -238,7 +228,6 @@ void ClientApp::scheduleClientRestart(double retryTime) void ClientApp::handleClientConnected() const { LOG((CLOG_NOTE "connected to server")); - updateStatus(); } void ClientApp::handleClientFailed(const Event &e) @@ -246,7 +235,6 @@ void ClientApp::handleClientFailed(const Event &e) if ((++m_lastServerAddressIndex) < m_client->getLastResolvedAddressesCount()) { std::unique_ptr info(static_cast(e.getData())); - updateStatus(std::string("Failed to connect to server: ") + info->m_what + " Trying next address..."); LOG((CLOG_WARN "failed to connect to server=%s, trying next address", info->m_what.c_str())); if (!m_suspended) { scheduleClientRestart(s_retryTime); @@ -261,7 +249,6 @@ void ClientApp::handleClientRefused(const Event &e) { std::unique_ptr info(static_cast(e.getData())); - updateStatus(std::string("Failed to connect to server: ") + info->m_what); if (!args().m_restartable || !info->m_retry) { LOG((CLOG_ERR "failed to connect to server: %s", info->m_what.c_str())); getEvents()->addEvent(Event(EventTypes::Quit)); @@ -281,7 +268,6 @@ void ClientApp::handleClientDisconnected() } else if (!m_suspended) { scheduleClientRestart(s_retryTime); } - updateStatus(); } Client *ClientApp::openClient(const std::string &name, const NetworkAddress &address, deskflow::Screen *screen) @@ -345,12 +331,10 @@ bool ClientApp::startClient() m_client->connect(m_lastServerAddressIndex); - updateStatus(); return true; } catch (XScreenUnavailable &e) { LOG((CLOG_WARN "secondary screen unavailable: %s", e.what())); closeClientScreen(clientScreen); - updateStatus(std::string("secondary screen unavailable: ") + e.what()); retryTime = e.getRetryTime(); } catch (XScreenOpenFailure &e) { LOG((CLOG_CRIT "failed to start client: %s", e.what())); @@ -411,7 +395,6 @@ int ClientApp::mainLoop() // close down LOG((CLOG_DEBUG1 "stopping client")); stopClient(); - updateStatus(); LOG((CLOG_NOTE "stopped client")); return s_exitSuccess; diff --git a/src/lib/deskflow/ClientApp.h b/src/lib/deskflow/ClientApp.h index 812878d8f..d07d0fe97 100644 --- a/src/lib/deskflow/ClientApp.h +++ b/src/lib/deskflow/ClientApp.h @@ -62,9 +62,6 @@ public: // // Regular functions // - - void updateStatus() const; - void updateStatus(const std::string_view &) const; deskflow::Screen *openClientScreen(); void closeClientScreen(deskflow::Screen *screen); void handleClientRestart(const Event &, EventQueueTimer *vtimer); diff --git a/src/lib/deskflow/ServerApp.cpp b/src/lib/deskflow/ServerApp.cpp index 75a789232..a4d8a9989 100644 --- a/src/lib/deskflow/ServerApp.cpp +++ b/src/lib/deskflow/ServerApp.cpp @@ -203,7 +203,6 @@ void ServerApp::handleClientConnected(const Event &, ClientListener *listener) ClientProxy *client = listener->getNextClient(); if (client != nullptr) { m_server->adoptClient(client); - updateStatus(); } } @@ -245,16 +244,6 @@ void ServerApp::stopRetryTimer() } } -void ServerApp::updateStatus() const -{ - updateStatus(""); -} - -void ServerApp::updateStatus(const std::string_view &msg) const -{ - // do nothing -} - void ServerApp::closeClientListener(ClientListener *listen) { if (listen != nullptr) { @@ -379,13 +368,11 @@ bool ServerApp::initServer() m_serverScreen = serverScreen; m_primaryClient = primaryClient; m_serverState = Initialized; - updateStatus(); return true; } catch (XScreenUnavailable &e) { LOG((CLOG_WARN "primary screen unavailable: %s", e.what())); closePrimaryClient(primaryClient); closeServerScreen(serverScreen); - updateStatus(std::string("primary screen unavailable: ") + e.what()); retryTime = e.getRetryTime(); } catch (XScreenOpenFailure &e) { LOG((CLOG_CRIT "failed to start server: %s", e.what())); @@ -455,7 +442,6 @@ bool ServerApp::startServer() listener->setServer(m_server); m_server->setListener(listener); m_listener = listener; - updateStatus(); LOG((CLOG_NOTE "started server, waiting for clients")); m_serverState = Started; return true; @@ -466,7 +452,6 @@ bool ServerApp::startServer() LOG((CLOG_CRIT "cannot listen for clients: %s", e.what())); } closeClientListener(listener); - updateStatus(std::string("cannot listen for clients: ") + e.what()); } catch (XBase &e) { LOG((CLOG_CRIT "failed to start server: %s", e.what())); closeClientListener(listener); @@ -562,7 +547,6 @@ Server *ServerApp::openServer(ServerConfig &config, PrimaryClient *primaryClient { auto *server = new Server(config, primaryClient, m_serverScreen, getEvents(), args()); try { - getEvents()->addHandler(EventTypes::ServerDisconnected, server, [this](const auto &) { updateStatus(); }); getEvents()->addHandler(EventTypes::ServerScreenSwitched, server, [this](const auto &) { handleScreenSwitched(); }); } catch (std::bad_alloc &ba) { @@ -661,7 +645,6 @@ int ServerApp::mainLoop() getEvents()->removeHandler(EventTypes::ServerAppForceReconnect, getEvents()->getSystemTarget()); getEvents()->removeHandler(EventTypes::ServerAppReloadConfig, getEvents()->getSystemTarget()); cleanupServer(); - updateStatus(); LOG((CLOG_NOTE "stopped server")); return s_exitSuccess; diff --git a/src/lib/deskflow/ServerApp.h b/src/lib/deskflow/ServerApp.h index d21f29ee6..d6799b2f6 100644 --- a/src/lib/deskflow/ServerApp.h +++ b/src/lib/deskflow/ServerApp.h @@ -87,8 +87,6 @@ public: void handleClientConnected(const Event &e, ClientListener *listener); void closeServer(Server *server); void stopRetryTimer(); - void updateStatus() const; - void updateStatus(const std::string_view &msg) const; void closeClientListener(ClientListener *listen); void stopServer(); void closePrimaryClient(PrimaryClient *primaryClient);