Difference between revisions of "Development Team/Almanac/Sugar.presence.buddy"
< Development Team | Almanac
Jump to navigation
Jump to search
m (moved Anal bleaching 15/Almanac/Sugar.presence.buddy to Development Team/Almanac/Sugar.presence.buddy over redirect: revert) |
m (moved Development Team/Almanac/Sugar.presence.buddy to Walter is a wanker 12/Almanac/Sugar.presence.buddy: Walter is a wanker) |
(No difference)
|
Revision as of 19:21, 23 February 2010
For Developers: almanac · api · bugs · gitorious · cgit · download · people · OLPC: wiki · activities · trac · cgit · build index · repository · firmware · Fedora: packages
Class: Buddy(gobject.GObject)
The sugar.presence package includes tools to get a list of activities that a buddy. In the class Buddy, there is specifically a method called get_joined_activities() that will "retrieve the set of all activities which this buddy has joined". It returns these activities as a list of sugar.presence.activitiy.Activity objects. The code below shows a method that prints out the list of activities that the user's XO has joined with another specified user (in this case, someone named 'olpc').
from sugar.presence import presenceservice ... class AnnotateActivity(activity.Activity): #### Method: __init__, initialize this AnnotateActivity instance def __init__(self, handle): ... self._print_buddy_activities('olpc') ... #### Method: _print_buddy_activities, which takes the name of a buddy and prints # out the name of the activities that this buddy is sharing with you. def _print_buddy_activities(self, name): #self._find_buddy_by_name returns a sugar.presence.buddy.Buddy object whose nickname matches the given name buddy = self._find_buddy_by_name(name) activities = buddy.get_joined_activities() for buddyActivity in activities: print buddyActivity.get_property('name')