| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  | /* GDBus - GLib D-Bus Library
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2008-2010 Red Hat, Inc. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2022-05-18 09:12:45 +01:00
										 |  |  |  * SPDX-License-Identifier: LGPL-2.1-or-later | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |  * This library is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  |  * License as published by the Free Software Foundation; either | 
					
						
							| 
									
										
										
										
											2017-05-27 18:21:30 +02:00
										 |  |  |  * version 2.1 of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This library is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  |  * Lesser General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Lesser General | 
					
						
							| 
									
										
										
										
											2014-01-23 12:58:29 +01:00
										 |  |  |  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Author: David Zeuthen <davidz@redhat.com> | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "config.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "gdbusobject.h"
 | 
					
						
							|  |  |  | #include "gdbusinterface.h"
 | 
					
						
							|  |  |  | #include "gdbusutils.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "glibintl.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-05 16:20:43 +01:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * GDBusObject: | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2023-11-02 16:21:25 +00:00
										 |  |  |  * The `GDBusObject` type is the base type for D-Bus objects on both | 
					
						
							|  |  |  |  * the service side (see [class@Gio.DBusObjectSkeleton]) and the client side | 
					
						
							|  |  |  |  * (see [class@Gio.DBusObjectProxy]). It is essentially just a container of | 
					
						
							|  |  |  |  * interfaces. | 
					
						
							| 
									
										
										
										
											2015-02-05 16:20:43 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  | typedef GDBusObjectIface GDBusObjectInterface; | 
					
						
							|  |  |  | G_DEFINE_INTERFACE (GDBusObject, g_dbus_object, G_TYPE_OBJECT) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | g_dbus_object_default_init (GDBusObjectIface *iface) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   /**
 | 
					
						
							|  |  |  |    * GDBusObject::interface-added: | 
					
						
							|  |  |  |    * @object: The #GDBusObject emitting the signal. | 
					
						
							|  |  |  |    * @interface: The #GDBusInterface that was added. | 
					
						
							|  |  |  |    * | 
					
						
							|  |  |  |    * Emitted when @interface is added to @object. | 
					
						
							| 
									
										
										
										
											2011-04-08 16:29:48 -04:00
										 |  |  |    * | 
					
						
							|  |  |  |    * Since: 2.30 | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-09-12 00:00:40 -04:00
										 |  |  |   g_signal_new (I_("interface-added"), | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |                 G_TYPE_FROM_INTERFACE (iface), | 
					
						
							|  |  |  |                 G_SIGNAL_RUN_LAST, | 
					
						
							|  |  |  |                 G_STRUCT_OFFSET (GDBusObjectIface, interface_added), | 
					
						
							|  |  |  |                 NULL, | 
					
						
							|  |  |  |                 NULL, | 
					
						
							| 
									
										
										
										
											2019-05-30 19:13:37 -07:00
										 |  |  |                 NULL, | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |                 G_TYPE_NONE, | 
					
						
							|  |  |  |                 1, | 
					
						
							|  |  |  |                 G_TYPE_DBUS_INTERFACE); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /**
 | 
					
						
							|  |  |  |    * GDBusObject::interface-removed: | 
					
						
							|  |  |  |    * @object: The #GDBusObject emitting the signal. | 
					
						
							|  |  |  |    * @interface: The #GDBusInterface that was removed. | 
					
						
							|  |  |  |    * | 
					
						
							|  |  |  |    * Emitted when @interface is removed from @object. | 
					
						
							| 
									
										
										
										
											2011-04-08 16:29:48 -04:00
										 |  |  |    * | 
					
						
							|  |  |  |    * Since: 2.30 | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-09-12 00:00:40 -04:00
										 |  |  |   g_signal_new (I_("interface-removed"), | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |                 G_TYPE_FROM_INTERFACE (iface), | 
					
						
							|  |  |  |                 G_SIGNAL_RUN_LAST, | 
					
						
							|  |  |  |                 G_STRUCT_OFFSET (GDBusObjectIface, interface_removed), | 
					
						
							|  |  |  |                 NULL, | 
					
						
							|  |  |  |                 NULL, | 
					
						
							| 
									
										
										
										
											2019-05-30 19:13:37 -07:00
										 |  |  |                 NULL, | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |                 G_TYPE_NONE, | 
					
						
							|  |  |  |                 1, | 
					
						
							|  |  |  |                 G_TYPE_DBUS_INTERFACE); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ---------------------------------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_dbus_object_get_object_path: | 
					
						
							|  |  |  |  * @object: A #GDBusObject. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Gets the object path for @object. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Returns: A string owned by @object. Do not free. | 
					
						
							| 
									
										
										
										
											2011-04-08 16:29:48 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |  */ | 
					
						
							|  |  |  | const gchar * | 
					
						
							|  |  |  | g_dbus_object_get_object_path (GDBusObject *object) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object); | 
					
						
							|  |  |  |   return iface->get_object_path (object); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_dbus_object_get_interfaces: | 
					
						
							|  |  |  |  * @object: A #GDBusObject. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Gets the D-Bus interfaces associated with @object. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-05-02 18:57:54 +05:30
										 |  |  |  * Returns: (element-type GDBusInterface) (transfer full): A list of #GDBusInterface instances. | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |  *   The returned list must be freed by g_list_free() after each element has been freed | 
					
						
							|  |  |  |  *   with g_object_unref(). | 
					
						
							| 
									
										
										
										
											2011-04-08 16:29:48 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |  */ | 
					
						
							|  |  |  | GList * | 
					
						
							|  |  |  | g_dbus_object_get_interfaces (GDBusObject *object) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object); | 
					
						
							|  |  |  |   return iface->get_interfaces (object); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * g_dbus_object_get_interface: | 
					
						
							|  |  |  |  * @object: A #GDBusObject. | 
					
						
							|  |  |  |  * @interface_name: A D-Bus interface name. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Gets the D-Bus interface with name @interface_name associated with | 
					
						
							|  |  |  |  * @object, if any. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2020-10-18 11:15:54 +03:00
										 |  |  |  * Returns: (nullable) (transfer full): %NULL if not found, otherwise a | 
					
						
							| 
									
										
										
										
											2011-04-16 14:42:21 -04:00
										 |  |  |  *   #GDBusInterface that must be freed with g_object_unref(). | 
					
						
							| 
									
										
										
										
											2011-04-08 16:29:48 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Since: 2.30 | 
					
						
							| 
									
										
										
										
											2011-04-08 15:14:47 -04:00
										 |  |  |  */ | 
					
						
							|  |  |  | GDBusInterface * | 
					
						
							|  |  |  | g_dbus_object_get_interface (GDBusObject *object, | 
					
						
							|  |  |  |                              const gchar *interface_name) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object); | 
					
						
							|  |  |  |   g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL); | 
					
						
							|  |  |  |   return iface->get_interface (object, interface_name); | 
					
						
							|  |  |  | } |