[sugar] mdns/presence server from python

Thibaut Lamadon thibaut.lamadon
Tue Feb 20 22:06:06 EST 2007


Hi,

I'm currently working on a network based activity for the OLPC. Today we've
met with Chris Blizzard who pointed me to this list.

I try to use the mdns through python. More generally I'd like to get more
information and maybe some example (maybe some reference of code within
sugar to look at ) on how to use the presence server.

Here is what I've tried, but it doesn't work (it's a stripped down version
of AvahiBookmark)

class AvahiTest:

    def __init__(self, use_host_names):
        self.bus = dbus.SystemBus()
        self.server = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME,
avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER)
        self.version_string = self.server.GetVersionString()
        self.browse_service_type("_presence_olpc._tcp")

    def browse_service_type(self, stype):
        domain="local"
        browser = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME,
self.server.ServiceBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, stype,
domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER)
        browser.connect_to_signal('ItemNew', self.new_service)
        browser.connect_to_signal('ItemRemove', self.remove_service)

    def new_service(self, interface, protocol, name, type, domain, flags):
        print "new service!!!!"

    def remove_service(self, interface, protocol, name, type, domain):
        print "service removed!!!"


Thks

Thibaut Lamadon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.laptop.org/pipermail/sugar/attachments/20070220/91bcbc10/attachment.html


More information about the Sugar-devel mailing list