# Gio::DBusMethodInvocation Class Reference

DBusMethodInvocation - Object for handling remote calls. More...

`#include <giomm/dbusmethodinvocation.h>`

Inheritance diagram for Gio::DBusMethodInvocation:
[legend]

List of all members.

## Public Member Functions

virtual | ~DBusMethodInvocation ()
GDBusMethodInvocation* | gobj ()
| Provides access to the underlying C GObject.
const GDBusMethodInvocation* | gobj () const
| Provides access to the underlying C GObject.
GDBusMethodInvocation* | gobj_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 DBusMethodInfo > | get_method_info () const
| Gets information about the method call, if any.
Glib::RefPtr< DBusConnection > | get_connection ()
| Gets the DBusConnection the method was invoked on.
Glib::RefPtr< const DBusConnection > | get_connection () const
| Gets the DBusConnection the method was invoked on.
Glib::RefPtr< DBusMessage > | get_message ()
| Gets the DBusMessage for the method invocation.
Glib::RefPtr< const DBusMessage > | get_message () const
| Gets the DBusMessage for the method invocation.
void | get_parameters (Glib::VariantBase&value) const
| Gets the parameters of the method invocation.
void | return_value (const Glib::VariantBase& parameters)
| Finishes handling a D-Bus method call by returning .
void | return_error_literal (const Glib::ustring& domain, int code, const Glib::ustring& message)
| Like g_dbus_method_invocation_return_error() but without printf()-style formatting.
void | return_gerror (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.

## Protected Member Functions

| DBusMethodInvocation ()

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr < Gio::DBusMethodInvocation > | wrap (GDBusMethodInvocation* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

DBusMethodInvocation - Object for handling remote calls.

Instances of the DBusMethodInvocation 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 DBusMethodInvocation object is to receive it as an argument to the SlotMethodCall that was passed to Gio::DBusConnection::register_object().

Since glibmm 2.26:

## Constructor & Destructor Documentation

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

Gio::DBusMethodInvocation::DBusMethodInvocation | ( |  | ) | `[protected]`

## Member Function Documentation

Glib::RefPtr<DBusConnection> Gio::DBusMethodInvocation::get_connection | ( |  | ) |

Gets the DBusConnection the method was invoked on.

Since glibmm 2.26:

Returns:
  A DBusConnection. Do not free, it is owned by invocation.

Glib::RefPtr<const DBusConnection> Gio::DBusMethodInvocation::get_connection | ( |  | ) | const

Gets the DBusConnection the method was invoked on.

Since glibmm 2.26:

Returns:
  A DBusConnection. Do not free, it is owned by invocation.

Glib::ustring Gio::DBusMethodInvocation::get_interface_name | ( |  | ) | const

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

Since glibmm 2.26:

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

Glib::RefPtr<DBusMessage> Gio::DBusMethodInvocation::get_message | ( |  | ) |

Gets the DBusMessage 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 <xref linkend="gdbus-server"> and <xref linkend="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:
  A DBusMessage. Do not free, it is owned by invocation.

Glib::RefPtr<const DBusMessage> Gio::DBusMethodInvocation::get_message | ( |  | ) | const

Gets the DBusMessage 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 <xref linkend="gdbus-server"> and <xref linkend="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:
  A DBusMessage. Do not free, it is owned by invocation.

Glib::RefPtr<const DBusMethodInfo> Gio::DBusMethodInvocation::get_method_info | ( |  | ) | const

Gets information about the method call, if any.

Since glibmm 2.26:

Returns:
  A DBusMethodInfo or `0`. Do not free, it is owned by invocation.

Glib::ustring Gio::DBusMethodInvocation::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.

Glib::ustring Gio::DBusMethodInvocation::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.

void Gio::DBusMethodInvocation::get_parameters | ( | Glib::VariantBase& | value | ) | const

Gets the parameters of the method invocation.

Parameters:

  | value | The location in which to return the parameters.

Since glibmm 2.26:

Glib::ustring Gio::DBusMethodInvocation::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.

const GDBusMethodInvocation* Gio::DBusMethodInvocation::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GDBusMethodInvocation* Gio::DBusMethodInvocation::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GDBusMethodInvocation* Gio::DBusMethodInvocation::gobj_copy | ( |  | ) |

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

void Gio::DBusMethodInvocation::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 free invocation, you cannot use it afterwards.

Since glibmm 2.26:

Parameters:

  | error_name | A valid D-Bus error name.
  | error_message | A valid D-Bus error message.

void Gio::DBusMethodInvocation::return_error_literal | ( | 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 free invocation, you cannot use it afterwards.

Since glibmm 2.26:

Parameters:

  | domain | A Quark for the Error error domain.
  | code | The error code.
  | message | The error message.

void Gio::DBusMethodInvocation::return_gerror | ( | 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 free invocation, you cannot use it afterwards.

Since glibmm 2.26:

void Gio::DBusMethodInvocation::return_value | ( | const Glib::VariantBase& | parameters | ) |

Finishes handling a D-Bus method call by returning .

If the GVariant is floating, it is consumed.

It is an error if is not of the right format.

This method will free invocation, you cannot use it afterwards.

Since glibmm 2.26:

Parameters:

  | parameters | A Variant tuple with out parameters for the method or `0` if not passing any parameters.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::DBusMethodInvocation > wrap | ( | GDBusMethodInvocation * | 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.