mirror of
https://github.com/debauchee/barrier.git
synced 2026-02-10 21:56:13 +08:00
#5657 Merge trial support
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless Ltd.
|
||||
* Copyright (C) 2002 Chris Schoeneman
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -45,11 +45,13 @@
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "common/stdexcept.h"
|
||||
#include "shared/SerialKey.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <ctime>
|
||||
|
||||
//
|
||||
// Server
|
||||
@@ -60,7 +62,7 @@ Server::Server(
|
||||
PrimaryClient* primaryClient,
|
||||
synergy::Screen* screen,
|
||||
IEventQueue* events,
|
||||
bool enableDragDrop) :
|
||||
ServerArgs const& args) :
|
||||
m_mock(false),
|
||||
m_primaryClient(primaryClient),
|
||||
m_active(primaryClient),
|
||||
@@ -91,10 +93,10 @@ Server::Server(
|
||||
m_sendFileThread(NULL),
|
||||
m_writeToDropDirThread(NULL),
|
||||
m_ignoreFileTransfer(false),
|
||||
m_enableDragDrop(enableDragDrop),
|
||||
m_enableClipboard(true),
|
||||
m_sendDragInfoThread(NULL),
|
||||
m_waitDragInfoThread(true)
|
||||
m_waitDragInfoThread(true),
|
||||
m_args(args)
|
||||
{
|
||||
// must have a primary client and it must have a canonical name
|
||||
assert(m_primaryClient != NULL);
|
||||
@@ -184,7 +186,7 @@ Server::Server(
|
||||
new TMethodEventJob<Server>(this,
|
||||
&Server::handleFakeInputEndEvent));
|
||||
|
||||
if (m_enableDragDrop) {
|
||||
if (m_args.m_enableDragDrop) {
|
||||
m_events->adoptHandler(m_events->forFile().fileChunkSending(),
|
||||
this,
|
||||
new TMethodEventJob<Server>(this,
|
||||
@@ -451,6 +453,13 @@ Server::switchScreen(BaseClientProxy* dst,
|
||||
SInt32 x, SInt32 y, bool forScreensaver)
|
||||
{
|
||||
assert(dst != NULL);
|
||||
|
||||
// if trial is expired, exit the process
|
||||
if (m_args.m_serial.isExpired(std::time(0))) {
|
||||
LOG((CLOG_ERR "trial has expired, aborting server"));
|
||||
exit(kExitSuccess);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
SInt32 dx, dy, dw, dh;
|
||||
@@ -534,7 +543,7 @@ Server::jumpToScreen(BaseClientProxy* newScreen)
|
||||
// get the last cursor position on the target screen
|
||||
SInt32 x, y;
|
||||
newScreen->getJumpCursorPos(x, y);
|
||||
|
||||
|
||||
switchScreen(newScreen, x, y, false);
|
||||
}
|
||||
|
||||
@@ -884,14 +893,14 @@ Server::isSwitchOkay(BaseClientProxy* newScreen,
|
||||
|
||||
if (!preventSwitch && (
|
||||
(this->m_switchNeedsShift && ((mods & KeyModifierShift) != KeyModifierShift)) ||
|
||||
(this->m_switchNeedsControl && ((mods & KeyModifierControl) != KeyModifierControl)) ||
|
||||
(this->m_switchNeedsControl && ((mods & KeyModifierControl) != KeyModifierControl)) ||
|
||||
(this->m_switchNeedsAlt && ((mods & KeyModifierAlt) != KeyModifierAlt))
|
||||
)) {
|
||||
LOG((CLOG_DEBUG1 "need modifiers to switch"));
|
||||
preventSwitch = true;
|
||||
stopSwitch();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return !preventSwitch;
|
||||
}
|
||||
|
||||
@@ -1171,7 +1180,7 @@ Server::processOptions()
|
||||
}
|
||||
else if (id == kOptionClipboardSharing) {
|
||||
m_enableClipboard = (value != 0);
|
||||
|
||||
|
||||
if (m_enableClipboard == false) {
|
||||
LOG((CLOG_NOTE "clipboard sharing is disabled"));
|
||||
}
|
||||
@@ -1395,7 +1404,7 @@ Server::handleClientCloseTimeout(const Event&, void* vclient)
|
||||
void
|
||||
Server::handleSwitchToScreenEvent(const Event& event, void*)
|
||||
{
|
||||
SwitchToScreenInfo* info =
|
||||
SwitchToScreenInfo* info =
|
||||
static_cast<SwitchToScreenInfo*>(event.getData());
|
||||
|
||||
ClientList::const_iterator index = m_clients.find(info->m_screen);
|
||||
@@ -1410,7 +1419,7 @@ Server::handleSwitchToScreenEvent(const Event& event, void*)
|
||||
void
|
||||
Server::handleSwitchInDirectionEvent(const Event& event, void*)
|
||||
{
|
||||
SwitchInDirectionInfo* info =
|
||||
SwitchInDirectionInfo* info =
|
||||
static_cast<SwitchInDirectionInfo*>(event.getData());
|
||||
|
||||
// jump to screen in chosen direction from center of this screen
|
||||
@@ -1700,8 +1709,8 @@ Server::onMouseUp(ButtonID id)
|
||||
m_ignoreFileTransfer = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_enableDragDrop) {
|
||||
|
||||
if (m_args.m_enableDragDrop) {
|
||||
if (!m_screen->isOnScreen()) {
|
||||
String& file = m_screen->getDraggingFilename();
|
||||
if (!file.empty()) {
|
||||
@@ -1786,7 +1795,7 @@ Server::onMouseMovePrimary(SInt32 x, SInt32 y)
|
||||
|
||||
// should we switch or not?
|
||||
if (isSwitchOkay(newScreen, dir, x, y, xc, yc)) {
|
||||
if (m_enableDragDrop
|
||||
if (m_args.m_enableDragDrop
|
||||
&& m_screen->isDraggingStarted()
|
||||
&& m_active != newScreen
|
||||
&& m_waitDragInfoThread) {
|
||||
@@ -1805,7 +1814,7 @@ Server::onMouseMovePrimary(SInt32 x, SInt32 y)
|
||||
m_waitDragInfoThread = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1821,7 +1830,7 @@ Server::sendDragInfoThread(void* arg)
|
||||
di.setFilename(dragFileList);
|
||||
m_dragFileList.push_back(di);
|
||||
}
|
||||
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// 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
|
||||
@@ -1844,7 +1853,7 @@ Server::sendDragInfo(BaseClientProxy* newScreen)
|
||||
{
|
||||
String infoString;
|
||||
UInt32 fileCount = DragInformation::setupDragInfo(m_dragFileList, infoString);
|
||||
|
||||
|
||||
if (fileCount > 0) {
|
||||
char* info = NULL;
|
||||
size_t size = infoString.size();
|
||||
@@ -2054,7 +2063,7 @@ Server::onFileChunkSending(const void* data)
|
||||
assert(m_active != NULL);
|
||||
|
||||
// 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
|
||||
@@ -2363,7 +2372,7 @@ Server::sendFileToClient(const char* filename)
|
||||
if (m_sendFileThread != NULL) {
|
||||
StreamChunker::interruptFile();
|
||||
}
|
||||
|
||||
|
||||
m_sendFileThread = new Thread(
|
||||
new TMethodJob<Server>(
|
||||
this, &Server::sendFileThread,
|
||||
@@ -2388,7 +2397,7 @@ Server::sendFileThread(void* data)
|
||||
void
|
||||
Server::dragInfoReceived(UInt32 fileNum, String content)
|
||||
{
|
||||
if (!m_enableDragDrop) {
|
||||
if (!m_args.m_enableDragDrop) {
|
||||
LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info."));
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user