fix service callbacks

This commit is contained in:
Stefan Bethge 2006-09-25 18:47:21 +00:00
parent 9c570f9588
commit 7dfdefcdcf
1 changed files with 6 additions and 11 deletions

View File

@ -48,7 +48,7 @@ class Zeroconf:
self.remove_serviceCB = remove_serviceCB self.remove_serviceCB = remove_serviceCB
self.name_conflictCB = name_conflictCB self.name_conflictCB = name_conflictCB
self.service_browsers = {} self.service_browser = None
self.contacts = {} # all current local contacts with data self.contacts = {} # all current local contacts with data
self.entrygroup = None self.entrygroup = None
self.connected = False self.connected = False
@ -84,20 +84,15 @@ class Zeroconf:
def new_service_type(self, interface, protocol, stype, domain, flags): def new_service_type(self, interface, protocol, stype, domain, flags):
# Are we already browsing this domain for this type? # Are we already browsing this domain for this type?
if self.service_browsers.has_key((interface, protocol, stype, domain)): if self.service_browser:
return return
# print "Browsing for services of type '%s' in domain '%s' on %i.%i ..." % (stype, domain, interface, protocol) self.service_browser = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, \
b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, \
self.server.ServiceBrowserNew(interface, protocol, \ self.server.ServiceBrowserNew(interface, protocol, \
stype, domain, dbus.UInt32(0))),avahi.DBUS_INTERFACE_SERVICE_BROWSER) stype, domain, dbus.UInt32(0))),avahi.DBUS_INTERFACE_SERVICE_BROWSER)
print 'b', dir(b), dir(self.server) #print 'b', dir(b), dir(self.server)
b.Free() self.service_browser.connect_to_signal('ItemNew', self.new_service_callback)
b.connect_to_signal('ItemNew', self.new_service_callback) self.service_browser.connect_to_signal('ItemRemove', self.remove_service_callback)
b.connect_to_signal('ItemRemove', self.remove_service_callback)
#~ b.Free()
self.service_browsers[(interface, protocol, stype, domain)] = b
def new_domain_callback(self,interface, protocol, domain, flags): def new_domain_callback(self,interface, protocol, domain, flags):
if domain != "local": if domain != "local":