From d2135af0d97170b91e6cc774eeaa778af3607855 Mon Sep 17 00:00:00 2001 From: crs Date: Sat, 1 Jun 2002 19:26:11 +0000 Subject: [PATCH] fixes, mainly for windows. first, had to add a notification from CServer to the primary screen when the configuration changes so it can make necessary adjustments (the win32 primary screen must tell the hook dll about the new jump zones). changed includes of some std c++ library files to go through our own include files. these wrap the include with stuff to keep vc++ quiet when compiling at warning level 4, which is what it does now. it also works around missing and on g++2.96. added missing std:: where necessary. g++ doesn't really support namespaces so it lets references without the namespace slip through. added workaround or fix. not sure if istringstream::str(string) should reset eofbit. it does on g++ but does not on vc++. added clear() after str() so it works either way. added low-level keyboard hook to win32. if available (it's only available on NT SP3 and up) it allows us to catch and handle alt+tab, alt+esc, ctrl+esc, and windows key hot keys. i think that leaves only ctrl+alt+del and accessibility functions uncaught on those systems. --- base/CLog.cpp | 11 +- base/CLog.h | 4 +- base/CString.h | 11 ++ base/XBase.h | 2 + base/base.dsp | 44 +++++++- base/common.h | 11 +- base/stdfstream.h | 4 + base/stdistream.h | 28 +++++ base/stdlist.h | 3 + base/stdmap.h | 3 + base/stdostream.h | 7 ++ base/stdpost.h | 3 + base/stdpre.h | 11 ++ base/stdset.h | 3 + base/stdsstream.h | 4 + base/stdvector.h | 3 + client/CMSWindowsSecondaryScreen.h | 4 +- client/CXWindowsSecondaryScreen.h | 4 +- client/client.cpp | 1 + client/client.dsp | 4 +- http/CHTTPProtocol.cpp | 6 +- http/CHTTPProtocol.h | 4 +- http/XHTTP.cpp | 13 ++- http/http.dsp | 110 ++++++++++++++++++++ io/CStreamBuffer.h | 4 +- io/io.dsp | 4 +- mt/mt.dsp | 4 +- net/net.dsp | 4 +- server/CConfig.cpp | 43 ++++---- server/CConfig.h | 16 +-- server/CHTTPServer.cpp | 74 ++----------- server/CHTTPServer.h | 2 +- server/CMSWindowsPrimaryScreen.cpp | 53 +++++++++- server/CMSWindowsPrimaryScreen.h | 2 + server/CServer.cpp | 5 + server/CServer.h | 4 +- server/CSynergyHook.cpp | 162 ++++++++++++++++++++++++++++- server/CXWindowsPrimaryScreen.cpp | 5 + server/CXWindowsPrimaryScreen.h | 1 + server/server.cpp | 5 +- server/server.dsp | 20 ++-- server/synrgyhk.dsp | 5 +- synergy.dsw | 55 +++------- synergy/CXWindowsClipboard.h | 4 +- synergy/IPrimaryScreen.h | 5 + synergy/synergy.dsp | 4 +- 46 files changed, 576 insertions(+), 203 deletions(-) create mode 100644 base/stdfstream.h create mode 100644 base/stdistream.h create mode 100644 base/stdlist.h create mode 100644 base/stdmap.h create mode 100644 base/stdostream.h create mode 100644 base/stdpost.h create mode 100644 base/stdpre.h create mode 100644 base/stdset.h create mode 100644 base/stdsstream.h create mode 100644 base/stdvector.h create mode 100755 http/http.dsp diff --git a/base/CLog.cpp b/base/CLog.cpp index 7ee437fa..145a2a2c 100644 --- a/base/CLog.cpp +++ b/base/CLog.cpp @@ -21,6 +21,11 @@ static const char* g_priority[] = { }; static const int g_numPriority = (int)(sizeof(g_priority) / sizeof(g_priority[0])); +#if defined(NDEBUG) +static const int g_defaultMaxPriority = 4; +#else +static const int g_defaultMaxPriority = 5; +#endif static const int g_maxPriorityLength = 7; // length of longest string static const int g_prioritySuffixLength = 2; static const int g_priorityPad = g_maxPriorityLength + @@ -145,11 +150,7 @@ int CLog::getMaxPriority() CHoldLock lock(s_lock); if (s_maxPriority == -1) { -#if defined(NDEBUG) - s_maxPriority = 4; -#else - s_maxPriority = 5; -#endif + s_maxPriority = g_defaultMaxPriority; const char* priEnv = getenv("SYN_LOG_PRI"); if (priEnv != NULL) { for (int i = 0; i < g_numPriority; ++i) { diff --git a/base/CLog.h b/base/CLog.h index 0a65a787..63d97174 100644 --- a/base/CLog.h +++ b/base/CLog.h @@ -37,11 +37,11 @@ public: private: class CHoldLock { public: - CHoldLock(CLog::Lock lock) : m_lock(lock) { m_lock(true); } + CHoldLock(Lock lock) : m_lock(lock) { m_lock(true); } ~CHoldLock() { m_lock(false); } private: - CLog::Lock m_lock; + Lock m_lock; }; static void dummyLock(bool); diff --git a/base/CString.h b/base/CString.h index 547152e3..dc0a15f4 100644 --- a/base/CString.h +++ b/base/CString.h @@ -2,7 +2,14 @@ #define CSTRING_H #include "common.h" +#include "stdpre.h" #include +#include "stdpost.h" + +#if defined(_MSC_VER) +#pragma warning(push, 4) +#pragma warning(disable: 4097) // typedef-name used as synonym +#endif #ifndef CSTRING_DEF_CTOR #define CSTRING_ALLOC1 @@ -37,5 +44,9 @@ public: _Myt(_f, _l CSTRING_ALLOC2) { } }; +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + #endif diff --git a/base/XBase.h b/base/XBase.h index 8ab63b5f..c654de6e 100644 --- a/base/XBase.h +++ b/base/XBase.h @@ -2,7 +2,9 @@ #define XBASE_H #include "CString.h" +#include "stdpre.h" #include +#include "stdpost.h" class XBase : public std::exception { public: diff --git a/base/base.dsp b/base/base.dsp index c73c0e44..fa7569aa 100644 --- a/base/base.dsp +++ b/base/base.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c +# ADD CPP /nologo /MT /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -65,7 +65,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c +# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" @@ -139,6 +139,46 @@ SOURCE=.\IJob.h # End Source File # Begin Source File +SOURCE=.\stdfstream.h +# End Source File +# Begin Source File + +SOURCE=.\stdistream.h +# End Source File +# Begin Source File + +SOURCE=.\stdlist.h +# End Source File +# Begin Source File + +SOURCE=.\stdmap.h +# End Source File +# Begin Source File + +SOURCE=.\stdostream.h +# End Source File +# Begin Source File + +SOURCE=.\stdpost.h +# End Source File +# Begin Source File + +SOURCE=.\stdpre.h +# End Source File +# Begin Source File + +SOURCE=.\stdset.h +# End Source File +# Begin Source File + +SOURCE=.\stdsstream.h +# End Source File +# Begin Source File + +SOURCE=.\stdvector.h +# End Source File +# Begin Source File + SOURCE=.\TMethodJob.h # End Source File # Begin Source File diff --git a/base/common.h b/base/common.h index e4ecb865..08f02331 100644 --- a/base/common.h +++ b/base/common.h @@ -25,17 +25,8 @@ // turn off bonehead warnings #pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4514) // unreferenced inline function removed -// -// ignore warnings inside microsoft's standard C++ library -// -// bonehead bugs/warnings -#pragma warning(disable: 4097) // typedef-name used as synonym -#pragma warning(disable: 4511) // copy constructor can't be generated -#pragma warning(disable: 4512) // assignment operator can't be generated - -// we'd really rather have these enabled to check our code -#pragma warning(disable: 4100) // unreferenced formal parameter #endif // (_MSC_VER >= 1200) #else diff --git a/base/stdfstream.h b/base/stdfstream.h new file mode 100644 index 00000000..1b9db065 --- /dev/null +++ b/base/stdfstream.h @@ -0,0 +1,4 @@ +#include "stdpre.h" +#include +#include "stdpost.h" +#include "stdistream.h" diff --git a/base/stdistream.h b/base/stdistream.h new file mode 100644 index 00000000..1cbbdcbd --- /dev/null +++ b/base/stdistream.h @@ -0,0 +1,28 @@ +#include "stdpre.h" +#if !defined(CONFIG_PLATFORM_LINUX) +#include +#else +#include +#endif +#include "stdpost.h" + +#if defined(CONFIG_PLATFORM_WIN32) && defined(_MSC_VER) +inline +std::istream& operator>>(std::istream& s, SInt8& i) +{ return s >> (signed char&)i; } +inline +std::istream& operator>>(std::istream& s, SInt16& i) +{ return s >> (short&)i; } +inline +std::istream& operator>>(std::istream& s, SInt32& i) +{ return s >> (int&)i; } +inline +std::istream& operator>>(std::istream& s, UInt8& i) +{ return s >> (unsigned char&)i; } +inline +std::istream& operator>>(std::istream& s, UInt16& i) +{ return s >> (unsigned short&)i; } +inline +std::istream& operator>>(std::istream& s, UInt32& i) +{ return s >> (unsigned int&)i; } +#endif diff --git a/base/stdlist.h b/base/stdlist.h new file mode 100644 index 00000000..98503b7b --- /dev/null +++ b/base/stdlist.h @@ -0,0 +1,3 @@ +#include "stdpre.h" +#include +#include "stdpost.h" diff --git a/base/stdmap.h b/base/stdmap.h new file mode 100644 index 00000000..a77f22b6 --- /dev/null +++ b/base/stdmap.h @@ -0,0 +1,3 @@ +#include "stdpre.h" +#include +#include "stdpost.h" diff --git a/base/stdostream.h b/base/stdostream.h new file mode 100644 index 00000000..11a1b361 --- /dev/null +++ b/base/stdostream.h @@ -0,0 +1,7 @@ +#include "stdpre.h" +#if !defined(CONFIG_PLATFORM_LINUX) +#include +#else +#include +#endif +#include "stdpost.h" diff --git a/base/stdpost.h b/base/stdpost.h new file mode 100644 index 00000000..658cd5d5 --- /dev/null +++ b/base/stdpost.h @@ -0,0 +1,3 @@ +#if defined(_MSC_VER) +#pragma warning(pop) +#endif diff --git a/base/stdpre.h b/base/stdpre.h new file mode 100644 index 00000000..4461b475 --- /dev/null +++ b/base/stdpre.h @@ -0,0 +1,11 @@ +#if defined(_MSC_VER) +#pragma warning(disable: 4786) // identifier truncated +#pragma warning(disable: 4514) // unreferenced inline +#pragma warning(disable: 4710) // not inlined +#pragma warning(disable: 4663) // C++ change, template specialization +#pragma warning(push, 3) +#pragma warning(disable: 4018) // signed/unsigned mismatch +#pragma warning(disable: 4284) +#pragma warning(disable: 4146) // unary minus on unsigned value +#pragma warning(disable: 4127) // conditional expression is constant +#endif diff --git a/base/stdset.h b/base/stdset.h new file mode 100644 index 00000000..fc818573 --- /dev/null +++ b/base/stdset.h @@ -0,0 +1,3 @@ +#include "stdpre.h" +#include +#include "stdpost.h" diff --git a/base/stdsstream.h b/base/stdsstream.h new file mode 100644 index 00000000..b486dc62 --- /dev/null +++ b/base/stdsstream.h @@ -0,0 +1,4 @@ +#include "stdpre.h" +#include +#include "stdpost.h" +#include "stdistream.h" diff --git a/base/stdvector.h b/base/stdvector.h new file mode 100644 index 00000000..8c7cd443 --- /dev/null +++ b/base/stdvector.h @@ -0,0 +1,3 @@ +#include "stdpre.h" +#include +#include "stdpost.h" diff --git a/client/CMSWindowsSecondaryScreen.h b/client/CMSWindowsSecondaryScreen.h index 3ca03338..258853b5 100644 --- a/client/CMSWindowsSecondaryScreen.h +++ b/client/CMSWindowsSecondaryScreen.h @@ -3,8 +3,8 @@ #include "CMSWindowsScreen.h" #include "ISecondaryScreen.h" -#include -#include +#include "stdmap.h" +#include "stdvector.h" class CMSWindowsSecondaryScreen : public CMSWindowsScreen, public ISecondaryScreen { public: diff --git a/client/CXWindowsSecondaryScreen.h b/client/CXWindowsSecondaryScreen.h index a89e344b..2617096c 100644 --- a/client/CXWindowsSecondaryScreen.h +++ b/client/CXWindowsSecondaryScreen.h @@ -3,8 +3,8 @@ #include "CXWindowsScreen.h" #include "ISecondaryScreen.h" -#include -#include +#include "stdmap.h" +#include "stdvector.h" class CXWindowsSecondaryScreen : public CXWindowsScreen, public ISecondaryScreen { public: diff --git a/client/client.cpp b/client/client.cpp index 479dbe06..1364d83d 100644 --- a/client/client.cpp +++ b/client/client.cpp @@ -5,6 +5,7 @@ #include "CNetwork.h" #include "CNetworkAddress.h" #include "CThread.h" +#include // // logging thread safety diff --git a/client/client.dsp b/client/client.dsp index b7ffa272..0d516a91 100644 --- a/client/client.dsp +++ b/client/client.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c +# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -68,7 +68,7 @@ LINK32=link.exe # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c +# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 diff --git a/http/CHTTPProtocol.cpp b/http/CHTTPProtocol.cpp index 46d5bc7a..4c52ca7d 100644 --- a/http/CHTTPProtocol.cpp +++ b/http/CHTTPProtocol.cpp @@ -3,11 +3,12 @@ #include "XHTTP.h" #include "IInputStream.h" #include "IOutputStream.h" +#include "stdsstream.h" +#include #include #include #include #include -#include // // CHTTPUtil::CaselessCmp @@ -88,6 +89,7 @@ CHTTPRequest* CHTTPProtocol::readRequest(IInputStream* stream) // parse version char dot; s.str(version); + s.clear(); s.ignore(5); s >> request->m_majorVersion; s.get(dot); @@ -229,7 +231,7 @@ void CHTTPProtocol::reply( } // write reply header - ostringstream s; + std::ostringstream s; s << "HTTP/" << reply.m_majorVersion << "." << reply.m_minorVersion << " " << reply.m_status << " " << diff --git a/http/CHTTPProtocol.h b/http/CHTTPProtocol.h index 216c8e45..357c3175 100644 --- a/http/CHTTPProtocol.h +++ b/http/CHTTPProtocol.h @@ -3,8 +3,8 @@ #include "BasicTypes.h" #include "CString.h" -#include -#include +#include "stdmap.h" +#include "stdvector.h" class IInputStream; class IOutputStream; diff --git a/http/XHTTP.cpp b/http/XHTTP.cpp index dfae8a97..f069f1da 100644 --- a/http/XHTTP.cpp +++ b/http/XHTTP.cpp @@ -1,6 +1,6 @@ #include "XHTTP.h" #include "CHTTPProtocol.h" -#include +#include "stdsstream.h" // // XHTTP @@ -45,16 +45,15 @@ void XHTTP::addHeaders(CHTTPReply&) const CString XHTTP::getWhat() const throw() { try { - char code[20]; - sprintf(code, "%d ", m_status); - CString msg(code); + std::ostringstream s; + s << m_status << " "; if (!m_reason.empty()) { - msg += m_reason; + s << m_reason.c_str(); } else { - msg += getReason(m_status); + s << getReason(m_status); } - return msg; + return s.str(); } catch (...) { return CString(); diff --git a/http/http.dsp b/http/http.dsp new file mode 100755 index 00000000..75173bef --- /dev/null +++ b/http/http.dsp @@ -0,0 +1,110 @@ +# Microsoft Developer Studio Project File - Name="http" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=http - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "http.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "http.mak" CFG="http - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "http - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "http - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "millpond" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "http - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\io" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "http - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "http - Win32 Release" +# Name "http - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\CHTTPProtocol.cpp +# End Source File +# Begin Source File + +SOURCE=.\XHTTP.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\CHTTPProtocol.h +# End Source File +# Begin Source File + +SOURCE=.\XHTTP.h +# End Source File +# End Group +# End Target +# End Project diff --git a/io/CStreamBuffer.h b/io/CStreamBuffer.h index 2338b8da..97b32296 100644 --- a/io/CStreamBuffer.h +++ b/io/CStreamBuffer.h @@ -2,8 +2,8 @@ #define CSTREAMBUFFER_H #include "BasicTypes.h" -#include -#include +#include "stdlist.h" +#include "stdvector.h" class CStreamBuffer { public: diff --git a/io/io.dsp b/io/io.dsp index b06989a9..58df7ddc 100644 --- a/io/io.dsp +++ b/io/io.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /I "..\mt" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c +# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\mt" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -65,7 +65,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /I "..\mt" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c +# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\mt" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" diff --git a/mt/mt.dsp b/mt/mt.dsp index 8067b7d7..0c5dab8d 100644 --- a/mt/mt.dsp +++ b/mt/mt.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c +# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -65,7 +65,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c +# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" diff --git a/net/net.dsp b/net/net.dsp index 54d52353..1b5ff922 100644 --- a/net/net.dsp +++ b/net/net.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c +# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -65,7 +65,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c +# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" diff --git a/server/CConfig.cpp b/server/CConfig.cpp index f1615622..c458c2b1 100644 --- a/server/CConfig.cpp +++ b/server/CConfig.cpp @@ -1,12 +1,7 @@ #include "CConfig.h" +#include "stdistream.h" +#include "stdostream.h" #include -// FIXME -- fix this with automake and config.h -#if !defined(CONFIG_PLATFORM_LINUX) -#include -#include -#else -#include -#endif // // CConfig @@ -160,10 +155,10 @@ const char* CConfig::dirName(EDirection dir) return s_name[dir - kFirstDirection]; } -bool CConfig::readLine(istream& s, CString& line) +bool CConfig::readLine(std::istream& s, CString& line) { s >> std::ws; - while (getline(s, line)) { + while (std::getline(s, line)) { // strip comments and then trailing whitespace CString::size_type i = line.rfind('#'); if (i != CString::npos) { @@ -183,7 +178,7 @@ bool CConfig::readLine(istream& s, CString& line) return false; } -void CConfig::readSection(istream& s) +void CConfig::readSection(std::istream& s) { static const char s_section[] = "section:"; static const char s_screens[] = "screens"; @@ -223,7 +218,7 @@ void CConfig::readSection(istream& s) } } -void CConfig::readSectionScreens(istream& s) +void CConfig::readSectionScreens(std::istream& s) { CString line; CString name; @@ -256,7 +251,7 @@ void CConfig::readSectionScreens(istream& s) throw XConfigRead("unexpected end of screens section"); } -void CConfig::readSectionLinks(istream& s) +void CConfig::readSectionLinks(std::istream& s) { CString line; CString screen; @@ -338,7 +333,7 @@ void CConfig::readSectionLinks(istream& s) // CConfig I/O // -istream& operator>>(istream& s, CConfig& config) +std::istream& operator>>(std::istream& s, CConfig& config) { // FIXME -- should track line and column to improve error reporting @@ -350,44 +345,44 @@ istream& operator>>(istream& s, CConfig& config) return s; } -ostream& operator<<(ostream& s, const CConfig& config) +std::ostream& operator<<(std::ostream& s, const CConfig& config) { // screens section - s << "section: screens" << endl; + s << "section: screens" << std::endl; for (CConfig::const_iterator screen = config.begin(); screen != config.end(); ++screen) { - s << "\t" << screen->c_str() << ":" << endl; + s << "\t" << screen->c_str() << ":" << std::endl; } - s << "end" << endl; + s << "end" << std::endl; // links section CString neighbor; - s << "section: links" << endl; + s << "section: links" << std::endl; for (CConfig::const_iterator screen = config.begin(); screen != config.end(); ++screen) { - s << "\t" << screen->c_str() << ":" << endl; + s << "\t" << screen->c_str() << ":" << std::endl; neighbor = config.getNeighbor(*screen, CConfig::kLeft); if (!neighbor.empty()) { - s << "\t\tleft=" << neighbor.c_str() << endl; + s << "\t\tleft=" << neighbor.c_str() << std::endl; } neighbor = config.getNeighbor(*screen, CConfig::kRight); if (!neighbor.empty()) { - s << "\t\tright=" << neighbor.c_str() << endl; + s << "\t\tright=" << neighbor.c_str() << std::endl; } neighbor = config.getNeighbor(*screen, CConfig::kTop); if (!neighbor.empty()) { - s << "\t\tup=" << neighbor.c_str() << endl; + s << "\t\tup=" << neighbor.c_str() << std::endl; } neighbor = config.getNeighbor(*screen, CConfig::kBottom); if (!neighbor.empty()) { - s << "\t\tdown=" << neighbor.c_str() << endl; + s << "\t\tdown=" << neighbor.c_str() << std::endl; } } - s << "end" << endl; + s << "end" << std::endl; return s; } diff --git a/server/CConfig.h b/server/CConfig.h index 3e9fcd16..cbb5f9ae 100644 --- a/server/CConfig.h +++ b/server/CConfig.h @@ -5,7 +5,7 @@ #include "CString.h" #include "XBase.h" #include -#include +#include "stdmap.h" class CConfig; @@ -57,7 +57,7 @@ public: } private: - CConfig::internal_const_iterator m_i; + internal_const_iterator m_i; }; CConfig(); @@ -98,17 +98,17 @@ public: // read/write a configuration. operator>> will throw XConfigRead // on error. - friend istream& operator>>(istream&, CConfig&); - friend ostream& operator<<(ostream&, const CConfig&); + friend std::istream& operator>>(std::istream&, CConfig&); + friend std::ostream& operator<<(std::ostream&, const CConfig&); // get the name of a direction (for debugging) static const char* dirName(EDirection); private: - static bool readLine(istream&, CString&); - void readSection(istream&); - void readSectionScreens(istream&); - void readSectionLinks(istream&); + static bool readLine(std::istream&, CString&); + void readSection(std::istream&); + void readSectionScreens(std::istream&); + void readSectionLinks(std::istream&); private: CCellMap m_map; diff --git a/server/CHTTPServer.cpp b/server/CHTTPServer.cpp index 7344fb29..05378d8e 100644 --- a/server/CHTTPServer.cpp +++ b/server/CHTTPServer.cpp @@ -6,8 +6,9 @@ #include "CLog.h" #include "XThread.h" #include "ISocket.h" -#include -#include +#include "stdset.h" +#include "stdsstream.h" +#include // // CHTTPServer @@ -158,7 +159,7 @@ void CHTTPServer::doProcessGetEditMap( static const char* s_editMapScreenEnd = "\r\n"; - ostringstream s; + std::ostringstream s; // convert screen map into a temporary screen map CScreenArray screens; @@ -236,7 +237,7 @@ void CHTTPServer::doProcessPostEditMap( } try { - ostringstream s; + std::ostringstream s; // convert post data into a temporary screen map. also check // that no screen name is invalid or used more than once. @@ -309,7 +310,7 @@ void CHTTPServer::doProcessPostEditMap( // now reply with current map doProcessGetEditMap(request, reply); } - catch (XHTTP& e) { + catch (XHTTP&) { // FIXME -- construct a more meaningful error? throw; } @@ -318,7 +319,7 @@ void CHTTPServer::doProcessPostEditMap( bool CHTTPServer::parseXY( const CString& xy, SInt32& x, SInt32& y) { - istringstream s(xy); + std::istringstream s(xy); char delimiter; s >> x; s.get(delimiter); @@ -326,65 +327,10 @@ bool CHTTPServer::parseXY( return (!!s && delimiter == 'x'); } -/* -#include // FIXME -// FIXME - cout << "method: " << request.m_method << endl; - cout << "uri: " << request.m_uri << endl; - cout << "version: " << request.m_majorVersion << "." << - request.m_majorVersion << endl; - cout << "headers:" << endl; - for (CHTTPRequest::CHeaderMap::const_iterator - index = request.m_headerIndexByName.begin(); - index != request.m_headerIndexByName.end(); - ++index) { - assert(index->second < request.m_headers.size()); - cout << " " << index->first << ": " << - request.m_headers[index->second] << endl; - } - cout << endl; - - cout << request.m_body << endl; - -// FIXME - reply.m_majorVersion = request.m_majorVersion; - reply.m_minorVersion = request.m_minorVersion; - reply.m_status = 200; - reply.m_reason = "OK"; - reply.m_method = request.m_method; - reply.m_headers.push_back(std::make_pair(CString("Content-Type"), - CString("text/html"))); -if (request.m_uri != "/bar") { - reply.m_body = -"\r\n" -" \r\n" -" test\r\n" -" \r\n" -" \r\n" -"

