diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-05-21 12:34:41 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-05-26 12:35:22 +0200 |
commit | 7b032fb01100f08efc3beb4ef2a4591262a398a8 (patch) | |
tree | ca10dd918b8b2641f5baadb245399b2185c69c28 | |
parent | f34ec7df6a34724ce178ff779d06d024b4fc5e3f (diff) | |
download | telepathy-logger-7b032fb01100f08efc3beb4ef2a4591262a398a8.tar.gz |
fix tpl_log_manager_get_dates_finish signature and implementation
We need to return a boolean to indicate if the call succeed or not. Returning
NULL in case of failure is wrong as an empty list is represented with NULL as
well.
-rw-r--r-- | telepathy-logger/dbus-service.c | 5 | ||||
-rw-r--r-- | telepathy-logger/log-manager.c | 22 | ||||
-rw-r--r-- | telepathy-logger/log-manager.h | 3 | ||||
-rw-r--r-- | tests/test-searches.c | 10 |
4 files changed, 27 insertions, 13 deletions
diff --git a/telepathy-logger/dbus-service.c b/telepathy-logger/dbus-service.c index a168884..b2f6b7a 100644 --- a/telepathy-logger/dbus-service.c +++ b/telepathy-logger/dbus-service.c @@ -475,9 +475,8 @@ _get_dates_return (GObject *manager, RecentMessagesContext *ctx = user_data; GError *error = NULL; - ctx->dates = tpl_log_manager_get_dates_finish (TPL_LOG_MANAGER (manager), res, - &error); - if (ctx->dates == NULL) + if (!tpl_log_manager_get_dates_finish (TPL_LOG_MANAGER (manager), res, + &ctx->dates, &error)) { DEBUG ("Failed to get dates: %s", error->message); diff --git a/telepathy-logger/log-manager.c b/telepathy-logger/log-manager.c index 224b0e1..ec0d3c1 100644 --- a/telepathy-logger/log-manager.c +++ b/telepathy-logger/log-manager.c @@ -859,17 +859,29 @@ _tpl_log_manager_add_message_async (TplLogManager *manager, /* Start of get_dates async implementation */ -GList * +gboolean tpl_log_manager_get_dates_finish (TplLogManager *self, GAsyncResult *result, + GList **dates, GError **error) { - g_return_val_if_fail (error == NULL || *error == NULL, NULL); + GSimpleAsyncResult *simple; - GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); - return g_simple_async_result_get_op_res_gpointer (simple); -} + g_return_val_if_fail (TPL_IS_LOG_MANAGER (self), FALSE); + g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE); + g_return_val_if_fail (g_simple_async_result_is_valid (result, + G_OBJECT (self), tpl_log_manager_get_dates_async), FALSE); + + simple = G_SIMPLE_ASYNC_RESULT (result); + if (g_simple_async_result_propagate_error (simple, error)) + return FALSE; + + if (dates != NULL) + *dates = g_simple_async_result_get_op_res_gpointer (simple); + + return TRUE; +} static void _get_dates_async_result_free (gpointer data) diff --git a/telepathy-logger/log-manager.h b/telepathy-logger/log-manager.h index 348eacc..8e576fe 100644 --- a/telepathy-logger/log-manager.h +++ b/telepathy-logger/log-manager.h @@ -85,8 +85,9 @@ gboolean tpl_log_manager_exists (TplLogManager *manager, GList *tpl_log_manager_get_dates (TplLogManager *manager, TpAccount *account, const gchar *chat_id, gboolean chatroom); -GList *tpl_log_manager_get_dates_finish (TplLogManager *self, +gboolean tpl_log_manager_get_dates_finish (TplLogManager *self, GAsyncResult *result, + GList **dates, GError **error); void tpl_log_manager_get_dates_async (TplLogManager *manager, diff --git a/tests/test-searches.c b/tests/test-searches.c index 7ff7e7f..71ef43a 100644 --- a/tests/test-searches.c +++ b/tests/test-searches.c @@ -13,8 +13,12 @@ static GMainLoop *loop = NULL; static void got_dates_cb (GObject *obj, GAsyncResult *result, gpointer user_data) { - GList *ret = tpl_log_manager_get_dates_finish (TPL_LOG_MANAGER (obj), result, - NULL); + GList *ret; + GError *error = NULL; + + tpl_log_manager_get_dates_finish (TPL_LOG_MANAGER (obj), result, &ret, + &error); + g_assert_no_error (error); for (; ret != NULL; ret = g_list_next (ret)) { @@ -26,8 +30,6 @@ got_dates_cb (GObject *obj, GAsyncResult *result, gpointer user_data) g_main_loop_quit (loop); } - - int main (int argc, char *argv[]) { |