Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
Burger::Unix::DBusInstance Class Reference

Handler for a dbus session. More...

Public Member Functions

 DBusInstance () BURGER_NOEXCEPT
 Initialize internal values.
 
 ~DBusInstance () BURGER_NOEXCEPT
 Release the connection.
 
BURGER_INLINE DBusConnectionget_system (void) const BURGER_NOEXCEPT
 Return the dbus system connection.
 
BURGER_INLINE DBusConnectionget_session (void) const BURGER_NOEXCEPT
 Return the dbus session connection.
 
eError init (void) BURGER_NOEXCEPT
 Start up a dbus connection.
 
void shutdown (void) BURGER_NOEXCEPT
 Release the connection.
 
uint_t send_and_receive (const char *pBusName, const char *pPath, const char *pInterface, const char *pMethod,...) BURGER_NOEXCEPT
 Send and receive a message using a dbug connection.
 
uint_t send_message (const char *pBusName, const char *pPath, const char *pInterface, const char *pMethod,...) BURGER_NOEXCEPT
 Send a message using a dbug connection.
 
uint_t query_object (const char *pBusName, const char *pPath, const char *pInterface, const char *pObject, const int iType, void *pOutput) BURGER_NOEXCEPT
 Get a property object from "org.freedesktop.DBus.Properties".
 
void x11_screen_saver_poll (void) BURGER_NOEXCEPT
 Send a message to screen savers to keep them disabled.
 
uint_t x11_screen_saver_disable (uint_t bDisable) BURGER_NOEXCEPT
 Enable/disable the screen saver.
 

Static Public Member Functions

static uint_t send_and_receive (DBusConnection *pConnection, const char *pBusName, const char *pPath, const char *pInterface, const char *pMethod,...) BURGER_NOEXCEPT
 Send and receive a message using a dbug connection.
 
static uint_t send_message (DBusConnection *pConnection, const char *pBusName, const char *pPath, const char *pInterface, const char *pMethod,...) BURGER_NOEXCEPT
 Send a message using a dbug connection.
 
static uint_t query_object (DBusConnection *pConnection, const char *pBusName, const char *pPath, const char *pInterface, const char *pObject, const int iType, void *pOutput) BURGER_NOEXCEPT
 Get a property object from "org.freedesktop.DBus.Properties".
 

Static Public Attributes

static const int kTimeout = 333
 Message timeout in milliseconds.
 

Static Protected Member Functions

static uint_t send_and_receive (DBusConnection *pConnection, const char *pBusName, const char *pPath, const char *pInterface, const char *pMethod, va_list pArgList) BURGER_NOEXCEPT
 Internal function to send and receive a message.
 
static uint_t send_message (DBusConnection *pConnection, const char *pBusName, const char *pPath, const char *pInterface, const char *pMethod, va_list pArgList) BURGER_NOEXCEPT
 Internal function to send a message.
 
static uint_t send_and_receive (DBusConnection *pConnection, DBusMessage *pMessage, const int iType, void *pOutput) BURGER_NOEXCEPT
 Internal function to send and receive a message.
 
static uint_t add_key_value (DBusMessageIter *iterInit, const char *key, const char *value) BURGER_NOEXCEPT
 Update a dictionary with a value.
 

Protected Attributes

DBusConnectionm_pSystem
 DBus system connection.
 
DBusConnectionm_pSession
 DBus session connection.
 
charm_pDisableObject
 String for the screen saver disable.
 
uint32_t m_uScreenSaverToken
 Screen saver token from X11.
 
uint_t m_bScreenSaverDisable
 Set to true to disable the screen saver.
 

Private Member Functions

 BURGER_DISABLE_COPY (DBusInstance)
 

Detailed Description

Handler for a dbus session.


This class handles the loading of the dbus library (If available) and create and manage a connection to dbus.

Constructor & Destructor Documentation

◆ DBusInstance()

Burger::Unix::DBusInstance::DBusInstance ( )

Initialize internal values.


Initialize variables to power up states.

See also
init()

◆ ~DBusInstance()

Burger::Unix::DBusInstance::~DBusInstance ( )

Release the connection.


Call shutdown() to ensure the dbus connection, if any, is properly released.

See also
shutdown()

Member Function Documentation

◆ add_key_value()

uint_t Burger::Unix::DBusInstance::add_key_value ( DBusMessageIter * pRoot,
const char * pKey,
const char * pInput )
staticprotected

Update a dictionary with a value.


Given an iterator for a DBusMessage, add a data string attached to a key.

Parameters
pRootDictionary root pointer
pKeyPointer to "C" string for the database key
pInputPointer to "C" string for the data to attach to the key
Returns
TRUE on success, FALSE on failure

