Coverage Report

Created: 2025-07-11 06:48

/src/tinysparql/subprojects/glib-2.80.3/gio/gdbusobject.c
Line
Count
Source (jump to first uncovered line)
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
#include "config.h"
24
25
#include "gdbusobject.h"
26
#include "gdbusinterface.h"
27
#include "gdbusutils.h"
28
29
#include "glibintl.h"
30
31
/**
32
 * GDBusObject:
33
 *
34
 * The `GDBusObject` type is the base type for D-Bus objects on both
35
 * the service side (see [class@Gio.DBusObjectSkeleton]) and the client side
36
 * (see [class@Gio.DBusObjectProxy]). It is essentially just a container of
37
 * interfaces.
38
 */
39
40
typedef GDBusObjectIface GDBusObjectInterface;
41
G_DEFINE_INTERFACE (GDBusObject, g_dbus_object, G_TYPE_OBJECT)
42
43
static void
44
g_dbus_object_default_init (GDBusObjectIface *iface)
45
0
{
46
  /**
47
   * GDBusObject::interface-added:
48
   * @object: The #GDBusObject emitting the signal.
49
   * @interface: The #GDBusInterface that was added.
50
   *
51
   * Emitted when @interface is added to @object.
52
   *
53
   * Since: 2.30
54
   */
55
0
  g_signal_new (I_("interface-added"),
56
0
                G_TYPE_FROM_INTERFACE (iface),
57
0
                G_SIGNAL_RUN_LAST,
58
0
                G_STRUCT_OFFSET (GDBusObjectIface, interface_added),
59
0
                NULL,
60
0
                NULL,
61
0
                NULL,
62
0
                G_TYPE_NONE,
63
0
                1,
64
0
                G_TYPE_DBUS_INTERFACE);
65
66
  /**
67
   * GDBusObject::interface-removed:
68
   * @object: The #GDBusObject emitting the signal.
69
   * @interface: The #GDBusInterface that was removed.
70
   *
71
   * Emitted when @interface is removed from @object.
72
   *
73
   * Since: 2.30
74
   */
75
0
  g_signal_new (I_("interface-removed"),
76
0
                G_TYPE_FROM_INTERFACE (iface),
77
0
                G_SIGNAL_RUN_LAST,
78
0
                G_STRUCT_OFFSET (GDBusObjectIface, interface_removed),
79
0
                NULL,
80
0
                NULL,
81
0
                NULL,
82
0
                G_TYPE_NONE,
83
0
                1,
84
0
                G_TYPE_DBUS_INTERFACE);
85
0
}
86
87
/* ---------------------------------------------------------------------------------------------------- */
88
89
/**
90
 * g_dbus_object_get_object_path:
91
 * @object: A #GDBusObject.
92
 *
93
 * Gets the object path for @object.
94
 *
95
 * Returns: A string owned by @object. Do not free.
96
 *
97
 * Since: 2.30
98
 */
99
const gchar *
100
g_dbus_object_get_object_path (GDBusObject *object)
101
0
{
102
0
  GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object);
103
0
  return iface->get_object_path (object);
104
0
}
105
106
/**
107
 * g_dbus_object_get_interfaces:
108
 * @object: A #GDBusObject.
109
 *
110
 * Gets the D-Bus interfaces associated with @object.
111
 *
112
 * Returns: (element-type GDBusInterface) (transfer full): A list of #GDBusInterface instances.
113
 *   The returned list must be freed by g_list_free() after each element has been freed
114
 *   with g_object_unref().
115
 *
116
 * Since: 2.30
117
 */
118
GList *
119
g_dbus_object_get_interfaces (GDBusObject *object)
120
0
{
121
0
  GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object);
122
0
  return iface->get_interfaces (object);
123
0
}
124
125
/**
126
 * g_dbus_object_get_interface:
127
 * @object: A #GDBusObject.
128
 * @interface_name: A D-Bus interface name.
129
 *
130
 * Gets the D-Bus interface with name @interface_name associated with
131
 * @object, if any.
132
 *
133
 * Returns: (nullable) (transfer full): %NULL if not found, otherwise a
134
 *   #GDBusInterface that must be freed with g_object_unref().
135
 *
136
 * Since: 2.30
137
 */
138
GDBusInterface *
139
g_dbus_object_get_interface (GDBusObject *object,
140
                             const gchar *interface_name)
141
0
{
142
0
  GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object);
143
0
  g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL);
144
0
  return iface->get_interface (object, interface_name);
145
0
}