refactor: update log calls to LOG_... fixes #8819

This commit is contained in:
sithlord48 2025-08-06 07:54:59 -04:00 committed by Nick Bolton
parent 4f644acbca
commit 2a84ef0ebf
64 changed files with 707 additions and 726 deletions

View file

@ -78,7 +78,7 @@ int ArchDaemonUnix::daemonize(const char *name, DaemonFunc const &func)
// TODO: this is a bit of a hack - can we find a better solution? // TODO: this is a bit of a hack - can we find a better solution?
if (int chdirErr = chdir("/"); chdirErr) if (int chdirErr = chdir("/"); chdirErr)
// NB: file logging actually isn't working at this point! // NB: file logging actually isn't working at this point!
LOG((CLOG_ERR "chdir error: %i", chdirErr)); LOG_ERR("chdir error: %i", chdirErr);
#endif #endif
// mask off permissions for any but owner // mask off permissions for any but owner
@ -96,7 +96,7 @@ int ArchDaemonUnix::daemonize(const char *name, DaemonFunc const &func)
if (int dupErr = dup(1); dupErr < 0) { if (int dupErr = dup(1); dupErr < 0) {
// NB: file logging actually isn't working at this point! // NB: file logging actually isn't working at this point!
LOG((CLOG_ERR "dup error: %i", dupErr)); LOG_ERR("dup error: %i", dupErr);
} }
#ifdef __APPLE__ #ifdef __APPLE__

View file

@ -322,7 +322,7 @@ bool ArchMiscWindows::wasLaunchedAsService()
{ {
std::string name; std::string name;
if (!getParentProcessName(name)) { if (!getParentProcessName(name)) {
LOG((CLOG_ERR "cannot determine if process was launched as service")); LOG_ERR("cannot determine if process was launched as service");
return false; return false;
} }
@ -333,7 +333,7 @@ bool ArchMiscWindows::getParentProcessName(std::string &name)
{ {
PROCESSENTRY32 parentEntry; PROCESSENTRY32 parentEntry;
if (!getParentProcessEntry(parentEntry)) { if (!getParentProcessEntry(parentEntry)) {
LOG((CLOG_ERR "could not get entry for parent process")); LOG_ERR("could not get entry for parent process");
return false; return false;
} }
@ -364,7 +364,7 @@ BOOL WINAPI ArchMiscWindows::getProcessEntry(PROCESSENTRY32 &entry, DWORD proces
// first we need to take a snapshot of the running processes // first we need to take a snapshot of the running processes
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (snapshot == INVALID_HANDLE_VALUE) { if (snapshot == INVALID_HANDLE_VALUE) {
LOG((CLOG_ERR "could not get process snapshot (error: %i)", GetLastError())); LOG_ERR("could not get process snapshot (error: %i)", GetLastError());
return FALSE; return FALSE;
} }
@ -374,7 +374,7 @@ BOOL WINAPI ArchMiscWindows::getProcessEntry(PROCESSENTRY32 &entry, DWORD proces
// unlikely we can go any further // unlikely we can go any further
BOOL gotEntry = Process32First(snapshot, &entry); BOOL gotEntry = Process32First(snapshot, &entry);
if (!gotEntry) { if (!gotEntry) {
LOG((CLOG_ERR "could not get first process entry (error: %i)", GetLastError())); LOG_ERR("could not get first process entry (error: %i)", GetLastError());
return FALSE; return FALSE;
} }
@ -409,7 +409,7 @@ std::string ArchMiscWindows::getActiveDesktopName()
{ {
HDESK desk = OpenInputDesktop(0, TRUE, GENERIC_READ); HDESK desk = OpenInputDesktop(0, TRUE, GENERIC_READ);
if (desk == nullptr) { if (desk == nullptr) {
LOG((CLOG_ERR "could not open input desktop")); LOG_ERR("could not open input desktop");
throw std::runtime_error(windowsErrorToString(GetLastError())); throw std::runtime_error(windowsErrorToString(GetLastError()));
} }

View file

@ -51,9 +51,9 @@ void EventQueue::loop()
*m_readyCondVar = true; *m_readyCondVar = true;
m_readyCondVar->signal(); m_readyCondVar->signal();
} }
LOG((CLOG_DEBUG "event queue is ready")); LOG_DEBUG("event queue is ready");
while (!m_pending.empty()) { while (!m_pending.empty()) {
LOG((CLOG_DEBUG "add pending events to buffer")); LOG_DEBUG("add pending events to buffer");
const Event &event = m_pending.front(); const Event &event = m_pending.front();
addEventToBuffer(event); addEventToBuffer(event);
m_pending.pop(); m_pending.pop();
@ -72,12 +72,12 @@ void EventQueue::adoptBuffer(IEventQueueBuffer *buffer)
{ {
std::scoped_lock lock{m_mutex}; std::scoped_lock lock{m_mutex};
LOG((CLOG_DEBUG "adopting new buffer")); LOG_DEBUG("adopting new buffer");
if (m_events.size() != 0) { if (m_events.size() != 0) {
// this can come as a nasty surprise to programmers expecting // this can come as a nasty surprise to programmers expecting
// their events to be raised, only to have them deleted. // their events to be raised, only to have them deleted.
LOG((CLOG_DEBUG "discarding %d event(s)", m_events.size())); LOG_DEBUG("discarding %d event(s)", m_events.size());
} }
// discard old buffer and old events // discard old buffer and old events

View file

@ -124,7 +124,7 @@ void Client::connect(size_t addressIndex)
m_stream = new PacketStreamFilter(m_events, socket, true); m_stream = new PacketStreamFilter(m_events, socket, true);
// connect // connect
LOG((CLOG_DEBUG1 "connecting to server")); LOG_DEBUG1("connecting to server");
setupConnecting(); setupConnecting();
setupTimer(); setupTimer();
socket->connect(m_serverAddress); socket->connect(m_serverAddress);
@ -132,7 +132,7 @@ void Client::connect(size_t addressIndex)
cleanupTimer(); cleanupTimer();
cleanupConnecting(); cleanupConnecting();
cleanupStream(); cleanupStream();
LOG((CLOG_DEBUG1 "connection failed")); LOG_DEBUG1("connection failed");
sendConnectionFailedEvent(e.what()); sendConnectionFailedEvent(e.what());
return; return;
} }
@ -305,7 +305,7 @@ void Client::setOptions(const OptionsList &options)
index++; index++;
if (index != options.end()) { if (index != options.end()) {
if (!*index) { if (!*index) {
LOG((CLOG_NOTE "clipboard sharing disabled by server")); LOG_NOTE("clipboard sharing disabled by server");
} }
m_enableClipboard = *index; m_enableClipboard = *index;
} }
@ -319,8 +319,7 @@ void Client::setOptions(const OptionsList &options)
if (m_enableClipboard && !m_maximumClipboardSize) { if (m_enableClipboard && !m_maximumClipboardSize) {
m_enableClipboard = false; m_enableClipboard = false;
LOG((CLOG_NOTE "clipboard sharing is disabled because the server " LOG_NOTE("clipboard sharing is disabled because the server set the maximum clipboard size to 0");
"set the maximum clipboard size to 0"));
} }
m_screen->setOptions(options); m_screen->setOptions(options);
@ -509,7 +508,7 @@ void Client::cleanupStream()
void Client::handleConnected() void Client::handleConnected()
{ {
LOG((CLOG_DEBUG1 "connected, waiting for hello")); LOG_DEBUG1("connected, waiting for hello");
cleanupConnecting(); cleanupConnecting();
setupConnection(); setupConnection();
@ -528,7 +527,7 @@ void Client::handleConnectionFailed(const Event &event)
cleanupTimer(); cleanupTimer();
cleanupConnecting(); cleanupConnecting();
cleanupStream(); cleanupStream();
LOG((CLOG_DEBUG1 "connection failed")); LOG_DEBUG1("connection failed");
sendConnectionFailedEvent(info->m_what.c_str()); sendConnectionFailedEvent(info->m_what.c_str());
delete info; delete info;
} }
@ -539,7 +538,7 @@ void Client::handleConnectTimeout()
cleanupConnecting(); cleanupConnecting();
cleanupConnection(); cleanupConnection();
cleanupStream(); cleanupStream();
LOG((CLOG_DEBUG1 "connection timed out")); LOG_DEBUG1("connection timed out");
sendConnectionFailedEvent("Timed out"); sendConnectionFailedEvent("Timed out");
} }
@ -548,7 +547,7 @@ void Client::handleOutputError()
cleanupTimer(); cleanupTimer();
cleanupScreen(); cleanupScreen();
cleanupConnection(); cleanupConnection();
LOG((CLOG_WARN "error sending to server")); LOG_WARN("error sending to server");
sendEvent(EventTypes::ClientDisconnected, nullptr); sendEvent(EventTypes::ClientDisconnected, nullptr);
} }
@ -557,13 +556,13 @@ void Client::handleDisconnected()
cleanupTimer(); cleanupTimer();
cleanupScreen(); cleanupScreen();
cleanupConnection(); cleanupConnection();
LOG((CLOG_DEBUG1 "disconnected")); LOG_DEBUG1("disconnected");
sendEvent(EventTypes::ClientDisconnected, nullptr); sendEvent(EventTypes::ClientDisconnected, nullptr);
} }
void Client::handleShapeChanged() void Client::handleShapeChanged()
{ {
LOG((CLOG_DEBUG "resolution changed")); LOG_DEBUG("resolution changed");
m_server->onInfoChanged(); m_server->onInfoChanged();
} }
@ -609,7 +608,7 @@ void Client::handleHello()
void Client::handleSuspend() void Client::handleSuspend()
{ {
if (!m_suspended) { if (!m_suspended) {
LOG((CLOG_INFO "suspend")); LOG_INFO("suspend");
m_suspended = true; m_suspended = true;
bool wasConnected = isConnected(); bool wasConnected = isConnected();
disconnect(nullptr); disconnect(nullptr);
@ -620,7 +619,7 @@ void Client::handleSuspend()
void Client::handleResume() void Client::handleResume()
{ {
if (m_suspended) { if (m_suspended) {
LOG((CLOG_INFO "resume")); LOG_INFO("resume");
m_suspended = false; m_suspended = false;
if (m_connectOnResume) { if (m_connectOnResume) {
m_connectOnResume = false; m_connectOnResume = false;
@ -633,7 +632,7 @@ void Client::bindNetworkInterface(IDataSocket *socket) const
{ {
try { try {
if (!m_args.m_deskflowAddress.empty()) { if (!m_args.m_deskflowAddress.empty()) {
LOG((CLOG_DEBUG1 "bind to network interface: %s", m_args.m_deskflowAddress.c_str())); LOG_DEBUG1("bind to network interface: %s", m_args.m_deskflowAddress.c_str());
NetworkAddress bindAddress(m_args.m_deskflowAddress); NetworkAddress bindAddress(m_args.m_deskflowAddress);
bindAddress.resolve(); bindAddress.resolve();
@ -641,7 +640,7 @@ void Client::bindNetworkInterface(IDataSocket *socket) const
socket->bind(bindAddress); socket->bind(bindAddress);
} }
} catch (XBase &e) { } catch (XBase &e) {
LOG((CLOG_WARN "%s", e.what())); LOG_WARN("%s", e.what());
LOG((CLOG_WARN "operating system will select network interface automatically")); LOG_WARN("operating system will select network interface automatically");
} }
} }

View file

@ -65,10 +65,7 @@ void HelloBack::handleHello(deskflow::IStream *stream, const std::string &client
} }
// say hello back with same protocol name and version // say hello back with same protocol name and version
LOG_DEBUG( LOG_DEBUG("saying hello back with version %s %d.%d", protocolName.c_str(), helloBackMajor, helloBackMinor);
"saying hello back with version %s %d.%d", //
protocolName.c_str(), helloBackMajor, helloBackMinor
);
// dynamically build write format for hello back since `ProtocolUtil::writef` // dynamically build write format for hello back since `ProtocolUtil::writef`
// doesn't support formatting fixed length strings yet. // doesn't support formatting fixed length strings yet.

View file

@ -87,13 +87,13 @@ void ServerProxy::handleData()
while (n != 0) { while (n != 0) {
// verify we got an entire code // verify we got an entire code
if (n != 4) { if (n != 4) {
LOG((CLOG_ERR "incomplete message from server: %d bytes", n)); LOG_ERR("incomplete message from server: %d bytes", n);
m_client->disconnect("incomplete message from server"); m_client->disconnect("incomplete message from server");
return; return;
} }
// parse message // parse message
LOG((CLOG_DEBUG2 "msg from server: %c%c%c%c", code[0], code[1], code[2], code[3])); LOG_DEBUG2("msg from server: %c%c%c%c", code[0], code[1], code[2], code[3]);
try { try {
switch ((this->*m_parser)(code)) { switch ((this->*m_parser)(code)) {
using enum ConnectionResult; using enum ConnectionResult;
@ -101,7 +101,7 @@ void ServerProxy::handleData()
break; break;
case Unknown: case Unknown:
LOG((CLOG_ERR "invalid message from server: %c%c%c%c", code[0], code[1], code[2], code[3])); LOG_ERR("invalid message from server: %c%c%c%c", code[0], code[1], code[2], code[3]);
// not possible to determine message boundaries // not possible to determine message boundaries
// read the whole stream to discard unkonwn data // read the whole stream to discard unkonwn data
while (m_stream->read(nullptr, 4)) while (m_stream->read(nullptr, 4))
@ -112,7 +112,7 @@ void ServerProxy::handleData()
return; return;
} }
} catch (const XBadClient &e) { } catch (const XBadClient &e) {
LOG((CLOG_ERR "protocol error from server: %s", e.what())); LOG_ERR("protocol error from server: %s", e.what());
ProtocolUtil::writef(m_stream, kMsgEBad); ProtocolUtil::writef(m_stream, kMsgEBad);
m_client->disconnect("invalid message from server"); m_client->disconnect("invalid message from server");
return; return;
@ -162,7 +162,7 @@ ServerProxy::ConnectionResult ServerProxy::parseHandshakeMessage(const uint8_t *
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_DEBUG1("recv close");
m_client->disconnect(nullptr); m_client->disconnect(nullptr);
return Disconnect; return Disconnect;
} }
@ -171,25 +171,25 @@ ServerProxy::ConnectionResult ServerProxy::parseHandshakeMessage(const uint8_t *
int32_t major; int32_t major;
int32_t minor; int32_t minor;
ProtocolUtil::readf(m_stream, kMsgEIncompatible + 4, &major, &minor); ProtocolUtil::readf(m_stream, kMsgEIncompatible + 4, &major, &minor);
LOG((CLOG_ERR "server has incompatible version %d.%d", major, minor)); LOG_ERR("server has incompatible version %d.%d", major, minor);
m_client->refuseConnection("server has incompatible version"); m_client->refuseConnection("server has incompatible version");
return Disconnect; return Disconnect;
} }
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\"", m_client->getName().c_str())); LOG_ERR("server already has a connected client with name \"%s\"", m_client->getName().c_str());
m_client->refuseConnection("server already has a connected client with our name"); m_client->refuseConnection("server already has a connected client with our name");
return Disconnect; return Disconnect;
} }
else if (memcmp(code, kMsgEUnknown, 4) == 0) { else if (memcmp(code, kMsgEUnknown, 4) == 0) {
LOG((CLOG_ERR "server refused client with name \"%s\"", m_client->getName().c_str())); LOG_ERR("server refused client with name \"%s\"", m_client->getName().c_str());
m_client->refuseConnection("server refused client with our name"); m_client->refuseConnection("server refused client with our name");
return Disconnect; return Disconnect;
} }
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_ERR("server disconnected due to a protocol error");
m_client->refuseConnection("server reported a protocol error"); m_client->refuseConnection("server reported a protocol error");
return Disconnect; return Disconnect;
} else if (memcmp(code, kMsgDLanguageSynchronisation, 4) == 0) { } else if (memcmp(code, kMsgDLanguageSynchronisation, 4) == 0) {
@ -222,7 +222,7 @@ ServerProxy::ConnectionResult ServerProxy::parseMessage(const uint8_t *code)
uint16_t mask = 0; uint16_t mask = 0;
uint16_t button = 0; uint16_t button = 0;
ProtocolUtil::readf(m_stream, kMsgDKeyDown + 4, &id, &mask, &button); ProtocolUtil::readf(m_stream, kMsgDKeyDown + 4, &id, &mask, &button);
LOG((CLOG_DEBUG1 "recv key down id=0x%08x, mask=0x%04x, button=0x%04x", id, mask, button)); LOG_DEBUG1("recv key down id=0x%08x, mask=0x%04x, button=0x%04x", id, mask, button);
keyDown(id, mask, button, ""); keyDown(id, mask, button, "");
} }
@ -234,8 +234,7 @@ ServerProxy::ConnectionResult ServerProxy::parseMessage(const uint8_t *code)
uint16_t button = 0; uint16_t button = 0;
ProtocolUtil::readf(m_stream, kMsgDKeyDownLang + 4, &id, &mask, &button, &lang); ProtocolUtil::readf(m_stream, kMsgDKeyDownLang + 4, &id, &mask, &button, &lang);
LOG((CLOG_DEBUG1 "recv key down id=0x%08x, mask=0x%04x, button=0x%04x, lang=\"%s\"", id, mask, button, lang.c_str()) LOG_DEBUG1("recv key down id=0x%08x, mask=0x%04x, button=0x%04x, lang=\"%s\"", id, mask, button, lang.c_str());
);
keyDown(id, mask, button, lang); keyDown(id, mask, button, lang);
} }
@ -308,11 +307,11 @@ ServerProxy::ConnectionResult ServerProxy::parseMessage(const uint8_t *code)
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_DEBUG1("recv close");
m_client->disconnect(nullptr); m_client->disconnect(nullptr);
return Disconnect; return Disconnect;
} 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_ERR("server disconnected due to a protocol error");
m_client->disconnect("server reported a protocol error"); m_client->disconnect("server reported a protocol error");
return Disconnect; return Disconnect;
} else { } else {
@ -333,7 +332,7 @@ ServerProxy::ConnectionResult ServerProxy::parseMessage(const uint8_t *code)
void ServerProxy::handleKeepAliveAlarm() void ServerProxy::handleKeepAliveAlarm()
{ {
LOG((CLOG_NOTE "server is dead")); LOG_NOTE("server is dead");
m_client->disconnect("server is not responding"); m_client->disconnect("server is not responding");
} }
@ -349,7 +348,7 @@ void ServerProxy::onInfoChanged()
bool ServerProxy::onGrabClipboard(ClipboardID id) bool ServerProxy::onGrabClipboard(ClipboardID id)
{ {
LOG((CLOG_DEBUG1 "sending clipboard %d changed", id)); LOG_DEBUG1("sending clipboard %d changed", id);
ProtocolUtil::writef(m_stream, kMsgCClipboard, id, m_seqNum); ProtocolUtil::writef(m_stream, kMsgCClipboard, id, m_seqNum);
return true; return true;
} }
@ -357,7 +356,7 @@ bool ServerProxy::onGrabClipboard(ClipboardID id)
void ServerProxy::onClipboardChanged(ClipboardID id, const IClipboard *clipboard) void ServerProxy::onClipboardChanged(ClipboardID id, const IClipboard *clipboard)
{ {
std::string data = IClipboard::marshall(clipboard); std::string data = IClipboard::marshall(clipboard);
LOG((CLOG_DEBUG "sending clipboard %d seqnum=%d", id, m_seqNum)); LOG_DEBUG("sending clipboard %d seqnum=%d", id, m_seqNum);
StreamChunker::sendClipboard(data, data.size(), id, m_seqNum, m_events, this); StreamChunker::sendClipboard(data, data.size(), id, m_seqNum, m_events, this);
} }
@ -378,7 +377,7 @@ void ServerProxy::flushCompressedMouse()
void ServerProxy::sendInfo(const ClientInfo &info) void ServerProxy::sendInfo(const ClientInfo &info)
{ {
LOG((CLOG_DEBUG1 "sending info shape=%d,%d %dx%d", info.m_x, info.m_y, info.m_w, info.m_h)); LOG_DEBUG1("sending info shape=%d,%d %dx%d", info.m_x, info.m_y, info.m_w, info.m_h);
ProtocolUtil::writef(m_stream, kMsgDInfo, info.m_x, info.m_y, info.m_w, info.m_h, 0, info.m_mx, info.m_my); ProtocolUtil::writef(m_stream, kMsgDInfo, info.m_x, info.m_y, info.m_w, info.m_h, 0, info.m_mx, info.m_my);
} }
@ -495,7 +494,7 @@ void ServerProxy::enter()
uint16_t mask; uint16_t mask;
uint32_t seqNum; uint32_t seqNum;
ProtocolUtil::readf(m_stream, kMsgCEnter + 4, &x, &y, &seqNum, &mask); ProtocolUtil::readf(m_stream, kMsgCEnter + 4, &x, &y, &seqNum, &mask);
LOG((CLOG_DEBUG1 "recv enter, %d,%d %d %04x", x, y, seqNum, mask)); LOG_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
m_compressMouse = false; m_compressMouse = false;
@ -513,7 +512,7 @@ void ServerProxy::enter()
void ServerProxy::leave() void ServerProxy::leave()
{ {
// parse // parse
LOG((CLOG_DEBUG1 "recv leave")); LOG_DEBUG1("recv leave");
// send last mouse motion // send last mouse motion
flushCompressedMouse(); flushCompressedMouse();
@ -533,16 +532,16 @@ void ServerProxy::setClipboard()
if (r == TransferState::Started) { if (r == TransferState::Started) {
size_t size = ClipboardChunk::getExpectedSize(); size_t size = ClipboardChunk::getExpectedSize();
LOG((CLOG_DEBUG "receiving clipboard %d size=%d", id, size)); LOG_DEBUG("receiving clipboard %d size=%d", id, size);
} else if (r == TransferState::Finished) { } else if (r == TransferState::Finished) {
LOG((CLOG_DEBUG "received clipboard %d size=%d", id, dataCached.size())); LOG_DEBUG("received clipboard %d size=%d", id, dataCached.size());
// forward // forward
Clipboard clipboard; Clipboard clipboard;
clipboard.unmarshall(dataCached, 0); clipboard.unmarshall(dataCached, 0);
m_client->setClipboard(id, &clipboard); m_client->setClipboard(id, &clipboard);
LOG((CLOG_INFO "clipboard was updated")); LOG_INFO("clipboard was updated");
} }
} }
@ -552,7 +551,7 @@ void ServerProxy::grabClipboard()
ClipboardID id; ClipboardID id;
uint32_t seqNum; uint32_t seqNum;
ProtocolUtil::readf(m_stream, kMsgCClipboard + 4, &id, &seqNum); ProtocolUtil::readf(m_stream, kMsgCClipboard + 4, &id, &seqNum);
LOG((CLOG_DEBUG "recv grab clipboard %d", id)); LOG_DEBUG("recv grab clipboard %d", id);
// validate // validate
if (id >= kClipboardEnd) { if (id >= kClipboardEnd) {
@ -573,7 +572,7 @@ void ServerProxy::keyDown(uint16_t id, uint16_t mask, uint16_t button, const std
KeyID id2 = translateKey(static_cast<KeyID>(id)); KeyID id2 = translateKey(static_cast<KeyID>(id));
KeyModifierMask mask2 = translateModifierMask(static_cast<KeyModifierMask>(mask)); KeyModifierMask mask2 = translateModifierMask(static_cast<KeyModifierMask>(mask));
if (id2 != static_cast<KeyID>(id) || mask2 != static_cast<KeyModifierMask>(mask)) if (id2 != static_cast<KeyID>(id) || mask2 != static_cast<KeyModifierMask>(mask))
LOG((CLOG_DEBUG1 "key down translated to id=0x%08x, mask=0x%04x", id2, mask2)); LOG_DEBUG1("key down translated to id=0x%08x, mask=0x%04x", id2, mask2);
// forward // forward
m_client->keyDown(id2, mask2, button, lang); m_client->keyDown(id2, mask2, button, lang);
@ -601,7 +600,7 @@ void ServerProxy::keyRepeat()
KeyID id2 = translateKey(static_cast<KeyID>(id)); KeyID id2 = translateKey(static_cast<KeyID>(id));
KeyModifierMask mask2 = translateModifierMask(static_cast<KeyModifierMask>(mask)); KeyModifierMask mask2 = translateModifierMask(static_cast<KeyModifierMask>(mask));
if (id2 != static_cast<KeyID>(id) || mask2 != static_cast<KeyModifierMask>(mask)) if (id2 != static_cast<KeyID>(id) || mask2 != static_cast<KeyModifierMask>(mask))
LOG((CLOG_DEBUG1 "key repeat translated to id=0x%08x, mask=0x%04x", id2, mask2)); LOG_DEBUG1("key repeat translated to id=0x%08x, mask=0x%04x", id2, mask2);
// forward // forward
m_client->keyRepeat(id2, mask2, count, button, lang); m_client->keyRepeat(id2, mask2, count, button, lang);
@ -617,13 +616,13 @@ void ServerProxy::keyUp()
uint16_t mask; uint16_t mask;
uint16_t button; uint16_t button;
ProtocolUtil::readf(m_stream, kMsgDKeyUp + 4, &id, &mask, &button); ProtocolUtil::readf(m_stream, kMsgDKeyUp + 4, &id, &mask, &button);
LOG((CLOG_DEBUG1 "recv key up id=0x%08x, mask=0x%04x, button=0x%04x", id, mask, button)); LOG_DEBUG1("recv key up id=0x%08x, mask=0x%04x, button=0x%04x", id, mask, button);
// translate // translate
KeyID id2 = translateKey(static_cast<KeyID>(id)); KeyID id2 = translateKey(static_cast<KeyID>(id));
KeyModifierMask mask2 = translateModifierMask(static_cast<KeyModifierMask>(mask)); KeyModifierMask mask2 = translateModifierMask(static_cast<KeyModifierMask>(mask));
if (id2 != static_cast<KeyID>(id) || mask2 != static_cast<KeyModifierMask>(mask)) if (id2 != static_cast<KeyID>(id) || mask2 != static_cast<KeyModifierMask>(mask))
LOG((CLOG_DEBUG1 "key up translated to id=0x%08x, mask=0x%04x", id2, mask2)); LOG_DEBUG1("key up translated to id=0x%08x, mask=0x%04x", id2, mask2);
// forward // forward
m_client->keyUp(id2, mask2, button); m_client->keyUp(id2, mask2, button);
@ -637,7 +636,7 @@ void ServerProxy::mouseDown()
// parse // parse
int8_t id; int8_t id;
ProtocolUtil::readf(m_stream, kMsgDMouseDown + 4, &id); ProtocolUtil::readf(m_stream, kMsgDMouseDown + 4, &id);
LOG((CLOG_DEBUG1 "recv mouse down id=%d", id)); LOG_DEBUG1("recv mouse down id=%d", id);
// forward // forward
m_client->mouseDown(static_cast<ButtonID>(id)); m_client->mouseDown(static_cast<ButtonID>(id));
@ -651,7 +650,7 @@ void ServerProxy::mouseUp()
// parse // parse
int8_t id; int8_t id;
ProtocolUtil::readf(m_stream, kMsgDMouseUp + 4, &id); ProtocolUtil::readf(m_stream, kMsgDMouseUp + 4, &id);
LOG((CLOG_DEBUG1 "recv mouse up id=%d", id)); LOG_DEBUG1("recv mouse up id=%d", id);
// forward // forward
m_client->mouseUp(static_cast<ButtonID>(id)); m_client->mouseUp(static_cast<ButtonID>(id));
@ -682,7 +681,7 @@ void ServerProxy::mouseMove()
m_dxMouse = 0; m_dxMouse = 0;
m_dyMouse = 0; m_dyMouse = 0;
} }
LOG((CLOG_DEBUG2 "recv mouse move %d,%d", x, y)); LOG_DEBUG2("recv mouse move %d,%d", x, y);
// forward // forward
if (!ignore) { if (!ignore) {
@ -712,7 +711,7 @@ void ServerProxy::mouseRelativeMove()
m_dxMouse += dx; m_dxMouse += dx;
m_dyMouse += dy; m_dyMouse += dy;
} }
LOG((CLOG_DEBUG2 "recv mouse relative move %d,%d", dx, dy)); LOG_DEBUG2("recv mouse relative move %d,%d", dx, dy);
// forward // forward
if (!ignore) { if (!ignore) {
@ -729,7 +728,7 @@ void ServerProxy::mouseWheel()
int16_t xDelta; int16_t xDelta;
int16_t yDelta; int16_t yDelta;
ProtocolUtil::readf(m_stream, kMsgDMouseWheel + 4, &xDelta, &yDelta); ProtocolUtil::readf(m_stream, kMsgDMouseWheel + 4, &xDelta, &yDelta);
LOG((CLOG_DEBUG2 "recv mouse wheel %+d,%+d", xDelta, yDelta)); LOG_DEBUG2("recv mouse wheel %+d,%+d", xDelta, yDelta);
// forward // forward
m_client->mouseWheel(xDelta, yDelta); m_client->mouseWheel(xDelta, yDelta);
@ -740,7 +739,7 @@ void ServerProxy::screensaver()
// parse // parse
int8_t on; int8_t on;
ProtocolUtil::readf(m_stream, kMsgCScreenSaver + 4, &on); ProtocolUtil::readf(m_stream, kMsgCScreenSaver + 4, &on);
LOG((CLOG_DEBUG1 "recv screen saver on=%d", on)); LOG_DEBUG1("recv screen saver on=%d", on);
// forward // forward
m_client->screensaver(on != 0); m_client->screensaver(on != 0);
@ -749,7 +748,7 @@ void ServerProxy::screensaver()
void ServerProxy::resetOptions() void ServerProxy::resetOptions()
{ {
// parse // parse
LOG((CLOG_DEBUG1 "recv reset options")); LOG_DEBUG1("recv reset options");
// forward // forward
m_client->resetOptions(); m_client->resetOptions();
@ -768,7 +767,7 @@ void ServerProxy::setOptions()
// parse // parse
OptionsList options; OptionsList options;
ProtocolUtil::readf(m_stream, kMsgDSetOptions + 4, &options); ProtocolUtil::readf(m_stream, kMsgDSetOptions + 4, &options);
LOG((CLOG_DEBUG1 "recv set options size=%d", options.size())); LOG_DEBUG1("recv set options size=%d", options.size());
// forward // forward
m_client->setOptions(options); m_client->setOptions(options);
@ -795,7 +794,7 @@ void ServerProxy::setOptions()
if (id != kKeyModifierIDNull) { if (id != kKeyModifierIDNull) {
m_modifierTranslationTable[id] = options[i + 1]; m_modifierTranslationTable[id] = options[i + 1];
LOG((CLOG_DEBUG1 "modifier %d mapped to %d", id, m_modifierTranslationTable[id])); LOG_DEBUG1("modifier %d mapped to %d", id, m_modifierTranslationTable[id]);
} }
} }
} }
@ -810,7 +809,7 @@ void ServerProxy::queryInfo()
void ServerProxy::infoAcknowledgment() void ServerProxy::infoAcknowledgment()
{ {
LOG((CLOG_DEBUG1 "recv info acknowledgment")); LOG_DEBUG1("recv info acknowledgment");
m_ignoreMouse = false; m_ignoreMouse = false;
} }
@ -818,7 +817,7 @@ void ServerProxy::secureInputNotification()
{ {
std::string app; std::string app;
ProtocolUtil::readf(m_stream, kMsgDSecureInputNotification + 4, &app); ProtocolUtil::readf(m_stream, kMsgDSecureInputNotification + 4, &app);
LOG((CLOG_INFO "application \"%s\" is blocking the keyboard", app.c_str())); LOG_INFO("application \"%s\" is blocking the keyboard", app.c_str());
} }
void ServerProxy::setServerLanguages() void ServerProxy::setServerLanguages()
@ -838,14 +837,14 @@ void ServerProxy::setActiveServerLanguage(const std::string_view &language)
if (!m_languageManager.isLanguageInstalled(m_serverLanguage)) { if (!m_languageManager.isLanguageInstalled(m_serverLanguage)) {
if (!m_isUserNotifiedAboutLanguageSyncError) { if (!m_isUserNotifiedAboutLanguageSyncError) {
LOG((CLOG_WARN "current server language is not installed on client")); LOG_WARN("current server language is not installed on client");
m_isUserNotifiedAboutLanguageSyncError = true; m_isUserNotifiedAboutLanguageSyncError = true;
} }
} else { } else {
m_isUserNotifiedAboutLanguageSyncError = false; m_isUserNotifiedAboutLanguageSyncError = false;
} }
} else { } else {
LOG((CLOG_DEBUG1 "active server language is empty")); LOG_DEBUG1("active server language is empty");
} }
} }

View file

@ -98,17 +98,17 @@ int App::run(int argc, char **argv)
// using the exit(int) function! // using the exit(int) function!
result = e.getCode(); result = e.getCode();
} catch (DisplayInvalidException &die) { } catch (DisplayInvalidException &die) {
LOG((CLOG_CRIT "a display invalid exception error occurred: %s\n", die.what())); LOG_CRIT("a display invalid exception error occurred: %s\n", die.what());
// display invalid exceptions can occur when going to sleep. When this // display invalid exceptions can occur when going to sleep. When this
// process exits, the UI will restart us instantly. We don't really want // process exits, the UI will restart us instantly. We don't really want
// that behevior, so we quies for a bit // that behevior, so we quies for a bit
Arch::sleep(10); Arch::sleep(10);
} catch (std::runtime_error &re) { } catch (std::runtime_error &re) {
LOG((CLOG_CRIT "a runtime error occurred: %s\n", re.what())); LOG_CRIT("a runtime error occurred: %s\n", re.what());
} catch (std::exception &e) { } catch (std::exception &e) {
LOG((CLOG_CRIT "an error occurred: %s\n", e.what())); LOG_CRIT("an error occurred: %s\n", e.what());
} catch (...) { } catch (...) {
LOG((CLOG_CRIT "an unknown error occurred\n")); LOG_CRIT("an unknown error occurred\n");
} }
return result; return result;
@ -129,7 +129,7 @@ void App::setupFileLogging()
if (argsBase().m_logFile != nullptr) { if (argsBase().m_logFile != nullptr) {
m_fileLog = new FileLogOutputter(argsBase().m_logFile); // NOSONAR - Adopted by `Log` m_fileLog = new FileLogOutputter(argsBase().m_logFile); // NOSONAR - Adopted by `Log`
CLOG->insert(m_fileLog); CLOG->insert(m_fileLog);
LOG((CLOG_DEBUG1 "logging to file (%s) enabled", argsBase().m_logFile)); LOG_DEBUG1("logging to file (%s) enabled", argsBase().m_logFile);
} }
} }
@ -186,7 +186,7 @@ void App::initApp(int argc, const char **argv)
void App::handleScreenError() const void App::handleScreenError() const
{ {
LOG((CLOG_CRIT "error on screen")); LOG_CRIT("error on screen");
getEvents()->addEvent(Event(EventTypes::Quit)); getEvents()->addEvent(Event(EventTypes::Quit));
} }

View file

@ -40,7 +40,7 @@ bool ArgParser::parseServerArgs(deskflow::ServerArgs &args, int argc, const char
} else if (isArg(i, argc, argv, nullptr, "--disable-client-cert-check")) { } else if (isArg(i, argc, argv, nullptr, "--disable-client-cert-check")) {
args.m_chkPeerCert = false; args.m_chkPeerCert = false;
} else { } else {
LOG((CLOG_CRIT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname)); LOG_CRIT("%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname);
return false; return false;
} }
++i; ++i;
@ -79,7 +79,7 @@ bool ArgParser::parseClientArgs(deskflow::ClientArgs &args, int argc, const char
return true; return true;
} }
LOG((CLOG_CRIT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname)); LOG_CRIT("%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname);
return false; return false;
} }
++i; ++i;
@ -87,7 +87,7 @@ bool ArgParser::parseClientArgs(deskflow::ClientArgs &args, int argc, const char
// exactly one non-option argument (server-address) // exactly one non-option argument (server-address)
if (i == argc && !args.m_shouldExitFail && !args.m_shouldExitOk) { if (i == argc && !args.m_shouldExitFail && !args.m_shouldExitOk) {
LOG((CLOG_CRIT "%s: a server address or name is required" BYE, args.m_pname, args.m_pname)); LOG_CRIT("%s: a server address or name is required" BYE, args.m_pname, args.m_pname);
return false; return false;
} }
@ -181,7 +181,7 @@ bool ArgParser::parseDeprecatedArgs(int argc, const char *const *argv, int &i) c
for (auto &arg : deprecatedArgs) { for (auto &arg : deprecatedArgs) {
if (isArg(i, argc, argv, nullptr, arg)) { if (isArg(i, argc, argv, nullptr, arg)) {
LOG((CLOG_NOTE "%s is deprecated", arg)); LOG_NOTE("%s is deprecated", arg);
i++; i++;
return true; return true;
} }
@ -197,7 +197,7 @@ bool ArgParser::isArg(
if ((name1 != nullptr && strcmp(argv[argi], name1) == 0) || (name2 != nullptr && strcmp(argv[argi], name2) == 0)) { if ((name1 != nullptr && strcmp(argv[argi], name1) == 0) || (name2 != nullptr && 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, argsBase().m_pname, argv[argi], argsBase().m_pname)); LOG_PRINT("%s: missing arguments for `%s'" BYE, argsBase().m_pname, argv[argi], argsBase().m_pname);
argsBase().m_shouldExitFail = true; argsBase().m_shouldExitFail = true;
return false; return false;
} }

View file

@ -88,7 +88,7 @@ void ClientApp::parseArgs(int argc, const char *const *argv)
// server. a bad port will never get better. patch by Brent // server. a bad port will never get better. patch by Brent
// Priddy. // Priddy.
if (!args().m_restartable || e.getError() == XSocketAddress::SocketError::BadPort) { if (!args().m_restartable || e.getError() == XSocketAddress::SocketError::BadPort) {
LOG((CLOG_CRIT "%s: %s" BYE, args().m_pname, e.what(), args().m_pname)); LOG_CRIT("%s: %s" BYE, args().m_pname, e.what(), args().m_pname);
bye(s_exitFailed); bye(s_exitFailed);
} }
} }
@ -130,7 +130,7 @@ void ClientApp::help()
<< "The hostname must be the address or hostname of the server.\n" << "The hostname must be the address or hostname of the server.\n"
<< "The port overrides the default port, " << kDefaultPort << ".\n"; << "The port overrides the default port, " << kDefaultPort << ".\n";
LOG((CLOG_PRINT "%s", help.str().c_str())); LOG_PRINT("%s", help.str().c_str());
} }
const char *ClientApp::daemonName() const const char *ClientApp::daemonName() const
@ -166,7 +166,7 @@ deskflow::Screen *ClientApp::createScreen()
#if defined(WINAPI_XWINDOWS) or defined(WINAPI_LIBEI) #if defined(WINAPI_XWINDOWS) or defined(WINAPI_LIBEI)
if (deskflow::platform::isWayland()) { if (deskflow::platform::isWayland()) {
#if WINAPI_LIBEI #if WINAPI_LIBEI
LOG((CLOG_INFO "using ei screen for wayland")); LOG_INFO("using ei screen for wayland");
return new deskflow::Screen(new deskflow::EiScreen(false, getEvents(), true), getEvents()); return new deskflow::Screen(new deskflow::EiScreen(false, getEvents(), true), getEvents());
#else #else
throw XNoEiSupport(); throw XNoEiSupport();
@ -175,7 +175,7 @@ deskflow::Screen *ClientApp::createScreen()
#endif #endif
#if WINAPI_XWINDOWS #if WINAPI_XWINDOWS
LOG((CLOG_INFO "using legacy x windows screen")); LOG_INFO("using legacy x windows screen");
return new deskflow::Screen( return new deskflow::Screen(
new XWindowsScreen(args().m_display, false, args().m_yscroll, getEvents(), args().m_clientScrollDirection), new XWindowsScreen(args().m_display, false, args().m_yscroll, getEvents(), args().m_clientScrollDirection),
getEvents() getEvents()
@ -220,14 +220,14 @@ void ClientApp::handleClientRestart(const Event &, EventQueueTimer *timer)
void ClientApp::scheduleClientRestart(double retryTime) void ClientApp::scheduleClientRestart(double retryTime)
{ {
// install a timer and handler to retry later // install a timer and handler to retry later
LOG((CLOG_DEBUG "retry in %.0f seconds", retryTime)); LOG_DEBUG("retry in %.0f seconds", retryTime);
EventQueueTimer *timer = getEvents()->newOneShotTimer(retryTime, nullptr); EventQueueTimer *timer = getEvents()->newOneShotTimer(retryTime, nullptr);
getEvents()->addHandler(EventTypes::Timer, timer, [this, timer](const auto &e) { handleClientRestart(e, timer); }); getEvents()->addHandler(EventTypes::Timer, timer, [this, timer](const auto &e) { handleClientRestart(e, timer); });
} }
void ClientApp::handleClientConnected() const void ClientApp::handleClientConnected() const
{ {
LOG((CLOG_NOTE "connected to server")); LOG_NOTE("connected to server");
} }
void ClientApp::handleClientFailed(const Event &e) void ClientApp::handleClientFailed(const Event &e)
@ -235,7 +235,7 @@ void ClientApp::handleClientFailed(const Event &e)
if ((++m_lastServerAddressIndex) < m_client->getLastResolvedAddressesCount()) { if ((++m_lastServerAddressIndex) < m_client->getLastResolvedAddressesCount()) {
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData())); std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
LOG((CLOG_WARN "failed to connect to server=%s, trying next address", info->m_what.c_str())); LOG_WARN("failed to connect to server=%s, trying next address", info->m_what.c_str());
if (!m_suspended) { if (!m_suspended) {
scheduleClientRestart(s_retryTime); scheduleClientRestart(s_retryTime);
} }
@ -250,10 +250,10 @@ void ClientApp::handleClientRefused(const Event &e)
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData())); std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
if (!args().m_restartable || !info->m_retry) { if (!args().m_restartable || !info->m_retry) {
LOG((CLOG_ERR "failed to connect to server: %s", info->m_what.c_str())); LOG_ERR("failed to connect to server: %s", info->m_what.c_str());
getEvents()->addEvent(Event(EventTypes::Quit)); getEvents()->addEvent(Event(EventTypes::Quit));
} else { } else {
LOG((CLOG_WARN "failed to connect to server: %s", info->m_what.c_str())); LOG_WARN("failed to connect to server: %s", info->m_what.c_str());
if (!m_suspended) { if (!m_suspended) {
scheduleClientRestart(s_retryTime); scheduleClientRestart(s_retryTime);
} }
@ -262,7 +262,7 @@ void ClientApp::handleClientRefused(const Event &e)
void ClientApp::handleClientDisconnected() void ClientApp::handleClientDisconnected()
{ {
LOG((CLOG_NOTE "disconnected from server")); LOG_NOTE("disconnected from server");
if (!args().m_restartable) { if (!args().m_restartable) {
getEvents()->addEvent(Event(EventTypes::Quit)); getEvents()->addEvent(Event(EventTypes::Quit));
} else if (!m_suspended) { } else if (!m_suspended) {
@ -326,22 +326,22 @@ bool ClientApp::startClient()
clientScreen = openClientScreen(); clientScreen = openClientScreen();
m_client = openClient(args().m_name, *m_serverAddress, clientScreen); m_client = openClient(args().m_name, *m_serverAddress, clientScreen);
m_clientScreen = clientScreen; m_clientScreen = clientScreen;
LOG((CLOG_NOTE "started client")); LOG_NOTE("started client");
} }
m_client->connect(m_lastServerAddressIndex); m_client->connect(m_lastServerAddressIndex);
return true; return true;
} catch (XScreenUnavailable &e) { } catch (XScreenUnavailable &e) {
LOG((CLOG_WARN "secondary screen unavailable: %s", e.what())); LOG_WARN("secondary screen unavailable: %s", e.what());
closeClientScreen(clientScreen); closeClientScreen(clientScreen);
retryTime = e.getRetryTime(); retryTime = e.getRetryTime();
} catch (XScreenOpenFailure &e) { } catch (XScreenOpenFailure &e) {
LOG((CLOG_CRIT "failed to start client: %s", e.what())); LOG_CRIT("failed to start client: %s", e.what());
closeClientScreen(clientScreen); closeClientScreen(clientScreen);
return false; return false;
} catch (XBase &e) { } catch (XBase &e) {
LOG((CLOG_CRIT "failed to start client: %s", e.what())); LOG_CRIT("failed to start client: %s", e.what());
closeClientScreen(clientScreen); closeClientScreen(clientScreen);
return false; return false;
} }
@ -393,9 +393,9 @@ int ClientApp::mainLoop()
DAEMON_RUNNING(false); DAEMON_RUNNING(false);
// close down // close down
LOG((CLOG_DEBUG1 "stopping client")); LOG_DEBUG1("stopping client");
stopClient(); stopClient();
LOG((CLOG_NOTE "stopped client")); LOG_NOTE("stopped client");
return s_exitSuccess; return s_exitSuccess;
} }
@ -440,7 +440,7 @@ void ClientApp::startNode()
{ {
// start the client. if this return false then we've failed and // start the client. if this return false then we've failed and
// we shouldn't retry. // we shouldn't retry.
LOG((CLOG_DEBUG1 "starting client")); LOG_DEBUG1("starting client");
if (!startClient()) { if (!startClient()) {
bye(s_exitFailed); bye(s_exitFailed);
} }

View file

@ -75,7 +75,7 @@ ClipboardChunk::assemble(deskflow::IStream *stream, std::string &dataCached, Cli
if (mark == ChunkType::DataStart) { if (mark == ChunkType::DataStart) {
s_expectedSize = deskflow::string::stringToSizeType(data); s_expectedSize = deskflow::string::stringToSizeType(data);
LOG((CLOG_DEBUG "start receiving clipboard data")); LOG_DEBUG("start receiving clipboard data");
dataCached.clear(); dataCached.clear();
return Started; return Started;
} else if (mark == ChunkType::DataChunk) { } else if (mark == ChunkType::DataChunk) {
@ -86,13 +86,13 @@ ClipboardChunk::assemble(deskflow::IStream *stream, std::string &dataCached, Cli
if (id >= kClipboardEnd) { if (id >= kClipboardEnd) {
return Error; return Error;
} else if (s_expectedSize != dataCached.size()) { } else if (s_expectedSize != dataCached.size()) {
LOG((CLOG_ERR "corrupted clipboard data, expected size=%d actual size=%d", s_expectedSize, dataCached.size())); LOG_ERR("corrupted clipboard data, expected size=%d actual size=%d", s_expectedSize, dataCached.size());
return Error; return Error;
} }
return Finished; return Finished;
} }
LOG((CLOG_ERR "clipboard transmission failed: unknown error")); LOG_ERR("clipboard transmission failed: unknown error");
return Error; return Error;
} }
@ -100,7 +100,7 @@ void ClipboardChunk::send(deskflow::IStream *stream, void *data)
{ {
const auto *clipboardData = static_cast<ClipboardChunk *>(data); const auto *clipboardData = static_cast<ClipboardChunk *>(data);
LOG((CLOG_DEBUG1 "sending clipboard chunk")); LOG_DEBUG1("sending clipboard chunk");
const char *chunk = clipboardData->m_chunk; const char *chunk = clipboardData->m_chunk;
ClipboardID id = chunk[0]; ClipboardID id = chunk[0];
@ -111,15 +111,15 @@ void ClipboardChunk::send(deskflow::IStream *stream, void *data)
switch (mark) { switch (mark) {
case ChunkType::DataStart: case ChunkType::DataStart:
LOG((CLOG_DEBUG2 "sending clipboard chunk start: size=%s", dataChunk.c_str())); LOG_DEBUG2("sending clipboard chunk start: size=%s", dataChunk.c_str());
break; break;
case ChunkType::DataChunk: case ChunkType::DataChunk:
LOG((CLOG_DEBUG2 "sending clipboard chunk data: size=%i", dataChunk.size())); LOG_DEBUG2("sending clipboard chunk data: size=%i", dataChunk.size());
break; break;
case ChunkType::DataEnd: case ChunkType::DataEnd:
LOG((CLOG_DEBUG2 "sending clipboard finished")); LOG_DEBUG2("sending clipboard finished");
break; break;
default: default:

View file

@ -45,32 +45,32 @@ bool Config::load(const std::string &firstArg)
} }
if (!std::filesystem::exists(m_filename)) { if (!std::filesystem::exists(m_filename)) {
LOG((CLOG_ERR "config file not found: %s", m_filename.c_str())); LOG_ERR("config file not found: %s", m_filename.c_str());
return false; return false;
} }
toml::table configTable; toml::table configTable;
try { try {
LOG((CLOG_INFO "loading config file: %s", m_filename.c_str())); LOG_INFO("loading config file: %s", m_filename.c_str());
configTable = toml::parse_file(m_filename); configTable = toml::parse_file(m_filename);
} catch (const toml::parse_error &err) { } catch (const toml::parse_error &err) {
LOG((CLOG_ERR "toml parse error: %s", err.what())); LOG_ERR("toml parse error: %s", err.what());
throw ParseError(); throw ParseError();
} catch (const std::exception &err) { } catch (const std::exception &err) {
LOG((CLOG_ERR "unknown parse error: %s", err.what())); LOG_ERR("unknown parse error: %s", err.what());
throw ParseError(); throw ParseError();
} }
if (!configTable.contains(m_section)) { if (!configTable.contains(m_section)) {
LOG((CLOG_WARN "no %s section found in config file", m_section.c_str())); LOG_WARN("no %s section found in config file", m_section.c_str());
return false; return false;
} }
const auto &section = configTable[m_section]; const auto &section = configTable[m_section];
const auto args = section["args"]; const auto args = section["args"];
if (!args.is_table()) { if (!args.is_table()) {
LOG((CLOG_WARN "no args table found in config file")); LOG_WARN("no args table found in config file");
return false; return false;
} }
@ -96,7 +96,7 @@ bool Config::load(const std::string &firstArg)
} }
if (m_args.empty()) { if (m_args.empty()) {
LOG((CLOG_WARN "no args loaded from config file")); LOG_WARN("no args loaded from config file");
return false; return false;
} }

View file

@ -216,9 +216,9 @@ int DaemonApp::mainLoop()
LOG_INFO("daemon is running"); LOG_INFO("daemon is running");
m_events.loop(); m_events.loop();
} catch (std::exception &e) { // NOSONAR - Catching all exceptions } catch (std::exception &e) { // NOSONAR - Catching all exceptions
LOG((CLOG_CRIT "daemon error: %s", e.what())); LOG_CRIT("daemon error: %s", e.what());
} catch (...) { // NOSONAR - Catching remaining exceptions } catch (...) { // NOSONAR - Catching remaining exceptions
LOG((CLOG_CRIT "daemon unknown error")); LOG_CRIT("daemon unknown error");
} }
LOG_INFO("daemon is stopping"); LOG_INFO("daemon is stopping");
@ -228,9 +228,9 @@ int DaemonApp::mainLoop()
LOG_DEBUG("stopping process watchdog"); LOG_DEBUG("stopping process watchdog");
m_pWatchdog->stop(); m_pWatchdog->stop();
} catch (std::exception &e) { // NOSONAR - Catching all exceptions } catch (std::exception &e) { // NOSONAR - Catching all exceptions
LOG((CLOG_CRIT "daemon stop watchdog error: %s", e.what())); LOG_CRIT("daemon stop watchdog error: %s", e.what());
} catch (...) { // NOSONAR - Catching remaining exceptions } catch (...) { // NOSONAR - Catching remaining exceptions
LOG((CLOG_CRIT "daemon stop watchdog unknown error")); LOG_CRIT("daemon stop watchdog unknown error");
} }
#endif #endif

View file

@ -264,7 +264,7 @@ const KeyMap::KeyItem *KeyMap::mapKey(
case kKeySetModifiers: case kKeySetModifiers:
if (!keysForModifierState(0, group, activeModifiers, currentState, desiredMask, desiredMask, 0, keys)) { if (!keysForModifierState(0, group, activeModifiers, currentState, desiredMask, desiredMask, 0, keys)) {
LOG((CLOG_DEBUG1 "unable to set modifiers %04x", desiredMask)); LOG_DEBUG1("unable to set modifiers %04x", desiredMask);
return nullptr; return nullptr;
} }
return &m_modifierKeyItem; return &m_modifierKeyItem;
@ -273,7 +273,7 @@ const KeyMap::KeyItem *KeyMap::mapKey(
if (!keysForModifierState( if (!keysForModifierState(
0, group, activeModifiers, currentState, currentState & ~desiredMask, desiredMask, 0, keys 0, group, activeModifiers, currentState, currentState & ~desiredMask, desiredMask, 0, keys
)) { )) {
LOG((CLOG_DEBUG1 "unable to clear modifiers %04x", desiredMask)); LOG_DEBUG1("unable to clear modifiers %04x", desiredMask);
return nullptr; return nullptr;
} }
return &m_modifierKeyItem; return &m_modifierKeyItem;
@ -288,7 +288,7 @@ const KeyMap::KeyItem *KeyMap::mapKey(
} }
if (item != nullptr) { if (item != nullptr) {
LOG((CLOG_DEBUG1 "mapped to %03x, new state %04x", item->m_button, currentState)); LOG_DEBUG1("mapped to %03x, new state %04x", item->m_button, currentState);
} }
return item; return item;
} }
@ -304,9 +304,9 @@ int32_t KeyMap::getLanguageGroupID(int32_t group, const std::string &lang) const
if (auto it = std::find(m_keyboardLayouts.begin(), m_keyboardLayouts.end(), lang); it != m_keyboardLayouts.end()) { if (auto it = std::find(m_keyboardLayouts.begin(), m_keyboardLayouts.end(), lang); it != m_keyboardLayouts.end()) {
id = static_cast<int>(std::distance(m_keyboardLayouts.begin(), it)); id = static_cast<int>(std::distance(m_keyboardLayouts.begin(), it));
LOG((CLOG_DEBUG1 "language %s has group id %d", lang.c_str(), id)); LOG_DEBUG1("language %s has group id %d", lang.c_str(), id);
} else { } else {
LOG((CLOG_DEBUG1 "could not found requested language")); LOG_DEBUG1("could not found requested language");
} }
return id; return id;
@ -481,7 +481,7 @@ const KeyMap::KeyItem *KeyMap::mapCommandKey(
KeyIDMap::const_iterator i = m_keyIDMap.find(id); KeyIDMap::const_iterator i = m_keyIDMap.find(id);
if (i == m_keyIDMap.end()) { if (i == m_keyIDMap.end()) {
// unknown key // unknown key
LOG((CLOG_DEBUG1 "key %04x is not on keyboard", id)); LOG_DEBUG1("key %04x is not on keyboard", id);
return nullptr; return nullptr;
} }
const KeyGroupTable &keyGroupTable = i->second; const KeyGroupTable &keyGroupTable = i->second;
@ -506,7 +506,7 @@ const KeyMap::KeyItem *KeyMap::mapCommandKey(
KeyModifierMask requiredIgnoreShiftMask = item.m_required & ~KeyModifierShift; KeyModifierMask requiredIgnoreShiftMask = item.m_required & ~KeyModifierShift;
if ((item.m_required & desiredShiftMask) == (item.m_sensitive & desiredShiftMask) && if ((item.m_required & desiredShiftMask) == (item.m_sensitive & desiredShiftMask) &&
((requiredIgnoreShiftMask & desiredMask) == requiredIgnoreShiftMask)) { ((requiredIgnoreShiftMask & desiredMask) == requiredIgnoreShiftMask)) {
LOG((CLOG_DEBUG1 "found key in group %d", effectiveGroup)); LOG_DEBUG1("found key in group %d", effectiveGroup);
keyItem = &item; keyItem = &item;
break; break;
} }
@ -517,7 +517,7 @@ const KeyMap::KeyItem *KeyMap::mapCommandKey(
} }
if (!keyItem) { if (!keyItem) {
// no mapping for this keysym // no mapping for this keysym
LOG((CLOG_DEBUG1 "no mapping for key %04x", id)); LOG_DEBUG1("no mapping for key %04x", id);
return nullptr; return nullptr;
} }
@ -533,14 +533,14 @@ const KeyMap::KeyItem *KeyMap::mapCommandKey(
if (!keysForKeyItem( if (!keysForKeyItem(
*keyItem, newGroup, newModifiers, newState, desiredMask, s_overrideModifiers, isAutoRepeat, keys, lang *keyItem, newGroup, newModifiers, newState, desiredMask, s_overrideModifiers, isAutoRepeat, keys, lang
)) { )) {
LOG((CLOG_DEBUG1 "can't map key")); LOG_DEBUG1("can't map key");
keys.clear(); keys.clear();
return nullptr; return nullptr;
} }
// add keystrokes to restore modifier keys // add keystrokes to restore modifier keys
if (!keysToRestoreModifiers(*keyItem, group, newModifiers, newState, activeModifiers, keys)) { if (!keysToRestoreModifiers(*keyItem, group, newModifiers, newState, activeModifiers, keys)) {
LOG((CLOG_DEBUG1 "modifiers were not restored")); LOG_DEBUG1("modifiers were not restored");
keys.clear(); keys.clear();
return nullptr; return nullptr;
} }
@ -562,7 +562,7 @@ KeyMap::getKeyItemList(const KeyMap::KeyGroupTable &keyGroupTable, int32_t group
const auto effectiveGroup = getEffectiveGroup(group, groupOffset); const auto effectiveGroup = getEffectiveGroup(group, groupOffset);
auto keyIndex = findBestKey(keyGroupTable[effectiveGroup], desiredMask); auto keyIndex = findBestKey(keyGroupTable[effectiveGroup], desiredMask);
if (keyIndex != -1) { if (keyIndex != -1) {
LOG((CLOG_DEBUG1 "found key in group %d", effectiveGroup)); LOG_DEBUG1("found key in group %d", effectiveGroup);
itemList = &keyGroupTable[effectiveGroup][keyIndex]; itemList = &keyGroupTable[effectiveGroup][keyIndex];
break; break;
} }
@ -580,7 +580,7 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey(
KeyIDMap::const_iterator i = m_keyIDMap.find(id); KeyIDMap::const_iterator i = m_keyIDMap.find(id);
if (i == m_keyIDMap.end()) { if (i == m_keyIDMap.end()) {
// unknown key // unknown key
LOG((CLOG_DEBUG1 "key %04x is not on keyboard", id)); LOG_DEBUG1("key %04x is not on keyboard", id);
return nullptr; return nullptr;
} }
@ -589,7 +589,7 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey(
const auto itemList = getKeyItemList(i->second, getLanguageGroupID(group, lang), desiredMask); const auto itemList = getKeyItemList(i->second, getLanguageGroupID(group, lang), desiredMask);
if (!itemList || itemList->empty()) { if (!itemList || itemList->empty()) {
// no mapping for this keysym // no mapping for this keysym
LOG((CLOG_DEBUG1 "no mapping for key %04x", id)); LOG_DEBUG1("no mapping for key %04x", id);
return nullptr; return nullptr;
} }
@ -603,7 +603,7 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey(
// add each key // add each key
for (auto &item : *itemList) { for (auto &item : *itemList) {
if (!keysForKeyItem(item, newGroup, newModifiers, newState, desiredMask, 0, isAutoRepeat, keys, lang)) { if (!keysForKeyItem(item, newGroup, newModifiers, newState, desiredMask, 0, isAutoRepeat, keys, lang)) {
LOG((CLOG_DEBUG1 "can't map key")); LOG_DEBUG1("can't map key");
keys.clear(); keys.clear();
return nullptr; return nullptr;
} }
@ -611,7 +611,7 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey(
// add keystrokes to restore modifier keys // add keystrokes to restore modifier keys
if (!keysToRestoreModifiers(keyItem, group, newModifiers, newState, activeModifiers, keys)) { if (!keysToRestoreModifiers(keyItem, group, newModifiers, newState, activeModifiers, keys)) {
LOG((CLOG_DEBUG1 "modifiers were not restored")); LOG_DEBUG1("modifiers were not restored");
keys.clear(); keys.clear();
return nullptr; return nullptr;
} }
@ -644,7 +644,7 @@ int32_t KeyMap::findBestKey(const KeyEntryList &entryList, KeyModifierMask desir
const KeyItem &item = entryList[i].back(); const KeyItem &item = entryList[i].back();
if ((item.m_required & desiredState) == item.m_required && if ((item.m_required & desiredState) == item.m_required &&
(item.m_required & desiredState) == (item.m_sensitive & desiredState)) { (item.m_required & desiredState) == (item.m_sensitive & desiredState)) {
LOG((CLOG_DEBUG1 "best key index %d of %d (exact)", i + 1, entryList.size())); LOG_DEBUG1("best key index %d of %d (exact)", i + 1, entryList.size());
return i; return i;
} }
} }
@ -662,7 +662,7 @@ int32_t KeyMap::findBestKey(const KeyEntryList &entryList, KeyModifierMask desir
} }
} }
if (bestIndex != -1) { if (bestIndex != -1) {
LOG((CLOG_DEBUG1 "best key index %d of %d (%d modifiers)", bestIndex + 1, entryList.size(), bestCount)); LOG_DEBUG1("best key index %d of %d (%d modifiers)", bestIndex + 1, entryList.size(), bestCount);
} }
return bestIndex; return bestIndex;
@ -708,7 +708,7 @@ bool KeyMap::keysForKeyItem(
keyItem.m_button, group, activeModifiers, currentState, keyItem.m_required, keyItem.m_sensitive, 0, keyItem.m_button, group, activeModifiers, currentState, keyItem.m_required, keyItem.m_sensitive, 0,
keystrokes keystrokes
)) { )) {
LOG((CLOG_DEBUG1 "unable to match modifier state for dead key %d", keyItem.m_button)); LOG_DEBUG1("unable to match modifier state for dead key %d", keyItem.m_button);
return false; return false;
} }
@ -726,7 +726,7 @@ bool KeyMap::keysForKeyItem(
// button (any other button) mapped to the shift modifier and then // button (any other button) mapped to the shift modifier and then
// the Shift_L button. // the Shift_L button.
// match key's required state // match key's required state
LOG((CLOG_DEBUG1 "state: %04x,%04x,%04x", currentState, keyItem.m_required, sensitive)); LOG_DEBUG1("state: %04x,%04x,%04x", currentState, keyItem.m_required, sensitive);
if (!keysForModifierState( if (!keysForModifierState(
keyItem.m_button, group, activeModifiers, currentState, keyItem.m_required, sensitive, 0, keystrokes keyItem.m_button, group, activeModifiers, currentState, keyItem.m_required, sensitive, 0, keystrokes
)) { )) {
@ -847,7 +847,7 @@ bool KeyMap::keysForModifierState(
const KeyItem *keyItem = keyForModifier(button, group, bit); const KeyItem *keyItem = keyForModifier(button, group, bit);
if (keyItem == nullptr) { if (keyItem == nullptr) {
if ((mask & notRequiredMask) == 0) { if ((mask & notRequiredMask) == 0) {
LOG((CLOG_DEBUG1 "no key for modifier %04x", mask)); LOG_DEBUG1("no key for modifier %04x", mask);
return false; return false;
} else { } else {
continue; continue;
@ -861,13 +861,13 @@ bool KeyMap::keysForModifierState(
if ((sensitive & mask) != 0) { if ((sensitive & mask) != 0) {
// modifier is sensitive to itself. that makes no sense // modifier is sensitive to itself. that makes no sense
// so ignore it. // so ignore it.
LOG((CLOG_DEBUG1 "modifier %04x modified by itself", mask)); LOG_DEBUG1("modifier %04x modified by itself", mask);
sensitive &= ~mask; sensitive &= ~mask;
} }
if (sensitive != 0) { if (sensitive != 0) {
if (sensitive > mask) { if (sensitive > mask) {
// our assumption is incorrect // our assumption is incorrect
LOG((CLOG_DEBUG1 "modifier %04x modified by %04x", mask, sensitive)); LOG_DEBUG1("modifier %04x modified by %04x", mask, sensitive);
return false; return false;
} }
if (active && if (active &&

View file

@ -686,7 +686,7 @@ void KeyState::onKey(KeyButton button, bool down, KeyModifierMask newState)
{ {
// update modifier state // update modifier state
m_mask = newState; m_mask = newState;
LOG((CLOG_DEBUG1 "new mask: 0x%04x", m_mask)); LOG_DEBUG1("new mask: 0x%04x", m_mask);
// ignore bogus buttons // ignore bogus buttons
button &= kButtonMask; button &= kButtonMask;
@ -768,7 +768,7 @@ void KeyState::updateKeyState()
AddActiveModifierContext addModifierContext(pollActiveGroup(), m_mask, m_activeModifiers); AddActiveModifierContext addModifierContext(pollActiveGroup(), m_mask, m_activeModifiers);
m_keyMap.foreachKey(&KeyState::addActiveModifierCB, &addModifierContext); m_keyMap.foreachKey(&KeyState::addActiveModifierCB, &addModifierContext);
LOG((CLOG_DEBUG1 "modifiers on update: 0x%04x", m_mask)); LOG_DEBUG1("modifiers on update: 0x%04x", m_mask);
} }
void KeyState::addActiveModifierCB(KeyID, int32_t group, deskflow::KeyMap::KeyItem &keyItem, void *vcontext) void KeyState::addActiveModifierCB(KeyID, int32_t group, deskflow::KeyMap::KeyItem &keyItem, void *vcontext)
@ -805,7 +805,7 @@ void KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID, c
// ignore certain keys // ignore certain keys
if (isIgnoredKey(id, mask)) { if (isIgnoredKey(id, mask)) {
LOG((CLOG_DEBUG1 "ignored key %04x %04x", id, mask)); LOG_DEBUG1("ignored key %04x %04x", id, mask);
return; return;
} }
@ -819,7 +819,7 @@ void KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID, c
// special way // special way
if (id == kKeyAudioDown || id == kKeyAudioUp || id == kKeyAudioMute || id == kKeyAudioPlay || id == kKeyAudioPrev || if (id == kKeyAudioDown || id == kKeyAudioUp || id == kKeyAudioMute || id == kKeyAudioPlay || id == kKeyAudioPrev ||
id == kKeyAudioNext || id == kKeyBrightnessDown || id == kKeyBrightnessUp) { id == kKeyAudioNext || id == kKeyBrightnessDown || id == kKeyBrightnessUp) {
LOG((CLOG_DEBUG1 "emulating media key")); LOG_DEBUG1("emulating media key");
fakeMediaKey(id); fakeMediaKey(id);
} }
@ -842,7 +842,7 @@ void KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID, c
bool KeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask, int32_t count, KeyButton serverID, const std::string &lang) bool KeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask, int32_t count, KeyButton serverID, const std::string &lang)
{ {
LOG((CLOG_DEBUG2 "fakeKeyRepeat")); LOG_DEBUG2("fakeKeyRepeat");
serverID &= kButtonMask; serverID &= kButtonMask;
// if we haven't seen this button go down then ignore it // if we haven't seen this button go down then ignore it
@ -928,7 +928,7 @@ bool KeyState::fakeKeyUp(KeyButton serverID)
if (!m_activeModifiers.contains(mask)) { if (!m_activeModifiers.contains(mask)) {
// no key for modifier is down so deactivate modifier // no key for modifier is down so deactivate modifier
m_mask &= ~mask; m_mask &= ~mask;
LOG((CLOG_DEBUG1 "new state %04x", m_mask)); LOG_DEBUG1("new state %04x", m_mask);
} }
} else { } else {
++i; ++i;
@ -1087,7 +1087,7 @@ void KeyState::fakeKeys(const Keystrokes &keys, uint32_t count)
// next key // next key
++k; ++k;
} else { } else {
LOG((CLOG_DEBUG1 "skipping keystroke, language sync is disabled")); LOG_DEBUG1("skipping keystroke, language sync is disabled");
++k; ++k;
} }
} }

View file

@ -71,7 +71,7 @@ void ProtocolUtil::writef(deskflow::IStream *stream, const char *fmt, ...)
{ {
assert(stream != nullptr); assert(stream != nullptr);
assert(fmt != nullptr); assert(fmt != nullptr);
LOG((CLOG_DEBUG2 "writef(%s)", fmt)); LOG_DEBUG2("writef(%s)", fmt);
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
@ -87,7 +87,7 @@ bool ProtocolUtil::readf(deskflow::IStream *stream, const char *fmt, ...)
bool result = false; bool result = false;
if (stream && fmt) { if (stream && fmt) {
LOG((CLOG_DEBUG2 "readf(%s)", fmt)); LOG_DEBUG2("readf(%s)", fmt);
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
try { try {
@ -121,9 +121,9 @@ void ProtocolUtil::vwritef(deskflow::IStream *stream, const char *fmt, uint32_t
try { try {
// write buffer // write buffer
stream->write(Buffer.data(), size); stream->write(Buffer.data(), size);
LOG((CLOG_DEBUG2 "wrote %d bytes", size)); LOG_DEBUG2("wrote %d bytes", size);
} catch (const XBase &exception) { } catch (const XBase &exception) {
LOG((CLOG_DEBUG2 "exception <%s> during wrote %d bytes into stream", exception.what(), size)); LOG_DEBUG2("exception <%s> during wrote %d bytes into stream", exception.what(), size);
throw; throw;
} }
} }
@ -157,7 +157,7 @@ void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list ar
break; break;
default: default:
// the length is wrong // the length is wrong
LOG((CLOG_ERR "read: length to be read is wrong: '%d' should be 1,2, or 4", len)); LOG_ERR("read: length to be read is wrong: '%d' should be 1,2, or 4", len);
assert(false); // assert for debugging assert(false); // assert for debugging
break; break;
} }
@ -181,7 +181,7 @@ void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list ar
break; break;
default: default:
// the length is wrong // the length is wrong
LOG((CLOG_ERR "read: length to be read is wrong: '%d' should be 1,2, or 4", len)); LOG_ERR("read: length to be read is wrong: '%d' should be 1,2, or 4", len);
assert(false); // assert for debugging assert(false); // assert for debugging
break; break;
} }
@ -192,7 +192,7 @@ void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list ar
std::string *destination = va_arg(args, std::string *); std::string *destination = va_arg(args, std::string *);
if (len > PROTOCOL_MAX_STRING_LENGTH) { if (len > PROTOCOL_MAX_STRING_LENGTH) {
LOG((CLOG_ERR "read: string length exceeds maximum allowed size: %u", len)); LOG_ERR("read: string length exceeds maximum allowed size: %u", len);
throw XBadClient("Too long message received"); throw XBadClient("Too long message received");
} }
@ -217,7 +217,7 @@ void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list ar
// 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_DEBUG2("readf: format mismatch: %c vs %c", *fmt, buffer[0]);
throw XIOReadMismatch(); throw XIOReadMismatch();
} }
@ -257,7 +257,7 @@ uint32_t ProtocolUtil::getLength(const char *fmt, va_list args)
break; break;
default: default:
LOG((CLOG_ERR "format specifier %%I%d has invalid length", len)); LOG_ERR("format specifier %%I%d has invalid length", len);
break; break;
} }
break; break;
@ -429,7 +429,7 @@ void ProtocolUtil::read(deskflow::IStream *stream, void *vbuffer, uint32_t 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_DEBUG2("unexpected disconnect in readf(), %d bytes left", count);
throw XIOEndOfStream(); throw XIOEndOfStream();
} }
@ -446,7 +446,7 @@ uint8_t ProtocolUtil::read1ByteInt(deskflow::IStream *stream)
read(stream, buffer.data(), BufferSize); read(stream, buffer.data(), BufferSize);
uint8_t Result = buffer[0]; uint8_t Result = buffer[0];
LOG((CLOG_DEBUG2 "readf: read 1 byte integer: %d (0x%x)", Result, Result)); LOG_DEBUG2("readf: read 1 byte integer: %d (0x%x)", Result, Result);
return Result; return Result;
} }
@ -458,7 +458,7 @@ uint16_t ProtocolUtil::read2BytesInt(deskflow::IStream *stream)
read(stream, buffer.data(), BufferSize); read(stream, buffer.data(), BufferSize);
auto Result = static_cast<uint16_t>((static_cast<uint16_t>(buffer[0]) << 8) | static_cast<uint16_t>(buffer[1])); auto Result = static_cast<uint16_t>((static_cast<uint16_t>(buffer[0]) << 8) | static_cast<uint16_t>(buffer[1]));
LOG((CLOG_DEBUG2 "readf: read 2 byte integer: %d (0x%x)", Result, Result)); LOG_DEBUG2("readf: read 2 byte integer: %d (0x%x)", Result, Result);
return Result; return Result;
} }
@ -472,7 +472,7 @@ uint32_t ProtocolUtil::read4BytesInt(deskflow::IStream *stream)
uint32_t Result = (static_cast<uint32_t>(buffer[0]) << 24) | (static_cast<uint32_t>(buffer[1]) << 16) | uint32_t Result = (static_cast<uint32_t>(buffer[0]) << 24) | (static_cast<uint32_t>(buffer[1]) << 16) |
(static_cast<uint32_t>(buffer[2]) << 8) | (static_cast<uint32_t>(buffer[3])); (static_cast<uint32_t>(buffer[2]) << 8) | (static_cast<uint32_t>(buffer[3]));
LOG((CLOG_DEBUG2 "readf: read 4 byte integer: %d (0x%x)", Result, Result)); LOG_DEBUG2("readf: read 4 byte integer: %d (0x%x)", Result, Result);
return Result; return Result;
} }
@ -506,7 +506,7 @@ uint32_t ProtocolUtil::readVectorSize(deskflow::IStream *stream)
auto size = read4BytesInt(stream); auto size = read4BytesInt(stream);
if (size > PROTOCOL_MAX_LIST_LENGTH) { if (size > PROTOCOL_MAX_LIST_LENGTH) {
LOG((CLOG_ERR "readVectorSize: vector length exceeds maximum allowed size: %u", size)); LOG_ERR("readVectorSize: vector length exceeds maximum allowed size: %u", size);
throw XBadClient("Too long message received"); throw XBadClient("Too long message received");
} }
@ -534,8 +534,8 @@ void ProtocolUtil::readBytes(deskflow::IStream *stream, uint32_t len, std::strin
sBuffer = new uint8_t[len]; sBuffer = new uint8_t[len];
} catch (std::bad_alloc &exception) { } catch (std::bad_alloc &exception) {
// Added try catch due to GHSA-chfm-333q-gfpp // Added try catch due to GHSA-chfm-333q-gfpp
LOG((CLOG_ERR "bad alloc, unable to allocate memory %d bytes", len)); LOG_ERR("bad alloc, unable to allocate memory %d bytes", len);
LOG((CLOG_DEBUG "bad_alloc detected: is there enough memory?")); LOG_DEBUG("bad_alloc detected: is there enough memory?");
throw exception; throw exception;
} }
} }
@ -550,7 +550,7 @@ void ProtocolUtil::readBytes(deskflow::IStream *stream, uint32_t len, std::strin
throw; throw;
} }
LOG((CLOG_DEBUG2 "readf: read %d byte string", len)); LOG_DEBUG2("readf: read %d byte string", len);
// save the data // save the data

View file

@ -29,7 +29,7 @@ Screen::Screen(IPlatformScreen *platformScreen, IEventQueue *events)
// reset options // reset options
resetOptions(); resetOptions();
LOG((CLOG_DEBUG "opened display")); LOG_DEBUG("opened display");
} }
Screen::~Screen() Screen::~Screen()
@ -57,14 +57,14 @@ Screen::~Screen()
m_entered ? "yes" : "no", m_isPrimary ? "yes" : "no") m_entered ? "yes" : "no", m_isPrimary ? "yes" : "no")
); );
if (m_isPrimary) { if (m_isPrimary) {
LOG((CLOG_WARN "current primary screen is not entered on shutdown")); LOG_WARN("current primary screen is not entered on shutdown");
} else { } else {
LOG((CLOG_WARN "current secondary screen is entered on shutdown")); LOG_WARN("current secondary screen is entered on shutdown");
} }
} }
delete m_screen; delete m_screen;
LOG((CLOG_DEBUG "closed display")); LOG_DEBUG("closed display");
} }
void Screen::enable() void Screen::enable()
@ -106,7 +106,7 @@ void Screen::disable()
void Screen::enter(KeyModifierMask toggleMask) void Screen::enter(KeyModifierMask toggleMask)
{ {
LOG((CLOG_INFO "entering screen")); LOG_INFO("entering screen");
if (m_entered) { if (m_entered) {
LOG_WARN("screen already entered"); LOG_WARN("screen already entered");
@ -125,7 +125,7 @@ void Screen::enter(KeyModifierMask toggleMask)
bool Screen::leave() bool Screen::leave()
{ {
LOG((CLOG_INFO "leaving screen")); LOG_INFO("leaving screen");
if (!m_entered) { if (!m_entered) {
LOG_WARN("screen already left"); LOG_WARN("screen already left");
@ -183,7 +183,7 @@ void Screen::keyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std
{ {
// check for ctrl+alt+del emulation // check for ctrl+alt+del emulation
if (id == kKeyDelete && (mask & (KeyModifierControl | KeyModifierAlt)) == (KeyModifierControl | KeyModifierAlt)) { if (id == kKeyDelete && (mask & (KeyModifierControl | KeyModifierAlt)) == (KeyModifierControl | KeyModifierAlt)) {
LOG((CLOG_DEBUG "emulating ctrl+alt+del press")); LOG_DEBUG("emulating ctrl+alt+del press");
if (m_screen->fakeCtrlAltDel()) { if (m_screen->fakeCtrlAltDel()) {
return; return;
} }
@ -249,21 +249,21 @@ void Screen::setOptions(const OptionsList &options)
} else { } else {
m_halfDuplex &= ~KeyModifierCapsLock; m_halfDuplex &= ~KeyModifierCapsLock;
} }
LOG((CLOG_DEBUG1 "half-duplex caps-lock %s", ((m_halfDuplex & KeyModifierCapsLock) != 0) ? "on" : "off")); LOG_DEBUG1("half-duplex caps-lock %s", ((m_halfDuplex & KeyModifierCapsLock) != 0) ? "on" : "off");
} else if (options[i] == kOptionHalfDuplexNumLock) { } else if (options[i] == kOptionHalfDuplexNumLock) {
if (options[i + 1] != 0) { if (options[i + 1] != 0) {
m_halfDuplex |= KeyModifierNumLock; m_halfDuplex |= KeyModifierNumLock;
} else { } else {
m_halfDuplex &= ~KeyModifierNumLock; m_halfDuplex &= ~KeyModifierNumLock;
} }
LOG((CLOG_DEBUG1 "half-duplex num-lock %s", ((m_halfDuplex & KeyModifierNumLock) != 0) ? "on" : "off")); LOG_DEBUG1("half-duplex num-lock %s", ((m_halfDuplex & KeyModifierNumLock) != 0) ? "on" : "off");
} else if (options[i] == kOptionHalfDuplexScrollLock) { } else if (options[i] == kOptionHalfDuplexScrollLock) {
if (options[i + 1] != 0) { if (options[i + 1] != 0) {
m_halfDuplex |= KeyModifierScrollLock; m_halfDuplex |= KeyModifierScrollLock;
} else { } else {
m_halfDuplex &= ~KeyModifierScrollLock; m_halfDuplex &= ~KeyModifierScrollLock;
} }
LOG((CLOG_DEBUG1 "half-duplex scroll-lock %s", ((m_halfDuplex & KeyModifierScrollLock) != 0) ? "on" : "off")); LOG_DEBUG1("half-duplex scroll-lock %s", ((m_halfDuplex & KeyModifierScrollLock) != 0) ? "on" : "off");
} }
} }
@ -313,7 +313,7 @@ bool Screen::isOnScreen() const
bool Screen::isLockedToScreen() const bool Screen::isLockedToScreen() const
{ {
if (uint32_t buttonID = 0; m_screen->isAnyMouseButtonDown(buttonID)) { if (uint32_t buttonID = 0; m_screen->isAnyMouseButtonDown(buttonID)) {
LOG((CLOG_DEBUG "locked by mouse buttonID: %d", buttonID)); LOG_DEBUG("locked by mouse buttonID: %d", buttonID);
return true; return true;
} }
// not locked // not locked

View file

@ -90,7 +90,7 @@ void ServerApp::parseArgs(int argc, const char *const *argv)
*m_deskflowAddress = NetworkAddress(args().m_deskflowAddress, kDefaultPort); *m_deskflowAddress = NetworkAddress(args().m_deskflowAddress, kDefaultPort);
m_deskflowAddress->resolve(); m_deskflowAddress->resolve();
} catch (XSocketAddress &e) { } catch (XSocketAddress &e) {
LOG((CLOG_CRIT "%s: %s" BYE, args().m_pname, e.what(), args().m_pname)); LOG_CRIT("%s: %s" BYE, args().m_pname, e.what(), args().m_pname);
bye(s_exitArgs); bye(s_exitArgs);
} }
} }
@ -137,7 +137,7 @@ void ServerApp::help()
<< "The default is to listen on all interfaces. The port overrides the\n" << "The default is to listen on all interfaces. The port overrides the\n"
<< "default port, " << kDefaultPort << ".\n"; << "default port, " << kDefaultPort << ".\n";
LOG((CLOG_PRINT "%s", help.str().c_str())); LOG_PRINT("%s", help.str().c_str());
} }
void ServerApp::reloadSignalHandler(Arch::ThreadSignal, void *) void ServerApp::reloadSignalHandler(Arch::ThreadSignal, void *)
@ -148,12 +148,12 @@ void ServerApp::reloadSignalHandler(Arch::ThreadSignal, void *)
void ServerApp::reloadConfig() void ServerApp::reloadConfig()
{ {
LOG((CLOG_DEBUG "reload configuration")); LOG_DEBUG("reload configuration");
if (loadConfig(args().m_configFile)) { if (loadConfig(args().m_configFile)) {
if (m_server != nullptr) { if (m_server != nullptr) {
m_server->setConfig(*args().m_config); m_server->setConfig(*args().m_config);
} }
LOG((CLOG_NOTE "reloaded configuration")); LOG_NOTE("reloaded configuration");
} }
} }
@ -161,12 +161,12 @@ void ServerApp::loadConfig()
{ {
const auto path = args().m_configFile; const auto path = args().m_configFile;
if (path.empty()) { if (path.empty()) {
LOG((CLOG_CRIT "no configuration path provided")); LOG_CRIT("no configuration path provided");
bye(s_exitConfig); bye(s_exitConfig);
} }
if (!loadConfig(path)) { if (!loadConfig(path)) {
LOG((CLOG_CRIT "%s: failed to load config: %s", args().m_pname, path.c_str())); LOG_CRIT("%s: failed to load config: %s", args().m_pname, path.c_str());
bye(s_exitConfig); bye(s_exitConfig);
} }
} }
@ -175,18 +175,18 @@ bool ServerApp::loadConfig(const std::string &pathname)
{ {
try { try {
// load configuration // load configuration
LOG((CLOG_DEBUG "opening configuration \"%s\"", pathname.c_str())); LOG_DEBUG("opening configuration \"%s\"", pathname.c_str());
std::ifstream configStream(deskflow::filesystem::path(pathname)); std::ifstream configStream(deskflow::filesystem::path(pathname));
if (!configStream.is_open()) { if (!configStream.is_open()) {
LOG((CLOG_ERR "cannot open configuration \"%s\"", pathname.c_str())); LOG_ERR("cannot open configuration \"%s\"", pathname.c_str());
return false; return false;
} }
configStream >> *args().m_config; configStream >> *args().m_config;
LOG((CLOG_DEBUG "configuration read successfully")); LOG_DEBUG("configuration read successfully");
return true; return true;
} catch (XConfigRead &e) { } catch (XConfigRead &e) {
// report error in configuration file // report error in configuration file
LOG((CLOG_ERR "cannot read configuration \"%s\": %s", pathname.c_str(), e.what())); LOG_ERR("cannot read configuration \"%s\": %s", pathname.c_str(), e.what());
} }
return false; return false;
} }
@ -320,7 +320,7 @@ void ServerApp::retryHandler()
break; break;
case Initializing: case Initializing:
LOG((CLOG_DEBUG1 "retry server initialization")); LOG_DEBUG1("retry server initialization");
m_serverState = Uninitialized; m_serverState = Uninitialized;
if (!initServer()) { if (!initServer()) {
getEvents()->addEvent(Event(EventTypes::Quit)); getEvents()->addEvent(Event(EventTypes::Quit));
@ -328,12 +328,12 @@ void ServerApp::retryHandler()
break; break;
case InitializingToStart: case InitializingToStart:
LOG((CLOG_DEBUG1 "retry server initialization")); LOG_DEBUG1("retry server initialization");
m_serverState = Uninitialized; m_serverState = Uninitialized;
if (!initServer()) { if (!initServer()) {
getEvents()->addEvent(Event(EventTypes::Quit)); getEvents()->addEvent(Event(EventTypes::Quit));
} else if (m_serverState == Initialized) { } else if (m_serverState == Initialized) {
LOG((CLOG_DEBUG1 "starting server")); LOG_DEBUG1("starting server");
if (!startServer()) { if (!startServer()) {
getEvents()->addEvent(Event(EventTypes::Quit)); getEvents()->addEvent(Event(EventTypes::Quit));
} }
@ -341,7 +341,7 @@ void ServerApp::retryHandler()
break; break;
case Starting: case Starting:
LOG((CLOG_DEBUG1 "retry starting server")); LOG_DEBUG1("retry starting server");
m_serverState = Initialized; m_serverState = Initialized;
if (!startServer()) { if (!startServer()) {
getEvents()->addEvent(Event(EventTypes::Quit)); getEvents()->addEvent(Event(EventTypes::Quit));
@ -370,17 +370,17 @@ bool ServerApp::initServer()
m_serverState = Initialized; m_serverState = Initialized;
return true; return true;
} catch (XScreenUnavailable &e) { } catch (XScreenUnavailable &e) {
LOG((CLOG_WARN "primary screen unavailable: %s", e.what())); LOG_WARN("primary screen unavailable: %s", e.what());
closePrimaryClient(primaryClient); closePrimaryClient(primaryClient);
closeServerScreen(serverScreen); closeServerScreen(serverScreen);
retryTime = e.getRetryTime(); retryTime = e.getRetryTime();
} catch (XScreenOpenFailure &e) { } catch (XScreenOpenFailure &e) {
LOG((CLOG_CRIT "failed to start server: %s", e.what())); LOG_CRIT("failed to start server: %s", e.what());
closePrimaryClient(primaryClient); closePrimaryClient(primaryClient);
closeServerScreen(serverScreen); closeServerScreen(serverScreen);
return false; return false;
} catch (XBase &e) { } catch (XBase &e) {
LOG((CLOG_CRIT "failed to start server: %s", e.what())); LOG_CRIT("failed to start server: %s", e.what());
closePrimaryClient(primaryClient); closePrimaryClient(primaryClient);
closeServerScreen(serverScreen); closeServerScreen(serverScreen);
return false; return false;
@ -389,7 +389,7 @@ bool ServerApp::initServer()
if (args().m_restartable) { if (args().m_restartable) {
// install a timer and handler to retry later // install a timer and handler to retry later
assert(m_timer == nullptr); assert(m_timer == nullptr);
LOG((CLOG_DEBUG "retry in %.0f seconds", retryTime)); LOG_DEBUG("retry in %.0f seconds", retryTime);
m_timer = getEvents()->newOneShotTimer(retryTime, nullptr); m_timer = getEvents()->newOneShotTimer(retryTime, nullptr);
getEvents()->addHandler(EventTypes::Timer, m_timer, [this](const auto &) { retryHandler(); }); getEvents()->addHandler(EventTypes::Timer, m_timer, [this](const auto &) { retryHandler(); });
m_serverState = Initializing; m_serverState = Initializing;
@ -442,18 +442,18 @@ bool ServerApp::startServer()
listener->setServer(m_server); listener->setServer(m_server);
m_server->setListener(listener); m_server->setListener(listener);
m_listener = listener; m_listener = listener;
LOG((CLOG_NOTE "started server, waiting for clients")); LOG_NOTE("started server, waiting for clients");
m_serverState = Started; m_serverState = Started;
return true; return true;
} catch (XSocketAddressInUse &e) { } catch (XSocketAddressInUse &e) {
if (args().m_restartable) { if (args().m_restartable) {
LOG((CLOG_ERR "cannot listen for clients: %s", e.what())); LOG_ERR("cannot listen for clients: %s", e.what());
} else { } else {
LOG((CLOG_CRIT "cannot listen for clients: %s", e.what())); LOG_CRIT("cannot listen for clients: %s", e.what());
} }
closeClientListener(listener); closeClientListener(listener);
} catch (XBase &e) { } catch (XBase &e) {
LOG((CLOG_CRIT "failed to start server: %s", e.what())); LOG_CRIT("failed to start server: %s", e.what());
closeClientListener(listener); closeClientListener(listener);
return false; return false;
} }
@ -462,7 +462,7 @@ bool ServerApp::startServer()
// install a timer and handler to retry later // install a timer and handler to retry later
assert(m_timer == nullptr); assert(m_timer == nullptr);
const auto retryTime = 10.0; const auto retryTime = 10.0;
LOG((CLOG_DEBUG "retry in %.0f seconds", retryTime)); LOG_DEBUG("retry in %.0f seconds", retryTime);
m_timer = getEvents()->newOneShotTimer(retryTime, nullptr); m_timer = getEvents()->newOneShotTimer(retryTime, nullptr);
getEvents()->addHandler(EventTypes::Timer, m_timer, [this](const auto &) { retryHandler(); }); getEvents()->addHandler(EventTypes::Timer, m_timer, [this](const auto &) { retryHandler(); });
m_serverState = Starting; m_serverState = Starting;
@ -482,7 +482,7 @@ deskflow::Screen *ServerApp::createScreen()
#if defined(WINAPI_XWINDOWS) or defined(WINAPI_LIBEI) #if defined(WINAPI_XWINDOWS) or defined(WINAPI_LIBEI)
if (deskflow::platform::isWayland()) { if (deskflow::platform::isWayland()) {
#if WINAPI_LIBEI #if WINAPI_LIBEI
LOG((CLOG_INFO "using ei screen for wayland")); LOG_INFO("using ei screen for wayland");
return new deskflow::Screen(new deskflow::EiScreen(true, getEvents(), true), getEvents()); return new deskflow::Screen(new deskflow::EiScreen(true, getEvents(), true), getEvents());
#else #else
throw XNoEiSupport(); throw XNoEiSupport();
@ -491,7 +491,7 @@ deskflow::Screen *ServerApp::createScreen()
#endif #endif
#if WINAPI_XWINDOWS #if WINAPI_XWINDOWS
LOG((CLOG_INFO "using legacy x windows screen")); LOG_INFO("using legacy x windows screen");
return new deskflow::Screen(new XWindowsScreen(args().m_display, true, 0, getEvents()), getEvents()); return new deskflow::Screen(new XWindowsScreen(args().m_display, true, 0, getEvents()), getEvents());
#elif WINAPI_CARBON #elif WINAPI_CARBON
return new deskflow::Screen(new OSXScreen(getEvents(), true), getEvents()); return new deskflow::Screen(new OSXScreen(getEvents(), true), getEvents());
@ -500,14 +500,14 @@ deskflow::Screen *ServerApp::createScreen()
PrimaryClient *ServerApp::openPrimaryClient(const std::string &name, deskflow::Screen *screen) PrimaryClient *ServerApp::openPrimaryClient(const std::string &name, deskflow::Screen *screen)
{ {
LOG((CLOG_DEBUG1 "creating primary screen")); LOG_DEBUG1("creating primary screen");
return new PrimaryClient(name, screen); return new PrimaryClient(name, screen);
} }
void ServerApp::handleSuspend() void ServerApp::handleSuspend()
{ {
if (!m_suspended) { if (!m_suspended) {
LOG((CLOG_INFO "suspend")); LOG_INFO("suspend");
stopServer(); stopServer();
m_suspended = true; m_suspended = true;
} }
@ -516,7 +516,7 @@ void ServerApp::handleSuspend()
void ServerApp::handleResume() void ServerApp::handleResume()
{ {
if (m_suspended) { if (m_suspended) {
LOG((CLOG_INFO "resume")); LOG_INFO("resume");
startServer(); startServer();
m_suspended = false; m_suspended = false;
} }
@ -595,7 +595,7 @@ int ServerApp::mainLoop()
// canonicalize the primary screen name // canonicalize the primary screen name
if (std::string primaryName = args().m_config->getCanonicalName(args().m_name); primaryName.empty()) { if (std::string primaryName = args().m_config->getCanonicalName(args().m_name); primaryName.empty()) {
LOG((CLOG_CRIT "unknown screen name `%s'", args().m_name.c_str())); LOG_CRIT("unknown screen name `%s'", args().m_name.c_str());
return s_exitFailed; return s_exitFailed;
} }
@ -641,18 +641,18 @@ int ServerApp::mainLoop()
DAEMON_RUNNING(false); DAEMON_RUNNING(false);
// close down // close down
LOG((CLOG_DEBUG1 "stopping server")); LOG_DEBUG1("stopping server");
getEvents()->removeHandler(EventTypes::ServerAppForceReconnect, getEvents()->getSystemTarget()); getEvents()->removeHandler(EventTypes::ServerAppForceReconnect, getEvents()->getSystemTarget());
getEvents()->removeHandler(EventTypes::ServerAppReloadConfig, getEvents()->getSystemTarget()); getEvents()->removeHandler(EventTypes::ServerAppReloadConfig, getEvents()->getSystemTarget());
cleanupServer(); cleanupServer();
LOG((CLOG_NOTE "stopped server")); LOG_NOTE("stopped server");
return s_exitSuccess; return s_exitSuccess;
} }
void ServerApp::resetServer() void ServerApp::resetServer()
{ {
LOG((CLOG_DEBUG1 "resetting server")); LOG_DEBUG1("resetting server");
stopServer(); stopServer();
cleanupServer(); cleanupServer();
startServer(); startServer();
@ -719,7 +719,7 @@ void ServerApp::startNode()
{ {
// start the server. if this return false then we've failed and // start the server. if this return false then we've failed and
// we shouldn't retry. // we shouldn't retry.
LOG((CLOG_DEBUG1 "starting server")); LOG_DEBUG1("starting server");
if (!startServer()) { if (!startServer()) {
bye(s_exitFailed); bye(s_exitFailed);
} }

View file

@ -57,5 +57,5 @@ void StreamChunker::sendClipboard(
events->addEvent(Event(EventTypes::ClipboardSending, eventTarget, end)); events->addEvent(Event(EventTypes::ClipboardSending, eventTarget, end));
LOG((CLOG_DEBUG "sent clipboard size=%d", sentLength)); LOG_DEBUG("sent clipboard size=%d", sentLength);
} }

View file

@ -29,7 +29,7 @@ namespace deskflow::languages {
LanguageManager::LanguageManager(const std::vector<std::string> &localLanguages) : m_localLanguages(localLanguages) LanguageManager::LanguageManager(const std::vector<std::string> &localLanguages) : m_localLanguages(localLanguages)
{ {
LOG((CLOG_INFO "local languages: %s", vectorToString(m_localLanguages, ", ").c_str())); LOG_INFO("local languages: %s", vectorToString(m_localLanguages, ", ").c_str());
} }
void LanguageManager::setRemoteLanguages(const std::string_view &remoteLanguages) void LanguageManager::setRemoteLanguages(const std::string_view &remoteLanguages)
@ -41,7 +41,7 @@ void LanguageManager::setRemoteLanguages(const std::string_view &remoteLanguages
m_remoteLanguages.emplace_back(rLangs); m_remoteLanguages.emplace_back(rLangs);
} }
} }
LOG((CLOG_INFO "remote languages: %s", vectorToString(m_remoteLanguages, ", ").c_str())); LOG_INFO("remote languages: %s", vectorToString(m_remoteLanguages, ", ").c_str());
} }
const std::vector<std::string> &LanguageManager::getRemoteLanguages() const const std::vector<std::string> &LanguageManager::getRemoteLanguages() const

View file

@ -92,13 +92,13 @@ std::string AppUtilUnix::getCurrentLanguageCode()
auto display = XOpenDisplay(nullptr); auto display = XOpenDisplay(nullptr);
if (!display) { if (!display) {
LOG((CLOG_WARN "failed to open x11 default display")); LOG_WARN("failed to open x11 default display");
return result; return result;
} }
auto kbdDescr = XkbAllocKeyboard(); auto kbdDescr = XkbAllocKeyboard();
if (!kbdDescr) { if (!kbdDescr) {
LOG((CLOG_WARN "failed to get x11 keyboard description")); LOG_WARN("failed to get x11 keyboard description");
return result; return result;
} }
XkbGetNames(display, XkbSymbolsNameMask, kbdDescr); XkbGetNames(display, XkbSymbolsNameMask, kbdDescr);

View file

@ -20,10 +20,10 @@ DeskflowXkbKeyboard::DeskflowXkbKeyboard()
if (display) { if (display) {
if (!XkbRF_GetNamesProp(display.get(), nullptr, &m_data)) { if (!XkbRF_GetNamesProp(display.get(), nullptr, &m_data)) {
LOG((CLOG_WARN "error reading keyboard layouts")); LOG_WARN("error reading keyboard layouts");
} }
} else { } else {
LOG((CLOG_WARN "can't open xkb display during reading languages")); LOG_WARN("can't open xkb display during reading languages");
} }
} }

View file

@ -36,7 +36,7 @@ bool X11LayoutsParser::readXMLConfigItemElem(const QDomNode &node, std::vector<L
{ {
auto configItemElem = node.firstChildElement("configItem"); auto configItemElem = node.firstChildElement("configItem");
if (configItemElem.isNull()) { if (configItemElem.isNull()) {
LOG((CLOG_WARN "failed to read \"configItem\" in xml file")); LOG_WARN("failed to read \"configItem\" in xml file");
return false; return false;
} }
@ -60,7 +60,7 @@ std::vector<X11LayoutsParser::Lang> X11LayoutsParser::getAllLanguageData(const s
QFile inFile(QString::fromStdString(pathToEvdevFile)); QFile inFile(QString::fromStdString(pathToEvdevFile));
if (!inFile.open(QIODevice::ReadOnly)) { if (!inFile.open(QIODevice::ReadOnly)) {
LOG((CLOG_WARN "unable to open %s", pathToEvdevFile.c_str())); LOG_WARN("unable to open %s", pathToEvdevFile.c_str());
return allCodes; return allCodes;
} }
@ -69,13 +69,13 @@ std::vector<X11LayoutsParser::Lang> X11LayoutsParser::getAllLanguageData(const s
const auto xkbConfigElem = xmlDoc.firstChildElement("xkbConfigRegistry"); const auto xkbConfigElem = xmlDoc.firstChildElement("xkbConfigRegistry");
if (xkbConfigElem.isNull()) { if (xkbConfigElem.isNull()) {
LOG((CLOG_WARN "failed to read xkbConfigRegistry in %s", pathToEvdevFile.c_str())); LOG_WARN("failed to read xkbConfigRegistry in %s", pathToEvdevFile.c_str());
return allCodes; return allCodes;
} }
auto layoutListElem = xkbConfigElem.firstChildElement("layoutList"); auto layoutListElem = xkbConfigElem.firstChildElement("layoutList");
if (layoutListElem.isNull()) { if (layoutListElem.isNull()) {
LOG((CLOG_WARN "failed to read layoutList in %s", pathToEvdevFile.c_str())); LOG_WARN("failed to read layoutList in %s", pathToEvdevFile.c_str());
return allCodes; return allCodes;
} }
@ -113,13 +113,13 @@ void X11LayoutsParser::convertLayoutToISO639_2(
for (size_t i = 0; i < layoutNames.size(); i++) { for (size_t i = 0; i < layoutNames.size(); i++) {
const auto &layoutName = layoutNames[i]; const auto &layoutName = layoutNames[i];
if (layoutNames[i].empty()) { if (layoutNames[i].empty()) {
LOG((CLOG_DEBUG "skip converting empty layout name")); LOG_DEBUG("skip converting empty layout name");
continue; continue;
} }
auto langIter = std::ranges::find_if(allLang, [&layoutName](const Lang &l) { return l.name == layoutName; }); auto langIter = std::ranges::find_if(allLang, [&layoutName](const Lang &l) { return l.name == layoutName; });
if (langIter == allLang.end()) { if (langIter == allLang.end()) {
LOG((CLOG_WARN "language \"%s\" is unknown", layoutNames[i].c_str())); LOG_WARN("language \"%s\" is unknown", layoutNames[i].c_str());
continue; continue;
} }
@ -175,20 +175,20 @@ std::string X11LayoutsParser::convertLayotToISO(
) )
{ {
if (layoutLangCode.empty()) { if (layoutLangCode.empty()) {
LOG((CLOG_DEBUG1 "skip converting empty layout lang code")); LOG_DEBUG1("skip converting empty layout lang code");
return ""; return "";
} }
std::vector<std::string> iso639_2Codes; std::vector<std::string> iso639_2Codes;
convertLayoutToISO639_2(pathToEvdevFile, needToReloadFiles, {layoutLangCode}, {""}, iso639_2Codes); convertLayoutToISO639_2(pathToEvdevFile, needToReloadFiles, {layoutLangCode}, {""}, iso639_2Codes);
if (iso639_2Codes.empty()) { if (iso639_2Codes.empty()) {
LOG((CLOG_WARN "failed to convert layout lang code: \"%s\"", layoutLangCode.c_str())); LOG_WARN("failed to convert layout lang code: \"%s\"", layoutLangCode.c_str());
return ""; return "";
} }
auto iso639_1Codes = convertISO639_2ToISO639_1(iso639_2Codes); auto iso639_1Codes = convertISO639_2ToISO639_1(iso639_2Codes);
if (iso639_1Codes.empty()) { if (iso639_1Codes.empty()) {
LOG((CLOG_WARN "failed to convert ISO639/2 lang code to ISO639/1")); LOG_WARN("failed to convert ISO639/2 lang code to ISO639/1");
return ""; return "";
} }
@ -203,7 +203,7 @@ std::vector<std::string> X11LayoutsParser::convertISO639_2ToISO639_1(const std::
return c.first == isoCode; return c.first == isoCode;
}); });
if (tableIter == ISO_Table.end()) { if (tableIter == ISO_Table.end()) {
LOG((CLOG_WARN "the ISO 639-2 code \"%s\" is missed in table", isoCode.c_str())); LOG_WARN("the ISO 639-2 code \"%s\" is missed in table", isoCode.c_str());
continue; continue;
} }

View file

@ -50,7 +50,7 @@ AppUtilWindows::~AppUtilWindows()
BOOL WINAPI AppUtilWindows::consoleHandler(DWORD) BOOL WINAPI AppUtilWindows::consoleHandler(DWORD)
{ {
LOG((CLOG_INFO "got shutdown signal")); LOG_INFO("got shutdown signal");
IEventQueue *events = AppUtil::instance().app().getEvents(); IEventQueue *events = AppUtil::instance().app().getEvents();
events->addEvent(Event(EventTypes::Quit)); events->addEvent(Event(EventTypes::Quit));
return TRUE; return TRUE;
@ -181,7 +181,7 @@ HKL AppUtilWindows::getCurrentKeyboardLayout() const
if (GetGUIThreadInfo(0, &gti) && gti.hwndActive) { if (GetGUIThreadInfo(0, &gti) && gti.hwndActive) {
layout = GetKeyboardLayout(GetWindowThreadProcessId(gti.hwndActive, nullptr)); layout = GetKeyboardLayout(GetWindowThreadProcessId(gti.hwndActive, nullptr));
} else { } else {
LOG((CLOG_WARN "failed to determine current keyboard layout")); LOG_WARN("failed to determine current keyboard layout");
} }
return layout; return layout;

View file

@ -125,28 +125,28 @@ void *Thread::threadFunc(void *vjob)
void *result = nullptr; void *result = nullptr;
try { try {
// go // go
LOG((CLOG_DEBUG1 "thread 0x%08x entry", id)); LOG_DEBUG1("thread 0x%08x entry", id);
job->run(); job->run();
LOG((CLOG_DEBUG1 "thread 0x%08x exit", id)); LOG_DEBUG1("thread 0x%08x exit", id);
} catch (XThreadCancel &) { } catch (XThreadCancel &) {
// client called cancel() // client called cancel()
LOG((CLOG_DEBUG1 "caught cancel on thread 0x%08x", id)); LOG_DEBUG1("caught cancel on thread 0x%08x", id);
delete job; delete job;
throw; throw;
} 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 0x%08x, result %p", id, result)); LOG_DEBUG1("caught exit on thread 0x%08x, result %p", id, result);
} catch (XBase &e) { } catch (XBase &e) {
LOG((CLOG_ERR "exception on thread 0x%08x: %s", id, e.what())); LOG_ERR("exception on thread 0x%08x: %s", id, e.what());
delete job; delete job;
throw; throw;
} catch (std::exception &e) { } catch (std::exception &e) {
LOG((CLOG_ERR "standard exception on thread 0x%08x: %s", id, e.what())); LOG_ERR("standard exception on thread 0x%08x: %s", id, e.what());
delete job; delete job;
throw; throw;
} catch (...) { } catch (...) {
LOG((CLOG_ERR "non-exception throw on thread 0x%08x: <unknown>", id)); LOG_ERR("non-exception throw on thread 0x%08x: <unknown>", id);
delete job; delete job;
throw; throw;
} }

View file

@ -225,7 +225,7 @@ int SecureSocket::secureRead(void *buffer, int size, int &read)
std::scoped_lock ssl_lock{ssl_mutex_}; std::scoped_lock ssl_lock{ssl_mutex_};
if (m_ssl->m_ssl != nullptr) { if (m_ssl->m_ssl != nullptr) {
LOG((CLOG_DEBUG2 "reading secure socket")); LOG_DEBUG2("reading secure socket");
read = SSL_read(m_ssl->m_ssl, buffer, size); read = SSL_read(m_ssl->m_ssl, buffer, size);
static int retry; static int retry;
@ -252,7 +252,7 @@ int SecureSocket::secureWrite(const void *buffer, int size, int &wrote)
std::scoped_lock ssl_lock{ssl_mutex_}; std::scoped_lock ssl_lock{ssl_mutex_};
if (m_ssl->m_ssl != nullptr) { if (m_ssl->m_ssl != nullptr) {
LOG((CLOG_DEBUG2 "writing secure socket: %p", this)); LOG_DEBUG2("writing secure socket: %p", this);
wrote = SSL_write(m_ssl->m_ssl, buffer, size); wrote = SSL_write(m_ssl->m_ssl, buffer, size);
@ -413,7 +413,7 @@ int SecureSocket::secureAccept(int socket)
// set connection socket to SSL state // set connection socket to SSL state
SSL_set_fd(m_ssl->m_ssl, socket); SSL_set_fd(m_ssl->m_ssl, socket);
LOG((CLOG_DEBUG2 "accepting secure socket")); LOG_DEBUG2("accepting secure socket");
int r = SSL_accept(m_ssl->m_ssl); int r = SSL_accept(m_ssl->m_ssl);
static int retry; static int retry;
@ -422,8 +422,8 @@ int SecureSocket::secureAccept(int socket)
if (isFatal()) { if (isFatal()) {
// tell user and sleep so the socket isn't hammered. // tell user and sleep so the socket isn't hammered.
LOG((CLOG_ERR "failed to accept secure socket")); LOG_ERR("failed to accept secure socket");
LOG((CLOG_WARN "client connection may not be secure")); LOG_WARN("client connection may not be secure");
m_secureReady = false; m_secureReady = false;
Arch::sleep(1); Arch::sleep(1);
retry = 0; retry = 0;
@ -438,7 +438,7 @@ int SecureSocket::secureAccept(int socket)
return -1; // Fail return -1; // Fail
} }
m_secureReady = true; m_secureReady = true;
LOG((CLOG_INFO "accepted secure socket")); LOG_INFO("accepted secure socket");
SslLogger::logSecureCipherInfo(m_ssl->m_ssl); SslLogger::logSecureCipherInfo(m_ssl->m_ssl);
SslLogger::logSecureConnectInfo(m_ssl->m_ssl); SslLogger::logSecureConnectInfo(m_ssl->m_ssl);
return 1; return 1;
@ -446,14 +446,14 @@ int SecureSocket::secureAccept(int socket)
// If not fatal and retry is set, not ready, and return retry // If not fatal and retry is set, not ready, and return retry
if (retry > 0) { if (retry > 0) {
LOG((CLOG_DEBUG2 "retry accepting secure socket")); LOG_DEBUG2("retry accepting secure socket");
m_secureReady = false; m_secureReady = false;
Arch::sleep(s_retryDelay); Arch::sleep(s_retryDelay);
return 0; return 0;
} }
// no good state exists here // no good state exists here
LOG((CLOG_ERR "unexpected state attempting to accept connection")); LOG_ERR("unexpected state attempting to accept connection");
return -1; return -1;
} }
@ -463,7 +463,7 @@ int SecureSocket::secureConnect(int socket)
std::string certDir = Settings::value(Settings::Security::Certificate).toString().toStdString(); std::string certDir = Settings::value(Settings::Security::Certificate).toString().toStdString();
if (!loadCertificates(certDir)) { if (!loadCertificates(certDir)) {
LOG((CLOG_ERR "could not load client certificates")); LOG_ERR("could not load client certificates");
disconnect(); disconnect();
return -1; return -1;
} }
@ -475,7 +475,7 @@ int SecureSocket::secureConnect(int socket)
// attach the socket descriptor // attach the socket descriptor
SSL_set_fd(m_ssl->m_ssl, socket); SSL_set_fd(m_ssl->m_ssl, socket);
LOG((CLOG_DEBUG2 "connecting secure socket")); LOG_DEBUG2("connecting secure socket");
// TODO: S1-1766, enable hostname verification. // TODO: S1-1766, enable hostname verification.
// the cert will need to be installed in the trusted store on the client. // the cert will need to be installed in the trusted store on the client.
@ -487,14 +487,14 @@ int SecureSocket::secureConnect(int socket)
checkResult(r, retry); checkResult(r, retry);
if (isFatal()) { if (isFatal()) {
LOG((CLOG_ERR "failed to connect secure socket")); LOG_ERR("failed to connect secure socket");
retry = 0; retry = 0;
return -1; return -1;
} }
// If we should retry, not ready and return 0 // If we should retry, not ready and return 0
if (retry > 0) { if (retry > 0) {
LOG((CLOG_DEBUG2 "retry connect secure socket")); LOG_DEBUG2("retry connect secure socket");
m_secureReady = false; m_secureReady = false;
Arch::sleep(s_retryDelay); Arch::sleep(s_retryDelay);
return 0; return 0;
@ -504,17 +504,17 @@ int SecureSocket::secureConnect(int socket)
// No error, set ready, process and return ok // No error, set ready, process and return ok
m_secureReady = true; m_secureReady = true;
if (verifyCertFingerprint(Settings::tlsTrustedServersDb())) { if (verifyCertFingerprint(Settings::tlsTrustedServersDb())) {
LOG((CLOG_INFO "connected to secure socket")); LOG_INFO("connected to secure socket");
if (!showCertificate()) { if (!showCertificate()) {
disconnect(); disconnect();
return -1; // Cert fail, error return -1; // Cert fail, error
} }
} else { } else {
LOG((CLOG_ERR "failed to verify server certificate fingerprint")); LOG_ERR("failed to verify server certificate fingerprint");
disconnect(); disconnect();
return -1; // Fingerprint failed, error return -1; // Fingerprint failed, error
} }
LOG((CLOG_DEBUG2 "connected secure socket")); LOG_DEBUG2("connected secure socket");
SslLogger::logSecureCipherInfo(m_ssl->m_ssl); SslLogger::logSecureCipherInfo(m_ssl->m_ssl);
SslLogger::logSecureConnectInfo(m_ssl->m_ssl); SslLogger::logSecureConnectInfo(m_ssl->m_ssl);
return 1; return 1;
@ -529,7 +529,7 @@ bool SecureSocket::showCertificate() const
cert = SSL_get_peer_certificate(m_ssl->m_ssl); cert = SSL_get_peer_certificate(m_ssl->m_ssl);
if (cert != nullptr) { if (cert != nullptr) {
line = X509_NAME_oneline(X509_get_subject_name(cert), nullptr, 0); line = X509_NAME_oneline(X509_get_subject_name(cert), nullptr, 0);
LOG((CLOG_INFO "server tls certificate info: %s", line)); LOG_INFO("server tls certificate info: %s", line);
OPENSSL_free(line); OPENSSL_free(line);
X509_free(cert); X509_free(cert);
} else { } else {
@ -553,12 +553,12 @@ void SecureSocket::checkResult(int status, int &retry)
case SSL_ERROR_ZERO_RETURN: case SSL_ERROR_ZERO_RETURN:
// connection closed // connection closed
isFatal(true); isFatal(true);
LOG((CLOG_DEBUG "tls connection closed")); LOG_DEBUG("tls connection closed");
break; break;
case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_READ:
retry++; retry++;
LOG((CLOG_DEBUG2 "want to read, error=%d, attempt=%d", errorCode, retry)); LOG_DEBUG2("want to read, error=%d, attempt=%d", errorCode, retry);
break; break;
case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_WRITE:
@ -567,30 +567,30 @@ void SecureSocket::checkResult(int status, int &retry)
// m_readable because the socket logic is always readable // m_readable because the socket logic is always readable
setWritable(true); setWritable(true);
retry++; retry++;
LOG((CLOG_DEBUG2 "want to write, error=%d, attempt=%d", errorCode, retry)); LOG_DEBUG2("want to write, error=%d, attempt=%d", errorCode, retry);
break; break;
case SSL_ERROR_WANT_CONNECT: case SSL_ERROR_WANT_CONNECT:
retry++; retry++;
LOG((CLOG_DEBUG2 "want to connect, error=%d, attempt=%d", errorCode, retry)); LOG_DEBUG2("want to connect, error=%d, attempt=%d", errorCode, retry);
break; break;
case SSL_ERROR_WANT_ACCEPT: case SSL_ERROR_WANT_ACCEPT:
retry++; retry++;
LOG((CLOG_DEBUG2 "want to accept, error=%d, attempt=%d", errorCode, retry)); LOG_DEBUG2("want to accept, error=%d, attempt=%d", errorCode, retry);
break; break;
case SSL_ERROR_SYSCALL: case SSL_ERROR_SYSCALL:
LOG((CLOG_ERR "tls error occurred (system call failure)")); LOG_ERR("tls error occurred (system call failure)");
if (ERR_peek_error() == 0) { if (ERR_peek_error() == 0) {
if (status == 0) { if (status == 0) {
LOG((CLOG_ERR "eof violates tls protocol")); LOG_ERR("eof violates tls protocol");
} else if (status == -1) { } else if (status == -1) {
// underlying socket I/O reproted an error // underlying socket I/O reproted an error
try { try {
ARCH->throwErrorOnSocket(getSocket()); ARCH->throwErrorOnSocket(getSocket());
} catch (XArchNetwork &e) { } catch (XArchNetwork &e) {
LOG((CLOG_ERR "%s", e.what())); LOG_ERR("%s", e.what());
} }
} }
} }
@ -599,12 +599,12 @@ void SecureSocket::checkResult(int status, int &retry)
break; break;
case SSL_ERROR_SSL: case SSL_ERROR_SSL:
LOG((CLOG_ERR "tls error occurred (generic failure)")); LOG_ERR("tls error occurred (generic failure)");
isFatal(true); isFatal(true);
break; break;
default: default:
LOG((CLOG_ERR "tls error occurred (unknown failure)")); LOG_ERR("tls error occurred (unknown failure)");
isFatal(true); isFatal(true);
break; break;
} }
@ -636,7 +636,7 @@ bool SecureSocket::verifyCertFingerprint(const QString &FingerprintDatabasePath)
return false; return false;
// Gui Must Parse this line, DO NOT CHANGE // Gui Must Parse this line, DO NOT CHANGE
LOG((CLOG_NOTE "peer fingerprint: %s", deskflow::formatSSLFingerprint(sha256.data, false).toStdString().c_str())); LOG_NOTE("peer fingerprint: %s", deskflow::formatSSLFingerprint(sha256.data, false).toStdString().c_str());
QFile file(FingerprintDatabasePath); QFile file(FingerprintDatabasePath);
@ -646,20 +646,20 @@ bool SecureSocket::verifyCertFingerprint(const QString &FingerprintDatabasePath)
const auto &path = FingerprintDatabasePath; const auto &path = FingerprintDatabasePath;
if (file.exists() && emptyDB) { if (file.exists() && emptyDB) {
LOG((CLOG_ERR "failed to open trusted fingerprints file: %s", path.toStdString().c_str())); LOG_ERR("failed to open trusted fingerprints file: %s", path.toStdString().c_str());
return false; return false;
} }
if (!emptyDB) { if (!emptyDB) {
LOG((CLOG_DEBUG "read %d fingerprint(s) from file: %s", db.fingerprints().size(), path.toStdString().c_str())); LOG_DEBUG("read %d fingerprint(s) from file: %s", db.fingerprints().size(), path.toStdString().c_str());
} }
if (!db.isTrusted(sha256)) { if (!db.isTrusted(sha256)) {
LOG((CLOG_WARN "fingerprint does not match trusted fingerprint")); LOG_WARN("fingerprint does not match trusted fingerprint");
return false; return false;
} }
LOG((CLOG_DEBUG "fingerprint matches trusted fingerprint")); LOG_DEBUG("fingerprint matches trusted fingerprint");
return true; return true;
} }
@ -721,7 +721,7 @@ ISocketMultiplexerJob *SecureSocket::serviceAccept(ISocketMultiplexerJob *job, b
void SecureSocket::handleTCPConnected(const Event &) void SecureSocket::handleTCPConnected(const Event &)
{ {
if (getSocket() == nullptr) { if (getSocket() == nullptr) {
LOG((CLOG_DEBUG "disregarding stale connect event")); LOG_DEBUG("disregarding stale connect event");
return; return;
} }
secureConnect(); secureConnect();

View file

@ -174,7 +174,7 @@ void SocketMultiplexer::removeSocket(ISocket *socket)
status = 0; status = 0;
} }
} catch (XArchNetwork &e) { } catch (XArchNetwork &e) {
LOG((CLOG_WARN "error in socket multiplexer: %s", e.what())); LOG_WARN("error in socket multiplexer: %s", e.what());
status = 0; status = 0;
} }

View file

@ -26,7 +26,7 @@ void showCipherStackDesc(STACK_OF(SSL_CIPHER) * stack)
msg[pos] = '\0'; msg[pos] = '\0';
} }
LOG((CLOG_DEBUG1 "%s", msg)); LOG_DEBUG1("%s", msg);
} }
} }
@ -35,10 +35,10 @@ void logLocalSecureCipherInfo(const SSL *ssl)
auto sStack = SSL_get_ciphers(ssl); auto sStack = SSL_get_ciphers(ssl);
if (sStack) { if (sStack) {
LOG((CLOG_DEBUG1 "available local ciphers:")); LOG_DEBUG1("available local ciphers:");
showCipherStackDesc(sStack); showCipherStackDesc(sStack);
} else { } else {
LOG((CLOG_DEBUG1 "local cipher list not available")); LOG_DEBUG1("local cipher list not available");
} }
} }
@ -54,10 +54,10 @@ void logRemoteSecureCipherInfo(const SSL *ssl)
auto cStack = SSL_get_client_ciphers(ssl); auto cStack = SSL_get_client_ciphers(ssl);
#endif #endif
if (cStack) { if (cStack) {
LOG((CLOG_DEBUG1 "available remote ciphers:")); LOG_DEBUG1("available remote ciphers:");
showCipherStackDesc(cStack); showCipherStackDesc(cStack);
} else { } else {
LOG((CLOG_DEBUG1 "remote cipher list not available")); LOG_DEBUG1("remote cipher list not available");
} }
} }
@ -66,11 +66,11 @@ void logRemoteSecureCipherInfo(const SSL *ssl)
void SslLogger::logSecureLibInfo() void SslLogger::logSecureLibInfo()
{ {
if (CLOG->getFilter() >= LogLevel::Debug) { if (CLOG->getFilter() >= LogLevel::Debug) {
LOG((CLOG_DEBUG "openssl version: %s", SSLeay_version(SSLEAY_VERSION))); LOG_DEBUG("openssl version: %s", SSLeay_version(SSLEAY_VERSION));
LOG((CLOG_DEBUG1 "openssl flags: %s", SSLeay_version(SSLEAY_CFLAGS))); LOG_DEBUG1("openssl flags: %s", SSLeay_version(SSLEAY_CFLAGS));
LOG((CLOG_DEBUG1 "openssl built on: %s", SSLeay_version(SSLEAY_BUILT_ON))); LOG_DEBUG1("openssl built on: %s", SSLeay_version(SSLEAY_BUILT_ON));
LOG((CLOG_DEBUG1 "openssl platform: %s", SSLeay_version(SSLEAY_PLATFORM))); LOG_DEBUG1("openssl platform: %s", SSLeay_version(SSLEAY_PLATFORM));
LOG((CLOG_DEBUG1 "openssl dir: %s", SSLeay_version(SSLEAY_DIR))); LOG_DEBUG1("openssl dir: %s", SSLeay_version(SSLEAY_DIR));
} }
} }
@ -90,7 +90,7 @@ void SslLogger::logSecureConnectInfo(const SSL *ssl)
if (cipher) { if (cipher) {
char msg[128] = {0}; char msg[128] = {0};
SSL_CIPHER_description(cipher, msg, sizeof(msg)); SSL_CIPHER_description(cipher, msg, sizeof(msg));
LOG((CLOG_DEBUG "openssl cipher: %s", msg)); LOG_DEBUG("openssl cipher: %s", msg);
// For some reason SSL_get_version is return mismatching information to // For some reason SSL_get_version is return mismatching information to
// SSL_CIPHER_description // SSL_CIPHER_description
@ -106,15 +106,15 @@ void SslLogger::logSecureConnectInfo(const SSL *ssl)
}; };
if (parts.size() > 2) { if (parts.size() > 2) {
// log the section containing the protocol version // log the section containing the protocol version
LOG((CLOG_INFO "network encryption protocol: %s", parts[1].c_str())); LOG_INFO("network encryption protocol: %s", parts[1].c_str());
} else { } else {
// log the error in spliting then display the whole description rather // log the error in spliting then display the whole description rather
// then nothing // then nothing
LOG((CLOG_ERR "could not split cipher for protocol")); LOG_ERR("could not split cipher for protocol");
LOG((CLOG_INFO "network encryption protocol: %s", msg)); LOG_INFO("network encryption protocol: %s", msg);
} }
} else { } else {
LOG((CLOG_ERR "could not get secure socket cipher")); LOG_ERR("could not get secure socket cipher");
} }
} }
} }
@ -122,14 +122,14 @@ void SslLogger::logSecureConnectInfo(const SSL *ssl)
void SslLogger::logError(const std::string &reason) void SslLogger::logError(const std::string &reason)
{ {
if (!reason.empty()) { if (!reason.empty()) {
LOG((CLOG_ERR "secure socket error: %s", reason.c_str())); LOG_ERR("secure socket error: %s", reason.c_str());
} }
auto id = ERR_get_error(); auto id = ERR_get_error();
if (id) { if (id) {
char error[65535] = {0}; char error[65535] = {0};
ERR_error_string_n(id, error, sizeof(error)); ERR_error_string_n(id, error, sizeof(error));
LOG((CLOG_ERR "openssl error: %s", error)); LOG_ERR("openssl error: %s", error);
} }
} }
@ -140,35 +140,35 @@ void SslLogger::logErrorByCode(int code, int retry)
break; break;
case SSL_ERROR_ZERO_RETURN: case SSL_ERROR_ZERO_RETURN:
LOG((CLOG_DEBUG "tls connection closed")); LOG_DEBUG("tls connection closed");
break; break;
case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_READ:
LOG((CLOG_DEBUG2 "want to read, error=%d, attempt=%d", code, retry)); LOG_DEBUG2("want to read, error=%d, attempt=%d", code, retry);
break; break;
case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_WRITE:
LOG((CLOG_DEBUG2 "want to write, error=%d, attempt=%d", code, retry)); LOG_DEBUG2("want to write, error=%d, attempt=%d", code, retry);
break; break;
case SSL_ERROR_WANT_CONNECT: case SSL_ERROR_WANT_CONNECT:
LOG((CLOG_DEBUG2 "want to connect, error=%d, attempt=%d", code, retry)); LOG_DEBUG2("want to connect, error=%d, attempt=%d", code, retry);
break; break;
case SSL_ERROR_WANT_ACCEPT: case SSL_ERROR_WANT_ACCEPT:
LOG((CLOG_DEBUG2 "want to accept, error=%d, attempt=%d", code, retry)); LOG_DEBUG2("want to accept, error=%d, attempt=%d", code, retry);
break; break;
case SSL_ERROR_SYSCALL: case SSL_ERROR_SYSCALL:
LOG((CLOG_ERR "tls error occurred (system call failure)")); LOG_ERR("tls error occurred (system call failure)");
break; break;
case SSL_ERROR_SSL: case SSL_ERROR_SSL:
LOG((CLOG_ERR "tls error occurred (generic failure)")); LOG_ERR("tls error occurred (generic failure)");
break; break;
default: default:
LOG((CLOG_ERR "tls error occurred (unknown failure)")); LOG_ERR("tls error occurred (unknown failure)");
break; break;
} }
} }

View file

@ -44,7 +44,7 @@ TCPListenSocket::~TCPListenSocket()
} }
} catch (...) { } catch (...) {
// ignore // ignore
LOG((CLOG_WARN "error while closing TCP socket")); LOG_WARN("error while closing TCP socket");
} }
} }

View file

@ -39,7 +39,7 @@ TCPSocket::TCPSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer,
throw XSocketCreate(e.what()); throw XSocketCreate(e.what());
} }
LOG((CLOG_DEBUG "opening new socket: %08X", m_socket)); LOG_DEBUG("opening new socket: %08X", m_socket);
init(); init();
} }
@ -53,7 +53,7 @@ TCPSocket::TCPSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer,
{ {
assert(m_socket != nullptr); assert(m_socket != nullptr);
LOG((CLOG_DEBUG "opening new socket: %08X", m_socket)); LOG_DEBUG("opening new socket: %08X", m_socket);
// socket starts in connected state // socket starts in connected state
init(); init();
@ -67,7 +67,7 @@ TCPSocket::~TCPSocket()
// warning virtual function in destructor is very danger practice // warning virtual function in destructor is very danger practice
close(); close();
} catch (...) { } catch (...) {
LOG((CLOG_DEBUG "error while TCP socket destruction")); LOG_DEBUG("error while TCP socket destruction");
} }
} }
@ -84,7 +84,7 @@ void TCPSocket::bind(const NetworkAddress &addr)
void TCPSocket::close() void TCPSocket::close()
{ {
LOG((CLOG_DEBUG "closing socket: %08X", m_socket)); LOG_DEBUG("closing socket: %08X", m_socket);
// remove ourself from the multiplexer // remove ourself from the multiplexer
setJob(nullptr); setJob(nullptr);
@ -105,7 +105,7 @@ void TCPSocket::close()
ARCH->closeSocket(socket); ARCH->closeSocket(socket);
} catch (const XArchNetwork &e) { } catch (const XArchNetwork &e) {
// ignore, there's not much we can do // ignore, there's not much we can do
LOG((CLOG_WARN "error closing socket: %s", e.what())); LOG_WARN("error closing socket: %s", e.what());
} }
} }
} }
@ -186,7 +186,7 @@ void TCPSocket::shutdownInput()
ARCH->closeSocketForRead(m_socket); ARCH->closeSocketForRead(m_socket);
} catch (const XArchNetwork &e) { } catch (const XArchNetwork &e) {
// ignore, there's not much we can do // ignore, there's not much we can do
LOG((CLOG_WARN "error closing socket: %s", e.what())); LOG_WARN("error closing socket: %s", e.what());
} }
// shutdown buffer for reading // shutdown buffer for reading
@ -212,7 +212,7 @@ void TCPSocket::shutdownOutput()
ARCH->closeSocketForWrite(m_socket); ARCH->closeSocketForWrite(m_socket);
} catch (const XArchNetwork &e) { } catch (const XArchNetwork &e) {
// ignore, there's not much we can do // ignore, there's not much we can do
LOG((CLOG_WARN "error closing socket: %s", e.what())); LOG_WARN("error closing socket: %s", e.what());
} }
// shutdown buffer for writing // shutdown buffer for writing
@ -236,7 +236,7 @@ bool TCPSocket::isReady() const
bool TCPSocket::isFatal() const bool TCPSocket::isFatal() const
{ {
// TCP sockets aren't ever left in a fatal state. // TCP sockets aren't ever left in a fatal state.
LOG((CLOG_ERR "isFatal() not valid for non-secure connections")); LOG_ERR("isFatal() not valid for non-secure connections");
return false; return false;
} }
@ -290,7 +290,7 @@ void TCPSocket::init()
m_socket = nullptr; m_socket = nullptr;
} catch (const XArchNetwork &e) { } catch (const XArchNetwork &e) {
// ignore, there's not much we can do // ignore, there's not much we can do
LOG((CLOG_WARN "error closing socket: %s", e.what())); LOG_WARN("error closing socket: %s", e.what());
} }
throw XSocketCreate(e.what()); throw XSocketCreate(e.what());
} }
@ -520,7 +520,7 @@ ISocketMultiplexerJob *TCPSocket::serviceConnected(ISocketMultiplexerJob *job, b
writeResult = New; writeResult = New;
} catch (XArchNetwork &e) { } catch (XArchNetwork &e) {
// other write error // other write error
LOG((CLOG_WARN "error writing socket: %s", e.what())); LOG_WARN("error writing socket: %s", e.what());
onDisconnected(); onDisconnected();
sendEvent(StreamOutputError); sendEvent(StreamOutputError);
sendEvent(SocketDisconnected); sendEvent(SocketDisconnected);
@ -538,7 +538,7 @@ ISocketMultiplexerJob *TCPSocket::serviceConnected(ISocketMultiplexerJob *job, b
readResult = New; readResult = New;
} catch (XArchNetwork &e) { } catch (XArchNetwork &e) {
// ignore other read error // ignore other read error
LOG((CLOG_WARN "error reading socket: %s", e.what())); LOG_WARN("error reading socket: %s", e.what());
} }
} }

View file

@ -53,13 +53,13 @@ void MSWindowsClipboard::setFacade(IMSWindowsClipboardFacade &facade)
bool MSWindowsClipboard::emptyUnowned() bool MSWindowsClipboard::emptyUnowned()
{ {
LOG((CLOG_DEBUG "empty clipboard")); LOG_DEBUG("empty clipboard");
// empty the clipboard (and take ownership) // empty the clipboard (and take ownership)
if (!EmptyClipboard()) { if (!EmptyClipboard()) {
// unable to cause this in integ tests, but this error has never // unable to cause this in integ tests, but this error has never
// actually been reported by users. // actually been reported by users.
LOG((CLOG_WARN "failed to grab clipboard")); LOG_WARN("failed to grab clipboard");
return false; return false;
} }
@ -75,7 +75,7 @@ bool MSWindowsClipboard::empty()
// mark clipboard as being owned by deskflow // mark clipboard as being owned by deskflow
HGLOBAL data = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, 1); HGLOBAL data = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, 1);
if (nullptr == SetClipboardData(getOwnershipFormat(), data)) { if (nullptr == SetClipboardData(getOwnershipFormat(), data)) {
LOG((CLOG_WARN "failed to set clipboard data")); LOG_WARN("failed to set clipboard data");
GlobalFree(data); GlobalFree(data);
return false; return false;
} }
@ -87,7 +87,7 @@ void MSWindowsClipboard::add(Format format, const std::string &data)
{ {
// exit early if there is no data to prevent spurious "failed to convert clipboard data" errors // exit early if there is no data to prevent spurious "failed to convert clipboard data" errors
if (data.empty()) { if (data.empty()) {
LOG((CLOG_DEBUG "not adding 0 bytes to clipboard format: %d", format)); LOG_DEBUG("not adding 0 bytes to clipboard format: %d", format);
return; return;
} }
bool isSucceeded = false; bool isSucceeded = false;
@ -99,27 +99,27 @@ void MSWindowsClipboard::add(Format format, const std::string &data)
if (converter->getFormat() == format) { if (converter->getFormat() == format) {
HANDLE win32Data = converter->fromIClipboard(data); HANDLE win32Data = converter->fromIClipboard(data);
if (win32Data != nullptr) { if (win32Data != nullptr) {
LOG((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format)); LOG_DEBUG("add %d bytes to clipboard format: %d", data.size(), format);
m_facade->write(win32Data, converter->getWin32Format()); m_facade->write(win32Data, converter->getWin32Format());
isSucceeded = true; isSucceeded = true;
break; break;
} else { } else {
LOG((CLOG_DEBUG "failed to convert clipboard data to platform format")); LOG_DEBUG("failed to convert clipboard data to platform format");
} }
} }
} }
if (!isSucceeded) { if (!isSucceeded) {
LOG((CLOG_DEBUG "missed clipboard data convert for format: %d", format)); LOG_DEBUG("missed clipboard data convert for format: %d", format);
} }
} }
bool MSWindowsClipboard::open(Time time) const bool MSWindowsClipboard::open(Time time) const
{ {
LOG((CLOG_DEBUG "open clipboard")); LOG_DEBUG("open clipboard");
if (!OpenClipboard(m_window)) { if (!OpenClipboard(m_window)) {
LOG((CLOG_WARN "failed to open clipboard: %d", GetLastError())); LOG_WARN("failed to open clipboard: %d", GetLastError());
return false; return false;
} }
@ -130,7 +130,7 @@ bool MSWindowsClipboard::open(Time time) const
void MSWindowsClipboard::close() const void MSWindowsClipboard::close() const
{ {
LOG((CLOG_DEBUG "close clipboard")); LOG_DEBUG("close clipboard");
CloseClipboard(); CloseClipboard();
} }
@ -167,7 +167,7 @@ std::string MSWindowsClipboard::get(Format format) const
// if no converter then we don't recognize any formats // if no converter then we don't recognize any formats
if (converter == nullptr) { if (converter == nullptr) {
LOG((CLOG_WARN "no converter for format %d", format)); LOG_WARN("no converter for format %d", format);
return std::string(); return std::string();
} }

View file

@ -67,8 +67,7 @@ std::string MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const
} }
// create a destination DIB section // create a destination DIB section
LOG((CLOG_INFO "convert image from: depth=%d comp=%d", bitmap->bmiHeader.biBitCount, bitmap->bmiHeader.biCompression) LOG_INFO("convert image from: depth=%d comp=%d", bitmap->bmiHeader.biBitCount, bitmap->bmiHeader.biCompression);
);
void *raw; void *raw;
BITMAPINFOHEADER info; BITMAPINFOHEADER info;
LONG w = bitmap->bmiHeader.biWidth; LONG w = bitmap->bmiHeader.biWidth;

View file

@ -183,7 +183,7 @@ void MSWindowsDesks::setOptions(const OptionsList &options)
for (uint32_t i = 0, n = (uint32_t)options.size(); i < n; i += 2) { for (uint32_t i = 0, n = (uint32_t)options.size(); i < n; i += 2) {
if (options[i] == kOptionWin32KeepForeground) { if (options[i] == kOptionWin32KeepForeground) {
m_leaveForegroundOption = (options[i + 1] != 0); m_leaveForegroundOption = (options[i + 1] != 0);
LOG((CLOG_DEBUG1 "%s the foreground window", m_leaveForegroundOption ? "don\'t grab" : "grab")); LOG_DEBUG1("%s the foreground window", m_leaveForegroundOption ? "don\'t grab" : "grab");
} }
} }
} }
@ -367,7 +367,7 @@ HWND MSWindowsDesks::createWindow(ATOM windowClass, const char *name) const
MSWindowsScreen::getWindowInstance(), nullptr MSWindowsScreen::getWindowInstance(), nullptr
); );
if (window == nullptr) { if (window == nullptr) {
LOG((CLOG_ERR "failed to create window: %d", GetLastError())); LOG_ERR("failed to create window: %d", GetLastError());
throw XScreenOpenFailure(); throw XScreenOpenFailure();
} }
return window; return window;
@ -611,10 +611,10 @@ void MSWindowsDesks::deskThread(void *vdesk)
// create a window. we use this window to hide the cursor. // create a window. we use this window to hide the cursor.
try { try {
desk->m_window = createWindow(m_deskClass, "DeskflowDesk"); desk->m_window = createWindow(m_deskClass, "DeskflowDesk");
LOG((CLOG_DEBUG "desk %s window is 0x%08x", desk->m_name.c_str(), desk->m_window)); LOG_DEBUG("desk %s window is 0x%08x", desk->m_name.c_str(), desk->m_window);
} catch (...) { } catch (...) {
// ignore // ignore
LOG((CLOG_DEBUG "can't create desk window for %s", desk->m_name.c_str())); LOG_DEBUG("can't create desk window for %s", desk->m_name.c_str());
} }
} }
@ -802,15 +802,15 @@ void MSWindowsDesks::checkDesk()
// from an inaccessible desktop so when we switch from an // from an inaccessible desktop so when we switch from an
// inaccessible desktop to an accessible one we have to // inaccessible desktop to an accessible one we have to
// update the keyboard state. // update the keyboard state.
LOG((CLOG_DEBUG "switched to desk \"%s\"", name.c_str())); LOG_DEBUG("switched to desk \"%s\"", name.c_str());
bool syncKeys = false; bool syncKeys = false;
bool isAccessible = isDeskAccessible(desk); bool isAccessible = isDeskAccessible(desk);
if (isDeskAccessible(m_activeDesk) != isAccessible) { if (isDeskAccessible(m_activeDesk) != isAccessible) {
if (isAccessible) { if (isAccessible) {
LOG((CLOG_DEBUG "desktop is now accessible")); LOG_DEBUG("desktop is now accessible");
syncKeys = true; syncKeys = true;
} else { } else {
LOG((CLOG_DEBUG "desktop is now inaccessible")); LOG_DEBUG("desktop is now inaccessible");
} }
} }

View file

@ -53,8 +53,8 @@ void MSWindowsHook::loadLibrary()
// initialize library // initialize library
if (init(GetCurrentThreadId()) == 0) { if (init(GetCurrentThreadId()) == 0) {
LOG((CLOG_ERR "failed to init %s.dll, another program may be using it", g_name)); LOG_ERR("failed to init %s.dll, another program may be using it", g_name);
LOG((CLOG_INFO "restarting your computer may solve this error")); LOG_INFO("restarting your computer may solve this error");
throw XScreenOpenFailure(); throw XScreenOpenFailure();
} }
} }

View file

@ -834,7 +834,7 @@ int32_t MSWindowsKeyState::pollActiveGroup() const
// get group // get group
GroupMap::const_iterator i = m_groupMap.find(hkl); GroupMap::const_iterator i = m_groupMap.find(hkl);
if (i == m_groupMap.end()) { if (i == m_groupMap.end()) {
LOG((CLOG_DEBUG1 "can't find keyboard layout %08x", hkl)); LOG_DEBUG1("can't find keyboard layout %08x", hkl);
return 0; return 0;
} }
@ -845,8 +845,8 @@ void MSWindowsKeyState::pollPressedKeys(KeyButtonSet &pressedKeys) const
{ {
BYTE keyState[256]; BYTE keyState[256];
if (!GetKeyboardState(keyState)) { if (!GetKeyboardState(keyState)) {
LOG((CLOG_WARN "keyboard state is unexpected")); LOG_WARN("keyboard state is unexpected");
LOG((CLOG_DEBUG "function 'GetKeyboardState' returned false on 'pollPressedKeys'")); LOG_DEBUG("function 'GetKeyboardState' returned false on 'pollPressedKeys'");
return; return;
} }
for (KeyButton i = 1; i < 256; ++i) { for (KeyButton i = 1; i < 256; ++i) {
@ -1172,7 +1172,7 @@ void MSWindowsKeyState::fakeKey(const Keystroke &keystroke)
// windows doesn't send key ups for key repeats // windows doesn't send key ups for key repeats
if (keystroke.m_data.m_button.m_repeat && !keystroke.m_data.m_button.m_press) { if (keystroke.m_data.m_button.m_repeat && !keystroke.m_data.m_button.m_press) {
LOG((CLOG_DEBUG1 " discard key repeat release")); LOG_DEBUG1(" discard key repeat release");
break; break;
} }
@ -1207,10 +1207,10 @@ void MSWindowsKeyState::fakeKey(const Keystroke &keystroke)
// key events. // key events.
if (!keystroke.m_data.m_group.m_restore) { if (!keystroke.m_data.m_group.m_restore) {
if (keystroke.m_data.m_group.m_absolute) { if (keystroke.m_data.m_group.m_absolute) {
LOG((CLOG_DEBUG1 " group %d", keystroke.m_data.m_group.m_group)); LOG_DEBUG1(" group %d", keystroke.m_data.m_group.m_group);
setWindowGroup(keystroke.m_data.m_group.m_group); setWindowGroup(keystroke.m_data.m_group.m_group);
} else { } else {
LOG((CLOG_DEBUG1 " group %+d", keystroke.m_data.m_group.m_group)); LOG_DEBUG1(" group %+d", keystroke.m_data.m_group.m_group);
setWindowGroup(getEffectiveGroup(pollActiveGroup(), keystroke.m_data.m_group.m_group)); setWindowGroup(getEffectiveGroup(pollActiveGroup(), keystroke.m_data.m_group.m_group));
} }
} }
@ -1232,13 +1232,13 @@ bool MSWindowsKeyState::getGroups(GroupList &groups) const
// get keyboard layouts // get keyboard layouts
uint32_t newNumLayouts = GetKeyboardLayoutList(0, nullptr); uint32_t newNumLayouts = GetKeyboardLayoutList(0, nullptr);
if (newNumLayouts == 0) { if (newNumLayouts == 0) {
LOG((CLOG_DEBUG1 "can't get keyboard layouts")); LOG_DEBUG1("can't get keyboard layouts");
return false; return false;
} }
HKL *newLayouts = new HKL[newNumLayouts]; HKL *newLayouts = new HKL[newNumLayouts];
newNumLayouts = GetKeyboardLayoutList(newNumLayouts, newLayouts); newNumLayouts = GetKeyboardLayoutList(newNumLayouts, newLayouts);
if (newNumLayouts == 0) { if (newNumLayouts == 0) {
LOG((CLOG_DEBUG1 "can't get keyboard layouts")); LOG_DEBUG1("can't get keyboard layouts");
delete[] newLayouts; delete[] newLayouts;
return false; return false;
} }
@ -1258,7 +1258,7 @@ void MSWindowsKeyState::setWindowGroup(int32_t group)
// character set. // character set.
if (!PostMessage(targetWindow, WM_INPUTLANGCHANGEREQUEST, sysCharSet ? 1 : 0, (LPARAM)m_groups[group])) { if (!PostMessage(targetWindow, WM_INPUTLANGCHANGEREQUEST, sysCharSet ? 1 : 0, (LPARAM)m_groups[group])) {
LOG((CLOG_WARN "failed to post change language message")); LOG_WARN("failed to post change language message");
} }
// XXX -- use a short delay to let the target window process the message // XXX -- use a short delay to let the target window process the message

View file

@ -62,7 +62,7 @@ BOOL MSWindowsProcess::startAsUser(HANDLE userToken, LPSECURITY_ATTRIBUTES sa)
LPVOID environment; LPVOID environment;
if (!CreateEnvironmentBlock(&environment, userToken, FALSE)) { if (!CreateEnvironmentBlock(&environment, userToken, FALSE)) {
LOG((CLOG_ERR "could not create environment block")); LOG_ERR("could not create environment block");
throw std::runtime_error(windowsErrorToString(GetLastError())); throw std::runtime_error(windowsErrorToString(GetLastError()));
} }

View file

@ -114,8 +114,8 @@ MSWindowsScreen::MSWindowsScreen(
m_class = createWindowClass(); m_class = createWindowClass();
m_window = createWindow(m_class, kAppName); m_window = createWindow(m_class, kAppName);
setupMouseKeys(); setupMouseKeys();
LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : "")); LOG_DEBUG("screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : "");
LOG((CLOG_DEBUG "window is 0x%08x", m_window)); LOG_DEBUG("window is 0x%08x", m_window);
if (App::instance().argsBase().m_preventSleep) { if (App::instance().argsBase().m_preventSleep) {
m_powerManager.disableSleep(); m_powerManager.disableSleep();
@ -186,7 +186,7 @@ void MSWindowsScreen::enable()
// install our clipboard snooper // install our clipboard snooper
if (!AddClipboardFormatListener(m_window)) { if (!AddClipboardFormatListener(m_window)) {
LOG((CLOG_WARN "failed to add the clipboard format listener: %d", GetLastError())); LOG_WARN("failed to add the clipboard format listener: %d", GetLastError());
} }
// track the active desk and (re)install the hooks // track the active desk and (re)install the hooks
@ -222,7 +222,7 @@ void MSWindowsScreen::disable()
// stop snooping the clipboard // stop snooping the clipboard
if (!RemoveClipboardFormatListener(m_window)) { if (!RemoveClipboardFormatListener(m_window)) {
LOG((CLOG_WARN "failed to remove the clipboard format listener: %d", GetLastError())); LOG_WARN("failed to remove the clipboard format listener: %d", GetLastError());
} }
// uninstall fix timer // uninstall fix timer
@ -310,7 +310,7 @@ void MSWindowsScreen::leave()
for (KeyButton i = 0; i < IKeyState::s_numButtons; ++i) { for (KeyButton i = 0; i < IKeyState::s_numButtons; ++i) {
if (m_keyState->isKeyDown(i)) { if (m_keyState->isKeyDown(i)) {
m_primaryKeyDownList.push_back(i); m_primaryKeyDownList.push_back(i);
LOG((CLOG_DEBUG1 "key button %d is down before leaving to another screen", i)); LOG_DEBUG1("key button %d is down before leaving to another screen", i);
} }
} }
} }
@ -350,7 +350,7 @@ void MSWindowsScreen::checkClipboards()
// won't be reflected on other screens until we leave but at // won't be reflected on other screens until we leave but at
// least the clipboard itself will work. // least the clipboard itself will work.
if (m_ownClipboard && !MSWindowsClipboard::isOwnedByDeskflow()) { if (m_ownClipboard && !MSWindowsClipboard::isOwnedByDeskflow()) {
LOG((CLOG_DEBUG "clipboard changed: lost ownership and no notification received")); LOG_DEBUG("clipboard changed: lost ownership and no notification received");
m_ownClipboard = false; m_ownClipboard = false;
sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardClipboard); sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardClipboard);
sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardSelection); sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardSelection);
@ -457,7 +457,7 @@ bool MSWindowsScreen::getThisCursorPos(LPPOINT pos)
LOG_DEBUG("retrying get cursor pos"); LOG_DEBUG("retrying get cursor pos");
result = GetCursorPos(pos); result = GetCursorPos(pos);
if (!result) { if (!result) {
LOG((CLOG_DEBUG "could not get cursor pos, error: %s", windowsErrorToString(GetLastError()).c_str())); LOG_DEBUG("could not get cursor pos, error: %s", windowsErrorToString(GetLastError()).c_str());
updateDesktopThread(); updateDesktopThread();
} }
@ -475,7 +475,7 @@ bool MSWindowsScreen::setThisCursorPos(int x, int y)
LOG_DEBUG("retrying to set cursor pos"); LOG_DEBUG("retrying to set cursor pos");
result = SetCursorPos(x, y); result = SetCursorPos(x, y);
if (!result) { if (!result) {
LOG((CLOG_DEBUG "could not set cursor pos, error: %s", windowsErrorToString(GetLastError()).c_str())); LOG_DEBUG("could not set cursor pos, error: %s", windowsErrorToString(GetLastError()).c_str());
updateDesktopThread(); updateDesktopThread();
} }
@ -506,7 +506,6 @@ void MSWindowsScreen::updateDesktopThread()
void MSWindowsScreen::reconfigure(uint32_t activeSides) void MSWindowsScreen::reconfigure(uint32_t activeSides)
{ {
assert(m_isPrimary); assert(m_isPrimary);
const static auto sidesText = sidesMaskToString(activeSides); const static auto sidesText = sidesMaskToString(activeSides);
LOG_DEBUG("active sides: %s (0x%02x)", sidesText.c_str(), activeSides); LOG_DEBUG("active sides: %s (0x%02x)", sidesText.c_str(), activeSides);
m_hook.setSides(activeSides); m_hook.setSides(activeSides);
@ -537,7 +536,7 @@ void MSWindowsScreen::saveMousePosition(int32_t x, int32_t y)
m_xCursor = x; m_xCursor = x;
m_yCursor = y; m_yCursor = y;
LOG((CLOG_DEBUG5 "saved mouse position for next delta: %+d,%+d", x, y)); LOG_DEBUG5("saved mouse position for next delta: %+d,%+d", x, y);
} }
uint32_t MSWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) uint32_t MSWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask)
@ -546,7 +545,7 @@ uint32_t MSWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask)
if ((mask & ~(KeyModifierShift | KeyModifierControl | KeyModifierAlt | KeyModifierSuper)) != 0) { if ((mask & ~(KeyModifierShift | KeyModifierControl | KeyModifierAlt | KeyModifierSuper)) != 0) {
// this should be a warning, but this can confuse users, // this should be a warning, but this can confuse users,
// as this warning happens almost always. // as this warning happens almost always.
LOG((CLOG_DEBUG "could not map hotkey id=%04x mask=%04x", key, mask)); LOG_DEBUG("could not map hotkey id=%04x mask=%04x", key, mask);
return 0; return 0;
} }
@ -574,7 +573,7 @@ uint32_t MSWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask)
// can't map key // can't map key
// this should be a warning, but this can confuse users, // this should be a warning, but this can confuse users,
// as this warning happens almost always. // as this warning happens almost always.
LOG((CLOG_DEBUG "could not map hotkey id=%04x mask=%04x", key, mask)); LOG_DEBUG("could not map hotkey id=%04x mask=%04x", key, mask);
return 0; return 0;
} }
@ -604,16 +603,15 @@ uint32_t MSWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask)
} else { } else {
m_oldHotKeyIDs.push_back(id); m_oldHotKeyIDs.push_back(id);
m_hotKeys.erase(id); m_hotKeys.erase(id);
LOG( LOG_WARN(
(CLOG_WARN "failed to register hotkey %s (id=%04x mask=%04x)", deskflow::KeyMap::formatKey(key, mask).c_str(), "failed to register hotkey %s (id=%04x mask=%04x)", deskflow::KeyMap::formatKey(key, mask).c_str(), key, mask
key, mask)
); );
return 0; return 0;
} }
LOG( LOG_DEBUG(
(CLOG_DEBUG "registered hotkey %s (id=%04x mask=%04x) as id=%d", deskflow::KeyMap::formatKey(key, mask).c_str(), "registered hotkey %s (id=%04x mask=%04x) as id=%d", deskflow::KeyMap::formatKey(key, mask).c_str(), key, mask, id
key, mask, id)
); );
return id; return id;
} }
@ -634,9 +632,9 @@ void MSWindowsScreen::unregisterHotKey(uint32_t id)
err = false; err = false;
} }
if (err) { if (err) {
LOG((CLOG_WARN "failed to unregister hotkey id=%d", id)); LOG_WARN("failed to unregister hotkey id=%d", id);
} else { } else {
LOG((CLOG_DEBUG "unregistered hotkey id=%d", id)); LOG_DEBUG("unregistered hotkey id=%d", id);
} }
// discard hot key from map and record old id for reuse // discard hot key from map and record old id for reuse
@ -678,7 +676,7 @@ bool MSWindowsScreen::isAnyMouseButtonDown(uint32_t &buttonID) const
for (uint32_t i = 1; i < sizeof(m_buttons) / sizeof(m_buttons[0]); ++i) { for (uint32_t i = 1; i < sizeof(m_buttons) / sizeof(m_buttons[0]); ++i) {
if (m_buttons[i]) { if (m_buttons[i]) {
buttonID = i; buttonID = i;
LOG((CLOG_DEBUG "locked by \"%s\"", buttonToName[i])); LOG_DEBUG("locked by \"%s\"", buttonToName[i]);
return true; return true;
} }
} }
@ -807,7 +805,7 @@ HWND MSWindowsScreen::createWindow(ATOM windowClass, const char *name) const
nullptr, nullptr, s_windowInstance, nullptr nullptr, nullptr, s_windowInstance, nullptr
); );
if (window == nullptr) { if (window == nullptr) {
LOG((CLOG_ERR "failed to create window: %d", GetLastError())); LOG_ERR("failed to create window: %d", GetLastError());
throw XScreenOpenFailure(); throw XScreenOpenFailure();
} }
return window; return window;
@ -829,7 +827,7 @@ void MSWindowsScreen::sendClipboardEvent(EventTypes type, ClipboardID id)
{ {
ClipboardInfo *info = (ClipboardInfo *)malloc(sizeof(ClipboardInfo)); ClipboardInfo *info = (ClipboardInfo *)malloc(sizeof(ClipboardInfo));
if (info == nullptr) { if (info == nullptr) {
LOG((CLOG_ERR "malloc failed on %s:%s", __FILE__, __LINE__)); LOG_ERR("malloc failed on %s:%s", __FILE__, __LINE__);
return; return;
} }
info->m_id = id; info->m_id = id;
@ -873,7 +871,7 @@ bool MSWindowsScreen::onPreDispatch(HWND hwnd, UINT message, WPARAM wParam, LPAR
return onScreensaver(wParam != 0); return onScreensaver(wParam != 0);
case DESKFLOW_MSG_DEBUG: case DESKFLOW_MSG_DEBUG:
LOG((CLOG_DEBUG1 "hook: 0x%08x 0x%08x", wParam, lParam)); LOG_DEBUG1("hook: 0x%08x 0x%08x", wParam, lParam);
return true; return true;
} }
@ -886,7 +884,7 @@ bool MSWindowsScreen::onPreDispatch(HWND hwnd, UINT message, WPARAM wParam, LPAR
bool MSWindowsScreen::onPreDispatchPrimary(HWND, UINT message, WPARAM wParam, LPARAM lParam) bool MSWindowsScreen::onPreDispatchPrimary(HWND, UINT message, WPARAM wParam, LPARAM lParam)
{ {
LOG((CLOG_DEBUG5 "handling pre-dispatch primary")); LOG_DEBUG5("handling pre-dispatch primary");
// handle event // handle event
switch (message) { switch (message) {
@ -923,7 +921,7 @@ bool MSWindowsScreen::onPreDispatchPrimary(HWND, UINT message, WPARAM wParam, LP
return true; return true;
case DESKFLOW_MSG_POST_WARP: case DESKFLOW_MSG_POST_WARP:
LOG((CLOG_WARN "unmatched post warp")); LOG_WARN("unmatched post warp");
return true; return true;
case WM_HOTKEY: case WM_HOTKEY:
@ -943,10 +941,7 @@ bool MSWindowsScreen::onEvent(HWND, UINT msg, WPARAM wParam, LPARAM lParam, LRES
case WM_CLIPBOARDUPDATE: { case WM_CLIPBOARDUPDATE: {
DWORD clipboardSequenceNumber = GetClipboardSequenceNumber(); DWORD clipboardSequenceNumber = GetClipboardSequenceNumber();
LOG( LOG_DEBUG("clipboard update: sequence number %d, current %d", clipboardSequenceNumber, m_clipboardSequenceNumber);
(CLOG_DEBUG "clipboard update: sequence number %d, current %d", clipboardSequenceNumber,
m_clipboardSequenceNumber)
);
if (clipboardSequenceNumber && (clipboardSequenceNumber != m_clipboardSequenceNumber)) { if (clipboardSequenceNumber && (clipboardSequenceNumber != m_clipboardSequenceNumber)) {
m_clipboardSequenceNumber = clipboardSequenceNumber; m_clipboardSequenceNumber = clipboardSequenceNumber;
@ -1018,9 +1013,9 @@ bool MSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam)
{ {
static const KeyModifierMask s_ctrlAlt = KeyModifierControl | KeyModifierAlt; static const KeyModifierMask s_ctrlAlt = KeyModifierControl | KeyModifierAlt;
LOG( LOG_DEBUG1(
(CLOG_DEBUG1 "event: Key char=%d, vk=0x%02x, nagr=%d, lParam=0x%08x", (wParam & 0xffffu), (wParam >> 16) & 0xffu, "event: Key char=%d, vk=0x%02x, nagr=%d, lParam=0x%08x", (wParam & 0xffffu), (wParam >> 16) & 0xffu,
(wParam & 0x1000000u) ? 1 : 0, lParam) (wParam & 0x1000000u) ? 1 : 0, lParam
); );
// get event info // get event info
@ -1052,7 +1047,7 @@ bool MSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam)
if (!down && m_isPrimary && !m_isOnScreen) { if (!down && m_isPrimary && !m_isOnScreen) {
PrimaryKeyDownList::iterator find = std::find(m_primaryKeyDownList.begin(), m_primaryKeyDownList.end(), button); PrimaryKeyDownList::iterator find = std::find(m_primaryKeyDownList.begin(), m_primaryKeyDownList.end(), button);
if (find != m_primaryKeyDownList.end()) { if (find != m_primaryKeyDownList.end()) {
LOG((CLOG_DEBUG1 "release key button %d on primary", *find)); LOG_DEBUG1("release key button %d on primary", *find);
m_hook.setMode(kHOOK_WATCH_JUMP_ZONE); m_hook.setMode(kHOOK_WATCH_JUMP_ZONE);
fakeLocalKey(*find, false); fakeLocalKey(*find, false);
m_primaryKeyDownList.erase(find); m_primaryKeyDownList.erase(find);
@ -1106,13 +1101,13 @@ bool MSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam)
// client. the user can use ctrl+alt+pause to emulate it. // client. the user can use ctrl+alt+pause to emulate it.
UINT virtKey = ((wParam >> 16) & 0xffu); UINT virtKey = ((wParam >> 16) & 0xffu);
if (virtKey == VK_DELETE && (state & s_ctrlAlt) == s_ctrlAlt) { if (virtKey == VK_DELETE && (state & s_ctrlAlt) == s_ctrlAlt) {
LOG((CLOG_DEBUG "discard ctrl+alt+del")); LOG_DEBUG("discard ctrl+alt+del");
return true; return true;
} }
// check for ctrl+alt+del emulation // check for ctrl+alt+del emulation
if ((virtKey == VK_PAUSE || virtKey == VK_CANCEL) && (state & s_ctrlAlt) == s_ctrlAlt) { if ((virtKey == VK_PAUSE || virtKey == VK_CANCEL) && (state & s_ctrlAlt) == s_ctrlAlt) {
LOG((CLOG_DEBUG "emulate ctrl+alt+del")); LOG_DEBUG("emulate ctrl+alt+del");
// switch wParam and lParam to be as if VK_DELETE was // switch wParam and lParam to be as if VK_DELETE was
// pressed or released. when mapping the key we require that // pressed or released. when mapping the key we require that
// we not use AltGr (the 0x10000 flag in wParam) and we not // we not use AltGr (the 0x10000 flag in wParam) and we not
@ -1134,7 +1129,7 @@ bool MSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam)
(int32_t)(lParam & 0xffff), button (int32_t)(lParam & 0xffff), button
); );
} else { } else {
LOG((CLOG_DEBUG1 "cannot map key")); LOG_DEBUG1("cannot map key");
} }
} }
@ -1199,12 +1194,12 @@ bool MSWindowsScreen::onMouseButton(WPARAM wParam, LPARAM lParam)
if (!ignore()) { if (!ignore()) {
KeyModifierMask mask = m_keyState->getActiveModifiers(); KeyModifierMask mask = m_keyState->getActiveModifiers();
if (pressed) { if (pressed) {
LOG((CLOG_DEBUG1 "event: button press button=%d", button)); LOG_DEBUG1("event: button press button=%d", button);
if (button != kButtonNone) { if (button != kButtonNone) {
sendEvent(EventTypes::PrimaryScreenButtonDown, ButtonInfo::alloc(button, mask)); sendEvent(EventTypes::PrimaryScreenButtonDown, ButtonInfo::alloc(button, mask));
} }
} else { } else {
LOG((CLOG_DEBUG1 "event: button release button=%d", button)); LOG_DEBUG1("event: button release button=%d", button);
if (button != kButtonNone) { if (button != kButtonNone) {
sendEvent(EventTypes::PrimaryScreenButtonUp, ButtonInfo::alloc(button, mask)); sendEvent(EventTypes::PrimaryScreenButtonUp, ButtonInfo::alloc(button, mask));
} }
@ -1231,7 +1226,7 @@ bool MSWindowsScreen::onMouseMove(int32_t mx, int32_t my)
int32_t x = mx - m_xCursor; int32_t x = mx - m_xCursor;
int32_t y = my - m_yCursor; int32_t y = my - m_yCursor;
LOG((CLOG_DEBUG3 "mouse move - motion delta: %+d=(%+d - %+d),%+d=(%+d - %+d)", x, mx, m_xCursor, y, my, m_yCursor)); LOG_DEBUG3("mouse move - motion delta: %+d=(%+d - %+d),%+d=(%+d - %+d)", x, mx, m_xCursor, y, my, m_yCursor);
// ignore if the mouse didn't move or if message posted prior // ignore if the mouse didn't move or if message posted prior
// to last mark change. // to last mark change.
@ -1250,7 +1245,7 @@ bool MSWindowsScreen::onMouseMove(int32_t mx, int32_t my)
// center on the server screen. if we don't do this, then the mouse // center on the server screen. if we don't do this, then the mouse
// will always try to return to the original entry point on the // will always try to return to the original entry point on the
// secondary screen. // secondary screen.
LOG((CLOG_DEBUG5 "centering cursor on motion: %+d,%+d", m_xCenter, m_yCenter)); LOG_DEBUG5("centering cursor on motion: %+d,%+d", m_xCenter, m_yCenter);
warpCursorNoFlush(m_xCenter, m_yCenter); warpCursorNoFlush(m_xCenter, m_yCenter);
// examine the motion. if it's about the distance // examine the motion. if it's about the distance
@ -1262,7 +1257,7 @@ bool MSWindowsScreen::onMouseMove(int32_t mx, int32_t my)
if (-x + bogusZoneSize > m_xCenter - m_x || x + bogusZoneSize > m_x + m_w - m_xCenter || if (-x + bogusZoneSize > m_xCenter - m_x || x + bogusZoneSize > m_x + m_w - m_xCenter ||
-y + bogusZoneSize > m_yCenter - m_y || y + bogusZoneSize > m_y + m_h - m_yCenter) { -y + bogusZoneSize > m_yCenter - m_y || y + bogusZoneSize > m_y + m_h - m_yCenter) {
LOG((CLOG_DEBUG "dropped bogus delta motion: %+d,%+d", x, y)); LOG_DEBUG("dropped bogus delta motion: %+d,%+d", x, y);
} else { } else {
// send motion // send motion
sendEvent(EventTypes::PrimaryScreenMotionOnSecondary, MotionInfo::alloc(x, y)); sendEvent(EventTypes::PrimaryScreenMotionOnSecondary, MotionInfo::alloc(x, y));
@ -1276,7 +1271,7 @@ bool MSWindowsScreen::onMouseWheel(int32_t xDelta, int32_t yDelta)
{ {
// 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", xDelta, yDelta)); LOG_DEBUG1("event: button wheel delta=%+d,%+d", xDelta, yDelta);
sendEvent(EventTypes::PrimaryScreenWheel, WheelInfo::alloc(xDelta, yDelta)); sendEvent(EventTypes::PrimaryScreenWheel, WheelInfo::alloc(xDelta, yDelta));
} }
return true; return true;
@ -1337,7 +1332,7 @@ bool MSWindowsScreen::onDisplayChange()
// send new screen info // send new screen info
sendEvent(EventTypes::ScreenShapeChanged); sendEvent(EventTypes::ScreenShapeChanged);
LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : "")); LOG_DEBUG("screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : "");
} }
return true; return true;
@ -1349,13 +1344,13 @@ void MSWindowsScreen::onClipboardChange()
// we're the owner). // we're the owner).
if (!MSWindowsClipboard::isOwnedByDeskflow()) { if (!MSWindowsClipboard::isOwnedByDeskflow()) {
if (m_ownClipboard) { if (m_ownClipboard) {
LOG((CLOG_DEBUG "clipboard changed: lost ownership")); LOG_DEBUG("clipboard changed: lost ownership");
m_ownClipboard = false; m_ownClipboard = false;
sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardClipboard); sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardClipboard);
sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardSelection); sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardSelection);
} }
} else if (!m_ownClipboard) { } else if (!m_ownClipboard) {
LOG((CLOG_DEBUG "clipboard changed: %s owned", kAppId)); LOG_DEBUG("clipboard changed: %s owned", kAppId);
m_ownClipboard = true; m_ownClipboard = true;
} }
} }
@ -1378,8 +1373,8 @@ void MSWindowsScreen::warpCursorNoFlush(int32_t x, int32_t y)
// since this feature is mainly for client, so only check on client. // since this feature is mainly for client, so only check on client.
if (!isPrimary()) { if (!isPrimary()) {
if ((cursorPos.x != x) && (cursorPos.y != y)) { if ((cursorPos.x != x) && (cursorPos.y != y)) {
LOG((CLOG_DEBUG "function 'SetCursorPos' failed; trying 'fakeMouseMove'")); LOG_DEBUG("function 'SetCursorPos' failed; trying 'fakeMouseMove'");
LOG((CLOG_DEBUG "cursor pos %d, %d expected pos %d, %d", cursorPos.x, cursorPos.y, x, y)); LOG_DEBUG("cursor pos %d, %d expected pos %d, %d", cursorPos.x, cursorPos.y, x, y);
// when at Vista/7 login screen, SetCursorPos does not work (which could // when at Vista/7 login screen, SetCursorPos does not work (which could
// be an MS security feature). instead we can use fakeMouseMove, which // be an MS security feature). instead we can use fakeMouseMove, which
// calls mouse_event. IMPORTANT: as of implementing this function, it has // calls mouse_event. IMPORTANT: as of implementing this function, it has

View file

@ -71,7 +71,7 @@ bool MSWindowsScreenSaver::checkStarted(UINT msg, WPARAM wParam, LPARAM lParam)
// we first check that the screen saver is indeed active // we first check that the screen saver is indeed active
// before watching for it to stop. // before watching for it to stop.
if (!isActive()) { if (!isActive()) {
LOG((CLOG_DEBUG2 "can't open screen saver desktop")); LOG_DEBUG2("can't open screen saver desktop");
return false; return false;
} }
@ -171,7 +171,7 @@ void MSWindowsScreenSaver::watchDesktop()
unwatchProcess(); unwatchProcess();
// watch desktop in another thread // watch desktop in another thread
LOG((CLOG_DEBUG "watching screen saver desktop")); LOG_DEBUG("watching screen saver desktop");
m_active = true; m_active = true;
m_watch = new Thread(new TMethodJob<MSWindowsScreenSaver>(this, &MSWindowsScreenSaver::watchDesktopThread)); m_watch = new Thread(new TMethodJob<MSWindowsScreenSaver>(this, &MSWindowsScreenSaver::watchDesktopThread));
} }
@ -183,7 +183,7 @@ void MSWindowsScreenSaver::watchProcess(HANDLE process)
// watch new process in another thread // watch new process in another thread
if (process != nullptr) { if (process != nullptr) {
LOG((CLOG_DEBUG "watching screen saver process")); LOG_DEBUG("watching screen saver process");
m_process = process; m_process = process;
m_active = true; m_active = true;
m_watch = new Thread(new TMethodJob<MSWindowsScreenSaver>(this, &MSWindowsScreenSaver::watchProcessThread)); m_watch = new Thread(new TMethodJob<MSWindowsScreenSaver>(this, &MSWindowsScreenSaver::watchProcessThread));
@ -193,7 +193,7 @@ void MSWindowsScreenSaver::watchProcess(HANDLE process)
void MSWindowsScreenSaver::unwatchProcess() void MSWindowsScreenSaver::unwatchProcess()
{ {
if (m_watch != nullptr) { if (m_watch != nullptr) {
LOG((CLOG_DEBUG "stopped watching screen saver process/desktop")); LOG_DEBUG("stopped watching screen saver process/desktop");
m_watch->cancel(); m_watch->cancel();
m_watch->wait(); m_watch->wait();
delete m_watch; delete m_watch;
@ -234,7 +234,7 @@ void MSWindowsScreenSaver::watchProcessThread(void *)
Thread::testCancel(); Thread::testCancel();
if (WaitForSingleObject(m_process, 50) == WAIT_OBJECT_0) { if (WaitForSingleObject(m_process, 50) == WAIT_OBJECT_0) {
// process terminated // process terminated
LOG((CLOG_DEBUG "screen saver died")); LOG_DEBUG("screen saver died");
// send screen saver deactivation message // send screen saver deactivation message
m_active = false; m_active = false;

View file

@ -21,7 +21,7 @@ bool MSWindowsSession::isProcessInSession(const char *name, PHANDLE process = nu
// first we need to take a snapshot of the running processes // first we need to take a snapshot of the running processes
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (snapshot == INVALID_HANDLE_VALUE) { if (snapshot == INVALID_HANDLE_VALUE) {
LOG((CLOG_ERR "could not get process snapshot")); LOG_ERR("could not get process snapshot");
throw std::runtime_error(windowsErrorToString(GetLastError())); throw std::runtime_error(windowsErrorToString(GetLastError()));
} }
@ -32,7 +32,7 @@ bool MSWindowsSession::isProcessInSession(const char *name, PHANDLE process = nu
// unlikely we can go any further // unlikely we can go any further
BOOL gotEntry = Process32First(snapshot, &entry); BOOL gotEntry = Process32First(snapshot, &entry);
if (!gotEntry) { if (!gotEntry) {
LOG((CLOG_ERR "could not get first process entry")); LOG_ERR("could not get first process entry");
throw std::runtime_error(windowsErrorToString(GetLastError())); throw std::runtime_error(windowsErrorToString(GetLastError()));
} }
@ -52,9 +52,8 @@ bool MSWindowsSession::isProcessInSession(const char *name, PHANDLE process = nu
if (!pidToSidRet) { if (!pidToSidRet) {
// if we can not acquire session associated with a specified process, // if we can not acquire session associated with a specified process,
// simply ignore it // simply ignore it
LOG( LOG_DEBUG2(
(CLOG_DEBUG2 "could not get session id for process: %i %s, code=%i", entry.th32ProcessID, entry.szExeFile, "could not get session id for process: %i %s, code=%i", entry.th32ProcessID, entry.szExeFile, GetLastError()
GetLastError())
); );
gotEntry = nextProcessEntry(snapshot, &entry); gotEntry = nextProcessEntry(snapshot, &entry);
continue; continue;
@ -82,19 +81,19 @@ bool MSWindowsSession::isProcessInSession(const char *name, PHANDLE process = nu
nameListJoin.append(", "); nameListJoin.append(", ");
} }
LOG((CLOG_DEBUG2 "processes in session %d: %s", m_activeSessionId, nameListJoin.c_str())); LOG_DEBUG2("processes in session %d: %s", m_activeSessionId, nameListJoin.c_str());
CloseHandle(snapshot); CloseHandle(snapshot);
if (pid) { if (pid) {
if (process != nullptr) { if (process != nullptr) {
// now get the process, which we'll use to get the process token. // now get the process, which we'll use to get the process token.
LOG((CLOG_DEBUG "found %s in session %i", name, m_activeSessionId)); LOG_DEBUG("found %s in session %i", name, m_activeSessionId);
*process = OpenProcess(MAXIMUM_ALLOWED, FALSE, pid); *process = OpenProcess(MAXIMUM_ALLOWED, FALSE, pid);
} }
return true; return true;
} else { } else {
LOG((CLOG_DEBUG "did not find %s in session %i", name, m_activeSessionId)); LOG_DEBUG("did not find %s in session %i", name, m_activeSessionId);
return false; return false;
} }
} }
@ -104,7 +103,7 @@ MSWindowsSession::getUserToken(LPSECURITY_ATTRIBUTES security)
{ {
HANDLE sourceToken; HANDLE sourceToken;
if (!WTSQueryUserToken(m_activeSessionId, &sourceToken)) { if (!WTSQueryUserToken(m_activeSessionId, &sourceToken)) {
LOG((CLOG_ERR "could not get token from session %d", m_activeSessionId)); LOG_ERR("could not get token from session %d", m_activeSessionId);
throw std::runtime_error(windowsErrorToString(GetLastError())); throw std::runtime_error(windowsErrorToString(GetLastError()));
} }
@ -113,11 +112,11 @@ MSWindowsSession::getUserToken(LPSECURITY_ATTRIBUTES security)
sourceToken, TOKEN_ASSIGN_PRIMARY | TOKEN_ALL_ACCESS, security, SecurityImpersonation, TokenPrimary, &newToken sourceToken, TOKEN_ASSIGN_PRIMARY | TOKEN_ALL_ACCESS, security, SecurityImpersonation, TokenPrimary, &newToken
)) { )) {
LOG((CLOG_ERR "could not duplicate token")); LOG_ERR("could not duplicate token");
throw std::runtime_error(windowsErrorToString(GetLastError())); throw std::runtime_error(windowsErrorToString(GetLastError()));
} }
LOG((CLOG_DEBUG "duplicated, new token: %i", newToken)); LOG_DEBUG("duplicated, new token: %i", newToken);
return newToken; return newToken;
} }
@ -147,7 +146,7 @@ BOOL MSWindowsSession::nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry)
// only throw if it's not the end of the snapshot, if not the 'no more // only throw if it's not the end of the snapshot, if not the 'no more
// files' error then it's probably something serious. // files' error then it's probably something serious.
if (err != ERROR_NO_MORE_FILES) { if (err != ERROR_NO_MORE_FILES) {
LOG((CLOG_ERR "could not get next process entry")); LOG_ERR("could not get next process entry");
throw std::runtime_error(windowsErrorToString(GetLastError())); throw std::runtime_error(windowsErrorToString(GetLastError()));
} }
} }

View file

@ -30,15 +30,15 @@ OSXClipboard::OSXClipboard() : m_time(0), m_pboard(nullptr)
OSStatus createErr = PasteboardCreate(kPasteboardClipboard, &m_pboard); OSStatus createErr = PasteboardCreate(kPasteboardClipboard, &m_pboard);
if (createErr != noErr) { if (createErr != noErr) {
LOG((CLOG_WARN "failed to create clipboard reference: error %i", createErr)); LOG_WARN("failed to create clipboard reference: error %i", createErr);
LOG((CLOG_ERR "unable to connect to pasteboard, clipboard sharing disabled", createErr)); LOG_ERR("unable to connect to pasteboard, clipboard sharing disabled", createErr);
m_pboard = nullptr; m_pboard = nullptr;
return; return;
} }
OSStatus syncErr = PasteboardSynchronize(m_pboard); OSStatus syncErr = PasteboardSynchronize(m_pboard);
if (syncErr != noErr) { if (syncErr != noErr) {
LOG((CLOG_WARN "failed to syncronize clipboard: error %i", syncErr)); LOG_WARN("failed to syncronize clipboard: error %i", syncErr);
} }
} }
@ -49,13 +49,13 @@ OSXClipboard::~OSXClipboard()
bool OSXClipboard::empty() bool OSXClipboard::empty()
{ {
LOG((CLOG_DEBUG "emptying clipboard")); LOG_DEBUG("emptying clipboard");
if (m_pboard == nullptr) if (m_pboard == nullptr)
return false; return false;
OSStatus err = PasteboardClear(m_pboard); OSStatus err = PasteboardClear(m_pboard);
if (err != noErr) { if (err != noErr) {
LOG((CLOG_WARN "failed to clear clipboard: error %i", err)); LOG_WARN("failed to clear clipboard: error %i", err);
return false; return false;
} }
@ -68,7 +68,7 @@ bool OSXClipboard::synchronize()
return false; return false;
PasteboardSyncFlags flags = PasteboardSynchronize(m_pboard); PasteboardSyncFlags flags = PasteboardSynchronize(m_pboard);
LOG((CLOG_DEBUG2 "flags: %x", flags)); LOG_DEBUG2("flags: %x", flags);
if (flags & kPasteboardModified) { if (flags & kPasteboardModified) {
return true; return true;
@ -81,13 +81,13 @@ void OSXClipboard::add(Format format, const std::string &data)
if (m_pboard == nullptr) if (m_pboard == nullptr)
return; return;
LOG((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format)); LOG_DEBUG("add %d bytes to clipboard format: %d", data.size(), format);
if (format == IClipboard::Format::Text) { if (format == IClipboard::Format::Text) {
LOG((CLOG_DEBUG "format of data to be added to clipboard was kText")); LOG_DEBUG("format of data to be added to clipboard was kText");
} else if (format == IClipboard::Format::Bitmap) { } else if (format == IClipboard::Format::Bitmap) {
LOG((CLOG_DEBUG "format of data to be added to clipboard was kBitmap")); LOG_DEBUG("format of data to be added to clipboard was kBitmap");
} else if (format == IClipboard::Format::HTML) { } else if (format == IClipboard::Format::HTML) {
LOG((CLOG_DEBUG "format of data to be added to clipboard was kHTML")); LOG_DEBUG("format of data to be added to clipboard was kHTML");
} }
for (ConverterList::const_iterator index = m_converters.begin(); index != m_converters.end(); ++index) { for (ConverterList::const_iterator index = m_converters.begin(); index != m_converters.end(); ++index) {
@ -105,7 +105,7 @@ void OSXClipboard::add(Format format, const std::string &data)
PasteboardPutItemFlavor(m_pboard, itemID, flavorType, dataRef, kPasteboardFlavorNoFlags); PasteboardPutItemFlavor(m_pboard, itemID, flavorType, dataRef, kPasteboardFlavorNoFlags);
CFRelease(dataRef); CFRelease(dataRef);
LOG((CLOG_DEBUG "added %d bytes to clipboard format: %d", data.size(), format)); LOG_DEBUG("added %d bytes to clipboard format: %d", data.size(), format);
} }
} }
} }
@ -116,14 +116,14 @@ bool OSXClipboard::open(Time time) const
if (m_pboard == nullptr) if (m_pboard == nullptr)
return false; return false;
LOG((CLOG_DEBUG "opening clipboard")); LOG_DEBUG("opening clipboard");
m_time = time; m_time = time;
return true; return true;
} }
void OSXClipboard::close() const void OSXClipboard::close() const
{ {
LOG((CLOG_DEBUG "closing clipboard")); LOG_DEBUG("closing clipboard");
/* not needed */ /* not needed */
} }
@ -184,7 +184,7 @@ std::string OSXClipboard::get(Format format) const
// if no converter then we don't recognize any formats // if no converter then we don't recognize any formats
if (converter == nullptr) { if (converter == nullptr) {
LOG((CLOG_DEBUG "unable to find converter for data")); LOG_DEBUG("unable to find converter for data");
return result; return result;
} }
@ -199,9 +199,9 @@ std::string OSXClipboard::get(Format format) const
result = std::string((char *)CFDataGetBytePtr(buffer), CFDataGetLength(buffer)); result = std::string((char *)CFDataGetBytePtr(buffer), CFDataGetLength(buffer));
} catch (OSStatus err) { } catch (OSStatus err) {
LOG((CLOG_DEBUG "exception thrown in OSXClipboard::get MacError (%d)", err)); LOG_DEBUG("exception thrown in OSXClipboard::get MacError (%d)", err);
} catch (...) { } catch (...) {
LOG((CLOG_DEBUG "unknown exception in OSXClipboard::get")); LOG_DEBUG("unknown exception in OSXClipboard::get");
RETHROW_XTHREAD RETHROW_XTHREAD
} }

View file

@ -61,7 +61,7 @@ CFStringRef OSXClipboardBMPConverter::getOSXFormat() const
std::string OSXClipboardBMPConverter::fromIClipboard(const std::string &bmp) const std::string OSXClipboardBMPConverter::fromIClipboard(const std::string &bmp) const
{ {
LOG((CLOG_DEBUG1 "getting data from clipboard")); LOG_DEBUG1("getting data from clipboard");
// create BMP image // create BMP image
uint8_t header[14]; uint8_t header[14];
uint8_t *dst = header; uint8_t *dst = header;

View file

@ -154,12 +154,12 @@ io_connect_t getEventDriver()
if (!IOServiceGetMatchingServices(masterPort, dict, &iter)) { if (!IOServiceGetMatchingServices(masterPort, dict, &iter)) {
sEventDrvrRef = getService(iter); sEventDrvrRef = getService(iter);
} else { } else {
LOG((CLOG_WARN, "io service not found")); LOG_WARN("io service not found");
} }
IOObjectRelease(iter); IOObjectRelease(iter);
} else { } else {
LOG((CLOG_WARN, "couldn't get io master port")); LOG_WARN("couldn't get io master port");
} }
} }
@ -231,7 +231,7 @@ KeyModifierMask OSXKeyState::mapModifiersFromOSX(uint32_t mask) const
outMask |= KeyModifierNumLock; outMask |= KeyModifierNumLock;
} }
LOG((CLOG_DEBUG1 "mask=%04x outMask=%04x", mask, outMask)); LOG_DEBUG1("mask=%04x outMask=%04x", mask, outMask);
return outMask; return outMask;
} }
@ -333,7 +333,7 @@ KeyButton OSXKeyState::mapKeyFromEvent(KeyIDs &ids, KeyModifierMask *maskOut, CG
// translate key // translate key
UniCharCount count; UniCharCount count;
UniChar chars[2]; UniChar chars[2];
LOG((CLOG_DEBUG2 "modifiers: %08x", modifiers & 0xffu)); LOG_DEBUG2("modifiers: %08x", modifiers & 0xffu);
OSStatus status = UCKeyTranslate( OSStatus status = UCKeyTranslate(
layout, vkCode & 0xffu, action, (modifiers >> 8) & 0xffu, LMGetKbdType(), 0, &m_deadKeyState, layout, vkCode & 0xffu, action, (modifiers >> 8) & 0xffu, LMGetKbdType(), 0, &m_deadKeyState,
sizeof(chars) / sizeof(chars[0]), &count, chars sizeof(chars) / sizeof(chars[0]), &count, chars
@ -421,7 +421,7 @@ KeyModifierMask OSXKeyState::pollActiveModifiers() const
outMask |= KeyModifierNumLock; outMask |= KeyModifierNumLock;
} }
LOG((CLOG_DEBUG1 "mask=%04x outMask=%04x", mask, outMask)); LOG_DEBUG1("mask=%04x outMask=%04x", mask, outMask);
return outMask; return outMask;
} }
@ -435,7 +435,7 @@ int32_t OSXKeyState::pollActiveGroup() const
return i->second; return i->second;
} }
LOG((CLOG_WARN "can't get the active group, use the first group instead")); LOG_WARN("can't get the active group, use the first group instead");
return 0; return 0;
} }
@ -488,13 +488,13 @@ void OSXKeyState::getKeyMap(deskflow::KeyMap &keyMap)
if (layoutValid) { if (layoutValid) {
OSXUchrKeyResource uchr(resource, keyboardType); OSXUchrKeyResource uchr(resource, keyboardType);
if (uchr.isValid()) { if (uchr.isValid()) {
LOG((CLOG_DEBUG1 "using uchr resource for group %d", g)); LOG_DEBUG1("using uchr resource for group %d", g);
getKeyMap(keyMap, g, uchr); getKeyMap(keyMap, g, uchr);
continue; continue;
} }
} }
LOG((CLOG_DEBUG1 "no keyboard resource for group %d", g)); LOG_DEBUG1("no keyboard resource for group %d", g);
} }
} }
@ -553,7 +553,7 @@ void OSXKeyState::setKeyboardModifiers(CGKeyCode virtualKey, bool keyDown)
m_capsPressed = keyDown; m_capsPressed = keyDown;
break; break;
default: default:
LOG((CLOG_DEBUG1 "the key is not a modifier")); LOG_DEBUG1("the key is not a modifier");
break; break;
} }
} }
@ -587,7 +587,7 @@ void OSXKeyState::postKeyboardKey(CGKeyCode virtualKey, bool keyDown)
CGEventPost(kCGHIDEventTap, event); CGEventPost(kCGHIDEventTap, event);
CFRelease(event); CFRelease(event);
} else { } else {
LOG((CLOG_CRIT "unable to create keyboard event for keystroke")); LOG_CRIT("unable to create keyboard event for keystroke");
} }
} }
@ -600,14 +600,14 @@ void OSXKeyState::fakeKey(const Keystroke &keystroke)
KeyButton button = keystroke.m_data.m_button.m_button; KeyButton button = keystroke.m_data.m_button.m_button;
CGKeyCode virtualKey = mapKeyButtonToVirtualKey(button); CGKeyCode virtualKey = mapKeyButtonToVirtualKey(button);
LOG( LOG_DEBUG1(
(CLOG_DEBUG1 " button=0x%04x virtualKey=0x%04x keyDown=%s client=0x%04x", button, virtualKey, " button=0x%04x virtualKey=0x%04x keyDown=%s client=0x%04x", button, virtualKey, keyDown ? "down" : "up",
keyDown ? "down" : "up", client) client
); );
setKeyboardModifiers(virtualKey, keyDown); setKeyboardModifiers(virtualKey, keyDown);
if (postHIDVirtualKey(virtualKey, keyDown) != KERN_SUCCESS) { if (postHIDVirtualKey(virtualKey, keyDown) != KERN_SUCCESS) {
LOG((CLOG_WARN, "fail to post hid event")); LOG_WARN("fail to post hid event");
postKeyboardKey(virtualKey, keyDown); postKeyboardKey(virtualKey, keyDown);
} }
@ -618,15 +618,15 @@ void OSXKeyState::fakeKey(const Keystroke &keystroke)
int32_t group = keystroke.m_data.m_group.m_group; int32_t group = keystroke.m_data.m_group.m_group;
if (!keystroke.m_data.m_group.m_restore) { if (!keystroke.m_data.m_group.m_restore) {
if (keystroke.m_data.m_group.m_absolute) { if (keystroke.m_data.m_group.m_absolute) {
LOG((CLOG_DEBUG1 " group %d", group)); LOG_DEBUG1(" group %d", group);
setGroup(group); setGroup(group);
} else { } else {
LOG((CLOG_DEBUG1 " group %+d", group)); LOG_DEBUG1(" group %+d", group);
setGroup(getEffectiveGroup(pollActiveGroup(), group)); setGroup(getEffectiveGroup(pollActiveGroup(), group));
} }
if (pollActiveGroup() != group) { if (pollActiveGroup() != group) {
LOG((CLOG_WARN "failed to set new keyboard layout")); LOG_WARN("failed to set new keyboard layout");
} }
} }
break; break;
@ -856,7 +856,7 @@ bool OSXKeyState::getGroups(AutoCFArray &groups) const
if (CFArrayGetCount(kbds.get()) > 0) { if (CFArrayGetCount(kbds.get()) > 0) {
groups = std::move(kbds); groups = std::move(kbds);
} else { } else {
LOG((CLOG_DEBUG1 "can't get keyboard layouts")); LOG_DEBUG1("can't get keyboard layouts");
return false; return false;
} }
@ -867,21 +867,21 @@ void OSXKeyState::setGroup(int32_t group)
{ {
TISInputSourceRef keyboardLayout = (TISInputSourceRef)CFArrayGetValueAtIndex(m_groups.get(), group); TISInputSourceRef keyboardLayout = (TISInputSourceRef)CFArrayGetValueAtIndex(m_groups.get(), group);
if (!keyboardLayout) { if (!keyboardLayout) {
LOG((CLOG_WARN "nedeed keyboard layout is null")); LOG_WARN("nedeed keyboard layout is null");
return; return;
} }
auto canBeSetted = (CFBooleanRef auto canBeSetted = (CFBooleanRef
)TISGetInputSourceProperty(TISCopyCurrentKeyboardInputSource(), kTISPropertyInputSourceIsEnableCapable); )TISGetInputSourceProperty(TISCopyCurrentKeyboardInputSource(), kTISPropertyInputSourceIsEnableCapable);
if (!canBeSetted) { if (!canBeSetted) {
LOG((CLOG_WARN "nedeed keyboard layout is disabled for programmatically selection")); LOG_WARN("nedeed keyboard layout is disabled for programmatically selection");
return; return;
} }
if (TISSelectInputSource(keyboardLayout) != noErr) { if (TISSelectInputSource(keyboardLayout) != noErr) {
LOG((CLOG_WARN "failed to set nedeed keyboard layout")); LOG_WARN("failed to set nedeed keyboard layout");
} }
LOG((CLOG_DEBUG1 "keyboard layout change to %d", group)); LOG_DEBUG1("keyboard layout change to %d", group);
// A minimal delay is needed after a group change because the // A minimal delay is needed after a group change because the
// keyboard key event often happens immediately after. // keyboard key event often happens immediately after.

View file

@ -22,7 +22,7 @@ void OSXPowerManager::disableSleep()
); );
if (result != kIOReturnSuccess) { if (result != kIOReturnSuccess) {
m_sleepPreventionAssertionID = 0; m_sleepPreventionAssertionID = 0;
LOG((CLOG_ERR "failed to disable system idle sleep")); LOG_ERR("failed to disable system idle sleep");
} }
} }
} }

View file

@ -150,7 +150,7 @@ OSXScreen::OSXScreen(
*m_pmThreadReady = false; *m_pmThreadReady = false;
m_carbonLoopMutex = new Mutex(); m_carbonLoopMutex = new Mutex();
m_carbonLoopReady = new CondVar<bool>(m_carbonLoopMutex, false); m_carbonLoopReady = new CondVar<bool>(m_carbonLoopMutex, false);
LOG((CLOG_DEBUG "starting watchSystemPowerThread")); LOG_DEBUG("starting watchSystemPowerThread");
m_pmWatchThread = new Thread(new TMethodJob<OSXScreen>(this, &OSXScreen::watchSystemPowerThread)); m_pmWatchThread = new Thread(new TMethodJob<OSXScreen>(this, &OSXScreen::watchSystemPowerThread));
} catch (...) { } catch (...) {
m_events->removeHandler(EventTypes::OsxScreenConfirmSleep, getEventTarget()); m_events->removeHandler(EventTypes::OsxScreenConfirmSleep, getEventTarget());
@ -191,7 +191,7 @@ OSXScreen::~OSXScreen()
} }
// now exit the thread's runloop and wait for it to exit // now exit the thread's runloop and wait for it to exit
LOG((CLOG_DEBUG "stopping watchSystemPowerThread")); LOG_DEBUG("stopping watchSystemPowerThread");
CFRunLoopStop(m_pmRunloop); CFRunLoopStop(m_pmRunloop);
m_pmWatchThread->wait(); m_pmWatchThread->wait();
delete m_pmWatchThread; delete m_pmWatchThread;
@ -306,7 +306,7 @@ uint32_t OSXScreen::registerHotKey(KeyID key, KeyModifierMask mask)
// get mac virtual key and modifier mask matching deskflow key and mask // get mac virtual key and modifier mask matching deskflow key and mask
uint32_t macKey, macMask; uint32_t macKey, macMask;
if (!m_keyState->mapDeskflowHotKeyToMac(key, mask, macKey, macMask)) { if (!m_keyState->mapDeskflowHotKeyToMac(key, mask, macKey, macMask)) {
LOG((CLOG_DEBUG "could not map hotkey id=%04x mask=%04x", key, mask)); LOG_DEBUG("could not map hotkey id=%04x mask=%04x", key, mask);
return 0; return 0;
} }
@ -340,18 +340,16 @@ uint32_t OSXScreen::registerHotKey(KeyID key, KeyModifierMask mask)
if (!okay) { if (!okay) {
m_oldHotKeyIDs.push_back(id); m_oldHotKeyIDs.push_back(id);
m_hotKeyToIDMap.erase(HotKeyItem(macKey, macMask)); m_hotKeyToIDMap.erase(HotKeyItem(macKey, macMask));
LOG( LOG_WARN(
(CLOG_WARN "failed to register hotkey %s (id=%04x mask=%04x)", deskflow::KeyMap::formatKey(key, mask).c_str(), "failed to register hotkey %s (id=%04x mask=%04x)", deskflow::KeyMap::formatKey(key, mask).c_str(), key, mask
key, mask)
); );
return 0; return 0;
} }
m_hotKeys.insert(std::make_pair(id, HotKeyItem(ref, macKey, macMask))); m_hotKeys.insert(std::make_pair(id, HotKeyItem(ref, macKey, macMask)));
LOG( LOG_DEBUG(
(CLOG_DEBUG "registered hotkey %s (id=%04x mask=%04x) as id=%d", deskflow::KeyMap::formatKey(key, mask).c_str(), "registered hotkey %s (id=%04x mask=%04x) as id=%d", deskflow::KeyMap::formatKey(key, mask).c_str(), key, mask, id
key, mask, id)
); );
return id; return id;
} }
@ -380,9 +378,9 @@ void OSXScreen::unregisterHotKey(uint32_t id)
} }
} }
if (!okay) { if (!okay) {
LOG((CLOG_WARN "failed to unregister hotkey id=%d", id)); LOG_WARN("failed to unregister hotkey id=%d", id);
} else { } else {
LOG((CLOG_DEBUG "unregistered hotkey id=%d", id)); LOG_DEBUG("unregistered hotkey id=%d", id);
} }
// discard hot key from map and record old id for reuse // discard hot key from map and record old id for reuse
@ -529,7 +527,7 @@ void OSXScreen::fakeMouseButton(ButtonID id, bool press)
EMouseButtonState state = press ? kMouseButtonDown : kMouseButtonUp; EMouseButtonState state = press ? kMouseButtonDown : kMouseButtonUp;
LOG((CLOG_DEBUG1 "faking mouse button id: %d press: %s", index, press ? "pressed" : "released")); LOG_DEBUG1("faking mouse button id: %d press: %s", index, press ? "pressed" : "released");
MouseButtonEventMapType thisButtonMap = MouseButtonEventMap[index]; MouseButtonEventMapType thisButtonMap = MouseButtonEventMap[index];
CGEventType type = thisButtonMap[state]; CGEventType type = thisButtonMap[state];
@ -606,7 +604,7 @@ void OSXScreen::fakeMouseWheel(int32_t xDelta, int32_t yDelta) const
void OSXScreen::showCursor() void OSXScreen::showCursor()
{ {
LOG((CLOG_DEBUG "showing cursor")); LOG_DEBUG("showing cursor");
CFStringRef propertyString = CFStringCreateWithCString(nullptr, "SetsCursorInBackground", kCFStringEncodingMacRoman); CFStringRef propertyString = CFStringCreateWithCString(nullptr, "SetsCursorInBackground", kCFStringEncodingMacRoman);
@ -616,7 +614,7 @@ void OSXScreen::showCursor()
CGError error = CGDisplayShowCursor(m_displayID); CGError error = CGDisplayShowCursor(m_displayID);
if (error != kCGErrorSuccess) { if (error != kCGErrorSuccess) {
LOG((CLOG_ERR "failed to show cursor, error=%d", error)); LOG_ERR("failed to show cursor, error=%d", error);
} }
// appears to fix "mouse randomly not showing" bug // appears to fix "mouse randomly not showing" bug
@ -629,7 +627,7 @@ void OSXScreen::showCursor()
void OSXScreen::hideCursor() void OSXScreen::hideCursor()
{ {
LOG((CLOG_DEBUG "hiding cursor")); LOG_DEBUG("hiding cursor");
CFStringRef propertyString = CFStringCreateWithCString(nullptr, "SetsCursorInBackground", kCFStringEncodingMacRoman); CFStringRef propertyString = CFStringCreateWithCString(nullptr, "SetsCursorInBackground", kCFStringEncodingMacRoman);
@ -639,7 +637,7 @@ void OSXScreen::hideCursor()
CGError error = CGDisplayHideCursor(m_displayID); CGError error = CGDisplayHideCursor(m_displayID);
if (error != kCGErrorSuccess) { if (error != kCGErrorSuccess) {
LOG((CLOG_ERR "failed to hide cursor, error=%d", error)); LOG_ERR("failed to hide cursor, error=%d", error);
} }
// appears to fix "mouse randomly not hiding" bug // appears to fix "mouse randomly not hiding" bug
@ -686,10 +684,10 @@ void OSXScreen::enable()
if (m_eventTapRLSR) { if (m_eventTapRLSR) {
CFRunLoopAddSource(CFRunLoopGetCurrent(), m_eventTapRLSR, kCFRunLoopDefaultMode); CFRunLoopAddSource(CFRunLoopGetCurrent(), m_eventTapRLSR, kCFRunLoopDefaultMode);
} else { } else {
LOG((CLOG_ERR "failed to create a CFRunLoopSourceRef for the quartz event tap")); LOG_ERR("failed to create a CFRunLoopSourceRef for the quartz event tap");
} }
} else { } else {
LOG((CLOG_ERR "failed to create quartz event tap")); LOG_ERR("failed to create quartz event tap");
} }
} }
@ -766,7 +764,7 @@ void OSXScreen::leave()
bool OSXScreen::setClipboard(ClipboardID, const IClipboard *src) bool OSXScreen::setClipboard(ClipboardID, const IClipboard *src)
{ {
if (src != nullptr) { if (src != nullptr) {
LOG((CLOG_DEBUG "setting clipboard")); LOG_DEBUG("setting clipboard");
Clipboard::copy(&m_pasteboard, src); Clipboard::copy(&m_pasteboard, src);
} }
return true; return true;
@ -774,9 +772,9 @@ bool OSXScreen::setClipboard(ClipboardID, const IClipboard *src)
void OSXScreen::checkClipboards() void OSXScreen::checkClipboards()
{ {
LOG((CLOG_DEBUG2 "checking clipboard")); LOG_DEBUG2("checking clipboard");
if (m_pasteboard.synchronize()) { if (m_pasteboard.synchronize()) {
LOG((CLOG_DEBUG "clipboard changed")); LOG_DEBUG("clipboard changed");
sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardClipboard); sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardClipboard);
sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardSelection); sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardSelection);
} }
@ -892,19 +890,19 @@ void OSXScreen::handleSystemEvent(const Event &event)
SendEventToEventTarget(*carbonEvent, nullptr); SendEventToEventTarget(*carbonEvent, nullptr);
switch (GetEventKind(*carbonEvent)) { switch (GetEventKind(*carbonEvent)) {
case kEventWindowActivated: case kEventWindowActivated:
LOG((CLOG_DEBUG1 "window activated")); LOG_DEBUG1("window activated");
break; break;
case kEventWindowDeactivated: case kEventWindowDeactivated:
LOG((CLOG_DEBUG1 "window deactivated")); LOG_DEBUG1("window deactivated");
break; break;
case kEventWindowFocusAcquired: case kEventWindowFocusAcquired:
LOG((CLOG_DEBUG1 "focus acquired")); LOG_DEBUG1("focus acquired");
break; break;
case kEventWindowFocusRelinquish: case kEventWindowFocusRelinquish:
LOG((CLOG_DEBUG1 "focus released")); LOG_DEBUG1("focus released");
break; break;
} }
break; break;
@ -917,7 +915,7 @@ void OSXScreen::handleSystemEvent(const Event &event)
bool OSXScreen::onMouseMove(CGFloat mx, CGFloat my) bool OSXScreen::onMouseMove(CGFloat mx, CGFloat my)
{ {
LOG((CLOG_DEBUG2 "mouse move %+f,%+f", mx, my)); LOG_DEBUG2("mouse move %+f,%+f", mx, my);
CGFloat x = mx - m_xCursor; CGFloat x = mx - m_xCursor;
CGFloat y = my - m_yCursor; CGFloat y = my - m_yCursor;
@ -946,7 +944,7 @@ bool OSXScreen::onMouseMove(CGFloat mx, CGFloat my)
static int32_t bogusZoneSize = 10; static int32_t bogusZoneSize = 10;
if (-x + bogusZoneSize > m_xCenter - m_x || x + bogusZoneSize > m_x + m_w - m_xCenter || if (-x + bogusZoneSize > m_xCenter - m_x || x + bogusZoneSize > m_x + m_w - m_xCenter ||
-y + bogusZoneSize > m_yCenter - m_y || y + bogusZoneSize > m_y + m_h - m_yCenter) { -y + bogusZoneSize > m_yCenter - m_y || y + bogusZoneSize > m_y + m_h - m_yCenter) {
LOG((CLOG_DEBUG "dropped bogus motion %+d,%+d", x, y)); LOG_DEBUG("dropped bogus motion %+d,%+d", x, y);
} else { } else {
// send motion // send motion
// Accumulate together the move into the running total // Accumulate together the move into the running total
@ -976,13 +974,13 @@ bool OSXScreen::onMouseButton(bool pressed, uint16_t macButton)
ButtonID button = mapMacButtonToDeskflow(macButton); ButtonID button = mapMacButtonToDeskflow(macButton);
if (pressed) { if (pressed) {
LOG((CLOG_DEBUG1 "event: button press button=%d", button)); LOG_DEBUG1("event: button press button=%d", button);
if (button != kButtonNone) { if (button != kButtonNone) {
KeyModifierMask mask = m_keyState->getActiveModifiers(); KeyModifierMask mask = m_keyState->getActiveModifiers();
sendEvent(EventTypes::PrimaryScreenButtonDown, ButtonInfo::alloc(button, mask)); sendEvent(EventTypes::PrimaryScreenButtonDown, ButtonInfo::alloc(button, mask));
} }
} else { } else {
LOG((CLOG_DEBUG1 "event: button release button=%d", button)); LOG_DEBUG1("event: button release button=%d", button);
if (button != kButtonNone) { if (button != kButtonNone) {
KeyModifierMask mask = m_keyState->getActiveModifiers(); KeyModifierMask mask = m_keyState->getActiveModifiers();
sendEvent(EventTypes::PrimaryScreenButtonUp, ButtonInfo::alloc(button, mask)); sendEvent(EventTypes::PrimaryScreenButtonUp, ButtonInfo::alloc(button, mask));
@ -994,7 +992,7 @@ bool OSXScreen::onMouseButton(bool pressed, uint16_t macButton)
bool OSXScreen::onMouseWheel(int32_t xDelta, int32_t yDelta) const bool OSXScreen::onMouseWheel(int32_t xDelta, int32_t yDelta) const
{ {
LOG((CLOG_DEBUG1 "event: button wheel delta=%+d,%+d", xDelta, yDelta)); LOG_DEBUG1("event: button wheel delta=%+d,%+d", xDelta, yDelta);
sendEvent(EventTypes::PrimaryScreenWheel, WheelInfo::alloc(xDelta, yDelta)); sendEvent(EventTypes::PrimaryScreenWheel, WheelInfo::alloc(xDelta, yDelta));
return true; return true;
} }
@ -1012,12 +1010,12 @@ void OSXScreen::displayReconfigurationCallback(
kCGDisplayDisabledFlag | kCGDisplayMirrorFlag | kCGDisplayUnMirrorFlag | kCGDisplayDisabledFlag | kCGDisplayMirrorFlag | kCGDisplayUnMirrorFlag |
kCGDisplayDesktopShapeChangedFlag; kCGDisplayDesktopShapeChangedFlag;
LOG((CLOG_DEBUG1 "event: display was reconfigured: %x %x %x", flags, mask, flags & mask)); LOG_DEBUG1("event: display was reconfigured: %x %x %x", flags, mask, flags & mask);
if (flags & mask) { /* Something actually did change */ if (flags & mask) { /* Something actually did change */
LOG((CLOG_DEBUG1 "event: screen changed shape; refreshing dimensions")); LOG_DEBUG1("event: screen changed shape; refreshing dimensions");
if (!screen->updateScreenShape(displayID, flags)) { if (!screen->updateScreenShape(displayID, flags)) {
LOG((CLOG_ERR "failed to update screen shape during display reconfiguration")); LOG_ERR("failed to update screen shape during display reconfiguration");
} }
} }
} }
@ -1029,7 +1027,7 @@ bool OSXScreen::onKey(CGEventRef event)
// get the key and active modifiers // get the key and active modifiers
uint32_t virtualKey = CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode); uint32_t virtualKey = CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
CGEventFlags macMask = CGEventGetFlags(event); CGEventFlags macMask = CGEventGetFlags(event);
LOG((CLOG_DEBUG1 "event: Key event kind: %d, keycode=%d", eventKind, virtualKey)); LOG_DEBUG1("event: Key event kind: %d, keycode=%d", eventKind, virtualKey);
// Special handling to track state of modifiers // Special handling to track state of modifiers
if (eventKind == kCGEventFlagsChanged) { if (eventKind == kCGEventFlagsChanged) {
@ -1135,14 +1133,11 @@ void OSXScreen::onMediaKey(CGEventRef event)
bool isRepeat; bool isRepeat;
if (!getMediaKeyEventInfo(event, &keyID, &down, &isRepeat)) { if (!getMediaKeyEventInfo(event, &keyID, &down, &isRepeat)) {
LOG((CLOG_ERR "Failed to decode media key event")); LOG_ERR("Failed to decode media key event");
return; return;
} }
LOG( LOG_DEBUG2("Media key event: keyID=0x%02x, %s, repeat=%s", keyID, (down ? "down" : "up"), (isRepeat ? "yes" : "no"));
(CLOG_DEBUG2 "Media key event: keyID=0x%02x, %s, repeat=%s", keyID, (down ? "down" : "up"),
(isRepeat ? "yes" : "no"))
);
KeyButton button = 0; KeyButton button = 0;
KeyModifierMask mask = m_keyState->getActiveModifiers(); KeyModifierMask mask = m_keyState->getActiveModifiers();
@ -1304,9 +1299,9 @@ bool OSXScreen::updateScreenShape()
// We want to notify the peer screen whether we are primary screen or not // We want to notify the peer screen whether we are primary screen or not
sendEvent(EventTypes::ScreenShapeChanged); sendEvent(EventTypes::ScreenShapeChanged);
LOG( LOG_DEBUG(
(CLOG_DEBUG "screen shape: center=%d,%d size=%dx%d on %u %s", m_x, m_y, m_w, m_h, displayCount, "screen shape: center=%d,%d size=%dx%d on %u %s", m_x, m_y, m_w, m_h, displayCount,
(displayCount == 1) ? "display" : "displays") (displayCount == 1) ? "display" : "displays"
); );
return true; return true;
@ -1329,10 +1324,10 @@ pascal OSStatus OSXScreen::userSwitchCallback(EventHandlerCallRef nextHandler, E
IEventQueue *events = screen->getEvents(); IEventQueue *events = screen->getEvents();
if (kind == kEventSystemUserSessionDeactivated) { if (kind == kEventSystemUserSessionDeactivated) {
LOG((CLOG_DEBUG "user session deactivated")); LOG_DEBUG("user session deactivated");
events->addEvent(Event(EventTypes::ScreenSuspend, screen->getEventTarget())); events->addEvent(Event(EventTypes::ScreenSuspend, screen->getEventTarget()));
} else if (kind == kEventSystemUserSessionActivated) { } else if (kind == kEventSystemUserSessionActivated) {
LOG((CLOG_DEBUG "user session activated")); LOG_DEBUG("user session activated");
events->addEvent(Event(EventTypes::ScreenResume, screen->getEventTarget())); events->addEvent(Event(EventTypes::ScreenResume, screen->getEventTarget()));
} }
return (CallNextEventHandler(nextHandler, theEvent)); return (CallNextEventHandler(nextHandler, theEvent));
@ -1358,7 +1353,7 @@ void OSXScreen::watchSystemPowerThread(void *)
// install system power change callback // install system power change callback
m_pmRootPort = IORegisterForSystemPower(this, &notificationPortRef, powerChangeCallback, &notifier); m_pmRootPort = IORegisterForSystemPower(this, &notificationPortRef, powerChangeCallback, &notifier);
if (m_pmRootPort == 0) { if (m_pmRootPort == 0) {
LOG((CLOG_WARN "IORegisterForSystemPower failed")); LOG_WARN("IORegisterForSystemPower failed");
} else { } else {
runloopSourceRef = IONotificationPortGetRunLoopSource(notificationPortRef); runloopSourceRef = IONotificationPortGetRunLoopSource(notificationPortRef);
CFRunLoopAddSource(m_pmRunloop, runloopSourceRef, kCFRunLoopCommonModes); CFRunLoopAddSource(m_pmRunloop, runloopSourceRef, kCFRunLoopCommonModes);
@ -1375,13 +1370,13 @@ void OSXScreen::watchSystemPowerThread(void *)
// setting m_pmThreadReady to true otherwise the parent thread will // setting m_pmThreadReady to true otherwise the parent thread will
// block waiting for it. // block waiting for it.
if (m_pmRootPort == 0) { if (m_pmRootPort == 0) {
LOG((CLOG_WARN "failed to init watchSystemPowerThread")); LOG_WARN("failed to init watchSystemPowerThread");
return; return;
} }
LOG((CLOG_DEBUG "started watchSystemPowerThread")); LOG_DEBUG("started watchSystemPowerThread");
LOG((CLOG_DEBUG "waiting for event loop")); LOG_DEBUG("waiting for event loop");
m_events->waitForReady(); m_events->waitForReady();
{ {
@ -1390,7 +1385,7 @@ void OSXScreen::watchSystemPowerThread(void *)
// we signalling carbon loop ready before starting // we signalling carbon loop ready before starting
// unless we know how to do it within the loop // unless we know how to do it within the loop
LOG((CLOG_DEBUG "signalling carbon loop ready")); LOG_DEBUG("signalling carbon loop ready");
*m_carbonLoopReady = true; *m_carbonLoopReady = true;
m_carbonLoopReady->signal(); m_carbonLoopReady->signal();
@ -1398,9 +1393,9 @@ void OSXScreen::watchSystemPowerThread(void *)
} }
// start the run loop // start the run loop
LOG((CLOG_DEBUG "starting carbon loop")); LOG_DEBUG("starting carbon loop");
CFRunLoopRun(); CFRunLoopRun();
LOG((CLOG_DEBUG "carbon loop has stopped")); LOG_DEBUG("carbon loop has stopped");
// cleanup // cleanup
if (notificationPortRef) { if (notificationPortRef) {
@ -1412,7 +1407,7 @@ void OSXScreen::watchSystemPowerThread(void *)
Lock lock(m_pmMutex); Lock lock(m_pmMutex);
IODeregisterForSystemPower(&notifier); IODeregisterForSystemPower(&notifier);
m_pmRootPort = 0; m_pmRootPort = 0;
LOG((CLOG_DEBUG "stopped watchSystemPowerThread")); LOG_DEBUG("stopped watchSystemPowerThread");
} }
void OSXScreen::powerChangeCallback(void *refcon, io_service_t service, natural_t messageType, void *messageArg) void OSXScreen::powerChangeCallback(void *refcon, io_service_t service, natural_t messageType, void *messageArg)
@ -1434,7 +1429,7 @@ void OSXScreen::handlePowerChangeRequest(natural_t messageType, void *messageArg
return; return;
case kIOMessageSystemHasPoweredOn: case kIOMessageSystemHasPoweredOn:
LOG((CLOG_DEBUG "system wakeup")); LOG_DEBUG("system wakeup");
m_events->addEvent(Event(EventTypes::ScreenResume, getEventTarget())); m_events->addEvent(Event(EventTypes::ScreenResume, getEventTarget()));
break; break;
@ -1459,7 +1454,7 @@ void OSXScreen::handleConfirmSleep(const Event &event)
Event(EventTypes::ScreenSuspend, getEventTarget(), nullptr, Event::EventFlags::DeliverImmediately) Event(EventTypes::ScreenSuspend, getEventTarget(), nullptr, Event::EventFlags::DeliverImmediately)
); );
LOG((CLOG_DEBUG "system will sleep")); LOG_DEBUG("system will sleep");
IOAllowPowerChange(m_pmRootPort, messageArg); IOAllowPowerChange(m_pmRootPort, messageArg);
} }
} }
@ -1607,7 +1602,7 @@ OSXScreen::handleCGInputEventSecondary(CGEventTapProxy proxy, CGEventType type,
CGPoint pos = CGEventGetLocation(event); CGPoint pos = CGEventGetLocation(event);
if (pos.x != screen->m_xCenter || pos.y != screen->m_yCenter) { if (pos.x != screen->m_xCenter || pos.y != screen->m_yCenter) {
LOG((CLOG_DEBUG "show cursor on secondary, type=%d pos=%d,%d", type, pos.x, pos.y)); LOG_DEBUG("show cursor on secondary, type=%d pos=%d,%d", type, pos.x, pos.y);
screen->showCursor(); screen->showCursor();
} }
} }
@ -1658,26 +1653,26 @@ CGEventRef OSXScreen::handleCGInputEvent(CGEventTapProxy proxy, CGEventType type
case kCGEventTapDisabledByTimeout: case kCGEventTapDisabledByTimeout:
// Re-enable our event-tap // Re-enable our event-tap
CGEventTapEnable(screen->m_eventTapPort, true); CGEventTapEnable(screen->m_eventTapPort, true);
LOG((CLOG_INFO "quartz event tap was disabled by timeout, re-enabling")); LOG_INFO("quartz event tap was disabled by timeout, re-enabling");
break; break;
case kCGEventTapDisabledByUserInput: case kCGEventTapDisabledByUserInput:
LOG((CLOG_ERR "quartz event tap was disabled by user input")); LOG_ERR("quartz event tap was disabled by user input");
break; break;
case NX_NULLEVENT: case NX_NULLEVENT:
break; break;
default: default:
if (type == NX_SYSDEFINED) { if (type == NX_SYSDEFINED) {
if (isMediaKeyEvent(event)) { if (isMediaKeyEvent(event)) {
LOG((CLOG_DEBUG2 "detected media key event")); LOG_DEBUG2("detected media key event");
screen->onMediaKey(event); screen->onMediaKey(event);
} else { } else {
LOG((CLOG_DEBUG2 "ignoring unknown system defined event")); LOG_DEBUG2("ignoring unknown system defined event");
return event; return event;
} }
break; break;
} }
LOG((CLOG_DEBUG3 "unknown quartz event type: 0x%02x", type)); LOG_DEBUG3("unknown quartz event type: 0x%02x", type);
} }
if (screen->m_isOnScreen) { if (screen->m_isOnScreen) {
@ -1746,23 +1741,23 @@ char *OSXScreen::CFStringRefToUTF8String(CFStringRef aString)
void OSXScreen::waitForCarbonLoop() const void OSXScreen::waitForCarbonLoop() const
{ {
if (*m_carbonLoopReady) { if (*m_carbonLoopReady) {
LOG((CLOG_DEBUG "carbon loop already ready")); LOG_DEBUG("carbon loop already ready");
return; return;
} }
Lock lock(m_carbonLoopMutex); Lock lock(m_carbonLoopMutex);
LOG((CLOG_DEBUG "waiting for carbon loop")); LOG_DEBUG("waiting for carbon loop");
double timeout = Arch::time() + kCarbonLoopWaitTimeout; double timeout = Arch::time() + kCarbonLoopWaitTimeout;
while (!m_carbonLoopReady->wait()) { while (!m_carbonLoopReady->wait()) {
if (Arch::time() > timeout) { if (Arch::time() > timeout) {
LOG((CLOG_DEBUG "carbon loop not ready, waiting again")); LOG_DEBUG("carbon loop not ready, waiting again");
timeout = Arch::time() + kCarbonLoopWaitTimeout; timeout = Arch::time() + kCarbonLoopWaitTimeout;
} }
} }
LOG((CLOG_DEBUG "carbon loop ready")); LOG_DEBUG("carbon loop ready");
} }
std::string OSXScreen::getSecureInputApp() const std::string OSXScreen::getSecureInputApp() const
@ -1865,7 +1860,7 @@ void logCursorVisibility()
{ {
// CGCursorIsVisible is probably deprecated because its unreliable. // CGCursorIsVisible is probably deprecated because its unreliable.
if (!CGCursorIsVisible()) { if (!CGCursorIsVisible()) {
LOG((CLOG_WARN "cursor may not be visible")); LOG_WARN("cursor may not be visible");
} }
} }

View file

@ -90,7 +90,7 @@ void OSXScreenSaver::processLaunched(ProcessSerialNumber psn)
{ {
if (isScreenSaverEngine(psn)) { if (isScreenSaverEngine(psn)) {
m_screenSaverPSN = psn; m_screenSaverPSN = psn;
LOG((CLOG_DEBUG1 "screen saver engine launched, enabled=%d", m_enabled)); LOG_DEBUG1("screen saver engine launched, enabled=%d", m_enabled);
if (m_enabled) { if (m_enabled) {
m_events->addEvent(Event(EventTypes::PrimaryScreenSaverActivated, m_eventTarget)); m_events->addEvent(Event(EventTypes::PrimaryScreenSaverActivated, m_eventTarget));
} }
@ -100,7 +100,7 @@ void OSXScreenSaver::processLaunched(ProcessSerialNumber psn)
void OSXScreenSaver::processTerminated(ProcessSerialNumber psn) void OSXScreenSaver::processTerminated(ProcessSerialNumber psn)
{ {
if (m_screenSaverPSN.highLongOfPSN == psn.highLongOfPSN && m_screenSaverPSN.lowLongOfPSN == psn.lowLongOfPSN) { if (m_screenSaverPSN.highLongOfPSN == psn.highLongOfPSN && m_screenSaverPSN.lowLongOfPSN == psn.lowLongOfPSN) {
LOG((CLOG_DEBUG1 "screen saver engine terminated, enabled=%d", m_enabled)); LOG_DEBUG1("screen saver engine terminated, enabled=%d", m_enabled);
if (m_enabled) { if (m_enabled) {
m_events->addEvent(Event(EventTypes::PrimaryScreenSaverDeactivated, m_eventTarget)); m_events->addEvent(Event(EventTypes::PrimaryScreenSaverDeactivated, m_eventTarget));
} }

View file

@ -83,7 +83,7 @@ XWindowsClipboard::~XWindowsClipboard()
void XWindowsClipboard::lost(Time time) void XWindowsClipboard::lost(Time time)
{ {
LOG((CLOG_DEBUG "lost clipboard %d ownership at %d", m_id, time)); LOG_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;
@ -97,10 +97,10 @@ void XWindowsClipboard::addRequest(Window owner, Window requestor, Atom target,
// at the given time. // at the given time.
bool success = false; bool success = false;
if (owner == m_window) { if (owner == m_window) {
LOG( LOG_DEBUG1(
(CLOG_DEBUG1 "request for clipboard %d, target %s by 0x%08x (property=%s)", m_selection, "request for clipboard %d, target %s by 0x%08x (property=%s)", m_selection,
XWindowsUtil::atomToString(m_display, target).c_str(), requestor, XWindowsUtil::atomToString(m_display, target).c_str(), requestor,
XWindowsUtil::atomToString(m_display, property).c_str()) XWindowsUtil::atomToString(m_display, property).c_str()
); );
if (wasOwnedAtTime(time)) { if (wasOwnedAtTime(time)) {
if (target == m_atomMultiple && property != None) { if (target == m_atomMultiple && property != None) {
@ -114,13 +114,13 @@ void XWindowsClipboard::addRequest(Window owner, Window requestor, Atom target,
success = true; success = true;
} }
} else { } else {
LOG((CLOG_DEBUG1 "clipboard not owned at time %d", time)); LOG_DEBUG1("clipboard not owned at time %d", time);
} }
} }
if (!success) { if (!success) {
// send failure // send failure
LOG((CLOG_DEBUG1 "clipboard request was not added")); LOG_DEBUG1("clipboard request was not added");
insertReply(new Reply(requestor, target, time)); insertReply(new Reply(requestor, target, time));
} }
@ -156,7 +156,7 @@ bool XWindowsClipboard::addSimpleRequest(Window requestor, Atom target, ::Time t
type = converter->getAtom(); type = converter->getAtom();
} catch (...) { } catch (...) {
// ignore -- cannot convert // ignore -- cannot convert
LOG((CLOG_WARN "error while converting clipboard data")); LOG_WARN("error while converting clipboard data");
} }
} }
} }
@ -164,12 +164,12 @@ bool XWindowsClipboard::addSimpleRequest(Window requestor, Atom target, ::Time t
if (type != None) { if (type != None) {
// success // success
LOG((CLOG_DEBUG1 "clipboard request added")); LOG_DEBUG1("clipboard request added");
insertReply(new Reply(requestor, target, time, property, data, type, format)); insertReply(new Reply(requestor, target, time, property, data, type, format));
return true; return true;
} else { } else {
// failure // failure
LOG((CLOG_DEBUG1 "clipboard request not added")); LOG_DEBUG1("clipboard request not added");
insertReply(new Reply(requestor, target, time)); insertReply(new Reply(requestor, target, time));
return false; return false;
} }
@ -182,9 +182,8 @@ bool XWindowsClipboard::processRequest(Window requestor, ::Time /*time*/, Atom p
// unknown requestor window // unknown requestor window
return false; return false;
} }
LOG( LOG_DEBUG1(
(CLOG_DEBUG1 "received property %s delete from 0x08%x", XWindowsUtil::atomToString(m_display, property).c_str(), "received property %s delete from 0x08%x", XWindowsUtil::atomToString(m_display, property).c_str(), requestor
requestor)
); );
// find the property in the known requests. it should be the // find the property in the known requests. it should be the
@ -235,12 +234,12 @@ bool XWindowsClipboard::empty()
{ {
assert(m_open); assert(m_open);
LOG((CLOG_DEBUG "empty clipboard %d", m_id)); LOG_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_WARN "failed to grab clipboard %d", m_id)); LOG_WARN("failed to grab clipboard %d", m_id);
return false; return false;
} }
@ -258,7 +257,7 @@ bool XWindowsClipboard::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_DEBUG("grabbed clipboard %d", m_id);
return true; return true;
} }
@ -268,7 +267,7 @@ void XWindowsClipboard::add(Format format, const std::string &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_DEBUG("add %d bytes to clipboard %d format: %d", data.size(), m_id, format);
const auto formatID = static_cast<int>(format); const auto formatID = static_cast<int>(format);
m_data[formatID] = data; m_data[formatID] = data;
@ -280,11 +279,11 @@ void XWindowsClipboard::add(Format format, const std::string &data)
bool XWindowsClipboard::open(Time time) const bool XWindowsClipboard::open(Time time) const
{ {
if (m_open) { if (m_open) {
LOG((CLOG_WARN "failed to open clipboard: already opened")); LOG_WARN("failed to open clipboard: already opened");
return false; return false;
} }
LOG((CLOG_DEBUG "open clipboard %d", m_id)); LOG_DEBUG("open clipboard %d", m_id);
// assume not motif // assume not motif
m_motif = false; m_motif = false;
@ -298,7 +297,7 @@ bool XWindowsClipboard::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_DEBUG1("motif does %sown clipboard", m_motif ? "" : "not ");
if (!m_motif) { if (!m_motif) {
motifUnlockClipboard(); motifUnlockClipboard();
} }
@ -318,7 +317,7 @@ void XWindowsClipboard::close() const
{ {
assert(m_open); assert(m_open);
LOG((CLOG_DEBUG "close clipboard %d", m_id)); LOG_DEBUG("close clipboard %d", m_id);
// unlock clipboard // unlock clipboard
if (m_motif) { if (m_motif) {
@ -369,13 +368,13 @@ IXWindowsClipboardConverter *XWindowsClipboard::getConverter(Atom target, bool o
} }
} }
if (converter == nullptr) { if (converter == nullptr) {
LOG((CLOG_DEBUG1 " no converter for target %s", XWindowsUtil::atomToString(m_display, target).c_str())); LOG_DEBUG1(" no converter for target %s", XWindowsUtil::atomToString(m_display, target).c_str());
return nullptr; return nullptr;
} }
// optionally skip already handled targets // optionally skip already handled targets
if (const auto formatID = static_cast<int>(converter->getFormat()); onlyIfNotAdded && m_added[formatID]) { if (const auto formatID = static_cast<int>(converter->getFormat()); onlyIfNotAdded && m_added[formatID]) {
LOG((CLOG_DEBUG1 " skipping handled format %d", formatID)); LOG_DEBUG1(" skipping handled format %d", formatID);
return nullptr; return nullptr;
} }
@ -446,7 +445,7 @@ void XWindowsClipboard::doFillCache()
void XWindowsClipboard::icccmFillCache() void XWindowsClipboard::icccmFillCache()
{ {
LOG((CLOG_DEBUG "icccm fill clipboard %d", m_id)); LOG_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. note that some clipboard // if not then use a default list of formats. note that some clipboard
@ -456,7 +455,7 @@ void XWindowsClipboard::icccmFillCache()
Atom target; Atom target;
std::string data; std::string data;
if (!icccmGetSelection(atomTargets, &target, &data) || (target != m_atomAtom && target != m_atomTargets)) { if (!icccmGetSelection(atomTargets, &target, &data) || (target != m_atomAtom && target != m_atomTargets)) {
LOG((CLOG_DEBUG1 "selection doesn't support TARGETS")); LOG_DEBUG1("selection doesn't support TARGETS");
data = ""; data = "";
XWindowsUtil::appendAtomData(data, XA_STRING); XWindowsUtil::appendAtomData(data, XA_STRING);
} }
@ -464,7 +463,7 @@ void XWindowsClipboard::icccmFillCache()
XWindowsUtil::convertAtomProperty(data); XWindowsUtil::convertAtomProperty(data);
auto targets = static_cast<const Atom *>(static_cast<const void *>(data.data())); auto targets = static_cast<const Atom *>(static_cast<const void *>(data.data()));
const uint32_t numTargets = data.size() / sizeof(Atom); const uint32_t numTargets = data.size() / sizeof(Atom);
LOG((CLOG_DEBUG " available targets: %s", XWindowsUtil::atomsToString(m_display, targets, numTargets).c_str())); LOG_DEBUG(" available targets: %s", XWindowsUtil::atomsToString(m_display, targets, numTargets).c_str());
// try each converter in order (because they're in order of // try each converter in order (because they're in order of
// preference). // preference).
@ -499,7 +498,7 @@ void XWindowsClipboard::icccmFillCache()
Atom actualTarget; Atom actualTarget;
std::string targetData; std::string targetData;
if (!icccmGetSelection(target, &actualTarget, &targetData)) { if (!icccmGetSelection(target, &actualTarget, &targetData)) {
LOG((CLOG_DEBUG1 " no data for target %s", XWindowsUtil::atomToString(m_display, target).c_str())); LOG_DEBUG1(" no data for target %s", XWindowsUtil::atomToString(m_display, target).c_str());
continue; continue;
} }
@ -522,12 +521,11 @@ bool XWindowsClipboard::icccmGetSelection(Atom target, Atom *actualTarget, std::
// request data conversion // request data conversion
if (CICCCMGetClipboard getter(m_window, m_time, m_atomData); if (CICCCMGetClipboard getter(m_window, m_time, m_atomData);
!getter.readClipboard(m_display, m_selection, target, actualTarget, data)) { !getter.readClipboard(m_display, m_selection, target, actualTarget, data)) {
LOG((CLOG_DEBUG1 "can't get data for selection target %s", XWindowsUtil::atomToString(m_display, target).c_str())); LOG_DEBUG1("can't get data for selection target %s", XWindowsUtil::atomToString(m_display, target).c_str());
LOGC(getter.error(), (CLOG_WARN "icccm violation by clipboard owner")); LOGC(getter.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 %s", XWindowsUtil::atomToString(m_display, target).c_str()) LOG_DEBUG1("selection conversion failed for target %s", XWindowsUtil::atomToString(m_display, target).c_str());
);
return false; return false;
} }
return true; return true;
@ -539,11 +537,11 @@ IClipboard::Time XWindowsClipboard::icccmGetTime() const
std::string data; std::string data;
if (icccmGetSelection(m_atomTimestamp, &actualTarget, &data) && actualTarget == m_atomInteger) { if (icccmGetSelection(m_atomTimestamp, &actualTarget, &data) && actualTarget == m_atomInteger) {
Time time = *static_cast<const Time *>(static_cast<const void *>(data.data())); Time time = *static_cast<const Time *>(static_cast<const void *>(data.data()));
LOG((CLOG_DEBUG1 "got ICCCM time %d", time)); LOG_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_DEBUG1("can't get ICCCM time");
return 0; return 0;
} }
} }
@ -553,7 +551,7 @@ bool XWindowsClipboard::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_DEBUG1("motif lock owner 0x%08x", lockOwner);
return false; return false;
} }
@ -565,17 +563,17 @@ bool XWindowsClipboard::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_DEBUG1("motif lock owner 0x%08x", lockOwner);
return false; return false;
} }
LOG((CLOG_DEBUG1 "locked motif clipboard")); LOG_DEBUG1("locked motif clipboard");
return true; return true;
} }
void XWindowsClipboard::motifUnlockClipboard() const void XWindowsClipboard::motifUnlockClipboard() const
{ {
LOG((CLOG_DEBUG1 "unlocked motif clipboard")); LOG_DEBUG1("unlocked motif clipboard");
// fail if we don't own the lock // fail if we don't own the lock
if (Window lockOwner = XGetSelectionOwner(m_display, m_atomMotifClipLock); lockOwner != m_window) { if (Window lockOwner = XGetSelectionOwner(m_display, m_atomMotifClipLock); lockOwner != m_window) {
@ -621,7 +619,7 @@ bool XWindowsClipboard::motifOwnsClipboard() const
void XWindowsClipboard::motifFillCache() void XWindowsClipboard::motifFillCache()
{ {
LOG((CLOG_DEBUG "motif fill clipboard %d", m_id)); LOG_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;
@ -717,14 +715,14 @@ void XWindowsClipboard::motifFillCache()
Atom actualTarget; Atom actualTarget;
std::string targetData; std::string targetData;
if (!motifGetSelection(&motifFormat, &actualTarget, &targetData)) { if (!motifGetSelection(&motifFormat, &actualTarget, &targetData)) {
LOG((CLOG_DEBUG1 " no data for target %s", XWindowsUtil::atomToString(m_display, target).c_str())); LOG_DEBUG1(" no data for target %s", XWindowsUtil::atomToString(m_display, target).c_str());
continue; continue;
} }
// add to clipboard and note we've done it // add to clipboard and note we've done it
m_data[formatID] = converter->toIClipboard(targetData); m_data[formatID] = converter->toIClipboard(targetData);
m_added[formatID] = true; m_added[formatID] = true;
LOG((CLOG_DEBUG "added format %d for target %s", format, XWindowsUtil::atomToString(m_display, target).c_str())); LOG_DEBUG("added format %d for target %s", format, XWindowsUtil::atomToString(m_display, target).c_str());
} }
} }
@ -987,8 +985,7 @@ bool XWindowsClipboard::sendReply(Reply *reply)
return false; return false;
} }
LOG((CLOG_DEBUG1 "clipboard: sending notify to 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property) LOG_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;
// nothing to log // nothing to log
@ -1008,13 +1005,13 @@ bool XWindowsClipboard::sendReply(Reply *reply)
XWindowsUtil::ErrorLock lock(m_display); XWindowsUtil::ErrorLock lock(m_display);
int n; int n;
Atom *props = XListProperties(m_display, reply->m_requestor, &n); Atom *props = XListProperties(m_display, reply->m_requestor, &n);
LOG((CLOG_DEBUG2 "properties of 0x%08x:", reply->m_requestor)); LOG_DEBUG2("properties of 0x%08x:", reply->m_requestor);
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
Atom target; Atom target;
std::string data; std::string data;
char *name = XGetAtomName(m_display, props[i]); char *name = XGetAtomName(m_display, props[i]);
if (!XWindowsUtil::getWindowProperty(m_display, reply->m_requestor, props[i], &data, &target, nullptr, False)) { if (!XWindowsUtil::getWindowProperty(m_display, reply->m_requestor, props[i], &data, &target, nullptr, False)) {
LOG((CLOG_DEBUG2 " %s: <can't read property>", name)); LOG_DEBUG2(" %s: <can't read property>", name);
} else { } else {
// convert to hex if contains non ascii symbols // convert to hex if contains non ascii symbols
if (std::ranges::find_if(data, [](const unsigned char &c) { return c < 32 || c > 126; }) != data.end()) { if (std::ranges::find_if(data, [](const unsigned char &c) { return c < 32 || c > 126; }) != data.end()) {
@ -1029,7 +1026,7 @@ bool XWindowsClipboard::sendReply(Reply *reply)
data = tmp; data = tmp;
} }
char *type = XGetAtomName(m_display, target); char *type = XGetAtomName(m_display, target);
LOG((CLOG_DEBUG2 " %s (%s): %s", name, type, data.c_str())); LOG_DEBUG2(" %s (%s): %s", name, type, data.c_str());
if (type != nullptr) { if (type != nullptr) {
XFree(type); XFree(type);
} }
@ -1246,7 +1243,7 @@ bool XWindowsClipboard::CICCCMGetClipboard::readClipboard(
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 after %fs", m_failed ? "failed" : "succeeded", timeout.getTime())); LOG_DEBUG1("request %s after %fs", m_failed ? "failed" : "succeeded", timeout.getTime());
return !m_failed; return !m_failed;
} }
@ -1328,14 +1325,14 @@ bool XWindowsClipboard::CICCCMGetClipboard::processEvent(Display *display, const
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 %s", XWindowsUtil::atomToString(display, target).c_str())); LOG_DEBUG1(" INCR first chunk, target %s", XWindowsUtil::atomToString(display, target).c_str());
*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_WARN(" INCR target mismatch");
m_failed = true; m_failed = true;
m_error = true; m_error = true;
} }
@ -1343,14 +1340,14 @@ bool XWindowsClipboard::CICCCMGetClipboard::processEvent(Display *display, const
// 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_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 %s", XWindowsUtil::atomToString(display, target).c_str())); LOG_DEBUG1(" target %s", XWindowsUtil::atomToString(display, target).c_str());
*m_actualTarget = target; *m_actualTarget = target;
m_done = true; m_done = true;
} }

View file

@ -96,12 +96,12 @@ void XWindowsKeyState::setAutoRepeat(const XKeyboardState &state)
KeyModifierMask XWindowsKeyState::mapModifiersFromX(unsigned int state) const KeyModifierMask XWindowsKeyState::mapModifiersFromX(unsigned int state) const
{ {
LOG((CLOG_DEBUG2 "mapping state: %i", state)); LOG_DEBUG2("mapping state: %i", state);
uint32_t offset = 8 * getGroupFromState(state); uint32_t offset = 8 * getGroupFromState(state);
KeyModifierMask mask = 0; KeyModifierMask mask = 0;
for (int i = 0; i < 8; ++i) { for (int i = 0; i < 8; ++i) {
if ((state & (1u << i)) != 0) { if ((state & (1u << i)) != 0) {
LOG((CLOG_DEBUG2 "|= modifier: %i", offset + i)); LOG_DEBUG2("|= modifier: %i", offset + i);
if (offset + i >= m_modifierFromX.size()) { if (offset + i >= m_modifierFromX.size()) {
LOG( LOG(
(CLOG_ERR "m_modifierFromX is too small (%d) for the " (CLOG_ERR "m_modifierFromX is too small (%d) for the "
@ -180,7 +180,7 @@ int32_t XWindowsKeyState::pollActiveGroup() const
return state.group; return state.group;
} }
LOG((CLOG_WARN "failed to poll active group")); LOG_WARN("failed to poll active group");
} }
#endif #endif
return 0; return 0;
@ -233,7 +233,7 @@ bool XWindowsKeyState::setCurrentLanguageWithDBus(int32_t group) const
QDBusInterface screenSaverInterface(service, path, service, bus); QDBusInterface screenSaverInterface(service, path, service, bus);
if (!screenSaverInterface.isValid()) { if (!screenSaverInterface.isValid()) {
LOG((CLOG_WARN "keyboard layout fail. dbus interface is invalid")); LOG_WARN("keyboard layout fail. dbus interface is invalid");
return false; return false;
} }
@ -250,12 +250,12 @@ bool XWindowsKeyState::setCurrentLanguageWithDBus(int32_t group) const
} }
if (reply.isError()) { if (reply.isError()) {
LOG((CLOG_WARN "keyboard layout fail. reply contains error")); LOG_WARN("keyboard layout fail. reply contains error");
return true; return true;
} }
if (!reply.argumentAt<0>() || reply.argumentAt<1>() != QString("")) { if (!reply.argumentAt<0>() || reply.argumentAt<1>() != QString("")) {
LOG((CLOG_WARN "keyboard layout fail. Reply is unexpected!")); LOG_WARN("keyboard layout fail. Reply is unexpected!");
return true; return true;
} }
@ -272,7 +272,7 @@ void XWindowsKeyState::fakeKey(const Keystroke &keystroke)
int b = 1 << (c & 7); int b = 1 << (c & 7);
if (m_keyboardState.global_auto_repeat == AutoRepeatModeOff || if (m_keyboardState.global_auto_repeat == AutoRepeatModeOff ||
(c != 113 && c != 116 && (m_keyboardState.auto_repeats[i] & b) == 0)) { (c != 113 && c != 116 && (m_keyboardState.auto_repeats[i] & b) == 0)) {
LOG((CLOG_DEBUG1 " discard autorepeat")); LOG_DEBUG1(" discard autorepeat");
break; break;
} }
} }
@ -296,12 +296,12 @@ void XWindowsKeyState::fakeKey(const Keystroke &keystroke)
#if HAVE_XKB_EXTENSION #if HAVE_XKB_EXTENSION
if (m_xkb != nullptr) { if (m_xkb != nullptr) {
if (XkbLockGroup(m_display, XkbUseCoreKbd, keystroke.m_data.m_group.m_group) == False) { if (XkbLockGroup(m_display, XkbUseCoreKbd, keystroke.m_data.m_group.m_group) == False) {
LOG((CLOG_DEBUG1 "xkb lock group request not sent")); LOG_DEBUG1("xkb lock group request not sent");
} }
} else } else
#endif #endif
{ {
LOG((CLOG_DEBUG1 " ignored")); LOG_DEBUG1(" ignored");
} }
} else { } else {
@ -315,12 +315,12 @@ void XWindowsKeyState::fakeKey(const Keystroke &keystroke)
if (XkbLockGroup( if (XkbLockGroup(
m_display, XkbUseCoreKbd, getEffectiveGroup(pollActiveGroup(), keystroke.m_data.m_group.m_group) m_display, XkbUseCoreKbd, getEffectiveGroup(pollActiveGroup(), keystroke.m_data.m_group.m_group)
) == False) { ) == False) {
LOG((CLOG_DEBUG1 "xkb lock group request not sent")); LOG_DEBUG1("xkb lock group request not sent");
} }
} else } else
#endif #endif
{ {
LOG((CLOG_DEBUG1 " ignored")); LOG_DEBUG1(" ignored");
} }
} }
@ -334,7 +334,7 @@ void XWindowsKeyState::updateKeysymMap(deskflow::KeyMap &keyMap)
// there are up to 4 keysyms per keycode // there are up to 4 keysyms per keycode
static const int maxKeysyms = 4; static const int maxKeysyms = 4;
LOG((CLOG_DEBUG1 "non-XKB mapping")); LOG_DEBUG1("non-XKB mapping");
// prepare map from X modifier to KeyModifierMask. certain bits // prepare map from X modifier to KeyModifierMask. certain bits
// are predefined. // are predefined.
@ -569,7 +569,7 @@ void XWindowsKeyState::updateKeysymMapXKB(deskflow::KeyMap &keyMap)
} }
}; };
LOG((CLOG_DEBUG1 "xkb mapping")); LOG_DEBUG1("xkb mapping");
// find the number of groups // find the number of groups
int maxNumGroups = 0; int maxNumGroups = 0;

View file

@ -20,7 +20,7 @@ namespace {
bool sleepInhibitCall(bool state, XWindowsPowerManager::InhibitScreenServices serviceID) bool sleepInhibitCall(bool state, XWindowsPowerManager::InhibitScreenServices serviceID)
{ {
if (std::string error; !XWindowsPowerManager::inhibitScreenCall(serviceID, state, error)) { if (std::string error; !XWindowsPowerManager::inhibitScreenCall(serviceID, state, error)) {
LOG((CLOG_DEBUG "dbus inhibit error %s", error.c_str())); LOG_DEBUG("dbus inhibit error %s", error.c_str());
return false; return false;
} }
@ -38,7 +38,7 @@ void XWindowsPowerManager::disableSleep() const
{ {
if (!sleepInhibitCall(true, XWindowsPowerManager::InhibitScreenServices::kScreenSaver) && if (!sleepInhibitCall(true, XWindowsPowerManager::InhibitScreenServices::kScreenSaver) &&
!sleepInhibitCall(true, XWindowsPowerManager::InhibitScreenServices::kSessionManager)) { !sleepInhibitCall(true, XWindowsPowerManager::InhibitScreenServices::kSessionManager)) {
LOG((CLOG_WARN "failed to prevent system from going to sleep")); LOG_WARN("failed to prevent system from going to sleep");
} }
} }
@ -46,7 +46,7 @@ void XWindowsPowerManager::enableSleep() const
{ {
if (!sleepInhibitCall(false, XWindowsPowerManager::InhibitScreenServices::kScreenSaver) && if (!sleepInhibitCall(false, XWindowsPowerManager::InhibitScreenServices::kScreenSaver) &&
!sleepInhibitCall(false, XWindowsPowerManager::InhibitScreenServices::kSessionManager)) { !sleepInhibitCall(false, XWindowsPowerManager::InhibitScreenServices::kSessionManager)) {
LOG((CLOG_WARN "failed to enable system idle sleep")); LOG_WARN("failed to enable system idle sleep");
} }
} }

View file

@ -111,8 +111,8 @@ XWindowsScreen::XWindowsScreen(
m_window = openWindow(); m_window = openWindow();
m_screensaver = new XWindowsScreenSaver(m_display, m_window, getEventTarget(), events); m_screensaver = new XWindowsScreenSaver(m_display, m_window, getEventTarget(), events);
m_keyState = new XWindowsKeyState(m_display, m_xkb, events, m_keyMap); m_keyState = new XWindowsKeyState(m_display, m_xkb, events, m_keyMap);
LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_xinerama ? "(xinerama)" : "")); LOG_DEBUG("screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_xinerama ? "(xinerama)" : "");
LOG((CLOG_DEBUG "window is 0x%08x", m_window)); LOG_DEBUG("window is 0x%08x", m_window);
} catch (...) { } catch (...) {
if (m_display != nullptr) { if (m_display != nullptr) {
XCloseDisplay(m_display); XCloseDisplay(m_display);
@ -406,10 +406,10 @@ void XWindowsScreen::setOptions(const OptionsList &options)
for (uint32_t i = 0, n = options.size(); i < n; i += 2) { for (uint32_t i = 0, n = options.size(); i < n; i += 2) {
if (options[i] == kOptionXTestXineramaUnaware) { if (options[i] == kOptionXTestXineramaUnaware) {
m_xtestIsXineramaUnaware = (options[i + 1] != 0); m_xtestIsXineramaUnaware = (options[i + 1] != 0);
LOG((CLOG_DEBUG1 "library, XTest is Xinerama unaware %s", m_xtestIsXineramaUnaware ? "true" : "false")); LOG_DEBUG1("library, XTest is Xinerama unaware %s", m_xtestIsXineramaUnaware ? "true" : "false");
} else if (options[i] == kOptionScreenPreserveFocus) { } else if (options[i] == kOptionScreenPreserveFocus) {
m_preserveFocus = (options[i + 1] != 0); m_preserveFocus = (options[i + 1] != 0);
LOG((CLOG_DEBUG1 "preserve focus: %s", m_preserveFocus ? "true" : "false")); LOG_DEBUG1("preserve focus: %s", m_preserveFocus ? "true" : "false");
} }
} }
} }
@ -512,7 +512,7 @@ uint32_t XWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask)
{ {
// only allow certain modifiers // only allow certain modifiers
if ((mask & ~(KeyModifierShift | KeyModifierControl | KeyModifierAlt | KeyModifierSuper)) != 0) { if ((mask & ~(KeyModifierShift | KeyModifierControl | KeyModifierAlt | KeyModifierSuper)) != 0) {
LOG((CLOG_DEBUG "could not map hotkey id=%04x mask=%04x", key, mask)); LOG_DEBUG("could not map hotkey id=%04x mask=%04x", key, mask);
return 0; return 0;
} }
@ -525,14 +525,14 @@ uint32_t XWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask)
unsigned int modifiers; unsigned int modifiers;
if (!m_keyState->mapModifiersToX(mask, modifiers)) { if (!m_keyState->mapModifiersToX(mask, modifiers)) {
// can't map all modifiers // can't map all modifiers
LOG((CLOG_DEBUG "could not map hotkey id=%04x mask=%04x", key, mask)); LOG_DEBUG("could not map hotkey id=%04x mask=%04x", key, mask);
return 0; return 0;
} }
XWindowsKeyState::KeycodeList keycodes; XWindowsKeyState::KeycodeList keycodes;
m_keyState->mapKeyToKeycodes(key, keycodes); m_keyState->mapKeyToKeycodes(key, keycodes);
if (key != kKeyNone && keycodes.empty()) { if (key != kKeyNone && keycodes.empty()) {
// can't map key // can't map key
LOG((CLOG_DEBUG "could not map hotkey id=%04x mask=%04x", key, mask)); LOG_DEBUG("could not map hotkey id=%04x mask=%04x", key, mask);
return 0; return 0;
} }
@ -713,9 +713,9 @@ void XWindowsScreen::unregisterHotKey(uint32_t id)
} }
} }
if (err) { if (err) {
LOG((CLOG_WARN "failed to unregister hotkey id=%d", id)); LOG_WARN("failed to unregister hotkey id=%d", id);
} else { } else {
LOG((CLOG_DEBUG "unregistered hotkey id=%d", id)); LOG_DEBUG("unregistered hotkey id=%d", id);
} }
// discard hot key from map and record old id for reuse // discard hot key from map and record old id for reuse
@ -821,7 +821,7 @@ void XWindowsScreen::fakeMouseWheel(int32_t, int32_t yDelta) const
} }
if (yDelta < m_mouseScrollDelta) { if (yDelta < m_mouseScrollDelta) {
LOG((CLOG_WARN "wheel scroll delta (%d) smaller than threshold (%d)", yDelta, m_mouseScrollDelta)); LOG_WARN("wheel scroll delta (%d) smaller than threshold (%d)", yDelta, m_mouseScrollDelta);
} }
// send as many clicks as necessary // send as many clicks as necessary
@ -843,7 +843,7 @@ Display *XWindowsScreen::openDisplay(const char *displayName)
} }
// open the display // open the display
LOG((CLOG_DEBUG3 "calling XOpenDisplay(\"%s\")", displayName)); LOG_DEBUG3("calling XOpenDisplay(\"%s\")", displayName);
Display *display = XOpenDisplay(displayName); Display *display = XOpenDisplay(displayName);
if (display == nullptr) { if (display == nullptr) {
throw XScreenUnavailable(60.0); throw XScreenUnavailable(60.0);
@ -855,7 +855,7 @@ Display *XWindowsScreen::openDisplay(const char *displayName)
int firstEvent; int firstEvent;
int firstError; int firstError;
if (!XQueryExtension(display, XTestExtensionName, &majorOpcode, &firstEvent, &firstError)) { if (!XQueryExtension(display, XTestExtensionName, &majorOpcode, &firstEvent, &firstError)) {
LOG((CLOG_ERR "the XTest extension is not available")); LOG_ERR("the XTest extension is not available");
XCloseDisplay(display); XCloseDisplay(display);
throw XScreenOpenFailure(); throw XScreenOpenFailure();
} }
@ -1038,7 +1038,7 @@ void XWindowsScreen::openIM()
// open the input methods // open the input methods
XIM im = XOpenIM(m_display, nullptr, nullptr, nullptr); XIM im = XOpenIM(m_display, nullptr, nullptr, nullptr);
if (im == nullptr) { if (im == nullptr) {
LOG((CLOG_INFO "no support for IM")); LOG_INFO("no support for IM");
return; return;
} }
@ -1046,7 +1046,7 @@ void XWindowsScreen::openIM()
// only at the moment. // only at the moment.
XIMStyles *styles; XIMStyles *styles;
if (XGetIMValues(im, XNQueryInputStyle, &styles, nullptr) != nullptr || styles == nullptr) { if (XGetIMValues(im, XNQueryInputStyle, &styles, nullptr) != nullptr || styles == nullptr) {
LOG((CLOG_WARN "cannot get IM styles")); LOG_WARN("cannot get IM styles");
XCloseIM(im); XCloseIM(im);
return; return;
} }
@ -1059,7 +1059,7 @@ void XWindowsScreen::openIM()
} }
XFree(styles); XFree(styles);
if (style == 0) { if (style == 0) {
LOG((CLOG_INFO "no supported IM styles")); LOG_INFO("no supported IM styles");
XCloseIM(im); XCloseIM(im);
return; return;
} }
@ -1067,7 +1067,7 @@ void XWindowsScreen::openIM()
// create an input context for the style and tell it about our window // create an input context for the style and tell it about our window
XIC ic = XCreateIC(im, XNInputStyle, style, XNClientWindow, m_window, nullptr); XIC ic = XCreateIC(im, XNInputStyle, style, XNClientWindow, m_window, nullptr);
if (ic == nullptr) { if (ic == nullptr) {
LOG((CLOG_WARN "cannot create IC")); LOG_WARN("cannot create IC");
XCloseIM(im); XCloseIM(im);
return; return;
} }
@ -1075,7 +1075,7 @@ void XWindowsScreen::openIM()
// find out the events we must select for and do so // find out the events we must select for and do so
unsigned long mask; unsigned long mask;
if (XGetICValues(ic, XNFilterEvents, &mask, nullptr) != nullptr) { if (XGetICValues(ic, XNFilterEvents, &mask, nullptr) != nullptr) {
LOG((CLOG_WARN "cannot get IC filter events")); LOG_WARN("cannot get IC filter events");
XDestroyIC(ic); XDestroyIC(ic);
XCloseIM(im); XCloseIM(im);
return; return;
@ -1342,7 +1342,7 @@ void XWindowsScreen::handleSystemEvent(const Event &event)
return; return;
case XkbStateNotify: case XkbStateNotify:
LOG((CLOG_INFO "group change: %d", xkbEvent->state.group)); LOG_INFO("group change: %d", xkbEvent->state.group);
m_keyState->setActiveGroup((int32_t)xkbEvent->state.group); m_keyState->setActiveGroup((int32_t)xkbEvent->state.group);
return; return;
@ -1357,8 +1357,7 @@ void XWindowsScreen::handleSystemEvent(const Event &event)
if (xevent->type == m_xrandrEventBase + RRScreenChangeNotify || if (xevent->type == m_xrandrEventBase + RRScreenChangeNotify ||
xevent->type == m_xrandrEventBase + RRNotify && xevent->type == m_xrandrEventBase + RRNotify &&
reinterpret_cast<XRRNotifyEvent *>(xevent)->subtype == RRNotify_CrtcChange) { reinterpret_cast<XRRNotifyEvent *>(xevent)->subtype == RRNotify_CrtcChange) {
LOG((CLOG_INFO "either XRRScreenChangeNotifyEvent or " LOG_INFO("either XRRScreenChangeNotifyEvent or RRNotify_CrtcChange received");
"RRNotify_CrtcChange received"));
// we're required to call back into XLib so XLib can update its internal // we're required to call back into XLib so XLib can update its internal
// state // state
@ -1387,7 +1386,7 @@ void XWindowsScreen::handleSystemEvent(const Event &event)
void XWindowsScreen::onKeyPress(XKeyEvent &xkey) void XWindowsScreen::onKeyPress(XKeyEvent &xkey)
{ {
LOG((CLOG_DEBUG1 "event: KeyPress code=%d, state=0x%04x", xkey.keycode, xkey.state)); LOG_DEBUG1("event: KeyPress code=%d, state=0x%04x", xkey.keycode, xkey.state);
const KeyModifierMask mask = m_keyState->mapModifiersFromX(xkey.state); const KeyModifierMask mask = m_keyState->mapModifiersFromX(xkey.state);
KeyID key = mapKeyFromX(&xkey); KeyID key = mapKeyFromX(&xkey);
if (key != kKeyNone) { if (key != kKeyNone) {
@ -1395,7 +1394,7 @@ void XWindowsScreen::onKeyPress(XKeyEvent &xkey)
if ((key == kKeyPause || key == kKeyBreak) && if ((key == kKeyPause || key == kKeyBreak) &&
(mask & (KeyModifierControl | KeyModifierAlt)) == (KeyModifierControl | KeyModifierAlt)) { (mask & (KeyModifierControl | KeyModifierAlt)) == (KeyModifierControl | KeyModifierAlt)) {
// pretend it's ctrl+alt+del // pretend it's ctrl+alt+del
LOG((CLOG_DEBUG "emulate ctrl+alt+del")); LOG_DEBUG("emulate ctrl+alt+del");
key = kKeyDelete; key = kKeyDelete;
} }
@ -1408,7 +1407,7 @@ void XWindowsScreen::onKeyPress(XKeyEvent &xkey)
keycode = static_cast<KeyButton>(m_lastKeycode); keycode = static_cast<KeyButton>(m_lastKeycode);
if (keycode == 0) { if (keycode == 0) {
// no keycode // no keycode
LOG((CLOG_DEBUG1 "event: KeyPress no keycode")); LOG_DEBUG1("event: KeyPress no keycode");
return; return;
} }
} }
@ -1421,7 +1420,7 @@ void XWindowsScreen::onKeyPress(XKeyEvent &xkey)
m_keyState->sendKeyEvent(getEventTarget(), false, false, key, mask, 1, keycode); m_keyState->sendKeyEvent(getEventTarget(), false, false, key, mask, 1, keycode);
} }
} else { } else {
LOG((CLOG_DEBUG1 "can't map keycode to key id")); LOG_DEBUG1("can't map keycode to key id");
} }
} }
@ -1434,7 +1433,7 @@ void XWindowsScreen::onKeyRelease(XKeyEvent &xkey, bool isRepeat)
if ((key == kKeyPause || key == kKeyBreak) && if ((key == kKeyPause || key == kKeyBreak) &&
(mask & (KeyModifierControl | KeyModifierAlt)) == (KeyModifierControl | KeyModifierAlt)) { (mask & (KeyModifierControl | KeyModifierAlt)) == (KeyModifierControl | KeyModifierAlt)) {
// pretend it's ctrl+alt+del and ignore autorepeat // pretend it's ctrl+alt+del and ignore autorepeat
LOG((CLOG_DEBUG "emulate ctrl+alt+del")); LOG_DEBUG("emulate ctrl+alt+del");
key = kKeyDelete; key = kKeyDelete;
isRepeat = false; isRepeat = false;
} }
@ -1442,14 +1441,14 @@ void XWindowsScreen::onKeyRelease(XKeyEvent &xkey, bool isRepeat)
auto keycode = static_cast<KeyButton>(xkey.keycode); auto keycode = static_cast<KeyButton>(xkey.keycode);
if (!isRepeat) { if (!isRepeat) {
// 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", keycode, xkey.state)); LOG_DEBUG1("event: KeyRelease code=%d, state=0x%04x", keycode, xkey.state);
m_keyState->sendKeyEvent(getEventTarget(), false, false, key, mask, 1, keycode); m_keyState->sendKeyEvent(getEventTarget(), false, false, key, mask, 1, keycode);
} else { } else {
// found a press event following so it's a repeat. // found a press event following so it's a repeat.
// 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", keycode, xkey.state)); LOG_DEBUG1("event: repeat code=%d, state=0x%04x", keycode, xkey.state);
m_keyState->sendKeyEvent(getEventTarget(), false, true, key, mask, 1, keycode); m_keyState->sendKeyEvent(getEventTarget(), false, true, key, mask, 1, keycode);
} }
} }
@ -1482,7 +1481,7 @@ bool XWindowsScreen::onHotKey(const XKeyEvent &xkey, bool isRepeat)
void XWindowsScreen::onMousePress(const XButtonEvent &xbutton) void XWindowsScreen::onMousePress(const XButtonEvent &xbutton)
{ {
LOG((CLOG_DEBUG1 "event: ButtonPress button=%d", xbutton.button)); LOG_DEBUG1("event: ButtonPress button=%d", xbutton.button);
ButtonID button = mapButtonFromX(&xbutton); ButtonID button = mapButtonFromX(&xbutton);
KeyModifierMask mask = m_keyState->mapModifiersFromX(xbutton.state); KeyModifierMask mask = m_keyState->mapModifiersFromX(xbutton.state);
if (button != kButtonNone) { if (button != kButtonNone) {
@ -1493,7 +1492,7 @@ void XWindowsScreen::onMousePress(const XButtonEvent &xbutton)
void XWindowsScreen::onMouseRelease(const XButtonEvent &xbutton) void XWindowsScreen::onMouseRelease(const XButtonEvent &xbutton)
{ {
using enum EventTypes; using enum EventTypes;
LOG((CLOG_DEBUG1 "event: ButtonRelease button=%d", xbutton.button)); LOG_DEBUG1("event: ButtonRelease button=%d", xbutton.button);
ButtonID button = mapButtonFromX(&xbutton); ButtonID button = mapButtonFromX(&xbutton);
KeyModifierMask mask = m_keyState->mapModifiersFromX(xbutton.state); KeyModifierMask mask = m_keyState->mapModifiersFromX(xbutton.state);
if (button != kButtonNone) { if (button != kButtonNone) {
@ -1510,7 +1509,7 @@ void XWindowsScreen::onMouseRelease(const XButtonEvent &xbutton)
void XWindowsScreen::onMouseMove(const XMotionEvent &xmotion) void XWindowsScreen::onMouseMove(const XMotionEvent &xmotion)
{ {
LOG((CLOG_DEBUG2 "event: MotionNotify %d,%d", xmotion.x_root, xmotion.y_root)); LOG_DEBUG2("event: MotionNotify %d,%d", xmotion.x_root, xmotion.y_root);
// compute motion delta (relative to the last known // compute motion delta (relative to the last known
// mouse position) // mouse position)
@ -1532,7 +1531,7 @@ void XWindowsScreen::onMouseMove(const XMotionEvent &xmotion)
do { do {
XMaskEvent(m_display, PointerMotionMask, &xevent); XMaskEvent(m_display, PointerMotionMask, &xevent);
if (cntr++ > 10) { if (cntr++ > 10) {
LOG((CLOG_WARN "too many discarded events! %d", cntr)); LOG_WARN("too many discarded events! %d", cntr);
break; break;
} }
} while (!xevent.xany.send_event); } while (!xevent.xany.send_event);
@ -1665,7 +1664,7 @@ int XWindowsScreen::ioErrorHandler(Display *)
// down. X forces us to exit at this point which is annoying. // down. X forces us to exit at this point which is annoying.
// we'll pretend as if we won't exit so we try to make sure we // we'll pretend as if we won't exit so we try to make sure we
// don't access the display anymore. // don't access the display anymore.
LOG((CLOG_CRIT "x display has unexpectedly disconnected")); LOG_CRIT("x display has unexpectedly disconnected");
s_screen->onError(); s_screen->onError();
return 0; return 0;
} }
@ -1765,11 +1764,11 @@ KeyID XWindowsScreen::mapKeyFromX(XKeyEvent *event) const
XLookupString(event, dummy, 0, &keysym, nullptr); XLookupString(event, dummy, 0, &keysym, nullptr);
} }
LOG((CLOG_DEBUG2 "mapped code=%d to keysym=0x%04x", event->keycode, keysym)); LOG_DEBUG2("mapped code=%d to keysym=0x%04x", event->keycode, keysym);
// convert key // convert key
KeyID result = XWindowsUtil::mapKeySymToKeyID(keysym); KeyID result = XWindowsUtil::mapKeySymToKeyID(keysym);
LOG((CLOG_DEBUG2 "mapped keysym=0x%04x to keyID=%d", keysym, result)); LOG_DEBUG2("mapped keysym=0x%04x to keyID=%d", keysym, result);
return result; return result;
} }
@ -1851,7 +1850,7 @@ void XWindowsScreen::warpCursorNoFlush(int32_t x, int32_t y)
XSendEvent(m_display, m_window, False, 0, &eventAfter); XSendEvent(m_display, m_window, False, 0, &eventAfter);
XSync(m_display, False); XSync(m_display, False);
LOG((CLOG_DEBUG2 "warped to %d,%d", x, y)); LOG_DEBUG2("warped to %d,%d", x, y);
} }
void XWindowsScreen::updateButtons() void XWindowsScreen::updateButtons()
@ -1903,15 +1902,15 @@ bool XWindowsScreen::grabMouseAndKeyboard()
result = XGrabKeyboard(m_display, m_window, True, GrabModeAsync, GrabModeAsync, CurrentTime); result = XGrabKeyboard(m_display, m_window, True, GrabModeAsync, GrabModeAsync, CurrentTime);
assert(result != GrabNotViewable); assert(result != GrabNotViewable);
if (result != GrabSuccess) { if (result != GrabSuccess) {
LOG((CLOG_DEBUG2 "waiting to grab keyboard")); LOG_DEBUG2("waiting to grab keyboard");
Arch::sleep(0.05); Arch::sleep(0.05);
if (timer.getTime() >= s_timeout) { if (timer.getTime() >= s_timeout) {
LOG((CLOG_DEBUG2 "grab keyboard timed out")); LOG_DEBUG2("grab keyboard timed out");
return false; return false;
} }
} }
} while (result != GrabSuccess); } while (result != GrabSuccess);
LOG((CLOG_DEBUG2 "grabbed keyboard")); LOG_DEBUG2("grabbed keyboard");
// now the mouse --- use event_mask to get EnterNotify, LeaveNotify events // now the mouse --- use event_mask to get EnterNotify, LeaveNotify events
result = result =
@ -1920,16 +1919,16 @@ bool XWindowsScreen::grabMouseAndKeyboard()
if (result != GrabSuccess) { if (result != GrabSuccess) {
// back off to avoid grab deadlock // back off to avoid grab deadlock
XUngrabKeyboard(m_display, CurrentTime); XUngrabKeyboard(m_display, CurrentTime);
LOG((CLOG_DEBUG2 "ungrabbed keyboard, waiting to grab pointer")); LOG_DEBUG2("ungrabbed keyboard, waiting to grab pointer");
Arch::sleep(0.05); Arch::sleep(0.05);
if (timer.getTime() >= s_timeout) { if (timer.getTime() >= s_timeout) {
LOG((CLOG_DEBUG2 "grab pointer timed out")); LOG_DEBUG2("grab pointer timed out");
return false; return false;
} }
} }
} while (result != GrabSuccess); } while (result != GrabSuccess);
LOG((CLOG_DEBUG1 "grabbed pointer and keyboard")); LOG_DEBUG1("grabbed pointer and keyboard");
return true; return true;
} }

View file

@ -66,7 +66,7 @@ XWindowsScreenSaver::XWindowsScreenSaver(Display *display, Window window, void *
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_DEBUG("didn't set root event mask");
m_rootEventMask = 0; m_rootEventMask = 0;
} }
@ -132,7 +132,7 @@ bool XWindowsScreenSaver::handleXEvent(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_DEBUG("xscreensaver died");
setXScreenSaver(None); setXScreenSaver(None);
return true; return true;
} }
@ -289,7 +289,7 @@ bool XWindowsScreenSaver::findXScreenSaver()
void XWindowsScreenSaver::setXScreenSaver(Window window) void XWindowsScreenSaver::setXScreenSaver(Window window)
{ {
LOG((CLOG_DEBUG "xscreensaver window: 0x%08x", window)); LOG_DEBUG("xscreensaver window: 0x%08x", window);
// save window // save window
m_xscreensaver = window; m_xscreensaver = window;
@ -331,7 +331,7 @@ bool XWindowsScreenSaver::isXScreenSaver(Window w) const
void XWindowsScreenSaver::setXScreenSaverActive(bool activated) void XWindowsScreenSaver::setXScreenSaverActive(bool activated)
{ {
if (m_xscreensaverActive != activated) { if (m_xscreensaverActive != activated) {
LOG((CLOG_DEBUG "xscreensaver %s on window 0x%08x", activated ? "activated" : "deactivated", m_xscreensaver)); LOG_DEBUG("xscreensaver %s on window 0x%08x", activated ? "activated" : "deactivated", m_xscreensaver);
m_xscreensaverActive = activated; m_xscreensaverActive = activated;
// if screen saver was activated forcefully (i.e. against // if screen saver was activated forcefully (i.e. against
@ -363,7 +363,7 @@ void XWindowsScreenSaver::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_DEBUG("send xscreensaver command: %d %d %d", (long)cmd, arg1, arg2);
bool error = false; bool error = false;
{ {
XWindowsUtil::ErrorLock lock(m_display, &error); XWindowsUtil::ErrorLock lock(m_display, &error);

View file

@ -1586,7 +1586,7 @@ bool XWindowsUtil::getWindowProperty(
); );
return true; return true;
} else { } else {
LOG((CLOG_DEBUG2 "can't read property %d on window 0x%08x", property, window)); LOG_DEBUG2("can't read property %d on window 0x%08x", property, window);
return false; return false;
} }
} }
@ -1949,13 +1949,13 @@ int XWindowsUtil::ErrorLock::internalHandler(Display *display, XErrorEvent *even
void XWindowsUtil::ErrorLock::ignoreHandler(Display *, XErrorEvent *e, void *) void XWindowsUtil::ErrorLock::ignoreHandler(Display *, XErrorEvent *e, void *)
{ {
LOG((CLOG_DEBUG1 "ignoring X error: %d", e->error_code)); LOG_DEBUG1("ignoring X error: %d", e->error_code);
} }
void XWindowsUtil::ErrorLock::saveHandler(Display *display, XErrorEvent *e, void *flag) void XWindowsUtil::ErrorLock::saveHandler(Display *display, XErrorEvent *e, void *flag)
{ {
char errtxt[1024]; char errtxt[1024];
XGetErrorText(display, e->error_code, errtxt, 1023); XGetErrorText(display, e->error_code, errtxt, 1023);
LOG((CLOG_DEBUG1 "flagging X error: %d - %.1023s", e->error_code, errtxt)); LOG_DEBUG1("flagging X error: %d - %.1023s", e->error_code, errtxt);
*static_cast<bool *>(flag) = true; *static_cast<bool *>(flag) = true;
} }

View file

@ -45,7 +45,7 @@ ClientListener::ClientListener(
m_socketFactory.reset(); m_socketFactory.reset();
throw; throw;
} }
LOG((CLOG_DEBUG1 "listening for clients")); LOG_DEBUG1("listening for clients");
} }
ClientListener::~ClientListener() ClientListener::~ClientListener()
@ -81,14 +81,14 @@ void ClientListener::start()
}); });
// bind listen address // bind listen address
LOG((CLOG_DEBUG1 "binding listen socket")); LOG_DEBUG1("binding listen socket");
m_listen->bind(m_address); m_listen->bind(m_address);
} }
void ClientListener::stop() void ClientListener::stop()
{ {
using enum EventTypes; using enum EventTypes;
LOG((CLOG_DEBUG1 "stop listening for clients")); LOG_DEBUG1("stop listening for clients");
// discard already connected clients // discard already connected clients
for (auto index = m_newClients.begin(); index != m_newClients.end(); ++index) { for (auto index = m_newClients.begin(); index != m_newClients.end(); ++index) {
@ -146,7 +146,7 @@ void ClientListener::handleClientConnecting()
void ClientListener::handleClientAccepted(IDataSocket *socket) void ClientListener::handleClientAccepted(IDataSocket *socket)
{ {
LOG((CLOG_NOTE "accepted client connection")); LOG_NOTE("accepted client connection");
// filter socket messages, including a packetizing filter // filter socket messages, including a packetizing filter
deskflow::IStream *stream = new PacketStreamFilter(m_events, socket, false); deskflow::IStream *stream = new PacketStreamFilter(m_events, socket, false);

View file

@ -28,7 +28,7 @@ ClientProxy::~ClientProxy()
void ClientProxy::close(const char *msg) const void ClientProxy::close(const char *msg) const
{ {
LOG((CLOG_DEBUG1 "send close \"%s\" to \"%s\"", msg, getName().c_str())); LOG_DEBUG1("send close \"%s\" to \"%s\"", msg, getName().c_str());
ProtocolUtil::writef(getStream(), msg); ProtocolUtil::writef(getStream(), msg);
// force the close to be sent before we return // force the close to be sent before we return

View file

@ -42,7 +42,7 @@ ClientProxy1_0::ClientProxy1_0(const std::string &name, deskflow::IStream *strea
setHeartbeatRate(kHeartRate, kHeartRate * kHeartBeatsUntilDeath); setHeartbeatRate(kHeartRate, kHeartRate * kHeartBeatsUntilDeath);
LOG((CLOG_DEBUG1 "querying client \"%s\" info", getName().c_str())); LOG_DEBUG1("querying client \"%s\" info", getName().c_str());
ProtocolUtil::writef(getStream(), kMsgQInfo); ProtocolUtil::writef(getStream(), kMsgQInfo);
} }
@ -113,14 +113,14 @@ void ClientProxy1_0::handleData()
while (n != 0) { while (n != 0) {
// 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_ERR("incomplete message from \"%s\": %d bytes", getName().c_str(), n);
disconnect(); disconnect();
return; return;
} }
// parse message // parse message
try { try {
LOG((CLOG_DEBUG2 "msg from \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], code[3])); LOG_DEBUG2("msg from \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], code[3]);
if (!(this->*m_parser)(code)) { if (!(this->*m_parser)(code)) {
LOG( LOG(
(CLOG_ERR "invalid message from client \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], (CLOG_ERR "invalid message from client \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2],
@ -132,7 +132,7 @@ void ClientProxy1_0::handleData()
; ;
} }
} catch (const XBadClient &e) { } catch (const XBadClient &e) {
LOG((CLOG_ERR "protocol error from client \"%s\": %s", getName().c_str(), e.what())); LOG_ERR("protocol error from client \"%s\": %s", getName().c_str(), e.what());
disconnect(); disconnect();
return; return;
} }
@ -149,7 +149,7 @@ bool ClientProxy1_0::parseHandshakeMessage(const uint8_t *code)
{ {
if (memcmp(code, kMsgCNoop, 4) == 0) { if (memcmp(code, kMsgCNoop, 4) == 0) {
// discard no-ops // discard no-ops
LOG((CLOG_DEBUG2 "no-op from", getName().c_str())); LOG_DEBUG2("no-op from", getName().c_str());
return true; return true;
} else if (memcmp(code, kMsgDInfo, 4) == 0) { } else if (memcmp(code, kMsgDInfo, 4) == 0) {
// future messages get parsed by parseMessage // future messages get parsed by parseMessage
@ -173,7 +173,7 @@ bool ClientProxy1_0::parseMessage(const uint8_t *code)
return false; return false;
} else if (memcmp(code, kMsgCNoop, 4) == 0) { } else if (memcmp(code, kMsgCNoop, 4) == 0) {
// discard no-ops // discard no-ops
LOG((CLOG_DEBUG2 "no-op from", getName().c_str())); LOG_DEBUG2("no-op from", getName().c_str());
return true; return true;
} else if (memcmp(code, kMsgCClipboard, 4) == 0) { } else if (memcmp(code, kMsgCClipboard, 4) == 0) {
return recvGrabClipboard(); return recvGrabClipboard();
@ -185,20 +185,20 @@ bool ClientProxy1_0::parseMessage(const uint8_t *code)
void ClientProxy1_0::handleDisconnect() void ClientProxy1_0::handleDisconnect()
{ {
LOG((CLOG_NOTE "client \"%s\" has disconnected", getName().c_str())); LOG_NOTE("client \"%s\" has disconnected", getName().c_str());
disconnect(); disconnect();
} }
void ClientProxy1_0::handleWriteError() void ClientProxy1_0::handleWriteError()
{ {
LOG((CLOG_WARN "error writing to client \"%s\"", getName().c_str())); LOG_WARN("error writing to client \"%s\"", getName().c_str());
disconnect(); disconnect();
} }
void ClientProxy1_0::handleFlatline() void ClientProxy1_0::handleFlatline()
{ {
// didn't get a heartbeat fast enough. assume client is dead. // didn't get a heartbeat fast enough. assume client is dead.
LOG((CLOG_NOTE "client \"%s\" is dead", getName().c_str())); LOG_NOTE("client \"%s\" is dead", getName().c_str());
disconnect(); disconnect();
} }
@ -225,13 +225,13 @@ void ClientProxy1_0::getCursorPos(int32_t &x, int32_t &y) const
void ClientProxy1_0::enter(int32_t xAbs, int32_t yAbs, uint32_t seqNum, KeyModifierMask mask, bool) void ClientProxy1_0::enter(int32_t xAbs, int32_t yAbs, uint32_t seqNum, KeyModifierMask mask, bool)
{ {
LOG((CLOG_DEBUG1 "send enter to \"%s\", %d,%d %d %04x", getName().c_str(), xAbs, yAbs, seqNum, mask)); LOG_DEBUG1("send enter to \"%s\", %d,%d %d %04x", getName().c_str(), xAbs, yAbs, seqNum, mask);
ProtocolUtil::writef(getStream(), kMsgCEnter, xAbs, yAbs, seqNum, mask); ProtocolUtil::writef(getStream(), kMsgCEnter, xAbs, yAbs, seqNum, mask);
} }
bool ClientProxy1_0::leave() bool ClientProxy1_0::leave()
{ {
LOG((CLOG_DEBUG1 "send leave to \"%s\"", getName().c_str())); LOG_DEBUG1("send leave to \"%s\"", getName().c_str());
ProtocolUtil::writef(getStream(), kMsgCLeave); ProtocolUtil::writef(getStream(), kMsgCLeave);
// we can never prevent the user from leaving // we can never prevent the user from leaving
@ -245,7 +245,7 @@ void ClientProxy1_0::setClipboard(ClipboardID id, const IClipboard *clipboard)
void ClientProxy1_0::grabClipboard(ClipboardID id) void ClientProxy1_0::grabClipboard(ClipboardID id)
{ {
LOG((CLOG_DEBUG "send grab clipboard %d to \"%s\"", id, getName().c_str())); LOG_DEBUG("send grab clipboard %d to \"%s\"", id, getName().c_str());
ProtocolUtil::writef(getStream(), kMsgCClipboard, id, 0); ProtocolUtil::writef(getStream(), kMsgCClipboard, id, 0);
// this clipboard is now dirty // this clipboard is now dirty
@ -259,37 +259,37 @@ void ClientProxy1_0::setClipboardDirty(ClipboardID id, bool dirty)
void ClientProxy1_0::keyDown(KeyID key, KeyModifierMask mask, KeyButton, const std::string &) void ClientProxy1_0::keyDown(KeyID key, KeyModifierMask mask, KeyButton, const std::string &)
{ {
LOG((CLOG_DEBUG1 "send key down to \"%s\" id=%d, mask=0x%04x", getName().c_str(), key, mask)); LOG_DEBUG1("send key down to \"%s\" id=%d, mask=0x%04x", getName().c_str(), key, mask);
ProtocolUtil::writef(getStream(), kMsgDKeyDown1_0, key, mask); ProtocolUtil::writef(getStream(), kMsgDKeyDown1_0, key, mask);
} }
void ClientProxy1_0::keyRepeat(KeyID key, KeyModifierMask mask, int32_t count, KeyButton, const std::string &) void ClientProxy1_0::keyRepeat(KeyID key, KeyModifierMask mask, int32_t count, KeyButton, const std::string &)
{ {
LOG((CLOG_DEBUG1 "send key repeat to \"%s\" id=%d, mask=0x%04x, count=%d", getName().c_str(), key, mask, count)); LOG_DEBUG1("send key repeat to \"%s\" id=%d, mask=0x%04x, count=%d", getName().c_str(), key, mask, count);
ProtocolUtil::writef(getStream(), kMsgDKeyRepeat1_0, key, mask, count); ProtocolUtil::writef(getStream(), kMsgDKeyRepeat1_0, key, mask, count);
} }
void ClientProxy1_0::keyUp(KeyID key, KeyModifierMask mask, KeyButton) void ClientProxy1_0::keyUp(KeyID key, KeyModifierMask mask, KeyButton)
{ {
LOG((CLOG_DEBUG1 "send key up to \"%s\" id=%d, mask=0x%04x", getName().c_str(), key, mask)); LOG_DEBUG1("send key up to \"%s\" id=%d, mask=0x%04x", getName().c_str(), key, mask);
ProtocolUtil::writef(getStream(), kMsgDKeyUp1_0, key, mask); ProtocolUtil::writef(getStream(), kMsgDKeyUp1_0, key, mask);
} }
void ClientProxy1_0::mouseDown(ButtonID button) void ClientProxy1_0::mouseDown(ButtonID button)
{ {
LOG((CLOG_DEBUG1 "send mouse down to \"%s\" id=%d", getName().c_str(), button)); LOG_DEBUG1("send mouse down to \"%s\" id=%d", getName().c_str(), button);
ProtocolUtil::writef(getStream(), kMsgDMouseDown, button); ProtocolUtil::writef(getStream(), kMsgDMouseDown, button);
} }
void ClientProxy1_0::mouseUp(ButtonID button) void ClientProxy1_0::mouseUp(ButtonID button)
{ {
LOG((CLOG_DEBUG1 "send mouse up to \"%s\" id=%d", getName().c_str(), button)); LOG_DEBUG1("send mouse up to \"%s\" id=%d", getName().c_str(), button);
ProtocolUtil::writef(getStream(), kMsgDMouseUp, button); ProtocolUtil::writef(getStream(), kMsgDMouseUp, button);
} }
void ClientProxy1_0::mouseMove(int32_t xAbs, int32_t yAbs) void ClientProxy1_0::mouseMove(int32_t xAbs, int32_t yAbs)
{ {
LOG((CLOG_DEBUG2 "send mouse move to \"%s\" %d,%d", getName().c_str(), xAbs, yAbs)); LOG_DEBUG2("send mouse move to \"%s\" %d,%d", getName().c_str(), xAbs, yAbs);
ProtocolUtil::writef(getStream(), kMsgDMouseMove, xAbs, yAbs); ProtocolUtil::writef(getStream(), kMsgDMouseMove, xAbs, yAbs);
} }
@ -301,44 +301,44 @@ void ClientProxy1_0::mouseRelativeMove(int32_t, int32_t)
void ClientProxy1_0::mouseWheel(int32_t, int32_t yDelta) void ClientProxy1_0::mouseWheel(int32_t, int32_t yDelta)
{ {
// clients prior to 1.3 only support the y axis // clients prior to 1.3 only support the y axis
LOG((CLOG_DEBUG2 "send mouse wheel to \"%s\" %+d", getName().c_str(), yDelta)); LOG_DEBUG2("send mouse wheel to \"%s\" %+d", getName().c_str(), yDelta);
ProtocolUtil::writef(getStream(), kMsgDMouseWheel1_0, yDelta); ProtocolUtil::writef(getStream(), kMsgDMouseWheel1_0, yDelta);
} }
void ClientProxy1_0::sendDragInfo(uint32_t fileCount, const char *info, size_t size) void ClientProxy1_0::sendDragInfo(uint32_t fileCount, const char *info, size_t size)
{ {
// ignore -- not supported in protocol 1.0 // ignore -- not supported in protocol 1.0
LOG((CLOG_DEBUG "draggingInfoSending not supported")); LOG_DEBUG("draggingInfoSending not supported");
} }
void ClientProxy1_0::fileChunkSending(uint8_t mark, char *data, size_t dataSize) void ClientProxy1_0::fileChunkSending(uint8_t mark, char *data, size_t dataSize)
{ {
// ignore -- not supported in protocol 1.0 // ignore -- not supported in protocol 1.0
LOG((CLOG_DEBUG "fileChunkSending not supported")); LOG_DEBUG("fileChunkSending not supported");
} }
std::string ClientProxy1_0::getSecureInputApp() const std::string ClientProxy1_0::getSecureInputApp() const
{ {
// ignore -- not supported on clients // ignore -- not supported on clients
LOG((CLOG_DEBUG "getSecureInputApp not supported")); LOG_DEBUG("getSecureInputApp not supported");
return ""; return "";
} }
void ClientProxy1_0::secureInputNotification(const std::string &app) const void ClientProxy1_0::secureInputNotification(const std::string &app) const
{ {
// ignore -- not supported in protocol 1.0 // ignore -- not supported in protocol 1.0
LOG((CLOG_DEBUG "secureInputNotification not supported")); LOG_DEBUG("secureInputNotification not supported");
} }
void ClientProxy1_0::screensaver(bool on) void ClientProxy1_0::screensaver(bool on)
{ {
LOG((CLOG_DEBUG1 "send screen saver to \"%s\" on=%d", getName().c_str(), on ? 1 : 0)); LOG_DEBUG1("send screen saver to \"%s\" on=%d", getName().c_str(), on ? 1 : 0);
ProtocolUtil::writef(getStream(), kMsgCScreenSaver, on ? 1 : 0); ProtocolUtil::writef(getStream(), kMsgCScreenSaver, on ? 1 : 0);
} }
void ClientProxy1_0::resetOptions() void ClientProxy1_0::resetOptions()
{ {
LOG((CLOG_DEBUG1 "send reset options to \"%s\"", getName().c_str())); LOG_DEBUG1("send reset options to \"%s\"", getName().c_str());
ProtocolUtil::writef(getStream(), kMsgCResetOptions); ProtocolUtil::writef(getStream(), kMsgCResetOptions);
// reset heart rate and death // reset heart rate and death
@ -349,7 +349,7 @@ void ClientProxy1_0::resetOptions()
void ClientProxy1_0::setOptions(const OptionsList &options) void ClientProxy1_0::setOptions(const OptionsList &options)
{ {
LOG((CLOG_DEBUG1 "send set options to \"%s\" size=%d", getName().c_str(), options.size())); LOG_DEBUG1("send set options to \"%s\" size=%d", getName().c_str(), options.size());
ProtocolUtil::writef(getStream(), kMsgDSetOptions, &options); ProtocolUtil::writef(getStream(), kMsgDSetOptions, &options);
// check options // check options
@ -379,7 +379,7 @@ bool ClientProxy1_0::recvInfo()
if (!ProtocolUtil::readf(getStream(), kMsgDInfo + 4, &x, &y, &w, &h, &dummy1, &mx, &my)) { if (!ProtocolUtil::readf(getStream(), kMsgDInfo + 4, &x, &y, &w, &h, &dummy1, &mx, &my)) {
return false; return false;
} }
LOG((CLOG_DEBUG "received client \"%s\" info shape=%d,%d %dx%d at %d,%d", getName().c_str(), x, y, w, h, mx, my)); LOG_DEBUG("received client \"%s\" info shape=%d,%d %dx%d at %d,%d", getName().c_str(), x, y, w, h, mx, my);
// validate // validate
if (w <= 0 || h <= 0) { if (w <= 0 || h <= 0) {
@ -399,7 +399,7 @@ bool ClientProxy1_0::recvInfo()
m_info.m_my = my; m_info.m_my = my;
// acknowledge receipt // acknowledge receipt
LOG((CLOG_DEBUG1 "send info ack to \"%s\"", getName().c_str())); LOG_DEBUG1("send info ack to \"%s\"", getName().c_str());
ProtocolUtil::writef(getStream(), kMsgCInfoAck); ProtocolUtil::writef(getStream(), kMsgCInfoAck);
return true; return true;
} }
@ -418,7 +418,7 @@ bool ClientProxy1_0::recvGrabClipboard()
if (!ProtocolUtil::readf(getStream(), kMsgCClipboard + 4, &id, &seqNum)) { if (!ProtocolUtil::readf(getStream(), kMsgCClipboard + 4, &id, &seqNum)) {
return false; return false;
} }
LOG((CLOG_DEBUG "received client \"%s\" grabbed clipboard %d seqnum=%d", getName().c_str(), id, seqNum)); LOG_DEBUG("received client \"%s\" grabbed clipboard %d seqnum=%d", getName().c_str(), id, seqNum);
// validate // validate
if (id >= kClipboardEnd) { if (id >= kClipboardEnd) {

View file

@ -25,7 +25,7 @@ ClientProxy1_1::ClientProxy1_1(const std::string &name, deskflow::IStream *strea
void ClientProxy1_1::keyDown(KeyID key, KeyModifierMask mask, KeyButton button, const std::string &) void ClientProxy1_1::keyDown(KeyID key, KeyModifierMask mask, KeyButton button, const std::string &)
{ {
LOG((CLOG_DEBUG1 "send key down to \"%s\" id=%d, mask=0x%04x, button=0x%04x", getName().c_str(), key, mask, button)); LOG_DEBUG1("send key down to \"%s\" id=%d, mask=0x%04x, button=0x%04x", getName().c_str(), key, mask, button);
ProtocolUtil::writef(getStream(), kMsgDKeyDown, key, mask, button); ProtocolUtil::writef(getStream(), kMsgDKeyDown, key, mask, button);
} }
@ -43,6 +43,6 @@ void ClientProxy1_1::keyRepeat(
void ClientProxy1_1::keyUp(KeyID key, KeyModifierMask mask, KeyButton button) void ClientProxy1_1::keyUp(KeyID key, KeyModifierMask mask, KeyButton button)
{ {
LOG((CLOG_DEBUG1 "send key up to \"%s\" id=%d, mask=0x%04x, button=0x%04x", getName().c_str(), key, mask, button)); LOG_DEBUG1("send key up to \"%s\" id=%d, mask=0x%04x, button=0x%04x", getName().c_str(), key, mask, button);
ProtocolUtil::writef(getStream(), kMsgDKeyUp, key, mask, button); ProtocolUtil::writef(getStream(), kMsgDKeyUp, key, mask, button);
} }

View file

@ -22,6 +22,6 @@ ClientProxy1_2::ClientProxy1_2(const std::string &name, deskflow::IStream *strea
void ClientProxy1_2::mouseRelativeMove(int32_t xRel, int32_t yRel) void ClientProxy1_2::mouseRelativeMove(int32_t xRel, int32_t yRel)
{ {
LOG((CLOG_DEBUG2 "send mouse relative move to \"%s\" %d,%d", getName().c_str(), xRel, yRel)); LOG_DEBUG2("send mouse relative move to \"%s\" %d,%d", getName().c_str(), xRel, yRel);
ProtocolUtil::writef(getStream(), kMsgDMouseRelMove, xRel, yRel); ProtocolUtil::writef(getStream(), kMsgDMouseRelMove, xRel, yRel);
} }

View file

@ -34,7 +34,7 @@ ClientProxy1_3::~ClientProxy1_3()
void ClientProxy1_3::mouseWheel(int32_t xDelta, int32_t yDelta) void ClientProxy1_3::mouseWheel(int32_t xDelta, int32_t yDelta)
{ {
LOG((CLOG_DEBUG2 "send mouse wheel to \"%s\" %+d,%+d", getName().c_str(), xDelta, yDelta)); LOG_DEBUG2("send mouse wheel to \"%s\" %+d,%+d", getName().c_str(), xDelta, yDelta);
ProtocolUtil::writef(getStream(), kMsgDMouseWheel, xDelta, yDelta); ProtocolUtil::writef(getStream(), kMsgDMouseWheel, xDelta, yDelta);
} }

View file

@ -37,7 +37,7 @@ void ClientProxy1_6::setClipboard(ClipboardID id, const IClipboard *clipboard)
std::string data = m_clipboard[id].m_clipboard.marshall(); std::string data = m_clipboard[id].m_clipboard.marshall();
size_t size = data.size(); size_t size = data.size();
LOG((CLOG_DEBUG "sending clipboard %d to \"%s\"", id, getName().c_str())); LOG_DEBUG("sending clipboard %d to \"%s\"", id, getName().c_str());
StreamChunker::sendClipboard(data, size, id, 0, m_events, this); StreamChunker::sendClipboard(data, size, id, 0, m_events, this);
} }
@ -52,7 +52,7 @@ bool ClientProxy1_6::recvClipboard()
if (auto r = ClipboardChunk::assemble(getStream(), dataCached, id, seq); r == TransferState::Started) { if (auto r = ClipboardChunk::assemble(getStream(), dataCached, id, seq); r == TransferState::Started) {
size_t size = ClipboardChunk::getExpectedSize(); size_t size = ClipboardChunk::getExpectedSize();
LOG((CLOG_DEBUG "receiving clipboard %d size=%d", id, size)); LOG_DEBUG("receiving clipboard %d size=%d", id, size);
} else if (r == TransferState::Finished) { } else if (r == TransferState::Finished) {
LOG( LOG(
(CLOG_DEBUG "received client \"%s\" clipboard %d seqnum=%d, size=%d", getName().c_str(), id, seq, (CLOG_DEBUG "received client \"%s\" clipboard %d seqnum=%d, size=%d", getName().c_str(), id, seq,

View file

@ -23,6 +23,6 @@ ClientProxy1_7::ClientProxy1_7(const std::string &name, deskflow::IStream *strea
void ClientProxy1_7::secureInputNotification(const std::string &app) const void ClientProxy1_7::secureInputNotification(const std::string &app) const
{ {
LOG((CLOG_DEBUG2 "send secure input notification to \"%s\" %s", getName().c_str(), app.c_str())); LOG_DEBUG2("send secure input notification to \"%s\" %s", getName().c_str(), app.c_str());
ProtocolUtil::writef(getStream(), kMsgDSecureInputNotification, &app); ProtocolUtil::writef(getStream(), kMsgDSecureInputNotification, &app);
} }

View file

@ -23,10 +23,10 @@ void ClientProxy1_8::synchronizeLanguages() const
deskflow::languages::LanguageManager languageManager; deskflow::languages::LanguageManager languageManager;
auto localLanguages = languageManager.getSerializedLocalLanguages(); auto localLanguages = languageManager.getSerializedLocalLanguages();
if (!localLanguages.empty()) { if (!localLanguages.empty()) {
LOG((CLOG_DEBUG1 "send server languages to the client: %s", localLanguages.c_str())); LOG_DEBUG1("send server languages to the client: %s", localLanguages.c_str());
ProtocolUtil::writef(getStream(), kMsgDLanguageSynchronisation, &localLanguages); ProtocolUtil::writef(getStream(), kMsgDLanguageSynchronisation, &localLanguages);
} else { } else {
LOG((CLOG_ERR "failed to read server languages")); LOG_ERR("failed to read server languages");
} }
} }

View file

@ -195,14 +195,14 @@ void ClientProxyUnknown::initProxy(const std::string &name, int major, int minor
void ClientProxyUnknown::handleData() void ClientProxyUnknown::handleData()
{ {
LOG((CLOG_DEBUG1 "parsing hello reply")); LOG_DEBUG1("parsing hello reply");
std::string name("<unknown>"); std::string name("<unknown>");
try { try {
// limit the maximum length of the hello // limit the maximum length of the hello
if (uint32_t n = m_stream->getSize(); n > kMaxHelloLength) { if (uint32_t n = m_stream->getSize(); n > kMaxHelloLength) {
LOG((CLOG_DEBUG1 "hello reply too long")); LOG_DEBUG1("hello reply too long");
throw XBadClient(); throw XBadClient();
} }
@ -227,7 +227,7 @@ void ClientProxyUnknown::handleData()
initProxy(name, major, minor); initProxy(name, major, minor);
// the proxy is created and now proxy now owns the stream // the proxy is created and now proxy now owns the stream
LOG((CLOG_DEBUG1 "created proxy for client \"%s\" version %d.%d", name.c_str(), major, minor)); LOG_DEBUG1("created proxy for client \"%s\" version %d.%d", name.c_str(), major, minor);
m_stream = nullptr; m_stream = nullptr;
// wait until the proxy signals that it's ready or has disconnected // wait until the proxy signals that it's ready or has disconnected
@ -235,33 +235,33 @@ void ClientProxyUnknown::handleData()
return; return;
} 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_WARN("client \"%s\" has incompatible version %d.%d)", name.c_str(), e.getMajor(), e.getMinor());
ProtocolUtil::writef(m_stream, kMsgEIncompatible, kProtocolMajorVersion, kProtocolMinorVersion); ProtocolUtil::writef(m_stream, kMsgEIncompatible, kProtocolMajorVersion, kProtocolMinorVersion);
} catch (XBadClient &) { } catch (XBadClient &) {
// client not behaving // client not behaving
LOG((CLOG_WARN "protocol error from client \"%s\"", name.c_str())); LOG_WARN("protocol error from client \"%s\"", name.c_str());
ProtocolUtil::writef(m_stream, kMsgEBad); ProtocolUtil::writef(m_stream, 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_WARN("error communicating with client \"%s\": %s", name.c_str(), e.what());
} }
sendFailure(); sendFailure();
} }
void ClientProxyUnknown::handleWriteError() void ClientProxyUnknown::handleWriteError()
{ {
LOG((CLOG_NOTE "error communicating with new client")); LOG_NOTE("error communicating with new client");
sendFailure(); sendFailure();
} }
void ClientProxyUnknown::handleTimeout() void ClientProxyUnknown::handleTimeout()
{ {
LOG((CLOG_NOTE "new client is unresponsive")); LOG_NOTE("new client is unresponsive");
sendFailure(); sendFailure();
} }
void ClientProxyUnknown::handleDisconnect() void ClientProxyUnknown::handleDisconnect()
{ {
LOG((CLOG_NOTE "new client disconnected")); LOG_NOTE("new client disconnected");
sendFailure(); sendFailure();
} }

View file

@ -659,18 +659,18 @@ bool InputFilter::Rule::handleEvent(const Event &event)
case Activate: case Activate:
actions = &m_activateActions; actions = &m_activateActions;
LOG((CLOG_DEBUG1 "activate actions")); LOG_DEBUG1("activate actions");
break; break;
case Deactivate: case Deactivate:
actions = &m_deactivateActions; actions = &m_deactivateActions;
LOG((CLOG_DEBUG1 "deactivate actions")); LOG_DEBUG1("deactivate actions");
break; break;
} }
// perform actions // perform actions
for (auto action : *actions) { for (auto action : *actions) {
LOG((CLOG_DEBUG1 "hotkey: %s", action->format().c_str())); LOG_DEBUG1("hotkey: %s", action->format().c_str());
action->perform(event); action->perform(event);
} }

View file

@ -215,7 +215,7 @@ std::string PrimaryClient::getSecureInputApp() const
void PrimaryClient::secureInputNotification(const std::string &app) const void PrimaryClient::secureInputNotification(const std::string &app) const
{ {
LOG((CLOG_INFO "application \"%s\" is blocking the keyboard", app.c_str())); LOG_INFO("application \"%s\" is blocking the keyboard", app.c_str());
} }
void PrimaryClient::resetOptions() void PrimaryClient::resetOptions()

View file

@ -136,7 +136,7 @@ Server::Server(
// Determine if scroll lock is already set. If so, lock the cursor to the // Determine if scroll lock is already set. If so, lock the cursor to the
// primary screen // primary screen
if (m_primaryClient->getToggleMask() & KeyModifierScrollLock) { if (m_primaryClient->getToggleMask() & KeyModifierScrollLock) {
LOG((CLOG_NOTE "scroll lock is on, locking cursor to screen")); LOG_NOTE("scroll lock is on, locking cursor to screen");
m_lockedToScreen = true; m_lockedToScreen = true;
} }
} }
@ -164,7 +164,7 @@ Server::~Server()
// force immediate disconnection of secondary clients // force immediate disconnection of secondary clients
disconnect(); disconnect();
} catch (std::exception &e) { // NOSONAR } catch (std::exception &e) { // NOSONAR
LOG((CLOG_ERR "failed to disconnect: %s", e.what())); LOG_ERR("failed to disconnect: %s", e.what());
} }
for (auto index = m_oldClients.begin(); index != m_oldClients.end(); ++index) { for (auto index = m_oldClients.begin(); index != m_oldClients.end(); ++index) {
@ -234,7 +234,7 @@ void Server::adoptClient(BaseClientProxy *client)
// name must be in our configuration // name must be in our configuration
if (!m_config->isScreen(client->getName())) { if (!m_config->isScreen(client->getName())) {
LOG((CLOG_WARN "unrecognised client name \"%s\", check server config", client->getName().c_str())); LOG_WARN("unrecognised client name \"%s\", check server config", client->getName().c_str());
closeClient(client, kMsgEUnknown); closeClient(client, kMsgEUnknown);
return; return;
} }
@ -242,11 +242,11 @@ void Server::adoptClient(BaseClientProxy *client)
// add client to client list // add client to client list
if (!addClient(client)) { if (!addClient(client)) {
// can only have one screen with a given name at any given time // can only have one screen with a given name at any given time
LOG((CLOG_WARN "a client with name \"%s\" is already connected", getName(client).c_str())); LOG_WARN("a client with name \"%s\" is already connected", getName(client).c_str());
closeClient(client, kMsgEBusy); closeClient(client, kMsgEBusy);
return; return;
} }
LOG((CLOG_NOTE "client \"%s\" has connected", getName(client).c_str())); LOG_NOTE("client \"%s\" has connected", getName(client).c_str());
// send configuration options to client // send configuration options to client
sendOptions(client); sendOptions(client);
@ -341,7 +341,7 @@ bool Server::isLockedToScreen() const
// locked if we say we're locked // locked if we say we're locked
if (isLockedToScreenServer()) { if (isLockedToScreenServer()) {
LOG((CLOG_NOTE "cursor is locked to screen, check scroll lock key")); LOG_NOTE("cursor is locked to screen, check scroll lock key");
return true; return true;
} }
@ -404,7 +404,7 @@ void Server::switchScreen(BaseClientProxy *dst, int32_t x, int32_t y, bool forSc
assert(m_active != nullptr); assert(m_active != nullptr);
LOG((CLOG_INFO "switch from \"%s\" to \"%s\" at %d,%d", getName(m_active).c_str(), getName(dst).c_str(), x, y)); LOG_INFO("switch from \"%s\" to \"%s\" at %d,%d", getName(m_active).c_str(), getName(dst).c_str(), x, y);
// stop waiting to switch // stop waiting to switch
stopSwitch(); stopSwitch();
@ -424,7 +424,7 @@ void Server::switchScreen(BaseClientProxy *dst, int32_t x, int32_t y, bool forSc
// 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_WARN("can't leave screen");
return; return;
} }
@ -558,7 +558,7 @@ BaseClientProxy *Server::getNeighbor(const BaseClientProxy *src, Direction dir,
// get source screen name // get source screen name
std::string srcName = getName(src); std::string srcName = getName(src);
assert(!srcName.empty()); assert(!srcName.empty());
LOG((CLOG_DEBUG2 "find neighbor on %s of \"%s\"", Config::dirName(dir), srcName.c_str())); LOG_DEBUG2("find neighbor on %s of \"%s\"", Config::dirName(dir), srcName.c_str());
// convert position to fraction // convert position to fraction
float t = mapToFraction(src, dir, x, y); float t = mapToFraction(src, dir, x, y);
@ -573,20 +573,20 @@ BaseClientProxy *Server::getNeighbor(const BaseClientProxy *src, Direction dir,
// progress in this direction. since we haven't found a // progress in this direction. since we haven't found a
// connected neighbor we return nullptr. // connected neighbor we return nullptr.
if (dstName.empty()) { if (dstName.empty()) {
LOG((CLOG_DEBUG2 "no neighbor on %s of \"%s\"", Config::dirName(dir), srcName.c_str())); LOG_DEBUG2("no neighbor on %s of \"%s\"", Config::dirName(dir), srcName.c_str());
return nullptr; return nullptr;
} }
// look up neighbor cell. if the screen is connected and // look up neighbor cell. if the screen is connected and
// ready then we can stop. // ready then we can stop.
if (ClientList::const_iterator index = m_clients.find(dstName); index != m_clients.end()) { if (ClientList::const_iterator index = m_clients.find(dstName); index != m_clients.end()) {
LOG((CLOG_DEBUG2 "\"%s\" is on %s of \"%s\" at %f", dstName.c_str(), Config::dirName(dir), srcName.c_str(), t)); LOG_DEBUG2("\"%s\" is on %s of \"%s\" at %f", dstName.c_str(), Config::dirName(dir), srcName.c_str(), t);
mapToPixel(index->second, dir, tTmp, x, y); mapToPixel(index->second, dir, tTmp, x, y);
return index->second; return index->second;
} }
// skip over unconnected screen // skip over unconnected screen
LOG((CLOG_DEBUG2 "ignored \"%s\" on %s of \"%s\"", dstName.c_str(), Config::dirName(dir), srcName.c_str())); LOG_DEBUG2("ignored \"%s\" on %s of \"%s\"", dstName.c_str(), Config::dirName(dir), srcName.c_str());
srcName = dstName; srcName = dstName;
// use position on skipped screen // use position on skipped screen
@ -630,7 +630,7 @@ BaseClientProxy *Server::mapToNeighbor(BaseClientProxy *src, Direction srcSide,
if (x >= 0) { if (x >= 0) {
break; break;
} }
LOG((CLOG_DEBUG2 "skipping over screen %s", getName(dst).c_str())); LOG_DEBUG2("skipping over screen %s", getName(dst).c_str());
dst = getNeighbor(lastGoodScreen, srcSide, x, y); dst = getNeighbor(lastGoodScreen, srcSide, x, y);
} }
assert(lastGoodScreen != nullptr); assert(lastGoodScreen != nullptr);
@ -646,7 +646,7 @@ BaseClientProxy *Server::mapToNeighbor(BaseClientProxy *src, Direction srcSide,
if (x < dw) { if (x < dw) {
break; break;
} }
LOG((CLOG_DEBUG2 "skipping over screen %s", getName(dst).c_str())); LOG_DEBUG2("skipping over screen %s", getName(dst).c_str());
dst = getNeighbor(lastGoodScreen, srcSide, x, y); dst = getNeighbor(lastGoodScreen, srcSide, x, y);
} }
assert(lastGoodScreen != nullptr); assert(lastGoodScreen != nullptr);
@ -662,7 +662,7 @@ BaseClientProxy *Server::mapToNeighbor(BaseClientProxy *src, Direction srcSide,
if (y >= 0) { if (y >= 0) {
break; break;
} }
LOG((CLOG_DEBUG2 "skipping over screen %s", getName(dst).c_str())); LOG_DEBUG2("skipping over screen %s", getName(dst).c_str());
dst = getNeighbor(lastGoodScreen, srcSide, x, y); dst = getNeighbor(lastGoodScreen, srcSide, x, y);
} }
assert(lastGoodScreen != nullptr); assert(lastGoodScreen != nullptr);
@ -678,7 +678,7 @@ BaseClientProxy *Server::mapToNeighbor(BaseClientProxy *src, Direction srcSide,
if (y < dh) { if (y < dh) {
break; break;
} }
LOG((CLOG_DEBUG2 "skipping over screen %s", getName(dst).c_str())); LOG_DEBUG2("skipping over screen %s", getName(dst).c_str());
dst = getNeighbor(lastGoodScreen, srcSide, x, y); dst = getNeighbor(lastGoodScreen, srcSide, x, y);
} }
assert(lastGoodScreen != nullptr); assert(lastGoodScreen != nullptr);
@ -753,13 +753,13 @@ bool Server::isSwitchOkay(
BaseClientProxy *newScreen, Direction dir, int32_t x, int32_t y, int32_t xActive, int32_t yActive BaseClientProxy *newScreen, Direction dir, int32_t x, int32_t y, int32_t xActive, int32_t yActive
) )
{ {
LOG((CLOG_DEBUG1 "try to leave \"%s\" on %s", getName(m_active).c_str(), Config::dirName(dir))); LOG_DEBUG1("try to leave \"%s\" on %s", getName(m_active).c_str(), Config::dirName(dir));
// is there a neighbor? // is there a neighbor?
if (newScreen == nullptr) { if (newScreen == nullptr) {
// there's no neighbor. we don't want to switch and we don't // there's no neighbor. we don't want to switch and we don't
// want to try to switch later. // want to try to switch later.
LOG((CLOG_DEBUG1 "no neighbor %s", Config::dirName(dir))); LOG_DEBUG1("no neighbor %s", Config::dirName(dir));
stopSwitch(); stopSwitch();
return false; return false;
} }
@ -816,7 +816,7 @@ bool Server::isSwitchOkay(
// see if we're in a locked corner // see if we're in a locked corner
if ((getCorner(m_active, xActive, yActive, size) & corners) != 0) { if ((getCorner(m_active, xActive, yActive, size) & corners) != 0) {
// yep, no switching // yep, no switching
LOG((CLOG_DEBUG1 "locked in corner")); LOG_DEBUG1("locked in corner");
preventSwitch = true; preventSwitch = true;
stopSwitch(); stopSwitch();
} }
@ -824,7 +824,7 @@ bool Server::isSwitchOkay(
// ignore if mouse is locked to screen and don't try to switch later // ignore if mouse is locked to screen and don't try to switch later
if (!preventSwitch && isLockedToScreen()) { if (!preventSwitch && isLockedToScreen()) {
LOG((CLOG_DEBUG1 "locked to screen")); LOG_DEBUG1("locked to screen");
preventSwitch = true; preventSwitch = true;
stopSwitch(); stopSwitch();
} }
@ -834,7 +834,7 @@ bool Server::isSwitchOkay(
!preventSwitch && ((this->m_switchNeedsShift && ((mods & KeyModifierShift) != KeyModifierShift)) || !preventSwitch && ((this->m_switchNeedsShift && ((mods & KeyModifierShift) != KeyModifierShift)) ||
(this->m_switchNeedsControl && ((mods & KeyModifierControl) != KeyModifierControl)) || (this->m_switchNeedsControl && ((mods & KeyModifierControl) != KeyModifierControl)) ||
(this->m_switchNeedsAlt && ((mods & KeyModifierAlt) != KeyModifierAlt)))) { (this->m_switchNeedsAlt && ((mods & KeyModifierAlt) != KeyModifierAlt)))) {
LOG((CLOG_DEBUG1 "need modifiers to switch")); LOG_DEBUG1("need modifiers to switch");
preventSwitch = true; preventSwitch = true;
stopSwitch(); stopSwitch();
} }
@ -863,7 +863,7 @@ void Server::startSwitchTwoTap()
m_switchTwoTapEngaged = true; m_switchTwoTapEngaged = true;
m_switchTwoTapArmed = false; m_switchTwoTapArmed = false;
m_switchTwoTapTimer.reset(); m_switchTwoTapTimer.reset();
LOG((CLOG_DEBUG1 "waiting for second tap")); LOG_DEBUG1("waiting for second tap");
} }
void Server::armSwitchTwoTap(int32_t x, int32_t y) void Server::armSwitchTwoTap(int32_t x, int32_t y)
@ -938,7 +938,7 @@ void Server::startSwitchWait(int32_t x, int32_t y)
m_switchWaitX = x; m_switchWaitX = x;
m_switchWaitY = y; m_switchWaitY = y;
m_switchWaitTimer = m_events->newOneShotTimer(m_switchWaitDelay, this); m_switchWaitTimer = m_events->newOneShotTimer(m_switchWaitDelay, this);
LOG((CLOG_DEBUG1 "waiting to switch")); LOG_DEBUG1("waiting to switch");
} }
void Server::stopSwitchWait() void Server::stopSwitchWait()
@ -1021,7 +1021,7 @@ void Server::stopRelativeMoves()
m_yDelta = 0; m_yDelta = 0;
m_xDelta2 = 0; m_xDelta2 = 0;
m_yDelta2 = 0; m_yDelta2 = 0;
LOG((CLOG_DEBUG2 "synchronize move on %s by %d,%d", getName(m_active).c_str(), m_x, m_y)); LOG_DEBUG2("synchronize move on %s by %d,%d", getName(m_active).c_str(), m_x, m_y);
m_active->mouseMove(m_x, m_y); m_active->mouseMove(m_x, m_y);
} }
} }
@ -1107,13 +1107,15 @@ void Server::processOptions()
} else if (id == kOptionClipboardSharing) { } else if (id == kOptionClipboardSharing) {
m_enableClipboard = value; m_enableClipboard = value;
if (!m_enableClipboard) { if (!m_enableClipboard) {
LOG((CLOG_NOTE "clipboard sharing is disabled")); LOG_NOTE("clipboard sharing is disabled");
} }
} else if (id == kOptionClipboardSharingSize) { } else if (id == kOptionClipboardSharingSize) {
if (value <= 0) { if (value <= 0) {
m_maximumClipboardSize = 0; m_maximumClipboardSize = 0;
LOG((CLOG_NOTE "clipboard sharing is disabled because the " LOG_NOTE(
"maximum shared clipboard size is set to 0")); "clipboard sharing is disabled because the "
"maximum shared clipboard size is set to 0"
);
} else { } else {
m_maximumClipboardSize = static_cast<size_t>(value); m_maximumClipboardSize = static_cast<size_t>(value);
} }
@ -1131,7 +1133,7 @@ void Server::handleShapeChanged(BaseClientProxy *client)
return; return;
} }
LOG((CLOG_DEBUG "screen \"%s\" shape changed", getName(client).c_str())); LOG_DEBUG("screen \"%s\" shape changed", getName(client).c_str());
// update jump coordinate // update jump coordinate
int32_t x; int32_t x;
@ -1273,7 +1275,7 @@ void Server::handleSwitchWaitTimeout()
{ {
// ignore if mouse is locked to screen // ignore if mouse is locked to screen
if (isLockedToScreen()) { if (isLockedToScreen()) {
LOG((CLOG_DEBUG1 "locked to screen")); LOG_DEBUG1("locked to screen");
stopSwitch(); stopSwitch();
return; return;
} }
@ -1295,7 +1297,7 @@ void Server::handleClientDisconnected(BaseClientProxy *client)
void Server::handleClientCloseTimeout(BaseClientProxy *client) void Server::handleClientCloseTimeout(BaseClientProxy *client)
{ {
// client took too long to disconnect. just dump it. // client took too long to disconnect. just dump it.
LOG((CLOG_NOTE "forced disconnection of client \"%s\"", getName(client).c_str())); LOG_NOTE("forced disconnection of client \"%s\"", getName(client).c_str());
removeOldClient(client); removeOldClient(client);
delete client; delete client;
@ -1307,7 +1309,7 @@ void Server::handleSwitchToScreenEvent(const Event &event)
ClientList::const_iterator index = m_clients.find(info->m_screen); ClientList::const_iterator index = m_clients.find(info->m_screen);
if (index == m_clients.end()) { if (index == m_clients.end()) {
LOG((CLOG_DEBUG1 "screen \"%s\" not active", info->m_screen)); LOG_DEBUG1("screen \"%s\" not active", info->m_screen);
} else { } else {
jumpToScreen(index->second); jumpToScreen(index->second);
} }
@ -1322,7 +1324,7 @@ void Server::handleSwitchInDirectionEvent(const Event &event)
int32_t y = m_y; int32_t y = m_y;
BaseClientProxy *newScreen = getNeighbor(m_active, info->m_direction, x, y); BaseClientProxy *newScreen = getNeighbor(m_active, info->m_direction, x, y);
if (newScreen == nullptr) { if (newScreen == nullptr) {
LOG((CLOG_DEBUG1 "no neighbor %s", Config::dirName(info->m_direction))); LOG_DEBUG1("no neighbor %s", Config::dirName(info->m_direction));
} else { } else {
jumpToScreen(newScreen); jumpToScreen(newScreen);
} }
@ -1384,7 +1386,7 @@ void Server::handleLockCursorToScreenEvent(const Event &event)
// enter new state // enter new state
if (newState != m_lockedToScreen) { if (newState != m_lockedToScreen) {
m_lockedToScreen = newState; m_lockedToScreen = newState;
LOG((CLOG_NOTE "cursor %s current screen", m_lockedToScreen ? "locked to" : "unlocked from")); LOG_NOTE("cursor %s current screen", m_lockedToScreen ? "locked to" : "unlocked from");
m_primaryClient->reconfigure(getActivePrimarySides()); m_primaryClient->reconfigure(getActivePrimarySides());
if (!isLockedToScreenServer()) { if (!isLockedToScreenServer()) {
@ -1440,7 +1442,7 @@ void Server::onClipboardChanged(const BaseClientProxy *sender, ClipboardID id, u
void Server::onScreensaver(bool activated) void Server::onScreensaver(bool activated)
{ {
LOG((CLOG_DEBUG "onScreenSaver %s", activated ? "activated" : "deactivated")); LOG_DEBUG("onScreenSaver %s", activated ? "activated" : "deactivated");
if (activated) { if (activated) {
// save current screen and position // save current screen and position
@ -1493,7 +1495,7 @@ void Server::onScreensaver(bool activated)
void Server::onKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang, const char *screens) void Server::onKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang, const char *screens)
{ {
LOG((CLOG_DEBUG1 "onKeyDown id=%d mask=0x%04x button=0x%04x lang=%s", id, mask, button, lang.c_str())); LOG_DEBUG1("onKeyDown id=%d mask=0x%04x button=0x%04x lang=%s", id, mask, button, lang.c_str());
assert(m_active != nullptr); assert(m_active != nullptr);
// relay // relay
@ -1516,7 +1518,7 @@ void Server::onKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const s
void Server::onKeyUp(KeyID id, KeyModifierMask mask, KeyButton button, const char *screens) void Server::onKeyUp(KeyID id, KeyModifierMask mask, KeyButton button, const char *screens)
{ {
LOG((CLOG_DEBUG1 "onKeyUp id=%d mask=0x%04x button=0x%04x", id, mask, button)); LOG_DEBUG1("onKeyUp id=%d mask=0x%04x button=0x%04x", id, mask, button);
assert(m_active != nullptr); assert(m_active != nullptr);
// relay // relay
@ -1551,7 +1553,7 @@ void Server::onKeyRepeat(KeyID id, KeyModifierMask mask, int32_t count, KeyButto
void Server::onMouseDown(ButtonID id) void Server::onMouseDown(ButtonID id)
{ {
LOG((CLOG_DEBUG1 "onMouseDown id=%d", id)); LOG_DEBUG1("onMouseDown id=%d", id);
assert(m_active != nullptr); assert(m_active != nullptr);
// relay // relay
@ -1560,7 +1562,7 @@ void Server::onMouseDown(ButtonID id)
void Server::onMouseUp(ButtonID id) void Server::onMouseUp(ButtonID id)
{ {
LOG((CLOG_DEBUG1 "onMouseUp id=%d", id)); LOG_DEBUG1("onMouseUp id=%d", id);
assert(m_active != nullptr); assert(m_active != nullptr);
// relay // relay
@ -1569,7 +1571,7 @@ void Server::onMouseUp(ButtonID id)
bool Server::onMouseMovePrimary(int32_t x, int32_t y) bool Server::onMouseMovePrimary(int32_t x, int32_t y)
{ {
LOG((CLOG_DEBUG4 "onMouseMovePrimary %d,%d", x, y)); LOG_DEBUG4("onMouseMovePrimary %d,%d", x, y);
// mouse move on primary (server's) screen // mouse move on primary (server's) screen
if (m_active != m_primaryClient) { if (m_active != m_primaryClient) {
@ -1695,7 +1697,7 @@ void Server::onMouseMoveSecondary(int32_t dx, int32_t dy)
// program on the secondary screen to warp the mouse on us, so we // program on the secondary screen to warp the mouse on us, so we
// have no idea where it really is. // have no idea where it really is.
if (m_relativeMoves && isLockedToScreenServer()) { if (m_relativeMoves && isLockedToScreenServer()) {
LOG((CLOG_DEBUG2 "relative move on %s by %d,%d", getName(m_active).c_str(), dx, dy)); LOG_DEBUG2("relative move on %s by %d,%d", getName(m_active).c_str(), dx, dy);
m_active->mouseRelativeMove(dx, dy); m_active->mouseRelativeMove(dx, dy);
return; return;
} }
@ -1815,22 +1817,22 @@ void Server::onMouseMoveSecondary(int32_t dx, int32_t dy)
m_y = yOld + dy; m_y = yOld + dy;
if (m_x < ax) { if (m_x < ax) {
m_x = ax; m_x = ax;
LOG((CLOG_DEBUG2 "clamp to left of \"%s\"", getName(m_active).c_str())); LOG_DEBUG2("clamp to left of \"%s\"", getName(m_active).c_str());
} else if (m_x > ax + aw - 1) { } else if (m_x > ax + aw - 1) {
m_x = ax + aw - 1; m_x = ax + aw - 1;
LOG((CLOG_DEBUG2 "clamp to right of \"%s\"", getName(m_active).c_str())); LOG_DEBUG2("clamp to right of \"%s\"", getName(m_active).c_str());
} }
if (m_y < ay) { if (m_y < ay) {
m_y = ay; m_y = ay;
LOG((CLOG_DEBUG2 "clamp to top of \"%s\"", getName(m_active).c_str())); LOG_DEBUG2("clamp to top of \"%s\"", getName(m_active).c_str());
} else if (m_y > ay + ah - 1) { } else if (m_y > ay + ah - 1) {
m_y = ay + ah - 1; m_y = ay + ah - 1;
LOG((CLOG_DEBUG2 "clamp to bottom of \"%s\"", getName(m_active).c_str())); LOG_DEBUG2("clamp to bottom of \"%s\"", getName(m_active).c_str());
} }
// warp cursor if it moved. // warp cursor if it moved.
if (m_x != xOld || m_y != yOld) { if (m_x != xOld || m_y != yOld) {
LOG((CLOG_DEBUG2 "move on %s to %d,%d", getName(m_active).c_str(), m_x, m_y)); LOG_DEBUG2("move on %s to %d,%d", getName(m_active).c_str(), m_x, m_y);
m_active->mouseMove(m_x, m_y); m_active->mouseMove(m_x, m_y);
} }
} }
@ -1838,7 +1840,7 @@ void Server::onMouseMoveSecondary(int32_t dx, int32_t dy)
void Server::onMouseWheel(int32_t xDelta, int32_t yDelta) void Server::onMouseWheel(int32_t xDelta, int32_t yDelta)
{ {
LOG((CLOG_DEBUG1 "onMouseWheel %+d,%+d", xDelta, yDelta)); LOG_DEBUG1("onMouseWheel %+d,%+d", xDelta, yDelta);
assert(m_active != nullptr); assert(m_active != nullptr);
// relay // relay
@ -1913,7 +1915,7 @@ void Server::closeClient(BaseClientProxy *client, const char *msg)
// note that this method also works on clients that are not in // note that this method also works on clients that are not in
// the m_clients list. adoptClient() may call us with such a // the m_clients list. adoptClient() may call us with such a
// client. // client.
LOG((CLOG_NOTE "disconnecting client \"%s\"", getName(client).c_str())); LOG_NOTE("disconnecting client \"%s\"", getName(client).c_str());
// send message // send message
// FIXME -- avoid type cast (kinda hard, though) // FIXME -- avoid type cast (kinda hard, though)

View file

@ -123,7 +123,7 @@ bool OSXKeyStateTests::isKeyPressed(const OSXKeyState &keyState, KeyButton butto
IKeyState::KeyButtonSet::const_iterator it; IKeyState::KeyButtonSet::const_iterator it;
for (it = pressed.begin(); it != pressed.end(); ++it) { for (it = pressed.begin(); it != pressed.end(); ++it) {
LOG((CLOG_DEBUG "checking key %d", *it)); LOG_DEBUG("checking key %d", *it);
if (*it == button) { if (*it == button) {
return true; return true;
} }