Changed log() and logc() macros to LOG() and LOGC(), respectively.
This avoids a conflict with the standard math library log() function.
This commit is contained in:
parent
9e7b411f78
commit
d8dde48c2b
|
@ -196,7 +196,7 @@ realMain(CMutex* mutex)
|
||||||
#undef FINALLY
|
#undef FINALLY
|
||||||
}
|
}
|
||||||
catch (XBase& e) {
|
catch (XBase& e) {
|
||||||
log((CLOG_CRIT "failed: %s", e.what()));
|
LOG((CLOG_CRIT "failed: %s", e.what()));
|
||||||
}
|
}
|
||||||
catch (XThread&) {
|
catch (XThread&) {
|
||||||
// terminated
|
// terminated
|
||||||
|
@ -230,7 +230,7 @@ static
|
||||||
void
|
void
|
||||||
version()
|
version()
|
||||||
{
|
{
|
||||||
log((CLOG_PRINT
|
LOG((CLOG_PRINT
|
||||||
"%s %s, protocol version %d.%d\n"
|
"%s %s, protocol version %d.%d\n"
|
||||||
"%s",
|
"%s",
|
||||||
pname,
|
pname,
|
||||||
|
@ -244,7 +244,7 @@ static
|
||||||
void
|
void
|
||||||
help()
|
help()
|
||||||
{
|
{
|
||||||
log((CLOG_PRINT
|
LOG((CLOG_PRINT
|
||||||
"Usage: %s"
|
"Usage: %s"
|
||||||
" [--camp|--no-camp]"
|
" [--camp|--no-camp]"
|
||||||
" [--daemon|--no-daemon]"
|
" [--daemon|--no-daemon]"
|
||||||
|
@ -293,7 +293,7 @@ isArg(int argi, int argc, const char** argv,
|
||||||
(name2 != NULL && strcmp(argv[argi], name2) == 0)) {
|
(name2 != NULL && strcmp(argv[argi], name2) == 0)) {
|
||||||
// match. check args left.
|
// match. check args left.
|
||||||
if (argi + minRequiredParameters >= argc) {
|
if (argi + minRequiredParameters >= argc) {
|
||||||
log((CLOG_PRINT "%s: missing arguments for `%s'" BYE,
|
LOG((CLOG_PRINT "%s: missing arguments for `%s'" BYE,
|
||||||
pname, argv[argi], pname));
|
pname, argv[argi], pname));
|
||||||
bye(kExitArgs);
|
bye(kExitArgs);
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ parse(int argc, const char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (argv[i][0] == '-') {
|
else if (argv[i][0] == '-') {
|
||||||
log((CLOG_PRINT "%s: unrecognized option `%s'" BYE,
|
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE,
|
||||||
pname, argv[i], pname));
|
pname, argv[i], pname));
|
||||||
bye(kExitArgs);
|
bye(kExitArgs);
|
||||||
}
|
}
|
||||||
|
@ -395,12 +395,12 @@ parse(int argc, const char** argv)
|
||||||
|
|
||||||
// exactly one non-option argument (server-address)
|
// exactly one non-option argument (server-address)
|
||||||
if (i == argc) {
|
if (i == argc) {
|
||||||
log((CLOG_PRINT "%s: a server address or name is required" BYE,
|
LOG((CLOG_PRINT "%s: a server address or name is required" BYE,
|
||||||
pname, pname));
|
pname, pname));
|
||||||
bye(kExitArgs);
|
bye(kExitArgs);
|
||||||
}
|
}
|
||||||
if (i + 1 != argc) {
|
if (i + 1 != argc) {
|
||||||
log((CLOG_PRINT "%s: unrecognized option `%s'" BYE,
|
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE,
|
||||||
pname, argv[i], pname));
|
pname, argv[i], pname));
|
||||||
bye(kExitArgs);
|
bye(kExitArgs);
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,7 @@ parse(int argc, const char** argv)
|
||||||
s_serverAddress = CNetworkAddress(argv[i], kDefaultPort);
|
s_serverAddress = CNetworkAddress(argv[i], kDefaultPort);
|
||||||
}
|
}
|
||||||
catch (XSocketAddress& e) {
|
catch (XSocketAddress& e) {
|
||||||
log((CLOG_PRINT "%s: %s" BYE,
|
LOG((CLOG_PRINT "%s: %s" BYE,
|
||||||
pname, e.what(), pname));
|
pname, e.what(), pname));
|
||||||
bye(kExitFailed);
|
bye(kExitFailed);
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ parse(int argc, const char** argv)
|
||||||
|
|
||||||
// set log filter
|
// set log filter
|
||||||
if (!CLog::setFilter(s_logFilter)) {
|
if (!CLog::setFilter(s_logFilter)) {
|
||||||
log((CLOG_PRINT "%s: unrecognized log level `%s'" BYE,
|
LOG((CLOG_PRINT "%s: unrecognized log level `%s'" BYE,
|
||||||
pname, s_logFilter, pname));
|
pname, s_logFilter, pname));
|
||||||
bye(kExitArgs);
|
bye(kExitArgs);
|
||||||
}
|
}
|
||||||
|
@ -537,7 +537,7 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
|
||||||
if (__argc <= 1 && !CWin32Platform::isWindows95Family()) {
|
if (__argc <= 1 && !CWin32Platform::isWindows95Family()) {
|
||||||
int result = platform.daemonize(DAEMON_NAME, &daemonStartup);
|
int result = platform.daemonize(DAEMON_NAME, &daemonStartup);
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
log((CLOG_CRIT "failed to start as a service" BYE, pname));
|
LOG((CLOG_CRIT "failed to start as a service" BYE, pname));
|
||||||
return kExitFailed;
|
return kExitFailed;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -556,7 +556,7 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
|
||||||
if (CWin32Platform::isWindows95Family()) {
|
if (CWin32Platform::isWindows95Family()) {
|
||||||
result = platform.daemonize(DAEMON_NAME, &daemonStartup95);
|
result = platform.daemonize(DAEMON_NAME, &daemonStartup95);
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
log((CLOG_CRIT "failed to start as a service" BYE, pname));
|
LOG((CLOG_CRIT "failed to start as a service" BYE, pname));
|
||||||
result = kExitFailed;
|
result = kExitFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -613,7 +613,7 @@ main(int argc, char** argv)
|
||||||
if (s_daemon) {
|
if (s_daemon) {
|
||||||
result = platform.daemonize(DAEMON_NAME, &daemonStartup);
|
result = platform.daemonize(DAEMON_NAME, &daemonStartup);
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
log((CLOG_CRIT "failed to daemonize"));
|
LOG((CLOG_CRIT "failed to daemonize"));
|
||||||
return kExitFailed;
|
return kExitFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,7 @@ realMain(CMutex* mutex)
|
||||||
#undef FINALLY
|
#undef FINALLY
|
||||||
}
|
}
|
||||||
catch (XBase& e) {
|
catch (XBase& e) {
|
||||||
log((CLOG_CRIT "failed: %s", e.what()));
|
LOG((CLOG_CRIT "failed: %s", e.what()));
|
||||||
}
|
}
|
||||||
catch (XThread&) {
|
catch (XThread&) {
|
||||||
// terminated
|
// terminated
|
||||||
|
@ -254,7 +254,7 @@ static
|
||||||
void
|
void
|
||||||
version()
|
version()
|
||||||
{
|
{
|
||||||
log((CLOG_PRINT
|
LOG((CLOG_PRINT
|
||||||
"%s %s, protocol version %d.%d\n"
|
"%s %s, protocol version %d.%d\n"
|
||||||
"%s",
|
"%s",
|
||||||
pname,
|
pname,
|
||||||
|
@ -289,7 +289,7 @@ help()
|
||||||
|
|
||||||
CPlatform platform;
|
CPlatform platform;
|
||||||
|
|
||||||
log((CLOG_PRINT
|
LOG((CLOG_PRINT
|
||||||
"Usage: %s"
|
"Usage: %s"
|
||||||
" [--address <address>]"
|
" [--address <address>]"
|
||||||
" [--config <pathname>]"
|
" [--config <pathname>]"
|
||||||
|
@ -353,7 +353,7 @@ isArg(int argi, int argc, const char** argv,
|
||||||
(name2 != NULL && strcmp(argv[argi], name2) == 0)) {
|
(name2 != NULL && strcmp(argv[argi], name2) == 0)) {
|
||||||
// match. check args left.
|
// match. check args left.
|
||||||
if (argi + minRequiredParameters >= argc) {
|
if (argi + minRequiredParameters >= argc) {
|
||||||
log((CLOG_PRINT "%s: missing arguments for `%s'" BYE,
|
LOG((CLOG_PRINT "%s: missing arguments for `%s'" BYE,
|
||||||
pname, argv[argi], pname));
|
pname, argv[argi], pname));
|
||||||
bye(kExitArgs);
|
bye(kExitArgs);
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ parse(int argc, const char** argv)
|
||||||
s_synergyAddress = CNetworkAddress(argv[i + 1], kDefaultPort);
|
s_synergyAddress = CNetworkAddress(argv[i + 1], kDefaultPort);
|
||||||
}
|
}
|
||||||
catch (XSocketAddress& e) {
|
catch (XSocketAddress& e) {
|
||||||
log((CLOG_PRINT "%s: %s" BYE,
|
LOG((CLOG_PRINT "%s: %s" BYE,
|
||||||
pname, e.what(), pname));
|
pname, e.what(), pname));
|
||||||
bye(kExitArgs);
|
bye(kExitArgs);
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,7 @@ parse(int argc, const char** argv)
|
||||||
s_httpAddress = CNetworkAddress(argv[i + 1], kDefaultPort + 1);
|
s_httpAddress = CNetworkAddress(argv[i + 1], kDefaultPort + 1);
|
||||||
}
|
}
|
||||||
catch (XSocketAddress& e) {
|
catch (XSocketAddress& e) {
|
||||||
log((CLOG_PRINT "%s: %s" BYE,
|
LOG((CLOG_PRINT "%s: %s" BYE,
|
||||||
pname, e.what(), pname));
|
pname, e.what(), pname));
|
||||||
bye(kExitArgs);
|
bye(kExitArgs);
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ parse(int argc, const char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (argv[i][0] == '-') {
|
else if (argv[i][0] == '-') {
|
||||||
log((CLOG_PRINT "%s: unrecognized option `%s'" BYE,
|
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE,
|
||||||
pname, argv[i], pname));
|
pname, argv[i], pname));
|
||||||
bye(kExitArgs);
|
bye(kExitArgs);
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,7 @@ parse(int argc, const char** argv)
|
||||||
|
|
||||||
// no non-option arguments are allowed
|
// no non-option arguments are allowed
|
||||||
if (i != argc) {
|
if (i != argc) {
|
||||||
log((CLOG_PRINT "%s: unrecognized option `%s'" BYE,
|
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE,
|
||||||
pname, argv[i], pname));
|
pname, argv[i], pname));
|
||||||
bye(kExitArgs);
|
bye(kExitArgs);
|
||||||
}
|
}
|
||||||
|
@ -499,7 +499,7 @@ parse(int argc, const char** argv)
|
||||||
|
|
||||||
// set log filter
|
// set log filter
|
||||||
if (!CLog::setFilter(s_logFilter)) {
|
if (!CLog::setFilter(s_logFilter)) {
|
||||||
log((CLOG_PRINT "%s: unrecognized log level `%s'" BYE,
|
LOG((CLOG_PRINT "%s: unrecognized log level `%s'" BYE,
|
||||||
pname, s_logFilter, pname));
|
pname, s_logFilter, pname));
|
||||||
bye(kExitArgs);
|
bye(kExitArgs);
|
||||||
}
|
}
|
||||||
|
@ -513,23 +513,23 @@ loadConfig(const char* pathname, bool require)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// load configuration
|
// load configuration
|
||||||
log((CLOG_DEBUG "opening configuration \"%s\"", pathname));
|
LOG((CLOG_DEBUG "opening configuration \"%s\"", pathname));
|
||||||
std::ifstream configStream(pathname);
|
std::ifstream configStream(pathname);
|
||||||
if (!configStream) {
|
if (!configStream) {
|
||||||
throw XConfigRead("cannot open configuration");
|
throw XConfigRead("cannot open configuration");
|
||||||
}
|
}
|
||||||
configStream >> s_config;
|
configStream >> s_config;
|
||||||
log((CLOG_DEBUG "configuration read successfully"));
|
LOG((CLOG_DEBUG "configuration read successfully"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (XConfigRead& e) {
|
catch (XConfigRead& e) {
|
||||||
if (require) {
|
if (require) {
|
||||||
log((CLOG_PRINT "%s: cannot read configuration '%s': %s",
|
LOG((CLOG_PRINT "%s: cannot read configuration '%s': %s",
|
||||||
pname, pathname, e.what()));
|
pname, pathname, e.what()));
|
||||||
bye(kExitConfig);
|
bye(kExitConfig);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log((CLOG_DEBUG "cannot read configuration \"%s\": %s",
|
LOG((CLOG_DEBUG "cannot read configuration \"%s\": %s",
|
||||||
pathname, e.what()));
|
pathname, e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -672,7 +672,7 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
|
||||||
if (__argc <= 1 && !CWin32Platform::isWindows95Family()) {
|
if (__argc <= 1 && !CWin32Platform::isWindows95Family()) {
|
||||||
int result = platform.daemonize(DAEMON_NAME, &daemonStartup);
|
int result = platform.daemonize(DAEMON_NAME, &daemonStartup);
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
log((CLOG_CRIT "failed to start as a service" BYE, pname));
|
LOG((CLOG_CRIT "failed to start as a service" BYE, pname));
|
||||||
return kExitFailed;
|
return kExitFailed;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -694,7 +694,7 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
|
||||||
if (CWin32Platform::isWindows95Family()) {
|
if (CWin32Platform::isWindows95Family()) {
|
||||||
result = platform.daemonize(DAEMON_NAME, &daemonStartup95);
|
result = platform.daemonize(DAEMON_NAME, &daemonStartup95);
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
log((CLOG_CRIT "failed to start as a service" BYE, pname));
|
LOG((CLOG_CRIT "failed to start as a service" BYE, pname));
|
||||||
result = kExitFailed;
|
result = kExitFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -754,7 +754,7 @@ main(int argc, char** argv)
|
||||||
if (s_daemon) {
|
if (s_daemon) {
|
||||||
result = platform.daemonize(DAEMON_NAME, &daemonStartup);
|
result = platform.daemonize(DAEMON_NAME, &daemonStartup);
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
log((CLOG_CRIT "failed to daemonize"));
|
LOG((CLOG_CRIT "failed to daemonize"));
|
||||||
return kExitFailed;
|
return kExitFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
/*!
|
/*!
|
||||||
The logging class; all console output should go through this class.
|
The logging class; all console output should go through this class.
|
||||||
It supports multithread safe operation, several message priority levels,
|
It supports multithread safe operation, several message priority levels,
|
||||||
filtering by priority, and output redirection. The macros log() and
|
filtering by priority, and output redirection. The macros LOG() and
|
||||||
clog() provide convenient access.
|
LOGC() provide convenient access.
|
||||||
*/
|
*/
|
||||||
class CLog {
|
class CLog {
|
||||||
public:
|
public:
|
||||||
|
@ -150,11 +150,11 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\def log(arg)
|
\def LOG(arg)
|
||||||
Write to the log. Because macros cannot accept variable arguments, this
|
Write to the log. Because macros cannot accept variable arguments, this
|
||||||
should be invoked like so:
|
should be invoked like so:
|
||||||
\code
|
\code
|
||||||
log((CLOG_XXX "%d and %d are %s", x, y, x == y ? "equal" : "not equal"));
|
LOG((CLOG_XXX "%d and %d are %s", x, y, x == y ? "equal" : "not equal"));
|
||||||
\endcode
|
\endcode
|
||||||
In particular, notice the double open and close parentheses. Also note
|
In particular, notice the double open and close parentheses. Also note
|
||||||
that there is no comma after the \c CLOG_XXX. The \c XXX should be
|
that there is no comma after the \c CLOG_XXX. The \c XXX should be
|
||||||
|
@ -169,11 +169,11 @@ which includes the filename and line number.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\def logc(expr, arg)
|
\def LOGC(expr, arg)
|
||||||
Write to the log if and only if expr is true. Because macros cannot accept
|
Write to the log if and only if expr is true. Because macros cannot accept
|
||||||
variable arguments, this should be invoked like so:
|
variable arguments, this should be invoked like so:
|
||||||
\code
|
\code
|
||||||
clog(x == y, (CLOG_XXX "%d and %d are equal", x, y));
|
LOGC(x == y, (CLOG_XXX "%d and %d are equal", x, y));
|
||||||
\endcode
|
\endcode
|
||||||
In particular, notice the parentheses around everything after the boolean
|
In particular, notice the parentheses around everything after the boolean
|
||||||
expression. Also note that there is no comma after the \c CLOG_XXX.
|
expression. Also note that there is no comma after the \c CLOG_XXX.
|
||||||
|
@ -189,16 +189,16 @@ which includes the filename and line number.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(NOLOGGING)
|
#if defined(NOLOGGING)
|
||||||
#define log(_a1)
|
#define LOG(_a1)
|
||||||
#define logc(_a1, _a2)
|
#define LOGC(_a1, _a2)
|
||||||
#define CLOG_TRACE
|
#define CLOG_TRACE
|
||||||
#elif defined(NDEBUG)
|
#elif defined(NDEBUG)
|
||||||
#define log(_a1) CLog::print _a1
|
#define LOG(_a1) CLog::print _a1
|
||||||
#define logc(_a1, _a2) if (_a1) CLog::print _a2
|
#define LOGC(_a1, _a2) if (_a1) CLog::print _a2
|
||||||
#define CLOG_TRACE
|
#define CLOG_TRACE
|
||||||
#else
|
#else
|
||||||
#define log(_a1) CLog::printt _a1
|
#define LOG(_a1) CLog::printt _a1
|
||||||
#define logc(_a1, _a2) if (_a1) CLog::printt _a2
|
#define LOGC(_a1, _a2) if (_a1) CLog::printt _a2
|
||||||
#define CLOG_TRACE __FILE__, __LINE__,
|
#define CLOG_TRACE __FILE__, __LINE__,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ CClient::onError()
|
||||||
void
|
void
|
||||||
CClient::onInfoChanged(const CClientInfo& info)
|
CClient::onInfoChanged(const CClientInfo& info)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "resolution changed"));
|
LOG((CLOG_DEBUG "resolution changed"));
|
||||||
|
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
if (m_server != NULL) {
|
if (m_server != NULL) {
|
||||||
|
@ -168,12 +168,12 @@ CClient::open()
|
||||||
{
|
{
|
||||||
// open the screen
|
// open the screen
|
||||||
try {
|
try {
|
||||||
log((CLOG_INFO "opening screen"));
|
LOG((CLOG_INFO "opening screen"));
|
||||||
openSecondaryScreen();
|
openSecondaryScreen();
|
||||||
}
|
}
|
||||||
catch (XScreenOpenFailure&) {
|
catch (XScreenOpenFailure&) {
|
||||||
// can't open screen
|
// can't open screen
|
||||||
log((CLOG_INFO "failed to open screen"));
|
LOG((CLOG_INFO "failed to open screen"));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ CClient::mainLoop()
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log((CLOG_NOTE "starting client \"%s\"", m_name.c_str()));
|
LOG((CLOG_NOTE "starting client \"%s\"", m_name.c_str()));
|
||||||
|
|
||||||
// start server interactions
|
// start server interactions
|
||||||
{
|
{
|
||||||
|
@ -207,29 +207,29 @@ CClient::mainLoop()
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
deleteSession();
|
deleteSession();
|
||||||
log((CLOG_NOTE "stopping client \"%s\"", m_name.c_str()));
|
LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str()));
|
||||||
}
|
}
|
||||||
catch (XBase& e) {
|
catch (XBase& e) {
|
||||||
log((CLOG_ERR "client error: %s", e.what()));
|
LOG((CLOG_ERR "client error: %s", e.what()));
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
deleteSession();
|
deleteSession();
|
||||||
log((CLOG_NOTE "stopping client \"%s\"", m_name.c_str()));
|
LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str()));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
m_rejected = false;
|
m_rejected = false;
|
||||||
}
|
}
|
||||||
catch (XThread&) {
|
catch (XThread&) {
|
||||||
// clean up
|
// clean up
|
||||||
deleteSession();
|
deleteSession();
|
||||||
log((CLOG_NOTE "stopping client \"%s\"", m_name.c_str()));
|
LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str()));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
log((CLOG_DEBUG "unknown client error"));
|
LOG((CLOG_DEBUG "unknown client error"));
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
deleteSession();
|
deleteSession();
|
||||||
log((CLOG_NOTE "stopping client \"%s\"", m_name.c_str()));
|
LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str()));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ void
|
||||||
CClient::close()
|
CClient::close()
|
||||||
{
|
{
|
||||||
closeSecondaryScreen();
|
closeSecondaryScreen();
|
||||||
log((CLOG_INFO "closed screen"));
|
LOG((CLOG_INFO "closed screen"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -392,7 +392,7 @@ CClient::openSecondaryScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
// create screen
|
// create screen
|
||||||
log((CLOG_DEBUG1 "creating secondary screen"));
|
LOG((CLOG_DEBUG1 "creating secondary screen"));
|
||||||
if (m_screenFactory != NULL) {
|
if (m_screenFactory != NULL) {
|
||||||
m_screen = m_screenFactory->create(this);
|
m_screen = m_screenFactory->create(this);
|
||||||
}
|
}
|
||||||
|
@ -402,11 +402,11 @@ CClient::openSecondaryScreen()
|
||||||
|
|
||||||
// open screen
|
// open screen
|
||||||
try {
|
try {
|
||||||
log((CLOG_DEBUG1 "opening secondary screen"));
|
LOG((CLOG_DEBUG1 "opening secondary screen"));
|
||||||
m_screen->open();
|
m_screen->open();
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
log((CLOG_DEBUG1 "destroying secondary screen"));
|
LOG((CLOG_DEBUG1 "destroying secondary screen"));
|
||||||
delete m_screen;
|
delete m_screen;
|
||||||
m_screen = NULL;
|
m_screen = NULL;
|
||||||
throw;
|
throw;
|
||||||
|
@ -419,7 +419,7 @@ CClient::closeSecondaryScreen()
|
||||||
// close the secondary screen
|
// close the secondary screen
|
||||||
try {
|
try {
|
||||||
if (m_screen != NULL) {
|
if (m_screen != NULL) {
|
||||||
log((CLOG_DEBUG1 "closing secondary screen"));
|
LOG((CLOG_DEBUG1 "closing secondary screen"));
|
||||||
m_screen->close();
|
m_screen->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ CClient::closeSecondaryScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
log((CLOG_DEBUG1 "destroying secondary screen"));
|
LOG((CLOG_DEBUG1 "destroying secondary screen"));
|
||||||
delete m_screen;
|
delete m_screen;
|
||||||
m_screen = NULL;
|
m_screen = NULL;
|
||||||
}
|
}
|
||||||
|
@ -471,14 +471,14 @@ void
|
||||||
CClient::runSession(void*)
|
CClient::runSession(void*)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
log((CLOG_DEBUG "starting server proxy"));
|
LOG((CLOG_DEBUG "starting server proxy"));
|
||||||
runServer();
|
runServer();
|
||||||
m_screen->exitMainLoop();
|
m_screen->exitMainLoop();
|
||||||
log((CLOG_DEBUG "stopping server proxy"));
|
LOG((CLOG_DEBUG "stopping server proxy"));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
m_screen->exitMainLoop();
|
m_screen->exitMainLoop();
|
||||||
log((CLOG_DEBUG "stopping server proxy"));
|
LOG((CLOG_DEBUG "stopping server proxy"));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -514,17 +514,17 @@ CClient::runServer()
|
||||||
CTimerThread timer(15.0);
|
CTimerThread timer(15.0);
|
||||||
|
|
||||||
// create socket and attempt to connect to server
|
// create socket and attempt to connect to server
|
||||||
log((CLOG_DEBUG1 "connecting to server"));
|
LOG((CLOG_DEBUG1 "connecting to server"));
|
||||||
if (m_socketFactory != NULL) {
|
if (m_socketFactory != NULL) {
|
||||||
socket = m_socketFactory->create();
|
socket = m_socketFactory->create();
|
||||||
}
|
}
|
||||||
assert(socket != NULL);
|
assert(socket != NULL);
|
||||||
socket->connect(m_serverAddress);
|
socket->connect(m_serverAddress);
|
||||||
log((CLOG_INFO "connected to server"));
|
LOG((CLOG_INFO "connected to server"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (XSocketConnect& e) {
|
catch (XSocketConnect& e) {
|
||||||
log((CLOG_DEBUG1 "failed to connect to server: %s", e.getErrstr()));
|
LOG((CLOG_DEBUG1 "failed to connect to server: %s", e.getErrstr()));
|
||||||
|
|
||||||
// failed to connect. if not camping then rethrow.
|
// failed to connect. if not camping then rethrow.
|
||||||
if (!m_camp) {
|
if (!m_camp) {
|
||||||
|
@ -537,25 +537,25 @@ CClient::runServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// create proxy
|
// create proxy
|
||||||
log((CLOG_DEBUG1 "negotiating with server"));
|
LOG((CLOG_DEBUG1 "negotiating with server"));
|
||||||
proxy = handshakeServer(socket);
|
proxy = handshakeServer(socket);
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
m_server = proxy;
|
m_server = proxy;
|
||||||
}
|
}
|
||||||
catch (XThread&) {
|
catch (XThread&) {
|
||||||
log((CLOG_ERR "connection timed out"));
|
LOG((CLOG_ERR "connection timed out"));
|
||||||
delete socket;
|
delete socket;
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch (XBase& e) {
|
catch (XBase& e) {
|
||||||
log((CLOG_ERR "connection failed: %s", e.what()));
|
LOG((CLOG_ERR "connection failed: %s", e.what()));
|
||||||
log((CLOG_DEBUG "disconnecting from server"));
|
LOG((CLOG_DEBUG "disconnecting from server"));
|
||||||
delete socket;
|
delete socket;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
log((CLOG_ERR "connection failed: <unknown error>"));
|
LOG((CLOG_ERR "connection failed: <unknown error>"));
|
||||||
log((CLOG_DEBUG "disconnecting from server"));
|
LOG((CLOG_DEBUG "disconnecting from server"));
|
||||||
delete socket;
|
delete socket;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -564,7 +564,7 @@ CClient::runServer()
|
||||||
// process messages
|
// process messages
|
||||||
bool rejected = true;
|
bool rejected = true;
|
||||||
if (proxy != NULL) {
|
if (proxy != NULL) {
|
||||||
log((CLOG_DEBUG1 "communicating with server"));
|
LOG((CLOG_DEBUG1 "communicating with server"));
|
||||||
rejected = !proxy->mainLoop();
|
rejected = !proxy->mainLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ CClient::runServer()
|
||||||
m_rejected = rejected;
|
m_rejected = rejected;
|
||||||
m_server = NULL;
|
m_server = NULL;
|
||||||
delete proxy;
|
delete proxy;
|
||||||
log((CLOG_DEBUG "disconnecting from server"));
|
LOG((CLOG_DEBUG "disconnecting from server"));
|
||||||
socket->close();
|
socket->close();
|
||||||
delete socket;
|
delete socket;
|
||||||
}
|
}
|
||||||
|
@ -582,7 +582,7 @@ CClient::runServer()
|
||||||
m_rejected = false;
|
m_rejected = false;
|
||||||
m_server = NULL;
|
m_server = NULL;
|
||||||
delete proxy;
|
delete proxy;
|
||||||
log((CLOG_DEBUG "disconnecting from server"));
|
LOG((CLOG_DEBUG "disconnecting from server"));
|
||||||
socket->close();
|
socket->close();
|
||||||
delete socket;
|
delete socket;
|
||||||
throw;
|
throw;
|
||||||
|
@ -615,19 +615,19 @@ CClient::handshakeServer(IDataSocket* socket)
|
||||||
CTimerThread timer(30.0);
|
CTimerThread timer(30.0);
|
||||||
|
|
||||||
// wait for hello from server
|
// wait for hello from server
|
||||||
log((CLOG_DEBUG1 "wait for hello"));
|
LOG((CLOG_DEBUG1 "wait for hello"));
|
||||||
SInt16 major, minor;
|
SInt16 major, minor;
|
||||||
CProtocolUtil::readf(input, kMsgHello, &major, &minor);
|
CProtocolUtil::readf(input, kMsgHello, &major, &minor);
|
||||||
|
|
||||||
// check versions
|
// check versions
|
||||||
log((CLOG_DEBUG1 "got hello version %d.%d", major, minor));
|
LOG((CLOG_DEBUG1 "got hello version %d.%d", major, minor));
|
||||||
if (major < kProtocolMajorVersion ||
|
if (major < kProtocolMajorVersion ||
|
||||||
(major == kProtocolMajorVersion && minor < kProtocolMinorVersion)) {
|
(major == kProtocolMajorVersion && minor < kProtocolMinorVersion)) {
|
||||||
throw XIncompatibleClient(major, minor);
|
throw XIncompatibleClient(major, minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// say hello back
|
// say hello back
|
||||||
log((CLOG_DEBUG1 "say hello version %d.%d", kProtocolMajorVersion, kProtocolMinorVersion));
|
LOG((CLOG_DEBUG1 "say hello version %d.%d", kProtocolMajorVersion, kProtocolMinorVersion));
|
||||||
CProtocolUtil::writef(output, kMsgHelloBack,
|
CProtocolUtil::writef(output, kMsgHelloBack,
|
||||||
kProtocolMajorVersion,
|
kProtocolMajorVersion,
|
||||||
kProtocolMinorVersion, &m_name);
|
kProtocolMinorVersion, &m_name);
|
||||||
|
@ -641,10 +641,10 @@ CClient::handshakeServer(IDataSocket* socket)
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
catch (XIncompatibleClient& e) {
|
catch (XIncompatibleClient& e) {
|
||||||
log((CLOG_ERR "server has incompatible version %d.%d", e.getMajor(), e.getMinor()));
|
LOG((CLOG_ERR "server has incompatible version %d.%d", e.getMajor(), e.getMinor()));
|
||||||
}
|
}
|
||||||
catch (XBase& e) {
|
catch (XBase& e) {
|
||||||
log((CLOG_WARN "error communicating with server: %s", e.what()));
|
LOG((CLOG_WARN "error communicating with server: %s", e.what()));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
// probably timed out
|
// probably timed out
|
||||||
|
|
|
@ -492,7 +492,7 @@ CMSWindowsSecondaryScreen::updateKeys()
|
||||||
m_mask |= KeyModifierScrollLock;
|
m_mask |= KeyModifierScrollLock;
|
||||||
}
|
}
|
||||||
// note -- do not save KeyModifierModeSwitch in m_mask
|
// note -- do not save KeyModifierModeSwitch in m_mask
|
||||||
log((CLOG_DEBUG2 "modifiers on update: 0x%04x", m_mask));
|
LOG((CLOG_DEBUG2 "modifiers on update: 0x%04x", m_mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -625,7 +625,7 @@ CMSWindowsSecondaryScreen::mapKey(Keystrokes& keys, UINT& virtualKey,
|
||||||
virtualKey = g_mapEF00[id & 0xff];
|
virtualKey = g_mapEF00[id & 0xff];
|
||||||
}
|
}
|
||||||
if (virtualKey == 0) {
|
if (virtualKey == 0) {
|
||||||
log((CLOG_DEBUG2 "unknown special key"));
|
LOG((CLOG_DEBUG2 "unknown special key"));
|
||||||
return m_mask;
|
return m_mask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -685,7 +685,7 @@ CMSWindowsSecondaryScreen::mapKey(Keystrokes& keys, UINT& virtualKey,
|
||||||
TCHAR ascii = static_cast<TCHAR>(id & 0x000000ff);
|
TCHAR ascii = static_cast<TCHAR>(id & 0x000000ff);
|
||||||
SHORT vk = VkKeyScan(ascii);
|
SHORT vk = VkKeyScan(ascii);
|
||||||
if (vk == 0xffff) {
|
if (vk == 0xffff) {
|
||||||
log((CLOG_DEBUG2 "no virtual key for character %d", id));
|
LOG((CLOG_DEBUG2 "no virtual key for character %d", id));
|
||||||
return m_mask;
|
return m_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,7 +712,7 @@ CMSWindowsSecondaryScreen::mapKey(Keystrokes& keys, UINT& virtualKey,
|
||||||
// are subject to case conversion.
|
// are subject to case conversion.
|
||||||
if ((outMask & KeyModifierCapsLock) != 0) {
|
if ((outMask & KeyModifierCapsLock) != 0) {
|
||||||
if (tolower(ascii) != toupper(ascii)) {
|
if (tolower(ascii) != toupper(ascii)) {
|
||||||
log((CLOG_DEBUG2 "flip shift"));
|
LOG((CLOG_DEBUG2 "flip shift"));
|
||||||
outMask ^= KeyModifierShift;
|
outMask ^= KeyModifierShift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -734,11 +734,11 @@ CMSWindowsSecondaryScreen::mapKey(Keystrokes& keys, UINT& virtualKey,
|
||||||
// set required shift state based on current numlock state
|
// set required shift state based on current numlock state
|
||||||
if ((outMask & KeyModifierNumLock) == 0) {
|
if ((outMask & KeyModifierNumLock) == 0) {
|
||||||
if ((m_mask & KeyModifierNumLock) == 0) {
|
if ((m_mask & KeyModifierNumLock) == 0) {
|
||||||
log((CLOG_DEBUG2 "turn on num lock for keypad key"));
|
LOG((CLOG_DEBUG2 "turn on num lock for keypad key"));
|
||||||
outMask |= KeyModifierNumLock;
|
outMask |= KeyModifierNumLock;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log((CLOG_DEBUG2 "turn on shift for keypad key"));
|
LOG((CLOG_DEBUG2 "turn on shift for keypad key"));
|
||||||
outMask |= KeyModifierShift;
|
outMask |= KeyModifierShift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -749,7 +749,7 @@ CMSWindowsSecondaryScreen::mapKey(Keystrokes& keys, UINT& virtualKey,
|
||||||
outMask |= KeyModifierShift;
|
outMask |= KeyModifierShift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log((CLOG_DEBUG2 "KeyID %d to virtual key %d mask 0x%04x", id, virtualKey, outMask));
|
LOG((CLOG_DEBUG2 "KeyID %d to virtual key %d mask 0x%04x", id, virtualKey, outMask));
|
||||||
|
|
||||||
// a list of modifier key info
|
// a list of modifier key info
|
||||||
class CModifierInfo {
|
class CModifierInfo {
|
||||||
|
@ -956,7 +956,7 @@ CMSWindowsSecondaryScreen::mapKey(Keystrokes& keys, UINT& virtualKey,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log((CLOG_DEBUG2 "previous modifiers 0x%04x, final modifiers 0x%04x", m_mask, mask));
|
LOG((CLOG_DEBUG2 "previous modifiers 0x%04x, final modifiers 0x%04x", m_mask, mask));
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1145,5 +1145,5 @@ CMSWindowsSecondaryScreen::sendKeyEvent(UINT virtualKey, bool press)
|
||||||
const UINT code = virtualKeyToScanCode(virtualKey);
|
const UINT code = virtualKeyToScanCode(virtualKey);
|
||||||
keybd_event(static_cast<BYTE>(virtualKey & 0xff),
|
keybd_event(static_cast<BYTE>(virtualKey & 0xff),
|
||||||
static_cast<BYTE>(code), flags, 0);
|
static_cast<BYTE>(code), flags, 0);
|
||||||
log((CLOG_DEBUG1 "send key %d, 0x%04x, %s%s", virtualKey & 0xff, code, ((flags & KEYEVENTF_KEYUP) ? "release" : "press"), ((flags & KEYEVENTF_EXTENDEDKEY) ? " extended" : "")));
|
LOG((CLOG_DEBUG1 "send key %d, 0x%04x, %s%s", virtualKey & 0xff, code, ((flags & KEYEVENTF_KEYUP) ? "release" : "press"), ((flags & KEYEVENTF_EXTENDEDKEY) ? " extended" : "")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,15 +40,15 @@ CSecondaryScreen::mainLoop()
|
||||||
|
|
||||||
// run event loop
|
// run event loop
|
||||||
try {
|
try {
|
||||||
log((CLOG_DEBUG "entering event loop"));
|
LOG((CLOG_DEBUG "entering event loop"));
|
||||||
onPreMainLoop();
|
onPreMainLoop();
|
||||||
getScreen()->mainLoop();
|
getScreen()->mainLoop();
|
||||||
onPostMainLoop();
|
onPostMainLoop();
|
||||||
log((CLOG_DEBUG "exiting event loop"));
|
LOG((CLOG_DEBUG "exiting event loop"));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
onPostMainLoop();
|
onPostMainLoop();
|
||||||
log((CLOG_DEBUG "exiting event loop"));
|
LOG((CLOG_DEBUG "exiting event loop"));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ CSecondaryScreen::enter(SInt32 x, SInt32 y, KeyModifierMask mask)
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
assert(m_active == false);
|
assert(m_active == false);
|
||||||
|
|
||||||
log((CLOG_INFO "entering screen at %d,%d mask=%04x", x, y, mask));
|
LOG((CLOG_INFO "entering screen at %d,%d mask=%04x", x, y, mask));
|
||||||
|
|
||||||
getScreen()->syncDesktop();
|
getScreen()->syncDesktop();
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ CSecondaryScreen::enter(SInt32 x, SInt32 y, KeyModifierMask mask)
|
||||||
void
|
void
|
||||||
CSecondaryScreen::leave()
|
CSecondaryScreen::leave()
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "leaving screen"));
|
LOG((CLOG_INFO "leaving screen"));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
assert(m_active == true);
|
assert(m_active == true);
|
||||||
|
|
||||||
|
|
|
@ -69,13 +69,13 @@ CServerProxy::mainLoop()
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for a message
|
// wait for a message
|
||||||
log((CLOG_DEBUG2 "waiting for message"));
|
LOG((CLOG_DEBUG2 "waiting for message"));
|
||||||
UInt8 code[4];
|
UInt8 code[4];
|
||||||
UInt32 n = getInputStream()->read(code, 4, kHeartRate);
|
UInt32 n = getInputStream()->read(code, 4, kHeartRate);
|
||||||
|
|
||||||
// check if server hungup
|
// check if server hungup
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
log((CLOG_NOTE "server disconnected"));
|
LOG((CLOG_NOTE "server disconnected"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,12 +95,12 @@ CServerProxy::mainLoop()
|
||||||
// verify we got an entire code
|
// verify we got an entire code
|
||||||
if (n != 4) {
|
if (n != 4) {
|
||||||
// client sent an incomplete message
|
// client sent an incomplete message
|
||||||
log((CLOG_ERR "incomplete message from server"));
|
LOG((CLOG_ERR "incomplete message from server"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse message
|
// parse message
|
||||||
log((CLOG_DEBUG2 "msg from server: %c%c%c%c", code[0], code[1], code[2], code[3]));
|
LOG((CLOG_DEBUG2 "msg from server: %c%c%c%c", code[0], code[1], code[2], code[3]));
|
||||||
if (memcmp(code, kMsgDMouseMove, 4) == 0) {
|
if (memcmp(code, kMsgDMouseMove, 4) == 0) {
|
||||||
mouseMove();
|
mouseMove();
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ CServerProxy::mainLoop()
|
||||||
|
|
||||||
else if (memcmp(code, kMsgCClose, 4) == 0) {
|
else if (memcmp(code, kMsgCClose, 4) == 0) {
|
||||||
// server wants us to hangup
|
// server wants us to hangup
|
||||||
log((CLOG_DEBUG1 "recv close"));
|
LOG((CLOG_DEBUG1 "recv close"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,39 +171,39 @@ CServerProxy::mainLoop()
|
||||||
SInt32 major, minor;
|
SInt32 major, minor;
|
||||||
CProtocolUtil::readf(getInputStream(),
|
CProtocolUtil::readf(getInputStream(),
|
||||||
kMsgEIncompatible + 4, &major, &minor);
|
kMsgEIncompatible + 4, &major, &minor);
|
||||||
log((CLOG_ERR "server has incompatible version %d.%d", major, minor));
|
LOG((CLOG_ERR "server has incompatible version %d.%d", major, minor));
|
||||||
failedToConnect = true;
|
failedToConnect = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (memcmp(code, kMsgEBusy, 4) == 0) {
|
else if (memcmp(code, kMsgEBusy, 4) == 0) {
|
||||||
log((CLOG_ERR "server already has a connected client with name \"%s\"", getName().c_str()));
|
LOG((CLOG_ERR "server already has a connected client with name \"%s\"", getName().c_str()));
|
||||||
failedToConnect = true;
|
failedToConnect = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (memcmp(code, kMsgEUnknown, 4) == 0) {
|
else if (memcmp(code, kMsgEUnknown, 4) == 0) {
|
||||||
log((CLOG_ERR "server refused client with name \"%s\"", getName().c_str()));
|
LOG((CLOG_ERR "server refused client with name \"%s\"", getName().c_str()));
|
||||||
failedToConnect = true;
|
failedToConnect = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (memcmp(code, kMsgEBad, 4) == 0) {
|
else if (memcmp(code, kMsgEBad, 4) == 0) {
|
||||||
log((CLOG_ERR "server disconnected due to a protocol error"));
|
LOG((CLOG_ERR "server disconnected due to a protocol error"));
|
||||||
failedToConnect = true;
|
failedToConnect = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
// unknown message
|
// unknown message
|
||||||
log((CLOG_ERR "unknown message from server"));
|
LOG((CLOG_ERR "unknown message from server"));
|
||||||
failedToConnect = true;
|
failedToConnect = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (XBase& e) {
|
catch (XBase& e) {
|
||||||
log((CLOG_ERR "error: %s", e.what()));
|
LOG((CLOG_ERR "error: %s", e.what()));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
throw;
|
throw;
|
||||||
|
@ -257,7 +257,7 @@ CServerProxy::onInfoChanged(const CClientInfo& info)
|
||||||
bool
|
bool
|
||||||
CServerProxy::onGrabClipboard(ClipboardID id)
|
CServerProxy::onGrabClipboard(ClipboardID id)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "sending clipboard %d changed", id));
|
LOG((CLOG_DEBUG1 "sending clipboard %d changed", id));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgCClipboard, id, m_seqNum);
|
CProtocolUtil::writef(getOutputStream(), kMsgCClipboard, id, m_seqNum);
|
||||||
return true;
|
return true;
|
||||||
|
@ -267,7 +267,7 @@ void
|
||||||
CServerProxy::onClipboardChanged(ClipboardID id, const CString& data)
|
CServerProxy::onClipboardChanged(ClipboardID id, const CString& data)
|
||||||
{
|
{
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
log((CLOG_DEBUG1 "sending clipboard %d seqnum=%d, size=%d", id, m_seqNum, data.size()));
|
LOG((CLOG_DEBUG1 "sending clipboard %d seqnum=%d, size=%d", id, m_seqNum, data.size()));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDClipboard, id, m_seqNum, &data);
|
CProtocolUtil::writef(getOutputStream(), kMsgDClipboard, id, m_seqNum, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ void
|
||||||
CServerProxy::sendInfo(const CClientInfo& info)
|
CServerProxy::sendInfo(const CClientInfo& info)
|
||||||
{
|
{
|
||||||
// note -- m_mutex should be locked on entry
|
// note -- m_mutex should be locked on entry
|
||||||
log((CLOG_DEBUG1 "sending info shape=%d,%d %dx%d zone=%d pos=%d,%d", info.m_x, info.m_y, info.m_w, info.m_h, info.m_zoneSize, info.m_mx, info.m_my));
|
LOG((CLOG_DEBUG1 "sending info shape=%d,%d %dx%d zone=%d pos=%d,%d", info.m_x, info.m_y, info.m_w, info.m_h, info.m_zoneSize, info.m_mx, info.m_my));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDInfo,
|
CProtocolUtil::writef(getOutputStream(), kMsgDInfo,
|
||||||
info.m_x, info.m_y,
|
info.m_x, info.m_y,
|
||||||
info.m_w, info.m_h,
|
info.m_w, info.m_h,
|
||||||
|
@ -312,7 +312,7 @@ CServerProxy::enter()
|
||||||
UInt32 seqNum;
|
UInt32 seqNum;
|
||||||
CProtocolUtil::readf(getInputStream(),
|
CProtocolUtil::readf(getInputStream(),
|
||||||
kMsgCEnter + 4, &x, &y, &seqNum, &mask);
|
kMsgCEnter + 4, &x, &y, &seqNum, &mask);
|
||||||
log((CLOG_DEBUG1 "recv enter, %d,%d %d %04x", x, y, seqNum, mask));
|
LOG((CLOG_DEBUG1 "recv enter, %d,%d %d %04x", x, y, seqNum, mask));
|
||||||
|
|
||||||
// discard old compressed mouse motion, if any
|
// discard old compressed mouse motion, if any
|
||||||
{
|
{
|
||||||
|
@ -329,7 +329,7 @@ void
|
||||||
CServerProxy::leave()
|
CServerProxy::leave()
|
||||||
{
|
{
|
||||||
// parse
|
// parse
|
||||||
log((CLOG_DEBUG1 "recv leave"));
|
LOG((CLOG_DEBUG1 "recv leave"));
|
||||||
|
|
||||||
// send last mouse motion
|
// send last mouse motion
|
||||||
flushCompressedMouse();
|
flushCompressedMouse();
|
||||||
|
@ -347,7 +347,7 @@ CServerProxy::setClipboard()
|
||||||
CString data;
|
CString data;
|
||||||
CProtocolUtil::readf(getInputStream(),
|
CProtocolUtil::readf(getInputStream(),
|
||||||
kMsgDClipboard + 4, &id, &seqNum, &data);
|
kMsgDClipboard + 4, &id, &seqNum, &data);
|
||||||
log((CLOG_DEBUG "recv clipboard %d size=%d", id, data.size()));
|
LOG((CLOG_DEBUG "recv clipboard %d size=%d", id, data.size()));
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
if (id >= kClipboardEnd) {
|
if (id >= kClipboardEnd) {
|
||||||
|
@ -365,7 +365,7 @@ CServerProxy::grabClipboard()
|
||||||
ClipboardID id;
|
ClipboardID id;
|
||||||
UInt32 seqNum;
|
UInt32 seqNum;
|
||||||
CProtocolUtil::readf(getInputStream(), kMsgCClipboard + 4, &id, &seqNum);
|
CProtocolUtil::readf(getInputStream(), kMsgCClipboard + 4, &id, &seqNum);
|
||||||
log((CLOG_DEBUG "recv grab clipboard %d", id));
|
LOG((CLOG_DEBUG "recv grab clipboard %d", id));
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
if (id >= kClipboardEnd) {
|
if (id >= kClipboardEnd) {
|
||||||
|
@ -385,7 +385,7 @@ CServerProxy::keyDown()
|
||||||
// parse
|
// parse
|
||||||
UInt16 id, mask;
|
UInt16 id, mask;
|
||||||
CProtocolUtil::readf(getInputStream(), kMsgDKeyDown + 4, &id, &mask);
|
CProtocolUtil::readf(getInputStream(), kMsgDKeyDown + 4, &id, &mask);
|
||||||
log((CLOG_DEBUG1 "recv key down id=%d, mask=0x%04x", id, mask));
|
LOG((CLOG_DEBUG1 "recv key down id=%d, mask=0x%04x", id, mask));
|
||||||
|
|
||||||
// forward
|
// forward
|
||||||
getClient()->keyDown(static_cast<KeyID>(id),
|
getClient()->keyDown(static_cast<KeyID>(id),
|
||||||
|
@ -402,7 +402,7 @@ CServerProxy::keyRepeat()
|
||||||
UInt16 id, mask, count;
|
UInt16 id, mask, count;
|
||||||
CProtocolUtil::readf(getInputStream(),
|
CProtocolUtil::readf(getInputStream(),
|
||||||
kMsgDKeyRepeat + 4, &id, &mask, &count);
|
kMsgDKeyRepeat + 4, &id, &mask, &count);
|
||||||
log((CLOG_DEBUG1 "recv key repeat id=%d, mask=0x%04x, count=%d", id, mask, count));
|
LOG((CLOG_DEBUG1 "recv key repeat id=%d, mask=0x%04x, count=%d", id, mask, count));
|
||||||
|
|
||||||
// forward
|
// forward
|
||||||
getClient()->keyRepeat(static_cast<KeyID>(id),
|
getClient()->keyRepeat(static_cast<KeyID>(id),
|
||||||
|
@ -419,7 +419,7 @@ CServerProxy::keyUp()
|
||||||
// parse
|
// parse
|
||||||
UInt16 id, mask;
|
UInt16 id, mask;
|
||||||
CProtocolUtil::readf(getInputStream(), kMsgDKeyUp + 4, &id, &mask);
|
CProtocolUtil::readf(getInputStream(), kMsgDKeyUp + 4, &id, &mask);
|
||||||
log((CLOG_DEBUG1 "recv key up id=%d, mask=0x%04x", id, mask));
|
LOG((CLOG_DEBUG1 "recv key up id=%d, mask=0x%04x", id, mask));
|
||||||
|
|
||||||
// forward
|
// forward
|
||||||
getClient()->keyUp(static_cast<KeyID>(id),
|
getClient()->keyUp(static_cast<KeyID>(id),
|
||||||
|
@ -435,7 +435,7 @@ CServerProxy::mouseDown()
|
||||||
// parse
|
// parse
|
||||||
SInt8 id;
|
SInt8 id;
|
||||||
CProtocolUtil::readf(getInputStream(), kMsgDMouseDown + 4, &id);
|
CProtocolUtil::readf(getInputStream(), kMsgDMouseDown + 4, &id);
|
||||||
log((CLOG_DEBUG1 "recv mouse down id=%d", id));
|
LOG((CLOG_DEBUG1 "recv mouse down id=%d", id));
|
||||||
|
|
||||||
// forward
|
// forward
|
||||||
getClient()->mouseDown(static_cast<ButtonID>(id));
|
getClient()->mouseDown(static_cast<ButtonID>(id));
|
||||||
|
@ -450,7 +450,7 @@ CServerProxy::mouseUp()
|
||||||
// parse
|
// parse
|
||||||
SInt8 id;
|
SInt8 id;
|
||||||
CProtocolUtil::readf(getInputStream(), kMsgDMouseUp + 4, &id);
|
CProtocolUtil::readf(getInputStream(), kMsgDMouseUp + 4, &id);
|
||||||
log((CLOG_DEBUG1 "recv mouse up id=%d", id));
|
LOG((CLOG_DEBUG1 "recv mouse up id=%d", id));
|
||||||
|
|
||||||
// forward
|
// forward
|
||||||
getClient()->mouseUp(static_cast<ButtonID>(id));
|
getClient()->mouseUp(static_cast<ButtonID>(id));
|
||||||
|
@ -481,7 +481,7 @@ CServerProxy::mouseMove()
|
||||||
m_yMouse = y;
|
m_yMouse = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log((CLOG_DEBUG2 "recv mouse move %d,%d", x, y));
|
LOG((CLOG_DEBUG2 "recv mouse move %d,%d", x, y));
|
||||||
|
|
||||||
// forward
|
// forward
|
||||||
if (!ignore) {
|
if (!ignore) {
|
||||||
|
@ -498,7 +498,7 @@ CServerProxy::mouseWheel()
|
||||||
// parse
|
// parse
|
||||||
SInt16 delta;
|
SInt16 delta;
|
||||||
CProtocolUtil::readf(getInputStream(), kMsgDMouseWheel + 4, &delta);
|
CProtocolUtil::readf(getInputStream(), kMsgDMouseWheel + 4, &delta);
|
||||||
log((CLOG_DEBUG2 "recv mouse wheel %+d", delta));
|
LOG((CLOG_DEBUG2 "recv mouse wheel %+d", delta));
|
||||||
|
|
||||||
// forward
|
// forward
|
||||||
getClient()->mouseWheel(delta);
|
getClient()->mouseWheel(delta);
|
||||||
|
@ -510,7 +510,7 @@ CServerProxy::screensaver()
|
||||||
// parse
|
// parse
|
||||||
SInt8 on;
|
SInt8 on;
|
||||||
CProtocolUtil::readf(getInputStream(), kMsgCScreenSaver + 4, &on);
|
CProtocolUtil::readf(getInputStream(), kMsgCScreenSaver + 4, &on);
|
||||||
log((CLOG_DEBUG1 "recv screen saver on=%d", on));
|
LOG((CLOG_DEBUG1 "recv screen saver on=%d", on));
|
||||||
|
|
||||||
// forward
|
// forward
|
||||||
getClient()->screensaver(on != 0);
|
getClient()->screensaver(on != 0);
|
||||||
|
@ -534,7 +534,7 @@ void
|
||||||
CServerProxy::infoAcknowledgment()
|
CServerProxy::infoAcknowledgment()
|
||||||
{
|
{
|
||||||
// parse
|
// parse
|
||||||
log((CLOG_DEBUG1 "recv info acknowledgment"));
|
LOG((CLOG_DEBUG1 "recv info acknowledgment"));
|
||||||
|
|
||||||
// now allow mouse motion
|
// now allow mouse motion
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
|
|
|
@ -293,7 +293,7 @@ CXWindowsSecondaryScreen::createWindow()
|
||||||
int majorOpcode, firstEvent, firstError;
|
int majorOpcode, firstEvent, firstError;
|
||||||
if (!XQueryExtension(display, XTestExtensionName,
|
if (!XQueryExtension(display, XTestExtensionName,
|
||||||
&majorOpcode, &firstEvent, &firstError)) {
|
&majorOpcode, &firstEvent, &firstError)) {
|
||||||
log((CLOG_ERR "XTEST extension not available"));
|
LOG((CLOG_ERR "XTEST extension not available"));
|
||||||
throw XScreenOpenFailure();
|
throw XScreenOpenFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ CXWindowsSecondaryScreen::createWindow()
|
||||||
if (m_window == None) {
|
if (m_window == None) {
|
||||||
throw XScreenOpenFailure();
|
throw XScreenOpenFailure();
|
||||||
}
|
}
|
||||||
log((CLOG_DEBUG "window is 0x%08x", m_window));
|
LOG((CLOG_DEBUG "window is 0x%08x", m_window));
|
||||||
|
|
||||||
// become impervious to server grabs
|
// become impervious to server grabs
|
||||||
XTestGrabControl(display, True);
|
XTestGrabControl(display, True);
|
||||||
|
@ -490,28 +490,28 @@ CXWindowsSecondaryScreen::mapKey(Keystrokes& keys, KeyCode& keycode,
|
||||||
// keys affected by CapsLock.
|
// keys affected by CapsLock.
|
||||||
bool desireShift = (getBits(desired, ShiftMask) != 0);
|
bool desireShift = (getBits(desired, ShiftMask) != 0);
|
||||||
bool invertShift = false;
|
bool invertShift = false;
|
||||||
log((CLOG_DEBUG1 "desire shift 1: %s", desireShift?"yes":"no"));
|
LOG((CLOG_DEBUG1 "desire shift 1: %s", desireShift?"yes":"no"));
|
||||||
if (adjustForNumLock(keysym)) {
|
if (adjustForNumLock(keysym)) {
|
||||||
log((CLOG_DEBUG1 "num lock sensitive"));
|
LOG((CLOG_DEBUG1 "num lock sensitive"));
|
||||||
if (m_numLockMask != 0) {
|
if (m_numLockMask != 0) {
|
||||||
log((CLOG_DEBUG1 "we have num lock"));
|
LOG((CLOG_DEBUG1 "we have num lock"));
|
||||||
if (getBits(desired, m_numLockMask) != 0) {
|
if (getBits(desired, m_numLockMask) != 0) {
|
||||||
log((CLOG_DEBUG1 "num lock desired, invert shift"));
|
LOG((CLOG_DEBUG1 "num lock desired, invert shift"));
|
||||||
invertShift = true;
|
invertShift = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (adjustForCapsLock(keysym)) {
|
else if (adjustForCapsLock(keysym)) {
|
||||||
log((CLOG_DEBUG1 "caps lock sensitive"));
|
LOG((CLOG_DEBUG1 "caps lock sensitive"));
|
||||||
if (m_capsLockMask != 0) {
|
if (m_capsLockMask != 0) {
|
||||||
log((CLOG_DEBUG1 "we have caps lock"));
|
LOG((CLOG_DEBUG1 "we have caps lock"));
|
||||||
if (getBits(desired, m_capsLockMask) != 0) {
|
if (getBits(desired, m_capsLockMask) != 0) {
|
||||||
log((CLOG_DEBUG1 "caps lock desired, invert shift"));
|
LOG((CLOG_DEBUG1 "caps lock desired, invert shift"));
|
||||||
invertShift = true;
|
invertShift = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log((CLOG_DEBUG1 "desire shift 2: %s", desireShift?"yes":"no"));
|
LOG((CLOG_DEBUG1 "desire shift 2: %s", desireShift?"yes":"no"));
|
||||||
if (desireShift != invertShift) {
|
if (desireShift != invertShift) {
|
||||||
index[0] ^= 1;
|
index[0] ^= 1;
|
||||||
index[1] ^= 1;
|
index[1] ^= 1;
|
||||||
|
@ -538,7 +538,7 @@ log((CLOG_DEBUG1 "desire shift 2: %s", desireShift?"yes":"no"));
|
||||||
|
|
||||||
// get the keycode
|
// get the keycode
|
||||||
keycode = entry.m_keycode[bestIndex];
|
keycode = entry.m_keycode[bestIndex];
|
||||||
log((CLOG_DEBUG1 "bestIndex = %d, keycode = %d", bestIndex, keycode));
|
LOG((CLOG_DEBUG1 "bestIndex = %d, keycode = %d", bestIndex, keycode));
|
||||||
|
|
||||||
// note if the key is a modifier
|
// note if the key is a modifier
|
||||||
ModifierMap::const_iterator modIndex = m_keycodeToModifier.find(keycode);
|
ModifierMap::const_iterator modIndex = m_keycodeToModifier.find(keycode);
|
||||||
|
@ -553,13 +553,13 @@ log((CLOG_DEBUG1 "bestIndex = %d, keycode = %d", bestIndex, keycode));
|
||||||
// though.
|
// though.
|
||||||
if (modifierBit != 0) {
|
if (modifierBit != 0) {
|
||||||
if (action == kRepeat) {
|
if (action == kRepeat) {
|
||||||
log((CLOG_DEBUG1 "ignore repeating modifier"));
|
LOG((CLOG_DEBUG1 "ignore repeating modifier"));
|
||||||
return m_mask;
|
return m_mask;
|
||||||
}
|
}
|
||||||
if (getBits(m_toggleModifierMask, modifierBit) == 0) {
|
if (getBits(m_toggleModifierMask, modifierBit) == 0) {
|
||||||
if ((action == kPress && (m_mask & modifierBit) != 0) ||
|
if ((action == kPress && (m_mask & modifierBit) != 0) ||
|
||||||
(action == kRelease && (m_mask & modifierBit) == 0)) {
|
(action == kRelease && (m_mask & modifierBit) == 0)) {
|
||||||
log((CLOG_DEBUG1 "modifier in proper state: 0x%04x", m_mask));
|
LOG((CLOG_DEBUG1 "modifier in proper state: 0x%04x", m_mask));
|
||||||
return m_mask;
|
return m_mask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -594,7 +594,7 @@ log((CLOG_DEBUG1 "modifier in proper state: 0x%04x", m_mask));
|
||||||
// the same bit in m_mask, meaning it's already in the right state.
|
// the same bit in m_mask, meaning it's already in the right state.
|
||||||
desired = assignBits(desired, modifierBit, m_mask);
|
desired = assignBits(desired, modifierBit, m_mask);
|
||||||
required = clearBits(required, modifierBit);
|
required = clearBits(required, modifierBit);
|
||||||
log((CLOG_DEBUG1 "desired = 0x%04x, current = 0x%04x", desired, m_mask));
|
LOG((CLOG_DEBUG1 "desired = 0x%04x, current = 0x%04x", desired, m_mask));
|
||||||
|
|
||||||
// add the key events required to get to the modifier state
|
// add the key events required to get to the modifier state
|
||||||
// necessary to generate an event yielding id. also save the
|
// necessary to generate an event yielding id. also save the
|
||||||
|
@ -607,13 +607,13 @@ log((CLOG_DEBUG1 "desired = 0x%04x, current = 0x%04x", desired, m_mask));
|
||||||
for (unsigned int i = 0; i < 8; ++i) {
|
for (unsigned int i = 0; i < 8; ++i) {
|
||||||
unsigned int bit = (1 << i);
|
unsigned int bit = (1 << i);
|
||||||
if (getBits(desired, bit) != getBits(m_mask, bit)) {
|
if (getBits(desired, bit) != getBits(m_mask, bit)) {
|
||||||
log((CLOG_DEBUG1 "fix modifier %d", i));
|
LOG((CLOG_DEBUG1 "fix modifier %d", i));
|
||||||
// get the keycode we're using for this modifier. if
|
// get the keycode we're using for this modifier. if
|
||||||
// there isn't one then bail if the modifier is required
|
// there isn't one then bail if the modifier is required
|
||||||
// or ignore it if not required.
|
// or ignore it if not required.
|
||||||
KeyCode modifierKey = m_modifierToKeycode[i];
|
KeyCode modifierKey = m_modifierToKeycode[i];
|
||||||
if (modifierKey == 0) {
|
if (modifierKey == 0) {
|
||||||
log((CLOG_DEBUG1 "no key mapped to modifier 0x%04x", bit));
|
LOG((CLOG_DEBUG1 "no key mapped to modifier 0x%04x", bit));
|
||||||
if (getBits(required, bit) != 0) {
|
if (getBits(required, bit) != 0) {
|
||||||
keys.clear();
|
keys.clear();
|
||||||
return m_mask;
|
return m_mask;
|
||||||
|
@ -630,9 +630,9 @@ log((CLOG_DEBUG1 "fix modifier %d", i));
|
||||||
// modifier is a toggle then toggle it on with a
|
// modifier is a toggle then toggle it on with a
|
||||||
// press/release, otherwise activate it with a
|
// press/release, otherwise activate it with a
|
||||||
// press. use the first keycode for the modifier.
|
// press. use the first keycode for the modifier.
|
||||||
log((CLOG_DEBUG2 "modifier 0x%04x is not active", bit));
|
LOG((CLOG_DEBUG2 "modifier 0x%04x is not active", bit));
|
||||||
if (getBits(m_toggleModifierMask, bit) != 0) {
|
if (getBits(m_toggleModifierMask, bit) != 0) {
|
||||||
log((CLOG_DEBUG2 "modifier 0x%04x is a toggle", bit));
|
LOG((CLOG_DEBUG2 "modifier 0x%04x is a toggle", bit));
|
||||||
if ((bit == m_capsLockMask && m_capsLockHalfDuplex) ||
|
if ((bit == m_capsLockMask && m_capsLockHalfDuplex) ||
|
||||||
(bit == m_numLockMask && m_numLockHalfDuplex)) {
|
(bit == m_numLockMask && m_numLockHalfDuplex)) {
|
||||||
keystroke.m_press = True;
|
keystroke.m_press = True;
|
||||||
|
@ -664,9 +664,9 @@ log((CLOG_DEBUG1 "fix modifier %d", i));
|
||||||
// press/release, otherwise deactivate it with a
|
// press/release, otherwise deactivate it with a
|
||||||
// release. we must check each keycode for the
|
// release. we must check each keycode for the
|
||||||
// modifier if not a toggle.
|
// modifier if not a toggle.
|
||||||
log((CLOG_DEBUG2 "modifier 0x%04x is active", bit));
|
LOG((CLOG_DEBUG2 "modifier 0x%04x is active", bit));
|
||||||
if (getBits(m_toggleModifierMask, bit) != 0) {
|
if (getBits(m_toggleModifierMask, bit) != 0) {
|
||||||
log((CLOG_DEBUG2 "modifier 0x%04x is a toggle", bit));
|
LOG((CLOG_DEBUG2 "modifier 0x%04x is a toggle", bit));
|
||||||
if ((bit == m_capsLockMask && m_capsLockHalfDuplex) ||
|
if ((bit == m_capsLockMask && m_capsLockHalfDuplex) ||
|
||||||
(bit == m_numLockMask && m_numLockHalfDuplex)) {
|
(bit == m_numLockMask && m_numLockHalfDuplex)) {
|
||||||
keystroke.m_press = False;
|
keystroke.m_press = False;
|
||||||
|
@ -773,7 +773,7 @@ log((CLOG_DEBUG1 "fix modifier %d", i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log((CLOG_DEBUG1 "final mask: 0x%04x", mask));
|
LOG((CLOG_DEBUG1 "final mask: 0x%04x", mask));
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1308,7 +1308,7 @@ CXWindowsSecondaryScreen::adjustForNumLock(KeySym keysym) const
|
||||||
{
|
{
|
||||||
if (IsKeypadKey(keysym) || IsPrivateKeypadKey(keysym)) {
|
if (IsKeypadKey(keysym) || IsPrivateKeypadKey(keysym)) {
|
||||||
// it's NumLock sensitive
|
// it's NumLock sensitive
|
||||||
log((CLOG_DEBUG2 "keypad key: NumLock %s", ((m_mask & m_numLockMask) != 0) ? "active" : "inactive"));
|
LOG((CLOG_DEBUG2 "keypad key: NumLock %s", ((m_mask & m_numLockMask) != 0) ? "active" : "inactive"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1321,7 +1321,7 @@ CXWindowsSecondaryScreen::adjustForCapsLock(KeySym keysym) const
|
||||||
XConvertCase(keysym, &lKey, &uKey);
|
XConvertCase(keysym, &lKey, &uKey);
|
||||||
if (lKey != uKey) {
|
if (lKey != uKey) {
|
||||||
// it's CapsLock sensitive
|
// it's CapsLock sensitive
|
||||||
log((CLOG_DEBUG2 "case convertible: CapsLock %s", ((m_mask & m_capsLockMask) != 0) ? "active" : "inactive"));
|
LOG((CLOG_DEBUG2 "case convertible: CapsLock %s", ((m_mask & m_capsLockMask) != 0) ? "active" : "inactive"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -128,7 +128,7 @@ CHTTPProtocol::readRequest(IInputStream* stream, UInt32 maxSize)
|
||||||
CString version;
|
CString version;
|
||||||
s >> request->m_method >> request->m_uri >> version;
|
s >> request->m_method >> request->m_uri >> version;
|
||||||
if (!s || request->m_uri.empty() || version.find("HTTP/") != 0) {
|
if (!s || request->m_uri.empty() || version.find("HTTP/") != 0) {
|
||||||
log((CLOG_DEBUG1 "failed to parse HTTP request line: %s", line.c_str()));
|
LOG((CLOG_DEBUG1 "failed to parse HTTP request line: %s", line.c_str()));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,16 +141,16 @@ CHTTPProtocol::readRequest(IInputStream* stream, UInt32 maxSize)
|
||||||
s.get(dot);
|
s.get(dot);
|
||||||
s >> request->m_minorVersion;
|
s >> request->m_minorVersion;
|
||||||
if (!s || dot != '.') {
|
if (!s || dot != '.') {
|
||||||
log((CLOG_DEBUG1 "failed to parse HTTP request line: %s", line.c_str()));
|
LOG((CLOG_DEBUG1 "failed to parse HTTP request line: %s", line.c_str()));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isValidToken(request->m_method)) {
|
if (!isValidToken(request->m_method)) {
|
||||||
log((CLOG_DEBUG1 "invalid HTTP method: %s", line.c_str()));
|
LOG((CLOG_DEBUG1 "invalid HTTP method: %s", line.c_str()));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
if (request->m_majorVersion < 1 || request->m_minorVersion < 0) {
|
if (request->m_majorVersion < 1 || request->m_minorVersion < 0) {
|
||||||
log((CLOG_DEBUG1 "invalid HTTP version: %s", line.c_str()));
|
LOG((CLOG_DEBUG1 "invalid HTTP version: %s", line.c_str()));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ CHTTPProtocol::readRequest(IInputStream* stream, UInt32 maxSize)
|
||||||
if (request->m_majorVersion > 1 ||
|
if (request->m_majorVersion > 1 ||
|
||||||
(request->m_majorVersion == 1 && request->m_minorVersion >= 1)) {
|
(request->m_majorVersion == 1 && request->m_minorVersion >= 1)) {
|
||||||
if (request->isHeader("Host") == 0) {
|
if (request->isHeader("Host") == 0) {
|
||||||
log((CLOG_DEBUG1 "Host header missing"));
|
LOG((CLOG_DEBUG1 "Host header missing"));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ CHTTPProtocol::readRequest(IInputStream* stream, UInt32 maxSize)
|
||||||
request->isHeader("Content-Length")) ==
|
request->isHeader("Content-Length")) ==
|
||||||
(request->m_method == "GET" ||
|
(request->m_method == "GET" ||
|
||||||
request->m_method == "HEAD")) {
|
request->m_method == "HEAD")) {
|
||||||
log((CLOG_DEBUG1 "HTTP method (%s)/body mismatch", request->m_method.c_str()));
|
LOG((CLOG_DEBUG1 "HTTP method (%s)/body mismatch", request->m_method.c_str()));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ CHTTPProtocol::readRequest(IInputStream* stream, UInt32 maxSize)
|
||||||
if (!(header = request->getHeader("Transfer-Encoding")).empty()) {
|
if (!(header = request->getHeader("Transfer-Encoding")).empty()) {
|
||||||
// we only understand "chunked" encodings
|
// we only understand "chunked" encodings
|
||||||
if (!CStringUtil::CaselessCmp::equal(header, "chunked")) {
|
if (!CStringUtil::CaselessCmp::equal(header, "chunked")) {
|
||||||
log((CLOG_DEBUG1 "unsupported Transfer-Encoding %s", header.c_str()));
|
LOG((CLOG_DEBUG1 "unsupported Transfer-Encoding %s", header.c_str()));
|
||||||
throw XHTTP(501);
|
throw XHTTP(501);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ CHTTPProtocol::readRequest(IInputStream* stream, UInt32 maxSize)
|
||||||
s.exceptions(std::ios::goodbit);
|
s.exceptions(std::ios::goodbit);
|
||||||
s >> length;
|
s >> length;
|
||||||
if (!s) {
|
if (!s) {
|
||||||
log((CLOG_DEBUG1 "cannot parse Content-Length", header.c_str()));
|
LOG((CLOG_DEBUG1 "cannot parse Content-Length", header.c_str()));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ CHTTPProtocol::readRequest(IInputStream* stream, UInt32 maxSize)
|
||||||
request->m_body = readBlock(stream, length, scratch);
|
request->m_body = readBlock(stream, length, scratch);
|
||||||
if (request->m_body.size() != length) {
|
if (request->m_body.size() != length) {
|
||||||
// length must match size of body
|
// length must match size of body
|
||||||
log((CLOG_DEBUG1 "Content-Length/actual length mismatch (%d vs %d)", length, request->m_body.size()));
|
LOG((CLOG_DEBUG1 "Content-Length/actual length mismatch (%d vs %d)", length, request->m_body.size()));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -559,7 +559,7 @@ CHTTPProtocol::readChunk(IInputStream* stream,
|
||||||
s.exceptions(std::ios::goodbit);
|
s.exceptions(std::ios::goodbit);
|
||||||
s >> std::hex >> size;
|
s >> std::hex >> size;
|
||||||
if (!s) {
|
if (!s) {
|
||||||
log((CLOG_DEBUG1 "cannot parse chunk size", line.c_str()));
|
LOG((CLOG_DEBUG1 "cannot parse chunk size", line.c_str()));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,14 +578,14 @@ CHTTPProtocol::readChunk(IInputStream* stream,
|
||||||
// read size bytes
|
// read size bytes
|
||||||
CString data = readBlock(stream, size, tmpBuffer);
|
CString data = readBlock(stream, size, tmpBuffer);
|
||||||
if (data.size() != size) {
|
if (data.size() != size) {
|
||||||
log((CLOG_DEBUG1 "expected/actual chunk size mismatch", size, data.size()));
|
LOG((CLOG_DEBUG1 "expected/actual chunk size mismatch", size, data.size()));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read an discard CRLF
|
// read an discard CRLF
|
||||||
line = readLine(stream, tmpBuffer);
|
line = readLine(stream, tmpBuffer);
|
||||||
if (!line.empty()) {
|
if (!line.empty()) {
|
||||||
log((CLOG_DEBUG1 "missing CRLF after chunk"));
|
LOG((CLOG_DEBUG1 "missing CRLF after chunk"));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,7 +614,7 @@ CHTTPProtocol::readHeaders(IInputStream* stream,
|
||||||
// throw.
|
// throw.
|
||||||
if (line[0] == ' ' || line[0] == '\t') {
|
if (line[0] == ' ' || line[0] == '\t') {
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
log((CLOG_DEBUG1 "first header is a continuation"));
|
LOG((CLOG_DEBUG1 "first header is a continuation"));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
request->appendHeader(name, line);
|
request->appendHeader(name, line);
|
||||||
|
@ -628,7 +628,7 @@ CHTTPProtocol::readHeaders(IInputStream* stream,
|
||||||
s.exceptions(std::ios::goodbit);
|
s.exceptions(std::ios::goodbit);
|
||||||
std::getline(s, name, ':');
|
std::getline(s, name, ':');
|
||||||
if (!s || !isValidToken(name)) {
|
if (!s || !isValidToken(name)) {
|
||||||
log((CLOG_DEBUG1 "invalid header: %s", line.c_str()));
|
LOG((CLOG_DEBUG1 "invalid header: %s", line.c_str()));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
std::getline(s, value);
|
std::getline(s, value);
|
||||||
|
|
|
@ -61,7 +61,7 @@ CMutex::fini()
|
||||||
{
|
{
|
||||||
pthread_mutex_t* mutex = reinterpret_cast<pthread_mutex_t*>(m_mutex);
|
pthread_mutex_t* mutex = reinterpret_cast<pthread_mutex_t*>(m_mutex);
|
||||||
int status = pthread_mutex_destroy(mutex);
|
int status = pthread_mutex_destroy(mutex);
|
||||||
logc(status != 0, (CLOG_ERR "pthread_mutex_destroy status %d", status));
|
LOGC(status != 0, (CLOG_ERR "pthread_mutex_destroy status %d", status));
|
||||||
assert(status == 0);
|
assert(status == 0);
|
||||||
delete mutex;
|
delete mutex;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ CMutex::lock() const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log((CLOG_ERR "pthread_mutex_lock status %d", status));
|
LOG((CLOG_ERR "pthread_mutex_lock status %d", status));
|
||||||
assert(0 && "unexpected error");
|
assert(0 && "unexpected error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ CMutex::unlock() const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log((CLOG_ERR "pthread_mutex_unlock status %d", status));
|
LOG((CLOG_ERR "pthread_mutex_unlock status %d", status));
|
||||||
assert(0 && "unexpected error");
|
assert(0 && "unexpected error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ void
|
||||||
CThread::exit(void* result)
|
CThread::exit(void* result)
|
||||||
{
|
{
|
||||||
CThreadPtr currentRep(CThreadRep::getCurrentThreadRep());
|
CThreadPtr currentRep(CThreadRep::getCurrentThreadRep());
|
||||||
log((CLOG_DEBUG1 "throw exit on thread %p", currentRep.operator->()));
|
LOG((CLOG_DEBUG1 "throw exit on thread %p", currentRep.operator->()));
|
||||||
throw XThreadExit(result);
|
throw XThreadExit(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -296,23 +296,23 @@ CThreadRep::doThreadFunc()
|
||||||
void* result = NULL;
|
void* result = NULL;
|
||||||
try {
|
try {
|
||||||
// go
|
// go
|
||||||
log((CLOG_DEBUG1 "thread %p entry", this));
|
LOG((CLOG_DEBUG1 "thread %p entry", this));
|
||||||
m_job->run();
|
m_job->run();
|
||||||
log((CLOG_DEBUG1 "thread %p exit", this));
|
LOG((CLOG_DEBUG1 "thread %p exit", this));
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (XThreadCancel&) {
|
catch (XThreadCancel&) {
|
||||||
// client called cancel()
|
// client called cancel()
|
||||||
log((CLOG_DEBUG1 "caught cancel on thread %p", this));
|
LOG((CLOG_DEBUG1 "caught cancel on thread %p", this));
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (XThreadExit& e) {
|
catch (XThreadExit& e) {
|
||||||
// client called exit()
|
// client called exit()
|
||||||
result = e.m_result;
|
result = e.m_result;
|
||||||
log((CLOG_DEBUG1 "caught exit on thread %p", this));
|
LOG((CLOG_DEBUG1 "caught exit on thread %p", this));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
log((CLOG_DEBUG1 "exception on thread %p", this));
|
LOG((CLOG_DEBUG1 "exception on thread %p", this));
|
||||||
// note -- don't catch (...) to avoid masking bugs
|
// note -- don't catch (...) to avoid masking bugs
|
||||||
delete m_job;
|
delete m_job;
|
||||||
throw;
|
throw;
|
||||||
|
@ -385,7 +385,7 @@ CThreadRep::cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
// break out of system calls
|
// break out of system calls
|
||||||
log((CLOG_DEBUG1 "cancel thread %p", this));
|
LOG((CLOG_DEBUG1 "cancel thread %p", this));
|
||||||
pthread_kill(m_thread, SIGWAKEUP);
|
pthread_kill(m_thread, SIGWAKEUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ CThreadRep::testCancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
// start cancel
|
// start cancel
|
||||||
log((CLOG_DEBUG1 "throw cancel on thread %p", this));
|
LOG((CLOG_DEBUG1 "throw cancel on thread %p", this));
|
||||||
throw XThreadCancel();
|
throw XThreadCancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ CThreadRep::sleep(
|
||||||
void
|
void
|
||||||
CThreadRep::cancel()
|
CThreadRep::cancel()
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "cancel thread %p", this));
|
LOG((CLOG_DEBUG1 "cancel thread %p", this));
|
||||||
SetEvent(m_cancel);
|
SetEvent(m_cancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ CThreadRep::testCancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
// start cancel
|
// start cancel
|
||||||
log((CLOG_DEBUG1 "throw cancel on thread %p", this));
|
LOG((CLOG_DEBUG1 "throw cancel on thread %p", this));
|
||||||
throw XThreadCancel();
|
throw XThreadCancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,10 +37,10 @@ CTimerThread::CTimerThread(double timeout) : m_timeout(timeout)
|
||||||
CTimerThread::~CTimerThread()
|
CTimerThread::~CTimerThread()
|
||||||
{
|
{
|
||||||
if (m_timingThread != NULL) {
|
if (m_timingThread != NULL) {
|
||||||
log((CLOG_DEBUG1 "cancelling timeout"));
|
LOG((CLOG_DEBUG1 "cancelling timeout"));
|
||||||
m_timingThread->cancel();
|
m_timingThread->cancel();
|
||||||
m_timingThread->wait();
|
m_timingThread->wait();
|
||||||
log((CLOG_DEBUG1 "cancelled timeout"));
|
LOG((CLOG_DEBUG1 "cancelled timeout"));
|
||||||
delete m_timingThread;
|
delete m_timingThread;
|
||||||
delete m_callingThread;
|
delete m_callingThread;
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ CTimerThread::~CTimerThread()
|
||||||
void
|
void
|
||||||
CTimerThread::timer(void*)
|
CTimerThread::timer(void*)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "timeout in %f seconds", m_timeout));
|
LOG((CLOG_DEBUG1 "timeout in %f seconds", m_timeout));
|
||||||
CThread::sleep(m_timeout);
|
CThread::sleep(m_timeout);
|
||||||
log((CLOG_DEBUG1 "timeout"));
|
LOG((CLOG_DEBUG1 "timeout"));
|
||||||
m_callingThread->cancel();
|
m_callingThread->cancel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ CNetwork::init()
|
||||||
// try winsock 2
|
// try winsock 2
|
||||||
HMODULE module = (HMODULE)::LoadLibrary("ws2_32.dll");
|
HMODULE module = (HMODULE)::LoadLibrary("ws2_32.dll");
|
||||||
if (module == NULL) {
|
if (module == NULL) {
|
||||||
log((CLOG_NOTE "ws2_32.dll not found"));
|
LOG((CLOG_NOTE "ws2_32.dll not found"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
|
@ -93,14 +93,14 @@ CNetwork::init()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (XNetwork& e) {
|
catch (XNetwork& e) {
|
||||||
log((CLOG_NOTE "ws2_32.dll error: %s", e.what()));
|
LOG((CLOG_NOTE "ws2_32.dll error: %s", e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try winsock 1
|
// try winsock 1
|
||||||
module = (HMODULE)::LoadLibrary("wsock32.dll");
|
module = (HMODULE)::LoadLibrary("wsock32.dll");
|
||||||
if (module == NULL) {
|
if (module == NULL) {
|
||||||
log((CLOG_NOTE "wsock32.dll not found"));
|
LOG((CLOG_NOTE "wsock32.dll not found"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
|
@ -108,7 +108,7 @@ CNetwork::init()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (XNetwork& e) {
|
catch (XNetwork& e) {
|
||||||
log((CLOG_NOTE "wsock32.dll error: %s", e.what()));
|
LOG((CLOG_NOTE "wsock32.dll error: %s", e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,10 @@ CMSWindowsClipboard::~CMSWindowsClipboard()
|
||||||
bool
|
bool
|
||||||
CMSWindowsClipboard::empty()
|
CMSWindowsClipboard::empty()
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "empty clipboard"));
|
LOG((CLOG_DEBUG "empty clipboard"));
|
||||||
|
|
||||||
if (!EmptyClipboard()) {
|
if (!EmptyClipboard()) {
|
||||||
log((CLOG_DEBUG "failed to grab clipboard"));
|
LOG((CLOG_DEBUG "failed to grab clipboard"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ CMSWindowsClipboard::empty()
|
||||||
void
|
void
|
||||||
CMSWindowsClipboard::add(EFormat format, const CString& data)
|
CMSWindowsClipboard::add(EFormat format, const CString& data)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format));
|
LOG((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format));
|
||||||
|
|
||||||
// convert data to win32 form
|
// convert data to win32 form
|
||||||
for (ConverterList::const_iterator index = m_converters.begin();
|
for (ConverterList::const_iterator index = m_converters.begin();
|
||||||
|
@ -76,10 +76,10 @@ CMSWindowsClipboard::add(EFormat format, const CString& data)
|
||||||
bool
|
bool
|
||||||
CMSWindowsClipboard::open(Time time) const
|
CMSWindowsClipboard::open(Time time) const
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "open clipboard"));
|
LOG((CLOG_DEBUG "open clipboard"));
|
||||||
|
|
||||||
if (!OpenClipboard(m_window)) {
|
if (!OpenClipboard(m_window)) {
|
||||||
log((CLOG_WARN "failed to open clipboard"));
|
LOG((CLOG_WARN "failed to open clipboard"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ CMSWindowsClipboard::open(Time time) const
|
||||||
void
|
void
|
||||||
CMSWindowsClipboard::close() const
|
CMSWindowsClipboard::close() const
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "close clipboard"));
|
LOG((CLOG_DEBUG "close clipboard"));
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ CMSWindowsScreen::open()
|
||||||
assert(s_instance != NULL);
|
assert(s_instance != NULL);
|
||||||
assert(m_class == 0);
|
assert(m_class == 0);
|
||||||
|
|
||||||
log((CLOG_DEBUG "opening display"));
|
LOG((CLOG_DEBUG "opening display"));
|
||||||
|
|
||||||
// create the transparent cursor
|
// create the transparent cursor
|
||||||
createBlankCursor();
|
createBlankCursor();
|
||||||
|
@ -253,7 +253,7 @@ CMSWindowsScreen::close()
|
||||||
m_cursor = NULL;
|
m_cursor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
log((CLOG_DEBUG "closed display"));
|
LOG((CLOG_DEBUG "closed display"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -349,7 +349,7 @@ CMSWindowsScreen::syncDesktop()
|
||||||
// change calling thread's desktop
|
// change calling thread's desktop
|
||||||
if (!m_is95Family) {
|
if (!m_is95Family) {
|
||||||
if (SetThreadDesktop(m_desk) == 0) {
|
if (SetThreadDesktop(m_desk) == 0) {
|
||||||
// log((CLOG_WARN "failed to set desktop: %d", GetLastError()));
|
// LOG((CLOG_WARN "failed to set desktop: %d", GetLastError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ CMSWindowsScreen::updateScreenShape()
|
||||||
m_y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
m_y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||||
m_w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
m_w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||||
m_h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
m_h = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||||
log((CLOG_INFO "screen shape: %d,%d %dx%d", m_x, m_y, m_w, m_h));
|
LOG((CLOG_INFO "screen shape: %d,%d %dx%d", m_x, m_y, m_w, m_h));
|
||||||
|
|
||||||
// check for multiple monitors
|
// check for multiple monitors
|
||||||
m_multimon = (m_w != GetSystemMetrics(SM_CXSCREEN) ||
|
m_multimon = (m_w != GetSystemMetrics(SM_CXSCREEN) ||
|
||||||
|
@ -504,7 +504,7 @@ CMSWindowsScreen::onEvent(CEvent* event)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case WM_DRAWCLIPBOARD:
|
case WM_DRAWCLIPBOARD:
|
||||||
log((CLOG_DEBUG "clipboard was taken"));
|
LOG((CLOG_DEBUG "clipboard was taken"));
|
||||||
|
|
||||||
// first pass it on
|
// first pass it on
|
||||||
if (m_nextClipboardWindow != NULL) {
|
if (m_nextClipboardWindow != NULL) {
|
||||||
|
@ -615,7 +615,7 @@ CMSWindowsScreen::switchDesktop(HDESK desk)
|
||||||
|
|
||||||
// if no new desktop then we're done
|
// if no new desktop then we're done
|
||||||
if (desk == NULL) {
|
if (desk == NULL) {
|
||||||
log((CLOG_INFO "disconnecting desktop"));
|
LOG((CLOG_INFO "disconnecting desktop"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,7 +629,7 @@ CMSWindowsScreen::switchDesktop(HDESK desk)
|
||||||
// set the desktop. can only do this when there are no windows
|
// set the desktop. can only do this when there are no windows
|
||||||
// and hooks on the current desktop owned by this thread.
|
// and hooks on the current desktop owned by this thread.
|
||||||
if (SetThreadDesktop(desk) == 0) {
|
if (SetThreadDesktop(desk) == 0) {
|
||||||
log((CLOG_ERR "failed to set desktop: %d", GetLastError()));
|
LOG((CLOG_ERR "failed to set desktop: %d", GetLastError()));
|
||||||
if (!m_is95Family) {
|
if (!m_is95Family) {
|
||||||
CloseDesktop(desk);
|
CloseDesktop(desk);
|
||||||
}
|
}
|
||||||
|
@ -648,7 +648,7 @@ CMSWindowsScreen::switchDesktop(HDESK desk)
|
||||||
getInstance(),
|
getInstance(),
|
||||||
NULL);
|
NULL);
|
||||||
if (m_window == NULL) {
|
if (m_window == NULL) {
|
||||||
log((CLOG_ERR "failed to create window: %d", GetLastError()));
|
LOG((CLOG_ERR "failed to create window: %d", GetLastError()));
|
||||||
if (!m_is95Family) {
|
if (!m_is95Family) {
|
||||||
CloseDesktop(desk);
|
CloseDesktop(desk);
|
||||||
}
|
}
|
||||||
|
@ -675,7 +675,7 @@ CMSWindowsScreen::switchDesktop(HDESK desk)
|
||||||
// save new desktop
|
// save new desktop
|
||||||
m_desk = desk;
|
m_desk = desk;
|
||||||
m_deskName = getDesktopName(m_desk);
|
m_deskName = getDesktopName(m_desk);
|
||||||
log((CLOG_INFO "switched to desktop \"%s\"", m_deskName.c_str()));
|
LOG((CLOG_INFO "switched to desktop \"%s\"", m_deskName.c_str()));
|
||||||
|
|
||||||
// let client prepare the window
|
// let client prepare the window
|
||||||
m_eventHandler->postCreateWindow(m_window);
|
m_eventHandler->postCreateWindow(m_window);
|
||||||
|
|
|
@ -73,7 +73,7 @@ CMSWindowsScreenSaver::checkStarted(UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
HWND hwnd = findScreenSaver();
|
HWND hwnd = findScreenSaver();
|
||||||
if (hwnd == NULL) {
|
if (hwnd == NULL) {
|
||||||
// didn't start
|
// didn't start
|
||||||
log((CLOG_DEBUG "can't find screen saver window"));
|
LOG((CLOG_DEBUG "can't find screen saver window"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ CMSWindowsScreenSaver::checkStarted(UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, processID);
|
HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, processID);
|
||||||
if (process == NULL) {
|
if (process == NULL) {
|
||||||
// didn't start
|
// didn't start
|
||||||
log((CLOG_DEBUG "can't open screen saver process"));
|
LOG((CLOG_DEBUG "can't open screen saver process"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ CMSWindowsScreenSaver::watchProcess(HANDLE process)
|
||||||
|
|
||||||
// watch new process in another thread
|
// watch new process in another thread
|
||||||
if (process != NULL) {
|
if (process != NULL) {
|
||||||
log((CLOG_DEBUG "watching screen saver process"));
|
LOG((CLOG_DEBUG "watching screen saver process"));
|
||||||
m_process = process;
|
m_process = process;
|
||||||
m_watch = new CThread(new TMethodJob<CMSWindowsScreenSaver>(this,
|
m_watch = new CThread(new TMethodJob<CMSWindowsScreenSaver>(this,
|
||||||
&CMSWindowsScreenSaver::watchProcessThread));
|
&CMSWindowsScreenSaver::watchProcessThread));
|
||||||
|
@ -284,7 +284,7 @@ void
|
||||||
CMSWindowsScreenSaver::unwatchProcess()
|
CMSWindowsScreenSaver::unwatchProcess()
|
||||||
{
|
{
|
||||||
if (m_watch != NULL) {
|
if (m_watch != NULL) {
|
||||||
log((CLOG_DEBUG "stopped watching screen saver process"));
|
LOG((CLOG_DEBUG "stopped watching screen saver process"));
|
||||||
m_watch->cancel();
|
m_watch->cancel();
|
||||||
m_watch->wait();
|
m_watch->wait();
|
||||||
delete m_watch;
|
delete m_watch;
|
||||||
|
@ -304,7 +304,7 @@ CMSWindowsScreenSaver::watchProcessThread(void*)
|
||||||
if (WaitForSingleObject(m_process, 50) == WAIT_OBJECT_0) {
|
if (WaitForSingleObject(m_process, 50) == WAIT_OBJECT_0) {
|
||||||
// process terminated. send screen saver deactivation
|
// process terminated. send screen saver deactivation
|
||||||
// message.
|
// message.
|
||||||
log((CLOG_DEBUG "screen saver died"));
|
LOG((CLOG_DEBUG "screen saver died"));
|
||||||
PostThreadMessage(m_threadID, m_msg, m_wParam, m_lParam);
|
PostThreadMessage(m_threadID, m_msg, m_wParam, m_lParam);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ CWin32Platform::isWindows95Family()
|
||||||
OSVERSIONINFO version;
|
OSVERSIONINFO version;
|
||||||
version.dwOSVersionInfoSize = sizeof(version);
|
version.dwOSVersionInfoSize = sizeof(version);
|
||||||
if (GetVersionEx(&version) == 0) {
|
if (GetVersionEx(&version) == 0) {
|
||||||
log((CLOG_WARN "cannot determine OS: %d", GetLastError()));
|
LOG((CLOG_WARN "cannot determine OS: %d", GetLastError()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return (version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
|
return (version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
|
||||||
|
@ -103,7 +103,7 @@ CWin32Platform::installDaemon(const char* name, const char* description,
|
||||||
HKEY key = isWindows95Family() ? open95ServicesKey() :
|
HKEY key = isWindows95Family() ? open95ServicesKey() :
|
||||||
openUserStartupKey();
|
openUserStartupKey();
|
||||||
if (key == NULL) {
|
if (key == NULL) {
|
||||||
log((CLOG_ERR "cannot open registry key", GetLastError()));
|
LOG((CLOG_ERR "cannot open registry key", GetLastError()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ CWin32Platform::installDaemon(const char* name, const char* description,
|
||||||
// open service manager
|
// open service manager
|
||||||
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
|
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
|
||||||
if (mgr == NULL) {
|
if (mgr == NULL) {
|
||||||
log((CLOG_ERR "OpenSCManager failed with %d", GetLastError()));
|
LOG((CLOG_ERR "OpenSCManager failed with %d", GetLastError()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ CWin32Platform::installDaemon(const char* name, const char* description,
|
||||||
else {
|
else {
|
||||||
// FIXME -- handle ERROR_SERVICE_EXISTS
|
// FIXME -- handle ERROR_SERVICE_EXISTS
|
||||||
|
|
||||||
log((CLOG_ERR "CreateService failed with %d", GetLastError()));
|
LOG((CLOG_ERR "CreateService failed with %d", GetLastError()));
|
||||||
CloseServiceHandle(mgr);
|
CloseServiceHandle(mgr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ CWin32Platform::uninstallDaemon(const char* name, bool allUsers)
|
||||||
HKEY key = isWindows95Family() ? open95ServicesKey() :
|
HKEY key = isWindows95Family() ? open95ServicesKey() :
|
||||||
openUserStartupKey();
|
openUserStartupKey();
|
||||||
if (key == NULL) {
|
if (key == NULL) {
|
||||||
log((CLOG_ERR "cannot open registry key", GetLastError()));
|
LOG((CLOG_ERR "cannot open registry key", GetLastError()));
|
||||||
return kAlready;
|
return kAlready;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ CWin32Platform::uninstallDaemon(const char* name, bool allUsers)
|
||||||
// open service manager
|
// open service manager
|
||||||
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
|
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
|
||||||
if (mgr == NULL) {
|
if (mgr == NULL) {
|
||||||
log((CLOG_ERR "OpenSCManager failed with %d", GetLastError()));
|
LOG((CLOG_ERR "OpenSCManager failed with %d", GetLastError()));
|
||||||
return kFailed;
|
return kFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ CWin32Platform::uninstallDaemon(const char* name, bool allUsers)
|
||||||
SC_HANDLE service = OpenService(mgr, name, DELETE);
|
SC_HANDLE service = OpenService(mgr, name, DELETE);
|
||||||
if (service == NULL) {
|
if (service == NULL) {
|
||||||
const DWORD e = GetLastError();
|
const DWORD e = GetLastError();
|
||||||
log((CLOG_ERR "OpenService failed with %d", e));
|
LOG((CLOG_ERR "OpenService failed with %d", e));
|
||||||
result = (e == ERROR_SERVICE_DOES_NOT_EXIST) ? kAlready : kFailed;
|
result = (e == ERROR_SERVICE_DOES_NOT_EXIST) ? kAlready : kFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ CWin32Platform::daemonize(const char* name, DaemonFunc func)
|
||||||
// user logs off.
|
// user logs off.
|
||||||
HINSTANCE kernel = LoadLibrary("kernel32.dll");
|
HINSTANCE kernel = LoadLibrary("kernel32.dll");
|
||||||
if (kernel == NULL) {
|
if (kernel == NULL) {
|
||||||
log((CLOG_ERR "LoadLibrary failed with %d", GetLastError()));
|
LOG((CLOG_ERR "LoadLibrary failed with %d", GetLastError()));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
RegisterServiceProcessT RegisterServiceProcess =
|
RegisterServiceProcessT RegisterServiceProcess =
|
||||||
|
@ -286,12 +286,12 @@ CWin32Platform::daemonize(const char* name, DaemonFunc func)
|
||||||
GetProcAddress(kernel,
|
GetProcAddress(kernel,
|
||||||
_T("RegisterServiceProcess")));
|
_T("RegisterServiceProcess")));
|
||||||
if (RegisterServiceProcess == NULL) {
|
if (RegisterServiceProcess == NULL) {
|
||||||
log((CLOG_ERR "can't lookup RegisterServiceProcess: %d", GetLastError()));
|
LOG((CLOG_ERR "can't lookup RegisterServiceProcess: %d", GetLastError()));
|
||||||
FreeLibrary(kernel);
|
FreeLibrary(kernel);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (RegisterServiceProcess(NULL, 1) == 0) {
|
if (RegisterServiceProcess(NULL, 1) == 0) {
|
||||||
log((CLOG_ERR "RegisterServiceProcess failed with %d", GetLastError()));
|
LOG((CLOG_ERR "RegisterServiceProcess failed with %d", GetLastError()));
|
||||||
FreeLibrary(kernel);
|
FreeLibrary(kernel);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ CWin32Platform::daemonize(const char* name, DaemonFunc func)
|
||||||
s_daemonPlatform = NULL;
|
s_daemonPlatform = NULL;
|
||||||
return m_daemonResult;
|
return m_daemonResult;
|
||||||
}
|
}
|
||||||
log((CLOG_ERR "StartServiceCtrlDispatcher failed with %d", GetLastError()));
|
LOG((CLOG_ERR "StartServiceCtrlDispatcher failed with %d", GetLastError()));
|
||||||
s_daemonPlatform = NULL;
|
s_daemonPlatform = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -943,7 +943,7 @@ CWin32Platform::serviceHandler(DWORD ctrl)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log((CLOG_WARN "unknown service command: %d", ctrl));
|
LOG((CLOG_WARN "unknown service command: %d", ctrl));
|
||||||
// fall through
|
// fall through
|
||||||
|
|
||||||
case SERVICE_CONTROL_INTERROGATE:
|
case SERVICE_CONTROL_INTERROGATE:
|
||||||
|
|
|
@ -93,7 +93,7 @@ CXWindowsClipboard::~CXWindowsClipboard()
|
||||||
void
|
void
|
||||||
CXWindowsClipboard::lost(Time time)
|
CXWindowsClipboard::lost(Time time)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "lost clipboard %d ownership at %d", m_id, time));
|
LOG((CLOG_DEBUG "lost clipboard %d ownership at %d", m_id, time));
|
||||||
if (m_owner) {
|
if (m_owner) {
|
||||||
m_owner = false;
|
m_owner = false;
|
||||||
m_timeLost = time;
|
m_timeLost = time;
|
||||||
|
@ -109,7 +109,7 @@ CXWindowsClipboard::addRequest(Window owner, Window requestor,
|
||||||
// at the given time.
|
// at the given time.
|
||||||
bool success = false;
|
bool success = false;
|
||||||
if (owner == m_window) {
|
if (owner == m_window) {
|
||||||
log((CLOG_DEBUG1 "request for clipboard %d, target %d by 0x%08x (property=%d)", m_selection, target, requestor, property));
|
LOG((CLOG_DEBUG1 "request for clipboard %d, target %d by 0x%08x (property=%d)", m_selection, target, requestor, property));
|
||||||
if (wasOwnedAtTime(time)) {
|
if (wasOwnedAtTime(time)) {
|
||||||
if (target == m_atomMultiple) {
|
if (target == m_atomMultiple) {
|
||||||
// add a multiple request. property may not be None
|
// add a multiple request. property may not be None
|
||||||
|
@ -126,13 +126,13 @@ CXWindowsClipboard::addRequest(Window owner, Window requestor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log((CLOG_DEBUG1 "failed, not owned at time %d", time));
|
LOG((CLOG_DEBUG1 "failed, not owned at time %d", time));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
// send failure
|
// send failure
|
||||||
log((CLOG_DEBUG1 "failed"));
|
LOG((CLOG_DEBUG1 "failed"));
|
||||||
insertReply(new CReply(requestor, target, time));
|
insertReply(new CReply(requestor, target, time));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,14 +180,14 @@ CXWindowsClipboard::addSimpleRequest(Window requestor,
|
||||||
|
|
||||||
if (type != None) {
|
if (type != None) {
|
||||||
// success
|
// success
|
||||||
log((CLOG_DEBUG1 "success"));
|
LOG((CLOG_DEBUG1 "success"));
|
||||||
insertReply(new CReply(requestor, target, time,
|
insertReply(new CReply(requestor, target, time,
|
||||||
property, data, type, format));
|
property, data, type, format));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// failure
|
// failure
|
||||||
log((CLOG_DEBUG1 "failed"));
|
LOG((CLOG_DEBUG1 "failed"));
|
||||||
insertReply(new CReply(requestor, target, time));
|
insertReply(new CReply(requestor, target, time));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ CXWindowsClipboard::processRequest(Window requestor,
|
||||||
// unknown requestor window
|
// unknown requestor window
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
log((CLOG_DEBUG1 "received property %d delete from 0x08%x", property, requestor));
|
LOG((CLOG_DEBUG1 "received property %d delete from 0x08%x", property, requestor));
|
||||||
|
|
||||||
// find the property in the known requests. it should be the
|
// find the property in the known requests. it should be the
|
||||||
// first property but we'll check 'em all if we have to.
|
// first property but we'll check 'em all if we have to.
|
||||||
|
@ -257,12 +257,12 @@ CXWindowsClipboard::empty()
|
||||||
{
|
{
|
||||||
assert(m_open);
|
assert(m_open);
|
||||||
|
|
||||||
log((CLOG_DEBUG "empty clipboard %d", m_id));
|
LOG((CLOG_DEBUG "empty clipboard %d", m_id));
|
||||||
|
|
||||||
// assert ownership of clipboard
|
// assert ownership of clipboard
|
||||||
XSetSelectionOwner(m_display, m_selection, m_window, m_time);
|
XSetSelectionOwner(m_display, m_selection, m_window, m_time);
|
||||||
if (XGetSelectionOwner(m_display, m_selection) != m_window) {
|
if (XGetSelectionOwner(m_display, m_selection) != m_window) {
|
||||||
log((CLOG_DEBUG "failed to grab clipboard %d", m_id));
|
LOG((CLOG_DEBUG "failed to grab clipboard %d", m_id));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ CXWindowsClipboard::empty()
|
||||||
|
|
||||||
// we're the owner now
|
// we're the owner now
|
||||||
m_owner = true;
|
m_owner = true;
|
||||||
log((CLOG_DEBUG "grabbed clipboard %d", m_id));
|
LOG((CLOG_DEBUG "grabbed clipboard %d", m_id));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ CXWindowsClipboard::add(EFormat format, const CString& data)
|
||||||
assert(m_open);
|
assert(m_open);
|
||||||
assert(m_owner);
|
assert(m_owner);
|
||||||
|
|
||||||
log((CLOG_DEBUG "add %d bytes to clipboard %d format: %d", data.size(), m_id, format));
|
LOG((CLOG_DEBUG "add %d bytes to clipboard %d format: %d", data.size(), m_id, format));
|
||||||
|
|
||||||
m_data[format] = data;
|
m_data[format] = data;
|
||||||
m_added[format] = true;
|
m_added[format] = true;
|
||||||
|
@ -304,7 +304,7 @@ CXWindowsClipboard::open(Time time) const
|
||||||
{
|
{
|
||||||
assert(!m_open);
|
assert(!m_open);
|
||||||
|
|
||||||
log((CLOG_DEBUG "open clipboard %d", m_id));
|
LOG((CLOG_DEBUG "open clipboard %d", m_id));
|
||||||
|
|
||||||
// assume not motif
|
// assume not motif
|
||||||
m_motif = false;
|
m_motif = false;
|
||||||
|
@ -318,7 +318,7 @@ CXWindowsClipboard::open(Time time) const
|
||||||
// check if motif owns the selection. unlock motif clipboard
|
// check if motif owns the selection. unlock motif clipboard
|
||||||
// if it does not.
|
// if it does not.
|
||||||
m_motif = motifOwnsClipboard();
|
m_motif = motifOwnsClipboard();
|
||||||
log((CLOG_DEBUG1 "motif does %sown clipboard", m_motif ? "" : "not "));
|
LOG((CLOG_DEBUG1 "motif does %sown clipboard", m_motif ? "" : "not "));
|
||||||
if (!m_motif) {
|
if (!m_motif) {
|
||||||
motifUnlockClipboard();
|
motifUnlockClipboard();
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ CXWindowsClipboard::close() const
|
||||||
{
|
{
|
||||||
assert(m_open);
|
assert(m_open);
|
||||||
|
|
||||||
log((CLOG_DEBUG "close clipboard %d", m_id));
|
LOG((CLOG_DEBUG "close clipboard %d", m_id));
|
||||||
|
|
||||||
// unlock clipboard
|
// unlock clipboard
|
||||||
if (m_motif) {
|
if (m_motif) {
|
||||||
|
@ -397,14 +397,14 @@ CXWindowsClipboard::getConverter(Atom target, bool onlyIfNotAdded) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (converter == NULL) {
|
if (converter == NULL) {
|
||||||
log((CLOG_DEBUG1 " no converter for target %d", target));
|
LOG((CLOG_DEBUG1 " no converter for target %d", target));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// optionally skip already handled targets
|
// optionally skip already handled targets
|
||||||
if (onlyIfNotAdded) {
|
if (onlyIfNotAdded) {
|
||||||
if (m_added[converter->getFormat()]) {
|
if (m_added[converter->getFormat()]) {
|
||||||
log((CLOG_DEBUG1 " skipping handled format %d", converter->getFormat()));
|
LOG((CLOG_DEBUG1 " skipping handled format %d", converter->getFormat()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -484,7 +484,7 @@ CXWindowsClipboard::doFillCache()
|
||||||
void
|
void
|
||||||
CXWindowsClipboard::icccmFillCache()
|
CXWindowsClipboard::icccmFillCache()
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "ICCCM fill clipboard %d", m_id));
|
LOG((CLOG_DEBUG "ICCCM fill clipboard %d", m_id));
|
||||||
|
|
||||||
// see if we can get the list of available formats from the selection.
|
// see if we can get the list of available formats from the selection.
|
||||||
// if not then use a default list of formats.
|
// if not then use a default list of formats.
|
||||||
|
@ -493,7 +493,7 @@ CXWindowsClipboard::icccmFillCache()
|
||||||
CString data;
|
CString data;
|
||||||
if (!icccmGetSelection(atomTargets, &target, &data) ||
|
if (!icccmGetSelection(atomTargets, &target, &data) ||
|
||||||
target != m_atomAtom) {
|
target != m_atomAtom) {
|
||||||
log((CLOG_DEBUG1 "selection doesn't support TARGETS"));
|
LOG((CLOG_DEBUG1 "selection doesn't support TARGETS"));
|
||||||
data = "";
|
data = "";
|
||||||
|
|
||||||
target = XA_STRING;
|
target = XA_STRING;
|
||||||
|
@ -529,7 +529,7 @@ CXWindowsClipboard::icccmFillCache()
|
||||||
Atom actualTarget;
|
Atom actualTarget;
|
||||||
CString targetData;
|
CString targetData;
|
||||||
if (!icccmGetSelection(target, &actualTarget, &targetData)) {
|
if (!icccmGetSelection(target, &actualTarget, &targetData)) {
|
||||||
log((CLOG_DEBUG1 " no data for target %d", target));
|
LOG((CLOG_DEBUG1 " no data for target %d", target));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,7 +537,7 @@ CXWindowsClipboard::icccmFillCache()
|
||||||
IClipboard::EFormat format = converter->getFormat();
|
IClipboard::EFormat format = converter->getFormat();
|
||||||
m_data[format] = converter->toIClipboard(targetData);
|
m_data[format] = converter->toIClipboard(targetData);
|
||||||
m_added[format] = true;
|
m_added[format] = true;
|
||||||
log((CLOG_DEBUG " added format %d for target %d", format, target));
|
LOG((CLOG_DEBUG " added format %d for target %d", format, target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,12 +552,12 @@ CXWindowsClipboard::icccmGetSelection(Atom target,
|
||||||
CICCCMGetClipboard getter(m_window, m_time, m_atomData);
|
CICCCMGetClipboard getter(m_window, m_time, m_atomData);
|
||||||
if (!getter.readClipboard(m_display, m_selection,
|
if (!getter.readClipboard(m_display, m_selection,
|
||||||
target, actualTarget, data)) {
|
target, actualTarget, data)) {
|
||||||
log((CLOG_DEBUG1 "can't get data for selection target %d", target));
|
LOG((CLOG_DEBUG1 "can't get data for selection target %d", target));
|
||||||
logc(getter.m_error, (CLOG_WARN "ICCCM violation by clipboard owner"));
|
LOGC(getter.m_error, (CLOG_WARN "ICCCM violation by clipboard owner"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (*actualTarget == None) {
|
else if (*actualTarget == None) {
|
||||||
log((CLOG_DEBUG1 "selection conversion failed for target %d", target));
|
LOG((CLOG_DEBUG1 "selection conversion failed for target %d", target));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -571,12 +571,12 @@ CXWindowsClipboard::icccmGetTime() const
|
||||||
if (icccmGetSelection(m_atomTimestamp, &actualTarget, &data) &&
|
if (icccmGetSelection(m_atomTimestamp, &actualTarget, &data) &&
|
||||||
actualTarget == m_atomInteger) {
|
actualTarget == m_atomInteger) {
|
||||||
Time time = *reinterpret_cast<const Time*>(data.data());
|
Time time = *reinterpret_cast<const Time*>(data.data());
|
||||||
log((CLOG_DEBUG1 "got ICCCM time %d", time));
|
LOG((CLOG_DEBUG1 "got ICCCM time %d", time));
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// no timestamp
|
// no timestamp
|
||||||
log((CLOG_DEBUG1 "can't get ICCCM time"));
|
LOG((CLOG_DEBUG1 "can't get ICCCM time"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -587,7 +587,7 @@ CXWindowsClipboard::motifLockClipboard() const
|
||||||
// fail if anybody owns the lock (even us, so this is non-recursive)
|
// fail if anybody owns the lock (even us, so this is non-recursive)
|
||||||
Window lockOwner = XGetSelectionOwner(m_display, m_atomMotifClipLock);
|
Window lockOwner = XGetSelectionOwner(m_display, m_atomMotifClipLock);
|
||||||
if (lockOwner != None) {
|
if (lockOwner != None) {
|
||||||
log((CLOG_DEBUG1 "motif lock owner 0x%08x", lockOwner));
|
LOG((CLOG_DEBUG1 "motif lock owner 0x%08x", lockOwner));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,18 +599,18 @@ CXWindowsClipboard::motifLockClipboard() const
|
||||||
XSetSelectionOwner(m_display, m_atomMotifClipLock, m_window, time);
|
XSetSelectionOwner(m_display, m_atomMotifClipLock, m_window, time);
|
||||||
lockOwner = XGetSelectionOwner(m_display, m_atomMotifClipLock);
|
lockOwner = XGetSelectionOwner(m_display, m_atomMotifClipLock);
|
||||||
if (lockOwner != m_window) {
|
if (lockOwner != m_window) {
|
||||||
log((CLOG_DEBUG1 "motif lock owner 0x%08x", lockOwner));
|
LOG((CLOG_DEBUG1 "motif lock owner 0x%08x", lockOwner));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log((CLOG_DEBUG1 "locked motif clipboard"));
|
LOG((CLOG_DEBUG1 "locked motif clipboard"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXWindowsClipboard::motifUnlockClipboard() const
|
CXWindowsClipboard::motifUnlockClipboard() const
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "unlocked motif clipboard"));
|
LOG((CLOG_DEBUG1 "unlocked motif clipboard"));
|
||||||
|
|
||||||
// fail if we don't own the lock
|
// fail if we don't own the lock
|
||||||
Window lockOwner = XGetSelectionOwner(m_display, m_atomMotifClipLock);
|
Window lockOwner = XGetSelectionOwner(m_display, m_atomMotifClipLock);
|
||||||
|
@ -662,7 +662,7 @@ CXWindowsClipboard::motifOwnsClipboard() const
|
||||||
void
|
void
|
||||||
CXWindowsClipboard::motifFillCache()
|
CXWindowsClipboard::motifFillCache()
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "Motif fill clipboard %d", m_id));
|
LOG((CLOG_DEBUG "Motif fill clipboard %d", m_id));
|
||||||
|
|
||||||
// get the Motif clipboard header property from the root window
|
// get the Motif clipboard header property from the root window
|
||||||
Atom target;
|
Atom target;
|
||||||
|
@ -767,7 +767,7 @@ CXWindowsClipboard::motifFillCache()
|
||||||
Atom actualTarget;
|
Atom actualTarget;
|
||||||
CString targetData;
|
CString targetData;
|
||||||
if (!motifGetSelection(motifFormat, &actualTarget, &targetData)) {
|
if (!motifGetSelection(motifFormat, &actualTarget, &targetData)) {
|
||||||
log((CLOG_DEBUG1 " no data for target %d", target));
|
LOG((CLOG_DEBUG1 " no data for target %d", target));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -775,7 +775,7 @@ CXWindowsClipboard::motifFillCache()
|
||||||
IClipboard::EFormat format = converter->getFormat();
|
IClipboard::EFormat format = converter->getFormat();
|
||||||
m_data[format] = converter->toIClipboard(targetData);
|
m_data[format] = converter->toIClipboard(targetData);
|
||||||
m_added[format] = true;
|
m_added[format] = true;
|
||||||
log((CLOG_DEBUG " added format %d for target %d", format, target));
|
LOG((CLOG_DEBUG " added format %d for target %d", format, target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,14 +957,14 @@ CXWindowsClipboard::sendReply(CReply* reply)
|
||||||
|
|
||||||
// bail out immediately if reply is done
|
// bail out immediately if reply is done
|
||||||
if (reply->m_done) {
|
if (reply->m_done) {
|
||||||
log((CLOG_DEBUG1 "clipboard: finished reply to 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property));
|
LOG((CLOG_DEBUG1 "clipboard: finished reply to 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// start in failed state if property is None
|
// start in failed state if property is None
|
||||||
bool failed = (reply->m_property == None);
|
bool failed = (reply->m_property == None);
|
||||||
if (!failed) {
|
if (!failed) {
|
||||||
log((CLOG_DEBUG1 "clipboard: setting property on 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property));
|
LOG((CLOG_DEBUG1 "clipboard: setting property on 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property));
|
||||||
|
|
||||||
// send using INCR if already sending incrementally or if reply
|
// send using INCR if already sending incrementally or if reply
|
||||||
// is too large, otherwise just send it.
|
// is too large, otherwise just send it.
|
||||||
|
@ -1013,7 +1013,7 @@ CXWindowsClipboard::sendReply(CReply* reply)
|
||||||
// the final zero-length property.
|
// the final zero-length property.
|
||||||
// FIXME -- how do you gracefully cancel an incremental transfer?
|
// FIXME -- how do you gracefully cancel an incremental transfer?
|
||||||
if (failed) {
|
if (failed) {
|
||||||
log((CLOG_DEBUG1 "clipboard: sending failure to 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property));
|
LOG((CLOG_DEBUG1 "clipboard: sending failure to 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property));
|
||||||
reply->m_done = true;
|
reply->m_done = true;
|
||||||
if (reply->m_property != None) {
|
if (reply->m_property != None) {
|
||||||
CXWindowsUtil::CErrorLock lock(m_display);
|
CXWindowsUtil::CErrorLock lock(m_display);
|
||||||
|
@ -1043,7 +1043,7 @@ CXWindowsClipboard::sendReply(CReply* reply)
|
||||||
|
|
||||||
// send notification if we haven't yet
|
// send notification if we haven't yet
|
||||||
if (!reply->m_replied) {
|
if (!reply->m_replied) {
|
||||||
log((CLOG_DEBUG1 "clipboard: sending notify to 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property));
|
LOG((CLOG_DEBUG1 "clipboard: sending notify to 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property));
|
||||||
reply->m_replied = true;
|
reply->m_replied = true;
|
||||||
|
|
||||||
// HACK -- work around apparent bug in lesstif, which doesn't
|
// HACK -- work around apparent bug in lesstif, which doesn't
|
||||||
|
@ -1219,7 +1219,7 @@ CXWindowsClipboard::CICCCMGetClipboard::readClipboard(Display* display,
|
||||||
assert(actualTarget != NULL);
|
assert(actualTarget != NULL);
|
||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
|
|
||||||
log((CLOG_DEBUG1 "request selection=%d, target=%d, window=%x", selection, target, m_requestor));
|
LOG((CLOG_DEBUG1 "request selection=%d, target=%d, window=%x", selection, target, m_requestor));
|
||||||
|
|
||||||
// save output pointers
|
// save output pointers
|
||||||
m_actualTarget = actualTarget;
|
m_actualTarget = actualTarget;
|
||||||
|
@ -1296,7 +1296,7 @@ CXWindowsClipboard::CICCCMGetClipboard::readClipboard(Display* display,
|
||||||
XSelectInput(display, m_requestor, attr.your_event_mask);
|
XSelectInput(display, m_requestor, attr.your_event_mask);
|
||||||
|
|
||||||
// return success or failure
|
// return success or failure
|
||||||
log((CLOG_DEBUG1 "request %s", m_failed ? "failed" : "succeeded"));
|
LOG((CLOG_DEBUG1 "request %s", m_failed ? "failed" : "succeeded"));
|
||||||
return !m_failed;
|
return !m_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1387,14 +1387,14 @@ CXWindowsClipboard::CICCCMGetClipboard::processEvent(
|
||||||
else if (m_incr) {
|
else if (m_incr) {
|
||||||
// if first incremental chunk then save target
|
// if first incremental chunk then save target
|
||||||
if (oldSize == 0) {
|
if (oldSize == 0) {
|
||||||
log((CLOG_DEBUG1 " INCR first chunk, target %d", target));
|
LOG((CLOG_DEBUG1 " INCR first chunk, target %d", target));
|
||||||
*m_actualTarget = target;
|
*m_actualTarget = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
// secondary chunks must have the same target
|
// secondary chunks must have the same target
|
||||||
else {
|
else {
|
||||||
if (target != *m_actualTarget) {
|
if (target != *m_actualTarget) {
|
||||||
log((CLOG_WARN " INCR target mismatch"));
|
LOG((CLOG_WARN " INCR target mismatch"));
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
m_error = true;
|
m_error = true;
|
||||||
}
|
}
|
||||||
|
@ -1402,20 +1402,20 @@ CXWindowsClipboard::CICCCMGetClipboard::processEvent(
|
||||||
|
|
||||||
// note if this is the final chunk
|
// note if this is the final chunk
|
||||||
if (m_data->size() == oldSize) {
|
if (m_data->size() == oldSize) {
|
||||||
log((CLOG_DEBUG1 " INCR final chunk: %d bytes total", m_data->size()));
|
LOG((CLOG_DEBUG1 " INCR final chunk: %d bytes total", m_data->size()));
|
||||||
m_done = true;
|
m_done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// not incremental; save the target.
|
// not incremental; save the target.
|
||||||
else {
|
else {
|
||||||
log((CLOG_DEBUG1 " target %d", target));
|
LOG((CLOG_DEBUG1 " target %d", target));
|
||||||
*m_actualTarget = target;
|
*m_actualTarget = target;
|
||||||
m_done = true;
|
m_done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this event has been processed
|
// this event has been processed
|
||||||
logc(!m_incr, (CLOG_DEBUG1 " got data, %d bytes", m_data->size()));
|
LOGC(!m_incr, (CLOG_DEBUG1 " got data, %d bytes", m_data->size()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ CXWindowsScreen::open()
|
||||||
}
|
}
|
||||||
|
|
||||||
// open the display
|
// open the display
|
||||||
log((CLOG_DEBUG "XOpenDisplay(\"%s\")", display));
|
LOG((CLOG_DEBUG "XOpenDisplay(\"%s\")", display));
|
||||||
m_display = XOpenDisplay(display);
|
m_display = XOpenDisplay(display);
|
||||||
if (m_display == NULL) {
|
if (m_display == NULL) {
|
||||||
throw XScreenUnavailable(60.0);
|
throw XScreenUnavailable(60.0);
|
||||||
|
@ -337,7 +337,7 @@ CXWindowsScreen::close()
|
||||||
if (m_display != NULL) {
|
if (m_display != NULL) {
|
||||||
XCloseDisplay(m_display);
|
XCloseDisplay(m_display);
|
||||||
m_display = NULL;
|
m_display = NULL;
|
||||||
log((CLOG_DEBUG "closed display"));
|
LOG((CLOG_DEBUG "closed display"));
|
||||||
}
|
}
|
||||||
XSetIOErrorHandler(NULL);
|
XSetIOErrorHandler(NULL);
|
||||||
}
|
}
|
||||||
|
@ -495,7 +495,7 @@ CXWindowsScreen::updateScreenShape()
|
||||||
m_y = 0;
|
m_y = 0;
|
||||||
m_w = WidthOfScreen(DefaultScreenOfDisplay(m_display));
|
m_w = WidthOfScreen(DefaultScreenOfDisplay(m_display));
|
||||||
m_h = HeightOfScreen(DefaultScreenOfDisplay(m_display));
|
m_h = HeightOfScreen(DefaultScreenOfDisplay(m_display));
|
||||||
log((CLOG_INFO "screen shape: %d,%d %dx%d", m_x, m_y, m_w, m_h));
|
LOG((CLOG_INFO "screen shape: %d,%d %dx%d", m_x, m_y, m_w, m_h));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -519,7 +519,7 @@ CXWindowsScreen::onPreDispatch(CEvent* event)
|
||||||
// selection owner. report that to the receiver.
|
// selection owner. report that to the receiver.
|
||||||
ClipboardID id = getClipboardID(xevent->xselectionclear.selection);
|
ClipboardID id = getClipboardID(xevent->xselectionclear.selection);
|
||||||
if (id != kClipboardEnd) {
|
if (id != kClipboardEnd) {
|
||||||
log((CLOG_DEBUG "lost clipboard %d ownership at time %d", id, xevent->xselectionclear.time));
|
LOG((CLOG_DEBUG "lost clipboard %d ownership at time %d", id, xevent->xselectionclear.time));
|
||||||
m_clipboard[id]->lost(xevent->xselectionclear.time);
|
m_clipboard[id]->lost(xevent->xselectionclear.time);
|
||||||
m_receiver->onGrabClipboard(id);
|
m_receiver->onGrabClipboard(id);
|
||||||
return true;
|
return true;
|
||||||
|
@ -724,10 +724,10 @@ CXWindowsScreen::ioErrorHandler(Display*)
|
||||||
// handle not having a Display* anymore. we'll simply log the
|
// handle not having a Display* anymore. we'll simply log the
|
||||||
// error, notify the subclass (which must not use the display
|
// error, notify the subclass (which must not use the display
|
||||||
// so we set it to NULL), and exit.
|
// so we set it to NULL), and exit.
|
||||||
log((CLOG_WARN "X display has unexpectedly disconnected"));
|
LOG((CLOG_WARN "X display has unexpectedly disconnected"));
|
||||||
s_screen->m_display = NULL;
|
s_screen->m_display = NULL;
|
||||||
s_screen->m_receiver->onError();
|
s_screen->m_receiver->onError();
|
||||||
log((CLOG_CRIT "quiting due to X display disconnection"));
|
LOG((CLOG_CRIT "quiting due to X display disconnection"));
|
||||||
exit(17);
|
exit(17);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ CXWindowsScreenSaver::CXWindowsScreenSaver(
|
||||||
CWDontPropagate | CWEventMask |
|
CWDontPropagate | CWEventMask |
|
||||||
CWOverrideRedirect,
|
CWOverrideRedirect,
|
||||||
&attr);
|
&attr);
|
||||||
log((CLOG_DEBUG "xscreensaver sink window is 0x%08x", m_xscreensaverSink));
|
LOG((CLOG_DEBUG "xscreensaver sink window is 0x%08x", m_xscreensaverSink));
|
||||||
|
|
||||||
// watch top-level windows for changes
|
// watch top-level windows for changes
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,7 @@ CXWindowsScreenSaver::CXWindowsScreenSaver(
|
||||||
m_rootEventMask = attr.your_event_mask;
|
m_rootEventMask = attr.your_event_mask;
|
||||||
XSelectInput(m_display, root, m_rootEventMask | SubstructureNotifyMask);
|
XSelectInput(m_display, root, m_rootEventMask | SubstructureNotifyMask);
|
||||||
if (error) {
|
if (error) {
|
||||||
log((CLOG_DEBUG "didn't set root event mask"));
|
LOG((CLOG_DEBUG "didn't set root event mask"));
|
||||||
m_rootEventMask = 0;
|
m_rootEventMask = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ CXWindowsScreenSaver::onPreDispatch(const XEvent* xevent)
|
||||||
case DestroyNotify:
|
case DestroyNotify:
|
||||||
if (xevent->xdestroywindow.window == m_xscreensaver) {
|
if (xevent->xdestroywindow.window == m_xscreensaver) {
|
||||||
// xscreensaver is gone
|
// xscreensaver is gone
|
||||||
log((CLOG_DEBUG "xscreensaver died"));
|
LOG((CLOG_DEBUG "xscreensaver died"));
|
||||||
setXScreenSaver(None);
|
setXScreenSaver(None);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ CXWindowsScreenSaver::findXScreenSaver()
|
||||||
void
|
void
|
||||||
CXWindowsScreenSaver::setXScreenSaver(Window window)
|
CXWindowsScreenSaver::setXScreenSaver(Window window)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "xscreensaver window: 0x%08x", window));
|
LOG((CLOG_DEBUG "xscreensaver window: 0x%08x", window));
|
||||||
|
|
||||||
// save window
|
// save window
|
||||||
m_xscreensaver = window;
|
m_xscreensaver = window;
|
||||||
|
@ -342,7 +342,7 @@ void
|
||||||
CXWindowsScreenSaver::setXScreenSaverActive(bool activated)
|
CXWindowsScreenSaver::setXScreenSaverActive(bool activated)
|
||||||
{
|
{
|
||||||
if (m_xscreensaverActive != activated) {
|
if (m_xscreensaverActive != activated) {
|
||||||
log((CLOG_DEBUG "xscreensaver %s", activated ? "activated" : "deactivated"));
|
LOG((CLOG_DEBUG "xscreensaver %s", activated ? "activated" : "deactivated"));
|
||||||
m_xscreensaverActive = activated;
|
m_xscreensaverActive = activated;
|
||||||
sendNotify(activated);
|
sendNotify(activated);
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ CXWindowsScreenSaver::sendXScreenSaverCommand(Atom cmd, long arg1, long arg2)
|
||||||
event.xclient.data.l[3] = 0;
|
event.xclient.data.l[3] = 0;
|
||||||
event.xclient.data.l[4] = 0;
|
event.xclient.data.l[4] = 0;
|
||||||
|
|
||||||
log((CLOG_DEBUG "send xscreensaver command: %d %d %d", (long)cmd, arg1, arg2));
|
LOG((CLOG_DEBUG "send xscreensaver command: %d %d %d", (long)cmd, arg1, arg2));
|
||||||
bool error = false;
|
bool error = false;
|
||||||
CXWindowsUtil::CErrorLock lock(m_display, &error);
|
CXWindowsUtil::CErrorLock lock(m_display, &error);
|
||||||
XSendEvent(m_display, m_xscreensaver, False, 0, &event);
|
XSendEvent(m_display, m_xscreensaver, False, 0, &event);
|
||||||
|
|
|
@ -99,11 +99,11 @@ CXWindowsUtil::getWindowProperty(Display* display, Window window,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == Success) {
|
if (result == Success) {
|
||||||
log((CLOG_DEBUG1 "read property %d on window 0x%08x: bytes=%d", property, window, (data == NULL) ? 0 : data->size()));
|
LOG((CLOG_DEBUG1 "read property %d on window 0x%08x: bytes=%d", property, window, (data == NULL) ? 0 : data->size()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log((CLOG_DEBUG1 "can't read property %d on window 0x%08x", property, window));
|
LOG((CLOG_DEBUG1 "can't read property %d on window 0x%08x", property, window));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,12 +265,12 @@ CXWindowsUtil::CErrorLock::internalHandler(Display* display, XErrorEvent* event)
|
||||||
void
|
void
|
||||||
CXWindowsUtil::CErrorLock::ignoreHandler(Display*, XErrorEvent* e, void*)
|
CXWindowsUtil::CErrorLock::ignoreHandler(Display*, XErrorEvent* e, void*)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "ignoring X error: %d", e->error_code));
|
LOG((CLOG_DEBUG1 "ignoring X error: %d", e->error_code));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXWindowsUtil::CErrorLock::saveHandler(Display*, XErrorEvent* e, void* flag)
|
CXWindowsUtil::CErrorLock::saveHandler(Display*, XErrorEvent* e, void* flag)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "flagging X error: %d", e->error_code));
|
LOG((CLOG_DEBUG1 "flagging X error: %d", e->error_code));
|
||||||
*reinterpret_cast<bool*>(flag) = true;
|
*reinterpret_cast<bool*>(flag) = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ void
|
||||||
CClientProxy1_0::open()
|
CClientProxy1_0::open()
|
||||||
{
|
{
|
||||||
// send request
|
// send request
|
||||||
log((CLOG_DEBUG1 "querying client \"%s\" info", getName().c_str()));
|
LOG((CLOG_DEBUG1 "querying client \"%s\" info", getName().c_str()));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgQInfo);
|
CProtocolUtil::writef(getOutputStream(), kMsgQInfo);
|
||||||
getOutputStream()->flush();
|
getOutputStream()->flush();
|
||||||
|
|
||||||
|
@ -86,14 +86,14 @@ CClientProxy1_0::mainLoop()
|
||||||
|
|
||||||
// check if client hungup
|
// check if client hungup
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
log((CLOG_NOTE "client \"%s\" disconnected", getName().c_str()));
|
LOG((CLOG_NOTE "client \"%s\" disconnected", getName().c_str()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if client has stopped sending heartbeats
|
// check if client has stopped sending heartbeats
|
||||||
if (n == (UInt32)-1) {
|
if (n == (UInt32)-1) {
|
||||||
if (kHeartDeath >= 0.0 && heartTimer.getTime() > kHeartDeath) {
|
if (kHeartDeath >= 0.0 && heartTimer.getTime() > kHeartDeath) {
|
||||||
log((CLOG_NOTE "client \"%s\" is dead", getName().c_str()));
|
LOG((CLOG_NOTE "client \"%s\" is dead", getName().c_str()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -104,14 +104,14 @@ CClientProxy1_0::mainLoop()
|
||||||
|
|
||||||
// verify we got an entire code
|
// verify we got an entire code
|
||||||
if (n != 4) {
|
if (n != 4) {
|
||||||
log((CLOG_ERR "incomplete message from \"%s\": %d bytes", getName().c_str(), n));
|
LOG((CLOG_ERR "incomplete message from \"%s\": %d bytes", getName().c_str(), n));
|
||||||
|
|
||||||
// client sent an incomplete message
|
// client sent an incomplete message
|
||||||
throw XBadClient();
|
throw XBadClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse message
|
// parse message
|
||||||
log((CLOG_DEBUG2 "msg from \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], code[3]));
|
LOG((CLOG_DEBUG2 "msg from \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], code[3]));
|
||||||
if (memcmp(code, kMsgDInfo, 4) == 0) {
|
if (memcmp(code, kMsgDInfo, 4) == 0) {
|
||||||
recvInfo(true);
|
recvInfo(true);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ CClientProxy1_0::mainLoop()
|
||||||
}
|
}
|
||||||
// note -- more message handlers go here
|
// note -- more message handlers go here
|
||||||
else {
|
else {
|
||||||
log((CLOG_ERR "invalid message from client \"%s\"", getName().c_str()));
|
LOG((CLOG_ERR "invalid message from client \"%s\"", getName().c_str()));
|
||||||
|
|
||||||
// unknown message
|
// unknown message
|
||||||
throw XBadClient();
|
throw XBadClient();
|
||||||
|
@ -138,7 +138,7 @@ CClientProxy1_0::mainLoop()
|
||||||
void
|
void
|
||||||
CClientProxy1_0::close()
|
CClientProxy1_0::close()
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "send close to \"%s\"", getName().c_str()));
|
LOG((CLOG_DEBUG1 "send close to \"%s\"", getName().c_str()));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgCClose);
|
CProtocolUtil::writef(getOutputStream(), kMsgCClose);
|
||||||
|
|
||||||
// force the close to be sent before we return
|
// force the close to be sent before we return
|
||||||
|
@ -149,7 +149,7 @@ void
|
||||||
CClientProxy1_0::enter(SInt32 xAbs, SInt32 yAbs,
|
CClientProxy1_0::enter(SInt32 xAbs, SInt32 yAbs,
|
||||||
UInt32 seqNum, KeyModifierMask mask, bool)
|
UInt32 seqNum, KeyModifierMask mask, bool)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "send enter to \"%s\", %d,%d %d %04x", getName().c_str(), xAbs, yAbs, seqNum, mask));
|
LOG((CLOG_DEBUG1 "send enter to \"%s\", %d,%d %d %04x", getName().c_str(), xAbs, yAbs, seqNum, mask));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgCEnter,
|
CProtocolUtil::writef(getOutputStream(), kMsgCEnter,
|
||||||
xAbs, yAbs, seqNum, mask);
|
xAbs, yAbs, seqNum, mask);
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ CClientProxy1_0::enter(SInt32 xAbs, SInt32 yAbs,
|
||||||
bool
|
bool
|
||||||
CClientProxy1_0::leave()
|
CClientProxy1_0::leave()
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "send leave to \"%s\"", getName().c_str()));
|
LOG((CLOG_DEBUG1 "send leave to \"%s\"", getName().c_str()));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgCLeave);
|
CProtocolUtil::writef(getOutputStream(), kMsgCLeave);
|
||||||
|
|
||||||
// we can never prevent the user from leaving
|
// we can never prevent the user from leaving
|
||||||
|
@ -173,7 +173,7 @@ CClientProxy1_0::setClipboard(ClipboardID id, const CString& data)
|
||||||
// this clipboard is now clean
|
// this clipboard is now clean
|
||||||
m_clipboardDirty[id] = false;
|
m_clipboardDirty[id] = false;
|
||||||
|
|
||||||
log((CLOG_DEBUG "send clipboard %d to \"%s\" size=%d", id, getName().c_str(), data.size()));
|
LOG((CLOG_DEBUG "send clipboard %d to \"%s\" size=%d", id, getName().c_str(), data.size()));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDClipboard, id, 0, &data);
|
CProtocolUtil::writef(getOutputStream(), kMsgDClipboard, id, 0, &data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ CClientProxy1_0::setClipboard(ClipboardID id, const CString& data)
|
||||||
void
|
void
|
||||||
CClientProxy1_0::grabClipboard(ClipboardID id)
|
CClientProxy1_0::grabClipboard(ClipboardID id)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "send grab clipboard %d to \"%s\"", id, getName().c_str()));
|
LOG((CLOG_DEBUG "send grab clipboard %d to \"%s\"", id, getName().c_str()));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgCClipboard, id, 0);
|
CProtocolUtil::writef(getOutputStream(), kMsgCClipboard, id, 0);
|
||||||
|
|
||||||
// this clipboard is now dirty
|
// this clipboard is now dirty
|
||||||
|
@ -199,56 +199,56 @@ CClientProxy1_0::setClipboardDirty(ClipboardID id, bool dirty)
|
||||||
void
|
void
|
||||||
CClientProxy1_0::keyDown(KeyID key, KeyModifierMask mask)
|
CClientProxy1_0::keyDown(KeyID key, KeyModifierMask mask)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "send key down to \"%s\" id=%d, mask=0x%04x", getName().c_str(), key, mask));
|
LOG((CLOG_DEBUG1 "send key down to \"%s\" id=%d, mask=0x%04x", getName().c_str(), key, mask));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDKeyDown, key, mask);
|
CProtocolUtil::writef(getOutputStream(), kMsgDKeyDown, key, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CClientProxy1_0::keyRepeat(KeyID key, KeyModifierMask mask, SInt32 count)
|
CClientProxy1_0::keyRepeat(KeyID key, KeyModifierMask mask, SInt32 count)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "send key repeat to \"%s\" id=%d, mask=0x%04x, count=%d", getName().c_str(), key, mask, count));
|
LOG((CLOG_DEBUG1 "send key repeat to \"%s\" id=%d, mask=0x%04x, count=%d", getName().c_str(), key, mask, count));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDKeyRepeat, key, mask, count);
|
CProtocolUtil::writef(getOutputStream(), kMsgDKeyRepeat, key, mask, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CClientProxy1_0::keyUp(KeyID key, KeyModifierMask mask)
|
CClientProxy1_0::keyUp(KeyID key, KeyModifierMask mask)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "send key up to \"%s\" id=%d, mask=0x%04x", getName().c_str(), key, mask));
|
LOG((CLOG_DEBUG1 "send key up to \"%s\" id=%d, mask=0x%04x", getName().c_str(), key, mask));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDKeyUp, key, mask);
|
CProtocolUtil::writef(getOutputStream(), kMsgDKeyUp, key, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CClientProxy1_0::mouseDown(ButtonID button)
|
CClientProxy1_0::mouseDown(ButtonID button)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "send mouse down to \"%s\" id=%d", getName().c_str(), button));
|
LOG((CLOG_DEBUG1 "send mouse down to \"%s\" id=%d", getName().c_str(), button));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDMouseDown, button);
|
CProtocolUtil::writef(getOutputStream(), kMsgDMouseDown, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CClientProxy1_0::mouseUp(ButtonID button)
|
CClientProxy1_0::mouseUp(ButtonID button)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "send mouse up to \"%s\" id=%d", getName().c_str(), button));
|
LOG((CLOG_DEBUG1 "send mouse up to \"%s\" id=%d", getName().c_str(), button));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDMouseUp, button);
|
CProtocolUtil::writef(getOutputStream(), kMsgDMouseUp, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CClientProxy1_0::mouseMove(SInt32 xAbs, SInt32 yAbs)
|
CClientProxy1_0::mouseMove(SInt32 xAbs, SInt32 yAbs)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG2 "send mouse move to \"%s\" %d,%d", getName().c_str(), xAbs, yAbs));
|
LOG((CLOG_DEBUG2 "send mouse move to \"%s\" %d,%d", getName().c_str(), xAbs, yAbs));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDMouseMove, xAbs, yAbs);
|
CProtocolUtil::writef(getOutputStream(), kMsgDMouseMove, xAbs, yAbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CClientProxy1_0::mouseWheel(SInt32 delta)
|
CClientProxy1_0::mouseWheel(SInt32 delta)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG2 "send mouse wheel to \"%s\" %+d", getName().c_str(), delta));
|
LOG((CLOG_DEBUG2 "send mouse wheel to \"%s\" %+d", getName().c_str(), delta));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgDMouseWheel, delta);
|
CProtocolUtil::writef(getOutputStream(), kMsgDMouseWheel, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CClientProxy1_0::screensaver(bool on)
|
CClientProxy1_0::screensaver(bool on)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "send screen saver to \"%s\" on=%d", getName().c_str(), on ? 1 : 0));
|
LOG((CLOG_DEBUG1 "send screen saver to \"%s\" on=%d", getName().c_str(), on ? 1 : 0));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgCScreenSaver, on ? 1 : 0);
|
CProtocolUtil::writef(getOutputStream(), kMsgCScreenSaver, on ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ CClientProxy1_0::recvInfo(bool notify)
|
||||||
SInt16 x, y, w, h, zoneSize, mx, my;
|
SInt16 x, y, w, h, zoneSize, mx, my;
|
||||||
CProtocolUtil::readf(getInputStream(), kMsgDInfo + 4,
|
CProtocolUtil::readf(getInputStream(), kMsgDInfo + 4,
|
||||||
&x, &y, &w, &h, &zoneSize, &mx, &my);
|
&x, &y, &w, &h, &zoneSize, &mx, &my);
|
||||||
log((CLOG_DEBUG "received client \"%s\" info shape=%d,%d %dx%d, zone=%d, pos=%d,%d", getName().c_str(), x, y, w, h, zoneSize, mx, my));
|
LOG((CLOG_DEBUG "received client \"%s\" info shape=%d,%d %dx%d, zone=%d, pos=%d,%d", getName().c_str(), x, y, w, h, zoneSize, mx, my));
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
if (w <= 0 || h <= 0 || zoneSize < 0) {
|
if (w <= 0 || h <= 0 || zoneSize < 0) {
|
||||||
|
@ -319,7 +319,7 @@ CClientProxy1_0::recvInfo(bool notify)
|
||||||
}
|
}
|
||||||
|
|
||||||
// acknowledge receipt
|
// acknowledge receipt
|
||||||
log((CLOG_DEBUG1 "send info ack to \"%s\"", getName().c_str()));
|
LOG((CLOG_DEBUG1 "send info ack to \"%s\"", getName().c_str()));
|
||||||
CProtocolUtil::writef(getOutputStream(), kMsgCInfoAck);
|
CProtocolUtil::writef(getOutputStream(), kMsgCInfoAck);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ CClientProxy1_0::recvClipboard()
|
||||||
UInt32 seqNum;
|
UInt32 seqNum;
|
||||||
CString data;
|
CString data;
|
||||||
CProtocolUtil::readf(getInputStream(), kMsgDClipboard + 4, &id, &seqNum, &data);
|
CProtocolUtil::readf(getInputStream(), kMsgDClipboard + 4, &id, &seqNum, &data);
|
||||||
log((CLOG_DEBUG "received client \"%s\" clipboard %d seqnum=%d, size=%d", getName().c_str(), id, seqNum, data.size()));
|
LOG((CLOG_DEBUG "received client \"%s\" clipboard %d seqnum=%d, size=%d", getName().c_str(), id, seqNum, data.size()));
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
if (id >= kClipboardEnd) {
|
if (id >= kClipboardEnd) {
|
||||||
|
@ -350,7 +350,7 @@ CClientProxy1_0::recvGrabClipboard()
|
||||||
ClipboardID id;
|
ClipboardID id;
|
||||||
UInt32 seqNum;
|
UInt32 seqNum;
|
||||||
CProtocolUtil::readf(getInputStream(), kMsgCClipboard + 4, &id, &seqNum);
|
CProtocolUtil::readf(getInputStream(), kMsgCClipboard + 4, &id, &seqNum);
|
||||||
log((CLOG_DEBUG "received client \"%s\" grabbed clipboard %d seqnum=%d", getName().c_str(), id, seqNum));
|
LOG((CLOG_DEBUG "received client \"%s\" grabbed clipboard %d seqnum=%d", getName().c_str(), id, seqNum));
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
if (id >= kClipboardEnd) {
|
if (id >= kClipboardEnd) {
|
||||||
|
|
|
@ -80,13 +80,13 @@ CHTTPServer::processRequest(IDataSocket* socket)
|
||||||
|
|
||||||
// send reply
|
// send reply
|
||||||
CHTTPProtocol::reply(socket->getOutputStream(), reply);
|
CHTTPProtocol::reply(socket->getOutputStream(), reply);
|
||||||
log((CLOG_INFO "HTTP reply %d for %s %s", reply.m_status, request->m_method.c_str(), request->m_uri.c_str()));
|
LOG((CLOG_INFO "HTTP reply %d for %s %s", reply.m_status, request->m_method.c_str(), request->m_uri.c_str()));
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
delete request;
|
delete request;
|
||||||
}
|
}
|
||||||
catch (XHTTP& e) {
|
catch (XHTTP& e) {
|
||||||
log((CLOG_WARN "returning HTTP error %d %s for %s", e.getStatus(), e.getReason().c_str(), (request != NULL) ? request->m_uri.c_str() : "<unknown>"));
|
LOG((CLOG_WARN "returning HTTP error %d %s for %s", e.getStatus(), e.getReason().c_str(), (request != NULL) ? request->m_uri.c_str() : "<unknown>"));
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
delete request;
|
delete request;
|
||||||
|
@ -256,7 +256,7 @@ CHTTPServer::doProcessPostEditMap(CHTTPRequest& request, CHTTPReply& reply)
|
||||||
// parse the result
|
// parse the result
|
||||||
CHTTPProtocol::CFormParts parts;
|
CHTTPProtocol::CFormParts parts;
|
||||||
if (!CHTTPProtocol::parseFormData(request, parts)) {
|
if (!CHTTPProtocol::parseFormData(request, parts)) {
|
||||||
log((CLOG_WARN "editmap: cannot parse form data"));
|
LOG((CLOG_WARN "editmap: cannot parse form data"));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ CHTTPServer::doProcessPostEditMap(CHTTPRequest& request, CHTTPReply& reply)
|
||||||
if (index == parts.end() ||
|
if (index == parts.end() ||
|
||||||
!parseXY(index->second, w, h) ||
|
!parseXY(index->second, w, h) ||
|
||||||
w <= 0 || h <= 0) {
|
w <= 0 || h <= 0) {
|
||||||
log((CLOG_WARN "editmap: cannot parse size or size is invalid"));
|
LOG((CLOG_WARN "editmap: cannot parse size or size is invalid"));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
ScreenSet screenNames;
|
ScreenSet screenNames;
|
||||||
|
@ -297,7 +297,7 @@ CHTTPServer::doProcessPostEditMap(CHTTPRequest& request, CHTTPReply& reply)
|
||||||
// already been seen.
|
// already been seen.
|
||||||
if (screenNames.count(name)) {
|
if (screenNames.count(name)) {
|
||||||
// FIXME -- better error message
|
// FIXME -- better error message
|
||||||
log((CLOG_WARN "editmap: duplicate name %s", name.c_str()));
|
LOG((CLOG_WARN "editmap: duplicate name %s", name.c_str()));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
// FIXME -- check that name is legal
|
// FIXME -- check that name is legal
|
||||||
|
@ -315,12 +315,12 @@ CHTTPServer::doProcessPostEditMap(CHTTPRequest& request, CHTTPReply& reply)
|
||||||
if (screenNames.empty()) {
|
if (screenNames.empty()) {
|
||||||
// no screens
|
// no screens
|
||||||
// FIXME -- need better no screens
|
// FIXME -- need better no screens
|
||||||
log((CLOG_WARN "editmap: no screens"));
|
LOG((CLOG_WARN "editmap: no screens"));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
if (!screens.isValid()) {
|
if (!screens.isValid()) {
|
||||||
// FIXME -- need better unconnected screens error
|
// FIXME -- need better unconnected screens error
|
||||||
log((CLOG_WARN "editmap: unconnected screens"));
|
LOG((CLOG_WARN "editmap: unconnected screens"));
|
||||||
throw XHTTP(400);
|
throw XHTTP(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ CMSWindowsPrimaryScreen::CMSWindowsPrimaryScreen(
|
||||||
// load the hook library
|
// load the hook library
|
||||||
m_hookLibrary = LoadLibrary("synrgyhk");
|
m_hookLibrary = LoadLibrary("synrgyhk");
|
||||||
if (m_hookLibrary == NULL) {
|
if (m_hookLibrary == NULL) {
|
||||||
log((CLOG_ERR "failed to load hook library"));
|
LOG((CLOG_ERR "failed to load hook library"));
|
||||||
throw XScreenOpenFailure();
|
throw XScreenOpenFailure();
|
||||||
}
|
}
|
||||||
m_setSides = (SetSidesFunc)GetProcAddress(m_hookLibrary, "setSides");
|
m_setSides = (SetSidesFunc)GetProcAddress(m_hookLibrary, "setSides");
|
||||||
|
@ -57,7 +57,7 @@ CMSWindowsPrimaryScreen::CMSWindowsPrimaryScreen(
|
||||||
m_uninstall == NULL ||
|
m_uninstall == NULL ||
|
||||||
m_init == NULL ||
|
m_init == NULL ||
|
||||||
m_cleanup == NULL) {
|
m_cleanup == NULL) {
|
||||||
log((CLOG_ERR "invalid hook library"));
|
LOG((CLOG_ERR "invalid hook library"));
|
||||||
FreeLibrary(m_hookLibrary);
|
FreeLibrary(m_hookLibrary);
|
||||||
throw XScreenOpenFailure();
|
throw XScreenOpenFailure();
|
||||||
}
|
}
|
||||||
|
@ -192,11 +192,11 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||||
// key press
|
// key press
|
||||||
const SInt32 repeat = (SInt32)(msg->lParam & 0xffff);
|
const SInt32 repeat = (SInt32)(msg->lParam & 0xffff);
|
||||||
if (repeat >= 2) {
|
if (repeat >= 2) {
|
||||||
log((CLOG_DEBUG1 "event: key repeat key=%d mask=0x%04x count=%d", key, mask, repeat));
|
LOG((CLOG_DEBUG1 "event: key repeat key=%d mask=0x%04x count=%d", key, mask, repeat));
|
||||||
m_receiver->onKeyRepeat(key, mask, repeat);
|
m_receiver->onKeyRepeat(key, mask, repeat);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log((CLOG_DEBUG1 "event: key press key=%d mask=0x%04x", key, mask));
|
LOG((CLOG_DEBUG1 "event: key press key=%d mask=0x%04x", key, mask));
|
||||||
m_receiver->onKeyDown(key, mask);
|
m_receiver->onKeyDown(key, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// key release
|
// key release
|
||||||
log((CLOG_DEBUG1 "event: key release key=%d mask=0x%04x", key, mask));
|
LOG((CLOG_DEBUG1 "event: key release key=%d mask=0x%04x", key, mask));
|
||||||
m_receiver->onKeyUp(key, mask);
|
m_receiver->onKeyUp(key, mask);
|
||||||
|
|
||||||
// update key state
|
// update key state
|
||||||
|
@ -213,7 +213,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log((CLOG_DEBUG2 "event: cannot map key wParam=%d lParam=0x%08x", msg->wParam, msg->lParam));
|
LOG((CLOG_DEBUG2 "event: cannot map key wParam=%d lParam=0x%08x", msg->wParam, msg->lParam));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -233,7 +233,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
log((CLOG_DEBUG1 "event: button press button=%d", button));
|
LOG((CLOG_DEBUG1 "event: button press button=%d", button));
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
m_receiver->onMouseDown(button);
|
m_receiver->onMouseDown(button);
|
||||||
m_keys[s_vkButton[button]] |= 0x80;
|
m_keys[s_vkButton[button]] |= 0x80;
|
||||||
|
@ -243,7 +243,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
log((CLOG_DEBUG1 "event: button release button=%d", button));
|
LOG((CLOG_DEBUG1 "event: button release button=%d", button));
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
m_receiver->onMouseUp(button);
|
m_receiver->onMouseUp(button);
|
||||||
m_keys[s_vkButton[button]] &= ~0x80;
|
m_keys[s_vkButton[button]] &= ~0x80;
|
||||||
|
@ -256,7 +256,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||||
case SYNERGY_MSG_MOUSE_WHEEL:
|
case SYNERGY_MSG_MOUSE_WHEEL:
|
||||||
// ignore message if posted prior to last mark change
|
// ignore message if posted prior to last mark change
|
||||||
if (!ignore()) {
|
if (!ignore()) {
|
||||||
log((CLOG_DEBUG1 "event: button wheel delta=%d %d", msg->wParam, msg->lParam));
|
LOG((CLOG_DEBUG1 "event: button wheel delta=%d %d", msg->wParam, msg->lParam));
|
||||||
m_receiver->onMouseWheel(msg->wParam);
|
m_receiver->onMouseWheel(msg->wParam);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -282,7 +282,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||||
}
|
}
|
||||||
|
|
||||||
case SYNERGY_MSG_POST_WARP:
|
case SYNERGY_MSG_POST_WARP:
|
||||||
log((CLOG_WARN "unmatched post warp"));
|
LOG((CLOG_WARN "unmatched post warp"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SYNERGY_MSG_MOUSE_MOVE:
|
case SYNERGY_MSG_MOUSE_MOVE:
|
||||||
|
@ -413,7 +413,7 @@ CMSWindowsPrimaryScreen::onPreOpen()
|
||||||
// initialize hook library
|
// initialize hook library
|
||||||
m_threadID = GetCurrentThreadId();
|
m_threadID = GetCurrentThreadId();
|
||||||
if (m_init(m_threadID) == 0) {
|
if (m_init(m_threadID) == 0) {
|
||||||
log((CLOG_ERR "cannot initialize hook library"));
|
LOG((CLOG_ERR "cannot initialize hook library"));
|
||||||
throw XScreenOpenFailure();
|
throw XScreenOpenFailure();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -927,12 +927,12 @@ CMSWindowsPrimaryScreen::mapKey(
|
||||||
mask &= ~(KeyModifierControl | KeyModifierAlt);
|
mask &= ~(KeyModifierControl | KeyModifierAlt);
|
||||||
}
|
}
|
||||||
*maskOut = mask;
|
*maskOut = mask;
|
||||||
log((CLOG_DEBUG2 "key in vk=%d info=0x%08x mask=0x%04x", vkCode, info, mask));
|
LOG((CLOG_DEBUG2 "key in vk=%d info=0x%08x mask=0x%04x", vkCode, info, mask));
|
||||||
|
|
||||||
// get the scan code and the extended keyboard flag
|
// get the scan code and the extended keyboard flag
|
||||||
UINT scanCode = static_cast<UINT>((info & 0x00ff0000u) >> 16);
|
UINT scanCode = static_cast<UINT>((info & 0x00ff0000u) >> 16);
|
||||||
int extended = ((info & 0x01000000) == 0) ? 0 : 1;
|
int extended = ((info & 0x01000000) == 0) ? 0 : 1;
|
||||||
log((CLOG_DEBUG1 "key vk=%d ext=%d scan=%d", vkCode, extended, scanCode));
|
LOG((CLOG_DEBUG1 "key vk=%d ext=%d scan=%d", vkCode, extended, scanCode));
|
||||||
|
|
||||||
// handle some keys via table lookup
|
// handle some keys via table lookup
|
||||||
KeyID id = g_virtualKey[vkCode][extended];
|
KeyID id = g_virtualKey[vkCode][extended];
|
||||||
|
|
|
@ -36,7 +36,7 @@ CPrimaryClient::CPrimaryClient(IPrimaryScreenFactory* screenFactory,
|
||||||
assert(m_server != NULL);
|
assert(m_server != NULL);
|
||||||
|
|
||||||
// create screen
|
// create screen
|
||||||
log((CLOG_DEBUG1 "creating primary screen"));
|
LOG((CLOG_DEBUG1 "creating primary screen"));
|
||||||
if (screenFactory != NULL) {
|
if (screenFactory != NULL) {
|
||||||
m_screen = screenFactory->create(this, receiver);
|
m_screen = screenFactory->create(this, receiver);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ CPrimaryClient::CPrimaryClient(IPrimaryScreenFactory* screenFactory,
|
||||||
|
|
||||||
CPrimaryClient::~CPrimaryClient()
|
CPrimaryClient::~CPrimaryClient()
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "destroying primary screen"));
|
LOG((CLOG_DEBUG1 "destroying primary screen"));
|
||||||
delete m_screen;
|
delete m_screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,15 +44,15 @@ CPrimaryScreen::mainLoop()
|
||||||
|
|
||||||
// run event loop
|
// run event loop
|
||||||
try {
|
try {
|
||||||
log((CLOG_DEBUG "entering event loop"));
|
LOG((CLOG_DEBUG "entering event loop"));
|
||||||
onPreMainLoop();
|
onPreMainLoop();
|
||||||
getScreen()->mainLoop();
|
getScreen()->mainLoop();
|
||||||
onPostMainLoop();
|
onPostMainLoop();
|
||||||
log((CLOG_DEBUG "exiting event loop"));
|
LOG((CLOG_DEBUG "exiting event loop"));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
onPostMainLoop();
|
onPostMainLoop();
|
||||||
log((CLOG_DEBUG "exiting event loop"));
|
LOG((CLOG_DEBUG "exiting event loop"));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ CPrimaryScreen::close()
|
||||||
void
|
void
|
||||||
CPrimaryScreen::enter(SInt32 x, SInt32 y, bool forScreensaver)
|
CPrimaryScreen::enter(SInt32 x, SInt32 y, bool forScreensaver)
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "entering primary at %d,%d%s", x, y, forScreensaver ? " for screen saver" : ""));
|
LOG((CLOG_INFO "entering primary at %d,%d%s", x, y, forScreensaver ? " for screen saver" : ""));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
assert(m_active == true);
|
assert(m_active == true);
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ CPrimaryScreen::enterNoWarp()
|
||||||
bool
|
bool
|
||||||
CPrimaryScreen::leave()
|
CPrimaryScreen::leave()
|
||||||
{
|
{
|
||||||
log((CLOG_INFO "leaving primary"));
|
LOG((CLOG_INFO "leaving primary"));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
assert(m_active == false);
|
assert(m_active == false);
|
||||||
|
|
||||||
|
|
|
@ -72,17 +72,17 @@ CServer::open()
|
||||||
{
|
{
|
||||||
// open the screen
|
// open the screen
|
||||||
try {
|
try {
|
||||||
log((CLOG_INFO "opening screen"));
|
LOG((CLOG_INFO "opening screen"));
|
||||||
openPrimaryScreen();
|
openPrimaryScreen();
|
||||||
}
|
}
|
||||||
catch (XScreen&) {
|
catch (XScreen&) {
|
||||||
// can't open screen
|
// can't open screen
|
||||||
log((CLOG_INFO "failed to open screen"));
|
LOG((CLOG_INFO "failed to open screen"));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch (XUnknownClient& e) {
|
catch (XUnknownClient& e) {
|
||||||
// can't open screen
|
// can't open screen
|
||||||
log((CLOG_CRIT "unknown screen name `%s'", e.getName().c_str()));
|
LOG((CLOG_CRIT "unknown screen name `%s'", e.getName().c_str()));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ CServer::mainLoop()
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log((CLOG_NOTE "starting server"));
|
LOG((CLOG_NOTE "starting server"));
|
||||||
|
|
||||||
// start listening for new clients
|
// start listening for new clients
|
||||||
m_acceptClientThread = new CThread(startThread(
|
m_acceptClientThread = new CThread(startThread(
|
||||||
|
@ -115,7 +115,7 @@ CServer::mainLoop()
|
||||||
m_primaryClient->mainLoop();
|
m_primaryClient->mainLoop();
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
log((CLOG_NOTE "stopping server"));
|
LOG((CLOG_NOTE "stopping server"));
|
||||||
|
|
||||||
// use a macro to write the stuff that should go into a finally
|
// use a macro to write the stuff that should go into a finally
|
||||||
// block so we can repeat it easily. stroustrup's view that
|
// block so we can repeat it easily. stroustrup's view that
|
||||||
|
@ -131,23 +131,23 @@ CServer::mainLoop()
|
||||||
FINALLY;
|
FINALLY;
|
||||||
}
|
}
|
||||||
catch (XBase& e) {
|
catch (XBase& e) {
|
||||||
log((CLOG_ERR "server error: %s", e.what()));
|
LOG((CLOG_ERR "server error: %s", e.what()));
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
log((CLOG_NOTE "stopping server"));
|
LOG((CLOG_NOTE "stopping server"));
|
||||||
FINALLY;
|
FINALLY;
|
||||||
}
|
}
|
||||||
catch (XThread&) {
|
catch (XThread&) {
|
||||||
// clean up
|
// clean up
|
||||||
log((CLOG_NOTE "stopping server"));
|
LOG((CLOG_NOTE "stopping server"));
|
||||||
FINALLY;
|
FINALLY;
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
log((CLOG_DEBUG "unknown server error"));
|
LOG((CLOG_DEBUG "unknown server error"));
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
log((CLOG_NOTE "stopping server"));
|
LOG((CLOG_NOTE "stopping server"));
|
||||||
FINALLY;
|
FINALLY;
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ CServer::close()
|
||||||
if (m_primaryClient != NULL) {
|
if (m_primaryClient != NULL) {
|
||||||
closePrimaryScreen();
|
closePrimaryScreen();
|
||||||
}
|
}
|
||||||
log((CLOG_INFO "closed screen"));
|
LOG((CLOG_INFO "closed screen"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -289,7 +289,7 @@ CServer::onInfoChanged(const CString& name, const CClientInfo& info)
|
||||||
m_x = info.m_mx;
|
m_x = info.m_mx;
|
||||||
m_y = info.m_my;
|
m_y = info.m_my;
|
||||||
}
|
}
|
||||||
log((CLOG_INFO "screen \"%s\" shape=%d,%d %dx%d zone=%d pos=%d,%d", name.c_str(), info.m_x, info.m_y, info.m_w, info.m_h, info.m_zoneSize, info.m_mx, info.m_my));
|
LOG((CLOG_INFO "screen \"%s\" shape=%d,%d %dx%d zone=%d pos=%d,%d", name.c_str(), info.m_x, info.m_y, info.m_w, info.m_h, info.m_zoneSize, info.m_mx, info.m_my));
|
||||||
|
|
||||||
// handle resolution change to primary screen
|
// handle resolution change to primary screen
|
||||||
if (client == m_primaryClient) {
|
if (client == m_primaryClient) {
|
||||||
|
@ -318,12 +318,12 @@ CServer::onGrabClipboard(const CString& name, ClipboardID id, UInt32 seqNum)
|
||||||
CClipboardInfo& clipboard = m_clipboards[id];
|
CClipboardInfo& clipboard = m_clipboards[id];
|
||||||
if (name != m_primaryClient->getName() &&
|
if (name != m_primaryClient->getName() &&
|
||||||
seqNum < clipboard.m_clipboardSeqNum) {
|
seqNum < clipboard.m_clipboardSeqNum) {
|
||||||
log((CLOG_INFO "ignored screen \"%s\" grab of clipboard %d", name.c_str(), id));
|
LOG((CLOG_INFO "ignored screen \"%s\" grab of clipboard %d", name.c_str(), id));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark screen as owning clipboard
|
// mark screen as owning clipboard
|
||||||
log((CLOG_INFO "screen \"%s\" grabbed clipboard %d from \"%s\"", name.c_str(), id, clipboard.m_clipboardOwner.c_str()));
|
LOG((CLOG_INFO "screen \"%s\" grabbed clipboard %d from \"%s\"", name.c_str(), id, clipboard.m_clipboardOwner.c_str()));
|
||||||
clipboard.m_clipboardOwner = name;
|
clipboard.m_clipboardOwner = name;
|
||||||
clipboard.m_clipboardSeqNum = seqNum;
|
clipboard.m_clipboardSeqNum = seqNum;
|
||||||
|
|
||||||
|
@ -365,18 +365,18 @@ CServer::onClipboardChangedNoLock(ClipboardID id,
|
||||||
|
|
||||||
// ignore update if sequence number is old
|
// ignore update if sequence number is old
|
||||||
if (seqNum < clipboard.m_clipboardSeqNum) {
|
if (seqNum < clipboard.m_clipboardSeqNum) {
|
||||||
log((CLOG_INFO "ignored screen \"%s\" update of clipboard %d (missequenced)", clipboard.m_clipboardOwner.c_str(), id));
|
LOG((CLOG_INFO "ignored screen \"%s\" update of clipboard %d (missequenced)", clipboard.m_clipboardOwner.c_str(), id));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore if data hasn't changed
|
// ignore if data hasn't changed
|
||||||
if (data == clipboard.m_clipboardData) {
|
if (data == clipboard.m_clipboardData) {
|
||||||
log((CLOG_DEBUG "ignored screen \"%s\" update of clipboard %d (unchanged)", clipboard.m_clipboardOwner.c_str(), id));
|
LOG((CLOG_DEBUG "ignored screen \"%s\" update of clipboard %d (unchanged)", clipboard.m_clipboardOwner.c_str(), id));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unmarshall into our clipboard buffer
|
// unmarshall into our clipboard buffer
|
||||||
log((CLOG_INFO "screen \"%s\" updated clipboard %d", clipboard.m_clipboardOwner.c_str(), id));
|
LOG((CLOG_INFO "screen \"%s\" updated clipboard %d", clipboard.m_clipboardOwner.c_str(), id));
|
||||||
clipboard.m_clipboardData = data;
|
clipboard.m_clipboardData = data;
|
||||||
clipboard.m_clipboard.unmarshall(clipboard.m_clipboardData, 0);
|
clipboard.m_clipboard.unmarshall(clipboard.m_clipboardData, 0);
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ CServer::onClipboardChangedNoLock(ClipboardID id,
|
||||||
void
|
void
|
||||||
CServer::onScreensaver(bool activated)
|
CServer::onScreensaver(bool activated)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "onScreenSaver %s", activated ? "activated" : "deactivated"));
|
LOG((CLOG_DEBUG "onScreenSaver %s", activated ? "activated" : "deactivated"));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
|
|
||||||
if (activated) {
|
if (activated) {
|
||||||
|
@ -452,7 +452,7 @@ CServer::onScreensaver(bool activated)
|
||||||
void
|
void
|
||||||
CServer::onKeyDown(KeyID id, KeyModifierMask mask)
|
CServer::onKeyDown(KeyID id, KeyModifierMask mask)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "onKeyDown id=%d mask=0x%04x", id, mask));
|
LOG((CLOG_DEBUG1 "onKeyDown id=%d mask=0x%04x", id, mask));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
assert(m_active != NULL);
|
assert(m_active != NULL);
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ CServer::onKeyDown(KeyID id, KeyModifierMask mask)
|
||||||
void
|
void
|
||||||
CServer::onKeyUp(KeyID id, KeyModifierMask mask)
|
CServer::onKeyUp(KeyID id, KeyModifierMask mask)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "onKeyUp id=%d mask=0x%04x", id, mask));
|
LOG((CLOG_DEBUG1 "onKeyUp id=%d mask=0x%04x", id, mask));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
assert(m_active != NULL);
|
assert(m_active != NULL);
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ CServer::onKeyUp(KeyID id, KeyModifierMask mask)
|
||||||
void
|
void
|
||||||
CServer::onKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count)
|
CServer::onKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "onKeyRepeat id=%d mask=0x%04x count=%d", id, mask, count));
|
LOG((CLOG_DEBUG1 "onKeyRepeat id=%d mask=0x%04x count=%d", id, mask, count));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
assert(m_active != NULL);
|
assert(m_active != NULL);
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ CServer::onKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count)
|
||||||
void
|
void
|
||||||
CServer::onMouseDown(ButtonID id)
|
CServer::onMouseDown(ButtonID id)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "onMouseDown id=%d", id));
|
LOG((CLOG_DEBUG1 "onMouseDown id=%d", id));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
assert(m_active != NULL);
|
assert(m_active != NULL);
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ CServer::onMouseDown(ButtonID id)
|
||||||
void
|
void
|
||||||
CServer::onMouseUp(ButtonID id)
|
CServer::onMouseUp(ButtonID id)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "onMouseUp id=%d", id));
|
LOG((CLOG_DEBUG1 "onMouseUp id=%d", id));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
assert(m_active != NULL);
|
assert(m_active != NULL);
|
||||||
|
|
||||||
|
@ -523,7 +523,7 @@ CServer::onMouseUp(ButtonID id)
|
||||||
bool
|
bool
|
||||||
CServer::onMouseMovePrimary(SInt32 x, SInt32 y)
|
CServer::onMouseMovePrimary(SInt32 x, SInt32 y)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG2 "onMouseMovePrimary %d,%d", x, y));
|
LOG((CLOG_DEBUG2 "onMouseMovePrimary %d,%d", x, y));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
return onMouseMovePrimaryNoLock(x, y);
|
return onMouseMovePrimaryNoLock(x, y);
|
||||||
}
|
}
|
||||||
|
@ -550,22 +550,22 @@ CServer::onMouseMovePrimaryNoLock(SInt32 x, SInt32 y)
|
||||||
if (x < ax + zoneSize) {
|
if (x < ax + zoneSize) {
|
||||||
x -= zoneSize;
|
x -= zoneSize;
|
||||||
dir = kLeft;
|
dir = kLeft;
|
||||||
log((CLOG_DEBUG1 "switch to left"));
|
LOG((CLOG_DEBUG1 "switch to left"));
|
||||||
}
|
}
|
||||||
else if (x >= ax + aw - zoneSize) {
|
else if (x >= ax + aw - zoneSize) {
|
||||||
x += zoneSize;
|
x += zoneSize;
|
||||||
dir = kRight;
|
dir = kRight;
|
||||||
log((CLOG_DEBUG1 "switch to right"));
|
LOG((CLOG_DEBUG1 "switch to right"));
|
||||||
}
|
}
|
||||||
else if (y < ay + zoneSize) {
|
else if (y < ay + zoneSize) {
|
||||||
y -= zoneSize;
|
y -= zoneSize;
|
||||||
dir = kTop;
|
dir = kTop;
|
||||||
log((CLOG_DEBUG1 "switch to top"));
|
LOG((CLOG_DEBUG1 "switch to top"));
|
||||||
}
|
}
|
||||||
else if (y >= ay + ah - zoneSize) {
|
else if (y >= ay + ah - zoneSize) {
|
||||||
y += zoneSize;
|
y += zoneSize;
|
||||||
dir = kBottom;
|
dir = kBottom;
|
||||||
log((CLOG_DEBUG1 "switch to bottom"));
|
LOG((CLOG_DEBUG1 "switch to bottom"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// still on local screen
|
// still on local screen
|
||||||
|
@ -587,7 +587,7 @@ CServer::onMouseMovePrimaryNoLock(SInt32 x, SInt32 y)
|
||||||
void
|
void
|
||||||
CServer::onMouseMoveSecondary(SInt32 dx, SInt32 dy)
|
CServer::onMouseMoveSecondary(SInt32 dx, SInt32 dy)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG2 "onMouseMoveSecondary %+d,%+d", dx, dy));
|
LOG((CLOG_DEBUG2 "onMouseMoveSecondary %+d,%+d", dx, dy));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
onMouseMoveSecondaryNoLock(dx, dy);
|
onMouseMoveSecondaryNoLock(dx, dy);
|
||||||
}
|
}
|
||||||
|
@ -647,12 +647,12 @@ CServer::onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy)
|
||||||
|
|
||||||
// get neighbor if we should switch
|
// get neighbor if we should switch
|
||||||
if (newScreen == NULL) {
|
if (newScreen == NULL) {
|
||||||
log((CLOG_DEBUG1 "leave \"%s\" on %s", m_active->getName().c_str(), CConfig::dirName(dir)));
|
LOG((CLOG_DEBUG1 "leave \"%s\" on %s", m_active->getName().c_str(), CConfig::dirName(dir)));
|
||||||
|
|
||||||
// get new position or clamp to current screen
|
// get new position or clamp to current screen
|
||||||
newScreen = getNeighbor(m_active, dir, m_x, m_y);
|
newScreen = getNeighbor(m_active, dir, m_x, m_y);
|
||||||
if (newScreen == NULL) {
|
if (newScreen == NULL) {
|
||||||
log((CLOG_DEBUG1 "no neighbor; clamping"));
|
LOG((CLOG_DEBUG1 "no neighbor; clamping"));
|
||||||
if (m_x < ax) {
|
if (m_x < ax) {
|
||||||
m_x = ax;
|
m_x = ax;
|
||||||
}
|
}
|
||||||
|
@ -670,7 +670,7 @@ CServer::onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// clamp to edge when locked
|
// clamp to edge when locked
|
||||||
log((CLOG_DEBUG1 "clamp to \"%s\"", m_active->getName().c_str()));
|
LOG((CLOG_DEBUG1 "clamp to \"%s\"", m_active->getName().c_str()));
|
||||||
if (m_x < ax) {
|
if (m_x < ax) {
|
||||||
m_x = ax;
|
m_x = ax;
|
||||||
}
|
}
|
||||||
|
@ -689,7 +689,7 @@ CServer::onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy)
|
||||||
if (newScreen == NULL || newScreen == m_active) {
|
if (newScreen == NULL || newScreen == m_active) {
|
||||||
// do nothing if mouse didn't move
|
// do nothing if mouse didn't move
|
||||||
if (m_x != xOld || m_y != yOld) {
|
if (m_x != xOld || m_y != yOld) {
|
||||||
log((CLOG_DEBUG2 "move on %s to %d,%d", m_active->getName().c_str(), m_x, m_y));
|
LOG((CLOG_DEBUG2 "move on %s to %d,%d", m_active->getName().c_str(), m_x, m_y));
|
||||||
m_active->mouseMove(m_x, m_y);
|
m_active->mouseMove(m_x, m_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -703,7 +703,7 @@ CServer::onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy)
|
||||||
void
|
void
|
||||||
CServer::onMouseWheel(SInt32 delta)
|
CServer::onMouseWheel(SInt32 delta)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "onMouseWheel %+d", delta));
|
LOG((CLOG_DEBUG1 "onMouseWheel %+d", delta));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
assert(m_active != NULL);
|
assert(m_active != NULL);
|
||||||
|
|
||||||
|
@ -749,7 +749,7 @@ CServer::switchScreen(IClient* dst, SInt32 x, SInt32 y, bool forScreensaver)
|
||||||
#endif
|
#endif
|
||||||
assert(m_active != NULL);
|
assert(m_active != NULL);
|
||||||
|
|
||||||
log((CLOG_INFO "switch from \"%s\" to \"%s\" at %d,%d", m_active->getName().c_str(), dst->getName().c_str(), x, y));
|
LOG((CLOG_INFO "switch from \"%s\" to \"%s\" at %d,%d", m_active->getName().c_str(), dst->getName().c_str(), x, y));
|
||||||
|
|
||||||
// record new position
|
// record new position
|
||||||
m_x = x;
|
m_x = x;
|
||||||
|
@ -762,7 +762,7 @@ CServer::switchScreen(IClient* dst, SInt32 x, SInt32 y, bool forScreensaver)
|
||||||
// leave active screen
|
// leave active screen
|
||||||
if (!m_active->leave()) {
|
if (!m_active->leave()) {
|
||||||
// cannot leave screen
|
// cannot leave screen
|
||||||
log((CLOG_WARN "can't leave screen"));
|
LOG((CLOG_WARN "can't leave screen"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -808,14 +808,14 @@ CServer::getNeighbor(IClient* src, EDirection dir) const
|
||||||
|
|
||||||
CString srcName = src->getName();
|
CString srcName = src->getName();
|
||||||
assert(!srcName.empty());
|
assert(!srcName.empty());
|
||||||
log((CLOG_DEBUG2 "find neighbor on %s of \"%s\"", CConfig::dirName(dir), srcName.c_str()));
|
LOG((CLOG_DEBUG2 "find neighbor on %s of \"%s\"", CConfig::dirName(dir), srcName.c_str()));
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// look up name of neighbor
|
// look up name of neighbor
|
||||||
const CString dstName(m_config.getNeighbor(srcName, dir));
|
const CString dstName(m_config.getNeighbor(srcName, dir));
|
||||||
|
|
||||||
// if nothing in that direction then return NULL
|
// if nothing in that direction then return NULL
|
||||||
if (dstName.empty()) {
|
if (dstName.empty()) {
|
||||||
log((CLOG_DEBUG2 "no neighbor on %s of \"%s\"", CConfig::dirName(dir), srcName.c_str()));
|
LOG((CLOG_DEBUG2 "no neighbor on %s of \"%s\"", CConfig::dirName(dir), srcName.c_str()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,11 +824,11 @@ CServer::getNeighbor(IClient* src, EDirection dir) const
|
||||||
// unconnected screen.
|
// unconnected screen.
|
||||||
CClientList::const_iterator index = m_clients.find(dstName);
|
CClientList::const_iterator index = m_clients.find(dstName);
|
||||||
if (index != m_clients.end()) {
|
if (index != m_clients.end()) {
|
||||||
log((CLOG_DEBUG2 "\"%s\" is on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str()));
|
LOG((CLOG_DEBUG2 "\"%s\" is on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str()));
|
||||||
return index->second;
|
return index->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
log((CLOG_DEBUG2 "ignored \"%s\" on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str()));
|
LOG((CLOG_DEBUG2 "ignored \"%s\" on %s of \"%s\"", dstName.c_str(), CConfig::dirName(dir), srcName.c_str()));
|
||||||
srcName = dstName;
|
srcName = dstName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -867,7 +867,7 @@ CServer::getNeighbor(IClient* src,
|
||||||
if (x >= 0) {
|
if (x >= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
log((CLOG_DEBUG2 "skipping over screen %s", dst->getName().c_str()));
|
LOG((CLOG_DEBUG2 "skipping over screen %s", dst->getName().c_str()));
|
||||||
dst = getNeighbor(lastGoodScreen, srcSide);
|
dst = getNeighbor(lastGoodScreen, srcSide);
|
||||||
}
|
}
|
||||||
assert(lastGoodScreen != NULL);
|
assert(lastGoodScreen != NULL);
|
||||||
|
@ -883,7 +883,7 @@ CServer::getNeighbor(IClient* src,
|
||||||
if (x < dw) {
|
if (x < dw) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
log((CLOG_DEBUG2 "skipping over screen %s", dst->getName().c_str()));
|
LOG((CLOG_DEBUG2 "skipping over screen %s", dst->getName().c_str()));
|
||||||
dst = getNeighbor(lastGoodScreen, srcSide);
|
dst = getNeighbor(lastGoodScreen, srcSide);
|
||||||
}
|
}
|
||||||
assert(lastGoodScreen != NULL);
|
assert(lastGoodScreen != NULL);
|
||||||
|
@ -899,7 +899,7 @@ CServer::getNeighbor(IClient* src,
|
||||||
if (y >= 0) {
|
if (y >= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
log((CLOG_DEBUG2 "skipping over screen %s", dst->getName().c_str()));
|
LOG((CLOG_DEBUG2 "skipping over screen %s", dst->getName().c_str()));
|
||||||
dst = getNeighbor(lastGoodScreen, srcSide);
|
dst = getNeighbor(lastGoodScreen, srcSide);
|
||||||
}
|
}
|
||||||
assert(lastGoodScreen != NULL);
|
assert(lastGoodScreen != NULL);
|
||||||
|
@ -915,7 +915,7 @@ CServer::getNeighbor(IClient* src,
|
||||||
if (y < sh) {
|
if (y < sh) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
log((CLOG_DEBUG2 "skipping over screen %s", dst->getName().c_str()));
|
LOG((CLOG_DEBUG2 "skipping over screen %s", dst->getName().c_str()));
|
||||||
dst = getNeighbor(lastGoodScreen, srcSide);
|
dst = getNeighbor(lastGoodScreen, srcSide);
|
||||||
}
|
}
|
||||||
assert(lastGoodScreen != NULL);
|
assert(lastGoodScreen != NULL);
|
||||||
|
@ -1073,14 +1073,14 @@ CServer::startThread(IJob* job)
|
||||||
// add new thread to list. use the job as user data for logging.
|
// add new thread to list. use the job as user data for logging.
|
||||||
CThread thread(job, job);
|
CThread thread(job, job);
|
||||||
m_threads.push_back(thread);
|
m_threads.push_back(thread);
|
||||||
log((CLOG_DEBUG1 "started thread %p", thread.getUserData()));
|
LOG((CLOG_DEBUG1 "started thread %p", thread.getUserData()));
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CServer::stopThreads(double timeout)
|
CServer::stopThreads(double timeout)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "stopping threads"));
|
LOG((CLOG_DEBUG1 "stopping threads"));
|
||||||
|
|
||||||
// cancel the accept client thread to prevent more clients from
|
// cancel the accept client thread to prevent more clients from
|
||||||
// connecting while we're shutting down.
|
// connecting while we're shutting down.
|
||||||
|
@ -1125,10 +1125,10 @@ CServer::stopThreads(double timeout)
|
||||||
// delete remaining threads
|
// delete remaining threads
|
||||||
for (CThreadList::iterator index = threads.begin();
|
for (CThreadList::iterator index = threads.begin();
|
||||||
index != threads.end(); ++index) {
|
index != threads.end(); ++index) {
|
||||||
log((CLOG_DEBUG1 "reaped running thread %p", index->getUserData()));
|
LOG((CLOG_DEBUG1 "reaped running thread %p", index->getUserData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
log((CLOG_DEBUG1 "stopped threads"));
|
LOG((CLOG_DEBUG1 "stopped threads"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1145,7 +1145,7 @@ CServer::doReapThreads(CThreadList& threads)
|
||||||
index != threads.end(); ) {
|
index != threads.end(); ) {
|
||||||
if (index->wait(0.0)) {
|
if (index->wait(0.0)) {
|
||||||
// thread terminated
|
// thread terminated
|
||||||
log((CLOG_DEBUG1 "reaped thread %p", index->getUserData()));
|
LOG((CLOG_DEBUG1 "reaped thread %p", index->getUserData()));
|
||||||
index = threads.erase(index);
|
index = threads.erase(index);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1158,7 +1158,7 @@ CServer::doReapThreads(CThreadList& threads)
|
||||||
void
|
void
|
||||||
CServer::acceptClients(void*)
|
CServer::acceptClients(void*)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "starting to wait for clients"));
|
LOG((CLOG_DEBUG1 "starting to wait for clients"));
|
||||||
|
|
||||||
IListenSocket* listen = NULL;
|
IListenSocket* listen = NULL;
|
||||||
try {
|
try {
|
||||||
|
@ -1173,16 +1173,16 @@ CServer::acceptClients(void*)
|
||||||
CStopwatch timer;
|
CStopwatch timer;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
try {
|
try {
|
||||||
log((CLOG_DEBUG1 "binding listen socket"));
|
LOG((CLOG_DEBUG1 "binding listen socket"));
|
||||||
listen->bind(m_config.getSynergyAddress());
|
listen->bind(m_config.getSynergyAddress());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (XSocketBind& e) {
|
catch (XSocketBind& e) {
|
||||||
log((CLOG_WARN "bind failed: %s", e.getErrstr()));
|
LOG((CLOG_WARN "bind failed: %s", e.getErrstr()));
|
||||||
|
|
||||||
// give up if we've waited too long
|
// give up if we've waited too long
|
||||||
if (timer.getTime() >= m_bindTimeout) {
|
if (timer.getTime() >= m_bindTimeout) {
|
||||||
log((CLOG_ERR "waited too long to bind, giving up"));
|
LOG((CLOG_ERR "waited too long to bind, giving up"));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1192,12 +1192,12 @@ CServer::acceptClients(void*)
|
||||||
}
|
}
|
||||||
|
|
||||||
// accept connections and begin processing them
|
// accept connections and begin processing them
|
||||||
log((CLOG_DEBUG1 "waiting for client connections"));
|
LOG((CLOG_DEBUG1 "waiting for client connections"));
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// accept connection
|
// accept connection
|
||||||
CThread::testCancel();
|
CThread::testCancel();
|
||||||
IDataSocket* socket = listen->accept();
|
IDataSocket* socket = listen->accept();
|
||||||
log((CLOG_NOTE "accepted client connection"));
|
LOG((CLOG_NOTE "accepted client connection"));
|
||||||
CThread::testCancel();
|
CThread::testCancel();
|
||||||
|
|
||||||
// start handshake thread
|
// start handshake thread
|
||||||
|
@ -1209,7 +1209,7 @@ CServer::acceptClients(void*)
|
||||||
delete listen;
|
delete listen;
|
||||||
}
|
}
|
||||||
catch (XBase& e) {
|
catch (XBase& e) {
|
||||||
log((CLOG_ERR "cannot listen for clients: %s", e.what()));
|
LOG((CLOG_ERR "cannot listen for clients: %s", e.what()));
|
||||||
delete listen;
|
delete listen;
|
||||||
exitMainLoop();
|
exitMainLoop();
|
||||||
}
|
}
|
||||||
|
@ -1251,7 +1251,7 @@ CServer::runClient(void* vsocket)
|
||||||
}
|
}
|
||||||
catch (XDuplicateClient& e) {
|
catch (XDuplicateClient& e) {
|
||||||
// client has duplicate name
|
// client has duplicate name
|
||||||
log((CLOG_WARN "a client with name \"%s\" is already connected", e.getName().c_str()));
|
LOG((CLOG_WARN "a client with name \"%s\" is already connected", e.getName().c_str()));
|
||||||
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEBusy);
|
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEBusy);
|
||||||
delete proxy;
|
delete proxy;
|
||||||
delete socket;
|
delete socket;
|
||||||
|
@ -1259,7 +1259,7 @@ CServer::runClient(void* vsocket)
|
||||||
}
|
}
|
||||||
catch (XUnknownClient& e) {
|
catch (XUnknownClient& e) {
|
||||||
// client has unknown name
|
// client has unknown name
|
||||||
log((CLOG_WARN "a client with name \"%s\" is not in the map", e.getName().c_str()));
|
LOG((CLOG_WARN "a client with name \"%s\" is not in the map", e.getName().c_str()));
|
||||||
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEUnknown);
|
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEUnknown);
|
||||||
delete proxy;
|
delete proxy;
|
||||||
delete socket;
|
delete socket;
|
||||||
|
@ -1281,17 +1281,17 @@ CServer::runClient(void* vsocket)
|
||||||
|
|
||||||
// handle client messages
|
// handle client messages
|
||||||
try {
|
try {
|
||||||
log((CLOG_NOTE "client \"%s\" has connected", proxy->getName().c_str()));
|
LOG((CLOG_NOTE "client \"%s\" has connected", proxy->getName().c_str()));
|
||||||
proxy->mainLoop();
|
proxy->mainLoop();
|
||||||
}
|
}
|
||||||
catch (XBadClient&) {
|
catch (XBadClient&) {
|
||||||
// client not behaving
|
// client not behaving
|
||||||
log((CLOG_WARN "protocol error from client \"%s\"", proxy->getName().c_str()));
|
LOG((CLOG_WARN "protocol error from client \"%s\"", proxy->getName().c_str()));
|
||||||
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEBad);
|
CProtocolUtil::writef(proxy->getOutputStream(), kMsgEBad);
|
||||||
}
|
}
|
||||||
catch (XBase& e) {
|
catch (XBase& e) {
|
||||||
// misc error
|
// misc error
|
||||||
log((CLOG_WARN "error communicating with client \"%s\": %s", proxy->getName().c_str(), e.what()));
|
LOG((CLOG_WARN "error communicating with client \"%s\": %s", proxy->getName().c_str(), e.what()));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
// mainLoop() was probably cancelled
|
// mainLoop() was probably cancelled
|
||||||
|
@ -1308,7 +1308,7 @@ CServer::runClient(void* vsocket)
|
||||||
CClientProxy*
|
CClientProxy*
|
||||||
CServer::handshakeClient(IDataSocket* socket)
|
CServer::handshakeClient(IDataSocket* socket)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "negotiating with new client"));
|
LOG((CLOG_DEBUG1 "negotiating with new client"));
|
||||||
|
|
||||||
// get the input and output streams
|
// get the input and output streams
|
||||||
IInputStream* input = socket->getInputStream();
|
IInputStream* input = socket->getInputStream();
|
||||||
|
@ -1334,14 +1334,14 @@ CServer::handshakeClient(IDataSocket* socket)
|
||||||
CTimerThread timer(30.0);
|
CTimerThread timer(30.0);
|
||||||
|
|
||||||
// say hello
|
// say hello
|
||||||
log((CLOG_DEBUG1 "saying hello"));
|
LOG((CLOG_DEBUG1 "saying hello"));
|
||||||
CProtocolUtil::writef(output, kMsgHello,
|
CProtocolUtil::writef(output, kMsgHello,
|
||||||
kProtocolMajorVersion,
|
kProtocolMajorVersion,
|
||||||
kProtocolMinorVersion);
|
kProtocolMinorVersion);
|
||||||
output->flush();
|
output->flush();
|
||||||
|
|
||||||
// wait for the reply
|
// wait for the reply
|
||||||
log((CLOG_DEBUG1 "waiting for hello reply"));
|
LOG((CLOG_DEBUG1 "waiting for hello reply"));
|
||||||
UInt32 n = input->getSize();
|
UInt32 n = input->getSize();
|
||||||
|
|
||||||
// limit the maximum length of the hello
|
// limit the maximum length of the hello
|
||||||
|
@ -1352,7 +1352,7 @@ CServer::handshakeClient(IDataSocket* socket)
|
||||||
// get and parse the reply to hello
|
// get and parse the reply to hello
|
||||||
SInt16 major, minor;
|
SInt16 major, minor;
|
||||||
try {
|
try {
|
||||||
log((CLOG_DEBUG1 "parsing hello reply"));
|
LOG((CLOG_DEBUG1 "parsing hello reply"));
|
||||||
CProtocolUtil::readf(input, kMsgHelloBack,
|
CProtocolUtil::readf(input, kMsgHelloBack,
|
||||||
&major, &minor, &name);
|
&major, &minor, &name);
|
||||||
}
|
}
|
||||||
|
@ -1382,32 +1382,32 @@ CServer::handshakeClient(IDataSocket* socket)
|
||||||
}
|
}
|
||||||
|
|
||||||
// create client proxy for highest version supported by the client
|
// create client proxy for highest version supported by the client
|
||||||
log((CLOG_DEBUG1 "creating proxy for client \"%s\" version %d.%d", name.c_str(), major, minor));
|
LOG((CLOG_DEBUG1 "creating proxy for client \"%s\" version %d.%d", name.c_str(), major, minor));
|
||||||
proxy = new CClientProxy1_0(this, name, input, output);
|
proxy = new CClientProxy1_0(this, name, input, output);
|
||||||
|
|
||||||
// negotiate
|
// negotiate
|
||||||
// FIXME
|
// FIXME
|
||||||
|
|
||||||
// ask and wait for the client's info
|
// ask and wait for the client's info
|
||||||
log((CLOG_DEBUG1 "waiting for info for client \"%s\"", name.c_str()));
|
LOG((CLOG_DEBUG1 "waiting for info for client \"%s\"", name.c_str()));
|
||||||
proxy->open();
|
proxy->open();
|
||||||
|
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
catch (XIncompatibleClient& e) {
|
catch (XIncompatibleClient& e) {
|
||||||
// client is incompatible
|
// client is incompatible
|
||||||
log((CLOG_WARN "client \"%s\" has incompatible version %d.%d)", name.c_str(), e.getMajor(), e.getMinor()));
|
LOG((CLOG_WARN "client \"%s\" has incompatible version %d.%d)", name.c_str(), e.getMajor(), e.getMinor()));
|
||||||
CProtocolUtil::writef(output, kMsgEIncompatible,
|
CProtocolUtil::writef(output, kMsgEIncompatible,
|
||||||
kProtocolMajorVersion, kProtocolMinorVersion);
|
kProtocolMajorVersion, kProtocolMinorVersion);
|
||||||
}
|
}
|
||||||
catch (XBadClient&) {
|
catch (XBadClient&) {
|
||||||
// client not behaving
|
// client not behaving
|
||||||
log((CLOG_WARN "protocol error from client \"%s\"", name.c_str()));
|
LOG((CLOG_WARN "protocol error from client \"%s\"", name.c_str()));
|
||||||
CProtocolUtil::writef(output, kMsgEBad);
|
CProtocolUtil::writef(output, kMsgEBad);
|
||||||
}
|
}
|
||||||
catch (XBase& e) {
|
catch (XBase& e) {
|
||||||
// misc error
|
// misc error
|
||||||
log((CLOG_WARN "error communicating with client \"%s\": %s", name.c_str(), e.what()));
|
LOG((CLOG_WARN "error communicating with client \"%s\": %s", name.c_str(), e.what()));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
// probably timed out
|
// probably timed out
|
||||||
|
@ -1436,7 +1436,7 @@ CServer::handshakeClient(IDataSocket* socket)
|
||||||
void
|
void
|
||||||
CServer::acceptHTTPClients(void*)
|
CServer::acceptHTTPClients(void*)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "starting to wait for HTTP clients"));
|
LOG((CLOG_DEBUG1 "starting to wait for HTTP clients"));
|
||||||
|
|
||||||
IListenSocket* listen = NULL;
|
IListenSocket* listen = NULL;
|
||||||
try {
|
try {
|
||||||
|
@ -1448,16 +1448,16 @@ CServer::acceptHTTPClients(void*)
|
||||||
CStopwatch timer;
|
CStopwatch timer;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
try {
|
try {
|
||||||
log((CLOG_DEBUG1 "binding HTTP listen socket"));
|
LOG((CLOG_DEBUG1 "binding HTTP listen socket"));
|
||||||
listen->bind(m_config.getHTTPAddress());
|
listen->bind(m_config.getHTTPAddress());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (XSocketBind& e) {
|
catch (XSocketBind& e) {
|
||||||
log((CLOG_DEBUG1 "bind HTTP failed: %s", e.getErrstr()));
|
LOG((CLOG_DEBUG1 "bind HTTP failed: %s", e.getErrstr()));
|
||||||
|
|
||||||
// give up if we've waited too long
|
// give up if we've waited too long
|
||||||
if (timer.getTime() >= m_bindTimeout) {
|
if (timer.getTime() >= m_bindTimeout) {
|
||||||
log((CLOG_DEBUG1 "waited too long to bind HTTP, giving up"));
|
LOG((CLOG_DEBUG1 "waited too long to bind HTTP, giving up"));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1467,7 +1467,7 @@ CServer::acceptHTTPClients(void*)
|
||||||
}
|
}
|
||||||
|
|
||||||
// accept connections and begin processing them
|
// accept connections and begin processing them
|
||||||
log((CLOG_DEBUG1 "waiting for HTTP connections"));
|
LOG((CLOG_DEBUG1 "waiting for HTTP connections"));
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// limit the number of HTTP requests being handled at once
|
// limit the number of HTTP requests being handled at once
|
||||||
{
|
{
|
||||||
|
@ -1482,7 +1482,7 @@ CServer::acceptHTTPClients(void*)
|
||||||
// accept connection
|
// accept connection
|
||||||
CThread::testCancel();
|
CThread::testCancel();
|
||||||
IDataSocket* socket = listen->accept();
|
IDataSocket* socket = listen->accept();
|
||||||
log((CLOG_NOTE "accepted HTTP connection"));
|
LOG((CLOG_NOTE "accepted HTTP connection"));
|
||||||
CThread::testCancel();
|
CThread::testCancel();
|
||||||
|
|
||||||
// handle HTTP request
|
// handle HTTP request
|
||||||
|
@ -1494,7 +1494,7 @@ CServer::acceptHTTPClients(void*)
|
||||||
delete listen;
|
delete listen;
|
||||||
}
|
}
|
||||||
catch (XBase& e) {
|
catch (XBase& e) {
|
||||||
log((CLOG_ERR "cannot listen for HTTP clients: %s", e.what()));
|
LOG((CLOG_ERR "cannot listen for HTTP clients: %s", e.what()));
|
||||||
delete listen;
|
delete listen;
|
||||||
exitMainLoop();
|
exitMainLoop();
|
||||||
}
|
}
|
||||||
|
@ -1574,7 +1574,7 @@ CServer::openPrimaryScreen()
|
||||||
m_active = m_primaryClient;
|
m_active = m_primaryClient;
|
||||||
|
|
||||||
// open the screen
|
// open the screen
|
||||||
log((CLOG_DEBUG1 "opening primary screen"));
|
LOG((CLOG_DEBUG1 "opening primary screen"));
|
||||||
m_primaryClient->open();
|
m_primaryClient->open();
|
||||||
|
|
||||||
// tell it about the active sides
|
// tell it about the active sides
|
||||||
|
@ -1600,7 +1600,7 @@ CServer::closePrimaryScreen()
|
||||||
|
|
||||||
// close the primary screen
|
// close the primary screen
|
||||||
try {
|
try {
|
||||||
log((CLOG_DEBUG1 "closing primary screen"));
|
LOG((CLOG_DEBUG1 "closing primary screen"));
|
||||||
m_primaryClient->close();
|
m_primaryClient->close();
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
|
@ -1617,7 +1617,7 @@ CServer::addConnection(IClient* client)
|
||||||
{
|
{
|
||||||
assert(client != NULL);
|
assert(client != NULL);
|
||||||
|
|
||||||
log((CLOG_DEBUG "adding connection \"%s\"", client->getName().c_str()));
|
LOG((CLOG_DEBUG "adding connection \"%s\"", client->getName().c_str()));
|
||||||
|
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
|
|
||||||
|
@ -1633,13 +1633,13 @@ CServer::addConnection(IClient* client)
|
||||||
|
|
||||||
// save screen info
|
// save screen info
|
||||||
m_clients.insert(std::make_pair(client->getName(), client));
|
m_clients.insert(std::make_pair(client->getName(), client));
|
||||||
log((CLOG_DEBUG "added connection \"%s\"", client->getName().c_str()));
|
LOG((CLOG_DEBUG "added connection \"%s\"", client->getName().c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CServer::removeConnection(const CString& name)
|
CServer::removeConnection(const CString& name)
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG "removing connection \"%s\"", name.c_str()));
|
LOG((CLOG_DEBUG "removing connection \"%s\"", name.c_str()));
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
|
|
||||||
// find client
|
// find client
|
||||||
|
@ -1653,7 +1653,7 @@ CServer::removeConnection(const CString& name)
|
||||||
m_primaryClient->getCursorCenter(m_x, m_y);
|
m_primaryClient->getCursorCenter(m_x, m_y);
|
||||||
|
|
||||||
// don't notify active screen since it probably already disconnected
|
// don't notify active screen since it probably already disconnected
|
||||||
log((CLOG_INFO "jump from \"%s\" to \"%s\" at %d,%d", active->getName().c_str(), m_primaryClient->getName().c_str(), m_x, m_y));
|
LOG((CLOG_INFO "jump from \"%s\" to \"%s\" at %d,%d", active->getName().c_str(), m_primaryClient->getName().c_str(), m_x, m_y));
|
||||||
|
|
||||||
// cut over
|
// cut over
|
||||||
m_active = m_primaryClient;
|
m_active = m_primaryClient;
|
||||||
|
|
|
@ -182,7 +182,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||||
|
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "event: KeyPress code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
LOG((CLOG_DEBUG1 "event: KeyPress code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
||||||
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
|
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
|
||||||
const KeyID key = mapKey(&xevent.xkey);
|
const KeyID key = mapKey(&xevent.xkey);
|
||||||
if (key != kKeyNone) {
|
if (key != kKeyNone) {
|
||||||
|
@ -223,7 +223,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||||
}
|
}
|
||||||
if (!hasPress) {
|
if (!hasPress) {
|
||||||
// no press event follows so it's a plain release
|
// no press event follows so it's a plain release
|
||||||
log((CLOG_DEBUG1 "event: KeyRelease code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
LOG((CLOG_DEBUG1 "event: KeyRelease code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
||||||
if (key == kKeyCapsLock && m_capsLockHalfDuplex) {
|
if (key == kKeyCapsLock && m_capsLockHalfDuplex) {
|
||||||
m_receiver->onKeyDown(key, mask);
|
m_receiver->onKeyDown(key, mask);
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||||
// we could attempt to count the already queued
|
// we could attempt to count the already queued
|
||||||
// repeats but we'll just send a repeat of 1.
|
// repeats but we'll just send a repeat of 1.
|
||||||
// note that we discard the press event.
|
// note that we discard the press event.
|
||||||
log((CLOG_DEBUG1 "event: repeat code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
LOG((CLOG_DEBUG1 "event: repeat code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
||||||
m_receiver->onKeyRepeat(key, mask, 1);
|
m_receiver->onKeyRepeat(key, mask, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||||
|
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "event: ButtonPress button=%d", xevent.xbutton.button));
|
LOG((CLOG_DEBUG1 "event: ButtonPress button=%d", xevent.xbutton.button));
|
||||||
const ButtonID button = mapButton(xevent.xbutton.button);
|
const ButtonID button = mapButton(xevent.xbutton.button);
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
m_receiver->onMouseDown(button);
|
m_receiver->onMouseDown(button);
|
||||||
|
@ -256,7 +256,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||||
|
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG1 "event: ButtonRelease button=%d", xevent.xbutton.button));
|
LOG((CLOG_DEBUG1 "event: ButtonRelease button=%d", xevent.xbutton.button));
|
||||||
const ButtonID button = mapButton(xevent.xbutton.button);
|
const ButtonID button = mapButton(xevent.xbutton.button);
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
m_receiver->onMouseUp(button);
|
m_receiver->onMouseUp(button);
|
||||||
|
@ -274,7 +274,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||||
|
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
{
|
{
|
||||||
log((CLOG_DEBUG2 "event: MotionNotify %d,%d", xevent.xmotion.x_root, xevent.xmotion.y_root));
|
LOG((CLOG_DEBUG2 "event: MotionNotify %d,%d", xevent.xmotion.x_root, xevent.xmotion.y_root));
|
||||||
|
|
||||||
// compute motion delta (relative to the last known
|
// compute motion delta (relative to the last known
|
||||||
// mouse position)
|
// mouse position)
|
||||||
|
@ -427,7 +427,7 @@ CXWindowsPrimaryScreen::createWindow()
|
||||||
if (m_window == None) {
|
if (m_window == None) {
|
||||||
throw XScreenOpenFailure();
|
throw XScreenOpenFailure();
|
||||||
}
|
}
|
||||||
log((CLOG_DEBUG "window is 0x%08x", m_window));
|
LOG((CLOG_DEBUG "window is 0x%08x", m_window));
|
||||||
|
|
||||||
// start watching for events on other windows
|
// start watching for events on other windows
|
||||||
selectEvents(display, m_screen->getRoot());
|
selectEvents(display, m_screen->getRoot());
|
||||||
|
@ -474,16 +474,16 @@ CXWindowsPrimaryScreen::showWindow()
|
||||||
GrabModeAsync, GrabModeAsync, CurrentTime);
|
GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||||
assert(result != GrabNotViewable);
|
assert(result != GrabNotViewable);
|
||||||
if (result != GrabSuccess) {
|
if (result != GrabSuccess) {
|
||||||
log((CLOG_DEBUG2 "waiting to grab keyboard"));
|
LOG((CLOG_DEBUG2 "waiting to grab keyboard"));
|
||||||
CThread::sleep(0.05);
|
CThread::sleep(0.05);
|
||||||
if (timer.getTime() >= s_timeout) {
|
if (timer.getTime() >= s_timeout) {
|
||||||
log((CLOG_DEBUG2 "grab keyboard timed out"));
|
LOG((CLOG_DEBUG2 "grab keyboard timed out"));
|
||||||
XUnmapWindow(display, m_window);
|
XUnmapWindow(display, m_window);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (result != GrabSuccess);
|
} while (result != GrabSuccess);
|
||||||
log((CLOG_DEBUG2 "grabbed keyboard"));
|
LOG((CLOG_DEBUG2 "grabbed keyboard"));
|
||||||
|
|
||||||
// now the mouse
|
// now the mouse
|
||||||
result = XGrabPointer(display, m_window, True, 0,
|
result = XGrabPointer(display, m_window, True, 0,
|
||||||
|
@ -493,16 +493,16 @@ CXWindowsPrimaryScreen::showWindow()
|
||||||
if (result != GrabSuccess) {
|
if (result != GrabSuccess) {
|
||||||
// back off to avoid grab deadlock
|
// back off to avoid grab deadlock
|
||||||
XUngrabKeyboard(display, CurrentTime);
|
XUngrabKeyboard(display, CurrentTime);
|
||||||
log((CLOG_DEBUG2 "ungrabbed keyboard, waiting to grab pointer"));
|
LOG((CLOG_DEBUG2 "ungrabbed keyboard, waiting to grab pointer"));
|
||||||
CThread::sleep(0.05);
|
CThread::sleep(0.05);
|
||||||
if (timer.getTime() >= s_timeout) {
|
if (timer.getTime() >= s_timeout) {
|
||||||
log((CLOG_DEBUG2 "grab pointer timed out"));
|
LOG((CLOG_DEBUG2 "grab pointer timed out"));
|
||||||
XUnmapWindow(display, m_window);
|
XUnmapWindow(display, m_window);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (result != GrabSuccess);
|
} while (result != GrabSuccess);
|
||||||
log((CLOG_DEBUG1 "grabbed pointer and keyboard"));
|
LOG((CLOG_DEBUG1 "grabbed pointer and keyboard"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,7 @@ CXWindowsPrimaryScreen::warpCursorNoFlush(
|
||||||
XSendEvent(display, m_window, False, 0, &eventAfter);
|
XSendEvent(display, m_window, False, 0, &eventAfter);
|
||||||
XSync(display, False);
|
XSync(display, False);
|
||||||
|
|
||||||
log((CLOG_DEBUG2 "warped to %d,%d", x, y));
|
LOG((CLOG_DEBUG2 "warped to %d,%d", x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -28,7 +28,7 @@ CProtocolUtil::writef(IOutputStream* stream, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
assert(stream != NULL);
|
assert(stream != NULL);
|
||||||
assert(fmt != NULL);
|
assert(fmt != NULL);
|
||||||
log((CLOG_DEBUG2 "writef(%s)", fmt));
|
LOG((CLOG_DEBUG2 "writef(%s)", fmt));
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ CProtocolUtil::writef(IOutputStream* stream, const char* fmt, ...)
|
||||||
UInt8* scan = buffer;
|
UInt8* scan = buffer;
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
const UInt32 n = stream->write(scan, count);
|
const UInt32 n = stream->write(scan, count);
|
||||||
log((CLOG_DEBUG2 "wrote %d of %d bytes", n, count));
|
LOG((CLOG_DEBUG2 "wrote %d of %d bytes", n, count));
|
||||||
count -= n;
|
count -= n;
|
||||||
scan += n;
|
scan += n;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ CProtocolUtil::readf(IInputStream* stream, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
assert(stream != NULL);
|
assert(stream != NULL);
|
||||||
assert(fmt != NULL);
|
assert(fmt != NULL);
|
||||||
log((CLOG_DEBUG2 "readf(%s)", fmt));
|
LOG((CLOG_DEBUG2 "readf(%s)", fmt));
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
@ -91,7 +91,7 @@ CProtocolUtil::readf(IInputStream* stream, const char* fmt, ...)
|
||||||
case 1:
|
case 1:
|
||||||
// 1 byte integer
|
// 1 byte integer
|
||||||
*reinterpret_cast<UInt8*>(v) = buffer[0];
|
*reinterpret_cast<UInt8*>(v) = buffer[0];
|
||||||
log((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt8*>(v), *reinterpret_cast<UInt8*>(v)));
|
LOG((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt8*>(v), *reinterpret_cast<UInt8*>(v)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -100,7 +100,7 @@ CProtocolUtil::readf(IInputStream* stream, const char* fmt, ...)
|
||||||
static_cast<UInt16>(
|
static_cast<UInt16>(
|
||||||
(static_cast<UInt16>(buffer[0]) << 8) |
|
(static_cast<UInt16>(buffer[0]) << 8) |
|
||||||
static_cast<UInt16>(buffer[1]));
|
static_cast<UInt16>(buffer[1]));
|
||||||
log((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt16*>(v), *reinterpret_cast<UInt16*>(v)));
|
LOG((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt16*>(v), *reinterpret_cast<UInt16*>(v)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
|
@ -110,7 +110,7 @@ CProtocolUtil::readf(IInputStream* stream, const char* fmt, ...)
|
||||||
(static_cast<UInt32>(buffer[1]) << 16) |
|
(static_cast<UInt32>(buffer[1]) << 16) |
|
||||||
(static_cast<UInt32>(buffer[2]) << 8) |
|
(static_cast<UInt32>(buffer[2]) << 8) |
|
||||||
static_cast<UInt32>(buffer[3]);
|
static_cast<UInt32>(buffer[3]);
|
||||||
log((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt32*>(v), *reinterpret_cast<UInt32*>(v)));
|
LOG((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt32*>(v), *reinterpret_cast<UInt32*>(v)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -149,7 +149,7 @@ CProtocolUtil::readf(IInputStream* stream, const char* fmt, ...)
|
||||||
}
|
}
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
log((CLOG_DEBUG2 "readf: read %d byte string: %.*s", len, len, sBuffer));
|
LOG((CLOG_DEBUG2 "readf: read %d byte string: %.*s", len, len, sBuffer));
|
||||||
|
|
||||||
// save the data
|
// save the data
|
||||||
CString* dst = va_arg(args, CString*);
|
CString* dst = va_arg(args, CString*);
|
||||||
|
@ -180,7 +180,7 @@ CProtocolUtil::readf(IInputStream* stream, const char* fmt, ...)
|
||||||
|
|
||||||
// verify match
|
// verify match
|
||||||
if (buffer[0] != *fmt) {
|
if (buffer[0] != *fmt) {
|
||||||
log((CLOG_DEBUG2 "readf: format mismatch: %c vs %c", *fmt, buffer[0]));
|
LOG((CLOG_DEBUG2 "readf: format mismatch: %c vs %c", *fmt, buffer[0]));
|
||||||
throw XIOReadMismatch();
|
throw XIOReadMismatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ CProtocolUtil::read(IInputStream* stream, void* vbuffer, UInt32 count)
|
||||||
|
|
||||||
// bail if stream has hungup
|
// bail if stream has hungup
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
log((CLOG_DEBUG2 "unexpected disconnect in readf(), %d bytes left", count));
|
LOG((CLOG_DEBUG2 "unexpected disconnect in readf(), %d bytes left", count));
|
||||||
throw XIOEndOfStream();
|
throw XIOEndOfStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue