1/* GDBus - GLib D-Bus Library
2 *
3 * Copyright (C) 2008-2010 Red Hat, Inc.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 *
20 * Author: David Zeuthen <davidz@redhat.com>
21 */
22
23#ifndef __G_DBUS_METHOD_INVOCATION_H__
24#define __G_DBUS_METHOD_INVOCATION_H__
25
26#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
27#error "Only <gio/gio.h> can be included directly."
28#endif
29
30#include <gio/giotypes.h>
31
32G_BEGIN_DECLS
33
34#define G_TYPE_DBUS_METHOD_INVOCATION (g_dbus_method_invocation_get_type ())
35#define G_DBUS_METHOD_INVOCATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_METHOD_INVOCATION, GDBusMethodInvocation))
36#define G_IS_DBUS_METHOD_INVOCATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_METHOD_INVOCATION))
37
38/**
39 * G_DBUS_METHOD_INVOCATION_HANDLED:
40 *
41 * The value returned by handlers of the signals generated by
42 * the `gdbus-codegen` tool to indicate that a method call has been
43 * handled by an implementation. It is equal to %TRUE, but using
44 * this macro is sometimes more readable.
45 *
46 * In code that needs to be backwards-compatible with older GLib,
47 * use %TRUE instead, often written like this:
48 *
49 * |[
50 * g_dbus_method_invocation_return_error (invocation, ...);
51 * return TRUE; // handled
52 * ]|
53 *
54 * Since: 2.68
55 */
56#define G_DBUS_METHOD_INVOCATION_HANDLED TRUE GIO_AVAILABLE_MACRO_IN_2_68
57
58/**
59 * G_DBUS_METHOD_INVOCATION_UNHANDLED:
60 *
61 * The value returned by handlers of the signals generated by
62 * the `gdbus-codegen` tool to indicate that a method call has not been
63 * handled by an implementation. It is equal to %FALSE, but using
64 * this macro is sometimes more readable.
65 *
66 * In code that needs to be backwards-compatible with older GLib,
67 * use %FALSE instead.
68 *
69 * Since: 2.68
70 */
71#define G_DBUS_METHOD_INVOCATION_UNHANDLED FALSE GIO_AVAILABLE_MACRO_IN_2_68
72
73GIO_AVAILABLE_IN_ALL
74GType g_dbus_method_invocation_get_type (void) G_GNUC_CONST;
75GIO_AVAILABLE_IN_ALL
76const gchar *g_dbus_method_invocation_get_sender (GDBusMethodInvocation *invocation);
77GIO_AVAILABLE_IN_ALL
78const gchar *g_dbus_method_invocation_get_object_path (GDBusMethodInvocation *invocation);
79GIO_AVAILABLE_IN_ALL
80const gchar *g_dbus_method_invocation_get_interface_name (GDBusMethodInvocation *invocation);
81GIO_AVAILABLE_IN_ALL
82const gchar *g_dbus_method_invocation_get_method_name (GDBusMethodInvocation *invocation);
83GIO_AVAILABLE_IN_ALL
84const GDBusMethodInfo *g_dbus_method_invocation_get_method_info (GDBusMethodInvocation *invocation);
85GIO_AVAILABLE_IN_2_38
86const GDBusPropertyInfo *g_dbus_method_invocation_get_property_info (GDBusMethodInvocation *invocation);
87GIO_AVAILABLE_IN_ALL
88GDBusConnection *g_dbus_method_invocation_get_connection (GDBusMethodInvocation *invocation);
89GIO_AVAILABLE_IN_ALL
90GDBusMessage *g_dbus_method_invocation_get_message (GDBusMethodInvocation *invocation);
91GIO_AVAILABLE_IN_ALL
92GVariant *g_dbus_method_invocation_get_parameters (GDBusMethodInvocation *invocation);
93GIO_AVAILABLE_IN_ALL
94gpointer g_dbus_method_invocation_get_user_data (GDBusMethodInvocation *invocation);
95
96GIO_AVAILABLE_IN_ALL
97void g_dbus_method_invocation_return_value (GDBusMethodInvocation *invocation,
98 GVariant *parameters);
99#ifdef G_OS_UNIX
100GIO_AVAILABLE_IN_ALL
101void g_dbus_method_invocation_return_value_with_unix_fd_list (GDBusMethodInvocation *invocation,
102 GVariant *parameters,
103 GUnixFDList *fd_list);
104#endif /* G_OS_UNIX */
105GIO_AVAILABLE_IN_ALL
106void g_dbus_method_invocation_return_error (GDBusMethodInvocation *invocation,
107 GQuark domain,
108 gint code,
109 const gchar *format,
110 ...) G_GNUC_PRINTF(4, 5);
111GIO_AVAILABLE_IN_ALL
112void g_dbus_method_invocation_return_error_valist (GDBusMethodInvocation *invocation,
113 GQuark domain,
114 gint code,
115 const gchar *format,
116 va_list var_args)
117 G_GNUC_PRINTF(4, 0);
118GIO_AVAILABLE_IN_ALL
119void g_dbus_method_invocation_return_error_literal (GDBusMethodInvocation *invocation,
120 GQuark domain,
121 gint code,
122 const gchar *message);
123GIO_AVAILABLE_IN_ALL
124void g_dbus_method_invocation_return_gerror (GDBusMethodInvocation *invocation,
125 const GError *error);
126GIO_AVAILABLE_IN_ALL
127void g_dbus_method_invocation_take_error (GDBusMethodInvocation *invocation,
128 GError *error);
129GIO_AVAILABLE_IN_ALL
130void g_dbus_method_invocation_return_dbus_error (GDBusMethodInvocation *invocation,
131 const gchar *error_name,
132 const gchar *error_message);
133
134G_END_DECLS
135
136#endif /* __G_DBUS_METHOD_INVOCATION_H__ */
137