Imported Upstream version 2.59.0
[platform/upstream/glib.git] / gio / tests / gdbus-example-objectmanager-server.c
index 97e39b1..c460e66 100644 (file)
@@ -1,5 +1,5 @@
 
-#include "gdbus-example-objectmanager-generated.h"
+#include "gdbus-object-manager-example/objectmanager-gen.h"
 
 /* ---------------------------------------------------------------------------------------------------- */
 
@@ -62,13 +62,13 @@ on_bus_acquired (GDBusConnection *connection,
                  const gchar     *name,
                  gpointer         user_data)
 {
-  GDBusObjectStub *object;
+  ExampleObjectSkeleton *object;
   guint n;
 
   g_print ("Acquired a message bus connection\n");
 
   /* Create a new org.freedesktop.DBus.ObjectManager rooted at /example/Animals */
-  manager = g_dbus_object_manager_server_new (connection, "/example/Animals");
+  manager = g_dbus_object_manager_server_new ("/example/Animals");
 
   for (n = 0; n < 10; n++)
     {
@@ -77,16 +77,16 @@ on_bus_acquired (GDBusConnection *connection,
 
       /* Create a new D-Bus object at the path /example/Animals/N where N is 000..009 */
       s = g_strdup_printf ("/example/Animals/%03d", n);
-      object = g_dbus_object_stub_new (s);
+      object = example_object_skeleton_new (s);
       g_free (s);
 
       /* Make the newly created object export the interface
        * org.gtk.GDBus.Example.ObjectManager.Animal (note
        * that @object takes its own reference to @animal).
        */
-      animal = example_animal_stub_new ();
+      animal = example_animal_skeleton_new ();
       example_animal_set_mood (animal, "Happy");
-      g_dbus_object_stub_add_interface (object, G_DBUS_INTERFACE_STUB (animal));
+      example_object_skeleton_set_animal (object, animal);
       g_object_unref (animal);
 
       /* Cats are odd animals - so some of our objects implement the
@@ -96,8 +96,8 @@ on_bus_acquired (GDBusConnection *connection,
       if (n % 2 == 1)
         {
           ExampleCat *cat;
-          cat = example_cat_stub_new ();
-          g_dbus_object_stub_add_interface (object, G_DBUS_INTERFACE_STUB (cat));
+          cat = example_cat_skeleton_new ();
+          example_object_skeleton_set_cat (object, cat);
           g_object_unref (cat);
         }
 
@@ -108,9 +108,12 @@ on_bus_acquired (GDBusConnection *connection,
                         NULL); /* user_data */
 
       /* Export the object (@manager takes its own reference to @object) */
-      g_dbus_object_manager_server_export (manager, object);
+      g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
       g_object_unref (object);
     }
+
+  /* Export all objects */
+  g_dbus_object_manager_server_set_connection (manager, connection);
 }
 
 static void
@@ -136,8 +139,6 @@ main (gint argc, gchar *argv[])
   GMainLoop *loop;
   guint id;
 
-  g_type_init ();
-
   loop = g_main_loop_new (NULL, FALSE);
 
   id = g_bus_own_name (G_BUS_TYPE_SESSION,