* Add missing atom ctor init * Init members with `None` * Use in-class init and delcare getter inside if init * Temp revert of changes ahead of unit test repair * Move IPC header to shared, restore X clipboard test, simplify test cmake, new X clipboard unit test * Suppress sonar for undefs * Remove base dir include * Revert "Temp revert of changes ahead of unit test repair" This reverts commit 8f84b6ea5d5828f1be1362de3809279bcacb8cc8. * Use new accessor * Use default dtor * Beef up to 32 core * Use enum class * Make IPC protocol headers const at all levels * Use enum class and const char for better type safety * Use unique_ptr for m_clipboard * Use `-j` instead of `-j8` to utilize full parallelism * Increase thread count for sonar-scanner * Use 32 threads * Use in-class init for IpcClientProxy members * Use const instead of #define * Remove ctor member inits * Use unique_ptr on win * Implement temp bin dir for windows with more robust post-build copy * Fixed missing iostream * Add warning about copy errors * Only run clean-gcda on Linux * Use in-class init for IPC mutex * Do no-op on Windows * Hide clean-gcda task * Move flakey test to integtests * Delete dead code * Test * Temp disable post_config_all * Disable post config step * Revert "Disable post config step" This reverts commit 2f956a7714ba9bedacd4b39d4ae00940c3d565d6. * Revert "Temp disable post_config_all" This reverts commit b44ed72e44f838bfe1309f6e9672d2f1c6f21b75. * Restore -j8 * Simplify error handling * Use const for test port * Remove python check * Update changelog * Fixed order * Fixed bad issue number * Fixed bin copy source path * Remove redundant except
121 lines
3.0 KiB
C++
121 lines
3.0 KiB
C++
/*
|
|
* synergy -- mouse and keyboard sharing utility
|
|
* Copyright (C) 2012-2016 Symless Ltd.
|
|
* Copyright (C) 2012 Nick Bolton
|
|
*
|
|
* 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/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "arch/Arch.h"
|
|
#include "arch/IArchMultithread.h"
|
|
#include "base/ILogOutputter.h"
|
|
#include "shared/Ipc.h"
|
|
|
|
#include <deque>
|
|
|
|
class IpcServer;
|
|
class Event;
|
|
class IpcClientProxy;
|
|
|
|
//! Write log to GUI over IPC
|
|
/*!
|
|
This outputter writes output to the GUI via IPC.
|
|
*/
|
|
class IpcLogOutputter : public ILogOutputter {
|
|
public:
|
|
/*!
|
|
If \p useThread is \c true, the buffer will be sent using a thread.
|
|
If \p useThread is \c false, then the buffer needs to be sent manually
|
|
using the \c sendBuffer() function.
|
|
*/
|
|
IpcLogOutputter(
|
|
IpcServer &ipcServer, IpcClientType clientType, bool useThread);
|
|
IpcLogOutputter(IpcLogOutputter const &) = delete;
|
|
virtual ~IpcLogOutputter();
|
|
|
|
// ILogOutputter overrides
|
|
virtual void open(const char *title);
|
|
virtual void close();
|
|
virtual void show(bool showIfEmpty);
|
|
virtual bool write(ELevel level, const char *message);
|
|
|
|
//! @name manipulators
|
|
//@{
|
|
|
|
//! Notify that the buffer should be sent.
|
|
void notifyBuffer();
|
|
|
|
//! Set the buffer size
|
|
/*!
|
|
Set the maximum size of the buffer to protect memory
|
|
from runaway logging.
|
|
*/
|
|
void bufferMaxSize(UInt16 bufferMaxSize);
|
|
|
|
//! Set the rate limit
|
|
/*!
|
|
Set the maximum number of \p writeRate for every \p timeRate in seconds.
|
|
*/
|
|
void bufferRateLimit(UInt16 writeLimit, double timeLimit);
|
|
|
|
//! Send the buffer
|
|
/*!
|
|
Sends a chunk of the buffer to the IPC server, normally called
|
|
when threaded mode is on.
|
|
*/
|
|
void sendBuffer();
|
|
|
|
//@}
|
|
|
|
//! @name accessors
|
|
//@{
|
|
|
|
//! Get the buffer size
|
|
/*!
|
|
Returns the maximum size of the buffer.
|
|
*/
|
|
UInt16 bufferMaxSize() const;
|
|
|
|
//@}
|
|
|
|
private:
|
|
void init();
|
|
void bufferThread(void *);
|
|
String getChunk(size_t count);
|
|
void appendBuffer(const String &text);
|
|
bool isRunning();
|
|
|
|
private:
|
|
typedef std::deque<String> Buffer;
|
|
|
|
IpcServer &m_ipcServer;
|
|
Buffer m_buffer;
|
|
ArchMutex m_bufferMutex;
|
|
bool m_sending;
|
|
Thread *m_bufferThread;
|
|
bool m_running;
|
|
ArchCond m_notifyCond;
|
|
ArchMutex m_notifyMutex;
|
|
bool m_bufferWaiting;
|
|
IArchMultithread::ThreadID m_bufferThreadId;
|
|
UInt16 m_bufferMaxSize;
|
|
UInt16 m_bufferRateWriteLimit;
|
|
double m_bufferRateTimeLimit;
|
|
UInt16 m_bufferWriteCount;
|
|
double m_bufferRateStart;
|
|
IpcClientType m_clientType;
|
|
ArchMutex m_runningMutex;
|
|
};
|