glibmm 2.80.0
Public Member Functions | Static Public Member Functions | Related Symbols | List of all members
Gio::DBus::MethodInvocation Class Reference

An Object for handling remote calls. More...

#include <giomm/dbusmethodinvocation.h>

Inheritance diagram for Gio::DBus::MethodInvocation:
Inheritance graph
[legend]

Public Member Functions

 MethodInvocation (MethodInvocation &&src) noexcept
 
MethodInvocationoperator= (MethodInvocation &&src) noexcept
 
 ~MethodInvocation () noexcept override
 
GDBusMethodInvocationgobj ()
 Provides access to the underlying C GObject.
 
const GDBusMethodInvocationgobj () const
 Provides access to the underlying C GObject.
 
GDBusMethodInvocationgobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
 
Glib::ustring get_sender () const
 Gets the bus name that invoked the method.
 
Glib::ustring get_object_path () const
 Gets the object path the method was invoked on.
 
Glib::ustring get_interface_name () const
 Gets the name of the D-Bus interface the method was invoked on.
 
Glib::ustring get_method_name () const
 Gets the name of the method that was invoked.
 
Glib::RefPtr< const MethodInfoget_method_info () const
 Gets information about the method call, if any.
 
Glib::RefPtr< Connectionget_connection ()
 Gets the Gio::DBus::Connection the method was invoked on.
 
Glib::RefPtr< const Connectionget_connection () const
 Gets the Gio::DBus::Connection the method was invoked on.
 
Glib::RefPtr< Messageget_message ()
 Gets the Gio::DBus::Message for the method invocation.
 
Glib::RefPtr< const Messageget_message () const
 Gets the Gio::DBus::Message for the method invocation.
 
Glib::VariantContainerBase get_parameters () const
 Gets the parameters of the method invocation.
 
void return_value (const Glib::VariantContainerBase &parameters)
 Finishes handling a D-Bus method call by returning parameters.
 
void return_value (const Glib::VariantContainerBase &parameters, const Glib::RefPtr< UnixFDList > &fd_list)
 Like g_dbus_method_invocation_return_value() but also takes a UnixFDList.
 
void return_error (const Glib::ustring & domain, int code, const Glib::ustring & message)
 Like g_dbus_method_invocation_return_error() but without printf()-style formatting.
 
void return_error (const Glib::Error &error)
 Like g_dbus_method_invocation_return_error() but takes a Error instead of the error domain, error code and message.
 
void return_dbus_error (const Glib::ustring &error_name, const Glib::ustring &error_message)
 Finishes handling a D-Bus method call by returning an error.
 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
voidget_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)
 
