#!/usr/bin/python
import sys
import telepathy
from telepathy.interfaces import CONN_MGR_INTERFACE
from telepathy.constants import CONN_MGR_PARAM_FLAG_REQUIRED, \
                                CONN_MGR_PARAM_FLAG_REGISTER

if len(sys.argv) >= 2:
    manager_name = sys.argv[1]
else:
    manager_name = "haze"
service_name = "org.freedesktop.Telepathy.ConnectionManager.%s" % manager_name
object_path = "/org/freedesktop/Telepathy/ConnectionManager/%s" % manager_name

object = telepathy.client.ConnectionManager(service_name, object_path)
manager = object[CONN_MGR_INTERFACE]

print "[ConnectionManager]"
print "BusName=%s" % service_name
print "ObjectPath=%s" % object_path
print

protocols = manager.ListProtocols()
protocols.sort()
for protocol in protocols:
    print "[Protocol %s]" % protocol
    for param in manager.GetParameters(protocol):
        (name, flags, type, default) = param

        print "param-%s=%s" % (name, type),
        if flags & CONN_MGR_PARAM_FLAG_REQUIRED:
            print "required",
        if flags & CONN_MGR_PARAM_FLAG_REGISTER:
            print "register",
        print
    print

@@ -756,16 +756,34 @@
 tocols:%0A
+    defaults = %5B%5D%0A
     prin
@@ -1122,16 +1122,461 @@
    print
+%0A%0A        if default != %22%22: # FIXME: is there a better way to check if a default%0A                          #        exists?%0A            defaults.append( (name, type, default) )%0A    for default in defaults:%0A        if default%5B1%5D == %22b%22:%0A            if default%5B2%5D:%0A                value = %22true%22%0A            else:%0A                value = %22false%22%0A        else:%0A            value = str(default%5B2%5D)%0A        print %22default-%25s=%25s%22 %25 (default%5B0%5D, value)
 %0A    pri

Include default values in generated .manager files