patch by jerry -- his first patch! :-)

issue #421 -- portable version for windows.
This commit is contained in:
Nick Bolton
2013-03-15 16:14:43 +00:00
parent c8ea071d78
commit 6ec2ea2c0e
27 changed files with 1352 additions and 15 deletions

View File

@@ -115,6 +115,9 @@ CLog::getFilterName() const
const char*
CLog::getFilterName(int level) const
{
if (level < 0) {
return "Message";
}
return g_priority[level];
}

View File

@@ -263,3 +263,47 @@ CFileLogOutputter::close() {}
void
CFileLogOutputter::show(bool showIfEmpty) {}
//
// CMesssageBoxLogOutputter
//
CMesssageBoxLogOutputter::CMesssageBoxLogOutputter()
{
// do nothing
}
CMesssageBoxLogOutputter::~CMesssageBoxLogOutputter()
{
// do nothing
}
void
CMesssageBoxLogOutputter::open(const char* title)
{
// do nothing
}
void
CMesssageBoxLogOutputter::close()
{
// do nothing
}
void
CMesssageBoxLogOutputter::show(bool showIfEmpty)
{
// do nothing
}
bool
CMesssageBoxLogOutputter::write(ELevel level, const char* msg)
{
// don't spam user with messages.
if (level > kERROR) {
return true;
}
MessageBox(NULL, msg, CLOG->getFilterName(level), MB_OK);
return true;
}

View File

@@ -153,4 +153,20 @@ private:
CBuffer m_buffer;
};
//! Write log to message box
/*!
The level for each message is ignored.
*/
class CMesssageBoxLogOutputter : public ILogOutputter {
public:
CMesssageBoxLogOutputter();
virtual ~CMesssageBoxLogOutputter();
// ILogOutputter overrides
virtual void open(const char* title);
virtual void close();
virtual void show(bool showIfEmpty);
virtual bool write(ELevel level, const char* message);
};
#endif

View File

@@ -153,6 +153,14 @@ CApp::parseArg(const int& argc, const char* const* argv, int& i)
argsBase().m_enableIpc = true;
}
else if (isArg(i, argc, argv, NULL, "--server")) {
// HACK: stop error happening when using portable (synergyp)
}
else if (isArg(i, argc, argv, NULL, "--client")) {
// HACK: stop error happening when using portable (synergyp)
}
#if VNC_SUPPORT
else if (isArg(i, argc, argv, NULL, "--vnc")) {
argsBase().m_enableVnc = true;
@@ -244,18 +252,7 @@ CApp::version()
int
CApp::run(int argc, char** argv)
{
#if SYSAPI_WIN32
// record window instance for tray icon, etc
CArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
#endif
CArch arch;
arch.init();
CLog log;
CEventQueue events;
{
#if MAC_OS_X_VERSION_10_7
// dock hide only supported on lion :(
ProcessSerialNumber psn = { 0, kCurrentProcess };

View File

@@ -205,9 +205,9 @@ CClientApp::help()
"must be the address or hostname of the server. The port overrides the\n"
"default port, %d.\n",
args().m_pname, kDefaultPort
);
);
std::cout << buffer << std::endl;
LOG((CLOG_PRINT "%s", buffer));
}
const char*

View File