◆ BURGER_DISABLE_COPY()

Burger::Unix::DBusInstance::BURGER_DISABLE_COPY ( DBusInstance )
private

◆ get_session()

Burger::Unix::DBusInstance::get_session ( void ) const
inline

Return the dbus session connection.


Returns
nullptr or a valid dbus connection pointer
See also
get_system() const

◆ get_system()

Burger::Unix::DBusInstance::get_system ( void ) const
inline

Return the dbus system connection.


Returns
nullptr or a valid dbus connection pointer
See also
get_session() const

◆ init()

Burger::eError Burger::Unix::DBusInstance::init ( void )

Start up a dbus connection.


Ensure that dbus is present on the platform and if so, initialize the sessions.

See also
shutdown()

◆ query_object() [1/2]

uint_t Burger::Unix::DBusInstance::query_object ( const char * pBusName,
const char * pPath,
const char * pInterface,
const char * pObject,
const int iType,
void * pOutput )

Get a property object from "org.freedesktop.DBus.Properties".


Using dbus via the default session, query "org.freedesktop.DBus.Properties" for the requested object.

Parameters
pBusNamePointer to "C" string of the bus to talk to
pPathPointer to "C" string to path
pInterfacePointer to "C" string to interface
pObjectPointer to "C" string of object to query
iTypeType of object to obtain
pOutputPointer to a buffer to get a copy of the object
Returns
TRUE if successful

◆ query_object() [2/2]

uint_t Burger::Unix::DBusInstance::query_object ( DBusConnection * pConnection,
const char * pBusName,
const char * pPath,
const char * pInterface,
const char * pObject,
const int iType,
void * pOutput )
static

Get a property object from "org.freedesktop.DBus.Properties".


Using dbus, query "org.freedesktop.DBus.Properties" for the requested object.

Parameters
pConnectionPointer to active connection
pBusNamePointer to "C" string of the bus to talk to
pPathPointer to "C" string to path
pInterfacePointer to "C" string to interface
pObjectPointer to "C" string of object to query
iTypeType of object to obtain
pOutputPointer to a buffer to get a copy of the object
Returns
TRUE if successful

◆ send_and_receive() [1/4]

uint_t Burger::Unix::DBusInstance::send_and_receive ( const char * pBusName,
const char * pPath,
const char * pInterface,
const char * pMethod,
... )

Send and receive a message using a dbug connection.


Send a message on dbus and get the answer from the default session.

See https://dbus.freedesktop.org/doc/api/html/group__DBusMessage.html#ga98ddc82450d818138ef326a284201ee0

Parameters
pBusNamePointer to "C" string of the bus to talk to
pPathPointer to "C" string to path
pInterfacePointer to "C" string to interface
pMethodPointer to "C" string of method to call
...Argument list to send to the method
Returns
TRUE if successful
See also
send_and_receive(DBusConnection*, const char*, const char*, const char*, const char*, va_list)

◆ send_and_receive() [2/4]

uint_t Burger::Unix::DBusInstance::send_and_receive ( DBusConnection * pConnection,
const char * pBusName,
const char * pPath,
const char * pInterface,
const char * pMethod,
va_list pArgList )
staticprotected

Internal function to send and receive a message.


Send a message on dbus and get the answer. If the connection is nullptr, do nothing and return FALSE

See https://dbus.freedesktop.org/doc/api/html/group__DBusMessage.html#ga98ddc82450d818138ef326a284201ee0

Parameters
pConnectionPointer to active connection
pBusNamePointer to "C" string of the bus to talk to
pPathPointer to "C" string to path
pInterfacePointer to "C" string to interface
pMethodPointer to "C" string of method to call
pArgListArgument list to send to the method
Returns
TRUE if successful

◆ send_and_receive() [3/4]

uint_t Burger::Unix::DBusInstance::send_and_receive ( DBusConnection * pConnection,
const char * pBusName,
const char * pPath,
const char * pInterface,
const char * pMethod,
... )
static

Send and receive a message using a dbug connection.


Send a message on dbus and get the answer. If the connection is nullptr, do nothing and return FALSE

See https://dbus.freedesktop.org/doc/api/html/group__DBusMessage.html#ga98ddc82450d818138ef326a284201ee0

Parameters
pConnectionPointer to active connection
pBusNamePointer to "C" string of the bus to talk to
pPathPointer to "C" string to path
pInterfacePointer to "C" string to interface
pMethodPointer to "C" string of method to call
...Argument list to send to the method
Returns
TRUE if successful
See also
send_and_receive(DBusConnection*, const char*, const char*, const char*, const char*, va_list)

