diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index f9f62cc25..56d6c58c0 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -423,7 +423,7 @@ void Client::setupConnection() handleDisconnected(); }); m_events->addHandler(EventTypes::SocketStopRetry, m_stream->getEventTarget(), [this](const auto &) { - handleStopRetry(); + m_args.m_restartable = false; }); } @@ -645,8 +645,3 @@ void Client::bindNetworkInterface(IDataSocket *socket) const LOG((CLOG_WARN "operating system will select network interface automatically")); } } - -void Client::handleStopRetry() -{ - m_args.m_restartable = false; -} diff --git a/src/lib/client/Client.h b/src/lib/client/Client.h index 0a85bf9d8..b699448fd 100644 --- a/src/lib/client/Client.h +++ b/src/lib/client/Client.h @@ -179,7 +179,6 @@ private: void handleHello(); void handleSuspend(); void handleResume(); - void handleStopRetry(); void sendClipboardThread(void *); void bindNetworkInterface(IDataSocket *socket) const; diff --git a/src/lib/client/ServerProxy.cpp b/src/lib/client/ServerProxy.cpp index 689501e78..ab1970cc6 100644 --- a/src/lib/client/ServerProxy.cpp +++ b/src/lib/client/ServerProxy.cpp @@ -47,7 +47,9 @@ ServerProxy::ServerProxy(Client *client, deskflow::IStream *stream, IEventQueue m_events->addHandler(EventTypes::StreamInputReady, m_stream->getEventTarget(), [this](const auto &) { handleData(); }); - m_events->addHandler(EventTypes::ClipboardSending, this, [this](const auto &e) { handleClipboardSendingEvent(e); }); + m_events->addHandler(EventTypes::ClipboardSending, this, [this](const auto &e) { + ClipboardChunk::send(m_stream, e.getDataObject()); + }); // send heartbeat setKeepAliveRate(kKeepAliveRate); @@ -805,11 +807,6 @@ void ServerProxy::infoAcknowledgment() m_ignoreMouse = false; } -void ServerProxy::handleClipboardSendingEvent(const Event &event) -{ - ClipboardChunk::send(m_stream, event.getDataObject()); -} - void ServerProxy::secureInputNotification() { std::string app; diff --git a/src/lib/client/ServerProxy.h b/src/lib/client/ServerProxy.h index a74c9ba35..fe3afbfb8 100644 --- a/src/lib/client/ServerProxy.h +++ b/src/lib/client/ServerProxy.h @@ -96,7 +96,6 @@ private: void setOptions(); void queryInfo(); void infoAcknowledgment(); - void handleClipboardSendingEvent(const Event &event); void secureInputNotification(); void setServerLanguages(); void setActiveServerLanguage(const std::string &language); diff --git a/src/lib/deskflow/ServerApp.cpp b/src/lib/deskflow/ServerApp.cpp index ad2acd613..eb6815744 100644 --- a/src/lib/deskflow/ServerApp.cpp +++ b/src/lib/deskflow/ServerApp.cpp @@ -210,11 +210,6 @@ void ServerApp::handleClientConnected(const Event &, ClientListener *listener) } } -void ServerApp::handleClientsDisconnected() -{ - m_events->addEvent(Event(EventTypes::Quit)); -} - void ServerApp::closeServer(Server *server) { if (server == nullptr) { @@ -227,8 +222,10 @@ void ServerApp::closeServer(Server *server) // wait for clients to disconnect for up to timeout seconds double timeout = 3.0; EventQueueTimer *timer = m_events->newOneShotTimer(timeout, nullptr); - m_events->addHandler(EventTypes::Timer, timer, [this](const auto &) { handleClientsDisconnected(); }); - m_events->addHandler(EventTypes::ServerDisconnected, server, [this](const auto &) { handleClientsDisconnected(); }); + m_events->addHandler(EventTypes::Timer, timer, [this](const auto &) { m_events->addEvent(Event(EventTypes::Quit)); }); + m_events->addHandler(EventTypes::ServerDisconnected, server, [this](const auto &) { + m_events->addEvent(Event(EventTypes::Quit)); + }); m_events->loop(); @@ -557,7 +554,7 @@ Server *ServerApp::openServer(ServerConfig &config, PrimaryClient *primaryClient { auto *server = new Server(config, primaryClient, m_serverScreen, m_events, args()); try { - m_events->addHandler(EventTypes::ServerDisconnected, server, [this](const auto &) { handleNoClients(); }); + m_events->addHandler(EventTypes::ServerDisconnected, server, [this](const auto &) { updateStatus(); }); m_events->addHandler(EventTypes::ServerScreenSwitched, server, [this](const auto &e) { handleScreenSwitched(e); }); } catch (std::bad_alloc &ba) { @@ -568,11 +565,6 @@ Server *ServerApp::openServer(ServerConfig &config, PrimaryClient *primaryClient return server; } -void ServerApp::handleNoClients() -{ - updateStatus(); -} - void ServerApp::handleScreenSwitched(const Event &e) { // do nothing diff --git a/src/lib/deskflow/ServerApp.h b/src/lib/deskflow/ServerApp.h index 0858cc6c3..ffcad8ac4 100644 --- a/src/lib/deskflow/ServerApp.h +++ b/src/lib/deskflow/ServerApp.h @@ -83,7 +83,6 @@ public: void forceReconnect(); void resetServer(); void handleClientConnected(const Event &e, ClientListener *listener); - void handleClientsDisconnected(); void closeServer(Server *server); void stopRetryTimer(); void updateStatus() const; @@ -102,7 +101,6 @@ public: void handleResume(); ClientListener *openClientListener(const NetworkAddress &address); Server *openServer(ServerConfig &config, PrimaryClient *primaryClient); - void handleNoClients(); bool startServer(); Server *getServerPtr() { diff --git a/src/lib/io/StreamFilter.cpp b/src/lib/io/StreamFilter.cpp index f8ba77091..5e50a85b5 100644 --- a/src/lib/io/StreamFilter.cpp +++ b/src/lib/io/StreamFilter.cpp @@ -20,9 +20,7 @@ StreamFilter::StreamFilter(IEventQueue *events, deskflow::IStream *stream, bool { // replace handlers for m_stream m_events->removeHandlers(m_stream->getEventTarget()); - m_events->addHandler(EventTypes::Unknown, m_stream->getEventTarget(), [this](const auto &e) { - handleUpstreamEvent(e); - }); + m_events->addHandler(EventTypes::Unknown, m_stream->getEventTarget(), [this](const auto &e) { filterEvent(e); }); } StreamFilter::~StreamFilter() @@ -87,8 +85,3 @@ void StreamFilter::filterEvent(const Event &event) { m_events->dispatchEvent(Event(event.getType(), getEventTarget(), event.getData())); } - -void StreamFilter::handleUpstreamEvent(const Event &event) -{ - filterEvent(event); -} diff --git a/src/lib/io/StreamFilter.h b/src/lib/io/StreamFilter.h index bfe437d74..b7afe17bf 100644 --- a/src/lib/io/StreamFilter.h +++ b/src/lib/io/StreamFilter.h @@ -59,9 +59,6 @@ protected: */ virtual void filterEvent(const Event &); -private: - void handleUpstreamEvent(const Event &); - private: deskflow::IStream *m_stream; bool m_adopted; diff --git a/src/lib/platform/OSXScreen.h b/src/lib/platform/OSXScreen.h index cde47c95d..0a4f8efe8 100644 --- a/src/lib/platform/OSXScreen.h +++ b/src/lib/platform/OSXScreen.h @@ -148,9 +148,6 @@ private: // get the current scroll wheel speed double getScrollSpeed() const; - // clipboard check timer handler - void handleClipboardCheck(); - // Resolution switch callback static void displayReconfigurationCallback(CGDirectDisplayID, CGDisplayChangeSummaryFlags, void *); diff --git a/src/lib/platform/OSXScreen.mm b/src/lib/platform/OSXScreen.mm index ac7fd0b5c..683e5d577 100644 --- a/src/lib/platform/OSXScreen.mm +++ b/src/lib/platform/OSXScreen.mm @@ -647,7 +647,7 @@ void OSXScreen::enable() { // watch the clipboard m_clipboardTimer = m_events->newTimer(1.0, nullptr); - m_events->addHandler(EventTypes::Timer, m_clipboardTimer, [this](const auto &) { handleClipboardCheck(); }); + m_events->addHandler(EventTypes::Timer, m_clipboardTimer, [this](const auto &) { checkClipboards(); }); if (m_isPrimary) { // FIXME -- start watching jump zones @@ -992,11 +992,6 @@ bool OSXScreen::onMouseWheel(int32_t xDelta, int32_t yDelta) const return true; } -void OSXScreen::handleClipboardCheck() -{ - checkClipboards(); -} - void OSXScreen::displayReconfigurationCallback( CGDirectDisplayID displayID, CGDisplayChangeSummaryFlags flags, void *inUserData ) diff --git a/src/lib/server/ClientListener.cpp b/src/lib/server/ClientListener.cpp index 489588320..99515e335 100644 --- a/src/lib/server/ClientListener.cpp +++ b/src/lib/server/ClientListener.cpp @@ -160,7 +160,7 @@ void ClientListener::handleClientAccepted(IDataSocket *socket) handleUnknownClient(client); }); m_events->addHandler(EventTypes::ClientProxyUnknownFailure, client, [this, client](const auto &) { - handleUnknownClientFailure(client); + removeUnknownClient(client); }); } @@ -190,11 +190,6 @@ void ClientListener::handleUnknownClient(ClientProxyUnknown *unknownClient) removeUnknownClient(unknownClient); } -void ClientListener::handleUnknownClientFailure(ClientProxyUnknown *client) -{ - removeUnknownClient(client); -} - void ClientListener::handleClientDisconnected(ClientProxy *client) { // find client in waiting clients queue diff --git a/src/lib/server/ClientListener.h b/src/lib/server/ClientListener.h index 300dda639..10637d2cd 100644 --- a/src/lib/server/ClientListener.h +++ b/src/lib/server/ClientListener.h @@ -67,7 +67,6 @@ private: void handleClientConnecting(); void handleClientAccepted(IDataSocket *socket); void handleUnknownClient(ClientProxyUnknown *unknownClient); - void handleUnknownClientFailure(ClientProxyUnknown *client); void handleClientDisconnected(ClientProxy *client); void cleanupListenSocket(); diff --git a/src/lib/server/ClientProxy1_3.cpp b/src/lib/server/ClientProxy1_3.cpp index a7abd2c13..c561ed2b6 100644 --- a/src/lib/server/ClientProxy1_3.cpp +++ b/src/lib/server/ClientProxy1_3.cpp @@ -73,7 +73,7 @@ void ClientProxy1_3::addHeartbeatTimer() // create and install a timer to periodically send keep alives if (m_keepAliveRate > 0.0) { m_keepAliveTimer = m_events->newTimer(m_keepAliveRate, nullptr); - m_events->addHandler(EventTypes::Timer, m_keepAliveTimer, [this](const auto &) { handleKeepAlive(); }); + m_events->addHandler(EventTypes::Timer, m_keepAliveTimer, [this](const auto &) { keepAlive(); }); } // superclass does the alarm @@ -93,11 +93,6 @@ void ClientProxy1_3::removeHeartbeatTimer() ClientProxy1_2::removeHeartbeatTimer(); } -void ClientProxy1_3::handleKeepAlive() -{ - keepAlive(); -} - void ClientProxy1_3::keepAlive() { ProtocolUtil::writef(getStream(), kMsgCKeepAlive); diff --git a/src/lib/server/ClientProxy1_3.h b/src/lib/server/ClientProxy1_3.h index 6a76dd01e..0c9c90fb1 100644 --- a/src/lib/server/ClientProxy1_3.h +++ b/src/lib/server/ClientProxy1_3.h @@ -25,8 +25,6 @@ public: // IClient overrides void mouseWheel(int32_t xDelta, int32_t yDelta) override; - void handleKeepAlive(); - protected: // ClientProxy overrides bool parseMessage(const uint8_t *code) override; diff --git a/src/lib/server/ClientProxy1_6.cpp b/src/lib/server/ClientProxy1_6.cpp index 8322496c7..173a96961 100644 --- a/src/lib/server/ClientProxy1_6.cpp +++ b/src/lib/server/ClientProxy1_6.cpp @@ -21,7 +21,9 @@ ClientProxy1_6::ClientProxy1_6(const std::string &name, deskflow::IStream *strea : ClientProxy1_5(name, stream, server, events), m_events(events) { - m_events->addHandler(EventTypes::ClipboardSending, this, [this](const auto &e) { handleClipboardSendingEvent(e); }); + m_events->addHandler(EventTypes::ClipboardSending, this, [this](const auto &e) { + ClipboardChunk::send(getStream(), e.getDataObject()); + }); } void ClientProxy1_6::setClipboard(ClipboardID id, const IClipboard *clipboard) @@ -41,11 +43,6 @@ void ClientProxy1_6::setClipboard(ClipboardID id, const IClipboard *clipboard) } } -void ClientProxy1_6::handleClipboardSendingEvent(const Event &event) -{ - ClipboardChunk::send(getStream(), event.getDataObject()); -} - bool ClientProxy1_6::recvClipboard() { // parse message diff --git a/src/lib/server/ClientProxy1_6.h b/src/lib/server/ClientProxy1_6.h index 6b1b66475..e20e53f37 100644 --- a/src/lib/server/ClientProxy1_6.h +++ b/src/lib/server/ClientProxy1_6.h @@ -21,9 +21,6 @@ public: void setClipboard(ClipboardID id, const IClipboard *clipboard) override; bool recvClipboard() override; -private: - void handleClipboardSendingEvent(const Event &e); - private: IEventQueue *m_events; }; diff --git a/src/lib/server/ClientProxyUnknown.cpp b/src/lib/server/ClientProxyUnknown.cpp index 20b60be98..ad68ea000 100644 --- a/src/lib/server/ClientProxyUnknown.cpp +++ b/src/lib/server/ClientProxyUnknown.cpp @@ -113,7 +113,7 @@ void ClientProxyUnknown::addProxyHandlers() { assert(m_proxy != nullptr); - m_events->addHandler(EventTypes::ClientProxyReady, m_proxy, [this](const auto &e) { handleReady(); }); + m_events->addHandler(EventTypes::ClientProxyReady, m_proxy, [this](const auto &e) { sendSuccess(); }); m_events->addHandler(EventTypes::ClientProxyDisconnected, m_proxy, [this](const auto &e) { handleDisconnect(); }); } @@ -261,8 +261,3 @@ void ClientProxyUnknown::handleDisconnect() LOG((CLOG_NOTE "new client disconnected")); sendFailure(); } - -void ClientProxyUnknown::handleReady() -{ - sendSuccess(); -} diff --git a/src/lib/server/ClientProxyUnknown.h b/src/lib/server/ClientProxyUnknown.h index 32a7b9e0f..b7241b1bb 100644 --- a/src/lib/server/ClientProxyUnknown.h +++ b/src/lib/server/ClientProxyUnknown.h @@ -64,7 +64,6 @@ private: void handleWriteError(); void handleTimeout(); void handleDisconnect(); - void handleReady(); private: deskflow::IStream *m_stream = nullptr; diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index d6a206198..9b55a35e0 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -96,11 +96,11 @@ Server::Server( }); m_events->addHandler( EventTypes::PrimaryScreenSaverActivated, m_primaryClient->getEventTarget(), - [this](const auto &) { handleScreensaverActivatedEvent(); } + [this](const auto &) { onScreensaver(true); } ); m_events->addHandler( EventTypes::PrimaryScreenSaverDeactivated, m_primaryClient->getEventTarget(), - [this](const auto &) { handleScreensaverDeactivatedEvent(); } + [this](const auto &) { onScreensaver(false); } ); m_events->addHandler(EventTypes::ServerSwitchToScreen, m_inputFilter, [this](const auto &e) { handleSwitchToScreenEvent(e); @@ -115,10 +115,10 @@ Server::Server( handleLockCursorToScreenEvent(e); }); m_events->addHandler(EventTypes::PrimaryScreenFakeInputBegin, m_inputFilter, [this](const auto &) { - handleFakeInputBeginEvent(); + m_primaryClient->fakeInputBegin(); }); m_events->addHandler(EventTypes::PrimaryScreenFakeInputEnd, m_inputFilter, [this](const auto &) { - handleFakeInputEndEvent(); + m_primaryClient->fakeInputEnd(); }); // add connection @@ -1260,16 +1260,6 @@ void Server::handleWheelEvent(const Event &event) onMouseWheel(info->m_xDelta, info->m_yDelta); } -void Server::handleScreensaverActivatedEvent() -{ - onScreensaver(true); -} - -void Server::handleScreensaverDeactivatedEvent() -{ - onScreensaver(false); -} - void Server::handleSwitchWaitTimeout() { // ignore if mouse is locked to screen @@ -1394,16 +1384,6 @@ void Server::handleLockCursorToScreenEvent(const Event &event) } } -void Server::handleFakeInputBeginEvent() -{ - m_primaryClient->fakeInputBegin(); -} - -void Server::handleFakeInputEndEvent() -{ - m_primaryClient->fakeInputEnd(); -} - void Server::onClipboardChanged(const BaseClientProxy *sender, ClipboardID id, uint32_t seqNum) { ClipboardInfo &clipboard = m_clipboards[id]; diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h index b5f86f14d..0345de34d 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -301,8 +301,6 @@ private: void handleMotionPrimaryEvent(const Event &event); void handleMotionSecondaryEvent(const Event &event); void handleWheelEvent(const Event &event); - void handleScreensaverActivatedEvent(); - void handleScreensaverDeactivatedEvent(); void handleSwitchWaitTimeout(); void handleClientDisconnected(BaseClientProxy *client); void handleClientCloseTimeout(BaseClientProxy *client); @@ -310,8 +308,6 @@ private: void handleSwitchInDirectionEvent(const Event &event); void handleKeyboardBroadcastEvent(const Event &event); void handleLockCursorToScreenEvent(const Event &event); - void handleFakeInputBeginEvent(); - void handleFakeInputEndEvent(); // event processing void onClipboardChanged(const BaseClientProxy *sender, ClipboardID id, uint32_t seqNum);