Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
This commit is contained in:
commit
d32dd05569
@ -469,13 +469,22 @@ class Activity(Window, gtk.Container):
|
|||||||
self._shared_activity = activity
|
self._shared_activity = activity
|
||||||
self.emit('shared')
|
self.emit('shared')
|
||||||
|
|
||||||
def share(self):
|
def share(self, private=False):
|
||||||
"""Request that the activity be shared on the network."""
|
"""Request that the activity be shared on the network.
|
||||||
|
|
||||||
|
private -- bool: True to share by invitation only,
|
||||||
|
False to advertise as shared to everyone.
|
||||||
|
"""
|
||||||
|
# FIXME: Make private=True to turn on the by-invitation-only scope
|
||||||
if self._shared_activity and self._shared_activity.props.joined:
|
if self._shared_activity and self._shared_activity.props.joined:
|
||||||
raise RuntimeError("Activity %s already shared." % self._activity_id)
|
raise RuntimeError("Activity %s already shared." %
|
||||||
logging.debug('Requesting share of activity %s.' % self._activity_id)
|
self._activity_id)
|
||||||
self._share_id = self._pservice.connect("activity-shared", self._internal_share_cb)
|
verb = private and 'private' or 'public'
|
||||||
self._pservice.share_activity(self)
|
logging.debug('Requesting %s share of activity %s.' %
|
||||||
|
(verb, self._activity_id))
|
||||||
|
self._share_id = self._pservice.connect("activity-shared",
|
||||||
|
self._internal_share_cb)
|
||||||
|
self._pservice.share_activity(self, private=private)
|
||||||
|
|
||||||
def _realize_cb(self, window):
|
def _realize_cb(self, window):
|
||||||
wm.set_bundle_id(window.window, self.get_service_name())
|
wm.set_bundle_id(window.window, self.get_service_name())
|
||||||
|
@ -167,16 +167,17 @@ class Activity(gobject.GObject):
|
|||||||
return bus_name, connection, channels
|
return bus_name, connection, channels
|
||||||
|
|
||||||
def _leave_cb(self):
|
def _leave_cb(self):
|
||||||
# XXX Is this the right thing to do?
|
"""Callback for async action of leaving shared activity."""
|
||||||
self.emit("joined", False, "left activity")
|
self.emit("joined", False, "left activity")
|
||||||
|
|
||||||
def _leave_error_cb(self, err):
|
def _leave_error_cb(self, err):
|
||||||
# XXX We are closing down anyway
|
"""Callback for error in async leaving of shared activity.
|
||||||
|
|
||||||
|
XXX Add logging!"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def leave(self):
|
def leave(self):
|
||||||
"""Leave this shared activity"""
|
"""Leave this shared activity"""
|
||||||
# FIXME
|
|
||||||
self._joined = False
|
self._joined = False
|
||||||
self._activity.Leave(reply_handler=self._leave_cb,
|
self._activity.Leave(reply_handler=self._leave_cb,
|
||||||
error_handler=self._leave_error_cb)
|
error_handler=self._leave_error_cb)
|
||||||
|
@ -364,7 +364,11 @@ class PresenceService(gobject.GObject):
|
|||||||
return self._new_object(owner_op)
|
return self._new_object(owner_op)
|
||||||
|
|
||||||
def _share_activity_cb(self, activity, op):
|
def _share_activity_cb(self, activity, op):
|
||||||
"""Notify with GObject event of successful sharing of activity"""
|
"""Notify with GObject event of successful sharing of activity
|
||||||
|
|
||||||
|
op -- full dbus path of the new object, must be
|
||||||
|
prefixed with either of _PS_BUDDY_OP or _PS_ACTIVITY_OP
|
||||||
|
"""
|
||||||
psact = self._new_object(op)
|
psact = self._new_object(op)
|
||||||
psact._joined = True
|
psact._joined = True
|
||||||
self.emit("activity-shared", True, psact, None)
|
self.emit("activity-shared", True, psact, None)
|
||||||
@ -374,10 +378,10 @@ class PresenceService(gobject.GObject):
|
|||||||
_logger.debug("Error sharing activity %s: %s" % (activity.get_id(), err))
|
_logger.debug("Error sharing activity %s: %s" % (activity.get_id(), err))
|
||||||
self.emit("activity-shared", False, None, err)
|
self.emit("activity-shared", False, None, err)
|
||||||
|
|
||||||
def share_activity(self, activity, properties={}):
|
def share_activity(self, activity, properties={}, private=True):
|
||||||
"""Ask presence service to ask the activity to share itself
|
"""Ask presence service to ask the activity to share itself publicly.
|
||||||
|
|
||||||
Uses the ShareActivity method on the service to ask for the
|
Uses the AdvertiseActivity method on the service to ask for the
|
||||||
sharing of the given activity. Arranges to emit activity-shared
|
sharing of the given activity. Arranges to emit activity-shared
|
||||||
event with:
|
event with:
|
||||||
|
|
||||||
@ -388,19 +392,33 @@ class PresenceService(gobject.GObject):
|
|||||||
returns None
|
returns None
|
||||||
"""
|
"""
|
||||||
actid = activity.get_id()
|
actid = activity.get_id()
|
||||||
|
_logger.debug('XXXX in share_activity')
|
||||||
|
|
||||||
# Ensure the activity is not already shared/joined
|
# Ensure the activity is not already shared/joined
|
||||||
for obj in self._objcache.values():
|
for obj in self._objcache.values():
|
||||||
if not isinstance(object, Activity):
|
if not isinstance(object, Activity):
|
||||||
continue
|
continue
|
||||||
if obj.props.id == actid or obj.props.joined:
|
if obj.props.id == actid or obj.props.joined:
|
||||||
raise RuntimeError("Activity %s is already shared." % actid)
|
raise RuntimeError("Activity %s is already shared." %
|
||||||
|
actid)
|
||||||
|
|
||||||
atype = activity.get_service_name()
|
atype = activity.get_service_name()
|
||||||
name = activity.props.title
|
name = activity.props.title
|
||||||
self._ps.ShareActivity(actid, atype, name, properties,
|
if private:
|
||||||
reply_handler=lambda *args: self._share_activity_cb(activity, *args),
|
_logger.debug('XXXX private, so calling InviteActivity')
|
||||||
error_handler=lambda *args: self._share_activity_error_cb(activity, *args))
|
self._ps.InviteActivity(actid, atype, name, properties,
|
||||||
|
reply_handler=lambda *args: \
|
||||||
|
self._share_activity_cb(activity, *args),
|
||||||
|
error_handler=lambda *args: \
|
||||||
|
self._share_activity_error_cb(activity, *args))
|
||||||
|
else:
|
||||||
|
# FIXME: Test, then make this AdvertiseActivity:
|
||||||
|
_logger.debug('XXXX not private, so calling ShareActivity')
|
||||||
|
self._ps.ShareActivity(actid, atype, name, properties,
|
||||||
|
reply_handler=lambda *args: \
|
||||||
|
self._share_activity_cb(activity, *args),
|
||||||
|
error_handler=lambda *args: \
|
||||||
|
self._share_activity_error_cb(activity, *args))
|
||||||
|
|
||||||
def get_preferred_connection(self):
|
def get_preferred_connection(self):
|
||||||
"""Gets the preferred telepathy connection object that an activity
|
"""Gets the preferred telepathy connection object that an activity
|
||||||
|
Loading…
Reference in New Issue
Block a user