OpenCPN Partial API docs
DbusServer Class Reference

Basic interface to low-level DBus library. More...

#include <dbus_server.h>

Inheritance diagram for DbusServer:
LocalServerApi InstanceCheck

Public Member Functions

 DbusServer (DbusServer &)=delete
 
void operator= (const DbusServer &)=delete
 
void WaitUntilValid () override
 Wait until ready. More...
 
bool IsMainInstance ()
 Check if this instance is the only one. More...
 
void SetMainInstance (bool value)
 
DbusServerUnitTestInstance ()
 
- Public Member Functions inherited from LocalServerApi
virtual void SetGetRestApiEndpointCb (std::function< std::string()> cb)
 Set callback returning the rest server root endpoint.
 
- Public Member Functions inherited from InstanceCheck
virtual void CleanUp ()
 Remove all persistent instance state, including possible lock file and defunct opencpn processes.
 
virtual void OnExit ()
 Do whatever needed before wxWidget's checks triggers.
 

Static Public Member Functions

static DbusServerGetInstance ()
 
static void Disconnect ()
 Clear current singleton instance and disconnect from session bus.
 
- Static Public Member Functions inherited from LocalServerApi
static LocalServerApiGetInstance ()
 
static void ReleaseInstance ()
 Release Instance.
 
- Static Public Member Functions inherited from InstanceCheck
static InstanceCheckGetInstance ()
 

Public Attributes

GDBusNodeInfo * introspection_data
 Callback context.
 
- Public Attributes inherited from LocalServerApi
EventVar on_raise
 Notified on the Raise command.
 
EventVar on_quit
 Notified on the Quit command.
 
std::function< bool(const std::string &)> open_file_cb
 Callback invoked on open command with a file path argument.
 
std::function< std::string()> get_rest_api_endpoint_cb
 

Detailed Description

Basic interface to low-level DBus library.

The server is started by the first call to GetInstance(). The server bith acts as a regular LocalApiServer and as an InstanceCheckinstance check.

Definition at line 94 of file dbus_server.h.

Member Function Documentation

◆ IsMainInstance()

bool DbusServer::IsMainInstance ( )
inlinevirtual

Check if this instance is the only one.

Returns
true if ctor was able to claim kDbusName, else false.

Implements InstanceCheck.

Definition at line 129 of file dbus_server.h.

◆ WaitUntilValid()

void DbusServer::WaitUntilValid ( )
overridevirtual

Wait until ready.

There is no signal for "ready", so the strategy is to just wait for some time, allowing the underlying layers to perform the dbus handshake. If we have claimed the bus name after this time we are a server, else a client.

TODO: Some clever algorithm to define processor speed which could be used to determine the wait time. On my fast development machine 200 us is enough in native Linux, but Flatpak requires longer time.

TODO: Some kind of lazy evalution to avoid delays?

Reimplemented from InstanceCheck.

Definition at line 154 of file dbus_server.cpp.


The documentation for this class was generated from the following files: