Fix the problem with service resolution (Dan please have a look...)

This commit is contained in:
Marco Pesenti Gritti 2006-06-15 18:27:50 -04:00
parent 7b507d545b
commit 6a8e863a16
3 changed files with 28 additions and 29 deletions

View File

@ -11,7 +11,7 @@ from sugar.browser import NavigationToolbar
from sugar.presence.PresenceService import PresenceService
_BROWSER_ACTIVITY_TYPE = "_web_olpc._udp"
_BROWSER_ACTIVITY_TYPE = "_web_browser_olpc._udp"
_SERVICE_URI_TAG = "URI"
_SERVICE_TITLE_TAG = "Title"
@ -46,20 +46,20 @@ class BrowserActivity(activity.Activity):
self.embed.load_address(address)
self._notif_bar.hide()
def set_mode(self, mode):
self._mode = mode
if mode == BrowserActivity.LEADING:
self._notif_bar.set_text('Share this page with the group.')
self._notif_bar.set_action('set_shared_location', 'Share')
self._notif_bar.set_icon('stock_shared-by-me')
self._notif_bar.show()
#def set_mode(self, mode):
# self._mode = mode
# if mode == BrowserActivity.LEADING:
# self._notif_bar.set_text('Share this page with the group.')
# self._notif_bar.set_action('set_shared_location', 'Share')
# self._notif_bar.set_icon('stock_shared-by-me')
# self._notif_bar.show()
def _setup_shared(self, uri):
if False:
self._model = self._group.get_store().get_model(uri)
if self._model:
self.set_mode(BrowserActivity.FOLLOWING)
self._model.add_listener(self.__shared_location_changed_cb)
pass
#self._model = self._group.get_store().get_model(uri)
#if self._model:
# self.set_mode(BrowserActivity.FOLLOWING)
# self._model.add_listener(self.__shared_location_changed_cb)
def on_connected_to_shell(self):
self.set_ellipsize_tab(True)
@ -108,19 +108,18 @@ class BrowserActivity(activity.Activity):
self._share_service = self._pservice.share_activity(self,
stype=_BROWSER_ACTIVITY_TYPE, properties=properties)
if False:
# Create our activity-specific browser sharing service
self._model = self._group.get_store().create_model(url)
self._model.set_value('owner', self._pservice.get_owner().get_nick_name())
self._update_shared_location()
self.set_mode(BrowserActivity.LEADING)
#self._model = self._group.get_store().create_model(url)
#self._model.set_value('owner', self._pservice.get_owner().get_nick_name())
#self._update_shared_location()
#self.set_mode(BrowserActivity.LEADING)
bus = dbus.SessionBus()
proxy_obj = bus.get_object('com.redhat.Sugar.Chat', '/com/redhat/Sugar/Chat')
chat_shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.ChatShell')
#bus = dbus.SessionBus()
#proxy_obj = bus.get_object('com.redhat.Sugar.Chat', '/com/redhat/Sugar/Chat')
#chat_shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.ChatShell')
chat_shell.send_text_message('<richtext><link href="' + escaped_address +
'">' + escaped_title + '</link></richtext>')
#chat_shell.send_text_message('<richtext><link href="' + escaped_address +
# '">' + escaped_title + '</link></richtext>')
def __title_cb(self, embed):
self.set_tab_text(embed.get_title())

View File

@ -256,6 +256,7 @@ class PresenceService(gobject.GObject):
def _resolve_service(self, interface, protocol, name, stype, domain, flags):
"""Resolve and lookup a ZeroConf service to obtain its address and TXT records."""
# Ask avahi to resolve this particular service
print 'Resolving service ' + name + ' ' + stype
self._server.ResolveService(int(interface), int(protocol), name,
stype, domain, avahi.PROTO_UNSPEC, dbus.UInt32(0), # use flags here maybe?
reply_handler=self._resolve_service_reply_cb_glue,
@ -395,11 +396,11 @@ class PresenceService(gobject.GObject):
return
# Decompose service type if we can
(uid, stype) = Service._decompose_service_type(stype)
(uid, dec_stype) = Service._decompose_service_type(stype)
if uid and util.validate_activity_uid(uid):
if uid not in self._activity_uids:
self._activity_uids.append(uid)
self._allowed_service_types.append(stype)
self._allowed_service_types.append(dec_stype)
# Find unresolved services that match the service type
# we're now interested in, and resolve them

View File

@ -100,7 +100,6 @@ class StartPage(gtk.HBox):
def _on_new_service_adv_cb(self, pservice, uid, stype):
if uid is not None:
real_stype = Service.compose_service_type(stype, uid)
print "Will ask to track uid=%s, stype=%s" % (uid, stype)
self._pservice.track_service_type(real_stype)
def _on_activity_announced_cb(self, pservice, service, buddy):