TpPresenceMixinInterface

TpPresenceMixinInterface — an interface that can be implemented on TpBaseConnection subclasses to add support for presence.

Functions

Types and Values

Object Hierarchy

    GBoxed
    ╰── TpPresenceStatusSpec

Includes

#include <telepathy-glib/telepathy-glib.h>

Description

TpBaseConnection subclasses can implement this interface to implement the corresponding DBus interface.

Functions

tp_presence_status_spec_can_set_on_self ()

gboolean
tp_presence_status_spec_can_set_on_self
                               (const TpPresenceStatusSpec *self);

Parameters

self

a presence status specification

 

Returns

TRUE if the user can set this presence status on themselves (most statuses), or FALSE if they cannot directly set it on themselves (typically used for TP_CONNECTION_PRESENCE_TYPE_OFFLINE and TP_CONNECTION_PRESENCE_TYPE_ERROR)

Since 0.99.5


tp_presence_status_spec_get_name ()

const gchar *
tp_presence_status_spec_get_name (const TpPresenceStatusSpec *self);

Parameters

self

a presence status specification

 

Returns

the name of this presence status, such as "available" or "out-to-lunch".

[transfer none]

Since 0.99.5


tp_presence_status_spec_get_presence_type ()

TpConnectionPresenceType
tp_presence_status_spec_get_presence_type
                               (const TpPresenceStatusSpec *self);

Return the category into which this presence type falls. For instance, for XMPP's "" (do not disturb) status, this would return TP_CONNECTION_PRESENCE_TYPE_BUSY.

Parameters

self

a presence status specification

 

Since 0.99.5


tp_presence_status_spec_has_message ()

gboolean
tp_presence_status_spec_has_message (const TpPresenceStatusSpec *self);

Parameters

self

a presence status specification

 

Returns

TRUE if this presence status is accompanied by an optional human-readable message

Since 0.99.5


tp_presence_status_spec_new ()

TpPresenceStatusSpec *
tp_presence_status_spec_new (const gchar *name,
                             TpConnectionPresenceType type,
                             gboolean can_set_on_self,
                             gboolean has_message);

Parameters

name

the name of the new presence status

 

type

the category into which this presence status falls

 

can_set_on_self

TRUE if the user can set this presence status on themselves

 

has_message

TRUE if this presence status is accompanied by an optional human-readable message

 

Returns

a new TpPresenceStatusSpec.

[transfer full]

Since 0.99.5


tp_presence_status_spec_copy ()

TpPresenceStatusSpec *
tp_presence_status_spec_copy (const TpPresenceStatusSpec *self);

Copy a presence status specification.

Parameters

self

a presence status specification

 

Returns

a new TpPresenceStatusSpec resembling self .

[transfer full]

Since 0.99.5


tp_presence_status_spec_free ()

void
tp_presence_status_spec_free (TpPresenceStatusSpec *self);

Free a presence status specification produced by tp_presence_status_spec_new() or tp_presence_status_spec_copy().

Parameters

self

a presence status specification.

[transfer full]

Since 0.99.5


TpPresenceMixinStatusAvailableFunc ()

gboolean
(*TpPresenceMixinStatusAvailableFunc) (TpPresenceMixin *self,
                                       guint which);

Signature of a callback to be used to determine if a given presence status can be set on the connection. Most users of this interface do not need to supply an implementation of this callback: the value of TpPresenceStatusSpec.self is enough to determine whether this is a user-settable presence.

One place where this callback may be needed is on XMPP: not all server implementation support the user becoming invisible. So an XMPP implementation would implement this function, so that—once connected—the hidden status is only available if the server supports it. Before the connection is connected, this callback should return TRUE for every status that might possibly be supported: this allows the user to at least try to sign in as invisible.

Parameters

self

A TpBaseConnection implementing TpPresenceMixinInterface

 

which

An index into the array of TpPresenceStatusSpec provided to tp_presence_mixin_class_init()

 

Returns

TRUE if the status can be set on this connection; FALSE if not.


TpPresenceMixinGetContactStatusFunc ()

TpPresenceStatus *
(*TpPresenceMixinGetContactStatusFunc)
                               (TpPresenceMixin *self,
                                TpHandle contact);

Return the contact's status

Parameters

self

A TpBaseConnection implementing TpPresenceMixinInterface

 

contact

A TpHandle of type TP_ENTITY_TYPE_CONTACT

 

Returns

The contact's presence status.

[transfer full]


TpPresenceMixinSetOwnStatusFunc ()

gboolean
(*TpPresenceMixinSetOwnStatusFunc) (TpPresenceMixin *self,
                                    const TpPresenceStatus *status,
                                    GError **error);

Signature of the callback used to commit changes to the user's own presence status in SetStatuses. It is also used in ClearStatus and RemoveStatus to reset the user's own status back to the "default" one with a NULL status argument.

The callback is responsible for emitting PresenceUpdate, if appropriate, by calling tp_presence_mixin_emit_presence_update().

Parameters

self

A TpBaseConnection implementing TpPresenceMixinInterface

 

status

The status to set, or NULL for whatever the protocol defines as a "default" status

 

error

Used to return a Telepathy D-Bus error if FALSE is returned

 

Returns

TRUE if the operation was successful, FALSE if not.


TpPresenceMixinGetMaximumStatusMessageLengthFunc ()

guint
(*TpPresenceMixinGetMaximumStatusMessageLengthFunc)
                               (TpPresenceMixin *self);

Signature of a callback used to determine the maximum length of status messages. If this callback is provided and returns non-zero, the TpPresenceMixinSetOwnStatusFunc implementation is responsible for truncating the message to fit this limit, if necessary.

Parameters

Returns

the maximum number of UTF-8 characters which may appear in a status message, or 0 if there is no limit.

