Merge pull request #6826 from symless/SYNERGY-509-sonarcloud-critical-bugs-in-synergy-core

SonarCloud Critical bugs
This commit is contained in:
Ignacio Rodríguez 2020-11-04 19:02:38 +07:00 committed by GitHub
commit 20c830afb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 263 additions and 11 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
.vscode
config.h config.h
.DS_Store .DS_Store
*.pyc *.pyc

View file

@ -12,6 +12,7 @@ Bug fixes:
- #6660 + #6582 Add missing XAtom for utf-8 handling with Xorg - #6660 + #6582 Add missing XAtom for utf-8 handling with Xorg
- #6814 The system asks to save twice. - #6814 The system asks to save twice.
- #6817 Configure requires dns_sd.h for enterprise version - #6817 Configure requires dns_sd.h for enterprise version
- #6826 SonarCloud Critical bugs
- #6821 Blocker bugs found by sonar in synergy and in tests - #6821 Blocker bugs found by sonar in synergy and in tests
- #6825 The system requires google test even when tests are disabled with BUILD_TESTS=OFF - #6825 The system requires google test even when tests are disabled with BUILD_TESTS=OFF

View file

@ -28,8 +28,13 @@ class CXWindowsClientTaskBarReceiver : public ClientTaskBarReceiver {
public: public:
CXWindowsClientTaskBarReceiver( CXWindowsClientTaskBarReceiver(
const BufferedLogOutputter*, IEventQueue* events); const BufferedLogOutputter*, IEventQueue* events);
CXWindowsClientTaskBarReceiver(const CXWindowsClientTaskBarReceiver &) =delete;
CXWindowsClientTaskBarReceiver(CXWindowsClientTaskBarReceiver &&) =delete;
virtual ~CXWindowsClientTaskBarReceiver(); virtual ~CXWindowsClientTaskBarReceiver();
CXWindowsClientTaskBarReceiver& operator=(const CXWindowsClientTaskBarReceiver &) =delete;
CXWindowsClientTaskBarReceiver& operator=(CXWindowsClientTaskBarReceiver &&) =delete;
// IArchTaskBarReceiver overrides // IArchTaskBarReceiver overrides
virtual void showStatus(); virtual void showStatus();
virtual void runMenu(int x, int y); virtual void runMenu(int x, int y);

View file

@ -28,7 +28,12 @@ class CXWindowsServerTaskBarReceiver : public ServerTaskBarReceiver {
public: public:
CXWindowsServerTaskBarReceiver( CXWindowsServerTaskBarReceiver(
const BufferedLogOutputter*, IEventQueue* events); const BufferedLogOutputter*, IEventQueue* events);
CXWindowsServerTaskBarReceiver(const CXWindowsServerTaskBarReceiver&) =delete;
CXWindowsServerTaskBarReceiver(CXWindowsServerTaskBarReceiver&&) =delete;
virtual ~CXWindowsServerTaskBarReceiver(); virtual ~CXWindowsServerTaskBarReceiver();
CXWindowsServerTaskBarReceiver& operator=(const CXWindowsServerTaskBarReceiver&) =delete;
CXWindowsServerTaskBarReceiver& operator=(const CXWindowsServerTaskBarReceiver&&) =delete;
// IArchTaskBarReceiver overrides // IArchTaskBarReceiver overrides
virtual void showStatus(); virtual void showStatus();

View file

@ -43,7 +43,12 @@ class ServerConfig : public BaseConfig, public GUI::Config::ConfigBase
public: public:
ServerConfig(int numColumns, int numRows, ServerConfig(int numColumns, int numRows,
QString serverName, MainWindow* mainWindow); QString serverName, MainWindow* mainWindow);
ServerConfig(const ServerConfig &src) =default;
ServerConfig(ServerConfig &&) =default;
~ServerConfig(); ~ServerConfig();
ServerConfig& operator=(const ServerConfig &src) =default;
ServerConfig& operator=(ServerConfig &&) =delete;
public: public:
const ScreenList& screens() const { return m_Screens; } const ScreenList& screens() const { return m_Screens; }

View file

@ -101,7 +101,7 @@ public:
//! Call init on other arch classes. //! Call init on other arch classes.
/*! /*!
Some arch classes depend on others to exist first. When init is called Some arch classes depend on others to exist first. When init is called
these clases will have ARCH available for use. these classes will have ARCH available for use.
*/ */
virtual void init(); virtual void init();
@ -129,11 +129,16 @@ public:
{ {
ARCH->lockMutex(m_mutex); ARCH->lockMutex(m_mutex);
} }
ArchMutexLock(ArchMutexLock const &) =delete;
ArchMutexLock(ArchMutexLock &&) =delete;
~ArchMutexLock() ~ArchMutexLock()
{ {
ARCH->unlockMutex(m_mutex); ARCH->unlockMutex(m_mutex);
} }
ArchMutexLock& operator=(ArchMutexLock const &) =delete;
ArchMutexLock& operator=(ArchMutexLock &&) =delete;
private: private:
ArchMutex m_mutex; ArchMutex m_mutex;
}; };

