From: Sebastien Estienne Date: Tue, 2 Aug 2005 23:14:13 +0000 (+0000) Subject: * add avahi-utils in autoconf X-Git-Url: http://git.meshlink.io/?p=catta;a=commitdiff_plain;h=1a912326734243e57a461c48131c1a0402318b5a * add avahi-utils in autoconf git-svn-id: file:///home/lennart/svn/public/avahi/trunk@211 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/Makefile.am b/Makefile.am index 6652d1a..4d25b3c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,11 +19,11 @@ include aminclude.am EXTRA_DIST = bootstrap.sh LICENSE $(DX_CONFIG) -SUBDIRS = avahi-common avahi-core avahi-discover avahi-client avahi-daemon initscript avahi-dnsconfd +SUBDIRS = avahi-common avahi-core avahi-discover avahi-client avahi-daemon initscript avahi-dnsconfd avahi-utils pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = avahi-core.pc MOSTLYCLEANFILES = $(DX_CLEANFILES) -.PHONY: distcleancheck +#.PHONY: distcleancheck diff --git a/avahi-utils/Makefile.am b/avahi-utils/Makefile.am new file mode 100644 index 0000000..ac8686e --- /dev/null +++ b/avahi-utils/Makefile.am @@ -0,0 +1,6 @@ +SUBDIRS=avahi + +avahiscriptsdir = $(bindir) +avahiscripts_SCRIPTS = avahi-publish-address avahi-publish-service avahi-dump-all + +EXTRA_DIST = $(avahiscripts_SCRIPTS) diff --git a/avahi-utils/SimpleGladeApp.py b/avahi-utils/SimpleGladeApp.py deleted file mode 100644 index 6d204e3..0000000 --- a/avahi-utils/SimpleGladeApp.py +++ /dev/null @@ -1,122 +0,0 @@ -# SimpleGladeApp.py -# Module that provides an object oriented abstraction to pygtk and libglade. -# Copyright (C) 2004 Sandino Flores Moreno - -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA - -try: - import os - import sys - import gtk - import gtk.glade - import weakref -except ImportError: - print "Error importing pygtk2 and pygtk2-libglade" - sys.exit(1) - -class SimpleGladeApp(dict): - def __init__(self, glade_filename, main_widget_name=None, domain=None, **kwargs): - if os.path.isfile(glade_filename): - self.glade_path = glade_filename - else: - glade_dir = os.path.split( sys.argv[0] )[0] - self.glade_path = os.path.join(glade_dir, glade_filename) - for key, value in kwargs.items(): - try: - setattr(self, key, weakref.proxy(value) ) - except TypeError: - setattr(self, key, value) - self.glade = None - gtk.glade.set_custom_handler(self.custom_handler) - self.glade = gtk.glade.XML(self.glade_path, main_widget_name, domain) - if main_widget_name: - self.main_widget = self.glade.get_widget(main_widget_name) - else: - self.main_widget = None - self.signal_autoconnect() - self.new() - - def signal_autoconnect(self): - signals = {} - for attr_name in dir(self): - attr = getattr(self, attr_name) - if callable(attr): - signals[attr_name] = attr - self.glade.signal_autoconnect(signals) - - def custom_handler(self, - glade, function_name, widget_name, - str1, str2, int1, int2): - if hasattr(self, function_name): - handler = getattr(self, function_name) - return handler(str1, str2, int1, int2) - - def __getattr__(self, name): - if name in self: - data = self[name] - return data - else: - widget = self.glade.get_widget(name) - if widget != None: - self[name] = widget - return widget - else: - raise AttributeError, name - - def __setattr__(self, name, value): - self[name] = value - - def new(self): - pass - - def on_keyboard_interrupt(self): - pass - - def gtk_widget_show(self, widget, *args): - widget.show() - - def gtk_widget_hide(self, widget, *args): - widget.hide() - - def gtk_widget_grab_focus(self, widget, *args): - widget.grab_focus() - - def gtk_widget_destroy(self, widget, *args): - widget.destroy() - - def gtk_window_activate_default(self, widget, *args): - widget.activate_default() - - def gtk_true(self, *args): - return gtk.TRUE - - def gtk_false(self, *args): - return gtk.FALSE - - def gtk_main_quit(self, *args): - gtk.main_quit() - - def main(self): - gtk.main() - - def quit(self): - gtk.main_quit() - - def run(self): - try: - self.main() - except KeyboardInterrupt: - self.on_keyboard_interrupt() diff --git a/avahi-utils/avahi-discover b/avahi-utils/avahi-discover deleted file mode 100755 index 9ebae71..0000000 --- a/avahi-utils/avahi-discover +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/python2.4 -# -*-python-*- -# $Id$ - -import os -import gtk -import gobject -from SimpleGladeApp import SimpleGladeApp - -import avahi, dbus, gobject, sys - - -try: - import dbus.glib -except ImportError, e: - pass - -service_type_browsers = {} -service_browsers = {} - - -glade_dir = "../avahi-discover/" - -class Main_window(SimpleGladeApp): - def __init__(self, path="avahi-discover.glade", root="main_window", domain=None, **kwargs): - path = os.path.join(glade_dir, path) - SimpleGladeApp.__init__(self, path, root, domain, **kwargs) - - def on_tree_view_cursor_changed(self, widget, *args): - (model, iter) = widget.get_selection().get_selected() - (name,interface,protocol,type,domain) = self.treemodel.get(iter,0,1,2,3,4) - if type == None: - self.info_label.set_markup("No service currently selected.") - return - #Asynchronous resolving - self.server.ResolveService( int(interface), int(protocol), name, type, domain, avahi.PROTO_UNSPEC, reply_handler=self.service_resolved, error_handler=self.print_error) - - - def service_resolved(self, interface, protocol, name, type, domain, host, aprotocol, address, port, txt): - print "Service data for service '%s' of type '%s' in domain '%s' on %i.%i:" % (name, type, domain, interface, protocol) - print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, str(txt)) - self.update_label(interface, protocol, name, type, domain, host, aprotocol, address, port, str(txt)) - - def print_error(err): - print "Error:", str(err) - - def new_service(self, interface, protocol, name, type, domain): - print "Found service '%s' of type '%s' in domain '%s' on %i.%i." % (name, type, domain, interface, protocol) - if self.service_type.has_key(type) == False: - self.service_type[type] = self.insert_row(self.treemodel,None,type, interface,None,None,None) - treeiter = self.insert_row(self.treemodel,self.service_type[type],name, interface,protocol,type,domain) - self.services_browsed[(interface, protocol, name, type, domain)] = treeiter - - - def remove_service(self, interface, protocol, name, type, domain): - print "Service '%s' of type '%s' in domain '%s' on %i.%i disappeared." % (name, type, domain, interface, protocol) - treeiter=self.services_browsed[(interface, protocol, name, type, domain)] - parent = self.treemodel.iter_parent(treeiter) - self.treemodel.remove(treeiter) - del self.services_browsed[(interface, protocol, name, type, domain)] - if self.treemodel.iter_has_child(parent) == False: - self.treemodel.remove(parent) - del self.service_type[type] - - def new_service_type(self, interface, protocol, type, domain): - global service_browsers - - # Are we already browsing this domain for this type? - if service_browsers.has_key((interface, protocol, type, domain)): - return - - print "Browsing for services of type '%s' in domain '%s' on %i.%i ..." % (type, domain, interface, protocol) - - b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(interface, protocol, type, domain)), avahi.DBUS_INTERFACE_SERVICE_BROWSER) - b.connect_to_signal('ItemNew', self.new_service) - b.connect_to_signal('ItemRemove', self.remove_service) - - service_browsers[(interface, protocol, type, domain)] = b - - def browse_domain(self, interface, protocol, domain): - global service_type_browsers - - # Are we already browsing this domain? - if service_type_browsers.has_key((interface, protocol, domain)): - return - - 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.connect_to_signal('ItemNew', self.new_service_type) - - service_type_browsers[(interface, protocol, domain)] = b - - def new_domain(self,interface, protocol, domain): - - # We browse for .local anyway... - if domain != "local": - browse_domain(interface, protocol, domain) - - def update_label(self,interface, protocol, name, type, domain, host, aprotocol, address, port, txt): - if protocol == avahi.PROTO_INET: - protocol = "IPv4" - if protocol == avahi.PROTO_INET6: - protocol = "IPv6" - infos = "Service Type: %s\nService Name: %s\nDomain Name: %s\nInterface:#%i %s\nAddress: %s/%s:%i\nTXT Data: %s" % (type, name, domain, interface, protocol, host, address, port, str(txt)) - self.info_label.set_markup(infos) - - def insert_row(self, model,parent, - name, interface,protocol,type,domain): - myiter=model.insert_after(parent,None) - model.set(myiter,0,name,1,interface,2,protocol,3,type,4,domain) - return myiter - - def new(self): - print "A new main_window has been created" - self.treemodel=gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) - self.tree_view.set_model(self.treemodel) - - #creating the columns headers - self.tree_view.set_headers_visible(True) - renderer=gtk.CellRendererText() - column=gtk.TreeViewColumn("Name",renderer, text=0) - column.set_resizable(True) - column.set_sizing("GTK_TREE_VIEW_COLUMN_GROW_ONLY"); - column.set_expand(True); - self.tree_view.append_column(column) - renderer=gtk.CellRendererText() - column=gtk.TreeViewColumn("Interface",renderer, - text=1) - column.set_resizable(True) - self.tree_view.append_column(column) - - # testing with fake data - self.service_type = {} - self.services_browsed = {} - - model=self.treemodel - - domain = None - - self.bus = dbus.SystemBus() - self.server = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) - - if domain is None: - # Explicitly browse .local - 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.connect_to_signal('ItemNew', self.new_domain) - - else: - # Just browse the domain the user wants us to browse - self.browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, domain) - - - -def main(): - main_window = Main_window() - - main_window.run() - -if __name__ == "__main__": - main() - - diff --git a/avahi-utils/avahi-discover.in b/avahi-utils/avahi-discover.in new file mode 100755 index 0000000..9734ae6 --- /dev/null +++ b/avahi-utils/avahi-discover.in @@ -0,0 +1,165 @@ +#!/usr/bin/env @PYTHON@ +# -*-python-*- +# $Id$ + +import os +import gtk +import gobject + +import avahi, dbus, gobject, sys +from avahi.SimpleGladeApp import SimpleGladeApp + +try: + import dbus.glib +except ImportError, e: + pass + +service_type_browsers = {} +service_browsers = {} + + +glade_dir = "@prefix@/share/@PACKAGE@/interfaces" + +class Main_window(SimpleGladeApp): + def __init__(self, path="avahi-discover.glade", root="main_window", domain=None, **kwargs): + path = os.path.join(glade_dir, path) + SimpleGladeApp.__init__(self, path, root, domain, **kwargs) + + def on_tree_view_cursor_changed(self, widget, *args): + (model, iter) = widget.get_selection().get_selected() + (name,interface,protocol,type,domain) = self.treemodel.get(iter,0,1,2,3,4) + if type == None: + self.info_label.set_markup("No service currently selected.") + return + #Asynchronous resolving + self.server.ResolveService( int(interface), int(protocol), name, type, domain, avahi.PROTO_UNSPEC, reply_handler=self.service_resolved, error_handler=self.print_error) + + + def service_resolved(self, interface, protocol, name, type, domain, host, aprotocol, address, port, txt): + print "Service data for service '%s' of type '%s' in domain '%s' on %i.%i:" % (name, type, domain, interface, protocol) + print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, str(txt)) + self.update_label(interface, protocol, name, type, domain, host, aprotocol, address, port, str(txt)) + + def print_error(err): + print "Error:", str(err) + + def new_service(self, interface, protocol, name, type, domain): + print "Found service '%s' of type '%s' in domain '%s' on %i.%i." % (name, type, domain, interface, protocol) + if self.service_type.has_key(type) == False: + self.service_type[type] = self.insert_row(self.treemodel,None,type, interface,None,None,None) + treeiter = self.insert_row(self.treemodel,self.service_type[type],name, interface,protocol,type,domain) + self.services_browsed[(interface, protocol, name, type, domain)] = treeiter + + + def remove_service(self, interface, protocol, name, type, domain): + print "Service '%s' of type '%s' in domain '%s' on %i.%i disappeared." % (name, type, domain, interface, protocol) + treeiter=self.services_browsed[(interface, protocol, name, type, domain)] + parent = self.treemodel.iter_parent(treeiter) + self.treemodel.remove(treeiter) + del self.services_browsed[(interface, protocol, name, type, domain)] + if self.treemodel.iter_has_child(parent) == False: + self.treemodel.remove(parent) + del self.service_type[type] + + def new_service_type(self, interface, protocol, type, domain): + global service_browsers + + # Are we already browsing this domain for this type? + if service_browsers.has_key((interface, protocol, type, domain)): + return + + print "Browsing for services of type '%s' in domain '%s' on %i.%i ..." % (type, domain, interface, protocol) + + b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(interface, protocol, type, domain)), avahi.DBUS_INTERFACE_SERVICE_BROWSER) + b.connect_to_signal('ItemNew', self.new_service) + b.connect_to_signal('ItemRemove', self.remove_service) + + service_browsers[(interface, protocol, type, domain)] = b + + def browse_domain(self, interface, protocol, domain): + global service_type_browsers + + # Are we already browsing this domain? + if service_type_browsers.has_key((interface, protocol, domain)): + return + + 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.connect_to_signal('ItemNew', self.new_service_type) + + service_type_browsers[(interface, protocol, domain)] = b + + def new_domain(self,interface, protocol, domain): + + # We browse for .local anyway... + if domain != "local": + browse_domain(interface, protocol, domain) + + def update_label(self,interface, protocol, name, type, domain, host, aprotocol, address, port, txt): + if protocol == avahi.PROTO_INET: + protocol = "IPv4" + if protocol == avahi.PROTO_INET6: + protocol = "IPv6" + infos = "Service Type: %s\nService Name: %s\nDomain Name: %s\nInterface:#%i %s\nAddress: %s/%s:%i\nTXT Data: %s" % (type, name, domain, interface, protocol, host, address, port, str(txt)) + self.info_label.set_markup(infos) + + def insert_row(self, model,parent, + name, interface,protocol,type,domain): + myiter=model.insert_after(parent,None) + model.set(myiter,0,name,1,interface,2,protocol,3,type,4,domain) + return myiter + + def new(self): + print "A new main_window has been created" + self.treemodel=gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) + self.tree_view.set_model(self.treemodel) + + #creating the columns headers + self.tree_view.set_headers_visible(True) + renderer=gtk.CellRendererText() + column=gtk.TreeViewColumn("Name",renderer, text=0) + column.set_resizable(True) + column.set_sizing("GTK_TREE_VIEW_COLUMN_GROW_ONLY"); + column.set_expand(True); + self.tree_view.append_column(column) + renderer=gtk.CellRendererText() + column=gtk.TreeViewColumn("Interface",renderer, + text=1) + column.set_resizable(True) + self.tree_view.append_column(column) + + # testing with fake data + self.service_type = {} + self.services_browsed = {} + + model=self.treemodel + + domain = None + + self.bus = dbus.SystemBus() + self.server = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) + + if domain is None: + # Explicitly browse .local + 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.connect_to_signal('ItemNew', self.new_domain) + + else: + # Just browse the domain the user wants us to browse + self.browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, domain) + + + +def main(): + main_window = Main_window() + + main_window.run() + +if __name__ == "__main__": + main() + + diff --git a/avahi-utils/avahi-dump-all b/avahi-utils/avahi-dump-all deleted file mode 100755 index 035f581..0000000 --- a/avahi-utils/avahi-dump-all +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/python2.4 -# -*-python-*- -# $Id$ - -import avahi, dbus, gobject, sys - -try: - import dbus.glib -except ImportError, e: - pass - -service_type_browsers = {} -service_browsers = {} - -def service_resolved(interface, protocol, name, type, domain, host, aprotocol, address, port, txt): - print "Service data for service '%s' of type '%s' in domain '%s' on %i.%i:" % (name, type, domain, interface, protocol) - print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, str(txt)) - -def print_error(err): - print "Error:", str(err) - -def new_service(interface, protocol, name, type, domain): - global server - - print "Found service '%s' of type '%s' in domain '%s' on %i.%i." % (name, type, domain, interface, protocol) - - # Asynchronous resolving - server.ResolveService(interface, protocol, name, type, domain, avahi.PROTO_UNSPEC, reply_handler=service_resolved, error_handler=print_error) - -def remove_service(interface, protocol, name, type, domain): - print "Service '%s' of type '%s' in domain '%s' on %i.%i disappeared." % (name, type, domain, interface, protocol) - -def new_service_type(interface, protocol, type, domain): - global server, service_browsers - - # Are we already browsing this domain for this type? - if service_browsers.has_key((interface, protocol, type, domain)): - return - - print "Browsing for services of type '%s' in domain '%s' on %i.%i ..." % (type, domain, interface, protocol) - - b = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.ServiceBrowserNew(interface, protocol, type, domain)), avahi.DBUS_INTERFACE_SERVICE_BROWSER) - b.connect_to_signal('ItemNew', new_service) - b.connect_to_signal('ItemRemove', remove_service) - - service_browsers[(interface, protocol, type, domain)] = b - -def browse_domain(interface, protocol, domain): - global server, service_type_browsers - - # Are we already browsing this domain? - if service_type_browsers.has_key((interface, protocol, domain)): - return - - print "Browsing domain '%s' on %i.%i ..." % (domain, interface, protocol) - - b = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.ServiceTypeBrowserNew(interface, protocol, domain)), avahi.DBUS_INTERFACE_SERVICE_TYPE_BROWSER) - b.connect_to_signal('ItemNew', new_service_type) - - service_type_browsers[(interface, protocol, domain)] = b - -def new_domain(interface, protocol, domain): - - # We browse for .local anyway... - if domain != "local": - browse_domain(interface, protocol, domain) - - -domain = None - -if len(sys.argv) > 1: - domain = sys.argv[1] - -bus = dbus.SystemBus() -server = dbus.Interface(bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) - -if domain is None: - # Explicitly browse .local - 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.connect_to_signal('ItemNew', new_domain) - -else: - # Just browse the domain the user wants us to browse - browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, domain) - -try: - gobject.MainLoop().run() -except KeyboardInterrupt, k: - pass diff --git a/avahi-utils/avahi-dump-all.in b/avahi-utils/avahi-dump-all.in new file mode 100755 index 0000000..6e27240 --- /dev/null +++ b/avahi-utils/avahi-dump-all.in @@ -0,0 +1,92 @@ +#!/usr/bin/env @PYTHON@ +# -*-python-*- +# $Id$ + +import avahi, dbus, gobject, sys + +try: + import dbus.glib +except ImportError, e: + pass + +service_type_browsers = {} +service_browsers = {} + +def service_resolved(interface, protocol, name, type, domain, host, aprotocol, address, port, txt): + print "Service data for service '%s' of type '%s' in domain '%s' on %i.%i:" % (name, type, domain, interface, protocol) + print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, str(txt)) + +def print_error(err): + print "Error:", str(err) + +def new_service(interface, protocol, name, type, domain): + global server + + print "Found service '%s' of type '%s' in domain '%s' on %i.%i." % (name, type, domain, interface, protocol) + + # Asynchronous resolving + server.ResolveService(interface, protocol, name, type, domain, avahi.PROTO_UNSPEC, reply_handler=service_resolved, error_handler=print_error) + +def remove_service(interface, protocol, name, type, domain): + print "Service '%s' of type '%s' in domain '%s' on %i.%i disappeared." % (name, type, domain, interface, protocol) + +def new_service_type(interface, protocol, type, domain): + global server, service_browsers + + # Are we already browsing this domain for this type? + if service_browsers.has_key((interface, protocol, type, domain)): + return + + print "Browsing for services of type '%s' in domain '%s' on %i.%i ..." % (type, domain, interface, protocol) + + b = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.ServiceBrowserNew(interface, protocol, type, domain)), avahi.DBUS_INTERFACE_SERVICE_BROWSER) + b.connect_to_signal('ItemNew', new_service) + b.connect_to_signal('ItemRemove', remove_service) + + service_browsers[(interface, protocol, type, domain)] = b + +def browse_domain(interface, protocol, domain): + global server, service_type_browsers + + # Are we already browsing this domain? + if service_type_browsers.has_key((interface, protocol, domain)): + return + + print "Browsing domain '%s' on %i.%i ..." % (domain, interface, protocol) + + b = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.ServiceTypeBrowserNew(interface, protocol, domain)), avahi.DBUS_INTERFACE_SERVICE_TYPE_BROWSER) + b.connect_to_signal('ItemNew', new_service_type) + + service_type_browsers[(interface, protocol, domain)] = b + +def new_domain(interface, protocol, domain): + + # We browse for .local anyway... + if domain != "local": + browse_domain(interface, protocol, domain) + + +domain = None + +if len(sys.argv) > 1: + domain = sys.argv[1] + +bus = dbus.SystemBus() +server = dbus.Interface(bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) + +if domain is None: + # Explicitly browse .local + 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.connect_to_signal('ItemNew', new_domain) + +else: + # Just browse the domain the user wants us to browse + browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, domain) + +try: + gobject.MainLoop().run() +except KeyboardInterrupt, k: + pass diff --git a/avahi-utils/avahi-publish-address b/avahi-utils/avahi-publish-address deleted file mode 100755 index d03f928..0000000 --- a/avahi-utils/avahi-publish-address +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/python2.4 -# -*-python-*- -# $Id$ - -import avahi, dbus, gobject, sys, getopt, string - -try: - import dbus.glib -except ImportError, e: - pass - -def usage(retval = 0): - print "%s
" % sys.argv[0] - sys.exit(retval) - -if len(sys.argv) != 3: - usage(2) - -name = sys.argv[1] -address = sys.argv[2] - -group = None -n_rename = 0 - -def remove_address(): - global group - - if not (group is None): - group.Free() - group = None - -def add_address(): - global server, group, name, address - assert group is None - - print "Adding address '%s' for '%s' ..." % (name, address) - group = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.EntryGroupNew()), avahi.DBUS_INTERFACE_ENTRY_GROUP) - group.connect_to_signal('StateChanged', entry_group_state_changed) - group.AddAddress(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, name, address) - group.Commit() - -def entry_group_state_changed(state): - global name, server, n_rename, main_loop - - if state == avahi.ENTRY_GROUP_ESTABLISHED: - print "Address established." - elif state == avahi.ENTRY_GROUP_COLLISION: - - n_rename = n_rename + 1 - if n_rename >= 12: - print "ERROR: No suitable name found after %i retries, exiting." % n_rename - main_loop.quit() - else: - hn = name.split('.') - hn[0] = server.GetAlternativeHostName(hn[0]) - name = string.join(hn, '.') - print "WARNING: Address/host name collision, changing name to '%s' ..." % name - remove_address() - add_address() - -main_loop = gobject.MainLoop() - -bus = dbus.SystemBus() -server = dbus.Interface(bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) - -add_address() - -try: - main_loop.run() -except KeyboardInterrupt, k: - pass - -remove_address() diff --git a/avahi-utils/avahi-publish-address.in b/avahi-utils/avahi-publish-address.in new file mode 100755 index 0000000..43921e8 --- /dev/null +++ b/avahi-utils/avahi-publish-address.in @@ -0,0 +1,73 @@ +#!/usr/bin/env @PYTHON@ +# -*-python-*- +# $Id$ + +import avahi, dbus, gobject, sys, getopt, string + +try: + import dbus.glib +except ImportError, e: + pass + +def usage(retval = 0): + print "%s
" % sys.argv[0] + sys.exit(retval) + +if len(sys.argv) != 3: + usage(2) + +name = sys.argv[1] +address = sys.argv[2] + +group = None +n_rename = 0 + +def remove_address(): + global group + + if not (group is None): + group.Free() + group = None + +def add_address(): + global server, group, name, address + assert group is None + + print "Adding address '%s' for '%s' ..." % (name, address) + group = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.EntryGroupNew()), avahi.DBUS_INTERFACE_ENTRY_GROUP) + group.connect_to_signal('StateChanged', entry_group_state_changed) + group.AddAddress(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, name, address) + group.Commit() + +def entry_group_state_changed(state): + global name, server, n_rename, main_loop + + if state == avahi.ENTRY_GROUP_ESTABLISHED: + print "Address established." + elif state == avahi.ENTRY_GROUP_COLLISION: + + n_rename = n_rename + 1 + if n_rename >= 12: + print "ERROR: No suitable name found after %i retries, exiting." % n_rename + main_loop.quit() + else: + hn = name.split('.') + hn[0] = server.GetAlternativeHostName(hn[0]) + name = string.join(hn, '.') + print "WARNING: Address/host name collision, changing name to '%s' ..." % name + remove_address() + add_address() + +main_loop = gobject.MainLoop() + +bus = dbus.SystemBus() +server = dbus.Interface(bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) + +add_address() + +try: + main_loop.run() +except KeyboardInterrupt, k: + pass + +remove_address() diff --git a/avahi-utils/avahi-publish-service b/avahi-utils/avahi-publish-service deleted file mode 100755 index d823f14..0000000 --- a/avahi-utils/avahi-publish-service +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/python2.4 -# -*-python-*- -# $Id$ - -import avahi, dbus, gobject, sys, getopt - -try: - import dbus.glib -except ImportError, e: - pass - -def usage(retval = 0): - print "%s [options] [ ...]\n" % sys.argv[0] - print " -h --help Show this help" - print " -d --domain Domain where to register this service" - print " -H --host Host where this service resides" - sys.exit(retval) - -try: - opts, args = getopt.getopt(sys.argv[1:], "d:H:", ["help", "domain=", "host="]) -except getopt.GetoptError: - usage(2) - -domain = "" -host = "" - -for o, a in opts: - if o in ("-h", "--help"): - usage() - - if o in ("-d", "--domain"): - domain = a - - if o in ("-H", "--host"): - host = a - -if len(args) < 3: - sys.stderr.write("Invalid number of arguments\n") - sys.exit(1) - -name = args[0] -stype = args[1] -port = int(args[2]) -txt = args[3:] - -# python-dbus doesn't allow transmission of empty arrays, therefore we "fix" it with a bogus entry -if len(txt) == 0: - txt.append("python-dbus=brain-damage") - -group = None -n_rename = 0 - -def remove_service(): - global group - - if not (group is None): - group.Free() - group = None - -def add_service(): - global server, group, name, stype, domain, host, port, txt - assert group is None - - print "Adding service '%s' of type '%s' ..." % (name, stype) - group = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.EntryGroupNew()), avahi.DBUS_INTERFACE_ENTRY_GROUP) - group.connect_to_signal('StateChanged', entry_group_state_changed) - group.AddService(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, name, stype, domain, host, dbus.UInt16(port), txt) - group.Commit() - -def entry_group_state_changed(state): - global name, server, n_rename - - if state == avahi.ENTRY_GROUP_ESTABLISHED: - print "Service established." - elif state == avahi.ENTRY_GROUP_COLLISION: - - n_rename = n_rename + 1 - if n_rename >= 12: - print "ERROR: No suitable service name found after %i retries, exiting." % n_rename - main_loop.quit() - else: - name = server.GetAlternativeServiceName(name) - print "WARNING: Service name collision, changing name to '%s' ..." % name - remove_service() - add_service() - -def server_state_changed(state): - if state == avahi.SERVER_COLLISION: - print "WARNING: Server name collision" - remove_service() - elif state == avahi.SERVER_RUNNING: - add_service() - -main_loop = gobject.MainLoop() - -bus = dbus.SystemBus() -server = dbus.Interface(bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) -server.connect_to_signal("StateChanged", server_state_changed) -server_state_changed(server.GetState()) - -try: - main_loop.run() -except KeyboardInterrupt, k: - pass - -remove_service() diff --git a/avahi-utils/avahi-publish-service.in b/avahi-utils/avahi-publish-service.in new file mode 100755 index 0000000..e6bb39c --- /dev/null +++ b/avahi-utils/avahi-publish-service.in @@ -0,0 +1,106 @@ +#!/usr/bin/env @PYTHON@ +# -*-python-*- +# $Id$ + +import avahi, dbus, gobject, sys, getopt + +try: + import dbus.glib +except ImportError, e: + pass + +def usage(retval = 0): + print "%s [options] [ ...]\n" % sys.argv[0] + print " -h --help Show this help" + print " -d --domain Domain where to register this service" + print " -H --host Host where this service resides" + sys.exit(retval) + +try: + opts, args = getopt.getopt(sys.argv[1:], "d:H:", ["help", "domain=", "host="]) +except getopt.GetoptError: + usage(2) + +domain = "" +host = "" + +for o, a in opts: + if o in ("-h", "--help"): + usage() + + if o in ("-d", "--domain"): + domain = a + + if o in ("-H", "--host"): + host = a + +if len(args) < 3: + sys.stderr.write("Invalid number of arguments\n") + sys.exit(1) + +name = args[0] +stype = args[1] +port = int(args[2]) +txt = args[3:] + +# python-dbus doesn't allow transmission of empty arrays, therefore we "fix" it with a bogus entry +if len(txt) == 0: + txt.append("python-dbus=brain-damage") + +group = None +n_rename = 0 + +def remove_service(): + global group + + if not (group is None): + group.Free() + group = None + +def add_service(): + global server, group, name, stype, domain, host, port, txt + assert group is None + + print "Adding service '%s' of type '%s' ..." % (name, stype) + group = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.EntryGroupNew()), avahi.DBUS_INTERFACE_ENTRY_GROUP) + group.connect_to_signal('StateChanged', entry_group_state_changed) + group.AddService(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, name, stype, domain, host, dbus.UInt16(port), txt) + group.Commit() + +def entry_group_state_changed(state): + global name, server, n_rename + + if state == avahi.ENTRY_GROUP_ESTABLISHED: + print "Service established." + elif state == avahi.ENTRY_GROUP_COLLISION: + + n_rename = n_rename + 1 + if n_rename >= 12: + print "ERROR: No suitable service name found after %i retries, exiting." % n_rename + main_loop.quit() + else: + name = server.GetAlternativeServiceName(name) + print "WARNING: Service name collision, changing name to '%s' ..." % name + remove_service() + add_service() + +def server_state_changed(state): + if state == avahi.SERVER_COLLISION: + print "WARNING: Server name collision" + remove_service() + elif state == avahi.SERVER_RUNNING: + add_service() + +main_loop = gobject.MainLoop() + +bus = dbus.SystemBus() +server = dbus.Interface(bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) +server.connect_to_signal("StateChanged", server_state_changed) +server_state_changed(server.GetState()) + +try: + main_loop.run() +except KeyboardInterrupt, k: + pass + +remove_service() diff --git a/avahi-utils/avahi.py b/avahi-utils/avahi.py deleted file mode 100644 index 1e2761c..0000000 --- a/avahi-utils/avahi.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/python2.4 -# $Id$ - -# Some definitions matching those in core.h -import socket - -SERVER_INVALID, SERVER_REGISTERING, SERVER_RUNNING, SERVER_COLLISION, SERVER_SLEEPING = range(-1, 4) - -ENTRY_GROUP_UNCOMMITED, ENTRY_GROUP_REGISTERING, ENTRY_GROUP_ESTABLISHED, ENTRY_GROUP_COLLISION = range(-1, 3) - -DOMAIN_BROWSER_REGISTER, DOMAIN_BROWSER_REGISTER_DEFAULT, DOMAIN_BROWSER_BROWSE, DOMAIN_BROWSER_BROWSE_DEFAULT, DOMAIN_BROWSER_BROWSE_LEGACY = range(0, 5) - -PROTO_INET, PROTO_INET6, PROTO_UNSPEC = socket.AF_INET, socket.AF_INET6, socket.AF_UNSPEC - -IF_UNSPEC = -1 - -DBUS_NAME = "org.freedesktop.Avahi" -DBUS_INTERFACE_SERVER = DBUS_NAME + ".Server" -DBUS_PATH_SERVER = "/" -DBUS_INTERFACE_ENTRY_GROUP = DBUS_NAME + ".EntryGroup" -DBUS_INTERFACE_DOMAIN_BROWSER = DBUS_NAME + ".DomainBrowser" -DBUS_INTERFACE_SERVICE_TYPE_BROWSER = DBUS_NAME + ".ServiceTypeBrowser" -DBUS_INTERFACE_SERVICE_BROWSER = DBUS_NAME + ".ServiceBrowser" diff --git a/avahi-utils/avahi/Makefile.am b/avahi-utils/avahi/Makefile.am new file mode 100644 index 0000000..357d3dc --- /dev/null +++ b/avahi-utils/avahi/Makefile.am @@ -0,0 +1,4 @@ +avahidir = $(pythondir)/avahi +avahi_PYTHON = __init__.py SimpleGladeApp.py + +EXTRA_DIST = $(avahi_PYTHON) diff --git a/avahi-utils/avahi/SimpleGladeApp.py b/avahi-utils/avahi/SimpleGladeApp.py new file mode 100644 index 0000000..90c598c --- /dev/null +++ b/avahi-utils/avahi/SimpleGladeApp.py @@ -0,0 +1,341 @@ +""" + SimpleGladeApp.py + Module that provides an object oriented abstraction to pygtk and libglade. + Copyright (C) 2004 Sandino Flores Moreno +""" + +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA + +import os +import sys +import re + +import tokenize +import gtk +import gtk.glade +import weakref +import inspect + +__version__ = "1.0" +__author__ = 'Sandino "tigrux" Flores-Moreno' + +def bindtextdomain(app_name, locale_dir=None): + """ + Bind the domain represented by app_name to the locale directory locale_dir. + It has the effect of loading translations, enabling applications for different + languages. + + app_name: + a domain to look for translations, tipically the name of an application. + + locale_dir: + a directory with locales like locale_dir/lang_isocode/LC_MESSAGES/app_name.mo + If omitted or None, then the current binding for app_name is used. + """ + try: + import locale + import gettext + locale.setlocale(locale.LC_ALL, "") + gtk.glade.bindtextdomain(app_name, locale_dir) + gettext.install(app_name, locale_dir, unicode=1) + except (IOError,locale.Error), e: + print "Warning", app_name, e + __builtins__.__dict__["_"] = lambda x : x + + +class SimpleGladeApp: + + def __init__(self, path, root=None, domain=None, **kwargs): + """ + Load a glade file specified by glade_filename, using root as + root widget and domain as the domain for translations. + + If it receives extra named arguments (argname=value), then they are used + as attributes of the instance. + + path: + path to a glade filename. + If glade_filename cannot be found, then it will be searched in the + same directory of the program (sys.argv[0]) + + root: + the name of the widget that is the root of the user interface, + usually a window or dialog (a top level widget). + If None or ommited, the full user interface is loaded. + + domain: + A domain to use for loading translations. + If None or ommited, no translation is loaded. + + **kwargs: + a dictionary representing the named extra arguments. + It is useful to set attributes of new instances, for example: + glade_app = SimpleGladeApp("ui.glade", foo="some value", bar="another value") + sets two attributes (foo and bar) to glade_app. + """ + if os.path.isfile(path): + self.glade_path = path + else: + glade_dir = os.path.dirname( sys.argv[0] ) + self.glade_path = os.path.join(glade_dir, path) + for key, value in kwargs.items(): + try: + setattr(self, key, weakref.proxy(value) ) + except TypeError: + setattr(self, key, value) + self.glade = None + self.install_custom_handler(self.custom_handler) + self.glade = self.create_glade(self.glade_path, root, domain) + if root: + self.main_widget = self.get_widget(root) + else: + self.main_widget = None + self.normalize_names() + self.add_callbacks(self) + self.new() + + def __repr__(self): + class_name = self.__class__.__name__ + if self.main_widget: + root = gtk.Widget.get_name(self.main_widget) + repr = '%s(path="%s", root="%s")' % (class_name, self.glade_path, root) + else: + repr = '%s(path="%s")' % (class_name, self.glade_path) + return repr + + def new(self): + """ + Method called when the user interface is loaded and ready to be used. + At this moment, the widgets are loaded and can be refered as self.widget_name + """ + pass + + def add_callbacks(self, callbacks_proxy): + """ + It uses the methods of callbacks_proxy as callbacks. + The callbacks are specified by using: + Properties window -> Signals tab + in glade-2 (or any other gui designer like gazpacho). + + Methods of classes inheriting from SimpleGladeApp are used as + callbacks automatically. + + callbacks_proxy: + an instance with methods as code of callbacks. + It means it has methods like on_button1_clicked, on_entry1_activate, etc. + """ + self.glade.signal_autoconnect(callbacks_proxy) + + def normalize_names(self): + """ + It is internally used to normalize the name of the widgets. + It means a widget named foo:vbox-dialog in glade + is refered self.vbox_dialog in the code. + + It also sets a data "prefixes" with the list of + prefixes a widget has for each widget. + """ + for widget in self.get_widgets(): + widget_name = gtk.Widget.get_name(widget) + prefixes_name_l = widget_name.split(":") + prefixes = prefixes_name_l[ : -1] + widget_api_name = prefixes_name_l[-1] + widget_api_name = "_".join( re.findall(tokenize.Name, widget_api_name) ) + gtk.Widget.set_name(widget, widget_api_name) + if hasattr(self, widget_api_name): + raise AttributeError("instance %s already has an attribute %s" % (self,widget_api_name)) + else: + setattr(self, widget_api_name, widget) + if prefixes: + gtk.Widget.set_data(widget, "prefixes", prefixes) + + def add_prefix_actions(self, prefix_actions_proxy): + """ + By using a gui designer (glade-2, gazpacho, etc) + widgets can have a prefix in theirs names + like foo:entry1 or foo:label3 + It means entry1 and label3 has a prefix action named foo. + + Then, prefix_actions_proxy must have a method named prefix_foo which + is called everytime a widget with prefix foo is found, using the found widget + as argument. + + prefix_actions_proxy: + An instance with methods as prefix actions. + It means it has methods like prefix_foo, prefix_bar, etc. + """ + prefix_s = "prefix_" + prefix_pos = len(prefix_s) + + is_method = lambda t : callable( t[1] ) + is_prefix_action = lambda t : t[0].startswith(prefix_s) + drop_prefix = lambda (k,w): (k[prefix_pos:],w) + + members_t = inspect.getmembers(prefix_actions_proxy) + methods_t = filter(is_method, members_t) + prefix_actions_t = filter(is_prefix_action, methods_t) + prefix_actions_d = dict( map(drop_prefix, prefix_actions_t) ) + + for widget in self.get_widgets(): + prefixes = gtk.Widget.get_data(widget, "prefixes") + if prefixes: + for prefix in prefixes: + if prefix in prefix_actions_d: + prefix_action = prefix_actions_d[prefix] + prefix_action(widget) + + def custom_handler(self, + glade, function_name, widget_name, + str1, str2, int1, int2): + """ + Generic handler for creating custom widgets, internally used to + enable custom widgets (custom widgets of glade). + + The custom widgets have a creation function specified in design time. + Those creation functions are always called with str1,str2,int1,int2 as + arguments, that are values specified in design time. + + Methods of classes inheriting from SimpleGladeApp are used as + creation functions automatically. + + If a custom widget has create_foo as creation function, then the + method named create_foo is called with str1,str2,int1,int2 as arguments. + """ + try: + handler = getattr(self, function_name) + return handler(str1, str2, int1, int2) + except AttributeError: + return None + + def gtk_widget_show(self, widget, *args): + """ + Predefined callback. + The widget is showed. + Equivalent to widget.show() + """ + widget.show() + + def gtk_widget_hide(self, widget, *args): + """ + Predefined callback. + The widget is hidden. + Equivalent to widget.hide() + """ + widget.hide() + + def gtk_widget_grab_focus(self, widget, *args): + """ + Predefined callback. + The widget grabs the focus. + Equivalent to widget.grab_focus() + """ + widget.grab_focus() + + def gtk_widget_destroy(self, widget, *args): + """ + Predefined callback. + The widget is destroyed. + Equivalent to widget.destroy() + """ + widget.destroy() + + def gtk_window_activate_default(self, window, *args): + """ + Predefined callback. + The default widget of the window is activated. + Equivalent to window.activate_default() + """ + widget.activate_default() + + def gtk_true(self, *args): + """ + Predefined callback. + Equivalent to return True in a callback. + Useful for stopping propagation of signals. + """ + return True + + def gtk_false(self, *args): + """ + Predefined callback. + Equivalent to return False in a callback. + """ + return False + + def gtk_main_quit(self, *args): + """ + Predefined callback. + Equivalent to self.quit() + """ + self.quit() + + def main(self): + """ + Starts the main loop of processing events. + The default implementation calls gtk.main() + + Useful for applications that needs a non gtk main loop. + For example, applications based on gstreamer needs to override + this method with gst.main() + + Do not directly call this method in your programs. + Use the method run() instead. + """ + gtk.main() + + def quit(self): + """ + Quit processing events. + The default implementation calls gtk.main_quit() + + Useful for applications that needs a non gtk main loop. + For example, applications based on gstreamer needs to override + this method with gst.main_quit() + """ + gtk.main_quit() + + def run(self): + """ + Starts the main loop of processing events checking for Control-C. + + The default implementation checks wheter a Control-C is pressed, + then calls on_keyboard_interrupt(). + + Use this method for starting programs. + """ + try: + self.main() + except KeyboardInterrupt: + self.on_keyboard_interrupt() + + def on_keyboard_interrupt(self): + """ + This method is called by the default implementation of run() + after a program is finished by pressing Control-C. + """ + pass + + def install_custom_handler(self, custom_handler): + gtk.glade.set_custom_handler(custom_handler) + + def create_glade(self, glade_path, root, domain): + return gtk.glade.XML(self.glade_path, root, domain) + + def get_widget(self, widget_name): + return self.glade.get_widget(widget_name) + + def get_widgets(self): + return self.glade.get_widget_prefix("") diff --git a/avahi-utils/avahi/__init__.py b/avahi-utils/avahi/__init__.py new file mode 100644 index 0000000..1e2761c --- /dev/null +++ b/avahi-utils/avahi/__init__.py @@ -0,0 +1,23 @@ +#!/usr/bin/python2.4 +# $Id$ + +# Some definitions matching those in core.h +import socket + +SERVER_INVALID, SERVER_REGISTERING, SERVER_RUNNING, SERVER_COLLISION, SERVER_SLEEPING = range(-1, 4) + +ENTRY_GROUP_UNCOMMITED, ENTRY_GROUP_REGISTERING, ENTRY_GROUP_ESTABLISHED, ENTRY_GROUP_COLLISION = range(-1, 3) + +DOMAIN_BROWSER_REGISTER, DOMAIN_BROWSER_REGISTER_DEFAULT, DOMAIN_BROWSER_BROWSE, DOMAIN_BROWSER_BROWSE_DEFAULT, DOMAIN_BROWSER_BROWSE_LEGACY = range(0, 5) + +PROTO_INET, PROTO_INET6, PROTO_UNSPEC = socket.AF_INET, socket.AF_INET6, socket.AF_UNSPEC + +IF_UNSPEC = -1 + +DBUS_NAME = "org.freedesktop.Avahi" +DBUS_INTERFACE_SERVER = DBUS_NAME + ".Server" +DBUS_PATH_SERVER = "/" +DBUS_INTERFACE_ENTRY_GROUP = DBUS_NAME + ".EntryGroup" +DBUS_INTERFACE_DOMAIN_BROWSER = DBUS_NAME + ".DomainBrowser" +DBUS_INTERFACE_SERVICE_TYPE_BROWSER = DBUS_NAME + ".ServiceTypeBrowser" +DBUS_INTERFACE_SERVICE_BROWSER = DBUS_NAME + ".ServiceBrowser" diff --git a/configure.ac b/configure.ac index e162452..29182ef 100644 --- a/configure.ac +++ b/configure.ac @@ -216,6 +216,8 @@ avahi_socket="${avahi_runtime_dir}/avahi-daemon/socket" AC_SUBST(avahi_runtime_dir) AC_SUBST(avahi_socket) +AM_PATH_PYTHON(2.2) + AC_CONFIG_FILES([ Makefile avahi-core.pc @@ -230,6 +232,12 @@ initscript/Debian/Makefile initscript/Gentoo/Makefile initscript/SUSE/Makefile avahi-dnsconfd/Makefile +avahi-utils/Makefile +avahi-utils/avahi/Makefile +avahi-utils/avahi-dump-all +avahi-utils/avahi-publish-service +avahi-utils/avahi-publish-address +avahi-utils/avahi-discover ]) AC_OUTPUT @@ -243,6 +251,8 @@ echo " dbus-1 version: `pkg-config dbus-1 --modversion` compiler: ${CC} cflags: ${CFLAGS} + Enable Gtk: ${ENABLE_GTK} + Enable Dbus: ${ENABLE_DBUS} Linux Distro: ${with_distro} User for Avahi: ${AVAHI_USER} Group for Avahi: ${AVAHI_GROUP} diff --git a/py-compile b/py-compile new file mode 100755 index 0000000..4c84b67 --- /dev/null +++ b/py-compile @@ -0,0 +1,92 @@ +#!/bin/sh + +# py-compile - Compile a Python program +# Copyright 2000, 2001 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# called as "py-compile [--basedir DIR] PY_FILES ... + +if [ -z "$PYTHON" ]; then + PYTHON=python +fi + +basedir= + +case "$1" in + --basedir) + basedir=$2 + shift 2 + ;; + --help) + echo "Usage: py-compile [--basedir DIR] PY_FILES ..." + echo "Byte compile some python scripts. This should be performed" + echo "after they have been moved to the final installation location" + exit 0 + ;; + --version) + echo "py-compile version 0.0" + exit 0 + ;; +esac + +if [ $# = 0 ]; then + echo "No files given to $0" 1>&2 + exit 1 +fi + +# if basedir was given, then it should be prepended to filenames before +# byte compilation. +if [ -z "$basedir" ]; then + trans="path = file" +else + trans="path = os.path.join('$basedir', file)" +fi + +$PYTHON -c " +import sys, os, string, py_compile + +files = '''$*''' +print 'Byte-compiling python modules...' +for file in string.split(files): + $trans + if not os.path.exists(path) or not (len(path) >= 3 and path[-3:] == '.py'): + continue + print file, + sys.stdout.flush() + py_compile.compile(path) +print" || exit $? + +# this will fail for python < 1.5, but that doesn't matter ... +$PYTHON -O -c " +import sys, os, string, py_compile + +files = '''$*''' +print 'Byte-compiling python modules (optimized versions) ...' +for file in string.split(files): + $trans + if not os.path.exists(path) or not (len(path) >= 3 and path[-3:] == '.py'): + continue + print file, + sys.stdout.flush() + py_compile.compile(path) +print" 2>/dev/null || : +