test

\r\n" -"
\r\n" -" \r\n" -" \r\n" -"
\r\n" -" \r\n" -"\r\n" -; -} -else { - reply.m_body = -"\r\n" -" \r\n" -" test reply\r\n" -" \r\n" -" \r\n" -"

test reply

\r\n" -" \r\n" -"\r\n" -; -} - // FIXME -*/ +// +// CHTTPServer::CScreenArray +// CHTTPServer::CScreenArray::CScreenArray() : m_w(0), m_h(0) { diff --git a/server/CHTTPServer.h b/server/CHTTPServer.h index 60369c31..50a5708b 100644 --- a/server/CHTTPServer.h +++ b/server/CHTTPServer.h @@ -3,7 +3,7 @@ #include "BasicTypes.h" #include "CString.h" -#include +#include "stdvector.h" class CServer; class CConfig; diff --git a/server/CMSWindowsPrimaryScreen.cpp b/server/CMSWindowsPrimaryScreen.cpp index fa6d7e5c..6e084fdd 100644 --- a/server/CMSWindowsPrimaryScreen.cpp +++ b/server/CMSWindowsPrimaryScreen.cpp @@ -22,7 +22,13 @@ CMSWindowsPrimaryScreen::CMSWindowsPrimaryScreen() : m_mark(0), m_markReceived(0) { - // do nothing + // detect operating system + OSVERSIONINFO version; + version.dwOSVersionInfoSize = sizeof(version); + if (GetVersionEx(&version) == 0) { + log((CLOG_WARN "cannot determine OS: %d", GetLastError())); + } + m_is95Family = (version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); } CMSWindowsPrimaryScreen::~CMSWindowsPrimaryScreen() @@ -97,7 +103,19 @@ void CMSWindowsPrimaryScreen::doEnter() // not active anymore m_active = false; - // set the zones that should cause a jump + // release keyboard/mouse and set the zones that should cause a jump +/* FIXME +if (UnregisterHotKey(m_window, 0x0001) != 0) { +log((CLOG_INFO "released hot key")); +} +else { +log((CLOG_INFO "failed to release hot key: %d", GetLastError())); +} +*/ + if (m_is95Family) { + DWORD dummy = 0; + SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &dummy, 0); + } SInt32 w, h; getScreenSize(&w, &h); SetZoneFunc setZone = (SetZoneFunc)GetProcAddress( @@ -159,6 +177,19 @@ void CMSWindowsPrimaryScreen::leave() SetRelayFunc setRelay = (SetRelayFunc)GetProcAddress( m_hookLibrary, "setRelay"); setRelay(); + if (m_is95Family) { + // disable ctrl+alt+del, alt+tab, ctrl+esc + DWORD dummy = 0; + SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &dummy, 0); + } +/* FIXME +if (RegisterHotKey(m_window, 0x0001, MOD_ALT, VK_TAB) != 0) { +log((CLOG_INFO "got hot key")); +} +else { +log((CLOG_INFO "failed to get hot key: %d", GetLastError())); +} +*/ // get keyboard input and capture mouse SetActiveWindow(m_window); @@ -203,6 +234,17 @@ void CMSWindowsPrimaryScreen::leave() } } +void CMSWindowsPrimaryScreen::onConfigure() +{ + if (!m_active) { + SInt32 w, h; + getScreenSize(&w, &h); + SetZoneFunc setZone = (SetZoneFunc)GetProcAddress( + m_hookLibrary, "setZone"); + setZone(m_server->getActivePrimarySides(), w, h, getJumpZoneSize()); + } +} + void CMSWindowsPrimaryScreen::warpCursor(SInt32 x, SInt32 y) { // set the cursor position without generating an event @@ -479,7 +521,12 @@ LRESULT CMSWindowsPrimaryScreen::onEvent( WPARAM wParam, LPARAM lParam) { switch (msg) { - // FIXME -- handle display changes (and resize full-screen window) +/* +case WM_HOTKEY: +log((CLOG_INFO "hot key: %d, %d, %s %s %s", wParam, HIWORD(lParam), (LOWORD(lParam) & MOD_ALT) ? "ALT" : "", (LOWORD(lParam) & MOD_CONTROL) ? "CTRL" : "", (LOWORD(lParam) & MOD_SHIFT) ? "SHIFT" : "", (LOWORD(lParam) & MOD_WIN) ? "WIN" : "")); +return 0; +*/ + case WM_PAINT: ValidateRect(hwnd, NULL); return 0; diff --git a/server/CMSWindowsPrimaryScreen.h b/server/CMSWindowsPrimaryScreen.h index 9d44c912..a3f3afe0 100644 --- a/server/CMSWindowsPrimaryScreen.h +++ b/server/CMSWindowsPrimaryScreen.h @@ -20,6 +20,7 @@ public: virtual void close(); virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute); virtual void leave(); + virtual void onConfigure(); virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute); virtual void setClipboard(ClipboardID, const IClipboard*); virtual void grabClipboard(ClipboardID); @@ -49,6 +50,7 @@ private: private: CServer* m_server; + bool m_is95Family; bool m_active; HWND m_window; HWND m_nextClipboardWindow; diff --git a/server/CServer.cpp b/server/CServer.cpp index c2c172a4..0de5c196 100644 --- a/server/CServer.cpp +++ b/server/CServer.cpp @@ -151,6 +151,11 @@ bool CServer::setConfig(const CConfig& config) // cut over m_config = config; + + // tell primary screen about reconfiguration + if (m_primary != NULL) { + m_primary->onConfigure(); + } } // wait for old secondary screen threads to disconnect. must diff --git a/server/CServer.h b/server/CServer.h index f11ba980..9f7b32b3 100644 --- a/server/CServer.h +++ b/server/CServer.h @@ -10,8 +10,8 @@ #include "CString.h" #include "CThread.h" #include "XBase.h" -#include -#include +#include "stdlist.h" +#include "stdmap.h" class CThread; class IServerProtocol; diff --git a/server/CSynergyHook.cpp b/server/CSynergyHook.cpp index 3c1df9eb..21bf518d 100644 --- a/server/CSynergyHook.cpp +++ b/server/CSynergyHook.cpp @@ -42,6 +42,10 @@ static HHOOK g_keyboard = NULL; static HHOOK g_mouse = NULL; static HHOOK g_cbt = NULL; static HHOOK g_getMessage = NULL; +static HANDLE g_keyHookThread = NULL; +static DWORD g_keyHookThreadID = 0; +static HANDLE g_keyHookEvent = NULL; +static HHOOK g_keyboardLL = NULL; static bool g_relay = false; static SInt32 g_zoneSize = 0; static UInt32 g_zoneSides = 0; @@ -103,7 +107,9 @@ static LRESULT CALLBACK keyboardHook(int code, WPARAM wParam, LPARAM lParam) case VK_CAPITAL: case VK_NUMLOCK: case VK_SCROLL: - // pass event + // pass event on. we want to let these through to + // the window proc because otherwise the keyboard + // lights may not stay synchronized. break; default: @@ -250,6 +256,119 @@ static LRESULT CALLBACK getMessageHook(int code, WPARAM wParam, LPARAM lParam) return CallNextHookEx(g_getMessage, code, wParam, lParam); } +#if (_WIN32_WINNT >= 0x0400) + +// +// low-level keyboard hook -- this allows us to capture and handle +// alt+tab, alt+esc, ctrl+esc, and windows key hot keys. on the down +// side, key repeats are not compressed for us. +// + +static LRESULT CALLBACK keyboardLLHook(int code, WPARAM wParam, LPARAM lParam) +{ + if (code >= 0) { + if (g_relay) { + KBDLLHOOKSTRUCT* info = reinterpret_cast(lParam); + + // let certain keys pass through + switch (info->vkCode) { + case VK_CAPITAL: + case VK_NUMLOCK: + case VK_SCROLL: + // pass event on. we want to let these through to + // the window proc because otherwise the keyboard + // lights may not stay synchronized. + break; + + default: + // construct lParam for WM_KEYDOWN, etc. + DWORD lParam = 1; // repeat code + lParam |= (info->scanCode << 16); // scan code + if (info->flags & LLKHF_EXTENDED) { + lParam |= (1lu << 24); // extended key + } + if (info->flags & LLKHF_ALTDOWN) { + lParam |= (1lu << 29); // context code + } + if (info->flags & LLKHF_UP) { + lParam |= (1lu << 31); // transition + } + // FIXME -- bit 30 should be set if key was already down + + // forward message to our window + PostMessage(g_hwnd, SYNERGY_MSG_KEY, info->vkCode, lParam); + + // discard event + return 1; + } + } + } + + return CallNextHookEx(g_keyboardLL, code, wParam, lParam); +} + +static DWORD WINAPI getKeyboardLLProc(void*) +{ + // thread proc for low-level keyboard hook. this does nothing but + // install the hook, process events, and uninstall the hook. + + // force this thread to have a message queue + MSG msg; + PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); + + // install low-level keyboard hook + g_keyboardLL = SetWindowsHookEx(WH_KEYBOARD_LL, + &keyboardLLHook, + g_hinstance, + 0); + if (g_keyboardLL == NULL) { + // indicate failure and exit + g_keyHookThreadID = 0; + SetEvent(g_keyHookEvent); + return 1; + } + + // ready + SetEvent(g_keyHookEvent); + + // message loop + bool done = false; + while (!done) { + switch (GetMessage(&msg, NULL, 0, 0)) { + case -1: + break; + + case 0: + done = true; + break; + + default: + TranslateMessage(&msg); + DispatchMessage(&msg); + break; + } + } + + // uninstall hook + UnhookWindowsHookEx(g_keyboardLL); + g_keyboardLL = NULL; + + return 0; +} + +#else // (_WIN32_WINNT < 0x0400) + +#error foo + +static DWORD WINAPI getKeyboardLLProc(void*) +{ + g_keyHookThreadID = 0; + SetEvent(g_keyHookEvent); + return 1; +} + +#endif + static EWheelSupport GetWheelSupport() { // get operating system @@ -286,8 +405,8 @@ static EWheelSupport GetWheelSupport() // assume modern. we don't do anything special in this case // except respond to WM_MOUSEWHEEL messages. GetSystemMetrics() // can apparently return FALSE even if a mouse wheel is present - // though i'm not sure exactly when it does that (but WinME does - // for my logitech usb trackball). + // though i'm not sure exactly when it does that (WinME returns + // FALSE for my logitech USB trackball). return kWheelModern; } @@ -387,6 +506,34 @@ int install(HWND hwnd) // ignore failure; we just won't get mouse wheel messages } + // install low-level keyboard hook, if possible. since this hook + // is called in the context of the installing thread and that + // thread must have a message loop but we don't want the caller's + // message loop to do the work, we'll fire up a separate thread + // just for the hook. note that low-level keyboard hooks are only + // available on windows NT SP3 and above. + g_keyHookEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + if (g_keyHookEvent != NULL) { + g_keyHookThread = CreateThread(NULL, 0, &getKeyboardLLProc, 0, + CREATE_SUSPENDED, &g_keyHookThreadID); + if (g_keyHookThread != NULL) { + // start the thread and wait for it to initialize + ResumeThread(g_keyHookThread); + WaitForSingleObject(g_keyHookEvent, INFINITE); + ResetEvent(g_keyHookEvent); + + // the thread clears g_keyHookThreadID if it failed + if (g_keyHookThreadID == 0) { + CloseHandle(g_keyHookThread); + g_keyHookThread = NULL; + } + } + if (g_keyHookThread == NULL) { + CloseHandle(g_keyHookEvent); + g_keyHookEvent = NULL; + } + } + return 1; } @@ -397,6 +544,15 @@ int uninstall(void) assert(g_cbt != NULL); // uninstall hooks + if (g_keyHookThread != NULL) { + PostThreadMessage(g_keyHookThreadID, WM_QUIT, 0, 0); + WaitForSingleObject(g_keyHookThread, INFINITE); + CloseHandle(g_keyHookEvent); + CloseHandle(g_keyHookThread); + g_keyHookEvent = NULL; + g_keyHookThread = NULL; + g_keyHookThreadID = 0; + } UnhookWindowsHookEx(g_keyboard); UnhookWindowsHookEx(g_mouse); UnhookWindowsHookEx(g_cbt); diff --git a/server/CXWindowsPrimaryScreen.cpp b/server/CXWindowsPrimaryScreen.cpp index 2ba6cfee..9d5a828b 100644 --- a/server/CXWindowsPrimaryScreen.cpp +++ b/server/CXWindowsPrimaryScreen.cpp @@ -303,6 +303,11 @@ void CXWindowsPrimaryScreen::leave() m_active = true; } +void CXWindowsPrimaryScreen::onConfigure() +{ + // do nothing +} + void CXWindowsPrimaryScreen::warpCursor(SInt32 x, SInt32 y) { CDisplayLock display(this); diff --git a/server/CXWindowsPrimaryScreen.h b/server/CXWindowsPrimaryScreen.h index e57f00b4..05c53a30 100644 --- a/server/CXWindowsPrimaryScreen.h +++ b/server/CXWindowsPrimaryScreen.h @@ -18,6 +18,7 @@ public: virtual void close(); virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute); virtual void leave(); + virtual void onConfigure(); virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute); virtual void setClipboard(ClipboardID, const IClipboard*); virtual void grabClipboard(ClipboardID); diff --git a/server/server.cpp b/server/server.cpp index e2b1ffdb..56a15d0c 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -4,7 +4,8 @@ #include "CMutex.h" #include "CNetwork.h" #include "CThread.h" -#include +#include "stdfstream.h" +#include // // config file stuff @@ -54,7 +55,7 @@ void realMain() CConfig config; { log((CLOG_DEBUG "opening configuration")); - ifstream configStream(s_configFileName); + std::ifstream configStream(s_configFileName); if (!configStream) { throw XConfigRead("cannot open configuration"); } diff --git a/server/server.dsp b/server/server.dsp index db189bee..9f201f65 100644 --- a/server/server.dsp +++ b/server/server.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c +# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /I "..\http" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -68,7 +68,7 @@ LINK32=link.exe # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c +# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /I "..\synergy" /I "..\http" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -92,11 +92,15 @@ LINK32=link.exe # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File -SOURCE=.\CMSWindowsPrimaryScreen.cpp +SOURCE=.\CConfig.cpp # End Source File # Begin Source File -SOURCE=.\CConfig.cpp +SOURCE=.\CHTTPServer.cpp +# End Source File +# Begin Source File + +SOURCE=.\CMSWindowsPrimaryScreen.cpp # End Source File # Begin Source File @@ -124,11 +128,15 @@ SOURCE=.\server.rc # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File -SOURCE=.\CMSWindowsPrimaryScreen.h +SOURCE=.\CConfig.h # End Source File # Begin Source File -SOURCE=.\CConfig.h +SOURCE=.\CHTTPServer.h +# End Source File +# Begin Source File + +SOURCE=.\CMSWindowsPrimaryScreen.h # End Source File # Begin Source File diff --git a/server/synrgyhk.dsp b/server/synrgyhk.dsp index d3c6c9b5..784e00a8 100644 --- a/server/synrgyhk.dsp +++ b/server/synrgyhk.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Intermediate_Dir "ReleaseHook" # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /FD /c +# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -68,7 +68,7 @@ LINK32=link.exe # PROP Intermediate_Dir "DebugHook" # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /FD /GZ /c +# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -93,6 +93,7 @@ LINK32=link.exe # Begin Source File SOURCE=.\CSynergyHook.cpp +# ADD CPP /D _WIN32_WINNT=0x0400 # End Source File # End Group # Begin Group "Header Files" diff --git a/synergy.dsw b/synergy.dsw index 4e67cce8..1d70ed66 100644 --- a/synergy.dsw +++ b/synergy.dsw @@ -7,10 +7,6 @@ Project: "all"=.\all.dsp - Package Owner=<4> Package=<5> {{{ - begin source code control - millpond - . - end source code control }}} Package=<4> @@ -29,10 +25,6 @@ Project: "base"=.\base\base.dsp - Package Owner=<4> Package=<5> {{{ - begin source code control - millpond - .\base - end source code control }}} Package=<4> @@ -45,10 +37,6 @@ Project: "client"=.\client\client.dsp - Package Owner=<4> Package=<5> {{{ - begin source code control - millpond - .\client - end source code control }}} Package=<4> @@ -72,14 +60,22 @@ Package=<4> ############################################################################### +Project: "http"=.\HTTP\http.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Project: "io"=.\io\io.dsp - Package Owner=<4> Package=<5> {{{ - begin source code control - millpond - .\io - end source code control }}} Package=<4> @@ -92,10 +88,6 @@ Project: "makehook"=.\server\makehook.dsp - Package Owner=<4> Package=<5> {{{ - begin source code control - millpond - .\server - end source code control }}} Package=<4> @@ -111,10 +103,6 @@ Project: "mt"=.\mt\mt.dsp - Package Owner=<4> Package=<5> {{{ - begin source code control - millpond - .\mt - end source code control }}} Package=<4> @@ -127,10 +115,6 @@ Project: "net"=.\net\net.dsp - Package Owner=<4> Package=<5> {{{ - begin source code control - millpond - .\net - end source code control }}} Package=<4> @@ -143,10 +127,6 @@ Project: "server"=.\server\server.dsp - Package Owner=<4> Package=<5> {{{ - begin source code control - millpond - .\server - end source code control }}} Package=<4> @@ -169,6 +149,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name makehook End Project Dependency + Begin Project Dependency + Project_Dep_Name http + End Project Dependency }}} ############################################################################### @@ -177,10 +160,6 @@ Project: "synergy"=.\synergy\synergy.dsp - Package Owner=<4> Package=<5> {{{ - begin source code control - millpond - .\synergy - end source code control }}} Package=<4> @@ -193,10 +172,6 @@ Project: "synrgyhk"=.\server\synrgyhk.dsp - Package Owner=<4> Package=<5> {{{ - begin source code control - millpond - .\server - end source code control }}} Package=<4> diff --git a/synergy/CXWindowsClipboard.h b/synergy/CXWindowsClipboard.h index bb0fde8e..3cc4b3b9 100644 --- a/synergy/CXWindowsClipboard.h +++ b/synergy/CXWindowsClipboard.h @@ -4,9 +4,9 @@ #include "IClipboard.h" #include "ClipboardTypes.h" #include "CString.h" +#include "stdmap.h" +#include "stdlist.h" #include -#include -#include class CXWindowsClipboard : public IClipboard { public: diff --git a/synergy/IPrimaryScreen.h b/synergy/IPrimaryScreen.h index 4390addc..464d85af 100644 --- a/synergy/IPrimaryScreen.h +++ b/synergy/IPrimaryScreen.h @@ -49,6 +49,11 @@ public: // the cursor and grab exclusive access to the input devices. virtual void leave() = 0; + // called when the configuration has changed. subclasses may need + // to adjust things (like the jump zones) after the configuration + // changes. + virtual void onConfigure() = 0; + // warp the cursor to the given position virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute) = 0; diff --git a/synergy/synergy.dsp b/synergy/synergy.dsp index 91f325ee..a14a9587 100644 --- a/synergy/synergy.dsp +++ b/synergy/synergy.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c +# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -65,7 +65,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c +# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\base" /I "..\io" /I "..\mt" /I "..\net" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG"