diff options
| author | Lennart Poettering <lennart@poettering.net> | 2005-09-25 20:15:46 +0000 | 
|---|---|---|
| committer | Lennart Poettering <lennart@poettering.net> | 2005-09-25 20:15:46 +0000 | 
| commit | c202afe723757ecd3a21a508eaa2eccf2d72b45d (patch) | |
| tree | b3bc35fd8a70ec41aa00c078d2cf8277759e13b7 | |
| parent | 7da8bb6e9a1990413c943dcfd54c71d8744fcb00 (diff) | |
update python programs to new DBUS API
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@611 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
| -rwxr-xr-x | avahi-utils/avahi-bookmarks.in | 15 | ||||
| -rwxr-xr-x | avahi-utils/avahi-browse.in | 20 | ||||
| -rwxr-xr-x | avahi-utils/avahi-discover.in | 18 | ||||
| -rwxr-xr-x | avahi-utils/avahi-resolve-address.in | 2 | ||||
| -rwxr-xr-x | avahi-utils/avahi-resolve-host-name.in | 2 | 
5 files changed, 32 insertions, 25 deletions
| diff --git a/avahi-utils/avahi-bookmarks.in b/avahi-utils/avahi-bookmarks.in index 49c4e3b..df36f49 100755 --- a/avahi-utils/avahi-bookmarks.in +++ b/avahi-utils/avahi-bookmarks.in @@ -46,6 +46,7 @@ urlproto = { "_http._tcp" : "http",  "_https._tcp" : "https", "_ftp._tcp" : "ftp  port = 8080  address = "127.0.0.1"  use_host_names = False +domain = "local"  class AvahiBookmarks(resource.Resource):      isLeaf = True @@ -68,7 +69,9 @@ class AvahiBookmarks(resource.Resource):      def browse_service_type(self, stype): -        browser = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, stype, "local")), avahi.DBUS_INTERFACE_SERVICE_BROWSER) +        global domain + +        browser = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, stype, domain, 0)), avahi.DBUS_INTERFACE_SERVICE_BROWSER)          browser.connect_to_signal('ItemNew', self.new_service)          browser.connect_to_signal('ItemRemove', self.remove_service) @@ -111,9 +114,9 @@ class AvahiBookmarks(resource.Resource):          return t -    def new_service(self, interface, protocol, name, type, domain): +    def new_service(self, interface, protocol, name, type, domain, flags): -        interface, protocol, name, type, domain, host, aprotocol, address, port, txt = self.server.ResolveService(interface, protocol, name, type, domain, avahi.PROTO_UNSPEC) +        interface, protocol, name, type, domain, host, aprotocol, address, port, txt, flags = self.server.ResolveService(interface, protocol, name, type, domain, avahi.PROTO_UNSPEC, 0)          if use_host_names:              h = host @@ -135,10 +138,11 @@ def usage(retval = 0):      print "   -p --port PORT        Specify the port to use (default %u)" % port      print "   -a --address ADDRESS  Specify the address to bind to (default %s)" % address      print "   -H --host-names       Show all services, regardless of the type" +    print "   -d --domain DOMAIN    Specify the domain to browse"       sys.exit(retval)  try: -    opts, args = getopt.getopt(sys.argv[1:], "hp:a:H", ["help", "port=", "address=", "host-names"]) +    opts, args = getopt.getopt(sys.argv[1:], "hp:a:Hd:", ["help", "port=", "address=", "host-names", "domain="])  except getopt.GetoptError:      usage(2) @@ -154,6 +158,9 @@ for o, a in opts:      if o in ("-H", "--host-names"):          use_host_names = True + +    if o in ("-d", "--domain"): +        domain = a  site = server.Site(AvahiBookmarks())  reactor.listenTCP(port, site, interface=address) diff --git a/avahi-utils/avahi-browse.in b/avahi-utils/avahi-browse.in index 1acc165..6ae00ba 100755 --- a/avahi-utils/avahi-browse.in +++ b/avahi-utils/avahi-browse.in @@ -88,25 +88,25 @@ def lookup_service_type(stype):      except KeyError:          return "n/a" -def service_resolved(interface, protocol, name, stype, domain, host, aprotocol, address, port, txt): +def service_resolved(interface, protocol, name, stype, domain, host, aprotocol, address, port, txt, flags):      print "Service data for service '%s' of type '%s' (%s) in domain '%s' on %s.%i:" % (name, stype, lookup_service_type(stype), domain, siocgifname(interface), protocol)      print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, avahi.txt_array_to_string_array(txt))  def print_error(err):      print "Error:", str(err) -def new_service(interface, protocol, name, stype, domain): +def new_service(interface, protocol, name, stype, domain, flags):      global server      print "Found service '%s' of type '%s' (%s) in domain '%s' on %s.%i." % (name, stype, lookup_service_type(stype), domain, siocgifname(interface), protocol)      # Asynchronous resolving -    server.ResolveService(interface, protocol, name, stype, domain, avahi.PROTO_UNSPEC, reply_handler=service_resolved, error_handler=print_error) +    server.ResolveService(interface, protocol, name, stype, domain, avahi.PROTO_UNSPEC, 0, reply_handler=service_resolved, error_handler=print_error) -def remove_service(interface, protocol, name, stype, domain): +def remove_service(interface, protocol, name, stype, domain, flags):      print "Service '%s' of type '%s' (%s) in domain '%s' on %s.%i disappeared." % (name, stype, lookup_service_type(stype), domain, siocgifname(interface), protocol) -def new_service_type(interface, protocol, stype, domain): +def new_service_type(interface, protocol, stype, domain, flags):      global server, service_browsers      # Are we already browsing this domain for this type?  @@ -115,7 +115,7 @@ def new_service_type(interface, protocol, stype, domain):      print "Browsing for services of type '%s' (%s) in domain '%s' on %s.%i ..." % (stype, lookup_service_type(stype), domain, siocgifname(interface), protocol) -    b = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.ServiceBrowserNew(interface, protocol, stype, domain)), avahi.DBUS_INTERFACE_SERVICE_BROWSER) +    b = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.ServiceBrowserNew(interface, protocol, stype, domain, 0)), avahi.DBUS_INTERFACE_SERVICE_BROWSER)      b.connect_to_signal('ItemNew', new_service)      b.connect_to_signal('ItemRemove', remove_service) @@ -131,14 +131,14 @@ def browse_domain(interface, protocol, domain):      if stype is None:          print "Browsing domain '%s' on %s.%i ..." % (domain, siocgifname(interface), protocol) -        b = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.ServiceTypeBrowserNew(interface, protocol, domain)), avahi.DBUS_INTERFACE_SERVICE_TYPE_BROWSER) +        b = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.ServiceTypeBrowserNew(interface, protocol, domain, 0)), avahi.DBUS_INTERFACE_SERVICE_TYPE_BROWSER)          b.connect_to_signal('ItemNew', new_service_type)          service_type_browsers[(interface, protocol, domain)] = b      else: -        new_service_type(interface, protocol, stype, domain) +        new_service_type(interface, protocol, stype, domain, 0) -def new_domain(interface, protocol, domain): +def new_domain(interface, protocol, domain, flags):      # We browse for .local anyway...      if domain != "local": @@ -153,7 +153,7 @@ if domain is None:      browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "local")      # Browse for other browsable domains -    db = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.DomainBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "", avahi.DOMAIN_BROWSER_BROWSE)), avahi.DBUS_INTERFACE_DOMAIN_BROWSER) +    db = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.DomainBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "", avahi.DOMAIN_BROWSER_BROWSE, 0)), avahi.DBUS_INTERFACE_DOMAIN_BROWSER)      db.connect_to_signal('ItemNew', new_domain)  else: diff --git a/avahi-utils/avahi-discover.in b/avahi-utils/avahi-discover.in index 04d133c..77ce72f 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("<i>No service currently selected.</i>")              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, 0, reply_handler=self.service_resolved, error_handler=self.print_error)      def protoname(self,protocol): @@ -68,7 +68,7 @@ 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))) @@ -93,7 +93,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 +108,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 +132,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 +141,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, 0)),  avahi.DBUS_INTERFACE_SERVICE_BROWSER)          b.connect_to_signal('ItemNew', self.new_service)          b.connect_to_signal('ItemRemove', self.remove_service) @@ -157,14 +157,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, 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: @@ -211,7 +211,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, 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 diff --git a/avahi-utils/avahi-resolve-address.in b/avahi-utils/avahi-resolve-address.in index 71c6287..a645bbd 100755 --- a/avahi-utils/avahi-resolve-address.in +++ b/avahi-utils/avahi-resolve-address.in @@ -44,7 +44,7 @@ ret = 0  for a in sys.argv[1:]:      try: -        r = server.ResolveAddress(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, a) +        r = server.ResolveAddress(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, a, 0)          print r[3], r[4]      except dbus.DBusException, e:          print "Resolving '%s' failed: %s" % (a, str(e)) diff --git a/avahi-utils/avahi-resolve-host-name.in b/avahi-utils/avahi-resolve-host-name.in index cc24526..3cc97b0 100755 --- a/avahi-utils/avahi-resolve-host-name.in +++ b/avahi-utils/avahi-resolve-host-name.in @@ -44,7 +44,7 @@ ret = 0  for name in sys.argv[1:]:      try: -        r = server.ResolveHostName(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, name, avahi.PROTO_UNSPEC) +        r = server.ResolveHostName(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, name, avahi.PROTO_UNSPEC, 0)          print r[2], r[4]      except dbus.DBusException, e:          print "Resolving '%s' failed: %s" % (name, str(e)) | 