◆ send_and_receive() [4/4]

uint_t Burger::Unix::DBusInstance::send_and_receive ( DBusConnection * pConnection,
DBusMessage * pMessage,
const int iType,
void * pOutput )
staticprotected

Internal function to send and receive a message.


Send a message on dbus and get the answer. If the connection is nullptr, do nothing and return FALSE\

Parameters
pConnectionPointer to active connection
pMessageDBusMessage to send
iTypeType of data to receive
pOutputPointer to buffer to receive the data
Returns
TRUE if successful

◆ send_message() [1/3]

uint_t Burger::Unix::DBusInstance::send_message ( const char * pBusName,
const char * pPath,
const char * pInterface,
const char * pMethod,
... )

Send a message using a dbug connection.


Send a message on dbus on the default session.

See https://dbus.freedesktop.org/doc/api/html/group__DBusMessage.html#ga98ddc82450d818138ef326a284201ee0

Parameters
pBusNamePointer to "C" string of the bus to talk to
pPathPointer to "C" string to path
pInterfacePointer to "C" string to interface
pMethodPointer to "C" string of method to call
...Argument list to send to the method
Returns
TRUE if successful
See also
send_message(DBusConnection*, const char*, const char*, const char*, const char*, va_list)

◆ send_message() [2/3]

uint_t Burger::Unix::DBusInstance::send_message ( DBusConnection * pConnection,
const char * pBusName,
const char * pPath,
const char * pInterface,
const char * pMethod,
va_list pArgList )
staticprotected

Internal function to send a message.


Send a message on dbus. If the connection is nullptr, do nothing and return FALSE

See https://dbus.freedesktop.org/doc/api/html/group__DBusMessage.html#ga98ddc82450d818138ef326a284201ee0

Parameters
pConnectionPointer to active connection
pBusNamePointer to "C" string of the bus to talk to
pPathPointer to "C" string to path
pInterfacePointer to "C" string to interface
pMethodPointer to "C" string of method to call
pArgListArgument list to send to the method
Returns
TRUE if successful

◆ send_message() [3/3]

uint_t Burger::Unix::DBusInstance::send_message ( DBusConnection * pConnection,
const char * pBusName,
const char * pPath,
const char * pInterface,
const char * pMethod,
... )
static

Send a message using a dbug connection.


Send a message on dbus. If the connection is nullptr, do nothing and return FALSE

See https://dbus.freedesktop.org/doc/api/html/group__DBusMessage.html#ga98ddc82450d818138ef326a284201ee0

Parameters
pConnectionPointer to active connection
pBusNamePointer to "C" string of the bus to talk to
pPathPointer to "C" string to path
pInterfacePointer to "C" string to interface
pMethodPointer to "C" string of method to call
...Argument list to send to the method
Returns
TRUE if successful
See also
send_message(DBusConnection*, const char*, const char*, const char*, const char*, va_list)

◆ shutdown()

void Burger::Unix::DBusInstance::shutdown ( void )

Release the connection.


If there was any connection, release it.

See also
init()

◆ x11_screen_saver_disable()

uint_t Burger::Unix::DBusInstance::x11_screen_saver_disable ( uint_t bDisable)

Enable/disable the screen saver.


On linux systems, the freedesktop window system supports messages that will enable and disable the activation of the screen saver. This function will enable Burgerlib to turn on or off this feature.

Note
This is only available on Linux platforms
Parameters
bDisableTRUE to disable the screen saver
Returns
TRUE on success, FALSE on failure

◆ x11_screen_saver_poll()

void Burger::Unix::DBusInstance::x11_screen_saver_poll ( void )

Send a message to screen savers to keep them disabled.


If the feature is not turned off, send a dbus message to gnome and freedesktop to let the know that the screen saver should not activate

Member Data Documentation

◆ kTimeout

const int Burger::Unix::DBusInstance::kTimeout = 333
static

Message timeout in milliseconds.

◆ m_bScreenSaverDisable

uint_t Burger::Unix::DBusInstance::m_bScreenSaverDisable
protected

Set to true to disable the screen saver.

◆ m_pDisableObject

char* Burger::Unix::DBusInstance::m_pDisableObject
protected

String for the screen saver disable.

◆ m_pSession

DBusConnection* Burger::Unix::DBusInstance::m_pSession
protected

DBus session connection.

◆ m_pSystem

DBusConnection* Burger::Unix::DBusInstance::m_pSystem
protected

DBus system connection.

◆ m_uScreenSaverToken

uint32_t Burger::Unix::DBusInstance::m_uScreenSaverToken
protected

Screen saver token from X11.