X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-python%2Favahi-bookmarks.in;h=dea7bef601989218aa48e4249ea0383345e68b2d;hb=7a5b2f69af7d36d6cd4153142f125fa011784e03;hp=a31533e24f5a7803e9fc73b8a7b8e4d878a08a9a;hpb=e614891d38cae63957d0bfc00d34ecdbad4f8322;p=catta diff --git a/avahi-python/avahi-bookmarks.in b/avahi-python/avahi-bookmarks.in index a31533e..dea7bef 100755 --- a/avahi-python/avahi-bookmarks.in +++ b/avahi-python/avahi-bookmarks.in @@ -1,7 +1,5 @@ #!@PYTHON@ # -*-python-*- -# $Id$ - # This file is part of avahi. # # avahi is free software; you can redistribute it and/or modify it @@ -19,12 +17,12 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. -import sys, getopt +import sys, getopt, os try: import avahi, gobject, dbus except ImportError: - print "Sorry, to use this tool you need to install Avahi, pygtk and python-dbus." + print "Sorry, to use this tool you need to install Avahi and python-dbus." sys.exit(1) try: @@ -32,29 +30,19 @@ try: except ImportError: pass -try: - from twisted.internet import gtk2reactor - gtk2reactor.install() - from twisted.internet import reactor - from twisted.web import server, resource -except ImportError: - print "Sorry, to use this tool you need to install twisted and twisted.web." - sys.exit(1) - urlproto = { "_http._tcp" : "http", "_https._tcp" : "https", "_ftp._tcp" : "ftp" } port = 8080 address = "127.0.0.1" use_host_names = None +use_CGI = None domain = "local" +timeout = 3000 -class AvahiBookmarks(resource.Resource): - isLeaf = True - +class AvahiBookmarks: services = {} def __init__(self, use_host_names): - resource.Resource.__init__(self) self.bus = dbus.SystemBus() self.server = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) @@ -75,11 +63,13 @@ class AvahiBookmarks(resource.Resource): def browse_service_type(self, stype): - global domain + global domain, use_CGI 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) + if use_CGI: + browser.connect_to_signal('AllForNow', self.all_for_now) def find_path(self, txt): @@ -94,12 +84,14 @@ class AvahiBookmarks(resource.Resource): return "/" - def render_GET(self, request): + def render_html(self): - t = 'Zeroconf Bookmarks

Zeroconf Bookmarks

' + global domain + + t = '%s Zeroconf Bookmarks

%s Zeroconf Bookmarks

' % (domain, domain) if len(self.services) == 0: - t += '

Sorry, no web services have been registered on the local LAN.

' + t += '

Sorry, no Zeroconf web services have been registered on the %s domain.

' % domain else: t += '