glibmm 2.80.0
|
This is a helper for listening to and accepting D-Bus connections. More...
#include <giomm/dbusserver.h>
Public Types | |
enum class | Flags { NONE = 0x0 , RUN_IN_THREAD = (1<<0) , AUTHENTICATION_ALLOW_ANONYMOUS = (1<<1) , AUTHENTICATION_REQUIRE_SAME_USER = (1<<2) } |
Public Types inherited from Glib::Object | |
using | DestroyNotify = void(*)(gpointer data) |
Public Member Functions | |
Server (Server &&src) noexcept | |
Server & | operator= (Server &&src) noexcept |
~Server () noexcept override | |
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. | |
std::string | get_guid () const |
Gets the GUID for server, as provided to g_dbus_server_new_sync(). | |
Flags | get_flags () const |
Gets the flags for server. | |
std::string | get_client_address () const |
Gets a D-Bus address string that can be used by clients to connect to server. | |
Glib::PropertyProxy_ReadOnly< bool > | property_active () const |
Whether the server is currently active. | |
Glib::PropertyProxy_ReadOnly< std::string > | property_address () const |
The D-Bus address to listen on. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< AuthObserver > > | property_authentication_observer () const |
A Gio::DBus::AuthObserver object to assist in the authentication process or nullptr . | |
Glib::PropertyProxy_ReadOnly< std::string > | property_client_address () const |
The D-Bus address that clients can use. | |
Glib::PropertyProxy_ReadOnly< Flags > | property_flags () const |
Flags from the Gio::DBus::Server::Flags enumeration. | |
Glib::PropertyProxy_ReadOnly< std::string > | property_guid () const |
The GUID of the server. | |
Glib::SignalProxy< bool(const Glib::RefPtr< Connection > &)> | signal_new_connection () |
Public Member Functions inherited from Glib::Object | |
Object (const Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&src) noexcept | |
Object & | operator= (Object &&src) noexcept |
void * | get_data (const QueryQuark & key) |
void | set_data (const Quark & key, void *data) |
void | set_data_with_c_callback (const Quark & key, void *data, GDestroyNotify notify) |
void | set_data (const Quark & key, void *data, DestroyNotify notify) |
Prefer set_data_with_c_callback() with a callback with C linkage. | |
void | remove_data (const QueryQuark &quark) |
void * | steal_data (const QueryQuark &quark) |
Public Member Functions inherited from Glib::ObjectBase | |
ObjectBase (const ObjectBase &)=delete | |
ObjectBase & | operator= (const ObjectBase &)=delete |
void | set_property_value (const Glib::ustring & property_name, const Glib::ValueBase & value) |
You probably want to use a specific property_*() accessor method instead. | |
void | get_property_value (const Glib::ustring & property_name, Glib::ValueBase & value) const |
You probably want to use a specific property_*() accessor method instead. | |
template<class PropertyType > | |
void | set_property (const Glib::ustring & property_name, const PropertyType & value) |
You probably want to use a specific property_*() accessor method instead. | |
template<class PropertyType > | |
void | get_property (const Glib::ustring & property_name, PropertyType & value) const |
You probably want to use a specific property_*() accessor method instead. | |
template<class PropertyType > | |
PropertyType | get_property (const Glib::ustring & property_name) const |
You probably want to use a specific property_*() accessor method instead. | |
sigc::connection | connect_property_changed (const Glib::ustring & property_name, const sigc::slot< void()> &slot) |
You can use the signal_changed() signal of the property proxy instead. | |
sigc::connection | connect_property_changed (const Glib::ustring & property_name, sigc::slot< void()> &&slot) |
You can use the signal_changed() signal of the property proxy instead. | |
void | freeze_notify () |
Increases the freeze count on object. | |
void | thaw_notify () |
Reverts the effect of a previous call to freeze_notify(). | |
virtual void | reference () const |
Increment the reference count for this object. | |
virtual void | unreference () const |
Decrement the reference count for this object. | |
GObject * | gobj () |
Provides access to the underlying C GObject. | |
const GObject * | gobj () const |
Provides access to the underlying C GObject. | |
GObject * | gobj_copy () const |
Give a ref-ed copy to someone. Use for direct struct access. | |
Public Member Functions inherited from Gio::Initable | |
Initable (Initable &&src) noexcept | |
Initable & | operator= (Initable &&src) noexcept |
~Initable () noexcept override | |
GInitable * | gobj () |
Provides access to the underlying C GObject. | |
const GInitable * | gobj () const |
Provides access to the underlying C GObject. | |
Public Member Functions inherited from Glib::Interface | |
Interface () | |
A Default constructor. | |
Interface (Interface &&src) noexcept | |
Interface & | operator= (Interface &&src) noexcept |
Interface (const Glib::Interface_Class &interface_class) | |
Called by constructors of derived classes. | |
Interface (GObject *castitem) | |
Called by constructors of derived classes. | |
~Interface () noexcept override | |
Interface (const Interface &)=delete | |
Interface & | operator= (const Interface &)=delete |
GObject * | gobj () |
const GObject * | gobj () const |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gio::DBus::Server > | wrap (GDBusServer *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Related Symbols inherited from Glib::Object | |
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false) |
Related Symbols inherited from Gio::Initable | |
Glib::RefPtr< Gio::Initable > | wrap (GInitable *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
This is a helper for listening to and accepting D-Bus connections.
Since Server derives from Initiable, its constructors can throw an exception if construction fails.
This can be used to create a new D-Bus server, allowing two peers to use the D-Bus protocol for their own specialized communication. A server instance provided in this way will not perform message routing or implement the org.freedesktop.DBus interface.
To just export an object on a well-known name on a message bus, such as the session or system bus, you should instead use Gio::DBus::own_name().
|
strong |
Enumerator | |
---|---|
NONE | No flags set. |
RUN_IN_THREAD | All Gio::DBus::Server::signal_new_connection() signals will run in separated dedicated threads (see signal for details). |
AUTHENTICATION_ALLOW_ANONYMOUS | Allow the anonymous authentication method. |
AUTHENTICATION_REQUIRE_SAME_USER | Require the UID of the peer to be the same as the UID of the server when authenticating. (Since: 2.68). |
|
noexcept |
|
overridenoexcept |
|
protected |
|
protected |
|
protected |
|
protected |
|
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.
To have control over the available authentication mechanisms and the users that are authorized to connect, it is strongly recommended to provide a non-nullptr
Gio::DBus::AuthObserver.
Connect to the Gio::DBus::Server::signal_new_connection() signal to handle incoming connections.
The returned Gio::DBus::Server isn't active - you have to start it with g_dbus_server_start().
Gio::DBus::Server is used in this [example][gdbus-peer-to-peer].
This is a synchronous failable constructor. There is currently no asynchronous version.
address | A D-Bus address. |
flags | Flags from the Gio::DBus::Server::Flags enumeration. |
guid | A D-Bus GUID. |
observer | A Gio::DBus::AuthObserver or nullptr . |
cancellable | A Cancellable or nullptr . |
nullptr
if error is set. Free with Glib::object_unref(). Glib::Error. |
|
static |
Non-cancellable version of create_sync().
|
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.
To have control over the available authentication mechanisms and the users that are authorized to connect, it is strongly recommended to provide a non-nullptr
Gio::DBus::AuthObserver.
Connect to the Gio::DBus::Server::signal_new_connection() signal to handle incoming connections.
The returned Gio::DBus::Server isn't active - you have to start it with g_dbus_server_start().
Gio::DBus::Server is used in this [example][gdbus-peer-to-peer].
This is a synchronous failable constructor. There is currently no asynchronous version.
address | A D-Bus address. |
flags | Flags from the Gio::DBus::Server::Flags enumeration. |
guid | A D-Bus GUID. |
observer | A Gio::DBus::AuthObserver or nullptr . |
cancellable | A Cancellable or nullptr . |
nullptr
if error is set. Free with Glib::object_unref(). Glib::Error. |
|
static |
Non-cancellable version of create_sync().
std::string Gio::DBus::Server::get_client_address | ( | ) | const |
Gets a D-Bus address string that can be used by clients to connect to server.
This is valid and non-empty if initializing the Gio::DBus::Server succeeded.
Flags Gio::DBus::Server::get_flags | ( | ) | const |
Gets the flags for server.
std::string Gio::DBus::Server::get_guid | ( | ) | const |
Gets the GUID for server, as provided to g_dbus_server_new_sync().
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
GDBusServer * Gio::DBus::Server::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::DBus::Server::is_active | ( | ) | const |
Glib::PropertyProxy_ReadOnly< bool > Gio::DBus::Server::property_active | ( | ) | const |
Whether the server is currently active.
Default value: false
Glib::PropertyProxy_ReadOnly< std::string > Gio::DBus::Server::property_address | ( | ) | const |
The D-Bus address to listen on.
Default value: ""
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< AuthObserver > > Gio::DBus::Server::property_authentication_observer | ( | ) | const |
A Gio::DBus::AuthObserver object to assist in the authentication process or nullptr
.
Glib::PropertyProxy_ReadOnly< std::string > Gio::DBus::Server::property_client_address | ( | ) | const |
The D-Bus address that clients can use.
Default value: ""
Glib::PropertyProxy_ReadOnly< Flags > Gio::DBus::Server::property_flags | ( | ) | const |
Flags from the Gio::DBus::Server::Flags enumeration.
Default value: Gio::DBus::Server::Flags::NONE
Glib::PropertyProxy_ReadOnly< std::string > Gio::DBus::Server::property_guid | ( | ) | const |
The GUID of the server.
See Gio::DBus::Connection::property_guid() for more details.
Default value: ""
Glib::SignalProxy< bool(const Glib::RefPtr< Connection > &)> Gio::DBus::Server::signal_new_connection | ( | ) |
bool on_my_new_connection(const Glib::RefPtr<Connection>& connection)
Flags: Run Last
Emitted when a new authenticated connection has been made. Use g_dbus_connection_get_peer_credentials() to figure out what identity (if any), was authenticated.
If you want to accept the connection, take a reference to the connection object and return true
. When you are done with the connection call g_dbus_connection_close() and give up your reference. Note that the other peer may disconnect at any time - a typical thing to do when accepting a connection is to listen to the Gio::DBus::Connection::signal_closed() signal.
If Gio::DBus::Server::property_flags() contains Gio::DBus::Server::Flags::RUN_IN_THREAD then the signal is emitted in a new thread dedicated to the connection. Otherwise the signal is emitted in the [thread-default main context][g-main-context-push-thread-default] of the thread that server was constructed in.
You are guaranteed that signal handlers for this signal runs before incoming messages on connection are processed. This means that it's suitable to call g_dbus_connection_register_object() or similar from the signal handler.
connection | A Gio::DBus::Connection for the new connection. |
true
to claim connection, false
to let other handlers run. void Gio::DBus::Server::start | ( | ) |
Starts server.
void Gio::DBus::Server::stop | ( | ) |
Stops server.
|
related |
A Glib::wrap() method for this object.
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. |