merged 1.4 r982:983 into trunk

This commit is contained in:
Nick Bolton 2011-05-09 00:28:45 +00:00
parent 627771cf13
commit 13c6c36107
18 changed files with 208 additions and 86 deletions

View File

@ -152,7 +152,7 @@ CMSWindowsClientTaskBarReceiver::runMenu(int x, int y)
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
HMENU logLevelMenu = GetSubMenu(menu, 3);
CheckMenuRadioItem(logLevelMenu, 0, 6,
CLOG->getFilter() - CLog::kERROR, MF_BYPOSITION);
CLOG->getFilter() - kERROR, MF_BYPOSITION);
int n = TrackPopupMenu(menu,
TPM_NONOTIFY |
TPM_RETURNCMD |
@ -176,31 +176,31 @@ CMSWindowsClientTaskBarReceiver::runMenu(int x, int y)
break;
case IDC_TASKBAR_LOG_LEVEL_ERROR:
CLOG->setFilter(CLog::kERROR);
CLOG->setFilter(kERROR);
break;
case IDC_TASKBAR_LOG_LEVEL_WARNING:
CLOG->setFilter(CLog::kWARNING);
CLOG->setFilter(kWARNING);
break;
case IDC_TASKBAR_LOG_LEVEL_NOTE:
CLOG->setFilter(CLog::kNOTE);
CLOG->setFilter(kNOTE);
break;
case IDC_TASKBAR_LOG_LEVEL_INFO:
CLOG->setFilter(CLog::kINFO);
CLOG->setFilter(kINFO);
break;
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
CLOG->setFilter(CLog::kDEBUG);
CLOG->setFilter(kDEBUG);
break;
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
CLOG->setFilter(CLog::kDEBUG1);
CLOG->setFilter(kDEBUG1);
break;
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
CLOG->setFilter(CLog::kDEBUG2);
CLOG->setFilter(kDEBUG2);
break;
case IDC_TASKBAR_QUIT:

View File

@ -167,7 +167,7 @@ CMSWindowsServerTaskBarReceiver::runMenu(int x, int y)
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
HMENU logLevelMenu = GetSubMenu(menu, 3);
CheckMenuRadioItem(logLevelMenu, 0, 6,
CLOG->getFilter() - CLog::kERROR, MF_BYPOSITION);
CLOG->getFilter() - kERROR, MF_BYPOSITION);
int n = TrackPopupMenu(menu,
TPM_NONOTIFY |
TPM_RETURNCMD |
@ -206,31 +206,31 @@ CMSWindowsServerTaskBarReceiver::runMenu(int x, int y)
break;
case IDC_TASKBAR_LOG_LEVEL_ERROR:
CLOG->setFilter(CLog::kERROR);
CLOG->setFilter(kERROR);
break;
case IDC_TASKBAR_LOG_LEVEL_WARNING:
CLOG->setFilter(CLog::kWARNING);
CLOG->setFilter(kWARNING);
break;
case IDC_TASKBAR_LOG_LEVEL_NOTE:
CLOG->setFilter(CLog::kNOTE);
CLOG->setFilter(kNOTE);
break;
case IDC_TASKBAR_LOG_LEVEL_INFO:
CLOG->setFilter(CLog::kINFO);
CLOG->setFilter(kINFO);
break;
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
CLOG->setFilter(CLog::kDEBUG);
CLOG->setFilter(kDEBUG);
break;
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
CLOG->setFilter(CLog::kDEBUG1);
CLOG->setFilter(kDEBUG1);
break;
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
CLOG->setFilter(CLog::kDEBUG2);
CLOG->setFilter(kDEBUG2);
break;
case IDC_TASKBAR_QUIT:

View File

@ -189,9 +189,9 @@ CArch::showConsole(bool showIfEmpty)
}
void
CArch::writeConsole(const char* str)
CArch::writeConsole(ELevel level, const char* str)
{
m_console->writeConsole(str);
m_console->writeConsole(level, str);
}
void

View File

