X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-utils%2Favahi-discover.in;h=00a56023cd1712921648915a7337aa882491ffd1;hb=2d48326e6731cb9266119cd531daac0bbf683f44;hp=04d133cdf439ff7f12ee0bfba73d0fa5b969b6fb;hpb=e14682626f03c86aad4d71d5a8562715ebbb2927;p=catta diff --git a/avahi-utils/avahi-discover.in b/avahi-utils/avahi-discover.in index 04d133c..00a5602 100755 --- a/avahi-utils/avahi-discover.in +++ b/avahi-utils/avahi-discover.in @@ -52,7 +52,7 @@ class Main_window(SimpleGladeApp): self.info_label.set_markup("No service currently selected.") return #Asynchronous resolving - self.server.ResolveService( int(interface), int(protocol), name, stype, domain, avahi.PROTO_UNSPEC, reply_handler=self.service_resolved, error_handler=self.print_error) + self.server.ResolveService( int(interface), int(protocol), name, stype, domain, avahi.PROTO_UNSPEC, dbus.UInt32(0), reply_handler=self.service_resolved, error_handler=self.print_error) def protoname(self,protocol): @@ -68,17 +68,12 @@ class Main_window(SimpleGladeApp): else: return self.server.GetNetworkInterfaceNameByIndex(interface) - def service_resolved(self, interface, protocol, name, stype, domain, host, aprotocol, address, port, txt): + def service_resolved(self, interface, protocol, name, stype, domain, host, aprotocol, address, port, txt, flags): print "Service data for service '%s' of type '%s' in domain '%s' on %i.%i:" % (name, stype, domain, interface, protocol) print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, str(avahi.txt_array_to_string_array(txt))) - if len(txt) == 0: - txt_data = "empty" - else: - txt_data = str(avahi.txt_array_to_string_array(txt)) - - self.update_label(interface, protocol, name, stype, domain, host, aprotocol, address, port, txt_data) + self.update_label(interface, protocol, name, stype, domain, host, aprotocol, address, port, avahi.txt_array_to_string_array(txt)) def print_error(self, err): error_label = "Error: %s" % (err) @@ -93,7 +88,7 @@ class Main_window(SimpleGladeApp): except KeyError: return stype - def new_service(self, interface, protocol, name, stype, domain): + def new_service(self, interface, protocol, name, stype, domain, flags): print "Found service '%s' of type '%s' in domain '%s' on %i.%i." % (name, stype, domain, interface, protocol) if self.zc_ifaces.has_key((interface,protocol)) == False: self.zc_ifaces[(interface,protocol)] = self.insert_row(self.treemodel, None, str(self.siocgifname(interface))+" "+str(self.protoname(protocol)),None,interface,protocol,None,domain) @@ -108,7 +103,7 @@ class Main_window(SimpleGladeApp): self.tree_view.expand_to_path(self.treemodel.get_path(treeiter)) - def remove_service(self, interface, protocol, name, stype, domain): + def remove_service(self, interface, protocol, name, stype, domain, flags): print "Service '%s' of type '%s' in domain '%s' on %i.%i disappeared." % (name, stype, domain, interface, protocol) self.info_label.set_markup("") treeiter=self.services_browsed[(interface, protocol, name, stype, domain)] @@ -132,7 +127,7 @@ class Main_window(SimpleGladeApp): del self.zc_ifaces[(interface,protocol)] - def new_service_type(self, interface, protocol, stype, domain): + def new_service_type(self, interface, protocol, stype, domain, flags): global service_browsers # Are we already browsing this domain for this type? @@ -141,7 +136,7 @@ class Main_window(SimpleGladeApp): print "Browsing for services of type '%s' in domain '%s' on %i.%i ..." % (stype, domain, interface, protocol) - b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(interface, protocol, stype, domain)), avahi.DBUS_INTERFACE_SERVICE_BROWSER) + b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(interface, protocol, stype, domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER) b.connect_to_signal('ItemNew', self.new_service) b.connect_to_signal('ItemRemove', self.remove_service) @@ -157,14 +152,14 @@ class Main_window(SimpleGladeApp): if self.stype is None: print "Browsing domain '%s' on %i.%i ..." % (domain, interface, protocol) - b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceTypeBrowserNew(interface, protocol, domain)), avahi.DBUS_INTERFACE_SERVICE_TYPE_BROWSER) + b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceTypeBrowserNew(interface, protocol, domain, dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_TYPE_BROWSER) b.connect_to_signal('ItemNew', self.new_service_type) service_type_browsers[(interface, protocol, domain)] = b else: new_service_type(interface, protocol, stype, domain) - def new_domain(self,interface, protocol, domain): + def new_domain(self,interface, protocol, domain, flags): if self.zc_ifaces.has_key((interface,protocol)) == False: self.zc_ifaces[(interface,protocol)] = self.insert_row(self.treemodel, None, str(self.siocgifname(interface))+" "+str(self.protoname(protocol)),None,interface,protocol,None,domain) if self.zc_domains.has_key((interface,protocol,domain)) == False: @@ -172,8 +167,28 @@ class Main_window(SimpleGladeApp): if domain != "local": self.browse_domain(interface, protocol, domain) + def pair_to_dict(self, l): + res = dict() + for el in l: + if "=" not in el: + res[el]='' + else: + tmp = el.split('=',1) + if len(tmp[0]) > 0: + res[tmp[0]] = tmp[1] + return res + + def update_label(self,interface, protocol, name, stype, domain, host, aprotocol, address, port, txt): - infos = "Service Type: %s\nService Name: %s\nDomain Name: %s\nInterface: %s %s\nAddress: %s/%s:%i\nTXT Data: %s" % (stype, name, domain, self.siocgifname(interface), self.protoname(protocol), host, address, port, str(txt)) + if len(txt) != 0: + txts = "" + txtd = self.pair_to_dict(txt) + for k,v in txtd.items(): + txts+="TXT %s = %s\n" % (k,v) + else: + txts = "TXT Data: empty" + + infos = "Service Type: %s\nService Name: %s\nDomain Name: %s\nInterface: %s %s\nAddress: %s/%s:%i\n%s" % (stype, name, domain, self.siocgifname(interface), self.protoname(protocol), host, address, port, txts.strip()) self.info_label.set_markup(infos) def insert_row(self, model,parent, @@ -211,7 +226,7 @@ class Main_window(SimpleGladeApp): self.browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "local") # Browse for other browsable domains - db = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.DomainBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "", avahi.DOMAIN_BROWSER_BROWSE)), avahi.DBUS_INTERFACE_DOMAIN_BROWSER) + db = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.DomainBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "", avahi.DOMAIN_BROWSER_BROWSE, dbus.UInt32(0))), avahi.DBUS_INTERFACE_DOMAIN_BROWSER) db.connect_to_signal('ItemNew', self.new_domain) else: # Just browse the domain the user wants us to browse