@@ -17,6 +17,7 @@
set(inc
CClientTaskBarReceiver.h
CServerTaskBarReceiver.h
CPortableTaskBarReceiver.h
CApp.h
CClientApp.h
CServerApp.h
@@ -54,6 +55,7 @@ set(inc
set(src
CClientTaskBarReceiver.cpp
CServerTaskBarReceiver.cpp
CPortableTaskBarReceiver.cpp
CApp.cpp
CClientApp.cpp
CServerApp.cpp

View File

@@ -0,0 +1,141 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012 Bolton Software Ltd.
* Copyright (C) 2003 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CPortableTaskBarReceiver.h"
#include "CLock.h"
#include "CStringUtil.h"
#include "IEventQueue.h"
#include "CArch.h"
#include "Version.h"
//
// CPortableTaskBarReceiver
//
CPortableTaskBarReceiver::CPortableTaskBarReceiver() :
m_state(kNotRunning)
{
// do nothing
}
CPortableTaskBarReceiver::~CPortableTaskBarReceiver()
{
// do nothing
}
void
CPortableTaskBarReceiver::updateStatus(INode* node, const CString& errorMsg)
{
{
// update our status
m_errorMessage = errorMsg;
if (node == NULL) {
if (m_errorMessage.empty()) {
m_state = kNotRunning;
}
else {
m_state = kNotWorking;
}
}
else {
m_state = kNotConnected;
}
// let subclasses have a go
onStatusChanged(node);
}
// tell task bar
ARCH->updateReceiver(this);
}
CPortableTaskBarReceiver::EState
CPortableTaskBarReceiver::getStatus() const
{
return m_state;
}
const CString&
CPortableTaskBarReceiver::getErrorMessage() const
{
return m_errorMessage;
}
void
CPortableTaskBarReceiver::quit()
{
EVENTQUEUE->addEvent(CEvent(CEvent::kQuit));
}
void
CPortableTaskBarReceiver::onStatusChanged(INode*)
{
// do nothing
}
void
CPortableTaskBarReceiver::lock() const
{
// do nothing
}
void
CPortableTaskBarReceiver::unlock() const
{
// do nothing
}
std::string
CPortableTaskBarReceiver::getToolTip() const
{
switch (m_state) {
case kNotRunning:
return CStringUtil::print("%s: Not running", kAppVersion);
case kNotWorking:
return CStringUtil::print("%s: %s",
kAppVersion, m_errorMessage.c_str());
case kNotConnected:
return CStringUtil::print("%s: Unknown", kAppVersion);
default:
return "";
}
}
CEvent::Type
CPortableTaskBarReceiver::getReloadConfigEvent()
{
// do nothing
return NULL;
}
CEvent::Type
CPortableTaskBarReceiver::getForceReconnectEvent()
{
// do nothing
return NULL;
}
CEvent::Type
CPortableTaskBarReceiver::getResetServerEvent()
{
// do nothing
return NULL;
}

View File

@@ -0,0 +1,96 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012 Bolton Software Ltd.
* Copyright (C) 2003 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "CString.h"
#include "IArchTaskBarReceiver.h"
#include "stdvector.h"
#include "CEvent.h"
#include "INode.h"
#include "LogOutputters.h"
//! Implementation of IArchTaskBarReceiver for the synergy server
class CPortableTaskBarReceiver : public IArchTaskBarReceiver {
public:
CPortableTaskBarReceiver();
virtual ~CPortableTaskBarReceiver();
//! @name manipulators
//@{
//! Update status
/*!
Determine the status and query required information from the server.
*/
void updateStatus(INode*, const CString& errorMsg);
//@}
// IArchTaskBarReceiver overrides
virtual void showStatus() = 0;
virtual void runMenu(int x, int y) = 0;
virtual void primaryAction() = 0;
virtual void lock() const;
virtual void unlock() const;
virtual const Icon getIcon() const = 0;
virtual std::string getToolTip() const;
protected:
typedef std::vector<CString> CClients;
enum EState {
kNotRunning,
kNotWorking,
kNotConnected,
kConnected,
kMaxState
};
//! Get status
EState getStatus() const;
//! Get error message
const CString& getErrorMessage() const;
//! Quit app
/*!
Causes the application to quit gracefully
*/
void quit();
//! Status change notification
/*!
Called when status changes. The default implementation does
nothing.
*/
virtual void onStatusChanged(INode* node);
protected:
CEvent::Type getReloadConfigEvent();
CEvent::Type getForceReconnectEvent();
CEvent::Type getResetServerEvent();
private:
EState m_state;
CString m_errorMessage;
CString m_server;
CClients m_clients;
};
IArchTaskBarReceiver* createTaskBarReceiver(const CBufferedLogOutputter* logBuffer);

View File

@@ -198,7 +198,7 @@ CServerApp::help()
ARCH->concatPath(ARCH->getSystemDirectory(), SYS_CONFIG_NAME).c_str()
);
std::cout << buffer << std::endl;
LOG((CLOG_PRINT "%s", buffer));
}
void