From 267fb729f0536843bcb7c42858bd3d6a6d029411 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Tue, 1 Feb 2011 08:41:24 +0000 Subject: utils: add the _finish macros from wocky Signed-off-by: Jonny Lamb --- libempathy/empathy-utils.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'libempathy') diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h index 3c89962c1..f0ac666ed 100644 --- a/libempathy/empathy-utils.h +++ b/libempathy/empathy-utils.h @@ -107,6 +107,51 @@ gboolean empathy_connection_can_group_personas (TpConnection *connection); gchar * empathy_get_x509_certificate_hostname (gnutls_x509_crt_t cert); +/* Copied from wocky/wocky-utils.h */ + +#define empathy_implement_finish_void(source, tag) \ + if (g_simple_async_result_propagate_error (\ + G_SIMPLE_ASYNC_RESULT (result), error)) \ + return FALSE; \ + g_return_val_if_fail (g_simple_async_result_is_valid (result, \ + G_OBJECT(source), tag), \ + FALSE); \ + return TRUE; + +#define empathy_implement_finish_copy_pointer(source, tag, copy_func, \ + out_param) \ + GSimpleAsyncResult *_simple; \ + _simple = (GSimpleAsyncResult *) result; \ + if (g_simple_async_result_propagate_error (_simple, error)) \ + return FALSE; \ + g_return_val_if_fail (g_simple_async_result_is_valid (result, \ + G_OBJECT (source), tag), \ + FALSE); \ + if (out_param != NULL) \ + *out_param = copy_func ( \ + g_simple_async_result_get_op_res_gpointer (_simple)); \ + return TRUE; + +#define empathy_implement_finish_return_copy_pointer(source, tag, copy_func) \ + GSimpleAsyncResult *_simple; \ + _simple = (GSimpleAsyncResult *) result; \ + if (g_simple_async_result_propagate_error (_simple, error)) \ + return NULL; \ + g_return_val_if_fail (g_simple_async_result_is_valid (result, \ + G_OBJECT (source), tag), \ + NULL); \ + return copy_func (g_simple_async_result_get_op_res_gpointer (_simple)); + +#define empathy_implement_finish_return_pointer(source, tag) \ + GSimpleAsyncResult *_simple; \ + _simple = (GSimpleAsyncResult *) result; \ + if (g_simple_async_result_propagate_error (_simple, error)) \ + return NULL; \ + g_return_val_if_fail (g_simple_async_result_is_valid (result, \ + G_OBJECT (source), tag), \ + NULL); \ + return g_simple_async_result_get_op_res_gpointer (_simple); + G_END_DECLS #endif /* __EMPATHY_UTILS_H__ */ -- cgit v1.2.3