View file

@ -30,8 +30,14 @@ synergy. Each architecture must implement this interface.
*/ */
class IArchString : public IInterface { class IArchString : public IInterface {
public: public:
IArchString() =default;
IArchString(const IArchString &) =delete;
IArchString(IArchString &&) =delete;
virtual ~IArchString(); virtual ~IArchString();
IArchString& operator=(const IArchString &) =delete;
IArchString& operator=(IArchString &&) =delete;
//! Wide character encodings //! Wide character encodings
/*! /*!
The known wide character encodings The known wide character encodings

View file

@ -39,8 +39,13 @@ public:
class ArchMultithreadPosix : public IArchMultithread { class ArchMultithreadPosix : public IArchMultithread {
public: public:
ArchMultithreadPosix(); ArchMultithreadPosix();
ArchMultithreadPosix(ArchMultithreadPosix const &) =delete;
ArchMultithreadPosix(ArchMultithreadPosix &&) =delete;
virtual ~ArchMultithreadPosix(); virtual ~ArchMultithreadPosix();
ArchMultithreadPosix& operator=(ArchMultithreadPosix const &) =delete;
ArchMultithreadPosix& operator=(ArchMultithreadPosix &&) =delete;
//! @name manipulators //! @name manipulators
//@{ //@{

View file

@ -59,13 +59,19 @@ public:
class ArchNetworkBSD : public IArchNetwork { class ArchNetworkBSD : public IArchNetwork {
public: public:
ArchNetworkBSD(); ArchNetworkBSD();
ArchNetworkBSD(ArchNetworkBSD const &) =delete;
ArchNetworkBSD(ArchNetworkBSD &&) =delete;
virtual ~ArchNetworkBSD(); virtual ~ArchNetworkBSD();
ArchNetworkBSD& operator=(ArchNetworkBSD const &) =delete;
ArchNetworkBSD& operator=(ArchNetworkBSD &&) =delete;
virtual void init(); virtual void init();
// IArchNetwork overrides // IArchNetwork overrides
virtual ArchSocket newSocket(EAddressFamily, ESocketType); virtual ArchSocket newSocket(EAddressFamily, ESocketType);
virtual ArchSocket copySocket(ArchSocket s); virtual void closeSocket(ArchSocket s); virtual ArchSocket copySocket(ArchSocket s);
virtual void closeSocket(ArchSocket s);
virtual void closeSocketForRead(ArchSocket s); virtual void closeSocketForRead(ArchSocket s);
virtual void closeSocketForWrite(ArchSocket s); virtual void closeSocketForWrite(ArchSocket s);
virtual void bindSocket(ArchSocket s, ArchNetAddress addr); virtual void bindSocket(ArchSocket s, ArchNetAddress addr);

View file

@ -39,7 +39,11 @@ delegates the platform dependent parts to a subclass.
class EventQueue : public IEventQueue { class EventQueue : public IEventQueue {
public: public:
EventQueue(); EventQueue();
EventQueue(EventQueue const &) =delete;
EventQueue(EventQueue &&) =delete;
virtual ~EventQueue(); virtual ~EventQueue();
EventQueue& operator=(EventQueue const &) =delete;
EventQueue& operator=(EventQueue &&) =delete;
// IEventQueue overrides // IEventQueue overrides
virtual void loop(); virtual void loop();

View file

@ -42,8 +42,13 @@ class Log {
public: public:
Log(); Log();
Log(Log* src); Log(Log* src);
Log(Log const &) =delete;
Log(Log &&) =delete;
~Log(); ~Log();
Log& operator=(Log const &) =delete;
Log& operator=(Log &&) =delete;
//! @name manipulators //! @name manipulators
//@{ //@{
@ -154,7 +159,7 @@ not be filtered and is never prefixed by the filename and line number.
If \c NOLOGGING is defined during the build then this macro expands to If \c NOLOGGING is defined during the build then this macro expands to
nothing. If \c NDEBUG is defined during the build then it expands to a nothing. If \c NDEBUG is defined during the build then it expands to a
call to Log::print. Otherwise it expands to a call to Log::printt, call to Log::print. Otherwise it expands to a call to Log::print,
which includes the filename and line number. which includes the filename and line number.
*/ */

View file

@ -28,9 +28,14 @@ An event queue buffer provides a queue of events for an IEventQueue.
*/ */
class SimpleEventQueueBuffer : public IEventQueueBuffer { class SimpleEventQueueBuffer : public IEventQueueBuffer {
public: public:
SimpleEventQueueBuffer(); SimpleEventQueueBuffer();
SimpleEventQueueBuffer(SimpleEventQueueBuffer const &) = delete;
SimpleEventQueueBuffer(SimpleEventQueueBuffer &&) = delete;
~SimpleEventQueueBuffer(); ~SimpleEventQueueBuffer();
SimpleEventQueueBuffer& operator=(SimpleEventQueueBuffer const &) = delete;
SimpleEventQueueBuffer& operator=(SimpleEventQueueBuffer &&) = delete;
// IEventQueueBuffer overrides // IEventQueueBuffer overrides
void init() { } void init() { }
virtual void waitForEvent(double timeout); virtual void waitForEvent(double timeout);

View file

@ -113,8 +113,13 @@ the scope.
class SystemLogger { class SystemLogger {
public: public:
SystemLogger(const char* title, bool blockConsole); SystemLogger(const char* title, bool blockConsole);
SystemLogger(SystemLogger const &) =delete;
SystemLogger(SystemLogger &&) =delete;
~SystemLogger(); ~SystemLogger();
SystemLogger& operator=(SystemLogger const &) =delete;
SystemLogger& operator=(SystemLogger &&) =delete;
private: private:
ILogOutputter* m_syslog; ILogOutputter* m_syslog;
ILogOutputter* m_stop; ILogOutputter* m_stop;

View file

@ -60,9 +60,13 @@ public:
Client(IEventQueue* events, const String& name, Client(IEventQueue* events, const String& name,
const NetworkAddress& address, ISocketFactory* socketFactory, const NetworkAddress& address, ISocketFactory* socketFactory,
synergy::Screen* screen, lib::synergy::ClientArgs const& args); synergy::Screen* screen, lib::synergy::ClientArgs const& args);
Client(Client const &) =delete;
Client(Client &&) =delete;
~Client(); ~Client();
Client& operator=(Client const &) =delete;
Client& operator=(Client &&) =delete;
//! @name manipulators //! @name manipulators
//@{ //@{
@ -119,7 +123,7 @@ public:
*/ */
NetworkAddress getServerAddress() const; NetworkAddress getServerAddress() const;
//! Return true if recieved file size is valid //! Return true if received file size is valid
bool isReceivedFileSizeValid(); bool isReceivedFileSizeValid();
//! Return expected file size //! Return expected file size

View file

@ -43,8 +43,13 @@ public:
\p client. \p client.
*/ */
ServerProxy(Client* client, synergy::IStream* stream, IEventQueue* events); ServerProxy(Client* client, synergy::IStream* stream, IEventQueue* events);
ServerProxy(ServerProxy const &) =delete;
ServerProxy(ServerProxy &&) =delete;
~ServerProxy(); ~ServerProxy();
ServerProxy& operator=(ServerProxy const &) =delete;
ServerProxy& operator=(ServerProxy &&) =delete;
//! @name manipulators //! @name manipulators
//@{ //@{

View file

@ -34,8 +34,13 @@ public:
d'tor. d'tor.
*/ */
StreamFilter(IEventQueue* events, synergy::IStream* stream, bool adoptStream = true); StreamFilter(IEventQueue* events, synergy::IStream* stream, bool adoptStream = true);
StreamFilter(StreamFilter const &) =delete;
StreamFilter(StreamFilter &&) =delete;
virtual ~StreamFilter(); virtual ~StreamFilter();
StreamFilter& operator=(StreamFilter const &) =delete;
StreamFilter& operator=(StreamFilter &&) =delete;
// IStream overrides // IStream overrides
// These all just forward to the underlying stream except getEventTarget. // These all just forward to the underlying stream except getEventTarget.
// Override as necessary. getEventTarget returns a pointer to this. // Override as necessary. getEventTarget returns a pointer to this.

View file

@ -34,8 +34,13 @@ class IpcClientProxy {
public: public:
IpcClientProxy(synergy::IStream& stream, IEventQueue* events); IpcClientProxy(synergy::IStream& stream, IEventQueue* events);
IpcClientProxy(IpcClientProxy const &) =delete;
IpcClientProxy(IpcClientProxy &&) =delete;
virtual ~IpcClientProxy(); virtual ~IpcClientProxy();
IpcClientProxy& operator=(IpcClientProxy const &) =delete;
IpcClientProxy& operator=(IpcClientProxy &&) =delete;
private: private:
void send(const IpcMessage& message); void send(const IpcMessage& message);
void handleData(const Event&, void*); void handleData(const Event&, void*);

View file

@ -41,6 +41,7 @@ public:
using the \c sendBuffer() function. using the \c sendBuffer() function.
*/ */
IpcLogOutputter(IpcServer& ipcServer, EIpcClientType clientType, bool useThread); IpcLogOutputter(IpcServer& ipcServer, EIpcClientType clientType, bool useThread);
IpcLogOutputter(IpcLogOutputter const &) =delete;
virtual ~IpcLogOutputter(); virtual ~IpcLogOutputter();
// ILogOutputter overrides // ILogOutputter overrides

View file

@ -43,8 +43,13 @@ class IpcServer {
public: public:
IpcServer(IEventQueue* events, SocketMultiplexer* socketMultiplexer); IpcServer(IEventQueue* events, SocketMultiplexer* socketMultiplexer);
IpcServer(IEventQueue* events, SocketMultiplexer* socketMultiplexer, int port); IpcServer(IEventQueue* events, SocketMultiplexer* socketMultiplexer, int port);
IpcServer(IpcServer const &) =delete;
IpcServer(IpcServer &&) =delete;
virtual ~IpcServer(); virtual ~IpcServer();
IpcServer& operator=(IpcServer const &) =delete;
IpcServer& operator=(IpcServer &&) =delete;
//! @name manipulators //! @name manipulators
//@{ //@{

View file

@ -31,6 +31,7 @@ class IpcServerProxy {
public: public:
IpcServerProxy(synergy::IStream& stream, IEventQueue* events); IpcServerProxy(synergy::IStream& stream, IEventQueue* events);
IpcServerProxy(IpcServerProxy const &) =delete;
virtual ~IpcServerProxy(); virtual ~IpcServerProxy();
private: private:

View file

@ -36,8 +36,13 @@ public:
SecureSocket(IEventQueue* events, SecureSocket(IEventQueue* events,
SocketMultiplexer* socketMultiplexer, SocketMultiplexer* socketMultiplexer,
ArchSocket socket); ArchSocket socket);
SecureSocket(SecureSocket const &) =delete;
SecureSocket(SecureSocket &&) =delete;
~SecureSocket(); ~SecureSocket();
SecureSocket& operator=(SecureSocket const &) =delete;
SecureSocket& operator=(SecureSocket &&) =delete;
// ISocket overrides // ISocket overrides
void close(); void close();

View file

@ -36,8 +36,13 @@ A socket multiplexer services multiple sockets simultaneously.
class SocketMultiplexer { class SocketMultiplexer {
public: public:
SocketMultiplexer(); SocketMultiplexer();
SocketMultiplexer(SocketMultiplexer const &) =delete;
SocketMultiplexer(SocketMultiplexer &&) =delete;
~SocketMultiplexer(); ~SocketMultiplexer();
SocketMultiplexer& operator=(SocketMultiplexer const &) =delete;
SocketMultiplexer& operator=(SocketMultiplexer &&) =delete;
//! @name manipulators //! @name manipulators
//@{ //@{

View file

@ -33,8 +33,13 @@ A listen socket using TCP.
class TCPListenSocket : public IListenSocket { class TCPListenSocket : public IListenSocket {
public: public:
TCPListenSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, IArchNetwork::EAddressFamily family); TCPListenSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, IArchNetwork::EAddressFamily family);
TCPListenSocket(TCPListenSocket const &) =delete;
TCPListenSocket(TCPListenSocket &&) =delete;
virtual ~TCPListenSocket(); virtual ~TCPListenSocket();
TCPListenSocket& operator=(TCPListenSocket const &) =delete;
TCPListenSocket& operator=(TCPListenSocket &&) =delete;
// ISocket overrides // ISocket overrides
virtual void bind(const NetworkAddress&); virtual void bind(const NetworkAddress&);
virtual void close(); virtual void close();

View file

@ -38,8 +38,13 @@ class TCPSocket : public IDataSocket {
public: public:
TCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, IArchNetwork::EAddressFamily family = IArchNetwork::kINET); TCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, IArchNetwork::EAddressFamily family = IArchNetwork::kINET);
TCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, ArchSocket socket); TCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, ArchSocket socket);
TCPSocket(TCPSocket const &) =delete;
TCPSocket(TCPSocket &&) =delete;
virtual ~TCPSocket(); virtual ~TCPSocket();
TCPSocket& operator=(TCPSocket const &) =delete;
TCPSocket& operator=(TCPSocket &&) =delete;
// ISocket overrides // ISocket overrides
virtual void bind(const NetworkAddress&); virtual void bind(const NetworkAddress&);
virtual void close(); virtual void close();

View file

@ -34,8 +34,13 @@ public:
//! run() invokes \c object->method(arg) //! run() invokes \c object->method(arg)
TSocketMultiplexerMethodJob(T* object, Method method, TSocketMultiplexerMethodJob(T* object, Method method,
ArchSocket socket, bool readable, bool writeable); ArchSocket socket, bool readable, bool writeable);
TSocketMultiplexerMethodJob(TSocketMultiplexerMethodJob const &) =delete;
TSocketMultiplexerMethodJob(TSocketMultiplexerMethodJob &&) =delete;
virtual ~TSocketMultiplexerMethodJob(); virtual ~TSocketMultiplexerMethodJob();
TSocketMultiplexerMethodJob& operator=(TSocketMultiplexerMethodJob const &) =delete;
TSocketMultiplexerMethodJob& operator=(TSocketMultiplexerMethodJob &&) =delete;
// IJob overrides // IJob overrides
virtual ISocketMultiplexerJob* virtual ISocketMultiplexerJob*
run(bool readable, bool writable, bool error); run(bool readable, bool writable, bool error);

View file

@ -40,8 +40,13 @@ public:
clipboard identified by \c id. clipboard identified by \c id.
*/ */
XWindowsClipboard(Display*, Window window, ClipboardID id); XWindowsClipboard(Display*, Window window, ClipboardID id);
XWindowsClipboard(XWindowsClipboard const &) =delete;
XWindowsClipboard(XWindowsClipboard &&) =delete;
virtual ~XWindowsClipboard(); virtual ~XWindowsClipboard();
XWindowsClipboard& operator=(XWindowsClipboard const &) =delete;
XWindowsClipboard& operator=(XWindowsClipboard &&) =delete;
//! Notify clipboard was lost //! Notify clipboard was lost
/*! /*!
Tells clipboard it lost ownership at the given time. Tells clipboard it lost ownership at the given time.

View file

@ -34,8 +34,13 @@ class IEventQueue;
class XWindowsEventQueueBuffer : public IEventQueueBuffer { class XWindowsEventQueueBuffer : public IEventQueueBuffer {
public: public:
XWindowsEventQueueBuffer(Display*, Window, IEventQueue* events); XWindowsEventQueueBuffer(Display*, Window, IEventQueue* events);
XWindowsEventQueueBuffer(XWindowsEventQueueBuffer const &) =delete;
XWindowsEventQueueBuffer(XWindowsEventQueueBuffer &&) =delete;
virtual ~XWindowsEventQueueBuffer(); virtual ~XWindowsEventQueueBuffer();
XWindowsEventQueueBuffer& operator=(XWindowsEventQueueBuffer const &) =delete;
XWindowsEventQueueBuffer& operator=(XWindowsEventQueueBuffer &&) =delete;
// IEventQueueBuffer overrides // IEventQueueBuffer overrides
virtual void init() { } virtual void init() { }
virtual void waitForEvent(double timeout); virtual void waitForEvent(double timeout);

View file

@ -35,8 +35,13 @@ class EventQueueTimer;
class XWindowsScreenSaver : public IScreenSaver { class XWindowsScreenSaver : public IScreenSaver {
public: public:
XWindowsScreenSaver(Display*, Window, void* eventTarget, IEventQueue* events); XWindowsScreenSaver(Display*, Window, void* eventTarget, IEventQueue* events);
XWindowsScreenSaver(XWindowsScreenSaver const &) =delete;
XWindowsScreenSaver(XWindowsScreenSaver &&) =delete;
virtual ~XWindowsScreenSaver(); virtual ~XWindowsScreenSaver();
XWindowsScreenSaver& operator=(XWindowsScreenSaver const &) =delete;
XWindowsScreenSaver& operator=(XWindowsScreenSaver &&) =delete;
//! @name manipulators //! @name manipulators
//@{ //@{
@ -115,7 +120,7 @@ private:
// the X display // the X display
Display* m_display; Display* m_display;
// window to receive xscreensaver repsonses // window to receive xscreensaver responses
Window m_xscreensaverSink; Window m_xscreensaverSink;
// the target for the events we generate // the target for the events we generate

View file

@ -138,6 +138,11 @@ public:
Ignore X11 errors. Ignore X11 errors.
*/ */
ErrorLock(Display*); ErrorLock(Display*);
ErrorLock(ErrorLock const &) =delete;
ErrorLock(ErrorLock &&) =delete;
ErrorLock& operator=(ErrorLock const &) =delete;
ErrorLock& operator=(ErrorLock &&) =delete;
/*! /*!
Set \c *errorFlag if any error occurs. Set \c *errorFlag if any error occurs.

View file

@ -40,8 +40,13 @@ public:
ISocketFactory*, ISocketFactory*,
IEventQueue* events, IEventQueue* events,
bool enableCrypto); bool enableCrypto);
ClientListener(ClientListener const &) =delete;
ClientListener(ClientListener &&) =delete;
~ClientListener(); ~ClientListener();
ClientListener& operator=(ClientListener const &) =delete;
ClientListener& operator=(ClientListener &&) =delete;
//! @name manipulators //! @name manipulators
//@{ //@{

View file

@ -32,8 +32,13 @@ public:
\c name is the name of the client. \c name is the name of the client.
*/ */
ClientProxy(const String& name, synergy::IStream* adoptedStream); ClientProxy(const String& name, synergy::IStream* adoptedStream);
ClientProxy(ClientProxy const &) =delete;
ClientProxy(ClientProxy &&) =delete;
~ClientProxy(); ~ClientProxy();
ClientProxy& operator=(ClientProxy const &) =delete;
ClientProxy& operator=(ClientProxy &&) =delete;
//! @name manipulators //! @name manipulators
//@{ //@{

View file

@ -30,8 +30,13 @@ class IEventQueue;
class ClientProxy1_0 : public ClientProxy { class ClientProxy1_0 : public ClientProxy {
public: public:
ClientProxy1_0(const String& name, synergy::IStream* adoptedStream, IEventQueue* events); ClientProxy1_0(const String& name, synergy::IStream* adoptedStream, IEventQueue* events);
ClientProxy1_0(ClientProxy1_0 const &) =delete;
ClientProxy1_0(ClientProxy1_0 &&) =delete;
~ClientProxy1_0(); ~ClientProxy1_0();
ClientProxy1_0& operator=(ClientProxy1_0 const &) =delete;
ClientProxy1_0& operator=(ClientProxy1_0 &&) =delete;
// IScreen // IScreen
virtual bool getClipboard(ClipboardID id, IClipboard*) const; virtual bool getClipboard(ClipboardID id, IClipboard*) const;
virtual void getShape(SInt32& x, SInt32& y, virtual void getShape(SInt32& x, SInt32& y,

View file

@ -24,8 +24,13 @@
class ClientProxy1_3 : public ClientProxy1_2 { class ClientProxy1_3 : public ClientProxy1_2 {
public: public:
ClientProxy1_3(const String& name, synergy::IStream* adoptedStream, IEventQueue* events); ClientProxy1_3(const String& name, synergy::IStream* adoptedStream, IEventQueue* events);
ClientProxy1_3(ClientProxy1_3 const &) =delete;
ClientProxy1_3(ClientProxy1_3 &&) =delete;
~ClientProxy1_3(); ~ClientProxy1_3();
ClientProxy1_3& operator=(ClientProxy1_3 const &) =delete;
ClientProxy1_3& operator=(ClientProxy1_3 &&) =delete;
// IClient overrides // IClient overrides
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta); virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta);

View file

@ -28,8 +28,13 @@ class IEventQueue;
class ClientProxy1_5 : public ClientProxy1_4 { class ClientProxy1_5 : public ClientProxy1_4 {
public: public:
ClientProxy1_5(const String& name, synergy::IStream* adoptedStream, Server* server, IEventQueue* events); ClientProxy1_5(const String& name, synergy::IStream* adoptedStream, Server* server, IEventQueue* events);
ClientProxy1_5(ClientProxy1_5 const &) =delete;
ClientProxy1_5(ClientProxy1_5 &&) =delete;
~ClientProxy1_5(); ~ClientProxy1_5();
ClientProxy1_5& operator=(ClientProxy1_5 const &) =delete;
ClientProxy1_5& operator=(ClientProxy1_5 &&) =delete;
virtual void sendDragInfo(UInt32 fileCount, const char* info, size_t size); virtual void sendDragInfo(UInt32 fileCount, const char* info, size_t size);
virtual void fileChunkSending(UInt8 mark, char* data, size_t dataSize); virtual void fileChunkSending(UInt8 mark, char* data, size_t dataSize);
virtual bool parseMessage(const UInt8* code); virtual bool parseMessage(const UInt8* code);

View file

@ -30,8 +30,13 @@ class IEventQueue;
class ClientProxyUnknown { class ClientProxyUnknown {
public: public:
ClientProxyUnknown(synergy::IStream* stream, double timeout, Server* server, IEventQueue* events); ClientProxyUnknown(synergy::IStream* stream, double timeout, Server* server, IEventQueue* events);
ClientProxyUnknown(ClientProxyUnknown const &) =delete;
ClientProxyUnknown(ClientProxyUnknown &&) =delete;
~ClientProxyUnknown(); ~ClientProxyUnknown();
ClientProxyUnknown& operator=(ClientProxyUnknown const &) =delete;
ClientProxyUnknown& operator=(ClientProxyUnknown &&) =delete;
//! @name manipulators //! @name manipulators
//@{ //@{

View file

@ -151,6 +151,8 @@ public:
public: public:
explicit const_iterator() : m_i() { } explicit const_iterator() : m_i() { }
explicit const_iterator(const internal_const_iterator& i) : m_i(i) { } explicit const_iterator(const internal_const_iterator& i) : m_i(i) { }
const_iterator(const const_iterator &src) =default;
~const_iterator() =default;
const_iterator& operator=(const const_iterator& i) { const_iterator& operator=(const const_iterator& i) {
m_i = i.m_i; m_i = i.m_i;

View file

@ -228,8 +228,13 @@ public:
class KeystrokeAction : public Action { class KeystrokeAction : public Action {
public: public:
KeystrokeAction(IEventQueue* events, IPlatformScreen::KeyInfo* adoptedInfo, bool press); KeystrokeAction(IEventQueue* events, IPlatformScreen::KeyInfo* adoptedInfo, bool press);
KeystrokeAction(KeystrokeAction const &) =delete;
KeystrokeAction(KeystrokeAction &&) =delete;
~KeystrokeAction(); ~KeystrokeAction();
KeystrokeAction& operator=(KeystrokeAction const &) =delete;
KeystrokeAction& operator=(KeystrokeAction &&) =delete;
void adoptInfo(IPlatformScreen::KeyInfo*); void adoptInfo(IPlatformScreen::KeyInfo*);
const IPlatformScreen::KeyInfo* const IPlatformScreen::KeyInfo*
getInfo() const; getInfo() const;
@ -255,8 +260,13 @@ public:
MouseButtonAction(IEventQueue* events, MouseButtonAction(IEventQueue* events,
IPlatformScreen::ButtonInfo* adoptedInfo, IPlatformScreen::ButtonInfo* adoptedInfo,
bool press); bool press);
MouseButtonAction(MouseButtonAction const &) =delete;
MouseButtonAction(MouseButtonAction &&) =delete;
~MouseButtonAction(); ~MouseButtonAction();
MouseButtonAction& operator=(MouseButtonAction const &) =delete;
MouseButtonAction& operator=(MouseButtonAction &&) =delete;
const IPlatformScreen::ButtonInfo* const IPlatformScreen::ButtonInfo*
getInfo() const; getInfo() const;
bool isOnPress() const; bool isOnPress() const;

View file

@ -108,8 +108,13 @@ public:
*/ */
Server(Config& config, PrimaryClient* primaryClient, Server(Config& config, PrimaryClient* primaryClient,
synergy::Screen* screen, IEventQueue* events, lib::synergy::ServerArgs const& args); synergy::Screen* screen, IEventQueue* events, lib::synergy::ServerArgs const& args);
Server(Server const &) =delete;
Server(Server &&) =delete;
~Server(); ~Server();
Server& operator=(Server const &) =delete;
Server& operator=(Server &&) =delete;
#ifdef TEST_ENV #ifdef TEST_ENV
Server() : m_mock(true), m_config(NULL) { } Server() : m_mock(true), m_config(NULL) { }
void setActive(BaseClientProxy* active) { m_active = active; } void setActive(BaseClientProxy* active) { m_active = active; }

View file

@ -44,8 +44,13 @@ typedef IArchTaskBarReceiver* (*CreateTaskBarReceiverFunc)(const BufferedLogOutp
class App : public IApp { class App : public IApp {
public: public:
App(IEventQueue* events, CreateTaskBarReceiverFunc createTaskBarReceiver, lib::synergy::ArgsBase* args); App(IEventQueue* events, CreateTaskBarReceiverFunc createTaskBarReceiver, lib::synergy::ArgsBase* args);
App(App const &) =delete;
App(App &&) =delete;
virtual ~App(); virtual ~App();
App& operator=(App const &) =delete;
App& operator=(App &&) =delete;
// Returns args that are common between server and client. // Returns args that are common between server and client.
lib::synergy::ArgsBase& argsBase() const { return *m_args; } lib::synergy::ArgsBase& argsBase() const { return *m_args; }

View file

@ -22,8 +22,13 @@
class Chunk { class Chunk {
public: public:
Chunk(size_t size); Chunk(size_t size);
Chunk(Chunk const &) =delete;
Chunk(Chunk &&) =delete;
~Chunk(); ~Chunk();
Chunk& operator=(Chunk const &) =delete;
Chunk& operator=(Chunk &&) =delete;
public: public:
size_t m_dataSize; size_t m_dataSize;
char* m_chunk; char* m_chunk;

View file

@ -40,8 +40,13 @@ primary or secondary screen.
class Screen : public IScreen { class Screen : public IScreen {
public: public:
Screen(IPlatformScreen* platformScreen, IEventQueue* events); Screen(IPlatformScreen* platformScreen, IEventQueue* events);
Screen(Screen const &) =delete;
Screen(Screen &&) =delete;
virtual ~Screen(); virtual ~Screen();
Screen& operator&(Screen const &) =delete;
Screen& operator&(Screen &&) =delete;
#ifdef TEST_ENV #ifdef TEST_ENV
Screen() : m_mock(true) { } Screen() : m_mock(true) { }
#endif #endif

View file

@ -789,7 +789,7 @@ ServerApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc
{ {
// general initialization // general initialization
m_synergyAddress = new NetworkAddress; m_synergyAddress = new NetworkAddress;
args().m_config = new Config(m_events); args().m_config = std::make_shared<Config>(m_events);
args().m_pname = ARCH->getBasename(argv[0]); args().m_pname = ARCH->getBasename(argv[0]);
// install caller's output filter // install caller's output filter
@ -806,7 +806,6 @@ ServerApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc
delete m_taskBarReceiver; delete m_taskBarReceiver;
} }
delete args().m_config;
delete m_synergyAddress; delete m_synergyAddress;
return result; return result;
} }

View file

@ -21,7 +21,6 @@ namespace lib {
namespace synergy { namespace synergy {
ServerArgs::~ServerArgs() { ServerArgs::~ServerArgs() {
destroy(m_config);
} }

View file

@ -18,6 +18,7 @@
#ifndef SYNERGY_CORE_SERVERARGS_H #ifndef SYNERGY_CORE_SERVERARGS_H
#define SYNERGY_CORE_SERVERARGS_H #define SYNERGY_CORE_SERVERARGS_H
#include <memory>
#include "ArgsBase.h" #include "ArgsBase.h"
#include "shared/SerialKey.h" #include "shared/SerialKey.h"
#include "server/Config.h" #include "server/Config.h"
@ -28,13 +29,18 @@ namespace lib {
/// Public Functions /// Public Functions
public: public:
ServerArgs(); ServerArgs();
ServerArgs(ServerArgs const &src) =default;
ServerArgs(ServerArgs &&) =default;
~ServerArgs() override; ~ServerArgs() override;
ServerArgs& operator=(ServerArgs const &) =default;
ServerArgs& operator=(ServerArgs &&) =default;
/// Public variables /// Public variables
public: public:
String m_configFile = ""; /// @brief Contains the path to the config file String m_configFile = ""; /// @brief Contains the path to the config file
SerialKey m_serial; /// @brief Contains the serial number and license info SerialKey m_serial; /// @brief Contains the serial number and license info
Config* m_config = nullptr; /// @brief Contains the Parsed Configuration settings std::shared_ptr<Config> m_config; /// @brief Contains the Parsed Configuration settings
/// Private Functions /// Private Functions
private: private:

View file

@ -0,0 +1,49 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "synergy/ArgParser.h"
#include "synergy/ServerArgs.h"
#define TEST_ENV
#include "synergy/ServerApp.h"
#include "test/global/gmock.h"
class MockServerApp : public ServerApp
{
public:
MockServerApp() : ServerApp(nullptr, nullptr) { }
};
#include "test/global/gtest.h"
// using ::testing::_;
// using ::testing::Invoke;
using ::testing::NiceMock;
TEST(ServerAppTests, runInner_will_handle_configuration_lifetime)
{
NiceMock<MockServerApp> app;
EXPECT_FALSE(app.args().m_config);
const char *argv[] {"synergyc"};
app.runInner(1, const_cast<char **>(argv), nullptr, [](int,char**){ return 0; });
EXPECT_TRUE(app.args().m_config);
}

View file

@ -37,6 +37,14 @@ server_stubCheckUnexpectedArgs()
return false; return false;
} }
TEST(ServerArgs, ServerArgs_will_construct_from_copy)
{
lib::synergy::ServerArgs serverArgs;
serverArgs.m_display = "display0";
auto serverArgs2 {serverArgs};
EXPECT_EQ(serverArgs.m_display, serverArgs2.m_display);
}
TEST(ServerArgsParsingTests, parseServerArgs_addressArg_setSynergyAddress) TEST(ServerArgsParsingTests, parseServerArgs_addressArg_setSynergyAddress)
{ {
NiceMock<MockArgParser> argParser; NiceMock<MockArgParser> argParser;