summaryrefslogtreecommitdiff
path: root/test/core/test-types.c
blob: 58f309cf8ecccb446f00e6307bd65cdb91dc3b01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <config.h>

#include <stdio.h>
#include <stdlib.h>
#include <dbus-glib.h>
#include <dbus-glib-lowlevel.h>

static void
lose (const char *str, ...)
{
  va_list args;

  va_start (args, str);

  vfprintf (stderr, str, args);
  fputc ('\n', stderr);

  va_end (args);

  exit (1);
}

int
main (int argc, char **argv)
{
  DBusError derror;
  GError *gerror = NULL;
  DBusGConnection *gconn, *gconn2;
  DBusConnection *conn;

  g_type_init ();
  dbus_error_init (&derror);

  /* Check DBusGConnection -> DBusConnection -> DBusGConnection */
  gconn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &gerror);
  if (!gconn)
    lose ("Cannot get connection: %s", gerror->message);
  
  conn = dbus_g_connection_get_connection (gconn);
  if (!conn)
    lose ("Cannot get DBusConnection from DBusGConnection");

  gconn2 = dbus_connection_get_g_connection (conn);
  if (gconn != gconn2)
    lose ("Retrieved DBusGConection != original DBusGConnection");

  dbus_connection_close (conn);
  dbus_g_connection_unref (gconn);
  dbus_shutdown ();

  return 0;
}