#5657 Exited server if trial is expired

This commit is contained in:
Jerry (Xinyu Hou) 2016-10-14 17:14:21 +01:00
parent 2b1b0640ea
commit 89851fddc3
4 changed files with 26 additions and 10 deletions

View File

@ -35,6 +35,8 @@ endif()
add_library(server STATIC ${sources}) add_library(server STATIC ${sources})
target_link_libraries(server shared)
if (UNIX) if (UNIX)
target_link_libraries(server synergy) target_link_libraries(server synergy)
endif() endif()

View File

@ -45,11 +45,13 @@
#include "base/Log.h" #include "base/Log.h"
#include "base/TMethodEventJob.h" #include "base/TMethodEventJob.h"
#include "common/stdexcept.h" #include "common/stdexcept.h"
#include "shared/SerialKey.h"
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
#include <ctime>
// //
// Server // Server
@ -60,7 +62,7 @@ Server::Server(
PrimaryClient* primaryClient, PrimaryClient* primaryClient,
synergy::Screen* screen, synergy::Screen* screen,
IEventQueue* events, IEventQueue* events,
bool enableDragDrop) : ServerArgs const& args) :
m_mock(false), m_mock(false),
m_primaryClient(primaryClient), m_primaryClient(primaryClient),
m_active(primaryClient), m_active(primaryClient),
@ -91,10 +93,10 @@ Server::Server(
m_sendFileThread(NULL), m_sendFileThread(NULL),
m_writeToDropDirThread(NULL), m_writeToDropDirThread(NULL),
m_ignoreFileTransfer(false), m_ignoreFileTransfer(false),
m_enableDragDrop(enableDragDrop),
m_enableClipboard(true), m_enableClipboard(true),
m_sendDragInfoThread(NULL), m_sendDragInfoThread(NULL),
m_waitDragInfoThread(true) m_waitDragInfoThread(true),
m_args(args)
{ {
// must have a primary client and it must have a canonical name // must have a primary client and it must have a canonical name
assert(m_primaryClient != NULL); assert(m_primaryClient != NULL);
@ -184,7 +186,7 @@ Server::Server(
new TMethodEventJob<Server>(this, new TMethodEventJob<Server>(this,
&Server::handleFakeInputEndEvent)); &Server::handleFakeInputEndEvent));
if (m_enableDragDrop) { if (m_args.m_enableDragDrop) {
m_events->adoptHandler(m_events->forFile().fileChunkSending(), m_events->adoptHandler(m_events->forFile().fileChunkSending(),
this, this,
new TMethodEventJob<Server>(this, new TMethodEventJob<Server>(this,
@ -451,6 +453,17 @@ Server::switchScreen(BaseClientProxy* dst,
SInt32 x, SInt32 y, bool forScreensaver) SInt32 x, SInt32 y, bool forScreensaver)
{ {
assert(dst != NULL); assert(dst != NULL);
// if trial is expired, exit the process
if (!m_args.m_serial.empty()) {
SerialKey serial(m_args.m_serial);
if (!serial.isValid(std::time(0))) {
LOG((CLOG_ERR "trial is expired, aborting server"));
exit(kExitSuccess);
return;
}
}
#ifndef NDEBUG #ifndef NDEBUG
{ {
SInt32 dx, dy, dw, dh; SInt32 dx, dy, dw, dh;
@ -1706,7 +1719,7 @@ Server::onMouseUp(ButtonID id)
return; return;
} }
if (m_enableDragDrop) { if (m_args.m_enableDragDrop) {
if (!m_screen->isOnScreen()) { if (!m_screen->isOnScreen()) {
String& file = m_screen->getDraggingFilename(); String& file = m_screen->getDraggingFilename();
if (!file.empty()) { if (!file.empty()) {
@ -1791,7 +1804,7 @@ Server::onMouseMovePrimary(SInt32 x, SInt32 y)
// should we switch or not? // should we switch or not?
if (isSwitchOkay(newScreen, dir, x, y, xc, yc)) { if (isSwitchOkay(newScreen, dir, x, y, xc, yc)) {
if (m_enableDragDrop if (m_args.m_enableDragDrop
&& m_screen->isDraggingStarted() && m_screen->isDraggingStarted()
&& m_active != newScreen && m_active != newScreen
&& m_waitDragInfoThread) { && m_waitDragInfoThread) {
@ -2393,7 +2406,7 @@ Server::sendFileThread(void* data)
void void
Server::dragInfoReceived(UInt32 fileNum, String content) Server::dragInfoReceived(UInt32 fileNum, String content)
{ {
if (!m_enableDragDrop) { if (!m_args.m_enableDragDrop) {
LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info.")); LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info."));
return; return;
} }

View File

@ -25,6 +25,7 @@
#include "synergy/mouse_types.h" #include "synergy/mouse_types.h"
#include "synergy/INode.h" #include "synergy/INode.h"
#include "synergy/DragInformation.h" #include "synergy/DragInformation.h"
#include "synergy/ServerArgs.h"
#include "base/Event.h" #include "base/Event.h"
#include "base/Stopwatch.h" #include "base/Stopwatch.h"
#include "base/EventTypes.h" #include "base/EventTypes.h"
@ -106,7 +107,7 @@ public:
ownership of \p primaryClient. ownership of \p primaryClient.
*/ */
Server(Config& config, PrimaryClient* primaryClient, Server(Config& config, PrimaryClient* primaryClient,
synergy::Screen* screen, IEventQueue* events, bool enableDragDrop); synergy::Screen* screen, IEventQueue* events, ServerArgs const& args);
~Server(); ~Server();
#ifdef TEST_ENV #ifdef TEST_ENV
@ -472,11 +473,11 @@ private:
Thread* m_writeToDropDirThread; Thread* m_writeToDropDirThread;
String m_dragFileExt; String m_dragFileExt;
bool m_ignoreFileTransfer; bool m_ignoreFileTransfer;
bool m_enableDragDrop;
bool m_enableClipboard; bool m_enableClipboard;
Thread* m_sendDragInfoThread; Thread* m_sendDragInfoThread;
bool m_waitDragInfoThread; bool m_waitDragInfoThread;
ClientListener* m_clientListener; ClientListener* m_clientListener;
ServerArgs m_args;
}; };

View File

@ -647,7 +647,7 @@ ServerApp::openClientListener(const NetworkAddress& address)
Server* Server*
ServerApp::openServer(Config& config, PrimaryClient* primaryClient) ServerApp::openServer(Config& config, PrimaryClient* primaryClient)
{ {
Server* server = new Server(config, primaryClient, m_serverScreen, m_events, args().m_enableDragDrop); Server* server = new Server(config, primaryClient, m_serverScreen, m_events, args());
try { try {
m_events->adoptHandler( m_events->adoptHandler(
m_events->forServer().disconnected(), server, m_events->forServer().disconnected(), server,