@ -77,7 +77,7 @@ public:
virtual void openConsole(const char*);
virtual void closeConsole();
virtual void showConsole(bool showIfEmpty);
virtual void writeConsole(const char*);
virtual void writeConsole(ELevel, const char*);
// IArchDaemon overrides
virtual void installDaemon(const char* name,

View File

@ -16,12 +16,16 @@
*/
#include "CArchConsoleStd.h"
#include "CLog.h"
#include <iostream>
void
CArchConsoleStd::writeConsole(const char* str)
CArchConsoleStd::writeConsole(ELevel level, const char* str)
{
// TODO: we need to use cerr also somehow
if ((level >= kFATAL) && (level <= kWARNING))
std::cerr << str << std::endl;
else
std::cout << str << std::endl;
std::cout.flush();
}

View File

@ -29,5 +29,5 @@ public:
virtual void openConsole(const char* title) { }
virtual void closeConsole() { }
virtual void showConsole(bool) { }
virtual void writeConsole(const char*);
virtual void writeConsole(ELevel level, const char*);
};

View File

@ -19,6 +19,7 @@
#define IARCHCONSOLE_H
#include "IInterface.h"
#include "ELevel.h"
//! Interface for architecture dependent console output
/*!
@ -59,7 +60,7 @@ public:
/*!
Writes the given string to the console, opening it if necessary.
*/
virtual void writeConsole(const char*) = 0;
virtual void writeConsole(ELevel, const char*) = 0;
//@}
};

View File

