Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cwd": "${workspaceRoot}",
"request": "launch",
"program": "${workspaceFolder}/build/bin/unittests",
"args": [ "${input:gtest-args}" ],
"args": ["${input:gtest-args}"],
"preLaunchTask": "build-silent"
},
{
Expand All @@ -24,8 +24,8 @@
"cwd": "${workspaceRoot}",
"request": "launch",
"program": "${workspaceFolder}/build/bin/integtests",
"args": [ "${input:gtest-args}" ],
"preLaunchTask": "build-silent",
"args": ["${input:gtest-args}"],
"preLaunchTask": "build-silent"
},
{
"name": "unix - server",
Expand Down Expand Up @@ -69,13 +69,22 @@
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "build-kill-gui"
},
{
"name": "windows - version",
"type": "cppvsdbg",
"cwd": "${workspaceRoot}",
"request": "launch",
"program": "${workspaceFolder}/build/bin-copy/synergy-core",
"args": ["--version"],
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "windows - unittests",
"type": "cppvsdbg",
"cwd": "${workspaceRoot}",
"request": "launch",
"program": "${workspaceFolder}/build/bin-copy/unittests",
"args": [ "${input:gtest-args}" ],
"args": ["${input:gtest-args}"],
"internalConsoleOptions": "openOnSessionStart"
},
{
Expand All @@ -84,7 +93,7 @@
"cwd": "${workspaceRoot}",
"request": "launch",
"program": "${workspaceFolder}/build/bin-copy/integtests",
"args": [ "${input:gtest-args}" ],
"args": ["${input:gtest-args}"],
"internalConsoleOptions": "openOnSessionStart"
},
{
Expand Down Expand Up @@ -161,7 +170,7 @@
"name": "windows - attach",
"type": "cppvsdbg",
"request": "attach",
"processId": "${command:pickProcess}",
"processId": "${command:pickProcess}"
}
],
"inputs": [
Expand Down
8 changes: 8 additions & 0 deletions src/apps/deskflow-core/deskflow-core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ int main(int argc, char **argv)
Log log;
EventQueue events;

// No need to start server/client just to show version.
for (int i = 1; i < argc; ++i) {
if (std::string(argv[i]) == "--version" || std::string(argv[i]) == "-v") {
printVersion(ARCH->getBasename(argv[0]));
return 0;
}
}

if (isServer(argc, argv)) {
ServerApp app(&events, nullptr);
return app.run(argc, argv);
Expand Down
31 changes: 20 additions & 11 deletions src/lib/deskflow/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ using namespace deskflow;

App *App::s_instance = nullptr;

//
// Free functions
//

void printVersion(const char *processName)
{
const auto version = deskflow::version();
const auto copyright = deskflow::copyright();

const auto kBufferLength = 1024;
std::vector<char> buffer(kBufferLength);
std::snprintf( // NOSONAR
buffer.data(), kBufferLength, "%s v%s, protocol v%d.%d\n%s", //
processName, version.c_str(), kProtocolMajorVersion, kProtocolMinorVersion, copyright.c_str()
);

std::cout << std::string(buffer.data()) << std::endl;
}

//
// App
//
Expand Down Expand Up @@ -97,17 +116,7 @@ App::~App()

void App::version()
{
const auto version = deskflow::version();
const auto copyright = deskflow::copyright();

const auto kBufferLength = 1024;
std::vector<char> buffer(kBufferLength);
std::snprintf( // NOSONAR
buffer.data(), kBufferLength, "%s v%s, protocol v%d.%d\n%s", //
argsBase().m_pname, version.c_str(), kProtocolMajorVersion, kProtocolMinorVersion, copyright.c_str()
);

std::cout << std::string(buffer.data()) << std::endl;
printVersion(argsBase().m_pname);
}

int App::run(int argc, char **argv)
Expand Down
7 changes: 5 additions & 2 deletions src/lib/deskflow/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ class IArchTaskBarReceiver;
class BufferedLogOutputter;
class ILogOutputter;
class FileLogOutputter;
class IEventQueue;
class SocketMultiplexer;

namespace deskflow {
class Screen;
}
class IEventQueue;
class SocketMultiplexer;

typedef IArchTaskBarReceiver *(*CreateTaskBarReceiverFunc)(const BufferedLogOutputter *, IEventQueue *events);

void printVersion(const char *processName);

class App : public IApp
{
public:
Expand Down
Loading