/* * Copyright (C) 2003-2007 Imendio AB * Copyright (C) 2007-2011 Collabora Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA * * Authors: Richard Hult * Martyn Russell * Xavier Claessens */ #ifndef __EMPATHY_UTILS_H__ #define __EMPATHY_UTILS_H__ #include #include #include #define EMPATHY_GET_PRIV(obj,type) ((type##Priv *) ((type *) obj)->priv) #define EMP_STR_EMPTY(x) ((x) == NULL || (x)[0] == '\0') /* 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); #endif /* __EMPATHY_UTILS_H__ */