Merge branch 'master' of git+ssh://crank.laptop.org/git/sugar
This commit is contained in:
commit
6fc051bc8e
@ -3,6 +3,7 @@ import geckoembed
|
|||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk
|
import gtk
|
||||||
|
import gobject
|
||||||
|
|
||||||
import sugar.env
|
import sugar.env
|
||||||
|
|
||||||
@ -29,11 +30,14 @@ class BrowserShell(dbus.service.Object):
|
|||||||
links.append(link)
|
links.append(link)
|
||||||
return links
|
return links
|
||||||
|
|
||||||
|
def _start_browser_cb(self, browser):
|
||||||
|
browser.connect_to_shell()
|
||||||
|
|
||||||
@dbus.service.method('com.redhat.Sugar.BrowserShell')
|
@dbus.service.method('com.redhat.Sugar.BrowserShell')
|
||||||
def open_browser(self, uri):
|
def open_browser(self, uri):
|
||||||
browser = BrowserActivity(uri)
|
browser = BrowserActivity(uri)
|
||||||
self.__browsers.append(browser)
|
self.__browsers.append(browser)
|
||||||
browser.connect_to_shell()
|
gobject.idle_add(self._start_browser_cb, browser)
|
||||||
|
|
||||||
@dbus.service.method('com.redhat.Sugar.BrowserShell')
|
@dbus.service.method('com.redhat.Sugar.BrowserShell')
|
||||||
def open_browser_with_id(self, uri, activity_id):
|
def open_browser_with_id(self, uri, activity_id):
|
||||||
|
@ -395,6 +395,25 @@ class PresenceService(gobject.GObject):
|
|||||||
def _new_domain_cb_glue(self, interface, protocol, domain, flags=0):
|
def _new_domain_cb_glue(self, interface, protocol, domain, flags=0):
|
||||||
gobject.idle_add(self._new_domain_cb, interface, protocol, domain, flags)
|
gobject.idle_add(self._new_domain_cb, interface, protocol, domain, flags)
|
||||||
|
|
||||||
|
def track_activity(self, activity_uid):
|
||||||
|
"""INTERNAL ONLY; register an activity's UID to recognize service
|
||||||
|
events for that specific activity."""
|
||||||
|
if not activity_uid or not util.validate_activity_uid(uid):
|
||||||
|
raise ValueError("activity uid must be a valid activity uid string.")
|
||||||
|
if activity_uid in self._allowed_activities:
|
||||||
|
return
|
||||||
|
self._allowed_activities.append(activity_uid)
|
||||||
|
self._check_and_resolve_service_advs(dec_stype)
|
||||||
|
|
||||||
|
def untrack_activity(self, activity_uid):
|
||||||
|
"""INTERNAL ONLY; unregister an activity's UID to stop service
|
||||||
|
events for that specific activity."""
|
||||||
|
if not activity_uid or not util.validate_activity_uid(uid):
|
||||||
|
raise ValueError("activity uid must be a valid activity uid string.")
|
||||||
|
if activity_uid not in self._allowed_activities:
|
||||||
|
return
|
||||||
|
self._allowed_activities.remove(activity_uid)
|
||||||
|
|
||||||
def track_service_type(self, short_stype):
|
def track_service_type(self, short_stype):
|
||||||
"""Requests that the Presence service look for and recognize
|
"""Requests that the Presence service look for and recognize
|
||||||
a certain mDNS service types."""
|
a certain mDNS service types."""
|
||||||
@ -414,17 +433,24 @@ class PresenceService(gobject.GObject):
|
|||||||
if uid:
|
if uid:
|
||||||
raise RuntimeError("Can only track plain service types!")
|
raise RuntimeError("Can only track plain service types!")
|
||||||
self._allowed_service_types.append(dec_stype)
|
self._allowed_service_types.append(dec_stype)
|
||||||
|
self._check_and_resolve_service_advs(dec_stype)
|
||||||
|
|
||||||
|
def _check_and_resolve_service_advs(self, specific_stype=None):
|
||||||
# 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
|
||||||
resolv_list = []
|
resolv_list = []
|
||||||
# Find all services first by their activity
|
# Find all services first by their activity
|
||||||
|
search_types = self._allowed_service_types
|
||||||
|
if specific_stype:
|
||||||
|
search_types = [specific_stype]
|
||||||
for uid in self._allowed_activities:
|
for uid in self._allowed_activities:
|
||||||
full_stype = Service.compose_service_type(dec_stype, uid)
|
for short_stype in search_stypes:
|
||||||
adv_list = self._find_service_adv(stype=full_stype)
|
full_stype = Service.compose_service_type(short_stype, uid)
|
||||||
resolv_list = resolv_list + adv_list
|
adv_list = self._find_service_adv(stype=full_stype)
|
||||||
|
resolv_list = resolv_list + adv_list
|
||||||
# Then, find services by just the plain service type
|
# Then, find services by just the plain service type
|
||||||
resolv_list = resolv_list + self._find_service_adv(stype=dec_stype)
|
if specific_stype is not None:
|
||||||
|
resolv_list = resolv_list + self._find_service_adv(stype=specific_stype)
|
||||||
|
|
||||||
# Request resolution for them
|
# Request resolution for them
|
||||||
for adv in resolv_list:
|
for adv in resolv_list:
|
||||||
|
@ -65,9 +65,9 @@ class ActivitiesView(gtk.TreeView):
|
|||||||
print 'Activated row %s %s' % (address, activity_id)
|
print 'Activated row %s %s' % (address, activity_id)
|
||||||
|
|
||||||
if activity_id is None:
|
if activity_id is None:
|
||||||
browser_shell.open_browser(address, ignore_reply=True)
|
browser_shell.open_browser(address)
|
||||||
else:
|
else:
|
||||||
browser_shell.open_browser_with_id(address, activity_id, ignore_reply=True)
|
browser_shell.open_browser_with_id(address, activity_id)
|
||||||
|
|
||||||
class StartPage(gtk.HBox):
|
class StartPage(gtk.HBox):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user