1 /* 2 * connection.h - proxy for a Telepathy connection 3 * 4 * Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/> 5 * Copyright (C) 2007 Nokia Corporation 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #if defined (TP_DISABLE_SINGLE_INCLUDE) && !defined (_TP_IN_META_HEADER) && !defined (_TP_COMPILATION) 23 #error "Only <telepathy-glib/telepathy-glib.h> and <telepathy-glib/telepathy-glib-dbus.h> can be included directly." 24 #endif 25 26 #ifndef __TP_CONNECTION_H__ 27 #define __TP_CONNECTION_H__ 28 29 #include <telepathy-glib/capabilities.h> 30 #include <telepathy-glib/defs.h> 31 #include <telepathy-glib/enums.h> 32 #include <telepathy-glib/handle.h> 33 #include <telepathy-glib/proxy.h> 34 35 G_BEGIN_DECLS 36 37 typedef struct _TpContactInfoFieldSpec TpContactInfoFieldSpec; 38 struct _TpContactInfoFieldSpec 39 { 40 /*<public>*/ 41 gchar *name; 42 GStrv parameters; 43 TpContactInfoFieldFlags flags; 44 guint max; 45 /*<private>*/ 46 gpointer priv; 47 }; 48 49 #define TP_TYPE_CONTACT_INFO_FIELD_SPEC (tp_contact_info_field_spec_get_type ()) 50 GType tp_contact_info_field_spec_get_type (void); 51 TpContactInfoFieldSpec *tp_contact_info_field_spec_copy ( 52 const TpContactInfoFieldSpec *self); 53 void tp_contact_info_field_spec_free (TpContactInfoFieldSpec *self); 54 55 #ifndef __GI_SCANNER__ 56 /* the typedef only exists for G_DEFINE_BOXED_TYPE's benefit, and 57 * g-ir-scanner 1.32.1 doesn't parse a skip annotation */ 58 typedef GList TpContactInfoSpecList; 59 #endif 60 61 #define TP_TYPE_CONTACT_INFO_SPEC_LIST (tp_contact_info_spec_list_get_type ()) 62 GType tp_contact_info_spec_list_get_type (void); 63 GList *tp_contact_info_spec_list_copy (GList *list); 64 void tp_contact_info_spec_list_free (GList *list); 65 66 typedef struct _TpContactInfoField TpContactInfoField; 67 struct _TpContactInfoField 68 { 69 /*<public>*/ 70 gchar *field_name; 71 GStrv parameters; 72 GStrv field_value; 73 /*<private>*/ 74 gpointer priv; 75 }; 76 77 #define TP_TYPE_CONTACT_INFO_FIELD (tp_contact_info_field_get_type ()) 78 GType tp_contact_info_field_get_type (void); 79 TpContactInfoField *tp_contact_info_field_new (const gchar *field_name, 80 GStrv parameters, GStrv field_value); 81 TpContactInfoField *tp_contact_info_field_copy (const TpContactInfoField *self); 82 void tp_contact_info_field_free (TpContactInfoField *self); 83 84 #ifndef __GI_SCANNER__ 85 /* the typedef only exists for G_DEFINE_BOXED_TYPE's benefit, and 86 * g-ir-scanner 1.32.1 doesn't parse a skip annotation */ 87 typedef GList TpContactInfoList; 88 #endif 89 90 #define TP_TYPE_CONTACT_INFO_LIST (tp_contact_info_list_get_type ()) 91 GType tp_contact_info_list_get_type (void); 92 GList *tp_contact_info_list_copy (GList *list); 93 void tp_contact_info_list_free (GList *list); 94 95 /* forward declaration, see contact.h for the rest */ 96 typedef struct _TpContact TpContact; 97 /* forward declaration, see account.h for the rest */ 98 typedef struct _TpAccount TpAccount; 99 100 typedef struct _TpConnection TpConnection; 101 typedef struct _TpConnectionPrivate TpConnectionPrivate; 102 typedef struct _TpConnectionClass TpConnectionClass; 103 104 struct _TpConnectionClass { 105 TpProxyClass parent_class; 106 /*<private>*/ 107 GCallback _1; 108 GCallback _2; 109 GCallback _3; 110 GCallback _4; 111 }; 112 113 struct _TpConnection { 114 /*<private>*/ 115 TpProxy parent; 116 TpConnectionPrivate *priv; 117 }; 118 119 GType tp_connection_get_type (void); 120 121 #define TP_ERRORS_DISCONNECTED (tp_errors_disconnected_quark ()) 122 GQuark tp_errors_disconnected_quark (void); 123 124 #define TP_UNKNOWN_CONNECTION_STATUS ((TpConnectionStatus) -1) 125 126 /* TYPE MACROS */ 127 #define TP_TYPE_CONNECTION \ 128 (tp_connection_get_type ()) 129 #define TP_CONNECTION(obj) \ 130 (G_TYPE_CHECK_INSTANCE_CAST((obj), TP_TYPE_CONNECTION, \ 131 TpConnection)) 132 #define TP_CONNECTION_CLASS(klass) \ 133 (G_TYPE_CHECK_CLASS_CAST((klass), TP_TYPE_CONNECTION, \ 134 TpConnectionClass)) 135 #define TP_IS_CONNECTION(obj) \ 136 (G_TYPE_CHECK_INSTANCE_TYPE((obj), TP_TYPE_CONNECTION)) 137 #define TP_IS_CONNECTION_CLASS(klass) \ 138 (G_TYPE_CHECK_CLASS_TYPE((klass), TP_TYPE_CONNECTION)) 139 #define TP_CONNECTION_GET_CLASS(obj) \ 140 (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_CONNECTION, \ 141 TpConnectionClass)) 142 143 _TP_DEPRECATED_IN_0_20_FOR(tp_simple_client_factory_ensure_connection) 144 TpConnection *tp_connection_new (TpDBusDaemon *dbus, const gchar *bus_name, 145 const gchar *object_path, GError **error) G_GNUC_WARN_UNUSED_RESULT; 146 147 _TP_AVAILABLE_IN_0_16 148 TpAccount *tp_connection_get_account (TpConnection *self); 149 150 TpConnectionStatus tp_connection_get_status (TpConnection *self, 151 TpConnectionStatusReason *reason); 152 153 #ifndef TP_DISABLE_DEPRECATED 154 _TP_DEPRECATED_IN_0_20_FOR (tp_connection_get_cm_name) 155 const gchar *tp_connection_get_connection_manager_name (TpConnection *self); 156 #endif 157 158 _TP_AVAILABLE_IN_0_20 159 const gchar *tp_connection_get_cm_name (TpConnection *self); 160 161 const gchar *tp_connection_get_protocol_name (TpConnection *self); 162 163 #ifndef TP_DISABLE_DEPRECATED 164 _TP_DEPRECATED_IN_0_20_FOR (tp_connection_get_self_contact) 165 TpHandle tp_connection_get_self_handle (TpConnection *self); 166 #endif 167 168 TpContact *tp_connection_get_self_contact (TpConnection *self); 169 170 TpCapabilities * tp_connection_get_capabilities (TpConnection *self); 171 172 TpContactInfoFlags tp_connection_get_contact_info_flags (TpConnection *self); 173 174 #ifndef TP_DISABLE_DEPRECATED 175 _TP_DEPRECATED_IN_0_20_FOR (tp_connection_dup_contact_info_supported_fields) 176 GList *tp_connection_get_contact_info_supported_fields (TpConnection *self); 177 #endif 178 179 _TP_AVAILABLE_IN_0_20 180 GList *tp_connection_dup_contact_info_supported_fields (TpConnection *self); 181 182 void tp_connection_set_contact_info_async (TpConnection *self, 183 GList *info, GAsyncReadyCallback callback, 184 gpointer user_data); 185 186 gboolean tp_connection_set_contact_info_finish (TpConnection *self, 187 GAsyncResult *result, GError **error); 188 189 #ifndef TP_DISABLE_DEPRECATED 190 _TP_DEPRECATED_IN_0_18_FOR (tp_proxy_is_prepared) 191 gboolean tp_connection_is_ready (TpConnection *self); 192 193 _TP_DEPRECATED_IN_0_18 194 gboolean tp_connection_run_until_ready (TpConnection *self, 195 gboolean connect, GError **error, 196 GMainLoop **loop); 197 198 typedef void (*TpConnectionWhenReadyCb) (TpConnection *connection, 199 const GError *error, gpointer user_data); 200 201 _TP_DEPRECATED_IN_0_18_FOR (tp_proxy_prepare_async) 202 void tp_connection_call_when_ready (TpConnection *self, 203 TpConnectionWhenReadyCb callback, 204 gpointer user_data); 205 #endif 206 207 typedef void (*TpConnectionNameListCb) (const gchar * const *names, 208 gsize n, const gchar * const *cms, const gchar * const *protocols, 209 const GError *error, gpointer user_data, 210 GObject *weak_object); 211 212 void tp_list_connection_names (TpDBusDaemon *bus_daemon, 213 TpConnectionNameListCb callback, 214 gpointer user_data, GDestroyNotify destroy, 215 GObject *weak_object); 216 217 void tp_connection_init_known_interfaces (void); 218 219 gint tp_connection_presence_type_cmp_availability (TpConnectionPresenceType p1, 220 TpConnectionPresenceType p2); 221 222 #ifndef TP_DISABLE_DEPRECATED 223 _TP_DEPRECATED_IN_0_20_FOR(tp_connection_get_protocol_name) 224 gboolean tp_connection_parse_object_path (TpConnection *self, gchar **protocol, 225 gchar **cm_name); 226 #endif 227 228 _TP_AVAILABLE_IN_0_20 229 const gchar *tp_connection_get_detailed_error (TpConnection *self, 230 const GHashTable **details); 231 _TP_AVAILABLE_IN_0_20 232 gchar *tp_connection_dup_detailed_error_vardict (TpConnection *self, 233 GVariant **details) G_GNUC_WARN_UNUSED_RESULT; 234 235 236 void tp_connection_add_client_interest (TpConnection *self, 237 const gchar *interested_in); 238 239 void tp_connection_add_client_interest_by_id (TpConnection *self, 240 GQuark interested_in); 241 242 gboolean tp_connection_has_immortal_handles (TpConnection *self); 243 244 #define TP_CONNECTION_FEATURE_CORE \ 245 (tp_connection_get_feature_quark_core ()) 246 GQuark tp_connection_get_feature_quark_core (void) G_GNUC_CONST; 247 248 #define TP_CONNECTION_FEATURE_CONNECTED \ 249 (tp_connection_get_feature_quark_connected ()) 250 GQuark tp_connection_get_feature_quark_connected (void) G_GNUC_CONST; 251 252 #define TP_CONNECTION_FEATURE_CAPABILITIES \ 253 (tp_connection_get_feature_quark_capabilities ()) 254 GQuark tp_connection_get_feature_quark_capabilities (void) G_GNUC_CONST; 255 256 #define TP_CONNECTION_FEATURE_CONTACT_INFO \ 257 (tp_connection_get_feature_quark_contact_info ()) 258 GQuark tp_connection_get_feature_quark_contact_info (void) G_GNUC_CONST; 259 260 /* connection-handles.c */ 261 262 #ifndef TP_DISABLE_DEPRECATED 263 typedef void (*TpConnectionHoldHandlesCb) (TpConnection *connection, 264 TpHandleType handle_type, guint n_handles, const TpHandle *handles, 265 const GError *error, gpointer user_data, GObject *weak_object); 266 267 _TP_DEPRECATED_IN_0_20 268 void tp_connection_hold_handles (TpConnection *self, gint timeout_ms, 269 TpHandleType handle_type, guint n_handles, const TpHandle *handles, 270 TpConnectionHoldHandlesCb callback, 271 gpointer user_data, GDestroyNotify destroy, GObject *weak_object); 272 273 typedef void (*TpConnectionRequestHandlesCb) (TpConnection *connection, 274 TpHandleType handle_type, 275 guint n_handles, const TpHandle *handles, const gchar * const *ids, 276 const GError *error, gpointer user_data, GObject *weak_object); 277 278 _TP_DEPRECATED_IN_0_20 279 void tp_connection_request_handles (TpConnection *self, gint timeout_ms, 280 TpHandleType handle_type, const gchar * const *ids, 281 TpConnectionRequestHandlesCb callback, 282 gpointer user_data, GDestroyNotify destroy, GObject *weak_object); 283 284 _TP_DEPRECATED_IN_0_20 285 void tp_connection_unref_handles (TpConnection *self, 286 TpHandleType handle_type, guint n_handles, const TpHandle *handles); 287 #endif 288 289 /* connection-avatars.c */ 290 291 typedef struct _TpAvatarRequirements TpAvatarRequirements; 292 struct _TpAvatarRequirements 293 { 294 /*<public>*/ 295 GStrv supported_mime_types; 296 guint minimum_width; 297 guint minimum_height; 298 guint recommended_width; 299 guint recommended_height; 300 guint maximum_width; 301 guint maximum_height; 302 guint maximum_bytes; 303 304 /*<private>*/ 305 gpointer _1; 306 gpointer _2; 307 gpointer _3; 308 gpointer _4; 309 }; 310 311 #define TP_TYPE_AVATAR_REQUIREMENTS (tp_avatar_requirements_get_type ()) 312 GType tp_avatar_requirements_get_type (void); 313 TpAvatarRequirements * tp_avatar_requirements_new (GStrv supported_mime_types, 314 guint minimum_width, 315 guint minimum_height, 316 guint recommended_width, 317 guint recommended_height, 318 guint maximum_width, 319 guint maximum_height, 320 guint maximum_bytes); 321 TpAvatarRequirements * tp_avatar_requirements_copy ( 322 const TpAvatarRequirements *self); 323 void tp_avatar_requirements_destroy (TpAvatarRequirements *self); 324 325 #define TP_CONNECTION_FEATURE_AVATAR_REQUIREMENTS \ 326 (tp_connection_get_feature_quark_avatar_requirements ()) 327 GQuark tp_connection_get_feature_quark_avatar_requirements (void) G_GNUC_CONST; 328 329 TpAvatarRequirements * tp_connection_get_avatar_requirements ( 330 TpConnection *self); 331 332 #define TP_CONNECTION_FEATURE_ALIASING \ 333 (tp_connection_get_feature_quark_aliasing ()) 334 _TP_AVAILABLE_IN_0_18 335 GQuark tp_connection_get_feature_quark_aliasing (void) G_GNUC_CONST; 336 337 _TP_AVAILABLE_IN_0_18 338 gboolean tp_connection_can_set_contact_alias (TpConnection *self); 339 340 #define TP_CONNECTION_FEATURE_BALANCE \ 341 (tp_connection_get_feature_quark_balance ()) 342 _TP_AVAILABLE_IN_0_16 343 GQuark tp_connection_get_feature_quark_balance (void) G_GNUC_CONST; 344 345 _TP_AVAILABLE_IN_0_16 346 gboolean tp_connection_get_balance (TpConnection *self, 347 gint *balance, guint *scale, const gchar **currency); 348 _TP_AVAILABLE_IN_0_16 349 const gchar * tp_connection_get_balance_uri (TpConnection *self); 350 351 _TP_AVAILABLE_IN_0_18 352 void tp_connection_disconnect_async (TpConnection *self, 353 GAsyncReadyCallback callback, 354 gpointer user_data); 355 _TP_AVAILABLE_IN_0_18 356 gboolean tp_connection_disconnect_finish (TpConnection *self, 357 GAsyncResult *result, 358 GError **error); 359 360 G_END_DECLS 361 362 #include <telepathy-glib/_gen/tp-cli-connection.h> 363 364 G_BEGIN_DECLS 365 366 /* connection-handles.c again - this has to come after the auto-generated 367 * stuff because it uses an auto-generated typedef */ 368 369 #ifndef TP_DISABLE_DEPRECATED 370 _TP_DEPRECATED_IN_0_20_FOR(tp_simple_client_factory_ensure_contact) 371 void tp_connection_get_contact_attributes (TpConnection *self, 372 gint timeout_ms, guint n_handles, const TpHandle *handles, 373 const gchar * const *interfaces, gboolean hold, 374 tp_cli_connection_interface_contacts_callback_for_get_contact_attributes callback, 375 gpointer user_data, GDestroyNotify destroy, GObject *weak_object); 376 377 _TP_DEPRECATED_IN_0_20_FOR(tp_connection_dup_contact_list) 378 void tp_connection_get_contact_list_attributes (TpConnection *self, 379 gint timeout_ms, const gchar * const *interfaces, gboolean hold, 380 tp_cli_connection_interface_contacts_callback_for_get_contact_attributes callback, 381 gpointer user_data, GDestroyNotify destroy, GObject *weak_object); 382 #endif 383 384 GBinding *tp_connection_bind_connection_status_to_property (TpConnection *self, 385 gpointer target, const char *target_property, gboolean invert); 386 387 G_END_DECLS 388 389 #endif 390