gdbus-auth: Fix leaks in tests
[platform/upstream/glib.git] / gio / tests / gdbus-example-peer.c
index 3a13858..b954f74 100644 (file)
@@ -1,17 +1,4 @@
 /*
- * Copyright © 2010 Red Hat, Inc.
- *
- * This program 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 version 2 of the licence or (at
- * your option) any later version.
- *
- * See the included COPYING file for more information.
- *
- * Author: David Zeuthen <davidz@redhat.com>
- */
-
-/*
 
 Usage examples (modulo addresses / credentials).
 
@@ -116,7 +103,7 @@ handle_method_call (GDBusConnection       *connection,
       const gchar *greeting;
       gchar *response;
 
-      g_variant_get (parameters, "(s)", &greeting);
+      g_variant_get (parameters, "(&s)", &greeting);
       response = g_strdup_printf ("You said '%s'. KTHXBYE!", greeting);
       g_dbus_method_invocation_return_value (invocation,
                                              g_variant_new ("(s)", response));
@@ -134,7 +121,7 @@ static const GDBusInterfaceVTable interface_vtable =
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-static void
+static gboolean
 on_new_connection (GDBusServer *server,
                    GDBusConnection *connection,
                    gpointer user_data)
@@ -159,13 +146,14 @@ on_new_connection (GDBusServer *server,
   g_object_ref (connection);
   registration_id = g_dbus_connection_register_object (connection,
                                                        "/org/gtk/GDBus/TestObject",
-                                                       "org.gtk.GDBus.TestPeerInterface",
                                                        introspection_data->interfaces[0],
                                                        &interface_vtable,
                                                        NULL,  /* user_data */
                                                        NULL,  /* user_data_free_func */
                                                        NULL); /* GError** */
   g_assert (registration_id > 0);
+
+  return TRUE;
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
@@ -189,8 +177,6 @@ main (int argc, char *argv[])
 
   ret = 1;
 
-  g_type_init ();
-
   opt_address = NULL;
   opt_server = FALSE;
   opt_allow_anonymous = FALSE;
@@ -273,6 +259,7 @@ main (int argc, char *argv[])
       error = NULL;
       connection = g_dbus_connection_new_for_address_sync (opt_address,
                                                            G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
+                                                           NULL, /* GDBusAuthObserver */
                                                            NULL, /* GCancellable */
                                                            &error);
       if (connection == NULL)
@@ -293,6 +280,7 @@ main (int argc, char *argv[])
                                            "org.gtk.GDBus.TestPeerInterface",
                                            "HelloWorld",
                                            g_variant_new ("(s)", greeting),
+                                           G_VARIANT_TYPE ("(s)"),
                                            G_DBUS_CALL_FLAGS_NONE,
                                            -1,
                                            NULL,
@@ -303,7 +291,7 @@ main (int argc, char *argv[])
           g_error_free (error);
           goto out;
         }
-      g_variant_get (value, "(s)", &greeting_response);
+      g_variant_get (value, "(&s)", &greeting_response);
       g_print ("Server said: %s\n", greeting_response);
       g_variant_unref (value);