diff --git a/src/lib/base/XBase.cpp b/src/lib/base/BaseException.cpp similarity index 68% rename from src/lib/base/XBase.cpp rename to src/lib/base/BaseException.cpp index a149c5b7a..caa17a11e 100644 --- a/src/lib/base/XBase.cpp +++ b/src/lib/base/BaseException.cpp @@ -1,30 +1,31 @@ /* * 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 "base/XBase.h" +#include "base/BaseException.h" #include "base/String.h" #include // -// XBase +// BaseException // -XBase::XBase() : std::runtime_error("") +BaseException::BaseException() : std::runtime_error("") { // do nothing } -XBase::XBase(const std::string &msg) : std::runtime_error(msg) +BaseException::BaseException(const std::string &msg) : std::runtime_error(msg) { // do nothing } -const char *XBase::what() const throw() +const char *BaseException::what() const throw() { if (const char *what = std::runtime_error::what(); what != nullptr && what[0] != '\0') { return what; @@ -34,7 +35,7 @@ const char *XBase::what() const throw() return m_what.c_str(); } -std::string XBase::format(const char * /*id*/, const char *fmt, ...) const noexcept +std::string BaseException::format(const char * /*id*/, const char *fmt, ...) const noexcept { // FIXME -- lookup message string using id as an index. set // fmt to that string if it exists. diff --git a/src/lib/base/XBase.h b/src/lib/base/BaseException.h similarity index 82% rename from src/lib/base/XBase.h rename to src/lib/base/BaseException.h index 16ff6fa04..e2d46710a 100644 --- a/src/lib/base/XBase.h +++ b/src/lib/base/BaseException.h @@ -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 @@ -14,14 +15,14 @@ /*! This is the base class of most exception types. */ -class XBase : public std::runtime_error +class BaseException : public std::runtime_error { public: //! Use getWhat() as the result of what() - XBase(); + BaseException(); //! Use \c msg as the result of what() - explicit XBase(const std::string &msg); - ~XBase() throw() override = default; + explicit BaseException(const std::string &msg); + ~BaseException() throw() override = default; //! Reason for exception const char *what() const throw() override; diff --git a/src/lib/base/CMakeLists.txt b/src/lib/base/CMakeLists.txt index f70ce872f..87241bd1e 100644 --- a/src/lib/base/CMakeLists.txt +++ b/src/lib/base/CMakeLists.txt @@ -4,6 +4,8 @@ # SPDX-License-Identifier: MIT add_library(base STATIC + BaseException.cpp + BaseException.h DirectionTypes.h Event.cpp Event.h @@ -38,8 +40,6 @@ add_library(base STATIC TMethodJob.h Unicode.cpp Unicode.h - XBase.cpp - XBase.h ) target_link_libraries(base PRIVATE arch) diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index e10ca1437..ce2ee049c 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -128,7 +128,7 @@ void Client::connect(size_t addressIndex) setupConnecting(); setupTimer(); socket->connect(m_serverAddress); - } catch (XBase &e) { + } catch (BaseException &e) { cleanupTimer(); cleanupConnecting(); cleanupStream(); @@ -639,7 +639,7 @@ void Client::bindNetworkInterface(IDataSocket *socket) const socket->bind(bindAddress); } - } catch (XBase &e) { + } catch (BaseException &e) { LOG_WARN("%s", e.what()); LOG_WARN("operating system will select network interface automatically"); } diff --git a/src/lib/client/ServerProxy.cpp b/src/lib/client/ServerProxy.cpp index 2214dbb9c..c783aaf94 100644 --- a/src/lib/client/ServerProxy.cpp +++ b/src/lib/client/ServerProxy.cpp @@ -8,9 +8,9 @@ #include "client/ServerProxy.h" +#include "base/BaseException.h" #include "base/IEventQueue.h" #include "base/Log.h" -#include "base/XBase.h" #include "client/Client.h" #include "deskflow/AppUtil.h" #include "deskflow/Clipboard.h" diff --git a/src/lib/deskflow/ClientApp.cpp b/src/lib/deskflow/ClientApp.cpp index dbbaefb47..8a082802b 100644 --- a/src/lib/deskflow/ClientApp.cpp +++ b/src/lib/deskflow/ClientApp.cpp @@ -340,7 +340,7 @@ bool ClientApp::startClient() LOG_CRIT("failed to start client: %s", e.what()); closeClientScreen(clientScreen); return false; - } catch (XBase &e) { + } catch (BaseException &e) { LOG_CRIT("failed to start client: %s", e.what()); closeClientScreen(clientScreen); return false; diff --git a/src/lib/deskflow/DeskflowException.h b/src/lib/deskflow/DeskflowException.h index c1b9ea219..c912d2144 100644 --- a/src/lib/deskflow/DeskflowException.h +++ b/src/lib/deskflow/DeskflowException.h @@ -8,14 +8,14 @@ #pragma once -#include "base/XBase.h" +#include "base/BaseException.h" /** * @brief The DeskflowException class Generic deskflow exception class */ -class DeskflowException : public XBase +class DeskflowException : public BaseException { - using XBase::XBase; + using BaseException::BaseException; }; /** diff --git a/src/lib/deskflow/ProtocolUtil.cpp b/src/lib/deskflow/ProtocolUtil.cpp index d79c2cbaf..c8b087930 100644 --- a/src/lib/deskflow/ProtocolUtil.cpp +++ b/src/lib/deskflow/ProtocolUtil.cpp @@ -122,7 +122,7 @@ void ProtocolUtil::vwritef(deskflow::IStream *stream, const char *fmt, uint32_t // write buffer stream->write(Buffer.data(), size); LOG_DEBUG2("wrote %d bytes", size); - } catch (const XBase &exception) { + } catch (const BaseException &exception) { LOG_DEBUG2("exception <%s> during wrote %d bytes into stream", exception.what(), size); throw; } diff --git a/src/lib/deskflow/ProtocolUtil.h b/src/lib/deskflow/ProtocolUtil.h index c768ddeef..a1e2abb91 100644 --- a/src/lib/deskflow/ProtocolUtil.h +++ b/src/lib/deskflow/ProtocolUtil.h @@ -101,6 +101,6 @@ match the format. class XIOReadMismatch : public IOException { public: - // XBase overrides + // BaseException overrides std::string getWhat() const throw() override; }; diff --git a/src/lib/deskflow/ScreenException.h b/src/lib/deskflow/ScreenException.h index 8d4dc535a..cfb5a8a5b 100644 --- a/src/lib/deskflow/ScreenException.h +++ b/src/lib/deskflow/ScreenException.h @@ -8,14 +8,14 @@ #pragma once -#include "base/XBase.h" +#include "base/BaseException.h" /** * @brief The ScreenException class, generic screen exception */ -class ScreenException : public XBase +class ScreenException : public BaseException { - using XBase::XBase; + using BaseException::BaseException; }; /** diff --git a/src/lib/deskflow/ServerApp.cpp b/src/lib/deskflow/ServerApp.cpp index 95d83ec6f..9d5f3d3b2 100644 --- a/src/lib/deskflow/ServerApp.cpp +++ b/src/lib/deskflow/ServerApp.cpp @@ -379,7 +379,7 @@ bool ServerApp::initServer() closePrimaryClient(primaryClient); closeServerScreen(serverScreen); return false; - } catch (XBase &e) { + } catch (BaseException &e) { LOG_CRIT("failed to start server: %s", e.what()); closePrimaryClient(primaryClient); closeServerScreen(serverScreen); @@ -452,7 +452,7 @@ bool ServerApp::startServer() LOG_CRIT("cannot listen for clients: %s", e.what()); } closeClientListener(listener); - } catch (XBase &e) { + } catch (BaseException &e) { LOG_CRIT("failed to start server: %s", e.what()); closeClientListener(listener); return false; diff --git a/src/lib/io/IOException.h b/src/lib/io/IOException.h index a014ac8ce..e0fca3eca 100644 --- a/src/lib/io/IOException.h +++ b/src/lib/io/IOException.h @@ -8,14 +8,14 @@ #pragma once -#include "base/XBase.h" +#include "base/BaseException.h" /** * @brief The IOException class Generic i/o exception class */ -class IOException : public XBase +class IOException : public BaseException { - using XBase::XBase; + using BaseException::BaseException; }; /** diff --git a/src/lib/mt/MTException.h b/src/lib/mt/MTException.h index ed2884893..750f75d7d 100644 --- a/src/lib/mt/MTException.h +++ b/src/lib/mt/MTException.h @@ -8,14 +8,14 @@ #pragma once -#include "base/XBase.h" +#include "base/BaseException.h" /** * @brief MTException generic multithreading exception */ -class MTException : public XBase +class MTException : public BaseException { - using XBase::XBase; + using BaseException::BaseException; }; /** diff --git a/src/lib/mt/Thread.cpp b/src/lib/mt/Thread.cpp index 95e3037c4..c52001281 100644 --- a/src/lib/mt/Thread.cpp +++ b/src/lib/mt/Thread.cpp @@ -137,7 +137,7 @@ void *Thread::threadFunc(void *vjob) // client called exit() result = e.m_result; LOG_DEBUG1("caught exit on thread 0x%08x, result %p", id, result); - } catch (XBase &e) { + } catch (BaseException &e) { LOG_ERR("exception on thread 0x%08x: %s", id, e.what()); delete job; throw; diff --git a/src/lib/net/SocketException.h b/src/lib/net/SocketException.h index f0192c705..df5d9d15b 100644 --- a/src/lib/net/SocketException.h +++ b/src/lib/net/SocketException.h @@ -8,16 +8,16 @@ #pragma once -#include "base/XBase.h" +#include "base/BaseException.h" #include "common/Common.h" #include "io/IOException.h" /** * @brief SocketException generic socket exception */ -class SocketException : public XBase +class SocketException : public BaseException { - using XBase::XBase; + using BaseException::BaseException; }; //! Socket bad address exception @@ -53,7 +53,7 @@ public: //@} protected: - // XBase overrides + // BaseException overrides std::string getWhat() const throw() override; private: diff --git a/src/lib/server/ClientListener.cpp b/src/lib/server/ClientListener.cpp index 5c663a841..76472ce26 100644 --- a/src/lib/server/ClientListener.cpp +++ b/src/lib/server/ClientListener.cpp @@ -40,7 +40,7 @@ ClientListener::ClientListener( cleanupListenSocket(); m_socketFactory.reset(); throw; - } catch (XBase &) { + } catch (BaseException &) { cleanupListenSocket(); m_socketFactory.reset(); throw; diff --git a/src/lib/server/ClientProxyUnknown.cpp b/src/lib/server/ClientProxyUnknown.cpp index 94952e34b..6f129f839 100644 --- a/src/lib/server/ClientProxyUnknown.cpp +++ b/src/lib/server/ClientProxyUnknown.cpp @@ -241,7 +241,7 @@ void ClientProxyUnknown::handleData() // client not behaving LOG_WARN("protocol error from client \"%s\"", name.c_str()); ProtocolUtil::writef(m_stream, kMsgEBad); - } catch (XBase &e) { + } catch (BaseException &e) { // misc error LOG_WARN("error communicating with client \"%s\": %s", name.c_str(), e.what()); } diff --git a/src/lib/server/Config.h b/src/lib/server/Config.h index bec2d7fee..99615ed64 100644 --- a/src/lib/server/Config.h +++ b/src/lib/server/Config.h @@ -7,8 +7,8 @@ #pragma once +#include "base/BaseException.h" #include "base/String.h" -#include "base/XBase.h" #include "deskflow/IPlatformScreen.h" #include "deskflow/OptionTypes.h" #include "deskflow/ProtocolTypes.h" @@ -529,7 +529,7 @@ private: /*! Thrown when a configuration stream cannot be parsed. */ -class XConfigRead : public XBase +class XConfigRead : public BaseException { public: XConfigRead(const ConfigReadContext &context, const std::string &); @@ -537,7 +537,7 @@ public: ~XConfigRead() throw() override = default; protected: - // XBase overrides + // BaseException overrides std::string getWhat() const throw() override; private: diff --git a/src/unittests/base/XBaseTests.cpp b/src/unittests/base/BaseExceptionTests.cpp similarity index 50% rename from src/unittests/base/XBaseTests.cpp rename to src/unittests/base/BaseExceptionTests.cpp index fa7436583..7e4ea1c2f 100644 --- a/src/unittests/base/XBaseTests.cpp +++ b/src/unittests/base/BaseExceptionTests.cpp @@ -5,24 +5,24 @@ * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception */ -#include "XBaseTests.h" +#include "BaseExceptionTests.h" -#include "base/XBase.h" +#include "base/BaseException.h" -void XBaseTests::empty() +void BaseExceptionTests::empty() { - XBase xbase; - const char *result = xbase.what(); + BaseException BaseException; + const char *result = BaseException.what(); QCOMPARE(result, ""); } -void XBaseTests::nonEmpty() +void BaseExceptionTests::nonEmpty() { - XBase xbase("test"); - const char *result = xbase.what(); + BaseException BaseException("test"); + const char *result = BaseException.what(); QCOMPARE(result, "test"); } -QTEST_MAIN(XBaseTests) +QTEST_MAIN(BaseExceptionTests) diff --git a/src/unittests/base/XBaseTests.h b/src/unittests/base/BaseExceptionTests.h similarity index 87% rename from src/unittests/base/XBaseTests.h rename to src/unittests/base/BaseExceptionTests.h index f96071879..fb7460891 100644 --- a/src/unittests/base/XBaseTests.h +++ b/src/unittests/base/BaseExceptionTests.h @@ -6,7 +6,7 @@ #include -class XBaseTests : public QObject +class BaseExceptionTests : public QObject { Q_OBJECT private Q_SLOTS: diff --git a/src/unittests/base/CMakeLists.txt b/src/unittests/base/CMakeLists.txt index 95671439a..ef8092d5e 100644 --- a/src/unittests/base/CMakeLists.txt +++ b/src/unittests/base/CMakeLists.txt @@ -30,10 +30,10 @@ create_test( ) create_test( - NAME XBaseTests + NAME BaseExceptionTests DEPENDS base LIBS arch - SOURCE XBaseTests.cpp + SOURCE BaseExceptionTests.cpp WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/base" )