# -*- coding: utf-8 -*-

"""
Test to introspect a peer-to-peer dbus connection

1) Run Example 6 from http://developer.gnome.org/gio/unstable/GDBusServer.html#gdbus-peer-to-peer
   with: ./gdbus-example-peer --server --address unix:abstract=myaddr
2) To verify the server, try: gdbus introspect -a unix:abstract=myaddr -o /org/gtk/GDBus
3) run this script: ./python server-test.py
"""

from gi.repository import GObject, Gio, GLib


ADDRESS = "unix:abstract=myaddr"

print "Get connection for address '%s'" % (ADDRESS)
connection = Gio.DBusConnection.new_for_address_sync(ADDRESS,
                                                     Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT,
                                                     None, None)
res = connection.call_sync(None, "/org/gtk/GDBus", 'org.freedesktop.DBus.Introspectable', 'Introspect', None, GLib.VariantType.new("(s)"), Gio.DBusCallFlags.NONE, -1, None)

print "Result: ", res