Since 0.14.5


tp_presence_status_new ()

TpPresenceStatus *
tp_presence_status_new (guint which,
                        const gchar *message);

Construct a presence status structure. You should free the returned structure with tp_presence_status_free.

Parameters

which

Index of the presence status in the provided supported presence statuses array

 

message

a human-readable status message, or NULL.

[allow-none]

Returns

A pointer to the newly allocated presence status structure.


tp_presence_status_free ()

void
tp_presence_status_free (TpPresenceStatus *status);

Deallocate all resources associated with a presence status structure.

Parameters

status

A pointer to the presence status structure to free.

 

tp_presence_mixin_init ()

void
tp_presence_mixin_init (TpPresenceMixin *self);

Implement the Presence interface via this mixin. Call this from the GObjectClass.constructed function of a TpBaseConnection subclass that implements TpPresenceMixin.

Parameters

self

a TpBaseConnection that implements TpPresenceMixinInterface

 

tp_presence_mixin_fill_contact_attributes ()

gboolean
tp_presence_mixin_fill_contact_attributes
                               (TpPresenceMixin *self,
                                const gchar *dbus_interface,
                                TpHandle contact,
                                GVariantDict *attributes);

If this mixin implements dbus_interface , fill in the attributes for contact and return TRUE.

Typical usage is something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
static void
my_fill_contact_attributes (TpBaseConnection *base,
    ...)
{
  if (!tp_strdiff (dbus_interface, INTERFACE_THAT_I_IMPLEMENT))
    {
      // ... fill them in
      return;
    }
  // ... similar calls for any other interfaces

  if (tp_presence_mixin_fill_contact_attributes (base, ...))
    return;
  // ... similar calls for any other mixins

  TP_BASE_CONNECTION_CLASS (my_connection_parent_class)->
    fill_contact_attributes (base, ...);
}

Parameters

self

a connection that implements TpPresenceMixin

 

dbus_interface

the interface in which the client is interested

 

contact

a contact's handle

 

attributes

used to return the attributes of contact

 

Returns

TRUE if dbus_interface was handled


tp_presence_mixin_emit_presence_update ()

void
tp_presence_mixin_emit_presence_update
                               (TpPresenceMixin *self,
                                GHashTable *contact_presences);

Emit the PresenceUpdate signal for multiple contacts. For emitting PresenceUpdate for a single contact, there is a convenience wrapper called tp_presence_mixin_emit_one_presence_update.

Parameters

self

A TpBaseConnection implementing TpPresenceMixinInterface

 

contact_presences

A mapping of contact handles to TpPresenceStatus structures with the presence data to emit

 

tp_presence_mixin_emit_one_presence_update ()

void
tp_presence_mixin_emit_one_presence_update
                               (TpPresenceMixin *self,
                                TpHandle handle,
                                const TpPresenceStatus *status);

Emit a presence update signal for a single contact. This method is just a convenience wrapper around tp_presence_mixin_emit_presence_update().

Parameters

self

A TpBaseConnection implementing TpPresenceMixinInterface

 

handle

The handle of the contact to emit the signal for

 

status

The new status to emit

 

Types and Values

struct TpPresenceStatusSpec

struct TpPresenceStatusSpec {
    const gchar *name;
    TpConnectionPresenceType presence_type;
    gboolean self;
    gboolean has_message;
};

Structure specifying a supported presence status.

In addition to the fields documented here, there are some reserved fields which must currently be NULL. A meaning may be defined for these in a future version of telepathy-glib.

Members

const gchar *name;

String identifier of the presence status

 

TpConnectionPresenceType presence_type;

A type value, as specified by TpConnectionPresenceType

 

gboolean self;

Indicates if this status may be set on yourself

 

gboolean has_message;

TRUE if a human-readable message can accompany this status.

 

struct TpPresenceStatus

struct TpPresenceStatus {
    guint index;
    gchar *message;
};

Structure representing a presence status.

In addition to the fields documented here, there are some gpointer fields which must currently be NULL. A meaning may be defined for these in a future version of telepathy-glib.

Members

guint index;

Index of the presence status in the provided supported presence statuses array

 

gchar *message;

the non-NULL human-readable status message

 

struct TpPresenceMixinInterface

struct TpPresenceMixinInterface {
  GTypeInterface parent;

  TpPresenceMixinStatusAvailableFunc status_available;
  TpPresenceMixinGetContactStatusFunc get_contact_status;
  TpPresenceMixinSetOwnStatusFunc set_own_status;
  TpPresenceMixinGetMaximumStatusMessageLengthFunc
      get_maximum_status_message_length;

  const TpPresenceStatusSpec *statuses;
};

The interface vtable for a TP_TYPE_PRESENCE_MIXIN.

Members

GTypeInterface parent;

the parent interface

 

TpPresenceMixinStatusAvailableFunc status_available;

A callback to be used to determine if a given presence status can be set on a particular connection. Should usually be NULL, to consider all statuses with TpPresenceStatusSpec.self set to TRUE to be settable.

 

TpPresenceMixinGetContactStatusFunc get_contact_status;

A callback to be used get the current presence status for contacts. This is used in implementations of various D-Bus methods and hence must be provided.

 

TpPresenceMixinSetOwnStatusFunc set_own_status;

A callback to be used to commit changes to the user's own presence status to the server. This is used in implementations of various D-Bus methods and hence must be provided.

 

TpPresenceMixinGetMaximumStatusMessageLengthFunc get_maximum_status_message_length;

The callback used to discover the the limit for status messages length, if any.

 

const TpPresenceStatusSpec *statuses;

An array of TpPresenceStatusSpec structures representing all presence statuses supported by the protocol, terminated by a NULL name.