refactor: XScreen Classes => ScreenException Classes
This commit is contained in:
@ -119,6 +119,8 @@ add_library(${lib_name} STATIC ${PLATFORM_CODE}
|
||||
ProtocolUtil.h
|
||||
Screen.cpp
|
||||
Screen.h
|
||||
ScreenException.cpp
|
||||
ScreenException.h
|
||||
ServerApp.cpp
|
||||
ServerApp.h
|
||||
ServerArgs.cpp
|
||||
@ -127,8 +129,6 @@ add_library(${lib_name} STATIC ${PLATFORM_CODE}
|
||||
StreamChunker.h
|
||||
XDeskflow.cpp
|
||||
XDeskflow.h
|
||||
XScreen.cpp
|
||||
XScreen.h
|
||||
languages/LanguageManager.cpp
|
||||
languages/LanguageManager.h
|
||||
ipc/DaemonIpcServer.cpp
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include "deskflow/ClientArgs.h"
|
||||
#include "deskflow/ProtocolTypes.h"
|
||||
#include "deskflow/Screen.h"
|
||||
#include "deskflow/XScreen.h"
|
||||
#include "deskflow/ScreenException.h"
|
||||
#include "net/NetworkAddress.h"
|
||||
#include "net/SocketException.h"
|
||||
#include "net/SocketMultiplexer.h"
|
||||
@ -332,11 +332,11 @@ bool ClientApp::startClient()
|
||||
m_client->connect(m_lastServerAddressIndex);
|
||||
|
||||
return true;
|
||||
} catch (XScreenUnavailable &e) {
|
||||
} catch (ScreenUnavailableException &e) {
|
||||
LOG_WARN("secondary screen unavailable: %s", e.what());
|
||||
closeClientScreen(clientScreen);
|
||||
retryTime = e.getRetryTime();
|
||||
} catch (XScreenOpenFailure &e) {
|
||||
} catch (ScreenOpenFailureException &e) {
|
||||
LOG_CRIT("failed to start client: %s", e.what());
|
||||
closeClientScreen(clientScreen);
|
||||
return false;
|
||||
|
||||
37
src/lib/deskflow/ScreenException.cpp
Normal file
37
src/lib/deskflow/ScreenException.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#include "deskflow/ScreenException.h"
|
||||
|
||||
//
|
||||
// ScreenOpenFailureException
|
||||
//
|
||||
|
||||
std::string ScreenOpenFailureException::getWhat() const throw()
|
||||
{
|
||||
return format("ScreenOpenFailureException", "unable to open screen");
|
||||
}
|
||||
|
||||
//
|
||||
// ScreenUnavailableException
|
||||
//
|
||||
|
||||
ScreenUnavailableException::ScreenUnavailableException(double timeUntilRetry) : m_timeUntilRetry(timeUntilRetry)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
double ScreenUnavailableException::getRetryTime() const
|
||||
{
|
||||
return m_timeUntilRetry;
|
||||
}
|
||||
|
||||
std::string ScreenUnavailableException::getWhat() const throw()
|
||||
{
|
||||
return format("ScreenUnavailableException", "unable to open screen");
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
@ -10,19 +11,19 @@
|
||||
#include "base/XBase.h"
|
||||
|
||||
/**
|
||||
* @brief The XScreen class, generic screen exception
|
||||
* @brief The ScreenException class, generic screen exception
|
||||
*/
|
||||
class XScreen : public XBase
|
||||
class ScreenException : public XBase
|
||||
{
|
||||
using XBase::XBase;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief XScreenOpenFailure - Thrown when a screen cannot be opened or initialized.
|
||||
* @brief ScreenOpenFailureException - Thrown when a screen cannot be opened or initialized.
|
||||
*/
|
||||
class XScreenOpenFailure : public XScreen
|
||||
class ScreenOpenFailureException : public ScreenException
|
||||
{
|
||||
using XScreen::XScreen;
|
||||
using ScreenException::ScreenException;
|
||||
|
||||
protected:
|
||||
std::string getWhat() const throw() override;
|
||||
@ -33,15 +34,15 @@ protected:
|
||||
Thrown when a screen cannot be opened or initialized but retrying later
|
||||
may be successful.
|
||||
*/
|
||||
class XScreenUnavailable : public XScreenOpenFailure
|
||||
class ScreenUnavailableException : public ScreenOpenFailureException
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
\c timeUntilRetry is the suggested time the caller should wait until
|
||||
trying to open the screen again.
|
||||
*/
|
||||
explicit XScreenUnavailable(double timeUntilRetry);
|
||||
~XScreenUnavailable() throw() override = default;
|
||||
explicit ScreenUnavailableException(double timeUntilRetry);
|
||||
~ScreenUnavailableException() throw() override = default;
|
||||
|
||||
//! @name manipulators
|
||||
//@{
|
||||
@ -15,8 +15,8 @@
|
||||
#include "deskflow/App.h"
|
||||
#include "deskflow/ArgParser.h"
|
||||
#include "deskflow/Screen.h"
|
||||
#include "deskflow/ScreenException.h"
|
||||
#include "deskflow/ServerArgs.h"
|
||||
#include "deskflow/XScreen.h"
|
||||
#include "net/SocketException.h"
|
||||
#include "net/SocketMultiplexer.h"
|
||||
#include "net/TCPSocketFactory.h"
|
||||
@ -369,12 +369,12 @@ bool ServerApp::initServer()
|
||||
m_primaryClient = primaryClient;
|
||||
m_serverState = Initialized;
|
||||
return true;
|
||||
} catch (XScreenUnavailable &e) {
|
||||
} catch (ScreenUnavailableException &e) {
|
||||
LOG_WARN("primary screen unavailable: %s", e.what());
|
||||
closePrimaryClient(primaryClient);
|
||||
closeServerScreen(serverScreen);
|
||||
retryTime = e.getRetryTime();
|
||||
} catch (XScreenOpenFailure &e) {
|
||||
} catch (ScreenOpenFailureException &e) {
|
||||
LOG_CRIT("failed to start server: %s", e.what());
|
||||
closePrimaryClient(primaryClient);
|
||||
closeServerScreen(serverScreen);
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#include "deskflow/XScreen.h"
|
||||
|
||||
//
|
||||
// XScreenOpenFailure
|
||||
//
|
||||
|
||||
std::string XScreenOpenFailure::getWhat() const throw()
|
||||
{
|
||||
return format("XScreenOpenFailure", "unable to open screen");
|
||||
}
|
||||
|
||||
//
|
||||
// XScreenUnavailable
|
||||
//
|
||||
|
||||
XScreenUnavailable::XScreenUnavailable(double timeUntilRetry) : m_timeUntilRetry(timeUntilRetry)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
double XScreenUnavailable::getRetryTime() const
|
||||
{
|
||||
return m_timeUntilRetry;
|
||||
}
|
||||
|
||||
std::string XScreenUnavailable::getWhat() const throw()
|
||||
{
|
||||
return format("XScreenUnavailable", "unable to open screen");
|
||||
}
|
||||
@ -16,7 +16,7 @@
|
||||
#include "common/Constants.h"
|
||||
#include "deskflow/Clipboard.h"
|
||||
#include "deskflow/KeyMap.h"
|
||||
#include "deskflow/XScreen.h"
|
||||
#include "deskflow/ScreenException.h"
|
||||
#include "platform/EiEventQueueBuffer.h"
|
||||
#include "platform/EiKeyState.h"
|
||||
#include "platform/PortalInputCapture.h"
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "deskflow/IScreenSaver.h"
|
||||
#include "deskflow/XScreen.h"
|
||||
#include "deskflow/ScreenException.h"
|
||||
#include "deskflow/win32/AppUtilWindows.h"
|
||||
#include "mt/Lock.h"
|
||||
#include "mt/Thread.h"
|
||||
@ -368,7 +368,7 @@ HWND MSWindowsDesks::createWindow(ATOM windowClass, const char *name) const
|
||||
);
|
||||
if (window == nullptr) {
|
||||
LOG_ERR("failed to create window: %d", GetLastError());
|
||||
throw XScreenOpenFailure();
|
||||
throw ScreenOpenFailureException();
|
||||
}
|
||||
return window;
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
#include "platform/MSWindowsHook.h"
|
||||
#include "base/Log.h"
|
||||
#include "deskflow/ProtocolTypes.h"
|
||||
#include "deskflow/XScreen.h"
|
||||
#include "deskflow/ScreenException.h"
|
||||
|
||||
static const char *g_name = "dfwhook";
|
||||
|
||||
@ -55,7 +55,7 @@ void MSWindowsHook::loadLibrary()
|
||||
if (init(GetCurrentThreadId()) == 0) {
|
||||
LOG_ERR("failed to init %s.dll, another program may be using it", g_name);
|
||||
LOG_INFO("restarting your computer may solve this error");
|
||||
throw XScreenOpenFailure();
|
||||
throw ScreenOpenFailureException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
#include "deskflow/ClientApp.h"
|
||||
#include "deskflow/Clipboard.h"
|
||||
#include "deskflow/KeyMap.h"
|
||||
#include "deskflow/XScreen.h"
|
||||
#include "deskflow/ScreenException.h"
|
||||
#include "platform/MSWindowsClipboard.h"
|
||||
#include "platform/MSWindowsDesks.h"
|
||||
#include "platform/MSWindowsEventQueueBuffer.h"
|
||||
@ -806,7 +806,7 @@ HWND MSWindowsScreen::createWindow(ATOM windowClass, const char *name) const
|
||||
);
|
||||
if (window == nullptr) {
|
||||
LOG_ERR("failed to create window: %d", GetLastError());
|
||||
throw XScreenOpenFailure();
|
||||
throw ScreenOpenFailureException();
|
||||
}
|
||||
return window;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "deskflow/ClientArgs.h"
|
||||
#include "deskflow/Clipboard.h"
|
||||
#include "deskflow/KeyMap.h"
|
||||
#include "deskflow/XScreen.h"
|
||||
#include "deskflow/ScreenException.h"
|
||||
#include "platform/XWindowsClipboard.h"
|
||||
#include "platform/XWindowsEventQueueBuffer.h"
|
||||
#include "platform/XWindowsKeyState.h"
|
||||
@ -846,7 +846,7 @@ Display *XWindowsScreen::openDisplay(const char *displayName)
|
||||
LOG_DEBUG3("calling XOpenDisplay(\"%s\")", displayName);
|
||||
Display *display = XOpenDisplay(displayName);
|
||||
if (display == nullptr) {
|
||||
throw XScreenUnavailable(60.0);
|
||||
throw ScreenUnavailableException(60.0);
|
||||
}
|
||||
|
||||
// verify the availability of the XTest extension
|
||||
@ -857,7 +857,7 @@ Display *XWindowsScreen::openDisplay(const char *displayName)
|
||||
if (!XQueryExtension(display, XTestExtensionName, &majorOpcode, &firstEvent, &firstError)) {
|
||||
LOG_ERR("the XTest extension is not available");
|
||||
XCloseDisplay(display);
|
||||
throw XScreenOpenFailure();
|
||||
throw ScreenOpenFailureException();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1028,7 +1028,7 @@ Window XWindowsScreen::openWindow() const
|
||||
CWDontPropagate | CWEventMask | CWOverrideRedirect | CWCursor, &attr
|
||||
);
|
||||
if (window == None) {
|
||||
throw XScreenOpenFailure();
|
||||
throw ScreenOpenFailureException();
|
||||
}
|
||||
return window;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user