sugar.presence package

Submodules

sugar.presence.activity module

UI interface to an activity in the presence service

STABLE.

class sugar.presence.activity.Activity(*args: Any, **kwargs: Any)[source]

Bases: GObject

UI interface for an Activity in the presence service

Activities in the presence service represent your and other user’s shared activities.

Properties:

id color name type joined

__init__(account_path, connection, room_handle=None, properties=None)[source]
object_path()[source]

Get our dbus object path

do_get_property(pspec)[source]

Retrieve a particular property from our property dictionary

do_set_property(pspec, val)[source]

Set a particular property in our property dictionary

set_private(val, reply_handler, error_handler)[source]
get_joined_buddies()[source]

Retrieve the set of Buddy objects attached to this activity

returns list of presence Buddy objects that we can successfully create from the buddy object paths that PS has for this activity.

get_buddy_by_handle(handle)[source]

Retrieve the Buddy object given a telepathy handle.

buddy object paths are cached in self._handle_to_buddy_path, so we can get the buddy without calling PS.

invite(buddy, message, response_cb)[source]

Invite the given buddy to join this activity.

The callback will be called with one parameter: None on success, or an exception on failure.

set_up_tubes(reply_handler, error_handler)[source]
join()[source]

Join this activity.

Emits ‘joined’ and otherwise does nothing if we’re already joined.

share(share_activity_cb, share_activity_error_cb)[source]
get_channels()[source]

Retrieve communications channel descriptions for the activity

Returns a tuple containing:
  • the D-Bus well-known service name of the connection (FIXME: this is redundant; in Telepathy it can be derived from that of the connection)

  • the D-Bus object path of the connection

  • a list of D-Bus object paths representing the channels associated with this activity

leave()[source]

Leave this shared activity

sugar.presence.buddy module

UI interface to a buddy in the presence service

STABLE.

class sugar.presence.buddy.BaseBuddy(*args: Any, **kwargs: Any)[source]

Bases: GObject

UI interface for a Buddy in the presence service

Each buddy interface tracks a set of activities and properties that can be queried to provide UI controls for manipulating the presence interface.

Properties Dictionary:

‘key’: public key, ‘nick’: nickname , ‘color’: color (XXX what format), ‘current-activity’: (XXX dbus path?), ‘owner’: (XXX dbus path?),

__init__()[source]
get_key()[source]
set_key(key)[source]
get_nick()[source]
set_nick(nick)[source]
get_color()[source]
set_color(color)[source]
get_current_activity()[source]
get_owner()[source]
set_owner(owner)[source]
get_ip4_address()[source]
set_ip4_address(ip4_address)[source]
get_tags()[source]
set_tags(tags)[source]
object_path()[source]

Retrieve our dbus object path

class sugar.presence.buddy.Buddy(*args: Any, **kwargs: Any)[source]

Bases: BaseBuddy

__init__(account_path, contact_id)[source]
do_get_property(pspec)[source]
class sugar.presence.buddy.Owner(*args: Any, **kwargs: Any)[source]

Bases: BaseBuddy

__init__()[source]

sugar.presence.connectionmanager module

UNSTABLE. It should really be internal to the sugar.presence package.

class sugar.presence.connectionmanager.Connection(account_path, connection)[source]

Bases: object

__init__(account_path, connection)[source]
class sugar.presence.connectionmanager.ConnectionManager[source]

Bases: object

Track available telepathy connections

__init__()[source]
get_preferred_connection()[source]
get_connection(account_path)[source]
get_connections_per_account()[source]
get_account_for_connection(connection_path)[source]
sugar.presence.connectionmanager.get_connection_manager()[source]

sugar.presence.presenceservice module

STABLE.

class sugar.presence.presenceservice.PresenceService(*args: Any, **kwargs: Any)[source]

Bases: GObject

Provides simplified access to the Telepathy framework to activities

__init__()[source]

Initialise the service and attempt to connect to events

get_activity(activity_id, warn_if_none=True)[source]

Retrieve single Activity object for the given unique id

activity_id – unique ID for the activity

returns single Activity object or None if the activity

is not found using GetActivityById on the service

get_activity_by_handle(connection_path, room_handle)[source]
get_buddy(account_path, contact_id)[source]
get_buddy_by_telepathy_handle(tp_conn_name, tp_conn_path, handle)[source]

Retrieve single Buddy object for the given public key

Parameters:
tp_conn_namestr

The well-known bus name of a Telepathy connection

tp_conn_pathdbus.ObjectPath

The object path of the Telepathy connection

handleint or long

The handle of a Telepathy contact on that connection, of type HANDLE_TYPE_CONTACT. This may not be a channel-specific handle.

Returns:

the Buddy object, or None if the buddy is not found

get_owner()[source]

Retrieves the laptop Buddy object.

share_activity(activity, properties=None, private=True)[source]
get_preferred_connection()[source]

Gets the preferred telepathy connection object that an activity should use when talking directly to telepathy

returns the bus name and the object path of the Telepathy connection

get(object_path)[source]
get_activities()[source]
get_activities_async(reply_handler=None, error_handler=None)[source]
get_buddies()[source]
get_buddies_async(reply_handler=None, error_handler=None)[source]
sugar.presence.presenceservice.get_instance(allow_offline_iface=False)[source]

Retrieve this process’ view of the PresenceService

sugar.presence.sugartubeconn module

Subclass of TubeConnection that converts handles to Sugar Buddies

STABLE.

class sugar.presence.sugartubeconn.SugarTubeConnection(conn, tubes_iface, tube_id, address=None, group_iface=None, mainloop=None)[source]

Bases: TubeConnection

Subclass of TubeConnection that converts handles to Sugar Buddies

get_buddy(cs_handle)[source]

Retrieve a Buddy object given a telepathy handle.

cs_handle: A channel-specific CONTACT type handle. returns: sugar.presence Buddy object or None

sugar.presence.tubeconn module

STABLE.

class sugar.presence.tubeconn.TubeConnection(conn, tubes_iface, tube_id, address=None, group_iface=None, mainloop=None)[source]

Bases: Connection

close()[source]
watch_participants(callback)[source]

Module contents

Client-code’s interface to the PresenceService

Provides a simplified API for accessing the dbus service which coordinates native network presence and sharing information. This includes both “buddies” and “shared activities”.