## TpContactsMixin

TpContactsMixin — a mixin implementation of the contacts connection interface

## Functions

void | tp_contacts_mixin_add_contact_attributes_iface ()
void | tp_contacts_mixin_class_init ()
void | tp_contacts_mixin_finalize ()
void | tp_contacts_mixin_iface_init ()
void | tp_contacts_mixin_init ()
void | tp_contacts_mixin_set_contact_attribute ()
GHashTable * | tp_contacts_mixin_get_contact_attributes ()
void | (*TpContactsMixinFillContactAttributesFunc) ()

## Types and Values

struct | TpContactsMixin
struct | TpContactsMixinClass

## Includes

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

## Description

This mixin can be added to a TpBaseConnection subclass to implement the Contacts interface in a generic way.

To use the contacts mixin, include a TpContactsMixinClass somewhere in your class structure and a TpContactsMixin somewhere in your instance structure, and call `tp_contacts_mixin_class_init()` from your class_init function, `tp_contacts_mixin_init()` from your init function or constructor, and `tp_contacts_mixin_finalize()` from your dispose or finalize function.

To use the contacts mixin as the implementation of TpSvcConnectionInterfaceContacts, in the function you pass to G_IMPLEMENT_INTERFACE, you should call tp_contacts_mixin_iface_init. TpContactsMixin implements all of the D-Bus methods and properties in the Contacts interface.

To add interfaces with contact attributes to this interface use tp_contacts_mixin_add_contact_attributes_iface:

## Functions

### tp_contacts_mixin_add_contact_attributes_iface ()

    void
    tp_contacts_mixin_add_contact_attributes_iface
                                   (GObject *obj,
                                    const gchar *interface,
                                    TpContactsMixinFillContactAttributesFunc fill_contact_attributes);

Declare that the given interface has contact attributes which can be added to the attributes hash using the filler function. All the handles in the handle array passed to the filler function are guaranteed to be valid and referenced.

[skip]

#### Parameters

obj | An instance of the implementation that uses this mixin |
interface | Name of the interface that has ContactAttributes |
fill_contact_attributes | Contact attribute filler function |

Since: 0.7.14

### tp_contacts_mixin_class_init ()

    void
    tp_contacts_mixin_class_init (GObjectClass *obj_cls,
                                  glong offset);

Initialize the contacts mixin. Should be called from the implementation's class_init function like so:

    1
    2

    tp_contacts_mixin_class_init ((GObjectClass *) klass,
                             G_STRUCT_OFFSET (SomeObjectClass, contacts_mixin));

[skip]

#### Parameters

obj_cls | The class of the implementation that uses this mixin |
offset | The byte offset of the TpContactsMixinClass within the class structure |

Since: 0.7.14

### tp_contacts_mixin_finalize ()

    void
    tp_contacts_mixin_finalize (GObject *obj);

Free resources held by the contacts mixin.

[skip]

#### Parameters

obj | An object with this mixin. |

Since: 0.7.14

### tp_contacts_mixin_iface_init ()

    void
    tp_contacts_mixin_iface_init (gpointer g_iface,
                                  gpointer iface_data);

Fill in the vtable entries needed to implement the contacts interface using this mixin. This function should usually be called via G_IMPLEMENT_INTERFACE.

[skip]

#### Parameters

g_iface | A pointer to the TpSvcConnectionInterfaceContacts in an object class |
iface_data | Ignored |

Since: 0.7.14

### tp_contacts_mixin_init ()

    void
    tp_contacts_mixin_init (GObject *obj,
                            gsize offset);

Initialize the contacts mixin. Should be called from the implementation's instance init function like so:

    1
    2

    tp_contacts_mixin_init ((GObject *) self,
                        G_STRUCT_OFFSET (SomeObject, contacts_mixin));

[skip]

#### Parameters

obj | An instance of the implementation that uses this mixin |
offset | The byte offset of the TpContactsMixin within the object structure |

Since: 0.7.14

### tp_contacts_mixin_set_contact_attribute ()

    void
    tp_contacts_mixin_set_contact_attribute
                                   (GHashTable *contact_attributes,
                                    TpHandle handle,
                                    const gchar *attribute,
                                    GValue *value);

Utility function to set attribute for handle to value in the attributes hash as passed to a TpContactsMixinFillContactAttributesFunc.

[skip]

#### Parameters

contact_attributes | contacts attribute hash as passed to TpContactsMixinFillContactAttributesFunc |
handle | Handle to set the attribute on |
attribute | attribute name |
value | slice allocated GValue containing the value of the attribute, for instance with tp_g_value_slice_new. Ownership of the GValue is taken over by the mixin |

Since: 0.7.14

### tp_contacts_mixin_get_contact_attributes ()

    GHashTable *
    tp_contacts_mixin_get_contact_attributes
                                   (GObject *obj,
                                    const GArray *handles,
                                    const gchar **interfaces,
                                    const gchar **assumed_interfaces,
                                    const gchar *sender);

Get contact attributes for the given contacts. Provide attributes for all requested interfaces. If contact attributes are not immediately known, the behaviour is defined by the interface; the attribute should either be omitted from the result or replaced with a default value.

[skip]

#### Parameters

obj | A connection instance that uses this mixin. The connection must be connected. |
handles | List of handles to retrieve contacts for. Any invalid handles will be dropped from the returned mapping. |
interfaces | A list of interfaces to retrieve attributes from. |
assumed_interfaces | A list of additional interfaces to retrieve attributes from. This can be used for interfaces documented as automatically included, like `TP_IFACE_CONNECTION` for GetContactAttributes, or `TP_IFACE_CONNECTION` and `TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST` for GetContactListAttributes. |
sender | The DBus client's unique name. If this is not NULL, the requested handles will be held on behalf of this client. |

#### Returns

A dictionary mapping the contact handles to contact attributes.

### TpContactsMixinFillContactAttributesFunc ()

    void
    (*TpContactsMixinFillContactAttributesFunc)
                                   (GObject *obj,
                                    const GArray *contacts,
                                    GHashTable *attributes_hash);

This function is called to supply contact attributes pertaining to a particular interface, for a list of contacts. All the handles in `contacts` are guaranteed to be valid and referenced.

#### Parameters

obj | An object implementing the Contacts interface with this mixin |
contacts | The contact handles for which attributes are requested |
attributes_hash | hash of handle => hash of attributes, containing all the contacts in the contacts array |

## Types and Values

### struct TpContactsMixin

    struct TpContactsMixin {
    };

Structure to be included in the instance structure of objects that use this mixin. Initialize it with `tp_contacts_mixin_init()`.

There are no public fields.

### struct TpContactsMixinClass

    struct TpContactsMixinClass {
    };

Structure to be included in the class structure of objects that use this mixin. Initialize it with `tp_contacts_mixin_class_init()`.

There are no public fields.

## See Also

TpSvcConnectionInterfaceContacts