mirror of
https://github.com/debauchee/barrier.git
synced 2026-05-09 16:02:46 +08:00
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:
@@ -47,7 +47,7 @@ void
|
||||
CClientProxy1_0::open()
|
||||
{
|
||||
// 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);
|
||||
getOutputStream()->flush();
|
||||
|
||||
@@ -86,14 +86,14 @@ CClientProxy1_0::mainLoop()
|
||||
|
||||
// check if client hungup
|
||||
if (n == 0) {
|
||||
log((CLOG_NOTE "client \"%s\" disconnected", getName().c_str()));
|
||||
LOG((CLOG_NOTE "client \"%s\" disconnected", getName().c_str()));
|
||||
return;
|
||||
}
|
||||
|
||||
// check if client has stopped sending heartbeats
|
||||
if (n == (UInt32)-1) {
|
||||
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;
|
||||
}
|
||||
continue;
|
||||
@@ -104,14 +104,14 @@ CClientProxy1_0::mainLoop()
|
||||
|
||||
// verify we got an entire code
|
||||
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
|
||||
throw XBadClient();
|
||||
}
|
||||
|
||||
// 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) {
|
||||
recvInfo(true);
|
||||
}
|
||||
@@ -127,7 +127,7 @@ CClientProxy1_0::mainLoop()
|
||||
}
|
||||
// note -- more message handlers go here
|
||||
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
|
||||
throw XBadClient();
|
||||
@@ -138,7 +138,7 @@ CClientProxy1_0::mainLoop()
|
||||
void
|
||||
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);
|
||||
|
||||
// force the close to be sent before we return
|
||||
@@ -149,7 +149,7 @@ void
|
||||
CClientProxy1_0::enter(SInt32 xAbs, SInt32 yAbs,
|
||||
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,
|
||||
xAbs, yAbs, seqNum, mask);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ CClientProxy1_0::enter(SInt32 xAbs, SInt32 yAbs,
|
||||
bool
|
||||
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);
|
||||
|
||||
// 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
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,7 @@ CClientProxy1_0::setClipboard(ClipboardID id, const CString& data)
|
||||
void
|
||||
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);
|
||||
|
||||
// this clipboard is now dirty
|
||||
@@ -199,56 +199,56 @@ CClientProxy1_0::setClipboardDirty(ClipboardID id, bool dirty)
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ CClientProxy1_0::recvInfo(bool notify)
|
||||
SInt16 x, y, w, h, zoneSize, mx, my;
|
||||
CProtocolUtil::readf(getInputStream(), kMsgDInfo + 4,
|
||||
&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
|
||||
if (w <= 0 || h <= 0 || zoneSize < 0) {
|
||||
@@ -319,7 +319,7 @@ CClientProxy1_0::recvInfo(bool notify)
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ CClientProxy1_0::recvClipboard()
|
||||
UInt32 seqNum;
|
||||
CString 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
|
||||
if (id >= kClipboardEnd) {
|
||||
@@ -350,7 +350,7 @@ CClientProxy1_0::recvGrabClipboard()
|
||||
ClipboardID id;
|
||||
UInt32 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
|
||||
if (id >= kClipboardEnd) {
|
||||
|
||||
@@ -80,13 +80,13 @@ CHTTPServer::processRequest(IDataSocket* socket)
|
||||
|
||||
// send 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
|
||||
delete request;
|
||||
}
|
||||
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
|
||||
delete request;
|
||||
@@ -256,7 +256,7 @@ CHTTPServer::doProcessPostEditMap(CHTTPRequest& request, CHTTPReply& reply)
|
||||
// parse the result
|
||||
CHTTPProtocol::CFormParts 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);
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ CHTTPServer::doProcessPostEditMap(CHTTPRequest& request, CHTTPReply& reply)
|
||||
if (index == parts.end() ||
|
||||
!parseXY(index->second, w, h) ||
|
||||
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);
|
||||
}
|
||||
ScreenSet screenNames;
|
||||
@@ -297,7 +297,7 @@ CHTTPServer::doProcessPostEditMap(CHTTPRequest& request, CHTTPReply& reply)
|
||||
// already been seen.
|
||||
if (screenNames.count(name)) {
|
||||
// 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);
|
||||
}
|
||||
// FIXME -- check that name is legal
|
||||
@@ -315,12 +315,12 @@ CHTTPServer::doProcessPostEditMap(CHTTPRequest& request, CHTTPReply& reply)
|
||||
if (screenNames.empty()) {
|
||||
// no screens
|
||||
// FIXME -- need better no screens
|
||||
log((CLOG_WARN "editmap: no screens"));
|
||||
LOG((CLOG_WARN "editmap: no screens"));
|
||||
throw XHTTP(400);
|
||||
}
|
||||
if (!screens.isValid()) {
|
||||
// FIXME -- need better unconnected screens error
|
||||
log((CLOG_WARN "editmap: unconnected screens"));
|
||||
LOG((CLOG_WARN "editmap: unconnected screens"));
|
||||
throw XHTTP(400);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ CMSWindowsPrimaryScreen::CMSWindowsPrimaryScreen(
|
||||
// load the hook library
|
||||
m_hookLibrary = LoadLibrary("synrgyhk");
|
||||
if (m_hookLibrary == NULL) {
|
||||
log((CLOG_ERR "failed to load hook library"));
|
||||
LOG((CLOG_ERR "failed to load hook library"));
|
||||
throw XScreenOpenFailure();
|
||||
}
|
||||
m_setSides = (SetSidesFunc)GetProcAddress(m_hookLibrary, "setSides");
|
||||
@@ -57,7 +57,7 @@ CMSWindowsPrimaryScreen::CMSWindowsPrimaryScreen(
|
||||
m_uninstall == NULL ||
|
||||
m_init == NULL ||
|
||||
m_cleanup == NULL) {
|
||||
log((CLOG_ERR "invalid hook library"));
|
||||
LOG((CLOG_ERR "invalid hook library"));
|
||||
FreeLibrary(m_hookLibrary);
|
||||
throw XScreenOpenFailure();
|
||||
}
|
||||
@@ -192,11 +192,11 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||
// key press
|
||||
const SInt32 repeat = (SInt32)(msg->lParam & 0xffff);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||
}
|
||||
else {
|
||||
// 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);
|
||||
|
||||
// update key state
|
||||
@@ -213,7 +213,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||
}
|
||||
}
|
||||
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;
|
||||
@@ -233,7 +233,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_RBUTTONDOWN:
|
||||
log((CLOG_DEBUG1 "event: button press button=%d", button));
|
||||
LOG((CLOG_DEBUG1 "event: button press button=%d", button));
|
||||
if (button != kButtonNone) {
|
||||
m_receiver->onMouseDown(button);
|
||||
m_keys[s_vkButton[button]] |= 0x80;
|
||||
@@ -243,7 +243,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||
case WM_LBUTTONUP:
|
||||
case WM_MBUTTONUP:
|
||||
case WM_RBUTTONUP:
|
||||
log((CLOG_DEBUG1 "event: button release button=%d", button));
|
||||
LOG((CLOG_DEBUG1 "event: button release button=%d", button));
|
||||
if (button != kButtonNone) {
|
||||
m_receiver->onMouseUp(button);
|
||||
m_keys[s_vkButton[button]] &= ~0x80;
|
||||
@@ -256,7 +256,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||
case SYNERGY_MSG_MOUSE_WHEEL:
|
||||
// ignore message if posted prior to last mark change
|
||||
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);
|
||||
}
|
||||
return true;
|
||||
@@ -282,7 +282,7 @@ CMSWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||
}
|
||||
|
||||
case SYNERGY_MSG_POST_WARP:
|
||||
log((CLOG_WARN "unmatched post warp"));
|
||||
LOG((CLOG_WARN "unmatched post warp"));
|
||||
return true;
|
||||
|
||||
case SYNERGY_MSG_MOUSE_MOVE:
|
||||
@@ -413,7 +413,7 @@ CMSWindowsPrimaryScreen::onPreOpen()
|
||||
// initialize hook library
|
||||
m_threadID = GetCurrentThreadId();
|
||||
if (m_init(m_threadID) == 0) {
|
||||
log((CLOG_ERR "cannot initialize hook library"));
|
||||
LOG((CLOG_ERR "cannot initialize hook library"));
|
||||
throw XScreenOpenFailure();
|
||||
}
|
||||
}
|
||||
@@ -927,12 +927,12 @@ CMSWindowsPrimaryScreen::mapKey(
|
||||
mask &= ~(KeyModifierControl | KeyModifierAlt);
|
||||
}
|
||||
*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
|
||||
UINT scanCode = static_cast<UINT>((info & 0x00ff0000u) >> 16);
|
||||
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
|
||||
KeyID id = g_virtualKey[vkCode][extended];
|
||||
|
||||
@@ -36,7 +36,7 @@ CPrimaryClient::CPrimaryClient(IPrimaryScreenFactory* screenFactory,
|
||||
assert(m_server != NULL);
|
||||
|
||||
// create screen
|
||||
log((CLOG_DEBUG1 "creating primary screen"));
|
||||
LOG((CLOG_DEBUG1 "creating primary screen"));
|
||||
if (screenFactory != NULL) {
|
||||
m_screen = screenFactory->create(this, receiver);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ CPrimaryClient::CPrimaryClient(IPrimaryScreenFactory* screenFactory,
|
||||
|
||||
CPrimaryClient::~CPrimaryClient()
|
||||
{
|
||||
log((CLOG_DEBUG1 "destroying primary screen"));
|
||||
LOG((CLOG_DEBUG1 "destroying primary screen"));
|
||||
delete m_screen;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,15 +44,15 @@ CPrimaryScreen::mainLoop()
|
||||
|
||||
// run event loop
|
||||
try {
|
||||
log((CLOG_DEBUG "entering event loop"));
|
||||
LOG((CLOG_DEBUG "entering event loop"));
|
||||
onPreMainLoop();
|
||||
getScreen()->mainLoop();
|
||||
onPostMainLoop();
|
||||
log((CLOG_DEBUG "exiting event loop"));
|
||||
LOG((CLOG_DEBUG "exiting event loop"));
|
||||
}
|
||||
catch (...) {
|
||||
onPostMainLoop();
|
||||
log((CLOG_DEBUG "exiting event loop"));
|
||||
LOG((CLOG_DEBUG "exiting event loop"));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ CPrimaryScreen::close()
|
||||
void
|
||||
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);
|
||||
assert(m_active == true);
|
||||
|
||||
@@ -153,7 +153,7 @@ CPrimaryScreen::enterNoWarp()
|
||||
bool
|
||||
CPrimaryScreen::leave()
|
||||
{
|
||||
log((CLOG_INFO "leaving primary"));
|
||||
LOG((CLOG_INFO "leaving primary"));
|
||||
CLock lock(&m_mutex);
|
||||
assert(m_active == false);
|
||||
|
||||
|
||||
@@ -72,17 +72,17 @@ CServer::open()
|
||||
{
|
||||
// open the screen
|
||||
try {
|
||||
log((CLOG_INFO "opening screen"));
|
||||
LOG((CLOG_INFO "opening screen"));
|
||||
openPrimaryScreen();
|
||||
}
|
||||
catch (XScreen&) {
|
||||
// can't open screen
|
||||
log((CLOG_INFO "failed to open screen"));
|
||||
LOG((CLOG_INFO "failed to open screen"));
|
||||
throw;
|
||||
}
|
||||
catch (XUnknownClient& e) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ CServer::mainLoop()
|
||||
}
|
||||
|
||||
try {
|
||||
log((CLOG_NOTE "starting server"));
|
||||
LOG((CLOG_NOTE "starting server"));
|
||||
|
||||
// start listening for new clients
|
||||
m_acceptClientThread = new CThread(startThread(
|
||||
@@ -115,7 +115,7 @@ CServer::mainLoop()
|
||||
m_primaryClient->mainLoop();
|
||||
|
||||
// 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
|
||||
// block so we can repeat it easily. stroustrup's view that
|
||||
@@ -131,23 +131,23 @@ CServer::mainLoop()
|
||||
FINALLY;
|
||||
}
|
||||
catch (XBase& e) {
|
||||
log((CLOG_ERR "server error: %s", e.what()));
|
||||
LOG((CLOG_ERR "server error: %s", e.what()));
|
||||
|
||||
// clean up
|
||||
log((CLOG_NOTE "stopping server"));
|
||||
LOG((CLOG_NOTE "stopping server"));
|
||||
FINALLY;
|
||||
}
|
||||
catch (XThread&) {
|
||||
// clean up
|
||||
log((CLOG_NOTE "stopping server"));
|
||||
LOG((CLOG_NOTE "stopping server"));
|
||||
FINALLY;
|
||||
throw;
|
||||
}
|
||||
catch (...) {
|
||||
log((CLOG_DEBUG "unknown server error"));
|
||||
LOG((CLOG_DEBUG "unknown server error"));
|
||||
|
||||
// clean up
|
||||
log((CLOG_NOTE "stopping server"));
|
||||
LOG((CLOG_NOTE "stopping server"));
|
||||
FINALLY;
|
||||
throw;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ CServer::close()
|
||||
if (m_primaryClient != NULL) {
|
||||
closePrimaryScreen();
|
||||
}
|
||||
log((CLOG_INFO "closed screen"));
|
||||
LOG((CLOG_INFO "closed screen"));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -289,7 +289,7 @@ CServer::onInfoChanged(const CString& name, const CClientInfo& info)
|
||||
m_x = info.m_mx;
|
||||
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
|
||||
if (client == m_primaryClient) {
|
||||
@@ -318,12 +318,12 @@ CServer::onGrabClipboard(const CString& name, ClipboardID id, UInt32 seqNum)
|
||||
CClipboardInfo& clipboard = m_clipboards[id];
|
||||
if (name != m_primaryClient->getName() &&
|
||||
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;
|
||||
}
|
||||
|
||||
// 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_clipboardSeqNum = seqNum;
|
||||
|
||||
@@ -365,18 +365,18 @@ CServer::onClipboardChangedNoLock(ClipboardID id,
|
||||
|
||||
// ignore update if sequence number is old
|
||||
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;
|
||||
}
|
||||
|
||||
// ignore if data hasn't changed
|
||||
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;
|
||||
}
|
||||
|
||||
// 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_clipboard.unmarshall(clipboard.m_clipboardData, 0);
|
||||
|
||||
@@ -396,7 +396,7 @@ CServer::onClipboardChangedNoLock(ClipboardID id,
|
||||
void
|
||||
CServer::onScreensaver(bool activated)
|
||||
{
|
||||
log((CLOG_DEBUG "onScreenSaver %s", activated ? "activated" : "deactivated"));
|
||||
LOG((CLOG_DEBUG "onScreenSaver %s", activated ? "activated" : "deactivated"));
|
||||
CLock lock(&m_mutex);
|
||||
|
||||
if (activated) {
|
||||
@@ -452,7 +452,7 @@ CServer::onScreensaver(bool activated)
|
||||
void
|
||||
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);
|
||||
assert(m_active != NULL);
|
||||
|
||||
@@ -468,7 +468,7 @@ CServer::onKeyDown(KeyID id, KeyModifierMask mask)
|
||||
void
|
||||
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);
|
||||
assert(m_active != NULL);
|
||||
|
||||
@@ -484,7 +484,7 @@ CServer::onKeyUp(KeyID id, KeyModifierMask mask)
|
||||
void
|
||||
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);
|
||||
assert(m_active != NULL);
|
||||
|
||||
@@ -501,7 +501,7 @@ CServer::onKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count)
|
||||
void
|
||||
CServer::onMouseDown(ButtonID id)
|
||||
{
|
||||
log((CLOG_DEBUG1 "onMouseDown id=%d", id));
|
||||
LOG((CLOG_DEBUG1 "onMouseDown id=%d", id));
|
||||
CLock lock(&m_mutex);
|
||||
assert(m_active != NULL);
|
||||
|
||||
@@ -512,7 +512,7 @@ CServer::onMouseDown(ButtonID id)
|
||||
void
|
||||
CServer::onMouseUp(ButtonID id)
|
||||
{
|
||||
log((CLOG_DEBUG1 "onMouseUp id=%d", id));
|
||||
LOG((CLOG_DEBUG1 "onMouseUp id=%d", id));
|
||||
CLock lock(&m_mutex);
|
||||
assert(m_active != NULL);
|
||||
|
||||
@@ -523,7 +523,7 @@ CServer::onMouseUp(ButtonID id)
|
||||
bool
|
||||
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);
|
||||
return onMouseMovePrimaryNoLock(x, y);
|
||||
}
|
||||
@@ -550,22 +550,22 @@ CServer::onMouseMovePrimaryNoLock(SInt32 x, SInt32 y)
|
||||
if (x < ax + zoneSize) {
|
||||
x -= zoneSize;
|
||||
dir = kLeft;
|
||||
log((CLOG_DEBUG1 "switch to left"));
|
||||
LOG((CLOG_DEBUG1 "switch to left"));
|
||||
}
|
||||
else if (x >= ax + aw - zoneSize) {
|
||||
x += zoneSize;
|
||||
dir = kRight;
|
||||
log((CLOG_DEBUG1 "switch to right"));
|
||||
LOG((CLOG_DEBUG1 "switch to right"));
|
||||
}
|
||||
else if (y < ay + zoneSize) {
|
||||
y -= zoneSize;
|
||||
dir = kTop;
|
||||
log((CLOG_DEBUG1 "switch to top"));
|
||||
LOG((CLOG_DEBUG1 "switch to top"));
|
||||
}
|
||||
else if (y >= ay + ah - zoneSize) {
|
||||
y += zoneSize;
|
||||
dir = kBottom;
|
||||
log((CLOG_DEBUG1 "switch to bottom"));
|
||||
LOG((CLOG_DEBUG1 "switch to bottom"));
|
||||
}
|
||||
else {
|
||||
// still on local screen
|
||||
@@ -587,7 +587,7 @@ CServer::onMouseMovePrimaryNoLock(SInt32 x, SInt32 y)
|
||||
void
|
||||
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);
|
||||
onMouseMoveSecondaryNoLock(dx, dy);
|
||||
}
|
||||
@@ -647,12 +647,12 @@ CServer::onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy)
|
||||
|
||||
// get neighbor if we should switch
|
||||
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
|
||||
newScreen = getNeighbor(m_active, dir, m_x, m_y);
|
||||
if (newScreen == NULL) {
|
||||
log((CLOG_DEBUG1 "no neighbor; clamping"));
|
||||
LOG((CLOG_DEBUG1 "no neighbor; clamping"));
|
||||
if (m_x < ax) {
|
||||
m_x = ax;
|
||||
}
|
||||
@@ -670,7 +670,7 @@ CServer::onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy)
|
||||
}
|
||||
else {
|
||||
// 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) {
|
||||
m_x = ax;
|
||||
}
|
||||
@@ -689,7 +689,7 @@ CServer::onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy)
|
||||
if (newScreen == NULL || newScreen == m_active) {
|
||||
// do nothing if mouse didn't move
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -703,7 +703,7 @@ CServer::onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy)
|
||||
void
|
||||
CServer::onMouseWheel(SInt32 delta)
|
||||
{
|
||||
log((CLOG_DEBUG1 "onMouseWheel %+d", delta));
|
||||
LOG((CLOG_DEBUG1 "onMouseWheel %+d", delta));
|
||||
CLock lock(&m_mutex);
|
||||
assert(m_active != NULL);
|
||||
|
||||
@@ -749,7 +749,7 @@ CServer::switchScreen(IClient* dst, SInt32 x, SInt32 y, bool forScreensaver)
|
||||
#endif
|
||||
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
|
||||
m_x = x;
|
||||
@@ -762,7 +762,7 @@ CServer::switchScreen(IClient* dst, SInt32 x, SInt32 y, bool forScreensaver)
|
||||
// leave active screen
|
||||
if (!m_active->leave()) {
|
||||
// cannot leave screen
|
||||
log((CLOG_WARN "can't leave screen"));
|
||||
LOG((CLOG_WARN "can't leave screen"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -808,14 +808,14 @@ CServer::getNeighbor(IClient* src, EDirection dir) const
|
||||
|
||||
CString srcName = src->getName();
|
||||
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 (;;) {
|
||||
// look up name of neighbor
|
||||
const CString dstName(m_config.getNeighbor(srcName, dir));
|
||||
|
||||
// if nothing in that direction then return NULL
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -824,11 +824,11 @@ CServer::getNeighbor(IClient* src, EDirection dir) const
|
||||
// unconnected screen.
|
||||
CClientList::const_iterator index = m_clients.find(dstName);
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -867,7 +867,7 @@ CServer::getNeighbor(IClient* src,
|
||||
if (x >= 0) {
|
||||
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);
|
||||
}
|
||||
assert(lastGoodScreen != NULL);
|
||||
@@ -883,7 +883,7 @@ CServer::getNeighbor(IClient* src,
|
||||
if (x < dw) {
|
||||
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);
|
||||
}
|
||||
assert(lastGoodScreen != NULL);
|
||||
@@ -899,7 +899,7 @@ CServer::getNeighbor(IClient* src,
|
||||
if (y >= 0) {
|
||||
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);
|
||||
}
|
||||
assert(lastGoodScreen != NULL);
|
||||
@@ -915,7 +915,7 @@ CServer::getNeighbor(IClient* src,
|
||||
if (y < sh) {
|
||||
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);
|
||||
}
|
||||
assert(lastGoodScreen != NULL);
|
||||
@@ -1073,14 +1073,14 @@ CServer::startThread(IJob* job)
|
||||
// add new thread to list. use the job as user data for logging.
|
||||
CThread thread(job, job);
|
||||
m_threads.push_back(thread);
|
||||
log((CLOG_DEBUG1 "started thread %p", thread.getUserData()));
|
||||
LOG((CLOG_DEBUG1 "started thread %p", thread.getUserData()));
|
||||
return thread;
|
||||
}
|
||||
|
||||
void
|
||||
CServer::stopThreads(double timeout)
|
||||
{
|
||||
log((CLOG_DEBUG1 "stopping threads"));
|
||||
LOG((CLOG_DEBUG1 "stopping threads"));
|
||||
|
||||
// cancel the accept client thread to prevent more clients from
|
||||
// connecting while we're shutting down.
|
||||
@@ -1125,10 +1125,10 @@ CServer::stopThreads(double timeout)
|
||||
// delete remaining threads
|
||||
for (CThreadList::iterator index = threads.begin();
|
||||
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
|
||||
@@ -1145,7 +1145,7 @@ CServer::doReapThreads(CThreadList& threads)
|
||||
index != threads.end(); ) {
|
||||
if (index->wait(0.0)) {
|
||||
// thread terminated
|
||||
log((CLOG_DEBUG1 "reaped thread %p", index->getUserData()));
|
||||
LOG((CLOG_DEBUG1 "reaped thread %p", index->getUserData()));
|
||||
index = threads.erase(index);
|
||||
}
|
||||
else {
|
||||
@@ -1158,7 +1158,7 @@ CServer::doReapThreads(CThreadList& threads)
|
||||
void
|
||||
CServer::acceptClients(void*)
|
||||
{
|
||||
log((CLOG_DEBUG1 "starting to wait for clients"));
|
||||
LOG((CLOG_DEBUG1 "starting to wait for clients"));
|
||||
|
||||
IListenSocket* listen = NULL;
|
||||
try {
|
||||
@@ -1173,16 +1173,16 @@ CServer::acceptClients(void*)
|
||||
CStopwatch timer;
|
||||
for (;;) {
|
||||
try {
|
||||
log((CLOG_DEBUG1 "binding listen socket"));
|
||||
LOG((CLOG_DEBUG1 "binding listen socket"));
|
||||
listen->bind(m_config.getSynergyAddress());
|
||||
break;
|
||||
}
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1192,12 +1192,12 @@ CServer::acceptClients(void*)
|
||||
}
|
||||
|
||||
// accept connections and begin processing them
|
||||
log((CLOG_DEBUG1 "waiting for client connections"));
|
||||
LOG((CLOG_DEBUG1 "waiting for client connections"));
|
||||
for (;;) {
|
||||
// accept connection
|
||||
CThread::testCancel();
|
||||
IDataSocket* socket = listen->accept();
|
||||
log((CLOG_NOTE "accepted client connection"));
|
||||
LOG((CLOG_NOTE "accepted client connection"));
|
||||
CThread::testCancel();
|
||||
|
||||
// start handshake thread
|
||||
@@ -1209,7 +1209,7 @@ CServer::acceptClients(void*)
|
||||
delete listen;
|
||||
}
|
||||
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;
|
||||
exitMainLoop();
|
||||
}
|
||||
@@ -1251,7 +1251,7 @@ CServer::runClient(void* vsocket)
|
||||
}
|
||||
catch (XDuplicateClient& e) {
|
||||
// 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);
|
||||
delete proxy;
|
||||
delete socket;
|
||||
@@ -1259,7 +1259,7 @@ CServer::runClient(void* vsocket)
|
||||
}
|
||||
catch (XUnknownClient& e) {
|
||||
// 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);
|
||||
delete proxy;
|
||||
delete socket;
|
||||
@@ -1281,17 +1281,17 @@ CServer::runClient(void* vsocket)
|
||||
|
||||
// handle client messages
|
||||
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();
|
||||
}
|
||||
catch (XBadClient&) {
|
||||
// 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);
|
||||
}
|
||||
catch (XBase& e) {
|
||||
// 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 (...) {
|
||||
// mainLoop() was probably cancelled
|
||||
@@ -1308,7 +1308,7 @@ CServer::runClient(void* vsocket)
|
||||
CClientProxy*
|
||||
CServer::handshakeClient(IDataSocket* socket)
|
||||
{
|
||||
log((CLOG_DEBUG1 "negotiating with new client"));
|
||||
LOG((CLOG_DEBUG1 "negotiating with new client"));
|
||||
|
||||
// get the input and output streams
|
||||
IInputStream* input = socket->getInputStream();
|
||||
@@ -1334,14 +1334,14 @@ CServer::handshakeClient(IDataSocket* socket)
|
||||
CTimerThread timer(30.0);
|
||||
|
||||
// say hello
|
||||
log((CLOG_DEBUG1 "saying hello"));
|
||||
LOG((CLOG_DEBUG1 "saying hello"));
|
||||
CProtocolUtil::writef(output, kMsgHello,
|
||||
kProtocolMajorVersion,
|
||||
kProtocolMinorVersion);
|
||||
output->flush();
|
||||
|
||||
// wait for the reply
|
||||
log((CLOG_DEBUG1 "waiting for hello reply"));
|
||||
LOG((CLOG_DEBUG1 "waiting for hello reply"));
|
||||
UInt32 n = input->getSize();
|
||||
|
||||
// limit the maximum length of the hello
|
||||
@@ -1352,7 +1352,7 @@ CServer::handshakeClient(IDataSocket* socket)
|
||||
// get and parse the reply to hello
|
||||
SInt16 major, minor;
|
||||
try {
|
||||
log((CLOG_DEBUG1 "parsing hello reply"));
|
||||
LOG((CLOG_DEBUG1 "parsing hello reply"));
|
||||
CProtocolUtil::readf(input, kMsgHelloBack,
|
||||
&major, &minor, &name);
|
||||
}
|
||||
@@ -1382,32 +1382,32 @@ CServer::handshakeClient(IDataSocket* socket)
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// negotiate
|
||||
// FIXME
|
||||
|
||||
// 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();
|
||||
|
||||
return proxy;
|
||||
}
|
||||
catch (XIncompatibleClient& e) {
|
||||
// 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,
|
||||
kProtocolMajorVersion, kProtocolMinorVersion);
|
||||
}
|
||||
catch (XBadClient&) {
|
||||
// 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);
|
||||
}
|
||||
catch (XBase& e) {
|
||||
// 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 (...) {
|
||||
// probably timed out
|
||||
@@ -1436,7 +1436,7 @@ CServer::handshakeClient(IDataSocket* socket)
|
||||
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;
|
||||
try {
|
||||
@@ -1448,16 +1448,16 @@ CServer::acceptHTTPClients(void*)
|
||||
CStopwatch timer;
|
||||
for (;;) {
|
||||
try {
|
||||
log((CLOG_DEBUG1 "binding HTTP listen socket"));
|
||||
LOG((CLOG_DEBUG1 "binding HTTP listen socket"));
|
||||
listen->bind(m_config.getHTTPAddress());
|
||||
break;
|
||||
}
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1467,7 +1467,7 @@ CServer::acceptHTTPClients(void*)
|
||||
}
|
||||
|
||||
// accept connections and begin processing them
|
||||
log((CLOG_DEBUG1 "waiting for HTTP connections"));
|
||||
LOG((CLOG_DEBUG1 "waiting for HTTP connections"));
|
||||
for (;;) {
|
||||
// limit the number of HTTP requests being handled at once
|
||||
{
|
||||
@@ -1482,7 +1482,7 @@ CServer::acceptHTTPClients(void*)
|
||||
// accept connection
|
||||
CThread::testCancel();
|
||||
IDataSocket* socket = listen->accept();
|
||||
log((CLOG_NOTE "accepted HTTP connection"));
|
||||
LOG((CLOG_NOTE "accepted HTTP connection"));
|
||||
CThread::testCancel();
|
||||
|
||||
// handle HTTP request
|
||||
@@ -1494,7 +1494,7 @@ CServer::acceptHTTPClients(void*)
|
||||
delete listen;
|
||||
}
|
||||
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;
|
||||
exitMainLoop();
|
||||
}
|
||||
@@ -1574,7 +1574,7 @@ CServer::openPrimaryScreen()
|
||||
m_active = m_primaryClient;
|
||||
|
||||
// open the screen
|
||||
log((CLOG_DEBUG1 "opening primary screen"));
|
||||
LOG((CLOG_DEBUG1 "opening primary screen"));
|
||||
m_primaryClient->open();
|
||||
|
||||
// tell it about the active sides
|
||||
@@ -1600,7 +1600,7 @@ CServer::closePrimaryScreen()
|
||||
|
||||
// close the primary screen
|
||||
try {
|
||||
log((CLOG_DEBUG1 "closing primary screen"));
|
||||
LOG((CLOG_DEBUG1 "closing primary screen"));
|
||||
m_primaryClient->close();
|
||||
}
|
||||
catch (...) {
|
||||
@@ -1617,7 +1617,7 @@ CServer::addConnection(IClient* client)
|
||||
{
|
||||
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);
|
||||
|
||||
@@ -1633,13 +1633,13 @@ CServer::addConnection(IClient* client)
|
||||
|
||||
// save screen info
|
||||
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
|
||||
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);
|
||||
|
||||
// find client
|
||||
@@ -1653,7 +1653,7 @@ CServer::removeConnection(const CString& name)
|
||||
m_primaryClient->getCursorCenter(m_x, m_y);
|
||||
|
||||
// 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
|
||||
m_active = m_primaryClient;
|
||||
|
||||
@@ -182,7 +182,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
|
||||
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 KeyID key = mapKey(&xevent.xkey);
|
||||
if (key != kKeyNone) {
|
||||
@@ -223,7 +223,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
}
|
||||
if (!hasPress) {
|
||||
// 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) {
|
||||
m_receiver->onKeyDown(key, mask);
|
||||
}
|
||||
@@ -237,7 +237,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
// we could attempt to count the already queued
|
||||
// repeats but we'll just send a repeat of 1.
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@@ -246,7 +246,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
|
||||
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);
|
||||
if (button != kButtonNone) {
|
||||
m_receiver->onMouseDown(button);
|
||||
@@ -256,7 +256,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
|
||||
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);
|
||||
if (button != kButtonNone) {
|
||||
m_receiver->onMouseUp(button);
|
||||
@@ -274,7 +274,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
|
||||
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
|
||||
// mouse position)
|
||||
@@ -427,7 +427,7 @@ CXWindowsPrimaryScreen::createWindow()
|
||||
if (m_window == None) {
|
||||
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
|
||||
selectEvents(display, m_screen->getRoot());
|
||||
@@ -474,16 +474,16 @@ CXWindowsPrimaryScreen::showWindow()
|
||||
GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||
assert(result != GrabNotViewable);
|
||||
if (result != GrabSuccess) {
|
||||
log((CLOG_DEBUG2 "waiting to grab keyboard"));
|
||||
LOG((CLOG_DEBUG2 "waiting to grab keyboard"));
|
||||
CThread::sleep(0.05);
|
||||
if (timer.getTime() >= s_timeout) {
|
||||
log((CLOG_DEBUG2 "grab keyboard timed out"));
|
||||
LOG((CLOG_DEBUG2 "grab keyboard timed out"));
|
||||
XUnmapWindow(display, m_window);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} while (result != GrabSuccess);
|
||||
log((CLOG_DEBUG2 "grabbed keyboard"));
|
||||
LOG((CLOG_DEBUG2 "grabbed keyboard"));
|
||||
|
||||
// now the mouse
|
||||
result = XGrabPointer(display, m_window, True, 0,
|
||||
@@ -493,16 +493,16 @@ CXWindowsPrimaryScreen::showWindow()
|
||||
if (result != GrabSuccess) {
|
||||
// back off to avoid grab deadlock
|
||||
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);
|
||||
if (timer.getTime() >= s_timeout) {
|
||||
log((CLOG_DEBUG2 "grab pointer timed out"));
|
||||
LOG((CLOG_DEBUG2 "grab pointer timed out"));
|
||||
XUnmapWindow(display, m_window);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} while (result != GrabSuccess);
|
||||
log((CLOG_DEBUG1 "grabbed pointer and keyboard"));
|
||||
LOG((CLOG_DEBUG1 "grabbed pointer and keyboard"));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -554,7 +554,7 @@ CXWindowsPrimaryScreen::warpCursorNoFlush(
|
||||
XSendEvent(display, m_window, False, 0, &eventAfter);
|
||||
XSync(display, False);
|
||||
|
||||
log((CLOG_DEBUG2 "warped to %d,%d", x, y));
|
||||
LOG((CLOG_DEBUG2 "warped to %d,%d", x, y));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user