Fix the problem with service resolution (Dan please have a look...)
This commit is contained in:
parent
7b507d545b
commit
6a8e863a16
@ -11,7 +11,7 @@ from sugar.browser import NavigationToolbar
|
|||||||
from sugar.presence.PresenceService import PresenceService
|
from sugar.presence.PresenceService import PresenceService
|
||||||
|
|
||||||
|
|
||||||
_BROWSER_ACTIVITY_TYPE = "_web_olpc._udp"
|
_BROWSER_ACTIVITY_TYPE = "_web_browser_olpc._udp"
|
||||||
_SERVICE_URI_TAG = "URI"
|
_SERVICE_URI_TAG = "URI"
|
||||||
_SERVICE_TITLE_TAG = "Title"
|
_SERVICE_TITLE_TAG = "Title"
|
||||||
|
|
||||||
@ -46,20 +46,20 @@ class BrowserActivity(activity.Activity):
|
|||||||
self.embed.load_address(address)
|
self.embed.load_address(address)
|
||||||
self._notif_bar.hide()
|
self._notif_bar.hide()
|
||||||
|
|
||||||
def set_mode(self, mode):
|
#def set_mode(self, mode):
|
||||||
self._mode = mode
|
# self._mode = mode
|
||||||
if mode == BrowserActivity.LEADING:
|
# if mode == BrowserActivity.LEADING:
|
||||||
self._notif_bar.set_text('Share this page with the group.')
|
# self._notif_bar.set_text('Share this page with the group.')
|
||||||
self._notif_bar.set_action('set_shared_location', 'Share')
|
# self._notif_bar.set_action('set_shared_location', 'Share')
|
||||||
self._notif_bar.set_icon('stock_shared-by-me')
|
# self._notif_bar.set_icon('stock_shared-by-me')
|
||||||
self._notif_bar.show()
|
# self._notif_bar.show()
|
||||||
|
|
||||||
def _setup_shared(self, uri):
|
def _setup_shared(self, uri):
|
||||||
if False:
|
pass
|
||||||
self._model = self._group.get_store().get_model(uri)
|
#self._model = self._group.get_store().get_model(uri)
|
||||||
if self._model:
|
#if self._model:
|
||||||
self.set_mode(BrowserActivity.FOLLOWING)
|
# self.set_mode(BrowserActivity.FOLLOWING)
|
||||||
self._model.add_listener(self.__shared_location_changed_cb)
|
# self._model.add_listener(self.__shared_location_changed_cb)
|
||||||
|
|
||||||
def on_connected_to_shell(self):
|
def on_connected_to_shell(self):
|
||||||
self.set_ellipsize_tab(True)
|
self.set_ellipsize_tab(True)
|
||||||
@ -108,19 +108,18 @@ class BrowserActivity(activity.Activity):
|
|||||||
self._share_service = self._pservice.share_activity(self,
|
self._share_service = self._pservice.share_activity(self,
|
||||||
stype=_BROWSER_ACTIVITY_TYPE, properties=properties)
|
stype=_BROWSER_ACTIVITY_TYPE, properties=properties)
|
||||||
|
|
||||||
if False:
|
# Create our activity-specific browser sharing service
|
||||||
# Create our activity-specific browser sharing service
|
#self._model = self._group.get_store().create_model(url)
|
||||||
self._model = self._group.get_store().create_model(url)
|
#self._model.set_value('owner', self._pservice.get_owner().get_nick_name())
|
||||||
self._model.set_value('owner', self._pservice.get_owner().get_nick_name())
|
#self._update_shared_location()
|
||||||
self._update_shared_location()
|
#self.set_mode(BrowserActivity.LEADING)
|
||||||
self.set_mode(BrowserActivity.LEADING)
|
|
||||||
|
|
||||||
bus = dbus.SessionBus()
|
#bus = dbus.SessionBus()
|
||||||
proxy_obj = bus.get_object('com.redhat.Sugar.Chat', '/com/redhat/Sugar/Chat')
|
#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 = dbus.Interface(proxy_obj, 'com.redhat.Sugar.ChatShell')
|
||||||
|
|
||||||
chat_shell.send_text_message('<richtext><link href="' + escaped_address +
|
#chat_shell.send_text_message('<richtext><link href="' + escaped_address +
|
||||||
'">' + escaped_title + '</link></richtext>')
|
# '">' + escaped_title + '</link></richtext>')
|
||||||
|
|
||||||
def __title_cb(self, embed):
|
def __title_cb(self, embed):
|
||||||
self.set_tab_text(embed.get_title())
|
self.set_tab_text(embed.get_title())
|
||||||
|
@ -256,6 +256,7 @@ class PresenceService(gobject.GObject):
|
|||||||
def _resolve_service(self, interface, protocol, name, stype, domain, flags):
|
def _resolve_service(self, interface, protocol, name, stype, domain, flags):
|
||||||
"""Resolve and lookup a ZeroConf service to obtain its address and TXT records."""
|
"""Resolve and lookup a ZeroConf service to obtain its address and TXT records."""
|
||||||
# Ask avahi to resolve this particular service
|
# Ask avahi to resolve this particular service
|
||||||
|
print 'Resolving service ' + name + ' ' + stype
|
||||||
self._server.ResolveService(int(interface), int(protocol), name,
|
self._server.ResolveService(int(interface), int(protocol), name,
|
||||||
stype, domain, avahi.PROTO_UNSPEC, dbus.UInt32(0), # use flags here maybe?
|
stype, domain, avahi.PROTO_UNSPEC, dbus.UInt32(0), # use flags here maybe?
|
||||||
reply_handler=self._resolve_service_reply_cb_glue,
|
reply_handler=self._resolve_service_reply_cb_glue,
|
||||||
@ -395,11 +396,11 @@ class PresenceService(gobject.GObject):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Decompose service type if we can
|
# 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 and util.validate_activity_uid(uid):
|
||||||
if uid not in self._activity_uids:
|
if uid not in self._activity_uids:
|
||||||
self._activity_uids.append(uid)
|
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
|
# Find unresolved services that match the service type
|
||||||
# we're now interested in, and resolve them
|
# we're now interested in, and resolve them
|
||||||
|
@ -100,7 +100,6 @@ class StartPage(gtk.HBox):
|
|||||||
def _on_new_service_adv_cb(self, pservice, uid, stype):
|
def _on_new_service_adv_cb(self, pservice, uid, stype):
|
||||||
if uid is not None:
|
if uid is not None:
|
||||||
real_stype = Service.compose_service_type(stype, uid)
|
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)
|
self._pservice.track_service_type(real_stype)
|
||||||
|
|
||||||
def _on_activity_announced_cb(self, pservice, service, buddy):
|
def _on_activity_announced_cb(self, pservice, service, buddy):
|
||||||
|
Loading…
Reference in New Issue
Block a user