cleanup
[platform/upstream/glib.git] / gio / gdbusinterface.c
index 9404500..5c1b355 100644 (file)
@@ -13,9 +13,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  *
  * Author: David Zeuthen <davidz@redhat.com>
  */
@@ -24,7 +22,6 @@
 
 #include "gdbusobject.h"
 #include "gdbusinterface.h"
-#include "gio-marshal.h"
 
 #include "glibintl.h"
 
@@ -34,8 +31,8 @@
  * @include: gio/gio.h
  *
  * The #GDBusInterface type is the base type for D-Bus interfaces both
- * on the service side (see #GDBusInterfaceStub) and client side (see
- * #GDBusProxy).
+ * on the service side (see #GDBusInterfaceSkeleton) and client side
+ * (see #GDBusProxy).
  */
 
 typedef GDBusInterfaceIface GDBusInterfaceInterface;
@@ -50,56 +47,93 @@ g_dbus_interface_default_init (GDBusInterfaceIface *iface)
 
 /**
  * g_dbus_interface_get_info:
- * @interface: An exported D-Bus interface.
+ * @interface_: An exported D-Bus interface.
  *
  * Gets D-Bus introspection information for the D-Bus interface
- * implemented by @interface.
+ * implemented by @interface_.
  *
  * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
  *
  * Since: 2.30
  */
 GDBusInterfaceInfo *
-g_dbus_interface_get_info (GDBusInterface *interface)
+g_dbus_interface_get_info (GDBusInterface *interface_)
 {
-  g_return_val_if_fail (G_IS_DBUS_INTERFACE (interface), NULL);
-  return G_DBUS_INTERFACE_GET_IFACE (interface)->get_info (interface);
+  g_return_val_if_fail (G_IS_DBUS_INTERFACE (interface_), NULL);
+  return G_DBUS_INTERFACE_GET_IFACE (interface_)->get_info (interface_);
 }
 
 /**
- * g_dbus_interface_get_object:
- * @interface: An exported D-Bus interface.
+ * g_dbus_interface_get_object: (skip)
+ * @interface_: An exported D-Bus interface
  *
- * Gets the #GDBusObject that @interface belongs to, if any.
+ * Gets the #GDBusObject that @interface_ belongs to, if any.
+ *
+ * It is not safe to use the returned object if @interface_ or
+ * the returned object is being used from other threads. See
+ * g_dbus_interface_dup_object() for a thread-safe alternative.
  *
  * Returns: (transfer none): A #GDBusObject or %NULL. The returned
- * reference belongs to @interface and should not be freed.
+ *     reference belongs to @interface_ and should not be freed.
  *
  * Since: 2.30
  */
 GDBusObject *
-g_dbus_interface_get_object (GDBusInterface *interface)
+g_dbus_interface_get_object (GDBusInterface *interface_)
+{
+  g_return_val_if_fail (G_IS_DBUS_INTERFACE (interface_), NULL);
+  return G_DBUS_INTERFACE_GET_IFACE (interface_)->get_object (interface_);
+}
+
+/**
+ * g_dbus_interface_dup_object:
+ * @interface_: An exported D-Bus interface.
+ *
+ * Gets the #GDBusObject that @interface_ belongs to, if any.
+ *
+ * Returns: (transfer full): A #GDBusObject or %NULL. The returned
+ * reference should be freed with g_object_unref().
+ *
+ * Since: 2.32
+ *
+ * Rename to: g_dbus_interface_get_object
+ */
+GDBusObject *
+g_dbus_interface_dup_object (GDBusInterface *interface_)
 {
-  g_return_val_if_fail (G_IS_DBUS_INTERFACE (interface), NULL);
-  return G_DBUS_INTERFACE_GET_IFACE (interface)->get_object (interface);
+  GDBusObject *ret;
+  g_return_val_if_fail (G_IS_DBUS_INTERFACE (interface_), NULL);
+  if (G_LIKELY (G_DBUS_INTERFACE_GET_IFACE (interface_)->dup_object != NULL))
+    {
+      ret = G_DBUS_INTERFACE_GET_IFACE (interface_)->dup_object (interface_);
+    }
+  else
+    {
+      g_warning ("No dup_object() vfunc on type %s - using get_object() in a way that is not thread-safe.",
+                 g_type_name_from_instance ((GTypeInstance *) interface_));
+      ret = G_DBUS_INTERFACE_GET_IFACE (interface_)->get_object (interface_);
+      if (ret != NULL)
+        g_object_ref (ret);
+    }
+  return ret;
 }
 
 /**
  * g_dbus_interface_set_object:
- * @interface: An exported D-Bus interface.
- * @object: A #GDBusObject or %NULL.
+ * @interface_: An exported D-Bus interface.
+ * @object: (allow-none): A #GDBusObject or %NULL.
  *
- * Sets the #GDBusObject for @interface to @object.
+ * Sets the #GDBusObject for @interface_ to @object.
  *
- * Note that @interface will hold a weak reference to @object.
+ * Note that @interface_ will hold a weak reference to @object.
  *
  * Since: 2.30
  */
 void
-g_dbus_interface_set_object (GDBusInterface    *interface,
+g_dbus_interface_set_object (GDBusInterface    *interface_,
                              GDBusObject       *object)
 {
-  g_return_if_fail (G_IS_DBUS_INTERFACE (interface));
+  g_return_if_fail (G_IS_DBUS_INTERFACE (interface_));
   g_return_if_fail (object == NULL || G_IS_DBUS_OBJECT (object));
-  G_DBUS_INTERFACE_GET_IFACE (interface)->set_object (interface, object);
+  G_DBUS_INTERFACE_GET_IFACE (interface_)->set_object (interface_, object);
 }