1 /* Object representing a Telepathy contact
2  *
3  * Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
4  * Copyright (C) 2008 Nokia Corporation
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20 
21 #if defined (TP_DISABLE_SINGLE_INCLUDE) && !defined (_TP_IN_META_HEADER) && !defined (_TP_COMPILATION)
22 #error "Only <telepathy-glib/telepathy-glib.h> and <telepathy-glib/telepathy-glib-dbus.h> can be included directly."
23 #endif
24 
25 #ifndef __TP_CONTACT_H__
26 #define __TP_CONTACT_H__
27 
28 #include <glib-object.h>
29 #include <gio/gio.h>
30 
31 #include <telepathy-glib/capabilities.h>
32 #include <telepathy-glib/connection.h>
33 #include <telepathy-glib/defs.h>
34 #include <telepathy-glib/handle.h>
35 
36 #include <telepathy-glib/_gen/genums.h>
37 
38 G_BEGIN_DECLS
39 
40 /* TpContact is forward-declared in connection.h */
41 typedef struct _TpContactClass TpContactClass;
42 typedef struct _TpContactPrivate TpContactPrivate;
43 
44 GType tp_contact_get_type (void) G_GNUC_CONST;
45 
46 #define TP_TYPE_CONTACT \
47   (tp_contact_get_type ())
48 #define TP_CONTACT(obj) \
49   (G_TYPE_CHECK_INSTANCE_CAST ((obj), TP_TYPE_CONTACT, \
50                                TpContact))
51 #define TP_CONTACT_CLASS(klass) \
52   (G_TYPE_CHECK_CLASS_CAST ((klass), TP_TYPE_CONTACT, \
53                             TpContactClass))
54 #define TP_IS_CONTACT(obj) \
55   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TP_TYPE_CONTACT))
56 #define TP_IS_CONTACT_CLASS(klass) \
57   (G_TYPE_CHECK_CLASS_TYPE ((klass), TP_TYPE_CONTACT))
58 #define TP_CONTACT_GET_CLASS(obj) \
59   (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_CONTACT, \
60                               TpContactClass))
61 
62 typedef enum {
63     TP_CONTACT_FEATURE_ALIAS,
64     TP_CONTACT_FEATURE_AVATAR_TOKEN,
65     TP_CONTACT_FEATURE_PRESENCE,
66     TP_CONTACT_FEATURE_LOCATION,
67     TP_CONTACT_FEATURE_CAPABILITIES,
68     TP_CONTACT_FEATURE_AVATAR_DATA,
69     TP_CONTACT_FEATURE_CONTACT_INFO,
70     TP_CONTACT_FEATURE_CLIENT_TYPES,
71     TP_CONTACT_FEATURE_SUBSCRIPTION_STATES,
72     TP_CONTACT_FEATURE_CONTACT_GROUPS,
73     TP_CONTACT_FEATURE_CONTACT_BLOCKING,
74 } TpContactFeature;
75 #define TP_NUM_CONTACT_FEATURES (TP_CONTACT_FEATURE_CONTACT_BLOCKING + 1)
76 #define NUM_TP_CONTACT_FEATURES TP_NUM_CONTACT_FEATURES
77 #define TP_CONTACT_FEATURE_INVALID ((TpContactFeature) -1)
78 
79 /* Basic functionality, always available */
80 _TP_AVAILABLE_IN_0_20
81 TpAccount *tp_contact_get_account (TpContact *self);
82 TpConnection *tp_contact_get_connection (TpContact *self);
83 TpHandle tp_contact_get_handle (TpContact *self);
84 const gchar *tp_contact_get_identifier (TpContact *self);
85 gboolean tp_contact_has_feature (TpContact *self, TpContactFeature feature);
86 
87 /* TP_CONTACT_FEATURE_ALIAS */
88 const gchar *tp_contact_get_alias (TpContact *self);
89 
90 /* TP_CONTACT_FEATURE_AVATAR_TOKEN */
91 const gchar *tp_contact_get_avatar_token (TpContact *self);
92 
93 /* TP_CONTACT_FEATURE_PRESENCE */
94 TpConnectionPresenceType tp_contact_get_presence_type (TpContact *self);
95 const gchar *tp_contact_get_presence_status (TpContact *self);
96 const gchar *tp_contact_get_presence_message (TpContact *self);
97 
98 /* TP_CONTACT_FEATURE_LOCATION */
99 GHashTable *tp_contact_get_location (TpContact *self);
100 _TP_AVAILABLE_IN_0_20
101 GVariant *tp_contact_dup_location (TpContact *self);
102 
103 /* TP_CONTACT_FEATURE_CAPABILITIES */
104 TpCapabilities *tp_contact_get_capabilities (TpContact *self);
105 
106 /* TP_CONTACT_FEATURE_AVATAR_DATA */
107 GFile *tp_contact_get_avatar_file (TpContact *self);
108 const gchar *tp_contact_get_avatar_mime_type (TpContact *self);
109 
110 /* TP_CONTACT_FEATURE_INFO */
111 #ifndef TP_DISABLE_DEPRECATED
112 _TP_DEPRECATED_IN_0_20_FOR (tp_contact_dup_contact_info)
113 GList *tp_contact_get_contact_info (TpContact *self);
114 #endif
115 
116 _TP_AVAILABLE_IN_0_20
117 GList *tp_contact_dup_contact_info (TpContact *self);
118 
119 void tp_contact_request_contact_info_async (TpContact *self,
120     GCancellable *cancellable, GAsyncReadyCallback callback,
121     gpointer user_data);
122 
123 gboolean tp_contact_request_contact_info_finish (TpContact *self,
124     GAsyncResult *result, GError **error);
125 
126 void tp_connection_refresh_contact_info (TpConnection *self,
127     guint n_contacts, TpContact * const *contacts);
128 
129 /* TP_CONTACT_FEATURE_CLIENT_TYPES */
130 const gchar * const *
131 /* this comment stops gtkdoc denying that this function exists */
132 tp_contact_get_client_types (TpContact *self);
133 
134 /* TP_CONTACT_FEATURE_SUBSCRIPTION_STATES */
135 TpSubscriptionState tp_contact_get_subscribe_state (TpContact *self);
136 TpSubscriptionState tp_contact_get_publish_state (TpContact *self);
137 const gchar *tp_contact_get_publish_request (TpContact *self);
138 
139 /* TP_CONTACT_FEATURE_CONTACT_GROUPS */
140 const gchar * const *
141 /* this comment stops gtkdoc denying that this function exists */
142 tp_contact_get_contact_groups (TpContact *self);
143 void tp_contact_set_contact_groups_async (TpContact *self,
144     gint n_groups, const gchar * const *groups, GAsyncReadyCallback callback,
145     gpointer user_data);
146 gboolean tp_contact_set_contact_groups_finish (TpContact *self,
147     GAsyncResult *result, GError **error);
148 
149 #ifndef TP_DISABLE_DEPRECATED
150 typedef void (*TpConnectionContactsByHandleCb) (TpConnection *connection,
151     guint n_contacts, TpContact * const *contacts,
152     guint n_failed, const TpHandle *failed,
153     const GError *error, gpointer user_data, GObject *weak_object);
154 
155 _TP_DEPRECATED_IN_0_20
156 void tp_connection_get_contacts_by_handle (TpConnection *self,
157     guint n_handles, const TpHandle *handles,
158     guint n_features, const TpContactFeature *features,
159     TpConnectionContactsByHandleCb callback,
160     gpointer user_data, GDestroyNotify destroy, GObject *weak_object);
161 
162 typedef void (*TpConnectionUpgradeContactsCb) (TpConnection *connection,
163     guint n_contacts, TpContact * const *contacts,
164     const GError *error, gpointer user_data, GObject *weak_object);
165 
166 _TP_DEPRECATED_IN_0_20_FOR(tp_connection_upgrade_contacts_async)
167 void tp_connection_upgrade_contacts (TpConnection *self,
168     guint n_contacts, TpContact * const *contacts,
169     guint n_features, const TpContactFeature *features,
170     TpConnectionUpgradeContactsCb callback,
171     gpointer user_data, GDestroyNotify destroy, GObject *weak_object);
172 
173 typedef void (*TpConnectionContactsByIdCb) (TpConnection *connection,
174     guint n_contacts, TpContact * const *contacts,
175     const gchar * const *requested_ids, GHashTable *failed_id_errors,
176     const GError *error, gpointer user_data, GObject *weak_object);
177 
178 _TP_DEPRECATED_IN_0_20_FOR(tp_connection_dup_contact_by_id_async)
179 void tp_connection_get_contacts_by_id (TpConnection *self,
180     guint n_ids, const gchar * const *ids,
181     guint n_features, const TpContactFeature *features,
182     TpConnectionContactsByIdCb callback,
183     gpointer user_data, GDestroyNotify destroy, GObject *weak_object);
184 #endif
185 
186 TpContact *tp_connection_dup_contact_if_possible (TpConnection *connection,
187     TpHandle handle, const gchar *identifier);
188 
189 _TP_AVAILABLE_IN_0_20
190 void tp_connection_dup_contact_by_id_async (TpConnection *self,
191     const gchar *id,
192     guint n_features,
193     const TpContactFeature *features,
194     GAsyncReadyCallback callback,
195     gpointer user_data);
196 _TP_AVAILABLE_IN_0_20
197 TpContact *tp_connection_dup_contact_by_id_finish (TpConnection *self,
198     GAsyncResult *result,
199     GError **error);
200 
201 _TP_AVAILABLE_IN_0_20
202 void tp_connection_upgrade_contacts_async (TpConnection *self,
203     guint n_contacts,
204     TpContact * const *contacts,
205     guint n_features,
206     const TpContactFeature *features,
207     GAsyncReadyCallback callback,
208     gpointer user_data);
209 _TP_AVAILABLE_IN_0_20
210 gboolean tp_connection_upgrade_contacts_finish (TpConnection *self,
211     GAsyncResult *result,
212     GPtrArray **contacts,
213     GError **error);
214 
215 /* TP_CONTACT_FEATURE_CONTACT_BLOCKING */
216 
217 _TP_AVAILABLE_IN_0_18
218 gboolean tp_contact_is_blocked (TpContact *self);
219 
220 G_END_DECLS
221 
222 #endif
223