@ -19,6 +19,7 @@
#define IARCHLOG_H
#include "IInterface.h"
#include "ELevel.h"
//! Interface for architecture dependent logging
/*!
@ -27,18 +28,6 @@ synergy. Each architecture must implement this interface.
*/
class IArchLog : public IInterface {
public:
//! Log levels
/*!
The logging priority levels in order of highest to lowest priority.
*/
enum ELevel {
kERROR, //!< For serious or fatal errors
kWARNING, //!< For minor errors and warnings
kNOTE, //!< For messages about notable events
kINFO, //!< For informational messages
kDEBUG //!< For debugging messages
};
//! @name manipulators
//@{

View File

@ -38,25 +38,6 @@ LOGC() provide convenient access.
*/
class CLog {
public:
//! Log levels
/*!
The logging priority levels in order of highest to lowest priority.
*/
enum ELevel {
kPRINT = -1, //!< For print only (no file or time)
kFATAL, //!< For fatal errors
kERROR, //!< For serious errors
kWARNING, //!< For minor errors and warnings
kNOTE, //!< For messages about notable events
kINFO, //!< For informational messages
kDEBUG, //!< For important debugging messages
kDEBUG1, //!< For verbosity +1 debugging messages
kDEBUG2, //!< For verbosity +2 debugging messages
kDEBUG3, //!< For verbosity +3 debugging messages
kDEBUG4, //!< For verbosity +4 debugging messages
kDEBUG5 //!< For verbosity +5 debugging messages
};
~CLog();
//! @name manipulators

View File

@ -34,6 +34,7 @@ set(inc
TMethodEventJob.h
TMethodJob.h
XBase.h
ELevel.h
)
set(src

40
src/lib/base/ELevel.h Normal file
View File

@ -0,0 +1,40 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2011 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
*
* 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/>.
*/
#ifndef ELEVEL_H
#define ELEVEL_H
//! Log levels
/*!
The logging priority levels in order of highest to lowest priority.
*/
enum ELevel {
kPRINT = -1, //!< For print only (no file or time)
kFATAL, //!< For fatal errors
kERROR, //!< For serious errors
kWARNING, //!< For minor errors and warnings
kNOTE, //!< For messages about notable events
kINFO, //!< For informational messages
kDEBUG, //!< For important debugging messages
kDEBUG1, //!< For verbosity +1 debugging messages
kDEBUG2, //!< For verbosity +2 debugging messages
kDEBUG3, //!< For verbosity +3 debugging messages
kDEBUG4, //!< For verbosity +4 debugging messages
kDEBUG5 //!< For verbosity +5 debugging messages
};
#endif

View File

@ -20,6 +20,7 @@
#include "IInterface.h"
#include "CLog.h"
#include "ELevel.h"
//! Outputter interface
/*!
@ -29,8 +30,6 @@ directly or indirectly.
*/
class ILogOutputter : public IInterface {
public:
typedef CLog::ELevel ELevel;
//! @name manipulators
//@{

View File

@ -92,8 +92,8 @@ CConsoleLogOutputter::show(bool showIfEmpty)
bool
CConsoleLogOutputter::write(ELevel level, const char* msg)
{
ARCH->writeConsole(msg);
return true; // wtf?
ARCH->writeConsole(level, msg);
return true;
}
void
@ -138,31 +138,7 @@ CSystemLogOutputter::show(bool showIfEmpty)
bool
CSystemLogOutputter::write(ELevel level, const char* msg)
{
IArchLog::ELevel archLogLevel;
switch (level) {
case CLog::kFATAL:
case CLog::kERROR:
archLogLevel = IArchLog::kERROR;
break;
case CLog::kWARNING:
archLogLevel = IArchLog::kWARNING;
break;
case CLog::kNOTE:
archLogLevel = IArchLog::kNOTE;
break;
case CLog::kINFO:
archLogLevel = IArchLog::kINFO;
break;
default:
archLogLevel = IArchLog::kDEBUG;
break;
};
ARCH->writeLog(archLogLevel, msg);
ARCH->writeLog(level, msg);
return true;
}
@ -266,7 +242,7 @@ CFileLogOutputter::~CFileLogOutputter()
}
bool
CFileLogOutputter::write(ILogOutputter::ELevel level, const char *message)
CFileLogOutputter::write(ELevel level, const char *message)
{
std::ofstream m_handle;
m_handle.open(m_fileName.c_str(), std::fstream::app);

View File

@ -80,6 +80,8 @@ public:
virtual SInt32 pollActiveGroup() const = 0;
virtual void pollPressedKeys(KeyButtonSet& pressedKeys) const = 0;
SInt32 getKeyState(KeyButton keyButton) { return m_keys[keyButton]; }
protected:
typedef CKeyMap::Keystroke Keystroke;

View File

@ -18,6 +18,7 @@
#include <iostream>
#include <gtest/gtest.h>
#include "CArch.h"
#include "CLog.h"
#if SYSAPI_WIN32
#include "CArchMiscWindows.h"
@ -69,6 +70,8 @@ main(int argc, char **argv)
CArch arch;
CLOG->setFilter(kDEBUG2);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();

View File

@ -14,8 +14,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(src
../../../tools/gtest-1.6.0/src/gtest_main.cc
Main.cpp
synergy/CClipboardTests.cpp
synergy/CKeyStateTests.cpp
)
set(inc

View File

@ -0,0 +1,41 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2011 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
*
* 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 <gtest/gtest.h>
#include "CArch.h"
#include "CLog.h"
#if SYSAPI_WIN32
#include "CArchMiscWindows.h"
#endif
int
main(int argc, char **argv)
{
#if SYSAPI_WIN32
// HACK: shouldn't be needed, but logging fails without this.
CArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
#endif
CArch arch;
CLOG->setFilter(kDEBUG2);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -0,0 +1,84 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2011 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
*
* 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 <gtest/gtest.h>
#include "CKeyState.h"
enum {
kAKey = 30
};
class CKeyStateImpl : public CKeyState
{
protected:
virtual SInt32 pollActiveGroup() const
{
throw std::exception("The method or operation is not implemented.");
}
virtual KeyModifierMask pollActiveModifiers() const
{
throw std::exception("The method or operation is not implemented.");
}
virtual bool fakeCtrlAltDel()
{
throw std::exception("The method or operation is not implemented.");
}
virtual void getKeyMap( CKeyMap& keyMap )
{
throw std::exception("The method or operation is not implemented.");
}
virtual void fakeKey( const Keystroke& keystroke )
{
throw std::exception("The method or operation is not implemented.");
}
virtual void pollPressedKeys( KeyButtonSet& pressedKeys ) const
{
throw std::exception("The method or operation is not implemented.");
}
};
TEST(CKeyStateTests, onKey_aKeyPressed_keyStateOne)
{
CKeyStateImpl keyState;
keyState.onKey(kAKey, true, KeyModifierAlt);
EXPECT_EQ(1, keyState.getKeyState(kAKey));
}
TEST(CKeyStateTests, onKey_validButtonUp_keyStateZero)
{
CKeyStateImpl keyState;
keyState.onKey(0, true, KeyModifierAlt);
EXPECT_EQ(0, keyState.getKeyState(0));
}
TEST(CKeyStateTests, onKey_bogusButtonDown_keyStateZero)
{
CKeyStateImpl keyState;
keyState.onKey(0, true, KeyModifierAlt);
EXPECT_EQ(0, keyState.getKeyState(0));
}