#include <glib.h>
#include <stdio.h>
#include <gio/gio.h>

static void on_bus_acquired (GObject *source_object, GAsyncResult *res, gpointer data)
{
  guint *reg_id = (guint*) data;

  g_bus_get_finish (res, NULL);

  g_bus_unown_name (*reg_id);
}

int main (int argc, char**argv)
{
  guint reg_id;
  GMainLoop *ml;
  g_type_init ();


  reg_id = g_bus_own_name (G_BUS_TYPE_SESSION, "org.foo.Test", 0, 
                  NULL, NULL, NULL, NULL, NULL);

  g_bus_get (G_BUS_TYPE_SESSION, NULL, on_bus_acquired, &reg_id);

  ml = g_main_loop_new (NULL, FALSE);

  g_main_loop_run (ml);

  return 0;
}
