telepathy-glib Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties |
#include <telepathy-glib/contact.h> TpContact; enum TpContactFeature; void (*TpConnectionContactsByHandleCb) (TpConnection *connection
,guint n_contacts
,TpContact * const *contacts
,guint n_failed
,const TpHandle *failed
,const GError *error
,gpointer user_data
,GObject *weak_object
); void tp_connection_get_contacts_by_handle (TpConnection *self
,guint n_handles
,const TpHandle *handles
,guint n_features
,const TpContactFeature *features
,TpConnectionContactsByHandleCb callback
,gpointer user_data
,GDestroyNotify destroy
,GObject *weak_object
); void (*TpConnectionContactsByIdCb) (TpConnection *connection
,guint n_contacts
,TpContact * const *contacts
,const gchar * const *requested_ids
,GHashTable *failed_id_errors
,const GError *error
,gpointer user_data
,GObject *weak_object
); void tp_connection_get_contacts_by_id (TpConnection *self
,guint n_ids
,const gchar * const *ids
,guint n_features
,const TpContactFeature *features
,TpConnectionContactsByIdCb callback
,gpointer user_data
,GDestroyNotify destroy
,GObject *weak_object
); void (*TpConnectionUpgradeContactsCb) (TpConnection *connection
,guint n_contacts
,TpContact * const *contacts
,const GError *error
,gpointer user_data
,GObject *weak_object
); void tp_connection_upgrade_contacts (TpConnection *self
,guint n_contacts
,TpContact * const *contacts
,guint n_features
,const TpContactFeature *features
,TpConnectionUpgradeContactsCb callback
,gpointer user_data
,GDestroyNotify destroy
,GObject *weak_object
); const gchar * tp_contact_get_alias (TpContact *self
); const gchar * tp_contact_get_avatar_token (TpContact *self
); TpConnection * tp_contact_get_connection (TpContact *self
); TpHandle tp_contact_get_handle (TpContact *self
); const gchar * tp_contact_get_identifier (TpContact *self
); const gchar * tp_contact_get_presence_message (TpContact *self
); const gchar * tp_contact_get_presence_status (TpContact *self
); TpConnectionPresenceType tp_contact_get_presence_type (TpContact *self
); gboolean tp_contact_has_feature (TpContact *self
,TpContactFeature feature
);
"alias" gchar* : Read "avatar-token" gchar* : Read "connection" TpConnection* : Read "handle" guint : Read "identifier" gchar* : Read "presence-message" gchar* : Read "presence-status" gchar* : Read "presence-type" guint : Read
typedef struct _TpContact TpContact;
An object representing a contact on a TpConnection.
Contact objects support tracking a number of attributes of contacts, as
described by the TpContactFeature flags. Features can be specified when
instantiating contact objects (with tp_connection_get_contacts_by_id()
or
tp_connection_get_contacts_by_handle()
), or added to an existing contact
object with tp_connection_upgrade_contacts()
. For example, a client wishing
to keep track of a contact's alias would set TP_CONTACT_FEATURE_ALIAS, and
then listen for the "notify::alias" signal, emitted whenever the
"alias" property changes.
Note that releasing a TpContact object might release handle references
held by calling tp_cli_connection_call_request_handles()
,
tp_cli_connection_run_request_handles()
,
tp_cli_connection_call_hold_handles()
,
tp_cli_connection_run_hold_handles()
,
tp_cli_connection_interface_contacts_call_get_contact_attributes()
or
tp_cli_connection_interface_contacts_run_get_contact_attributes()
directly.
Those functions should be avoided in favour of using TpContact,
tp_connection_hold_handles()
, tp_connection_request_handles()
and
tp_connection_get_contact_attributes()
.
Since 0.7.18
typedef enum { TP_CONTACT_FEATURE_ALIAS, TP_CONTACT_FEATURE_AVATAR_TOKEN, TP_CONTACT_FEATURE_PRESENCE, NUM_TP_CONTACT_FEATURES } TpContactFeature;
Enumeration representing the features a TpContact can optionally support. When requesting a TpContact, library users specify the desired features; the TpContact code will only initialize state for those features, to avoid unwanted D-Bus round-trips and signal connections.
"alias" | |
"avatar-token" | |
"presence-type", "presence-status" and "presence-message" | |
1 higher than the highest TpContactFeature supported by this version of telepathy-glib |
Since 0.7.18
void (*TpConnectionContactsByHandleCb) (TpConnection *connection
,guint n_contacts
,TpContact * const *contacts
,guint n_failed
,const TpHandle *failed
,const GError *error
,gpointer user_data
,GObject *weak_object
);
Signature of a callback used to receive the result of
tp_connection_get_contacts_by_handle()
.
If an unrecoverable error occurs (for instance, if connection
becomes disconnected) the whole operation fails, and no contacts or
invalid handles are returned.
If some or even all of the handles
passed to
tp_connection_get_contacts_by_handle()
were not valid, this is not
considered to be a failure. error
will be NULL
in this situation,
contacts
will contain contact objects for those handles that were
valid (possibly none of them), and invalid
will contain the handles
that were not valid.
|
The connection |
|
The number of TpContact objects successfully created (one per valid handle), or 0 on unrecoverable errors |
|
An array of n_contacts TpContact objects (this callback is
not given a reference to any of these objects, and must call g_object_ref()
on any that it will keep), or NULL on unrecoverable errors
|
|
The number of invalid handles that were passed to
tp_connection_get_contacts_by_handle() (or on unrecoverable errors,
the total number of handles that were given)
|
|
An array of n_failed handles that were passed to
tp_connection_get_contacts_by_handle() but turned out to be invalid
(or on unrecoverable errors, all the handles that were given)
|
|
NULL on success, or an unrecoverable error that caused everything
to fail
|
|
the user_data that was passed to
tp_connection_get_contacts_by_handle()
|
|
the weak_object that was passed to
tp_connection_get_contacts_by_handle()
|
Since 0.7.18
void tp_connection_get_contacts_by_handle (TpConnection *self
,guint n_handles
,const TpHandle *handles
,guint n_features
,const TpContactFeature *features
,TpConnectionContactsByHandleCb callback
,gpointer user_data
,GDestroyNotify destroy
,GObject *weak_object
);
Create a number of TpContact objects and make asynchronous method calls
to hold their handles and ensure that all the features specified in
features
are ready for use (if they are supported at all).
It is not an error to put features in features
even if the connection
manager doesn't support them - users of this method should have a static
list of features they would like to use if possible, and use it for all
connection managers.
|
A connection, which must be ready ("connection-ready"
must be TRUE )
|
|
The number of handles in handles (must be at least 1)
|
|
An array of handles of type TP_HANDLE_TYPE_CONTACT representing
the desired contacts
|
|
The number of features in features (may be 0)
|
|
An array of features that must be ready for use (if supported)
before the callback is called (may be NULL if n_features is 0)
|
|
A user callback to call when the contacts are ready |
|
Data to pass to the callback |
|
Called to destroy user_data either after callback has been
called, or if the operation is cancelled
|
|
An object to pass to the callback, which will be weakly referenced; if this object is destroyed, the operation will be cancelled |
Since 0.7.18
void (*TpConnectionContactsByIdCb) (TpConnection *connection
,guint n_contacts
,TpContact * const *contacts
,const gchar * const *requested_ids
,GHashTable *failed_id_errors
,const GError *error
,gpointer user_data
,GObject *weak_object
);
Signature of a callback used to receive the result of
tp_connection_get_contacts_by_id()
.
requested_ids
contains the IDs that were converted to handles successfully.
The normalized form of requested_ids[i] is
tp_contact_get_identifier (contacts[i]).
If some or even all of the ids
passed to
tp_connection_get_contacts_by_id()
were not valid, this is not
considered to be a fatal error. error
will be NULL
in this situation,
contacts
will contain contact objects for those IDs that were
valid (it may be empty), and failed_id_errors
will map the IDs
that were not valid to a corresponding GError (if the connection manager
complies with the Telepathy spec, it will have domain TP_ERRORS
and code
TP_ERROR_INVALID_HANDLE
).
If an unrecoverable error occurs (for instance, if connection
becomes disconnected) the whole operation fails, and no contacts
or requested IDs are returned. failed_id_errors
will contain all the IDs
that were requested, mapped to a corresponding GError (either one
indicating that the ID was invalid, if that was determined before the
fatal error occurred, or a copy of error
).
|
The connection |
|
The number of TpContact objects successfully created (one per valid ID), or 0 on unrecoverable errors |
|
An array of n_contacts TpContact objects (this callback is
not given a reference to any of these objects, and must call
g_object_ref() on any that it will keep), or NULL on unrecoverable errors
|
|
An array of n_contacts valid IDs (JIDs, SIP URIs etc.)
that were passed to tp_connection_get_contacts_by_id() , in an order
corresponding to contacts , or NULL on unrecoverable errors
|
|
A hash table in which the keys are IDs and the values are errors (GError) |
|
NULL on success, or an unrecoverable error that caused everything
to fail
|
|
the user_data that was passed to
tp_connection_get_contacts_by_id()
|
|
the weak_object that was passed to
tp_connection_get_contacts_by_id()
|
Since 0.7.18
void tp_connection_get_contacts_by_id (TpConnection *self
,guint n_ids
,const gchar * const *ids
,guint n_features
,const TpContactFeature *features
,TpConnectionContactsByIdCb callback
,gpointer user_data
,GDestroyNotify destroy
,GObject *weak_object
);
Create a number of TpContact objects and make asynchronous method calls
to obtain their handles and ensure that all the features specified in
features
are ready for use (if they are supported at all).
It is not an error to put features in features
even if the connection
manager doesn't support them - users of this method should have a static
list of features they would like to use if possible, and use it for all
connection managers.
|
A connection, which must be ready ("connection-ready"
must be TRUE )
|
|
The number of IDs in ids (must be at least 1)
|
|
An array of strings representing the desired contacts by their identifiers in the IM protocol (XMPP JIDs, SIP URIs, MSN Passports, AOL screen-names etc.) |
|
The number of features in features (may be 0)
|
|
An array of features that must be ready for use (if supported)
before the callback is called (may be NULL if n_features is 0)
|
|
A user callback to call when the contacts are ready |
|
Data to pass to the callback |
|
Called to destroy user_data either after callback has been
called, or if the operation is cancelled
|
|
An object to pass to the callback, which will be weakly referenced; if this object is destroyed, the operation will be cancelled |
Since 0.7.18
void (*TpConnectionUpgradeContactsCb) (TpConnection *connection
,guint n_contacts
,TpContact * const *contacts
,const GError *error
,gpointer user_data
,GObject *weak_object
);
Signature of a callback used to receive the result of
tp_connection_upgrade_contacts()
.
If an unrecoverable error occurs (for instance, if connection
becomes
disconnected) it is indicated by error
, but the contacts in contacts
are still provided.
|
The connection |
|
The number of TpContact objects for which an upgrade was requested |
|
An array of n_contacts TpContact objects (this callback is
not given an extra reference to any of these objects, and must call
g_object_ref() on any that it will keep)
|
|
An unrecoverable error, or NULL if the connection remains valid
|
|
the user_data that was passed to
tp_connection_upgrade_contacts()
|
|
the weak_object that was passed to
tp_connection_upgrade_contacts()
|
Since 0.7.18
void tp_connection_upgrade_contacts (TpConnection *self
,guint n_contacts
,TpContact * const *contacts
,guint n_features
,const TpContactFeature *features
,TpConnectionUpgradeContactsCb callback
,gpointer user_data
,GDestroyNotify destroy
,GObject *weak_object
);
Given several TpContact objects, make asynchronous method calls
ensure that all the features specified in features
are ready for use
(if they are supported at all).
It is not an error to put features in features
even if the connection
manager doesn't support them - users of this method should have a static
list of features they would like to use if possible, and use it for all
connection managers.
|
A connection, which must be ready ("connection-ready"
must be TRUE )
|
|
The number of contacts in contacts (must be at least 1)
|
|
An array of TpContact objects associated with self
|
|
The number of features in features (must be at least 1)
|
|
An array of features that must be ready for use (if supported) before the callback is called |
|
A user callback to call when the contacts are ready |
|
Data to pass to the callback |
|
Called to destroy user_data either after callback has been
called, or if the operation is cancelled
|
|
An object to pass to the callback, which will be weakly referenced; if this object is destroyed, the operation will be cancelled |
Since 0.7.18
const gchar * tp_contact_get_alias (TpContact *self
);
Return the contact's alias. This remains valid until the main loop
is re-entered; if the caller requires a string that will persist for
longer than that, it must be copied with g_strdup()
.
Since 0.7.18
const gchar * tp_contact_get_avatar_token (TpContact *self
);
Return the contact's avatar token. This remains valid until the main loop
is re-entered; if the caller requires a string that will persist for
longer than that, it must be copied with g_strdup()
.
|
a contact |
Returns : |
the same token as the "avatar-token" property
(possibly NULL )
|
Since 0.7.18
TpConnection * tp_contact_get_connection (TpContact *self
);
|
a contact |
Returns : |
a borrowed reference to the "connection" (it must be referenced with g_object_ref if it must remain valid longer than the contact) |
Since 0.7.18
TpHandle tp_contact_get_handle (TpContact *self
);
Return the contact's handle, which is of type TP_HANDLE_TYPE_CONTACT
,
or 0 if the "connection" has become invalid.
This handle is referenced using the Telepathy D-Bus API and remains
referenced for as long as self
exists and the
"connection" remains valid.
However, the caller of this function does not gain an additional reference to the handle.
|
a contact |
Returns : |
the same handle as the "handle" property |
Since 0.7.18
const gchar * tp_contact_get_identifier (TpContact *self
);
Return the contact's identifier. This remains valid for as long as self
exists; if the caller requires a string that will persist for longer than
that, it must be copied with g_strdup()
.
|
a contact |
Returns : |
the same non-NULL identifier as the "identifier" property
|
Since 0.7.18
const gchar * tp_contact_get_presence_message (TpContact *self
);
Return the contact's user-defined status message, or an empty string.
This remains valid until the main loop is re-entered; if the caller
requires a string that will persist for longer than that, it must be
copied with g_strdup()
.
|
a contact |
Returns : |
the same non-NULL message as the "presence-message"
property
|
Since 0.7.18
const gchar * tp_contact_get_presence_status (TpContact *self
);
Return the name of the contact's presence status, or an empty string.
This remains valid until the main loop is re-entered; if the caller
requires a string that will persist for longer than that, it must be
copied with g_strdup()
.
|
a contact |
Returns : |
the same non-NULL status name as the "presence-status"
property
|
Since 0.7.18
TpConnectionPresenceType tp_contact_get_presence_type (TpContact *self
);
If this object has been set up to track TP_CONTACT_FEATURE_PRESENCE
and the underlying connection supports either the Presence or
SimplePresence interfaces, return the type of the contact's presence.
Otherwise, return TP_CONNECTION_PRESENCE_TYPE_UNSET
.
|
a contact |
Returns : |
the same presence type as the "presence-type" property |
Since 0.7.18
gboolean tp_contact_has_feature (TpContact *self
,TpContactFeature feature
);
|
a contact |
|
a desired feature |
Returns : |
TRUE if self has been set up to track the feature feature
|
Since 0.7.18
"alias"
property"alias" gchar* : Read
The contact's alias if available, falling back to their
"identifier" if no alias is available or if the TpContact has
not been set up to track TP_CONTACT_FEATURE_ALIAS
. This is never NULL
.
This alias may have been supplied by the contact themselves, or by the local user, so it does not necessarily unambiguously identify the contact. However, it is suitable for use as a main "display name" for the contact.
Default value: NULL
"avatar-token"
property"avatar-token" gchar* : Read
An opaque string representing state of the contact's avatar (depending on the protocol, this might be a hash, a timestamp or something else), or an empty string if there is no avatar.
This may be NULL
if it is not known whether this contact has an avatar
or not (either for network protocol reasons, or because this TpContact
has not been set up to track TP_CONTACT_FEATURE_AVATAR_TOKEN
).
Default value: NULL
"connection"
property"connection" TpConnection* : Read
The TpConnection to which this contact belongs.
"handle"
property"handle" guint : Read
The contact's handle in the Telepathy D-Bus API, a handle of type
TP_HANDLE_TYPE_CONTACT
representing the string
given by "identifier".
This handle is referenced using the Telepathy D-Bus API and remains referenced for as long as the TpContact exists and the "connection" remains valid.
However, getting this property does not cause an additional reference to the handle to be held.
If the "connection" becomes invalid, this property is no longer meaningful and will be set to 0.
Default value: 0
"identifier"
property"identifier" gchar* : Read
The contact's identifier in the instant messaging protocol (e.g.
XMPP JID, SIP URI, AOL screenname or IRC nick - whatever the underlying
protocol uses to identify a user). This is never NULL
.
Default value: NULL
"presence-message"
property"presence-message" gchar* : Read
If this contact has set a user-defined status message, that message; if not, an empty string (which user interfaces may replace with a localized form of the "presence-status" or "presence-type").
This may be an empty string even if the contact has set a message,
if this TpContact object has not been set up to track
TP_CONTACT_FEATURE_PRESENCE
. It is never NULL
.
Default value: NULL
"presence-status"
property"presence-status" gchar* : Read
A string representing the presence status of this contact. This may be a well-known string from the Telepathy specification, like "available", or a connection-manager-specific string, like "out-to-lunch".
This may be an empty string if this TpContact object has not been set up
to track TP_CONTACT_FEATURE_PRESENCE
. It is never NULL
.
Default value: NULL
"presence-type"
property"presence-type" guint : Read
The TpConnectionPresenceType representing the type of presence status for this contact.
This is provided so even unknown values for "presence-status" can be classified into their fundamental types.
This may be TP_CONNECTION_PRESENCE_TYPE_UNSET
if this TpContact
has not been set up to track TP_CONTACT_FEATURE_PRESENCE
.
Default value: 0