summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Estienne <sebastien.estienne@gmail.com>2005-11-13 00:24:58 +0000
committerSebastien Estienne <sebastien.estienne@gmail.com>2005-11-13 00:24:58 +0000
commitba6d55cb136846b83172c0bea9e8087d198a4801 (patch)
tree859fc9622720c04d862e9afaaa146bce391b5ddc
parent14493d4e41890251fbb24ebbdd1c36e8f2fc6a4b (diff)
* more work on the simple api
git-svn-id: file:///home/lennart/svn/public/avahi/branches/py-simple-api@950 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
-rwxr-xr-xavahi-utils/avahi/SimpleAvahiApp.py.in34
1 files changed, 30 insertions, 4 deletions
diff --git a/avahi-utils/avahi/SimpleAvahiApp.py.in b/avahi-utils/avahi/SimpleAvahiApp.py.in
index 07bd9bb..322efb3 100755
--- a/avahi-utils/avahi/SimpleAvahiApp.py.in
+++ b/avahi-utils/avahi/SimpleAvahiApp.py.in
@@ -75,7 +75,24 @@ class SimpleAvahiApp:
b.connect_to_signal('ItemRemove', remove_cb)
self.service_type_browsers[(interface, protocol, domain)] = b
-
+
+ def PublishEGNew(self, entry_group_state_changed_cb = None):
+ group = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.EntryGroupNew()), avahi.DBUS_INTERFACE_ENTRY_GROUP)
+ if not entry_group_state_changed_cb is None:
+ group.connect_to_signal('StateChanged', entry_group_state_changed_cb)
+ return group
+
+ def PublishEGAddService(self, group, name, stype, port, txts={"a":"b"}, host = "", domain="local", interface=avahi.IF_UNSPEC, protocol=avahi.PROTO_UNSPEC):
+
+ group.AddService(interface, protocol, name, stype, domain, host, dbus.UInt16(port), avahi.dict_to_txt_array(txts))
+
+ def PublishEGRemove(self, group):
+ if not group is None:
+ group.Reset()
+
+ def PublishEGCommit(self, group):
+ if not group is None:
+ group.Commit()
if __name__ == "__main__":
print "__main__"
@@ -100,10 +117,19 @@ if __name__ == "__main__":
def __init__(self):
self.sb = SimpleAvahiApp()
-# self.sb.BrowseService("_ssh._tcp", self.new_service)
- self.sb.BrowseService("_workstation._tcp", self.new_service, self.remove_service)
-
+ self.sb.BrowseService("_ssh._tcp", self.new_service)
+# self.sb.BrowseService("_workstation._tcp", self.new_service, self.remove_service)
+
+ class AvahiPublish:
+ def __init__(self):
+ self.sp = SimpleAvahiApp()
+ group = self.sp.PublishEGNew()
+ self.sp.PublishEGAddService(group, "coucou", "_ssh._tcp", 22)
+ self.sp.PublishEGAddService(group, "coucou", "_http._tcp", 80)
+ self.sp.PublishEGCommit(group)
+
ab = AvahiBrowse()
+ ap = AvahiPublish()
try:
gobject.MainLoop().run()