24#ifndef DBUS_HANDLER_H_
25#define DBUS_HANDLER_H_
38static const char*
const kDbusName =
"org.opencpn.OpenCPN";
41static const char*
const kDbusObject =
"/org/opencpn/OpenCPN";
44static const char*
const kDbusInterface =
"opencpn.desktop";
47static const gchar introspection_xml[] = R
"""(
49 <interface name='opencpn.desktop'>
50 <annotation name='org.gtk.GDBus.Annotation' value='OnInterface'/>
51 <annotation name='org.gtk.GDBus.Annotation' value='AlsoOnInterface'/>
53 <annotation name='org.gtk.GDBus.Annotation' value='OnMethod'/>
54 <arg type='u' name='level' direction='out'/>
55 <arg type='b' name='stat' direction='out'/>
58 <annotation name='org.gtk.GDBus.Annotation' value='OnMethod'/>
59 <!-- In the GUI case, raise application to top. -->
62 <annotation name='org.gtk.GDBus.Annotation' value='OnMethod'/>
63 <arg type='s' name='level' direction='in'/>
64 <arg type='b' name='stat' direction='out'/>
66 <method name='GetRestEndpoint'>
67 <annotation name='org.gtk.GDBus.Annotation' value='OnMethod'/>
68 <arg type='s' name='endpoint' direction='out'/>
71 <annotation name='org.gtk.GDBus.Annotation' value='OnMethod'/>
78static void HandleMethodCall(GDBusConnection* connection,
const gchar* sender,
79 const gchar* object_path,
80 const gchar* interface_name,
81 const gchar* method_name, GVariant* parameters,
82 GDBusMethodInvocation* invocation,
99 DbusServer(DbusServer&) =
delete;
100 void operator=(
const DbusServer&) =
delete;
102 virtual ~DbusServer();
128 void SetMainInstance(
bool value) { m_is_main_instance = value; }
130 DbusServer* UnitTestInstance() {
return new DbusServer(); }
136 static DbusServer* s_instance;
137 bool m_is_main_instance;
GDBusNodeInfo * introspection_data
Callback context.
static void Disconnect()
Clear current singleton instance and disconnect from session bus.
void WaitUntilValid() override
Wait until ready.
bool IsMainInstance()
Check if this instance is the only one.
Common interface for all instance checkers.
static InstanceCheck & GetInstance()
A common variable shared between producer and consumer which supports Listen() and Notify().
Instance check interface.
The local API has a server side handling commands and a client part issuing commands.