From fdb9c57e659c8ff66479f80633e2305e3a56a686 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 11 Sep 2007 17:53:27 +0200 Subject: [PATCH] Handle invitations inside Activity. --- shell/view/ActivityHost.py | 17 +++++++---------- sugar/activity/activity.py | 14 ++++++++++++++ sugar/activity/activityservice.py | 5 +++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index b22cd2b9..c6c08539 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -64,16 +64,13 @@ class ActivityHost: def get_model(self): return self._model - def invite(self, buddy): - pservice = presenceservice.get_instance() - activity = pservice.get_activity(self.get_id()) - if activity is None: - logging.error('Invite failed, %s is unknown.' % self.get_id()) - activity.invite(buddy.get_buddy(), '', self._invite_response_cb) - - def _invite_response_cb(self, error): - if error: - logging.error('Invite failed: %s' % error) + def invite(self, buddy_model): + service = self._model.get_service() + if service: + buddy = buddy_model.get_buddy() + service.Invite(buddy.props.key) + else: + logging.error('Invite failed, activity service not ') def present(self): # wnck.Window.activate() expects a timestamp, but we don't diff --git a/sugar/activity/activity.py b/sugar/activity/activity.py index 9e140884..af15e4e0 100644 --- a/sugar/activity/activity.py +++ b/sugar/activity/activity.py @@ -543,6 +543,20 @@ class Activity(Window, gtk.Container): # FIXME: some way to distinguish between share scopes self._jobject.metadata['share-scope'] = SCOPE_NEIGHBORHOOD + def _invite_response_cb(self, error): + if error: + logging.error('Invite failed: %s' % error) + + def invite(self, buddy_key): + if self._shared_activity is None: + return + + buddy = self._pservice.get_buddy(buddy_key) + if buddy: + self._shared_activity.invite(buddy, '', self._invite_response_cb) + else: + logging.error('Cannot invite %s, no such buddy.' % buddy_key) + def share(self, private=False): """Request that the activity be shared on the network. diff --git a/sugar/activity/activityservice.py b/sugar/activity/activityservice.py index f2b33945..b2f7e150 100644 --- a/sugar/activity/activityservice.py +++ b/sugar/activity/activityservice.py @@ -59,3 +59,8 @@ class ActivityService(dbus.service.Object): def SetActive(self, active): logging.debug('ActivityService.set_active: %s.' % active) self._activity.props.active = active + + @dbus.service.method(_ACTIVITY_INTERFACE) + def Invite(self, buddy_key): + self._activity.invite(buddy_key) +