mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-06 08:55:34 +00:00
Gentoo doesn't use systemd. `libelogind` or `basu` implement some aspects of systemd, so we use that on Gentoo (or rather when `libsystemd` is not available but `libelogind` or `basu` is). Patch from https://forums.gentoo.org/viewtopic.php?p=8850566. See also https://community.software.sil.org/t/keyman-for-gentoo-linux/9615. Cherry-pick-of: #12889
63 lines
1.3 KiB
C++
63 lines
1.3 KiB
C++
// Call the Exit method on the km-dbus-test-server. Remember to source
|
|
// `/tmp/km-test-server.env` prior to running stop-test-server in order
|
|
// to run on our non-standard DBus.
|
|
#include "config.h"
|
|
#include <iostream>
|
|
#if DBUS_IMPLEMENTATION == SYSTEMD
|
|
#include <systemd/sd-bus.h>
|
|
#else
|
|
#include <basu/sd-bus.h>
|
|
#endif
|
|
|
|
using namespace std;
|
|
|
|
class StopTestServer
|
|
{
|
|
private:
|
|
sd_bus_error* error = NULL;
|
|
sd_bus_message* msg = NULL;
|
|
sd_bus* bus = NULL;
|
|
|
|
public:
|
|
StopTestServer();
|
|
~StopTestServer();
|
|
|
|
int Run();
|
|
};
|
|
|
|
StopTestServer::StopTestServer()
|
|
{
|
|
}
|
|
|
|
StopTestServer::~StopTestServer()
|
|
{
|
|
if (error) { sd_bus_error_free(error); }
|
|
if (msg) { sd_bus_message_unref(msg); }
|
|
if (bus) { sd_bus_unref(bus); }
|
|
}
|
|
|
|
int StopTestServer::Run()
|
|
{
|
|
int result;
|
|
|
|
result = sd_bus_open_user(&bus);
|
|
if (result < 0) {
|
|
std::cerr << "Can't get connection: " << strerror(-result) << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
result = sd_bus_call_method(bus, "com.keyman.ExitTestService",
|
|
"/com/keyman/ExitTestService/Exit", "com.keyman.ExitTestService.Exit",
|
|
"Exit", error, &msg, "");
|
|
if (result < 0) {
|
|
std::cerr << "Failed to issue method call: " << strerror(-result) << std::endl;
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
main(int argc, char* argv[]) {
|
|
StopTestServer stopServer;
|
|
return stopServer.Run();
|
|
}
|