#5657 Use SerialKey class in ServerArgs
This commit is contained in:
parent
88c59b4ca6
commit
99dbdc5eb3
|
@ -2,11 +2,11 @@
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2012-2016 Symless Ltd.
|
* Copyright (C) 2012-2016 Symless Ltd.
|
||||||
* Copyright (C) 2002 Chris Schoeneman
|
* Copyright (C) 2002 Chris Schoeneman
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* found in the file LICENSE that should have accompanied this file.
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
*
|
*
|
||||||
* This package is distributed in the hope that it will be useful,
|
* This package is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
@ -453,15 +453,11 @@ 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 trial is expired, exit the process
|
||||||
if (!m_args.m_serial.empty()) {
|
if (!m_args.m_serial.isExpired(std::time(0))) {
|
||||||
SerialKey serial(m_args.m_serial);
|
LOG((CLOG_ERR "trial is expired, aborting server"));
|
||||||
if (!serial.isValid(std::time(0))) {
|
exit(kExitSuccess);
|
||||||
LOG((CLOG_ERR "trial is expired, aborting server"));
|
|
||||||
exit(kExitSuccess);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -547,7 +543,7 @@ Server::jumpToScreen(BaseClientProxy* newScreen)
|
||||||
// get the last cursor position on the target screen
|
// get the last cursor position on the target screen
|
||||||
SInt32 x, y;
|
SInt32 x, y;
|
||||||
newScreen->getJumpCursorPos(x, y);
|
newScreen->getJumpCursorPos(x, y);
|
||||||
|
|
||||||
switchScreen(newScreen, x, y, false);
|
switchScreen(newScreen, x, y, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,14 +893,14 @@ Server::isSwitchOkay(BaseClientProxy* newScreen,
|
||||||
|
|
||||||
if (!preventSwitch && (
|
if (!preventSwitch && (
|
||||||
(this->m_switchNeedsShift && ((mods & KeyModifierShift) != KeyModifierShift)) ||
|
(this->m_switchNeedsShift && ((mods & KeyModifierShift) != KeyModifierShift)) ||
|
||||||
(this->m_switchNeedsControl && ((mods & KeyModifierControl) != KeyModifierControl)) ||
|
(this->m_switchNeedsControl && ((mods & KeyModifierControl) != KeyModifierControl)) ||
|
||||||
(this->m_switchNeedsAlt && ((mods & KeyModifierAlt) != KeyModifierAlt))
|
(this->m_switchNeedsAlt && ((mods & KeyModifierAlt) != KeyModifierAlt))
|
||||||
)) {
|
)) {
|
||||||
LOG((CLOG_DEBUG1 "need modifiers to switch"));
|
LOG((CLOG_DEBUG1 "need modifiers to switch"));
|
||||||
preventSwitch = true;
|
preventSwitch = true;
|
||||||
stopSwitch();
|
stopSwitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
return !preventSwitch;
|
return !preventSwitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1184,7 +1180,7 @@ Server::processOptions()
|
||||||
}
|
}
|
||||||
else if (id == kOptionClipboardSharing) {
|
else if (id == kOptionClipboardSharing) {
|
||||||
m_enableClipboard = (value != 0);
|
m_enableClipboard = (value != 0);
|
||||||
|
|
||||||
if (m_enableClipboard == false) {
|
if (m_enableClipboard == false) {
|
||||||
LOG((CLOG_NOTE "clipboard sharing is disabled"));
|
LOG((CLOG_NOTE "clipboard sharing is disabled"));
|
||||||
}
|
}
|
||||||
|
@ -1413,7 +1409,7 @@ Server::handleClientCloseTimeout(const Event&, void* vclient)
|
||||||
void
|
void
|
||||||
Server::handleSwitchToScreenEvent(const Event& event, void*)
|
Server::handleSwitchToScreenEvent(const Event& event, void*)
|
||||||
{
|
{
|
||||||
SwitchToScreenInfo* info =
|
SwitchToScreenInfo* info =
|
||||||
static_cast<SwitchToScreenInfo*>(event.getData());
|
static_cast<SwitchToScreenInfo*>(event.getData());
|
||||||
|
|
||||||
ClientList::const_iterator index = m_clients.find(info->m_screen);
|
ClientList::const_iterator index = m_clients.find(info->m_screen);
|
||||||
|
@ -1428,7 +1424,7 @@ Server::handleSwitchToScreenEvent(const Event& event, void*)
|
||||||
void
|
void
|
||||||
Server::handleSwitchInDirectionEvent(const Event& event, void*)
|
Server::handleSwitchInDirectionEvent(const Event& event, void*)
|
||||||
{
|
{
|
||||||
SwitchInDirectionInfo* info =
|
SwitchInDirectionInfo* info =
|
||||||
static_cast<SwitchInDirectionInfo*>(event.getData());
|
static_cast<SwitchInDirectionInfo*>(event.getData());
|
||||||
|
|
||||||
// jump to screen in chosen direction from center of this screen
|
// jump to screen in chosen direction from center of this screen
|
||||||
|
@ -1718,7 +1714,7 @@ Server::onMouseUp(ButtonID id)
|
||||||
m_ignoreFileTransfer = false;
|
m_ignoreFileTransfer = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_args.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();
|
||||||
|
@ -1823,7 +1819,7 @@ Server::onMouseMovePrimary(SInt32 x, SInt32 y)
|
||||||
m_waitDragInfoThread = true;
|
m_waitDragInfoThread = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1839,7 +1835,7 @@ Server::sendDragInfoThread(void* arg)
|
||||||
di.setFilename(dragFileList);
|
di.setFilename(dragFileList);
|
||||||
m_dragFileList.push_back(di);
|
m_dragFileList.push_back(di);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
// on mac it seems that after faking a LMB up, system would signal back
|
// on mac it seems that after faking a LMB up, system would signal back
|
||||||
// to synergy a mouse up event, which doesn't happen on windows. as a
|
// to synergy a mouse up event, which doesn't happen on windows. as a
|
||||||
|
@ -1862,7 +1858,7 @@ Server::sendDragInfo(BaseClientProxy* newScreen)
|
||||||
{
|
{
|
||||||
String infoString;
|
String infoString;
|
||||||
UInt32 fileCount = DragInformation::setupDragInfo(m_dragFileList, infoString);
|
UInt32 fileCount = DragInformation::setupDragInfo(m_dragFileList, infoString);
|
||||||
|
|
||||||
if (fileCount > 0) {
|
if (fileCount > 0) {
|
||||||
char* info = NULL;
|
char* info = NULL;
|
||||||
size_t size = infoString.size();
|
size_t size = infoString.size();
|
||||||
|
@ -2072,7 +2068,7 @@ Server::onFileChunkSending(const void* data)
|
||||||
assert(m_active != NULL);
|
assert(m_active != NULL);
|
||||||
|
|
||||||
// relay
|
// relay
|
||||||
m_active->fileChunkSending(chunk->m_chunk[0], &chunk->m_chunk[1], chunk->m_dataSize);
|
m_active->fileChunkSending(chunk->m_chunk[0], &chunk->m_chunk[1], chunk->m_dataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2381,7 +2377,7 @@ Server::sendFileToClient(const char* filename)
|
||||||
if (m_sendFileThread != NULL) {
|
if (m_sendFileThread != NULL) {
|
||||||
StreamChunker::interruptFile();
|
StreamChunker::interruptFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sendFileThread = new Thread(
|
m_sendFileThread = new Thread(
|
||||||
new TMethodJob<Server>(
|
new TMethodJob<Server>(
|
||||||
this, &Server::sendFileThread,
|
this, &Server::sendFileThread,
|
||||||
|
|
|
@ -48,9 +48,6 @@ private:
|
||||||
|
|
||||||
#ifdef TEST_ENV
|
#ifdef TEST_ENV
|
||||||
private:
|
private:
|
||||||
FRIEND_TEST(SerialKeyTests, decode_empty_returnEmptyString);
|
|
||||||
FRIEND_TEST(SerialKeyTests, decode_invalidDigit_returnEmptyString);
|
|
||||||
FRIEND_TEST(SerialKeyTests, decode_validSerial_returnPlainText);
|
|
||||||
FRIEND_TEST(SerialKeyTests, parse_noParty_invalid);
|
FRIEND_TEST(SerialKeyTests, parse_noParty_invalid);
|
||||||
FRIEND_TEST(SerialKeyTests, parse_invalidPartsLenghth_invalid);
|
FRIEND_TEST(SerialKeyTests, parse_invalidPartsLenghth_invalid);
|
||||||
FRIEND_TEST(SerialKeyTests, parse_validV1Serial_valid);
|
FRIEND_TEST(SerialKeyTests, parse_validV1Serial_valid);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2014-2016 Symless Ltd.
|
* Copyright (C) 2014-2016 Symless Ltd.
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* found in the file LICENSE that should have accompanied this file.
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
*
|
*
|
||||||
* This package is distributed in the hope that it will be useful,
|
* This package is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
@ -71,7 +71,7 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv)
|
||||||
DpiHelper::s_primaryHeightCenter = synergy::string::stringToSizeType(argv[++i]);
|
DpiHelper::s_primaryHeightCenter = synergy::string::stringToSizeType(argv[++i]);
|
||||||
}
|
}
|
||||||
else if (isArg(i, argc, argv, "", "--serial-key", 1)) {
|
else if (isArg(i, argc, argv, "", "--serial-key", 1)) {
|
||||||
args.m_serial = argv[++i];
|
args.m_serial = SerialKey(argv[++i]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname));
|
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname));
|
||||||
|
@ -110,7 +110,7 @@ ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv)
|
||||||
// ignore -- included for backwards compatibility
|
// ignore -- included for backwards compatibility
|
||||||
}
|
}
|
||||||
else if (isArg(i, argc, argv, NULL, "--yscroll", 1)) {
|
else if (isArg(i, argc, argv, NULL, "--yscroll", 1)) {
|
||||||
// define scroll
|
// define scroll
|
||||||
args.m_yscroll = atoi(argv[++i]);
|
args.m_yscroll = atoi(argv[++i]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -271,10 +271,10 @@ ArgParser::parseGenericArgs(int argc, const char* const* argv, int& i)
|
||||||
argsBase().m_enableIpc = true;
|
argsBase().m_enableIpc = true;
|
||||||
}
|
}
|
||||||
else if (isArg(i, argc, argv, NULL, "--server")) {
|
else if (isArg(i, argc, argv, NULL, "--server")) {
|
||||||
// HACK: stop error happening when using portable (synergyp)
|
// HACK: stop error happening when using portable (synergyp)
|
||||||
}
|
}
|
||||||
else if (isArg(i, argc, argv, NULL, "--client")) {
|
else if (isArg(i, argc, argv, NULL, "--client")) {
|
||||||
// HACK: stop error happening when using portable (synergyp)
|
// HACK: stop error happening when using portable (synergyp)
|
||||||
}
|
}
|
||||||
else if (isArg(i, argc, argv, NULL, "--enable-drag-drop")) {
|
else if (isArg(i, argc, argv, NULL, "--enable-drag-drop")) {
|
||||||
bool useDragDrop = true;
|
bool useDragDrop = true;
|
||||||
|
@ -378,7 +378,7 @@ ArgParser::splitCommandString(String& command, std::vector<String>& argv)
|
||||||
else if (space > rightDoubleQuote){
|
else if (space > rightDoubleQuote){
|
||||||
searchDoubleQuotes(command, leftDoubleQuote, rightDoubleQuote, rightDoubleQuote + 1);
|
searchDoubleQuotes(command, leftDoubleQuote, rightDoubleQuote, rightDoubleQuote + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ignoreThisSpace) {
|
if (!ignoreThisSpace) {
|
||||||
String subString = command.substr(startPos, space - startPos);
|
String subString = command.substr(startPos, space - startPos);
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ ArgParser::getArgv(std::vector<String>& argsArray)
|
||||||
// them to the inner array. So caller only need to use
|
// them to the inner array. So caller only need to use
|
||||||
// delete[] to delete the outer array
|
// delete[] to delete the outer array
|
||||||
const char** argv = new const char*[argc];
|
const char** argv = new const char*[argc];
|
||||||
|
|
||||||
for (size_t i = 0; i < argc; i++) {
|
for (size_t i = 0; i < argc; i++) {
|
||||||
argv[i] = argsArray[i].c_str();
|
argv[i] = argsArray[i].c_str();
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,7 @@ ArgParser::assembleCommand(std::vector<String>& argsArray, String ignoreArg, in
|
||||||
|
|
||||||
if (!result.empty()) {
|
if (!result.empty()) {
|
||||||
// remove the tail space
|
// remove the tail space
|
||||||
result = result.substr(0, result.size() - 1);
|
result = result.substr(0, result.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -493,13 +493,13 @@ bool
|
||||||
ArgParser::checkUnexpectedArgs()
|
ArgParser::checkUnexpectedArgs()
|
||||||
{
|
{
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
// suggest that user installs as a windows service. when launched as
|
// suggest that user installs as a windows service. when launched as
|
||||||
// service, process should automatically detect that it should run in
|
// service, process should automatically detect that it should run in
|
||||||
// daemon mode.
|
// daemon mode.
|
||||||
if (argsBase().m_daemon) {
|
if (argsBase().m_daemon) {
|
||||||
LOG((CLOG_ERR
|
LOG((CLOG_ERR
|
||||||
"the --daemon argument is not supported on windows. "
|
"the --daemon argument is not supported on windows. "
|
||||||
"instead, install %s as a service (--service install)",
|
"instead, install %s as a service (--service install)",
|
||||||
argsBase().m_pname));
|
argsBase().m_pname));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2014-2016 Symless Ltd.
|
* Copyright (C) 2014-2016 Symless Ltd.
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* found in the file LICENSE that should have accompanied this file.
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
*
|
*
|
||||||
* This package is distributed in the hope that it will be useful,
|
* This package is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "synergy/ArgsBase.h"
|
#include "synergy/ArgsBase.h"
|
||||||
|
#include "shared/SerialKey.h"
|
||||||
|
|
||||||
class NetworkAddress;
|
class NetworkAddress;
|
||||||
class Config;
|
class Config;
|
||||||
|
@ -28,6 +29,6 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
String m_configFile;
|
String m_configFile;
|
||||||
String m_serial;
|
SerialKey m_serial;
|
||||||
Config* m_config;
|
Config* m_config;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2014-2016 Symless Ltd.
|
* Copyright (C) 2014-2016 Symless Ltd.
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* found in the file LICENSE that should have accompanied this file.
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
*
|
*
|
||||||
* This package is distributed in the hope that it will be useful,
|
* This package is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
@ -64,17 +64,3 @@ TEST(ServerArgsParsingTests, parseServerArgs_configArg_setConfigFile)
|
||||||
|
|
||||||
EXPECT_EQ("mock_configFile", serverArgs.m_configFile);
|
EXPECT_EQ("mock_configFile", serverArgs.m_configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ServerArgsParsingTests, parseServerArgs_serialArg_setSerial)
|
|
||||||
{
|
|
||||||
NiceMock<MockArgParser> argParser;
|
|
||||||
ON_CALL(argParser, parseGenericArgs(_, _, _)).WillByDefault(Invoke(server_stubParseGenericArgs));
|
|
||||||
ON_CALL(argParser, checkUnexpectedArgs()).WillByDefault(Invoke(server_stubCheckUnexpectedArgs));
|
|
||||||
ServerArgs serverArgs;
|
|
||||||
const int argc = 3;
|
|
||||||
const char* kSerialCmd[argc] = { "stub", "--serial-key", "mock_serial" };
|
|
||||||
|
|
||||||
argParser.parseServerArgs(serverArgs, argc, kSerialCmd);
|
|
||||||
|
|
||||||
EXPECT_EQ("mock_serial", serverArgs.m_serial);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue