Use new PresenceService API for sharing by invitation only
This commit is contained in:
		
							parent
							
								
									d09b8d3ea4
								
							
						
					
					
						commit
						52f2bea3ed
					
				@ -448,13 +448,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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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())
 | 
				
			||||||
 | 
				
			|||||||
@ -371,10 +371,14 @@ 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, 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 
 | 
					        activity -- sugar.activity.activity.Activity instance
 | 
				
			||||||
 | 
					        private -- bool: True to share by invitation only,
 | 
				
			||||||
 | 
					            False to advertise as shared to everyone.
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        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:
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
@ -395,7 +399,8 @@ class PresenceService(gobject.GObject):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        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,
 | 
					        # FIXME: Test, then make this AdvertiseActivity:
 | 
				
			||||||
 | 
					        self._ps.ShareActivity(actid, atype, name, private,
 | 
				
			||||||
                reply_handler=lambda *args: self._share_activity_cb(activity, *args),
 | 
					                reply_handler=lambda *args: self._share_activity_cb(activity, *args),
 | 
				
			||||||
                error_handler=lambda *args: self._share_activity_error_cb(activity, *args))
 | 
					                error_handler=lambda *args: self._share_activity_error_cb(activity, *args))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user