Removing avahi module stuff, already in avahi-tools RPM
This commit is contained in:
parent
d4bacf35db
commit
f41ce25a65
@ -1,7 +0,0 @@
|
||||
DEPENDENCIES
|
||||
------------
|
||||
|
||||
gecko-embed
|
||||
|
||||
http://gnome.org/~marco/gecko-embed-0.1-2.i386.rpm
|
||||
http://gnome.org/~marco/gecko-embed-0.1-2.src.rpm
|
@ -1,13 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import dbus
|
||||
import dbus.service
|
||||
import dbus.glib
|
||||
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
|
||||
import geckoembed
|
||||
|
||||
class AddressToolbar(gtk.Toolbar):
|
||||
@ -19,7 +14,8 @@ class AddressToolbar(gtk.Toolbar):
|
||||
address_item.show()
|
||||
|
||||
def __open_address_cb(self, address):
|
||||
web_activity.openAddress(address)
|
||||
browser = BrowserWindow(address)
|
||||
browser.show()
|
||||
|
||||
class AddressItem(gtk.ToolItem):
|
||||
def __init__(self, callback):
|
||||
@ -68,21 +64,13 @@ class AddressEntry(gtk.HBox):
|
||||
image.show()
|
||||
|
||||
self.entry.show()
|
||||
self.entry.grab_focus()
|
||||
|
||||
def get_folded(self):
|
||||
return self.folded
|
||||
|
||||
def set_folded(self, folded):
|
||||
def __button_clicked_cb(self, button):
|
||||
self.folded = not self.folded
|
||||
self._update_folded_state()
|
||||
|
||||
def __button_clicked_cb(self, button):
|
||||
self.set_folded(not self.get_folded())
|
||||
|
||||
def __activate_cb(self, entry):
|
||||
self.callback(entry.get_text())
|
||||
self.set_folded(True)
|
||||
|
||||
class NavigationToolbar(gtk.Toolbar):
|
||||
def __init__(self, embed):
|
||||
@ -137,35 +125,47 @@ class NavigationToolbar(gtk.Toolbar):
|
||||
def __open_address_cb(self, address):
|
||||
self.embed.load_url(address)
|
||||
|
||||
class BrowserActivity(gtk.VBox):
|
||||
class BrowserWindow(gtk.Window):
|
||||
def __init__(self, uri):
|
||||
gtk.VBox.__init__(self)
|
||||
gtk.Window.__init__(self)
|
||||
self.set_default_size(640, 480);
|
||||
|
||||
vbox = gtk.VBox()
|
||||
|
||||
self.embed = geckoembed.Embed()
|
||||
self.pack_start(self.embed)
|
||||
vbox.pack_start(self.embed)
|
||||
self.embed.show()
|
||||
self.embed.load_url(uri)
|
||||
|
||||
nav_toolbar = NavigationToolbar(self.embed)
|
||||
self.pack_start(nav_toolbar, False)
|
||||
vbox.pack_start(nav_toolbar, False)
|
||||
nav_toolbar.show()
|
||||
|
||||
class SearchActivity(gtk.VBox):
|
||||
def __init__(self):
|
||||
gtk.VBox.__init__(self)
|
||||
self.add(vbox)
|
||||
vbox.show()
|
||||
|
||||
class SearchWindow(gtk.Window):
|
||||
def __init__(self):
|
||||
gtk.Window.__init__(self)
|
||||
|
||||
self.set_default_size(640, 480);
|
||||
self.connect("delete-event", self.__delete_event);
|
||||
|
||||
vbox = gtk.VBox()
|
||||
|
||||
self.embed = geckoembed.Embed()
|
||||
self.embed.connect("open-address", self.__open_address);
|
||||
|
||||
self.pack_start(self.embed)
|
||||
vbox.pack_start(self.embed)
|
||||
self.embed.show()
|
||||
|
||||
address_toolbar = AddressToolbar()
|
||||
self.pack_start(address_toolbar, False)
|
||||
vbox.pack_start(address_toolbar, False)
|
||||
address_toolbar.show()
|
||||
|
||||
self.add(vbox)
|
||||
vbox.show()
|
||||
|
||||
self.embed.load_url("http://www.google.com")
|
||||
|
||||
def __delete_event(self, widget, event, data=None):
|
||||
@ -175,39 +175,10 @@ class SearchActivity(gtk.VBox):
|
||||
if uri.startswith("http://www.google.com"):
|
||||
return False
|
||||
else:
|
||||
web_activity.openAddress(uri)
|
||||
browser = BrowserWindow(uri)
|
||||
browser.show()
|
||||
return True
|
||||
|
||||
class WebActivity:
|
||||
def __init__(self):
|
||||
bus = dbus.SessionBus()
|
||||
container_object = bus.get_object("com.redhat.Sugar.Shell", \
|
||||
"/com/redhat/Sugar/Shell/ActivityContainer")
|
||||
self.container = dbus.Interface(container_object, \
|
||||
"com.redhat.Sugar.Shell.ActivityContainer")
|
||||
|
||||
def run(self):
|
||||
window_id = self.container.add_activity("Web")
|
||||
|
||||
plug = gtk.Plug(window_id)
|
||||
|
||||
window = SearchActivity()
|
||||
plug.add(window)
|
||||
window.show()
|
||||
|
||||
plug.show()
|
||||
|
||||
def openAddress(self, uri):
|
||||
window_id = self.container.add_activity("Page")
|
||||
|
||||
plug = gtk.Plug(window_id)
|
||||
|
||||
window = BrowserActivity(uri)
|
||||
plug.add(window)
|
||||
window.show()
|
||||
|
||||
plug.show()
|
||||
|
||||
web_activity = WebActivity()
|
||||
web_activity.run()
|
||||
window = SearchWindow()
|
||||
window.show()
|
||||
gtk.main()
|
||||
|
@ -1,114 +0,0 @@
|
||||
# $Id: __init__.py 977 2005-11-15 01:49:54Z lennart $
|
||||
|
||||
# This file is part of avahi.
|
||||
#
|
||||
# avahi 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 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# avahi 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 Lesser General Public
|
||||
# License along with avahi; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
# USA.
|
||||
|
||||
# Some definitions matching those in avahi-common/defs.h
|
||||
|
||||
import dbus
|
||||
|
||||
SERVER_INVALID, SERVER_REGISTERING, SERVER_RUNNING, SERVER_COLLISION, SERVER_FAILURE = range(0, 5)
|
||||
|
||||
ENTRY_GROUP_UNCOMMITED, ENTRY_GROUP_REGISTERING, ENTRY_GROUP_ESTABLISHED, ENTRY_GROUP_COLLISION, ENTRY_GROUP_FAILURE = range(0, 5)
|
||||
|
||||
DOMAIN_BROWSER_BROWSE, DOMAIN_BROWSER_BROWSE_DEFAULT, DOMAIN_BROWSER_REGISTER, DOMAIN_BROWSER_REGISTER_DEFAULT, DOMAIN_BROWSER_BROWSE_LEGACY = range(0, 5)
|
||||
|
||||
PROTO_UNSPEC, PROTO_INET, PROTO_INET6 = -1, 0, 1
|
||||
|
||||
IF_UNSPEC = -1
|
||||
|
||||
PUBLISH_UNIQUE = 1
|
||||
PUBLISH_NO_PROBE = 2
|
||||
PUBLISH_NO_ANNOUNCE = 4
|
||||
PUBLISH_ALLOW_MULTIPLE = 8
|
||||
PUBLISH_NO_REVERSE = 16
|
||||
PUBLISH_NO_COOKIE = 32
|
||||
PUBLISH_UPDATE = 64
|
||||
PUBLISH_USE_WIDE_AREA = 128
|
||||
PUBLISH_USE_MULTICAST = 256
|
||||
|
||||
LOOKUP_USE_WIDE_AREA = 1
|
||||
LOOKUP_USE_MULTICAST = 2
|
||||
LOOKUP_NO_TXT = 4
|
||||
LOOKUP_NO_ADDRESS = 8
|
||||
|
||||
LOOKUP_RESULT_CACHED = 1
|
||||
LOOKUP_RESULT_WIDE_AREA = 2
|
||||
LOOKUP_RESULT_MULTICAST = 4
|
||||
LOOKUP_RESULT_LOCAL = 8
|
||||
LOOKUP_RESULT_OUR_OWN = 16
|
||||
LOOKUP_RESULT_STATIC = 32
|
||||
|
||||
SERVICE_COOKIE = "org.freedesktop.Avahi.cookie"
|
||||
SERVICE_COOKIE_INVALID = 0
|
||||
|
||||
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"
|
||||
DBUS_INTERFACE_ADDRESS_RESOLVER = DBUS_NAME + ".AddressResolver"
|
||||
DBUS_INTERFACE_HOST_NAME_RESOLVER = DBUS_NAME + ".HostNameResolver"
|
||||
DBUS_INTERFACE_SERVICE_RESOLVER = DBUS_NAME + ".ServiceResolver"
|
||||
DBUS_INTERFACE_RECORD_BROWSER = DBUS_NAME + ".RecordBrowser"
|
||||
|
||||
def byte_array_to_string(s):
|
||||
r = ""
|
||||
|
||||
for c in s:
|
||||
|
||||
if c >= 32 and c < 127:
|
||||
r += "%c" % c
|
||||
else:
|
||||
r += "."
|
||||
|
||||
return r
|
||||
|
||||
def txt_array_to_string_array(t):
|
||||
l = []
|
||||
|
||||
for s in t:
|
||||
l.append(byte_array_to_string(s))
|
||||
|
||||
return l
|
||||
|
||||
|
||||
def string_to_byte_array(s):
|
||||
r = []
|
||||
|
||||
for c in s:
|
||||
r.append(dbus.Byte(ord(c)))
|
||||
|
||||
return r
|
||||
|
||||
def string_array_to_txt_array(t):
|
||||
l = []
|
||||
|
||||
for s in t:
|
||||
l.append(string_to_byte_array(s))
|
||||
|
||||
return l
|
||||
|
||||
def dict_to_txt_array(txt_dict):
|
||||
l = []
|
||||
|
||||
for k,v in txt_dict.items():
|
||||
l.append(string_to_byte_array("%s=%s" % (k,v)))
|
||||
|
||||
return l
|
16
chat/main.py
16
chat/main.py
@ -33,11 +33,6 @@ class ChatApp(SimpleGladeApp):
|
||||
realname = "Some Clueless User"
|
||||
return (nick, realname)
|
||||
|
||||
def new_service(self, action, interface, protocol, name, stype, domain, flags):
|
||||
if action != 'added' or stype != presence.OLPC_CHAT_SERVICE:
|
||||
return
|
||||
self._pdiscovery.resolve_service(interface, protocol, name, stype, domain, self.service_resolved)
|
||||
|
||||
def on_buddyList_buddy_selected(self, widget, *args):
|
||||
(model, aniter) = widget.get_selection().get_selected()
|
||||
name = self.treemodel.get(aniter,0)
|
||||
@ -72,12 +67,6 @@ class ChatApp(SimpleGladeApp):
|
||||
res[tmp[0]] = ''
|
||||
return res
|
||||
|
||||
def service_resolved(self, interface, protocol, name, stype, domain, host, aprotocol, address, port, txt, flags):
|
||||
data = self._pair_to_dict(avahi.txt_array_to_string_array(txt))
|
||||
if len(data) > 0 and 'name' in data.keys():
|
||||
aniter = self.treemodel.insert_after(None,None)
|
||||
self.treemodel.set(aniter, 0, data['name'])
|
||||
|
||||
def new(self):
|
||||
self._group_chat_buffer = gtk.TextBuffer()
|
||||
self.chatView.set_buffer(self._group_chat_buffer)
|
||||
@ -97,12 +86,13 @@ class ChatApp(SimpleGladeApp):
|
||||
self.buddyList.append_column(column)
|
||||
|
||||
self._pannounce.register_service(self._realname, 6666, presence.OLPC_CHAT_SERVICE, name=self._nick)
|
||||
self._pdiscovery.add_service_listener(self.new_service)
|
||||
self._pdiscovery.start()
|
||||
|
||||
self._gc_controller = network.GroupChatController('224.0.0.221', 6666, self._recv_group_message)
|
||||
self._gc_controller.start()
|
||||
|
||||
aniter = self.treemodel.insert_after(None,None)
|
||||
self.treemodel.set(aniter, 0, data['name'])
|
||||
|
||||
def cleanup(self):
|
||||
pass
|
||||
|
||||
|
@ -1,6 +1,3 @@
|
||||
#!/usr/bin/python -t
|
||||
|
||||
|
||||
import avahi, dbus, dbus.glib
|
||||
|
||||
OLPC_CHAT_SERVICE = "_olpc_chat._udp"
|
||||
|
Loading…
Reference in New Issue
Block a user