[sugar] Issues with the presence service

Dan Williams dcbw
Sat Jul 29 12:31:41 EDT 2006

On Sat, 2006-07-29 at 15:05 +0200, Marco Pesenti Gritti wrote:
> >> - We need a way to get the activity default type, so we can figure out 
> >> which activity to associate to the service.
> >>     
> >
> > Right; I think we should do this locally.  We have to have something
> > like .desktop files, or hardcoded in the activities init routine, what
> > it's default type is.  We already do that when the activity registers
> > with the shell (I think?), so we need to allow the HomePage to access
> > that.  I'm not sure if the PS should know about the default type.
> >
> >   
> We are already doing this locally... I think we need to advertise it in 
> the PS though. Otherwise how  do you associate the right activity icon 
> in the home page for remote activities (published by someone and not 
> joined) ? And, more importantly, how do you open a remote activity if 
> you don't know his type?

Well, you can't join the activity if you don't have that activity
locally already (though we need to figure out how to get the activity
from another child if you don't have it).  It's also completely useless
advertise the activity type if you don't have the activity code locally
too, since you have to have the activity code locally to be able to
display that activity.

Like icons; if you don't have the icon for .doc files, it shows up as a
blank one.  I don't see how publishing the activity type is not like
this.  If you have the activity locally already, the activity itself
will be able to register all the types it handles with the PS, so that
the PS can tell the activity when new instances appear.

I don't think this has anything to do with the PS.  The Home Page is
more of a document viewer, and activities will have to "register" their
type and how to handle it with the Home Page.  Trying to add that to the
PS seems like unnecessary complication to me, when all the rendering is
done in the home page anyway.

So how about this for a flow?

- PS sees new "_tamtam._tcp" service advertised, sends ServiceAppeared

- Home Page receives ServiceAppeared signal, looks through it's registry
for Activities that can handle "_tamtam._tcp"

- Home Page finds the TamTam activity can handle it, and asks some
TamTam code to thumbnail and display the activity on the Home Page

My point is that on the activities _themselves_ can know what service
types the can handle, and how to handle those types.  We don't need a
"default type" passed through the PS, because the local activity knows
how to handle it.  For example, the browser uses "_web_olpc._udp" and
"_olpc_model._tcp".  The Browser activity already knows that the
_web_olpc._udp service is the "default" service for a browser activity,
and it can tell the Home Page that without the PS getting involved.

> >> - I had to make some hacky changes to share_activity. For udp services 
> >> we need to publish the group IP in the properties (unless there is a 
> >> better way?). Have a look at how I'm doing it currently... I'm sure we 
> >> can clean it up.
> >>     
> >
> > Shouldn't the PS already be adding the "address" of the group into the
> > attributes of the message?  The address returned by get_address() on the
> > service should _always_ be the communication address of the service, not
> > the unicast address of the person who published it (which is what
> > get_source_address() is for).  I thought this worked already.
> >
> >   
> That make sense now. Though I think it was not working... a bug 
> somewhere I guess.

I did change that code somewhat from the previous in-process PS
implementation, and it's somewhat complicated.  So there may be a bug.

> >> - There seem to be no way to join an activity other than manually 
> >> duplicate the service. Also should we provide this rather than have 
> >> every activity to reimplement it? In sugar.activity.Activity or maybe 
> >> even directly in the shell...
> >>     
> >
> > Well, we _have_ to create a new service when we join the activity, since
> > we need to change the source address for the service anyway.  Even if we
> > receive a service from the network from somebody else, that service is
> > "somebody else's" service, and _not_ ours.  We have to create a new
> > service, cloned from the original service, and publish that instead,
> > because that uses our local information
> Right, my point was more than we need convenient way to do it (and one 
> that doesn't need a comment to clarify what is going on)...
>                 # Ok, there's an existing chat service that we copy
>                 # parameters and such from
>                 addr = service.get_address()
>                 port = service.get_port()
>                 self._chat_service = 
> self._pservice.share_activity(self._activity,
>                                 stype=ActivityChat.SERVICE_TYPE, 
> address=addr, port=port)

Hmm, maybe we should make the Activity base class handle the sharing?
Because Activity objects already know their default service type, and we
shouldn't be using "share_activity" to publish anything _except_ the
default service type.

I wanted to get away from having create_service()/create_activity()
calls that just create the service/activity and then wait for you to do
something with it.  That's pretty useless and encourages bad habits.
When you create a service, it should be published automatically because
there's no legitimate reason I can think of that it shouldn't be
published automatically.


More information about the Sugar-devel mailing list