voidsteal_data (const QueryQuark &quark)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (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.
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system.
 

Related Symbols

(Note that these are not member symbols.)

Glib::RefPtr< Gio::DBus::MethodInvocationwrap (GDBusMethodInvocation *object, bool take_copy=false)
 A Glib::wrap() method for this object.
 

Additional Inherited Members

- Public Types inherited from Glib::Object
using DestroyNotify = void(*)(gpointer data)
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor.
 
 ObjectBase (const char *custom_type_name)
 A derived constructor always overrides this choice.
 
 ObjectBase (const std::type_info &custom_type_info)
 This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually.
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Detailed Description

An Object for handling remote calls.

Instances of the MethodInvocation class are used when handling D-Bus method calls. It provides a way to asynchronously return results and errors.

The normal way to obtain a MethodInvocation object is to receive it as an argument to the SlotMethodCall that was passed to Gio::DBus::Connection::register_object().

Since glibmm 2.28:

Constructor & Destructor Documentation

◆ MethodInvocation()

Gio::DBus::MethodInvocation::MethodInvocation ( MethodInvocation &&  src)
noexcept

◆ ~MethodInvocation()

Gio::DBus::MethodInvocation::~MethodInvocation ( )
overridenoexcept

Member Function Documentation

◆ get_connection() [1/2]

Glib::RefPtr< Connection > Gio::DBus::MethodInvocation::get_connection ( )

Gets the Gio::DBus::Connection the method was invoked on.

Since glibmm 2.26:
Returns
A Gio::DBus::Connection. Do not free, it is owned by invocation.

◆ get_connection() [2/2]

Glib::RefPtr< const Connection > Gio::DBus::MethodInvocation::get_connection ( ) const

Gets the Gio::DBus::Connection the method was invoked on.

Since glibmm 2.26:
Returns
A Gio::DBus::Connection. Do not free, it is owned by invocation.

◆ get_interface_name()

Glib::ustring Gio::DBus::MethodInvocation::get_interface_name ( ) const

Gets the name of the D-Bus interface the method was invoked on.

If this method call is a property Get, Set or GetAll call that has been redirected to the method call handler then "org.freedesktop.DBus.Properties" will be returned. See DBusInterfaceVTable for more information.

Since glibmm 2.26:
Returns
A string. Do not free, it is owned by invocation.

◆ get_message() [1/2]

Glib::RefPtr< Message > Gio::DBus::MethodInvocation::get_message ( )

Gets the Gio::DBus::Message for the method invocation.

This is useful if you need to use low-level protocol features, such as UNIX file descriptor passing, that cannot be properly expressed in the Variant API.

See this [server][gdbus-server] and [client][gdbus-unix-fd-client] for an example of how to use this low-level API to send and receive UNIX file descriptors.

Since glibmm 2.26:
Returns
Gio::DBus::Message. Do not free, it is owned by invocation.

◆ get_message() [2/2]

Glib::RefPtr< const Message > Gio::DBus::MethodInvocation::get_message ( ) const

Gets the Gio::DBus::Message for the method invocation.

This is useful if you need to use low-level protocol features, such as UNIX file descriptor passing, that cannot be properly expressed in the Variant API.

See this [server][gdbus-server] and [client][gdbus-unix-fd-client] for an example of how to use this low-level API to send and receive UNIX file descriptors.

Since glibmm 2.26:
Returns
Gio::DBus::Message. Do not free, it is owned by invocation.

◆ get_method_info()

Glib::RefPtr< const MethodInfo > Gio::DBus::MethodInvocation::get_method_info ( ) const

Gets information about the method call, if any.

If this method invocation is a property Get, Set or GetAll call that has been redirected to the method call handler then nullptr will be returned. See g_dbus_method_invocation_get_property_info() and DBusInterfaceVTable for more information.

Since glibmm 2.26:
Returns
A DBusMethodInfo or nullptr. Do not free, it is owned by invocation.

◆ get_method_name()

Glib::ustring Gio::DBus::MethodInvocation::get_method_name ( ) const

Gets the name of the method that was invoked.

Since glibmm 2.26:
Returns
A string. Do not free, it is owned by invocation.

◆ get_object_path()

Glib::ustring Gio::DBus::MethodInvocation::get_object_path ( ) const

Gets the object path the method was invoked on.

Since glibmm 2.26:
Returns
A string. Do not free, it is owned by invocation.

◆ get_parameters()

Glib::VariantContainerBase Gio::DBus::MethodInvocation::get_parameters ( ) const

Gets the parameters of the method invocation.

If there are no input parameters then this will return a GVariant with 0 children rather than nullptr.

Since glibmm 2.26:
Returns
A Variant tuple. Do not unref this because it is owned by invocation.

◆ get_sender()

Glib::ustring Gio::DBus::MethodInvocation::get_sender ( ) const

Gets the bus name that invoked the method.

Since glibmm 2.26:
Returns
A string. Do not free, it is owned by invocation.

◆ get_type()

static GType Gio::DBus::MethodInvocation::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gobj() [1/2]

GDBusMethodInvocation * Gio::DBus::MethodInvocation::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GDBusMethodInvocation * Gio::DBus::MethodInvocation::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GDBusMethodInvocation * Gio::DBus::MethodInvocation::gobj_copy ( )

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

◆ operator=()

MethodInvocation & Gio::DBus::MethodInvocation::operator= ( MethodInvocation &&  src)
noexcept

◆ return_dbus_error()

void Gio::DBus::MethodInvocation::return_dbus_error ( const Glib::ustring error_name,
const Glib::ustring error_message 
)

Finishes handling a D-Bus method call by returning an error.

This method will take ownership of invocation. See DBusInterfaceVTable for more information about the ownership of invocation.

Since glibmm 2.26:
Parameters
error_nameA valid D-Bus error name.
error_messageA valid D-Bus error message.

◆ return_error() [1/2]

void Gio::DBus::MethodInvocation::return_error ( const Glib::Error error)

Like g_dbus_method_invocation_return_error() but takes a Error instead of the error domain, error code and message.

This method will take ownership of invocation. See DBusInterfaceVTable for more information about the ownership of invocation.

Since glibmm 2.26:
Parameters
errorA Error.

◆ return_error() [2/2]

void Gio::DBus::MethodInvocation::return_error ( const Glib::ustring domain,
int  code,
const Glib::ustring message 
)

Like g_dbus_method_invocation_return_error() but without printf()-style formatting.

This method will take ownership of invocation. See DBusInterfaceVTable for more information about the ownership of invocation.

Since glibmm 2.26:
Parameters
domainA Quark for the Error error domain.
codeThe error code.
messageThe error message.

◆ return_value() [1/2]

void Gio::DBus::MethodInvocation::return_value ( const Glib::VariantContainerBase parameters)

Finishes handling a D-Bus method call by returning parameters.

If the parameters GVariant is floating, it is consumed.

It is an error if parameters is not of the right format: it must be a tuple containing the out-parameters of the D-Bus method. Even if the method has a single out-parameter, it must be contained in a tuple. If the method has no out-parameters, parameters may be nullptr or an empty tuple.

[C example ellipted]

This method will take ownership of invocation. See DBusInterfaceVTable for more information about the ownership of invocation.

Since 2.48, if the method call requested for a reply not to be sent then this call will sink parameters and free invocation, but otherwise do nothing (as per the recommendations of the D-Bus specification).

Since glibmm 2.26:
Parameters
parametersA Variant tuple with out parameters for the method or nullptr if not passing any parameters.

◆ return_value() [2/2]

void Gio::DBus::MethodInvocation::return_value ( const Glib::VariantContainerBase parameters,
const Glib::RefPtr< UnixFDList > &  fd_list 
)

Like g_dbus_method_invocation_return_value() but also takes a UnixFDList.

This method is only available on UNIX.

This method will take ownership of invocation. See DBusInterfaceVTable for more information about the ownership of invocation.

Since glibmm 2.30:
Parameters
parametersA Variant tuple with out parameters for the method or nullptr if not passing any parameters.
fd_listA UnixFDList or nullptr.

Friends And Related Symbol Documentation

◆ wrap()

Glib::RefPtr< Gio::DBus::MethodInvocation > wrap ( GDBusMethodInvocation object,
bool  take_copy = false 
)
related

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

Parameters
objectThe C instance.
take_copyFalse 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.