mirror of
https://github.com/debauchee/barrier.git
synced 2026-11-01 21:15:03 +08:00
Fixed win32 config saving, keyboard mapping, and AltGr bugs.
Made extensive changes to the launcher to provide more control over setting up auto-start and it now saves configuration to the user's documents directory if auto-starting at login and saves to the system directory if auto-starting at boot. Replaced MapVirtualKey() with table lookup to work around that function's lack of support for extended keyboard scan codes. Added first cut at support for AltGr.
This commit is contained in:
262
cmd/launcher/CAutoStart.cpp
Executable file
262
cmd/launcher/CAutoStart.cpp
Executable file
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* 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 COPYING 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.
|
||||
*/
|
||||
|
||||
#include "CPlatform.h"
|
||||
#include "CLog.h"
|
||||
#include "CAutoStart.h"
|
||||
#include "LaunchUtil.h"
|
||||
#include "resource.h"
|
||||
|
||||
#define CLIENT_DAEMON_NAME "Synergy Client"
|
||||
#define SERVER_DAEMON_NAME "Synergy Server"
|
||||
#define CLIENT_DAEMON_INFO "Shares this system's mouse and keyboard with others."
|
||||
#define SERVER_DAEMON_INFO "Shares this system's mouse and keyboard with others."
|
||||
|
||||
//
|
||||
// CAutoStart
|
||||
//
|
||||
|
||||
CAutoStart* CAutoStart::s_singleton = NULL;
|
||||
|
||||
CAutoStart::CAutoStart(HWND parent, CConfig* config, const CString& cmdLine) :
|
||||
m_parent(parent),
|
||||
m_config(config),
|
||||
m_isServer(config != NULL),
|
||||
m_cmdLine(cmdLine),
|
||||
m_name((config != NULL) ? SERVER_DAEMON_NAME : CLIENT_DAEMON_NAME),
|
||||
m_userConfigSaved(false)
|
||||
|
||||
{
|
||||
assert(s_singleton == NULL);
|
||||
s_singleton = this;
|
||||
}
|
||||
|
||||
CAutoStart::~CAutoStart()
|
||||
{
|
||||
s_singleton = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
CAutoStart::doModal()
|
||||
{
|
||||
// install our log outputter
|
||||
CLog::Outputter oldOutputter = CLog::getOutputter();
|
||||
CLog::setOutputter(&CAutoStart::onLog);
|
||||
|
||||
// reset saved flag
|
||||
m_userConfigSaved = false;
|
||||
|
||||
// do dialog
|
||||
DialogBoxParam(s_instance, MAKEINTRESOURCE(IDD_AUTOSTART),
|
||||
m_parent, dlgProc, (LPARAM)this);
|
||||
|
||||
// restore log outputter
|
||||
CLog::setOutputter(oldOutputter);
|
||||
}
|
||||
|
||||
bool
|
||||
CAutoStart::wasUserConfigSaved() const
|
||||
{
|
||||
return m_userConfigSaved;
|
||||
}
|
||||
|
||||
void
|
||||
CAutoStart::update()
|
||||
{
|
||||
// need a platform object
|
||||
CPlatform platform;
|
||||
|
||||
// get installation state
|
||||
const bool installedSystem = platform.isDaemonInstalled(
|
||||
m_name.c_str(), true);
|
||||
const bool installedUser = platform.isDaemonInstalled(
|
||||
m_name.c_str(), false);
|
||||
|
||||
// get user's permissions
|
||||
const bool canInstallSystem = platform.canInstallDaemon(
|
||||
m_name.c_str(), true);
|
||||
const bool canInstallUser = platform.canInstallDaemon(
|
||||
m_name.c_str(), false);
|
||||
|
||||
// update messages
|
||||
CString msg, label;
|
||||
if (canInstallSystem) {
|
||||
msg = getString(IDS_AUTOSTART_PERMISSION_SYSTEM);
|
||||
}
|
||||
else if (canInstallUser) {
|
||||
msg = getString(IDS_AUTOSTART_PERMISSION_USER);
|
||||
}
|
||||
else {
|
||||
msg = getString(IDS_AUTOSTART_PERMISSION_NONE);
|
||||
}
|
||||
setWindowText(getItem(m_hwnd, IDC_AUTOSTART_PERMISSION_MSG), msg);
|
||||
if (installedSystem) {
|
||||
msg = getString(IDS_AUTOSTART_INSTALLED_SYSTEM);
|
||||
label = getString(IDS_UNINSTALL_LABEL);
|
||||
}
|
||||
else if (installedUser) {
|
||||
msg = getString(IDS_AUTOSTART_INSTALLED_USER);
|
||||
label = getString(IDS_UNINSTALL_LABEL);
|
||||
}
|
||||
else {
|
||||
msg = getString(IDS_AUTOSTART_INSTALLED_NONE);
|
||||
label = getString(IDS_INSTALL_LABEL);
|
||||
}
|
||||
setWindowText(getItem(m_hwnd, IDC_AUTOSTART_INSTALLED_MSG), msg);
|
||||
|
||||
// update buttons
|
||||
setWindowText(getItem(m_hwnd, IDC_AUTOSTART_INSTALL_SYSTEM), label);
|
||||
setWindowText(getItem(m_hwnd, IDC_AUTOSTART_INSTALL_USER), label);
|
||||
if (installedSystem) {
|
||||
enableItem(m_hwnd, IDC_AUTOSTART_INSTALL_SYSTEM, canInstallSystem);
|
||||
enableItem(m_hwnd, IDC_AUTOSTART_INSTALL_USER, false);
|
||||
m_install = false;
|
||||
}
|
||||
else if (installedUser) {
|
||||
enableItem(m_hwnd, IDC_AUTOSTART_INSTALL_SYSTEM, false);
|
||||
enableItem(m_hwnd, IDC_AUTOSTART_INSTALL_USER, canInstallUser);
|
||||
m_install = false;
|
||||
}
|
||||
else {
|
||||
enableItem(m_hwnd, IDC_AUTOSTART_INSTALL_SYSTEM, canInstallSystem);
|
||||
enableItem(m_hwnd, IDC_AUTOSTART_INSTALL_USER, canInstallUser);
|
||||
m_install = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CAutoStart::onInstall(bool allUsers)
|
||||
{
|
||||
if (!m_install) {
|
||||
return onUninstall(allUsers);
|
||||
}
|
||||
|
||||
// try saving configuration. if we can't then don't try
|
||||
// installing the daemon.
|
||||
if (m_config != NULL) {
|
||||
if (!saveConfig(*m_config, allUsers)) {
|
||||
showError(m_hwnd, CStringUtil::format(
|
||||
getString(IDS_SAVE_FAILED).c_str(),
|
||||
getErrorString(GetLastError()).c_str()));
|
||||
return false;
|
||||
}
|
||||
|
||||
// note if we've saved the user's configuration
|
||||
if (!allUsers) {
|
||||
m_userConfigSaved = true;
|
||||
}
|
||||
}
|
||||
|
||||
// get the app path
|
||||
CString appPath = getAppPath(m_isServer ? SERVER_APP : CLIENT_APP);
|
||||
|
||||
// clear error message
|
||||
m_errorMessage = "";
|
||||
|
||||
// install
|
||||
CPlatform platform;
|
||||
if (!platform.installDaemon(m_name.c_str(),
|
||||
m_isServer ? SERVER_DAEMON_INFO : CLIENT_DAEMON_INFO,
|
||||
appPath.c_str(), m_cmdLine.c_str(), allUsers)) {
|
||||
if (m_errorMessage.empty()) {
|
||||
m_errorMessage = getString(IDS_INSTALL_GENERIC_ERROR);
|
||||
}
|
||||
showError(m_hwnd, m_errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
askOkay(m_hwnd, getString(IDS_INSTALL_TITLE),
|
||||
getString(allUsers ?
|
||||
IDS_INSTALLED_SYSTEM :
|
||||
IDS_INSTALLED_USER));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CAutoStart::onUninstall(bool allUsers)
|
||||
{
|
||||
// clear error message
|
||||
m_errorMessage = "";
|
||||
|
||||
// uninstall
|
||||
CPlatform platform;
|
||||
if (platform.uninstallDaemon(m_name.c_str(), allUsers) !=
|
||||
IPlatform::kSuccess) {
|
||||
if (m_errorMessage.empty()) {
|
||||
m_errorMessage = getString(IDS_UNINSTALL_GENERIC_ERROR);
|
||||
}
|
||||
showError(m_hwnd, m_errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
askOkay(m_hwnd, getString(IDS_UNINSTALL_TITLE),
|
||||
getString(allUsers ?
|
||||
IDS_UNINSTALLED_SYSTEM :
|
||||
IDS_UNINSTALLED_USER));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CAutoStart::onLog(int priority, const char* message)
|
||||
{
|
||||
if (priority <= CLog::kERROR) {
|
||||
s_singleton->m_errorMessage = message;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CAutoStart::doDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM)
|
||||
{
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
// save our hwnd
|
||||
m_hwnd = hwnd;
|
||||
|
||||
// update the controls
|
||||
update();
|
||||
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDC_AUTOSTART_INSTALL_SYSTEM:
|
||||
onInstall(true);
|
||||
update();
|
||||
return TRUE;
|
||||
|
||||
case IDC_AUTOSTART_INSTALL_USER:
|
||||
onInstall(false);
|
||||
update();
|
||||
return TRUE;
|
||||
|
||||
case IDCANCEL:
|
||||
EndDialog(hwnd, 0);
|
||||
m_hwnd = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK
|
||||
CAutoStart::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return s_singleton->doDlgProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
81
cmd/launcher/CAutoStart.h
Executable file
81
cmd/launcher/CAutoStart.h
Executable file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* 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 COPYING 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.
|
||||
*/
|
||||
|
||||
#ifndef CAUTOSTART_H
|
||||
#define CAUTOSTART_H
|
||||
|
||||
#include "CString.h"
|
||||
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
class CConfig;
|
||||
|
||||
//! Auto start dialog for Microsoft Windows launcher
|
||||
class CAutoStart {
|
||||
public:
|
||||
// if config == NULL then it's assumed we're installing/uninstalling
|
||||
// the client, otherwise the server.
|
||||
CAutoStart(HWND parent, CConfig* config, const CString& cmdLine);
|
||||
~CAutoStart();
|
||||
|
||||
//! @name manipulators
|
||||
//@{
|
||||
|
||||
//! Run dialog
|
||||
/*!
|
||||
Display and handle the dialog until closed by the user.
|
||||
*/
|
||||
void doModal();
|
||||
|
||||
//@}
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
||||
//! Test if user configuration was saved
|
||||
/*!
|
||||
Returns true if the user's configuration (as opposed to the system-wide
|
||||
configuration) was saved successfully while in doModal().
|
||||
*/
|
||||
bool wasUserConfigSaved() const;
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
void update();
|
||||
bool onInstall(bool allUsers);
|
||||
bool onUninstall(bool allUsers);
|
||||
|
||||
// log handling
|
||||
static bool onLog(int priority, const char* message);
|
||||
|
||||
// message handling
|
||||
BOOL doDlgProc(HWND, UINT, WPARAM, LPARAM);
|
||||
static BOOL CALLBACK dlgProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
private:
|
||||
static CAutoStart* s_singleton;
|
||||
|
||||
HWND m_parent;
|
||||
CConfig* m_config;
|
||||
bool m_isServer;
|
||||
CString m_cmdLine;
|
||||
CString m_name;
|
||||
HWND m_hwnd;
|
||||
bool m_install;
|
||||
CString m_errorMessage;
|
||||
bool m_userConfigSaved;
|
||||
};
|
||||
|
||||
#endif
|
||||
211
cmd/launcher/LaunchUtil.cpp
Executable file
211
cmd/launcher/LaunchUtil.cpp
Executable file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* 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 COPYING 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.
|
||||
*/
|
||||
|
||||
#include "CConfig.h"
|
||||
#include "CPlatform.h"
|
||||
#include "LaunchUtil.h"
|
||||
#include "resource.h"
|
||||
#include "stdfstream.h"
|
||||
|
||||
#define CONFIG_NAME "synergy.sgc"
|
||||
|
||||
CString
|
||||
getString(DWORD id)
|
||||
{
|
||||
char buffer[1024];
|
||||
buffer[0] = '\0';
|
||||
LoadString(s_instance, id, buffer, sizeof(buffer) / sizeof(buffer[0]));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
CString
|
||||
getErrorString(DWORD error)
|
||||
{
|
||||
char* buffer;
|
||||
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
0,
|
||||
error,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR)&buffer,
|
||||
0,
|
||||
NULL) == 0) {
|
||||
return getString(IDS_ERROR);
|
||||
}
|
||||
else {
|
||||
CString result(buffer);
|
||||
LocalFree(buffer);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
showError(HWND hwnd, const CString& msg)
|
||||
{
|
||||
CString title = getString(IDS_ERROR);
|
||||
MessageBox(hwnd, msg.c_str(), title.c_str(), MB_OK | MB_APPLMODAL);
|
||||
}
|
||||
|
||||
void
|
||||
askOkay(HWND hwnd, const CString& title, const CString& msg)
|
||||
{
|
||||
MessageBox(hwnd, msg.c_str(), title.c_str(), MB_OK | MB_APPLMODAL);
|
||||
}
|
||||
|
||||
bool
|
||||
askVerify(HWND hwnd, const CString& msg)
|
||||
{
|
||||
CString title = getString(IDS_VERIFY);
|
||||
int result = MessageBox(hwnd, msg.c_str(),
|
||||
title.c_str(), MB_OKCANCEL | MB_APPLMODAL);
|
||||
return (result == IDOK);
|
||||
}
|
||||
|
||||
void
|
||||
setWindowText(HWND hwnd, const CString& msg)
|
||||
{
|
||||
SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)msg.c_str());
|
||||
}
|
||||
|
||||
CString
|
||||
getWindowText(HWND hwnd)
|
||||
{
|
||||
LRESULT size = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0);
|
||||
char* buffer = new char[size + 1];
|
||||
SendMessage(hwnd, WM_GETTEXT, size + 1, (LPARAM)buffer);
|
||||
buffer[size] = '\0';
|
||||
CString result(buffer);
|
||||
delete[] buffer;
|
||||
return result;
|
||||
}
|
||||
|
||||
HWND
|
||||
getItem(HWND hwnd, int id)
|
||||
{
|
||||
return GetDlgItem(hwnd, id);
|
||||
}
|
||||
|
||||
void
|
||||
enableItem(HWND hwnd, int id, bool enabled)
|
||||
{
|
||||
EnableWindow(GetDlgItem(hwnd, id), enabled);
|
||||
}
|
||||
|
||||
CString
|
||||
getAppPath(const CString& appName)
|
||||
{
|
||||
// prepare path to app
|
||||
CPlatform platform;
|
||||
char myPathname[MAX_PATH];
|
||||
GetModuleFileName(s_instance, myPathname, MAX_PATH);
|
||||
const char* myBasename = platform.getBasename(myPathname);
|
||||
CString appPath = CString(myPathname, myBasename - myPathname);
|
||||
appPath += appName;
|
||||
return appPath;
|
||||
}
|
||||
|
||||
static
|
||||
bool
|
||||
loadConfig(const CString& pathname, CConfig& config)
|
||||
{
|
||||
try {
|
||||
std::ifstream stream(pathname.c_str());
|
||||
if (stream) {
|
||||
stream >> config;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
// ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
loadConfig(CConfig& config)
|
||||
{
|
||||
CPlatform platform;
|
||||
|
||||
// load configuration
|
||||
bool configLoaded = false;
|
||||
CString path = platform.getUserDirectory();
|
||||
if (!path.empty()) {
|
||||
CPlatform platform;
|
||||
|
||||
// try loading the user's configuration
|
||||
path = platform.addPathComponent(path, CONFIG_NAME);
|
||||
if (loadConfig(path, config)) {
|
||||
configLoaded = true;
|
||||
}
|
||||
else {
|
||||
// try the system-wide config file
|
||||
path = platform.getSystemDirectory();
|
||||
if (!path.empty()) {
|
||||
path = platform.addPathComponent(path, CONFIG_NAME);
|
||||
if (loadConfig(path, config)) {
|
||||
configLoaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return configLoaded;
|
||||
}
|
||||
|
||||
static
|
||||
bool
|
||||
saveConfig(const CString& pathname, const CConfig& config)
|
||||
{
|
||||
try {
|
||||
std::ofstream stream(pathname.c_str());
|
||||
if (stream) {
|
||||
stream << config;
|
||||
return !!stream;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
// ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
saveConfig(const CConfig& config, bool sysOnly)
|
||||
{
|
||||
CPlatform platform;
|
||||
|
||||
// try saving the user's configuration
|
||||
if (!sysOnly) {
|
||||
CString path = platform.getUserDirectory();
|
||||
if (!path.empty()) {
|
||||
path = platform.addPathComponent(path, CONFIG_NAME);
|
||||
if (saveConfig(path, config)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// try the system-wide config file
|
||||
else {
|
||||
CString path = platform.getSystemDirectory();
|
||||
if (!path.empty()) {
|
||||
path = platform.addPathComponent(path, CONFIG_NAME);
|
||||
if (saveConfig(path, config)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
50
cmd/launcher/LaunchUtil.h
Executable file
50
cmd/launcher/LaunchUtil.h
Executable file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* 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 COPYING 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.
|
||||
*/
|
||||
|
||||
#ifndef LAUNCHUTIL_H
|
||||
#define LAUNCHUTIL_H
|
||||
|
||||
#include "CString.h"
|
||||
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#define CLIENT_APP "synergyc.exe"
|
||||
#define SERVER_APP "synergys.exe"
|
||||
|
||||
class CConfig;
|
||||
|
||||
// client must define this and set it before calling any function here
|
||||
extern HINSTANCE s_instance;
|
||||
|
||||
CString getString(DWORD id);
|
||||
CString getErrorString(DWORD error);
|
||||
|
||||
void showError(HWND hwnd, const CString& msg);
|
||||
void askOkay(HWND hwnd, const CString& title,
|
||||
const CString& msg);
|
||||
bool askVerify(HWND hwnd, const CString& msg);
|
||||
|
||||
void setWindowText(HWND hwnd, const CString& msg);
|
||||
CString getWindowText(HWND hwnd);
|
||||
|
||||
HWND getItem(HWND hwnd, int id);
|
||||
void enableItem(HWND hwnd, int id, bool enabled);
|
||||
|
||||
CString getAppPath(const CString& appName);
|
||||
|
||||
bool loadConfig(CConfig& config);
|
||||
bool saveConfig(const CConfig& config, bool sysOnly);
|
||||
|
||||
#endif
|
||||
@@ -17,12 +17,12 @@
|
||||
#include "CPlatform.h"
|
||||
#include "CNetwork.h"
|
||||
#include "Version.h"
|
||||
#include "stdfstream.h"
|
||||
#include "stdvector.h"
|
||||
#include "resource.h"
|
||||
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
// these must come after the above because it includes windows.h
|
||||
#include "LaunchUtil.h"
|
||||
#include "CAutoStart.h"
|
||||
|
||||
#define CONFIG_NAME "synergy.sgc"
|
||||
#define CLIENT_APP "synergyc.exe"
|
||||
@@ -45,9 +45,10 @@ public:
|
||||
HANDLE m_stop;
|
||||
};
|
||||
|
||||
HINSTANCE s_instance = NULL;
|
||||
|
||||
static const TCHAR* s_mainClass = TEXT("GoSynergy");
|
||||
static const TCHAR* s_layoutClass = TEXT("SynergyLayout");
|
||||
static HINSTANCE s_instance = NULL;
|
||||
|
||||
static HWND s_mainWindow;
|
||||
static CConfig s_config;
|
||||
@@ -92,84 +93,6 @@ isNameInList(const CStringList& names, const CString& name)
|
||||
return false;
|
||||
}
|
||||
|
||||
static
|
||||
CString
|
||||
getString(DWORD id)
|
||||
{
|
||||
char buffer[1024];
|
||||
buffer[0] = '\0';
|
||||
LoadString(s_instance, id, buffer, sizeof(buffer) / sizeof(buffer[0]));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static
|
||||
CString
|
||||
getErrorString(DWORD error)
|
||||
{
|
||||
char* buffer;
|
||||
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
0,
|
||||
error,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR)&buffer,
|
||||
0,
|
||||
NULL) == 0) {
|
||||
return getString(IDS_ERROR);
|
||||
}
|
||||
else {
|
||||
CString result(buffer);
|
||||
LocalFree(buffer);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
showError(HWND hwnd, const CString& msg)
|
||||
{
|
||||
CString title = getString(IDS_ERROR);
|
||||
MessageBox(hwnd, msg.c_str(), title.c_str(), MB_OK | MB_APPLMODAL);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
askOkay(HWND hwnd, const CString& title, const CString& msg)
|
||||
{
|
||||
MessageBox(hwnd, msg.c_str(), title.c_str(), MB_OK | MB_APPLMODAL);
|
||||
}
|
||||
|
||||
static
|
||||
bool
|
||||
askVerify(HWND hwnd, const CString& msg)
|
||||
{
|
||||
CString title = getString(IDS_VERIFY);
|
||||
int result = MessageBox(hwnd, msg.c_str(),
|
||||
title.c_str(), MB_OKCANCEL | MB_APPLMODAL);
|
||||
return (result == IDOK);
|
||||
}
|
||||
|
||||
static
|
||||
CString
|
||||
getWindowText(HWND hwnd)
|
||||
{
|
||||
LRESULT size = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0);
|
||||
char* buffer = new char[size + 1];
|
||||
SendMessage(hwnd, WM_GETTEXT, size + 1, (LPARAM)buffer);
|
||||
buffer[size] = '\0';
|
||||
CString result(buffer);
|
||||
delete[] buffer;
|
||||
return result;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
enableItem(HWND hwnd, int id, bool enabled)
|
||||
{
|
||||
EnableWindow(GetDlgItem(hwnd, id), enabled);
|
||||
}
|
||||
|
||||
static
|
||||
bool
|
||||
isClientChecked(HWND hwnd)
|
||||
@@ -178,6 +101,13 @@ isClientChecked(HWND hwnd)
|
||||
return (SendMessage(child, BM_GETCHECK, 0, 0) == BST_CHECKED);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
enableSaveControls(HWND hwnd)
|
||||
{
|
||||
enableItem(hwnd, IDC_MAIN_SAVE, s_config != s_oldConfig);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
enableScreensControls(HWND hwnd)
|
||||
@@ -217,6 +147,7 @@ enableMainWindowControls(HWND hwnd)
|
||||
enableItem(hwnd, IDC_MAIN_CLIENT_SERVER_NAME_LABEL, client);
|
||||
enableItem(hwnd, IDC_MAIN_CLIENT_SERVER_NAME_EDIT, client);
|
||||
enableScreensControls(hwnd);
|
||||
enableSaveControls(hwnd);
|
||||
}
|
||||
|
||||
static
|
||||
@@ -310,6 +241,7 @@ addScreen(HWND hwnd)
|
||||
// update neighbors
|
||||
updateNeighbors(hwnd);
|
||||
enableScreensControls(hwnd);
|
||||
enableSaveControls(hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,6 +302,7 @@ editScreen(HWND hwnd)
|
||||
|
||||
// update neighbors
|
||||
updateNeighbors(hwnd);
|
||||
enableSaveControls(hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,6 +333,7 @@ removeScreen(HWND hwnd)
|
||||
// update neighbors
|
||||
updateNeighbors(hwnd);
|
||||
enableScreensControls(hwnd);
|
||||
enableSaveControls(hwnd);
|
||||
}
|
||||
|
||||
static
|
||||
@@ -431,6 +365,8 @@ changeNeighbor(HWND hwnd, HWND combo, EDirection direction)
|
||||
s_config.connect(screen, direction, CString(neighbor));
|
||||
delete[] neighbor;
|
||||
}
|
||||
|
||||
enableSaveControls(hwnd);
|
||||
}
|
||||
|
||||
static
|
||||
@@ -459,16 +395,16 @@ execApp(const char* app, const CString& cmdLine, PROCESS_INFORMATION* procInfo)
|
||||
startup.hStdError = NULL;
|
||||
|
||||
// prepare path to app
|
||||
CPlatform platform;
|
||||
char myPathname[MAX_PATH];
|
||||
GetModuleFileName(s_instance, myPathname, MAX_PATH);
|
||||
const char* myBasename = platform.getBasename(myPathname);
|
||||
CString appPath = CString(myPathname, myBasename - myPathname);
|
||||
appPath += app;
|
||||
CString appPath = getAppPath(app);
|
||||
|
||||
// put path to app in command line
|
||||
CString commandLine = "\"";
|
||||
commandLine += appPath;
|
||||
commandLine += "\" ";
|
||||
commandLine += cmdLine;
|
||||
|
||||
// start child
|
||||
if (CreateProcess(appPath.c_str(),
|
||||
(char*)cmdLine.c_str(),
|
||||
if (CreateProcess(NULL, (char*)commandLine.c_str(),
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE,
|
||||
@@ -487,30 +423,11 @@ execApp(const char* app, const CString& cmdLine, PROCESS_INFORMATION* procInfo)
|
||||
}
|
||||
|
||||
static
|
||||
bool
|
||||
uninstallApp(const char* app)
|
||||
{
|
||||
PROCESS_INFORMATION procInfo;
|
||||
|
||||
// uninstall
|
||||
DWORD exitCode = kExitFailed;
|
||||
if (execApp(app, "-z --uninstall", &procInfo)) {
|
||||
WaitForSingleObject(procInfo.hProcess, INFINITE);
|
||||
GetExitCodeProcess(procInfo.hProcess, &exitCode);
|
||||
CloseHandle(procInfo.hProcess);
|
||||
CloseHandle(procInfo.hThread);
|
||||
}
|
||||
|
||||
return (exitCode == kExitSuccess);
|
||||
}
|
||||
|
||||
static
|
||||
HANDLE
|
||||
launchApp(HWND hwnd, bool testing, DWORD* threadID)
|
||||
CString
|
||||
getCommandLine(HWND hwnd, bool testing)
|
||||
{
|
||||
// decide if client or server
|
||||
const bool isClient = isClientChecked(hwnd);
|
||||
const char* app = isClient ? CLIENT_APP : SERVER_APP;
|
||||
|
||||
// get and verify screen name
|
||||
HWND child = GetDlgItem(hwnd, IDC_MAIN_ADVANCED_NAME_EDIT);
|
||||
@@ -520,14 +437,14 @@ launchApp(HWND hwnd, bool testing, DWORD* threadID)
|
||||
getString(IDS_INVALID_SCREEN_NAME).c_str(),
|
||||
name.c_str()));
|
||||
SetFocus(child);
|
||||
return NULL;
|
||||
return CString();
|
||||
}
|
||||
if (!isClient && !s_config.isScreen(name)) {
|
||||
showError(hwnd, CStringUtil::format(
|
||||
getString(IDS_UNKNOWN_SCREEN_NAME).c_str(),
|
||||
name.c_str()));
|
||||
SetFocus(child);
|
||||
return NULL;
|
||||
return CString();
|
||||
}
|
||||
|
||||
// get and verify port
|
||||
@@ -541,7 +458,7 @@ launchApp(HWND hwnd, bool testing, DWORD* threadID)
|
||||
portString.c_str(),
|
||||
defaultPortString.c_str()));
|
||||
SetFocus(child);
|
||||
return NULL;
|
||||
return CString();
|
||||
}
|
||||
|
||||
// prepare command line
|
||||
@@ -557,10 +474,10 @@ launchApp(HWND hwnd, bool testing, DWORD* threadID)
|
||||
CString server = getWindowText(child);
|
||||
if (!s_config.isValidScreenName(server)) {
|
||||
showError(hwnd, CStringUtil::format(
|
||||
getString(IDS_INVALID_SCREEN_NAME).c_str(),
|
||||
getString(IDS_INVALID_SERVER_NAME).c_str(),
|
||||
server.c_str()));
|
||||
SetFocus(child);
|
||||
return NULL;
|
||||
return CString();
|
||||
}
|
||||
|
||||
if (testing) {
|
||||
@@ -576,27 +493,21 @@ launchApp(HWND hwnd, bool testing, DWORD* threadID)
|
||||
cmdLine += portString;
|
||||
}
|
||||
|
||||
// uninstall client and server then reinstall one of them
|
||||
if (!testing) {
|
||||
// uninstall client and server
|
||||
uninstallApp(CLIENT_APP);
|
||||
uninstallApp(SERVER_APP);
|
||||
return cmdLine;
|
||||
}
|
||||
|
||||
// install client or server
|
||||
PROCESS_INFORMATION procInfo;
|
||||
DWORD exitCode = kExitFailed;
|
||||
if (execApp(app, CString("-z --install") + cmdLine, &procInfo)) {
|
||||
WaitForSingleObject(procInfo.hProcess, INFINITE);
|
||||
GetExitCodeProcess(procInfo.hProcess, &exitCode);
|
||||
CloseHandle(procInfo.hProcess);
|
||||
CloseHandle(procInfo.hThread);
|
||||
}
|
||||
static
|
||||
HANDLE
|
||||
launchApp(HWND hwnd, bool testing, DWORD* threadID)
|
||||
{
|
||||
// decide if client or server
|
||||
const bool isClient = isClientChecked(hwnd);
|
||||
const char* app = isClient ? CLIENT_APP : SERVER_APP;
|
||||
|
||||
// see if install succeeded
|
||||
if (exitCode != kExitSuccess) {
|
||||
showError(hwnd, getString(IDS_INSTALL_FAILED).c_str());
|
||||
return NULL;
|
||||
}
|
||||
// prepare command line
|
||||
CString cmdLine = getCommandLine(hwnd, testing);
|
||||
if (cmdLine.empty()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// start child
|
||||
@@ -716,67 +627,6 @@ waitForChild(HWND hwnd, HANDLE thread, DWORD threadID)
|
||||
CloseHandle(info.m_stop);
|
||||
}
|
||||
|
||||
static
|
||||
bool
|
||||
loadConfig(const CString& pathname, CConfig& config)
|
||||
{
|
||||
try {
|
||||
std::ifstream stream(pathname.c_str());
|
||||
if (stream) {
|
||||
stream >> config;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
// ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static
|
||||
bool
|
||||
saveConfig(const CString& pathname, const CConfig& config)
|
||||
{
|
||||
try {
|
||||
std::ofstream stream(pathname.c_str());
|
||||
if (stream) {
|
||||
stream << config;
|
||||
return !!stream;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
// ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static
|
||||
bool
|
||||
saveConfig(const CConfig& config)
|
||||
{
|
||||
CPlatform platform;
|
||||
|
||||
CString path = platform.getUserDirectory();
|
||||
if (!path.empty()) {
|
||||
// try loading the user's configuration
|
||||
path = platform.addPathComponent(path, CONFIG_NAME);
|
||||
if (saveConfig(path, config)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// try the system-wide config file
|
||||
path = platform.getSystemDirectory();
|
||||
if (!path.empty()) {
|
||||
path = platform.addPathComponent(path, CONFIG_NAME);
|
||||
if (saveConfig(path, config)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
initMainWindow(HWND hwnd)
|
||||
@@ -784,26 +634,9 @@ initMainWindow(HWND hwnd)
|
||||
CPlatform platform;
|
||||
|
||||
// load configuration
|
||||
bool configLoaded = false;
|
||||
CString path = platform.getUserDirectory();
|
||||
if (!path.empty()) {
|
||||
// try loading the user's configuration
|
||||
path = platform.addPathComponent(path, CONFIG_NAME);
|
||||
if (loadConfig(path, s_config)) {
|
||||
configLoaded = true;
|
||||
}
|
||||
else {
|
||||
// try the system-wide config file
|
||||
path = platform.getSystemDirectory();
|
||||
if (!path.empty()) {
|
||||
path = platform.addPathComponent(path, CONFIG_NAME);
|
||||
if (loadConfig(path, s_config)) {
|
||||
configLoaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool configLoaded = loadConfig(s_config);
|
||||
s_oldConfig = s_config;
|
||||
enableSaveControls(hwnd);
|
||||
|
||||
// choose client/server radio buttons
|
||||
HWND child;
|
||||
@@ -978,82 +811,81 @@ mainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
|
||||
case IDOK: {
|
||||
// save data
|
||||
if (s_config != s_oldConfig) {
|
||||
if (!saveConfig(s_config)) {
|
||||
showError(hwnd, CStringUtil::format(
|
||||
getString(IDS_SAVE_FAILED).c_str(),
|
||||
getErrorString(GetLastError()).c_str()));
|
||||
return 0;
|
||||
}
|
||||
s_oldConfig = s_config;
|
||||
}
|
||||
|
||||
// launch child app
|
||||
HANDLE thread = launchApp(hwnd, false, NULL);
|
||||
if (thread == NULL) {
|
||||
return 0;
|
||||
}
|
||||
CloseHandle(thread);
|
||||
|
||||
// notify of success
|
||||
askOkay(hwnd, getString(IDS_STARTED_TITLE),
|
||||
getString(IDS_STARTED));
|
||||
|
||||
// quit
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case IDOK:
|
||||
case IDC_MAIN_TEST: {
|
||||
// note if testing
|
||||
const bool testing = (LOWORD(wParam) == IDC_MAIN_TEST);
|
||||
|
||||
// save data
|
||||
if (s_config != s_oldConfig) {
|
||||
if (!saveConfig(s_config)) {
|
||||
if (!saveConfig(s_config, false)) {
|
||||
showError(hwnd, CStringUtil::format(
|
||||
getString(IDS_SAVE_FAILED).c_str(),
|
||||
getErrorString(GetLastError()).c_str()));
|
||||
return 0;
|
||||
}
|
||||
s_oldConfig = s_config;
|
||||
enableSaveControls(hwnd);
|
||||
}
|
||||
|
||||
// launch child app
|
||||
DWORD threadID;
|
||||
HANDLE thread = launchApp(hwnd, true, &threadID);
|
||||
HANDLE thread = launchApp(hwnd, testing, &threadID);
|
||||
if (thread == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// wait for process to stop, allowing the user to kill it
|
||||
waitForChild(hwnd, thread, threadID);
|
||||
// handle child program
|
||||
if (testing) {
|
||||
// wait for process to stop, allowing the user to kill it
|
||||
waitForChild(hwnd, thread, threadID);
|
||||
|
||||
// clean up
|
||||
CloseHandle(thread);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case IDC_MAIN_UNINSTALL: {
|
||||
// uninstall client and server
|
||||
bool removedClient = uninstallApp(CLIENT_APP);
|
||||
bool removedServer = uninstallApp(SERVER_APP);
|
||||
if (!removedClient) {
|
||||
showError(hwnd, CStringUtil::format(
|
||||
getString(IDS_UNINSTALL_FAILED).c_str(),
|
||||
getString(IDS_CLIENT).c_str()));
|
||||
}
|
||||
else if (!removedServer) {
|
||||
showError(hwnd, CStringUtil::format(
|
||||
getString(IDS_UNINSTALL_FAILED).c_str(),
|
||||
getString(IDS_SERVER).c_str()));
|
||||
// clean up
|
||||
CloseHandle(thread);
|
||||
}
|
||||
else {
|
||||
askOkay(hwnd, getString(IDS_UNINSTALL_TITLE),
|
||||
getString(IDS_UNINSTALLED));
|
||||
// don't need thread handle
|
||||
CloseHandle(thread);
|
||||
|
||||
// notify of success
|
||||
askOkay(hwnd, getString(IDS_STARTED_TITLE),
|
||||
getString(IDS_STARTED));
|
||||
|
||||
// quit
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
case IDC_MAIN_AUTOSTART: {
|
||||
// construct command line
|
||||
CString cmdLine = getCommandLine(hwnd, false);
|
||||
if (!cmdLine.empty()) {
|
||||
// run dialog
|
||||
CAutoStart autoStart(hwnd,
|
||||
isClientChecked(hwnd) ? NULL : &s_config,
|
||||
cmdLine);
|
||||
autoStart.doModal();
|
||||
if (autoStart.wasUserConfigSaved()) {
|
||||
s_oldConfig = s_config;
|
||||
enableSaveControls(hwnd);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
case IDC_MAIN_SAVE:
|
||||
if (!saveConfig(s_config, false)) {
|
||||
showError(hwnd, CStringUtil::format(
|
||||
getString(IDS_SAVE_FAILED).c_str(),
|
||||
getErrorString(GetLastError()).c_str()));
|
||||
}
|
||||
else {
|
||||
s_oldConfig = s_config;
|
||||
enableSaveControls(hwnd);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case IDC_MAIN_CLIENT_RADIO:
|
||||
case IDC_MAIN_SERVER_RADIO:
|
||||
enableMainWindowControls(hwnd);
|
||||
|
||||
@@ -95,18 +95,34 @@ LINK32=link.exe
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CAutoStart.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\launcher.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\launcher.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LaunchUtil.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CAutoStart.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LaunchUtil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# End Group
|
||||
|
||||
@@ -52,7 +52,7 @@ END
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_MAIN DIALOG DISCARDABLE 32768, 0, 300, 241
|
||||
IDD_MAIN DIALOG DISCARDABLE 32768, 0, 300, 262
|
||||
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Synergy"
|
||||
CLASS "GoSynergy"
|
||||
@@ -62,22 +62,22 @@ BEGIN
|
||||
IDC_STATIC,7,7,286,19
|
||||
GROUPBOX "",IDC_STATIC,7,29,286,31
|
||||
GROUPBOX "",IDC_STATIC,7,67,286,103
|
||||
GROUPBOX "Advanced Options",IDC_STATIC,7,177,286,34
|
||||
CONTROL "Client",IDC_MAIN_CLIENT_RADIO,"Button",
|
||||
GROUPBOX "Advanced Options",IDC_STATIC,7,177,286,56
|
||||
CONTROL "&Client",IDC_MAIN_CLIENT_RADIO,"Button",
|
||||
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,11,29,33,10
|
||||
CONTROL "Server",IDC_MAIN_SERVER_RADIO,"Button",
|
||||
BS_AUTORADIOBUTTON,11,67,37,10
|
||||
LTEXT "Server Host Name:",IDC_MAIN_CLIENT_SERVER_NAME_LABEL,12,
|
||||
41,61,8
|
||||
LTEXT "Server &Host Name:",IDC_MAIN_CLIENT_SERVER_NAME_LABEL,
|
||||
12,41,61,8
|
||||
EDITTEXT IDC_MAIN_CLIENT_SERVER_NAME_EDIT,79,39,106,12,
|
||||
ES_AUTOHSCROLL
|
||||
LTEXT "Screens:",IDC_MAIN_SERVER_SCREENS_LABEL,12,79,29,8
|
||||
LTEXT "&Screens:",IDC_MAIN_SERVER_SCREENS_LABEL,12,79,29,8
|
||||
LISTBOX IDC_MAIN_SERVER_SCREENS_LIST,12,91,106,36,
|
||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Add",IDC_MAIN_SERVER_ADD_BUTTON,12,132,50,14
|
||||
PUSHBUTTON "Edit",IDC_MAIN_SERVER_EDIT_BUTTON,68,132,50,14
|
||||
PUSHBUTTON "Remove",IDC_MAIN_SERVER_REMOVE_BUTTON,12,150,50,14
|
||||
LTEXT "Layout:",IDC_MAIN_SERVER_LAYOUT_LABEL,138,79,24,8
|
||||
PUSHBUTTON "&Add",IDC_MAIN_SERVER_ADD_BUTTON,12,132,50,14
|
||||
PUSHBUTTON "&Edit",IDC_MAIN_SERVER_EDIT_BUTTON,68,132,50,14
|
||||
PUSHBUTTON "&Remove",IDC_MAIN_SERVER_REMOVE_BUTTON,12,150,50,14
|
||||
LTEXT "&Layout:",IDC_MAIN_SERVER_LAYOUT_LABEL,138,79,24,8
|
||||
LTEXT "Left:",IDC_MAIN_SERVER_LEFT_LABEL,144,93,15,8
|
||||
COMBOBOX IDC_MAIN_SERVER_LEFT_COMBO,175,91,118,46,
|
||||
CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
||||
@@ -90,15 +90,17 @@ BEGIN
|
||||
LTEXT "Below:",IDC_MAIN_SERVER_BOTTOM_LABEL,144,141,22,8
|
||||
COMBOBOX IDC_MAIN_SERVER_BOTTOM_COMBO,175,139,118,46,
|
||||
CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Screen Name:",IDC_STATIC,12,192,46,8
|
||||
LTEXT "Screen &Name:",IDC_STATIC,12,192,46,8
|
||||
EDITTEXT IDC_MAIN_ADVANCED_NAME_EDIT,64,190,106,12,ES_AUTOHSCROLL
|
||||
LTEXT "Port:",IDC_STATIC,194,192,16,8
|
||||
LTEXT "&Port:",IDC_STATIC,194,192,16,8
|
||||
EDITTEXT IDC_MAIN_ADVANCED_PORT_EDIT,216,190,40,12,ES_AUTOHSCROLL |
|
||||
ES_NUMBER
|
||||
DEFPUSHBUTTON "Test",IDC_MAIN_TEST,75,220,50,14
|
||||
PUSHBUTTON "Start",IDOK,131,220,50,14
|
||||
PUSHBUTTON "No Auto-Start",IDC_MAIN_UNINSTALL,187,220,50,14
|
||||
PUSHBUTTON "Quit",IDCANCEL,243,220,50,14
|
||||
LTEXT "Automatic Startup:",IDC_STATIC,12,212,59,8
|
||||
PUSHBUTTON "Con&figure...",IDC_MAIN_AUTOSTART,78,210,50,14
|
||||
PUSHBUTTON "Sa&ve",IDC_MAIN_SAVE,75,241,50,14
|
||||
DEFPUSHBUTTON "&Test",IDC_MAIN_TEST,131,241,50,14
|
||||
PUSHBUTTON "Start",IDOK,187,241,50,14
|
||||
PUSHBUTTON "Quit",IDCANCEL,243,241,50,14
|
||||
END
|
||||
|
||||
IDD_ADD DIALOG DISCARDABLE 0, 0, 172, 95
|
||||
@@ -125,6 +127,26 @@ BEGIN
|
||||
IDC_STATIC,7,7,172,15
|
||||
END
|
||||
|
||||
IDD_AUTOSTART DIALOG DISCARDABLE 0, 0, 195, 189
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Auto Start"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Close",IDCANCEL,138,168,50,14
|
||||
LTEXT "Synergy can be configured to start automatically when you log in. If you have sufficient access rights, you can instead configure synergy to start automatically when your computer starts.",
|
||||
IDC_STATIC,7,7,181,33
|
||||
LTEXT "You have sufficient access rights to install and uninstall Auto Start for all users or for just yourself.",
|
||||
IDC_AUTOSTART_PERMISSION_MSG,7,69,181,17
|
||||
LTEXT "Synergy is configured to start automatically when the system starts.",
|
||||
IDC_AUTOSTART_INSTALLED_MSG,7,93,181,17
|
||||
GROUPBOX "When &You Log In",IDC_STATIC,7,119,84,40
|
||||
PUSHBUTTON "Install",IDC_AUTOSTART_INSTALL_USER,23,133,50,14
|
||||
GROUPBOX "When &Computer Starts",IDC_STATIC,104,119,84,40
|
||||
PUSHBUTTON "Install",IDC_AUTOSTART_INSTALL_SYSTEM,119,134,50,14
|
||||
LTEXT "Synergy can be configured to start automatically when the computer starts or when you log in but not both.",
|
||||
IDC_STATIC,7,43,181,17
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -139,7 +161,7 @@ BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 293
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 234
|
||||
BOTTOMMARGIN, 255
|
||||
END
|
||||
|
||||
IDD_ADD, DIALOG
|
||||
@@ -157,6 +179,14 @@ BEGIN
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 47
|
||||
END
|
||||
|
||||
IDD_AUTOSTART, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 188
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 182
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
@@ -189,16 +219,37 @@ BEGIN
|
||||
IDS_STARTUP_FAILED "Failed to start synergy: %{1}"
|
||||
IDS_STARTED_TITLE "Started"
|
||||
IDS_STARTED "Synergy was successfully started. Use the task manager to terminate it."
|
||||
IDS_INSTALL_FAILED "Failed to install synergy auto-starter. Synergy will not be started now and it will not automatically start each time you start or reboot your computer."
|
||||
IDS_UNINSTALL_TITLE "Removed Auto-Start"
|
||||
IDS_UNINSTALLED "Removed auto-start. Synergy will not automatically start each time you start or reboot your computer."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_UNINSTALL_FAILED "Failed to remove auto-start of %{1}. You might not have permission to remove it or it might be in use.\n\nOn Windows NT, 2000, or XP you should open the Services control panel and stop the synergy %{1} service then try again."
|
||||
IDS_CLIENT "client"
|
||||
IDS_SERVER "server"
|
||||
IDS_AUTOSTART_PERMISSION_SYSTEM
|
||||
"You have sufficient access rights to install and uninstall Auto Start for all users or for just yourself."
|
||||
IDS_AUTOSTART_PERMISSION_USER
|
||||
"You have sufficient access rights to install and uninstall Auto Start for just yourself."
|
||||
IDS_AUTOSTART_PERMISSION_NONE
|
||||
"You do not have sufficient access rights to install or uninstall Auto Start."
|
||||
IDS_AUTOSTART_INSTALLED_SYSTEM
|
||||
"Synergy is configured to start automatically when the system starts."
|
||||
IDS_AUTOSTART_INSTALLED_USER
|
||||
"Synergy is configured to start automatically when you log in."
|
||||
IDS_AUTOSTART_INSTALLED_NONE
|
||||
"Synergy is not configured to start automatically."
|
||||
IDS_INSTALL_LABEL "Install"
|
||||
IDS_UNINSTALL_LABEL "Uninstall"
|
||||
IDS_INSTALL_GENERIC_ERROR "Install failed for an unknown reason."
|
||||
IDS_UNINSTALL_GENERIC_ERROR "Uninstall failed for an unknown reason."
|
||||
IDS_INSTALL_TITLE "Installed Auto-Start"
|
||||
IDS_INSTALLED_SYSTEM "Installed auto-start. Synergy will now automatically start each time you start your computer."
|
||||
IDS_INSTALLED_USER "Installed auto-start. Synergy will now automatically start each time you log in."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_UNINSTALLED_SYSTEM "Removed auto-start. Synergy will not automatically start each time you start or reboot your computer."
|
||||
IDS_UNINSTALLED_USER "Removed auto-start. Synergy will not automatically start each time you log in."
|
||||
IDS_INVALID_SERVER_NAME "Server name `%{1}' is invalid."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
|
||||
@@ -1,62 +1,85 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by launcher.rc
|
||||
//
|
||||
#define IDS_ERROR 1
|
||||
#define IDS_INVALID_SCREEN_NAME 2
|
||||
#define IDS_DUPLICATE_SCREEN_NAME 3
|
||||
#define IDS_SCREEN_NAME_IS_ALIAS 4
|
||||
#define IDS_VERIFY 5
|
||||
#define IDS_UNSAVED_DATA_REALLY_QUIT 6
|
||||
#define IDS_UNKNOWN_SCREEN_NAME 7
|
||||
#define IDS_INVALID_PORT 8
|
||||
#define IDS_SAVE_FAILED 9
|
||||
#define IDS_STARTUP_FAILED 10
|
||||
#define IDS_STARTED_TITLE 11
|
||||
#define IDS_STARTED 12
|
||||
#define IDS_INSTALL_FAILED 13
|
||||
#define IDS_UNINSTALL_TITLE 14
|
||||
#define IDS_UNINSTALLED 15
|
||||
#define IDS_UNINSTALL_FAILED 16
|
||||
#define IDS_CLIENT 17
|
||||
#define IDS_SERVER 18
|
||||
#define IDD_MAIN 101
|
||||
#define IDD_ADD 102
|
||||
#define IDD_WAIT 103
|
||||
#define IDI_SYNERGY 104
|
||||
#define IDC_MAIN_CLIENT_RADIO 1000
|
||||
#define IDC_MAIN_SERVER_RADIO 1001
|
||||
#define IDC_MAIN_CLIENT_SERVER_NAME_EDIT 1002
|
||||
#define IDC_MAIN_ADVANCED_NAME_EDIT 1006
|
||||
#define IDC_MAIN_ADVANCED_PORT_EDIT 1008
|
||||
#define IDC_MAIN_TEST 1009
|
||||
#define IDC_MAIN_CLIENT_SERVER_NAME_LABEL 1011
|
||||
#define IDC_MAIN_SERVER_SCREENS_LIST 1012
|
||||
#define IDC_MAIN_SERVER_SCREENS_LABEL 1013
|
||||
#define IDC_MAIN_SERVER_LAYOUT_LABEL 1014
|
||||
#define IDC_MAIN_SERVER_ADD_BUTTON 1018
|
||||
#define IDC_MAIN_SERVER_EDIT_BUTTON 1019
|
||||
#define IDC_ADD_SCREEN_NAME_EDIT 1020
|
||||
#define IDC_MAIN_SERVER_REMOVE_BUTTON 1020
|
||||
#define IDC_ADD_ALIASES_EDIT 1021
|
||||
#define IDC_MAIN_SERVER_LEFT_COMBO 1022
|
||||
#define IDC_MAIN_SERVER_RIGHT_COMBO 1023
|
||||
#define IDC_MAIN_SERVER_TOP_COMBO 1024
|
||||
#define IDC_MAIN_SERVER_BOTTOM_COMBO 1025
|
||||
#define IDC_MAIN_SERVER_LEFT_LABEL 1026
|
||||
#define IDC_MAIN_SERVER_RIGHT_LABEL 1027
|
||||
#define IDC_MAIN_SERVER_TOP_LABEL 1028
|
||||
#define IDC_MAIN_SERVER_BOTTOM_LABEL 1029
|
||||
#define IDC_MAIN_UNINSTALL 1030
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 105
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1031
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by launcher.rc
|
||||
//
|
||||
#define IDS_ERROR 1
|
||||
#define IDS_INVALID_SCREEN_NAME 2
|
||||
#define IDS_DUPLICATE_SCREEN_NAME 3
|
||||
#define IDS_SCREEN_NAME_IS_ALIAS 4
|
||||
#define IDS_VERIFY 5
|
||||
#define IDS_UNSAVED_DATA_REALLY_QUIT 6
|
||||
#define IDS_UNKNOWN_SCREEN_NAME 7
|
||||
#define IDS_INVALID_PORT 8
|
||||
#define IDS_SAVE_FAILED 9
|
||||
#define IDS_STARTUP_FAILED 10
|
||||
#define IDS_STARTED_TITLE 11
|
||||
#define IDS_STARTED 12
|
||||
#define IDS_INSTALL_FAILED 13
|
||||
#define IDS_UNINSTALL_TITLE 14
|
||||
#define IDS_UNINSTALLED 15
|
||||
#define IDS_UNINSTALL_FAILED 16
|
||||
#define IDS_CLIENT 17
|
||||
#define IDS_SERVER 18
|
||||
#define IDS_AUTOSTART_PERMISSION_SYSTEM 19
|
||||
#define IDS_AUTOSTART_PERMISSION_USER 20
|
||||
#define IDS_AUTOSTART_PERMISSION_NONE 21
|
||||
#define IDS_AUTOSTART_INSTALLED_SYSTEM 22
|
||||
#define IDS_AUTOSTART_INSTALLED_USER 23
|
||||
#define IDS_AUTOSTART_INSTALLED_NONE 24
|
||||
#define IDS_INSTALL_LABEL 25
|
||||
#define IDS_UNINSTALL_LABEL 26
|
||||
#define IDS_INSTALL_GENERIC_ERROR 27
|
||||
#define IDS_UNINSTALL_GENERIC_ERROR 28
|
||||
#define IDS_INSTALL_TITLE 29
|
||||
#define IDS_INSTALLED_SYSTEM 30
|
||||
#define IDS_INSTALLED_USER 31
|
||||
#define IDS_UNINSTALLED_SYSTEM 32
|
||||
#define IDS_UNINSTALLED_USER 33
|
||||
#define IDS_INVALID_SERVER_NAME 34
|
||||
#define IDD_MAIN 101
|
||||
#define IDD_ADD 102
|
||||
#define IDD_WAIT 103
|
||||
#define IDI_SYNERGY 104
|
||||
#define IDD_AUTOSTART 105
|
||||
#define IDC_MAIN_CLIENT_RADIO 1000
|
||||
#define IDC_MAIN_SERVER_RADIO 1001
|
||||
#define IDC_MAIN_CLIENT_SERVER_NAME_EDIT 1002
|
||||
#define IDC_MAIN_ADVANCED_NAME_EDIT 1006
|
||||
#define IDC_MAIN_ADVANCED_PORT_EDIT 1008
|
||||
#define IDC_MAIN_TEST 1009
|
||||
#define IDC_MAIN_SAVE 1010
|
||||
#define IDC_MAIN_CLIENT_SERVER_NAME_LABEL 1011
|
||||
#define IDC_MAIN_SERVER_SCREENS_LIST 1012
|
||||
#define IDC_MAIN_SERVER_SCREENS_LABEL 1013
|
||||
#define IDC_MAIN_SERVER_LAYOUT_LABEL 1014
|
||||
#define IDC_MAIN_SERVER_ADD_BUTTON 1018
|
||||
#define IDC_MAIN_SERVER_EDIT_BUTTON 1019
|
||||
#define IDC_ADD_SCREEN_NAME_EDIT 1020
|
||||
#define IDC_MAIN_SERVER_REMOVE_BUTTON 1020
|
||||
#define IDC_ADD_ALIASES_EDIT 1021
|
||||
#define IDC_MAIN_SERVER_LEFT_COMBO 1022
|
||||
#define IDC_MAIN_SERVER_RIGHT_COMBO 1023
|
||||
#define IDC_MAIN_SERVER_TOP_COMBO 1024
|
||||
#define IDC_MAIN_SERVER_BOTTOM_COMBO 1025
|
||||
#define IDC_MAIN_SERVER_LEFT_LABEL 1026
|
||||
#define IDC_MAIN_SERVER_RIGHT_LABEL 1027
|
||||
#define IDC_MAIN_SERVER_TOP_LABEL 1028
|
||||
#define IDC_MAIN_SERVER_BOTTOM_LABEL 1029
|
||||
#define IDC_MAIN_UNINSTALL 1030
|
||||
#define IDC_AUTOSTART_INSTALLED_MSG 1031
|
||||
#define IDC_AUTOSTART_PERMISSION_MSG 1032
|
||||
#define IDC_AUTOSTART_INSTALL_USER 1033
|
||||
#define IDC_AUTOSTART_INSTALL_SYSTEM 1034
|
||||
#define IDC_MAIN_AUTOSTART 1035
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 106
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1036
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by synergy.rc
|
||||
//
|
||||
#define IDS_FAILED 1
|
||||
#define IDD_SYNERGY 101
|
||||
#define IDI_SYNERGY 103
|
||||
#define IDC_LOG 1000
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 104
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by synergyc.rc
|
||||
//
|
||||
#define IDS_FAILED 1
|
||||
#define IDD_SYNERGY 101
|
||||
#define IDI_SYNERGY 103
|
||||
#define IDC_LOG 1000
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 104
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -54,8 +54,6 @@ static bool s_backend = false;
|
||||
static bool s_restartable = true;
|
||||
static bool s_daemon = true;
|
||||
static bool s_camp = true;
|
||||
static bool s_install = false;
|
||||
static bool s_uninstall = false;
|
||||
static const char* s_logFilter = NULL;
|
||||
static CString s_name;
|
||||
static CNetworkAddress s_serverAddress;
|
||||
@@ -246,25 +244,6 @@ static
|
||||
void
|
||||
help()
|
||||
{
|
||||
#if WINDOWS_LIKE
|
||||
|
||||
# define PLATFORM_ARGS \
|
||||
" [--install]" \
|
||||
" <server-address>\n" \
|
||||
"or\n" \
|
||||
" --uninstall\n"
|
||||
# define PLATFORM_DESC \
|
||||
" --install install server as a service.\n" \
|
||||
" --uninstall uninstall server service.\n"
|
||||
|
||||
#else
|
||||
|
||||
# define PLATFORM_ARGS \
|
||||
" <server-address>\n"
|
||||
# define PLATFORM_DESC
|
||||
|
||||
#endif
|
||||
|
||||
log((CLOG_PRINT
|
||||
"Usage: %s"
|
||||
" [--camp|--no-camp]"
|
||||
@@ -272,7 +251,7 @@ help()
|
||||
" [--debug <level>]"
|
||||
" [--name <screen-name>]"
|
||||
" [--restart|--no-restart]"
|
||||
PLATFORM_ARGS
|
||||
" <server-address>\n"
|
||||
"\n"
|
||||
"Start the synergy mouse/keyboard sharing server.\n"
|
||||
"\n"
|
||||
@@ -289,7 +268,6 @@ PLATFORM_ARGS
|
||||
" -1, --no-restart do not try to restart the client if it fails for\n"
|
||||
" some reason.\n"
|
||||
"* --restart restart the client automatically if it fails.\n"
|
||||
PLATFORM_DESC
|
||||
" -h, --help display this help and exit.\n"
|
||||
" --version display version information and exit.\n"
|
||||
"\n"
|
||||
@@ -397,30 +375,6 @@ parse(int argc, const char** argv)
|
||||
bye(kExitSuccess);
|
||||
}
|
||||
|
||||
#if WINDOWS_LIKE
|
||||
else if (isArg(i, argc, argv, NULL, "--install")) {
|
||||
s_install = true;
|
||||
if (s_uninstall) {
|
||||
log((CLOG_PRINT "%s: `--install' and `--uninstall'"
|
||||
" are mutually exclusive" BYE,
|
||||
pname, argv[i], pname));
|
||||
bye(kExitArgs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WINDOWS_LIKE
|
||||
else if (isArg(i, argc, argv, NULL, "--uninstall")) {
|
||||
s_uninstall = true;
|
||||
if (s_install) {
|
||||
log((CLOG_PRINT "%s: `--install' and `--uninstall'"
|
||||
" are mutually exclusive" BYE,
|
||||
pname, argv[i], pname));
|
||||
bye(kExitArgs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
else if (isArg(i, argc, argv, "--", NULL)) {
|
||||
// remaining arguments are not options
|
||||
++i;
|
||||
@@ -439,37 +393,26 @@ parse(int argc, const char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
// exactly one non-option argument (server-address) unless using
|
||||
// --uninstall.
|
||||
if (s_uninstall) {
|
||||
if (i != argc) {
|
||||
log((CLOG_PRINT "%s: unrecognized option `%s' to `%s'" BYE,
|
||||
pname, argv[i], pname,
|
||||
s_install ? "--install" : "--uninstall"));
|
||||
bye(kExitArgs);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (i == argc) {
|
||||
log((CLOG_PRINT "%s: a server address or name is required" BYE,
|
||||
// exactly one non-option argument (server-address)
|
||||
if (i == argc) {
|
||||
log((CLOG_PRINT "%s: a server address or name is required" BYE,
|
||||
pname, pname));
|
||||
bye(kExitArgs);
|
||||
}
|
||||
if (i + 1 != argc) {
|
||||
log((CLOG_PRINT "%s: unrecognized option `%s'" BYE,
|
||||
bye(kExitArgs);
|
||||
}
|
||||
if (i + 1 != argc) {
|
||||
log((CLOG_PRINT "%s: unrecognized option `%s'" BYE,
|
||||
pname, argv[i], pname));
|
||||
bye(kExitArgs);
|
||||
}
|
||||
bye(kExitArgs);
|
||||
}
|
||||
|
||||
// save server address
|
||||
try {
|
||||
s_serverAddress = CNetworkAddress(argv[i], kDefaultPort);
|
||||
}
|
||||
catch (XSocketAddress& e) {
|
||||
log((CLOG_PRINT "%s: %s" BYE,
|
||||
// save server address
|
||||
try {
|
||||
s_serverAddress = CNetworkAddress(argv[i], kDefaultPort);
|
||||
}
|
||||
catch (XSocketAddress& e) {
|
||||
log((CLOG_PRINT "%s: %s" BYE,
|
||||
pname, e.what(), pname));
|
||||
bye(kExitFailed);
|
||||
}
|
||||
bye(kExitFailed);
|
||||
}
|
||||
|
||||
// increase default filter level for daemon. the user must
|
||||
@@ -496,7 +439,6 @@ parse(int argc, const char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// platform dependent entry points
|
||||
//
|
||||
@@ -505,24 +447,16 @@ parse(int argc, const char** argv)
|
||||
|
||||
#include "CMSWindowsScreen.h"
|
||||
|
||||
static bool s_errors = false;
|
||||
|
||||
static
|
||||
bool
|
||||
logMessageBox(int priority, const char* msg)
|
||||
{
|
||||
if (priority <= CLog::kERROR) {
|
||||
s_errors = true;
|
||||
}
|
||||
if (s_backend) {
|
||||
return true;
|
||||
}
|
||||
if (priority <= CLog::kFATAL) {
|
||||
if (priority <= (s_backend ? CLog::kERROR : CLog::kFATAL)) {
|
||||
MessageBox(NULL, msg, pname, MB_OK | MB_ICONWARNING);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
return s_backend;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,13 +485,7 @@ daemonStartup(IPlatform* iplatform, int argc, const char** argv)
|
||||
bye = &byeThrow;
|
||||
|
||||
// parse command line
|
||||
s_install = false;
|
||||
s_uninstall = false;
|
||||
parse(argc, argv);
|
||||
if (s_install || s_uninstall) {
|
||||
// not allowed to install/uninstall from service
|
||||
throw CWin32Platform::CDaemonFailed(kExitArgs);
|
||||
}
|
||||
|
||||
// run as a service
|
||||
return platform->runDaemon(realMain, daemonStop);
|
||||
@@ -605,58 +533,6 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
|
||||
// parse command line
|
||||
parse(__argc, const_cast<const char**>(__argv));
|
||||
|
||||
// install/uninstall
|
||||
if (s_install) {
|
||||
// get the full path to this program
|
||||
TCHAR path[MAX_PATH];
|
||||
if (GetModuleFileName(NULL, path,
|
||||
sizeof(path) / sizeof(path[0])) == 0) {
|
||||
log((CLOG_CRIT "cannot determine absolute path to program"));
|
||||
return kExitFailed;
|
||||
}
|
||||
|
||||
// construct the command line to start the service with
|
||||
CString commandLine = "--daemon";
|
||||
if (s_restartable) {
|
||||
commandLine += " --restart";
|
||||
}
|
||||
else {
|
||||
commandLine += " --no-restart";
|
||||
}
|
||||
if (s_logFilter != NULL) {
|
||||
commandLine += " --debug ";
|
||||
commandLine += s_logFilter;
|
||||
}
|
||||
commandLine += " ";
|
||||
commandLine += s_serverAddress.getHostname().c_str();
|
||||
|
||||
// install
|
||||
if (!platform.installDaemon(DAEMON_NAME,
|
||||
"Shares this system's mouse and keyboard with others.",
|
||||
path, commandLine.c_str())) {
|
||||
log((CLOG_CRIT "failed to install service"));
|
||||
return kExitFailed;
|
||||
}
|
||||
log((CLOG_PRINT "installed successfully"));
|
||||
return kExitSuccess;
|
||||
}
|
||||
else if (s_uninstall) {
|
||||
switch (platform.uninstallDaemon(DAEMON_NAME)) {
|
||||
case IPlatform::kSuccess:
|
||||
log((CLOG_PRINT "uninstalled successfully"));
|
||||
return kExitSuccess;
|
||||
|
||||
case IPlatform::kFailed:
|
||||
log((CLOG_CRIT "failed to uninstall service"));
|
||||
return kExitFailed;
|
||||
|
||||
case IPlatform::kAlready:
|
||||
log((CLOG_CRIT "service isn't installed"));
|
||||
// return success since service is uninstalled
|
||||
return kExitSuccess;
|
||||
}
|
||||
}
|
||||
|
||||
// daemonize if requested
|
||||
int result;
|
||||
if (s_daemon) {
|
||||
@@ -684,15 +560,6 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
|
||||
|
||||
CNetwork::cleanup();
|
||||
|
||||
// if running as a non-daemon backend and there was an error then
|
||||
// wait for the user to click okay so he can see the error messages.
|
||||
if (s_backend && !s_daemon && (result == kExitFailed || s_errors)) {
|
||||
char msg[1024];
|
||||
msg[0] = '\0';
|
||||
LoadString(instance, IDS_FAILED, msg, sizeof(msg) / sizeof(msg[0]));
|
||||
MessageBox(NULL, msg, pname, MB_OK | MB_ICONWARNING);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,17 +89,6 @@ END
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_SYNERGY ICON DISCARDABLE "synergyc.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_FAILED "Synergy is about to quit with an error. Please check the log for error messages then click OK."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by synergyd.rc
|
||||
//
|
||||
#define IDS_FAILED 1
|
||||
#define IDD_SYNERGY 101
|
||||
#define IDI_SYNERGY 102
|
||||
#define IDC_LOG 1000
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1002
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by synergyd.rc
|
||||
//
|
||||
#define IDS_FAILED 1
|
||||
#define IDD_SYNERGY 101
|
||||
#define IDI_SYNERGY 102
|
||||
#define IDC_LOG 1000
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1002
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -61,10 +61,6 @@ static const char* pname = NULL;
|
||||
static bool s_backend = false;
|
||||
static bool s_restartable = true;
|
||||
static bool s_daemon = true;
|
||||
#if WINDOWS_LIKE
|
||||
static bool s_install = false;
|
||||
static bool s_uninstall = false;
|
||||
#endif
|
||||
static const char* s_configFile = NULL;
|
||||
static const char* s_logFilter = NULL;
|
||||
static CString s_name;
|
||||
@@ -275,13 +271,8 @@ help()
|
||||
#if WINDOWS_LIKE
|
||||
|
||||
# define PLATFORM_ARGS \
|
||||
" {--daemon|--no-daemon}" \
|
||||
" [--install]\n" \
|
||||
"or\n" \
|
||||
" --uninstall\n"
|
||||
# define PLATFORM_DESC \
|
||||
" --install install server as a daemon.\n" \
|
||||
" --uninstall uninstall server daemon.\n"
|
||||
" {--daemon|--no-daemon}"
|
||||
# define PLATFORM_DESC
|
||||
# define PLATFORM_EXTRA \
|
||||
"At least one command line argument is required. If you don't otherwise\n" \
|
||||
"need an argument use `--daemon'.\n" \
|
||||
@@ -334,7 +325,7 @@ PLATFORM_EXTRA
|
||||
"default port, %d.\n"
|
||||
"\n"
|
||||
"If no configuration file pathname is provided then the first of the\n"
|
||||
"following to load sets the configuration:\n"
|
||||
"following to load successfully sets the configuration:\n"
|
||||
" %s\n"
|
||||
" %s\n"
|
||||
"If no configuration file can be loaded then the configuration uses its\n"
|
||||
@@ -465,30 +456,6 @@ parse(int argc, const char** argv)
|
||||
bye(kExitSuccess);
|
||||
}
|
||||
|
||||
#if WINDOWS_LIKE
|
||||
else if (isArg(i, argc, argv, NULL, "--install")) {
|
||||
s_install = true;
|
||||
if (s_uninstall) {
|
||||
log((CLOG_PRINT "%s: `--install' and `--uninstall'"
|
||||
" are mutually exclusive" BYE,
|
||||
pname, argv[i], pname));
|
||||
bye(kExitArgs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WINDOWS_LIKE
|
||||
else if (isArg(i, argc, argv, NULL, "--uninstall")) {
|
||||
s_uninstall = true;
|
||||
if (s_install) {
|
||||
log((CLOG_PRINT "%s: `--install' and `--uninstall'"
|
||||
" are mutually exclusive" BYE,
|
||||
pname, argv[i], pname));
|
||||
bye(kExitArgs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
else if (isArg(i, argc, argv, "--", NULL)) {
|
||||
// remaining arguments are not options
|
||||
++i;
|
||||
@@ -612,24 +579,16 @@ loadConfig()
|
||||
|
||||
#include "CMSWindowsScreen.h"
|
||||
|
||||
static bool s_errors = false;
|
||||
|
||||
static
|
||||
bool
|
||||
logMessageBox(int priority, const char* msg)
|
||||
{
|
||||
if (priority <= CLog::kERROR) {
|
||||
s_errors = true;
|
||||
}
|
||||
if (s_backend) {
|
||||
return true;
|
||||
}
|
||||
if (priority <= CLog::kFATAL) {
|
||||
if (priority <= (s_backend ? CLog::kERROR : CLog::kFATAL)) {
|
||||
MessageBox(NULL, msg, pname, MB_OK | MB_ICONWARNING);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
return s_backend;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -658,13 +617,7 @@ daemonStartup(IPlatform* iplatform, int argc, const char** argv)
|
||||
bye = &byeThrow;
|
||||
|
||||
// parse command line
|
||||
s_install = false;
|
||||
s_uninstall = false;
|
||||
parse(argc, argv);
|
||||
if (s_install || s_uninstall) {
|
||||
// not allowed to install/uninstall from service
|
||||
throw CWin32Platform::CDaemonFailed(kExitArgs);
|
||||
}
|
||||
|
||||
// load configuration
|
||||
loadConfig();
|
||||
@@ -715,62 +668,6 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
|
||||
// parse command line
|
||||
parse(__argc, const_cast<const char**>(__argv));
|
||||
|
||||
// install/uninstall
|
||||
if (s_install) {
|
||||
// get the full path to this program
|
||||
TCHAR path[MAX_PATH];
|
||||
if (GetModuleFileName(NULL, path,
|
||||
sizeof(path) / sizeof(path[0])) == 0) {
|
||||
log((CLOG_CRIT "cannot determine absolute path to program"));
|
||||
return kExitFailed;
|
||||
}
|
||||
|
||||
// construct the command line to start the service with
|
||||
CString commandLine;
|
||||
commandLine += "--daemon";
|
||||
if (s_restartable) {
|
||||
commandLine += " --restart";
|
||||
}
|
||||
else {
|
||||
commandLine += " --no-restart";
|
||||
}
|
||||
if (s_logFilter != NULL) {
|
||||
commandLine += " --debug ";
|
||||
commandLine += s_logFilter;
|
||||
}
|
||||
if (s_configFile != NULL) {
|
||||
commandLine += " --config \"";
|
||||
commandLine += s_configFile;
|
||||
commandLine += "\"";
|
||||
}
|
||||
|
||||
// install
|
||||
if (!platform.installDaemon(DAEMON_NAME,
|
||||
"Shares this system's mouse and keyboard with others.",
|
||||
path, commandLine.c_str())) {
|
||||
log((CLOG_CRIT "failed to install service"));
|
||||
return kExitFailed;
|
||||
}
|
||||
log((CLOG_PRINT "installed successfully"));
|
||||
return kExitSuccess;
|
||||
}
|
||||
else if (s_uninstall) {
|
||||
switch (platform.uninstallDaemon(DAEMON_NAME)) {
|
||||
case IPlatform::kSuccess:
|
||||
log((CLOG_PRINT "uninstalled successfully"));
|
||||
return kExitSuccess;
|
||||
|
||||
case IPlatform::kFailed:
|
||||
log((CLOG_CRIT "failed to uninstall service"));
|
||||
return kExitFailed;
|
||||
|
||||
case IPlatform::kAlready:
|
||||
log((CLOG_CRIT "service isn't installed"));
|
||||
// return success since service is uninstalled
|
||||
return kExitSuccess;
|
||||
}
|
||||
}
|
||||
|
||||
// load configuration
|
||||
loadConfig();
|
||||
|
||||
@@ -801,15 +698,6 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
|
||||
|
||||
CNetwork::cleanup();
|
||||
|
||||
// if running as a non-daemon backend and there was an error then
|
||||
// wait for the user to click okay so he can see the error messages.
|
||||
if (s_backend && !s_daemon && (result == kExitFailed || s_errors)) {
|
||||
char msg[1024];
|
||||
msg[0] = '\0';
|
||||
LoadString(instance, IDS_FAILED, msg, sizeof(msg) / sizeof(msg[0]));
|
||||
MessageBox(NULL, msg, pname, MB_OK | MB_ICONWARNING);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user