Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions

# Gio::DBusServer Class Reference
[D-Bus API]

DBusServer - Helper for accepting connections. More...

`#include <giomm/dbusserver.h>`

Inheritance diagram for Gio::DBusServer:
[legend]

List of all members.

## Public Member Functions
virtual | ~DBusServer ()
GDBusServer* | gobj ()
| Provides access to the underlying C GObject.
const GDBusServer* | gobj () const
| Provides access to the underlying C GObject.
GDBusServer* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void | start ()
| Starts server.
void | stop ()
| Stops server.
bool | is_active () const
| Gets whether server is active.
Glib::ustring | get_guid () const
| Gets the GUID for server.
DBusServerFlags | get_flags () const
| Gets the flags for server.
Glib::ustring | get_client_address () const
| Gets a D-Bus address string that can be used by clients to connect to server.
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_active () const
| Whether the server is currently active.
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_address () const
| The address to listen on.
Glib::PropertyProxy_ReadOnly < Glib::RefPtr < DBusAuthObserver > > | property_authentication_observer () const
| Object used to assist in the authentication process.
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_client_address () const
| The address clients can use.
Glib::PropertyProxy_ReadOnly < DBusServerFlags > | property_flags () const
| Flags for the server.
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_guid () const
| The guid of the server.
Glib::SignalProxy1< bool, const Glib::RefPtr < DBusConnection >& > | signal_new_connection ()
## Static Public Member Functions
static Glib::RefPtr< DBusServer > | create_sync (const Glib::ustring& address, const Glib::ustring& guid, const Glib::RefPtr< DBusAuthObserver >& observer, const Glib::RefPtr< Cancellable >& cancellable, DBusServerFlags flags=Gio::DBUS_SERVER_FLAGS_NONE)
| Creates a new D-Bus server that listens on the first address in address that works.
static Glib::RefPtr< DBusServer > | create_sync (const Glib::ustring& address, const Glib::ustring& guid, const Glib::RefPtr< DBusAuthObserver >& observer, DBusServerFlags flags=Gio::DBUS_SERVER_FLAGS_NONE)
| Non-cancellable version of create_sync().
## Protected Member Functions
| DBusServer (const Glib::ustring& address, const Glib::ustring& guid, const Glib::RefPtr< DBusAuthObserver >& observer, const Glib::RefPtr< Cancellable >& cancellable, DBusServerFlags flags)
| DBusServer (const Glib::ustring& address, const Glib::ustring& guid, const Glib::RefPtr< DBusAuthObserver >& observer, DBusServerFlags flags)
## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gio::DBusServer > | wrap (GDBusServer* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

DBusServer - Helper for accepting connections.

DBusServer is a helper for listening to and accepting D-Bus connections. Since DBusServer implements the Initable interface, its constructors can throw an exception if construction fails.

Since glibmm 2.28:

## Constructor & Destructor Documentation

virtual Gio::DBusServer::~DBusServer | ( | ) | `[virtual]`

Gio::DBusServer::DBusServer | ( | const Glib::ustring& | address,
|  | const Glib::ustring& | guid,
|  | const Glib::RefPtr< DBusAuthObserver >& | observer,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | DBusServerFlags | flags
| ) |  | `[protected]`

Gio::DBusServer::DBusServer | ( | const Glib::ustring& | address,
|  | const Glib::ustring& | guid,
|  | const Glib::RefPtr< DBusAuthObserver >& | observer,
|  | DBusServerFlags | flags
| ) |  | `[protected]`

## Member Function Documentation

static Glib::RefPtr<DBusServer> Gio::DBusServer::create_sync | ( | const Glib::ustring& | address,
|  | const Glib::ustring& | guid,
|  | const Glib::RefPtr< DBusAuthObserver >& | observer,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | DBusServerFlags | flags = `Gio::DBUS_SERVER_FLAGS_NONE`
| ) |  | `[static]`

Creates a new D-Bus server that listens on the first address in address that works.

Once constructed, you can use g_dbus_server_get_client_address() to get a D-Bus address string that clients can use to connect.

Connect to the DBusServer::new-connection signal to handle incoming connections.

The returned DBusServer isn't active - you have to start it with g_dbus_server_start().

See <xref linkend="gdbus-peer-to-peer"> for how DBusServer can be used.

This is a synchronous failable constructor. See Glib::dbus_server_new() for the asynchronous version.

Since glibmm 2.26:

Parameters:

  address | A D-Bus address.
  flags | Flags from the DBusServerFlags enumeration.
  guid | A D-Bus GUID.
  observer | A DBusAuthObserver or `0`.
  cancellable | A Cancellable or `0`.

Returns:
  A DBusServer or `0` if error is set. Free with Glib::object_unref().

Exceptions:

  Glib::Error. |

static Glib::RefPtr<DBusServer> Gio::DBusServer::create_sync | ( | const Glib::ustring& | address,
|  | const Glib::ustring& | guid,
|  | const Glib::RefPtr< DBusAuthObserver >& | observer,
|  | DBusServerFlags | flags = `Gio::DBUS_SERVER_FLAGS_NONE`
| ) |  | `[static]`

Non-cancellable version of create_sync().

Glib::ustring Gio::DBusServer::get_client_address | ( | ) | const

Gets a D-Bus address string that can be used by clients to connect to server.

Since glibmm 2.26:

Returns:
  A D-Bus address string. Do not free, the string is owned by server.

DBusServerFlags Gio::DBusServer::get_flags | ( | ) | const

Gets the flags for server.

Since glibmm 2.26:

Returns:
  A set of flags from the DBusServerFlags enumeration.

Glib::ustring Gio::DBusServer::get_guid | ( | ) | const

Gets the GUID for server.

Since glibmm 2.26:

Returns:
  A D-Bus GUID. Do not free this string, it is owned by server.

const GDBusServer* Gio::DBusServer::gobj | ( | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gio::Initable.

GDBusServer* Gio::DBusServer::gobj | ( | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gio::Initable.

GDBusServer* Gio::DBusServer::gobj_copy | ( | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

bool Gio::DBusServer::is_active | ( | ) | const

Gets whether server is active.

Since glibmm 2.26:

Returns:
  `true` if server is active, `false` otherwise.

Glib::PropertyProxy_ReadOnly<Glib::ustring> Gio::DBusServer::property_active | ( | ) | const

Whether the server is currently active.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Glib::ustring> Gio::DBusServer::property_address | ( | ) | const

The address to listen on.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::RefPtr<DBusAuthObserver> > Gio::DBusServer::property_authentication_observer | ( | ) | const

Object used to assist in the authentication process.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Glib::ustring> Gio::DBusServer::property_client_address | ( | ) | const

The address clients can use.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<DBusServerFlags> Gio::DBusServer::property_flags | ( | ) | const

Flags for the server.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Glib::ustring> Gio::DBusServer::property_guid | ( | ) | const

The guid of the server.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::SignalProxy1< bool,const Glib::RefPtr<DBusConnection>& > Gio::DBusServer::signal_new_connection | ( | ) |

Prototype:
  `bool on_my_new_connection(const Glib::RefPtr<DBusConnection>& connection)`

void Gio::DBusServer::start | ( | ) |

Starts server.

Since glibmm 2.26:

void Gio::DBusServer::stop | ( | ) |

Stops server.

Since glibmm 2.26:

## Friends And Related Function Documentation

Glib::RefPtr< Gio::DBusServer > wrap | ( | GDBusServer * | object,
|  | bool | take_copy = `false`
| ) |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.