Difference between revisions of "Development Team/Almanac/Sugar.presence.presenceservice"

From Sugar Labs
Jump to navigation Jump to search
 
(11 intermediate revisions by 8 users not shown)
Line 1: Line 1:
 +
{{Almanac}}
 +
 
= Class: PresenceService (gobject.GObject) =
 
= Class: PresenceService (gobject.GObject) =
  
 
=== How do I share an activity with other buddies in my neighborhood? ===
 
=== How do I share an activity with other buddies in my neighborhood? ===
  
The standard [Sugar.activity.activity#Class:_ActivityToolbar_.28gtk.Toolbar.29 sugar ActivityToolbar] already contains a dropdown menu that allows users to make their activities public or private on the mesh network. To use this toolbar, you can simply use the [Sugar.activity.activity#Class:_ActivityToolbox_.28Toolbox.29 ActivityToolbox] in your activity, which adds the ActivityToolbar by default. You can see code on how to do this by reading the entry on [Sugar.activity.activity#What_is_the_standard_toolbox_needed_in_most_activities_and_how_do_I_create_it.3F creating a standard toolbox].  
+
Sharing an activity means that you make the activity visible in other users' neighborhoods so that they have the option to join the activity.  
  
 +
The standard [[Sugar.activity.activity#Class:_ActivityToolbar_.28gtk.Toolbar.29 sugar | ActivityToolbar]] already contains a dropdown menu that allows users to make their activities public or private on the mesh network. To use this toolbar, you can simply use the [[Sugar.activity.activity#Class:_ActivityToolbox_.28Toolbox.29 | ActivityToolbox]] in your activity, which adds the ActivityToolbar by default. You can see code on how to do this by reading the entry on [[Sugar.activity.activity#What_is_the_standard_toolbox_needed_in_most_activities_and_how_do_I_create_it.3F | creating a standard toolbox]].
  
 +
In your activity, you may want users to be able to control the public/private share settings outside of just using the standard ActivityToolbar menu. This can be done by using the [[Sugar.activity.activity#How_do_I_programmatically_make_my_activity_available_for_sharing.3F | Activity.share()]] method.
  
 
=== How do I get a list of buddies that are presently available on my mesh network? ===
 
=== How do I get a list of buddies that are presently available on my mesh network? ===

Latest revision as of 21:32, 23 February 2010

  Development Team/Almanac


Class: PresenceService (gobject.GObject)

How do I share an activity with other buddies in my neighborhood?

Sharing an activity means that you make the activity visible in other users' neighborhoods so that they have the option to join the activity.

The standard ActivityToolbar already contains a dropdown menu that allows users to make their activities public or private on the mesh network. To use this toolbar, you can simply use the ActivityToolbox in your activity, which adds the ActivityToolbar by default. You can see code on how to do this by reading the entry on creating a standard toolbox.

In your activity, you may want users to be able to control the public/private share settings outside of just using the standard ActivityToolbar menu. This can be done by using the Activity.share() method.

How do I get a list of buddies that are presently available on my mesh network?

The PresenceService class has a helper method called get_buddies() that will return a list of sugar.presence.buddy.Buddy objects. The code below shows how you can get a list of available buddies and print out some relevant properties for each.


    from sugar.presence import presenceservice
    ...
    #### Method: _print_buddy_info, which finds all the buddies detected for this 
    # XO and then prints their relevant properties. 
    def _print_buddy_info(self):
        ps = presenceservice.PresenceService()
        buddies = ps.get_buddies()
        for currBuddy in buddies:
            print '----------------------- ' + currBuddy.get_property('nick') + ': '
            print currBuddy.get_property('key')
            print currBuddy.get_property('color')
            print currBuddy.get_property('current-activity')
            print currBuddy.get_property('owner')
            print currBuddy.get_property('ip4-address')
            print ''