1 /*<private_header>*/ 2 /* 3 * util-internal.h - Headers for non-public telepathy-glib utility functions 4 * 5 * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/> 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 #ifndef __TP_UTIL_INTERNAL_H__ 23 #define __TP_UTIL_INTERNAL_H__ 24 25 #include "config.h" 26 27 #include <glib.h> 28 #include <gio/gio.h> 29 30 #include <telepathy-glib/channel-request.h> 31 #include <telepathy-glib/connection.h> 32 #include <telepathy-glib/contact.h> 33 34 GArray *_tp_quark_array_copy (const GQuark *quarks) G_GNUC_WARN_UNUSED_RESULT; 35 void _tp_quark_array_merge (GArray *array, const GQuark *quarks, gssize n); 36 void _tp_quark_array_merge_valist (GArray *array, 37 GQuark feature, 38 va_list var_args); 39 40 #ifdef HAVE_GIO_UNIX 41 GSocketAddress * _tp_create_temp_unix_socket (GSocketService *service, 42 gchar **tmpdir, 43 GError **error); 44 #endif /* HAVE_GIO_UNIX */ 45 46 GList * _tp_create_channel_request_list (TpSimpleClientFactory *factory, 47 GHashTable *request_props); 48 49 /* Copied from wocky/wocky-utils.h */ 50 51 gboolean _tp_enum_from_nick (GType enum_type, const gchar *nick, gint *value); 52 const gchar *_tp_enum_to_nick (GType enum_type, gint value); 53 const gchar *_tp_enum_to_nick_nonnull (GType enum_type, gint value); 54 55 #define _tp_implement_finish_void(source, tag) \ 56 if (g_simple_async_result_propagate_error (\ 57 G_SIMPLE_ASYNC_RESULT (result), error)) \ 58 return FALSE; \ 59 g_return_val_if_fail (g_simple_async_result_is_valid (result, \ 60 G_OBJECT(source), tag), \ 61 FALSE); \ 62 return TRUE; 63 64 #define _tp_implement_finish_copy_pointer(source, tag, copy_func, \ 65 out_param) \ 66 GSimpleAsyncResult *_simple; \ 67 _simple = (GSimpleAsyncResult *) result; \ 68 if (g_simple_async_result_propagate_error (_simple, error)) \ 69 return FALSE; \ 70 g_return_val_if_fail (g_simple_async_result_is_valid (result, \ 71 G_OBJECT (source), tag), \ 72 FALSE); \ 73 if (out_param != NULL) \ 74 *out_param = copy_func ( \ 75 g_simple_async_result_get_op_res_gpointer (_simple)); \ 76 return TRUE; 77 78 #define _tp_implement_finish_return_copy_pointer(source, tag, copy_func) \ 79 GSimpleAsyncResult *_simple; \ 80 _simple = (GSimpleAsyncResult *) result; \ 81 if (g_simple_async_result_propagate_error (_simple, error)) \ 82 return NULL; \ 83 g_return_val_if_fail (g_simple_async_result_is_valid (result, \ 84 G_OBJECT (source), tag), \ 85 NULL); \ 86 return copy_func (g_simple_async_result_get_op_res_gpointer (_simple)); 87 88 gboolean _tp_bind_connection_status_to_boolean (GBinding *binding, 89 const GValue *src_value, GValue *dest_value, gpointer user_data); 90 91 gboolean _tp_set_socket_address_type_and_access_control_type ( 92 GHashTable *supported_sockets, 93 TpSocketAddressType *address_type, 94 TpSocketAccessControl *access_control, 95 GError **error); 96 97 GSocket * _tp_create_client_socket (TpSocketAddressType socket_type, 98 GError **error); 99 100 gboolean _tp_contacts_to_handles (TpConnection *connection, 101 guint n_contacts, 102 TpContact * const *contacts, 103 GArray **handles); 104 105 GPtrArray *_tp_contacts_from_values (GHashTable *table); 106 107 GList *_tp_object_list_copy (GList *l); 108 void _tp_object_list_free (GList *l); 109 110 /* This can be removed once we depend on GLib 2.34 */ 111 GList *_tp_g_list_copy_deep (GList *list, 112 GCopyFunc func, 113 gpointer user_data); 114 115 #endif /* __TP_UTIL_INTERNAL_H__ */ 116