[telepathy-glib/master] account{, -manager}: assert if the GSimpleAsyncResult is not valid

Jonny Lamb jonny.lamb at collabora.co.uk
Sat Sep 26 03:58:03 PDT 2009


Also, make sure we do this after propagating any error, as
_report_error_in_idle doesn't allow one to pass a source_tag.

Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
 telepathy-glib/account-manager.c |   17 ++++-
 telepathy-glib/account.c         |  120 +++++++++++++++++++++++++-------------
 2 files changed, 92 insertions(+), 45 deletions(-)

diff --git a/telepathy-glib/account-manager.c b/telepathy-glib/account-manager.c
index fe07551..ac7228a 100644
--- a/telepathy-glib/account-manager.c
+++ b/telepathy-glib/account-manager.c
@@ -1224,8 +1224,12 @@ tp_account_manager_create_account_finish (TpAccountManager *manager,
     GError **error)
 {
   TpAccount *retval;
+  GSimpleAsyncResult *simple;
 
   g_return_val_if_fail (TP_IS_ACCOUNT_MANAGER (manager), NULL);
+  g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
+
+  simple = G_SIMPLE_ASYNC_RESULT (result);
 
   if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
           error))
@@ -1357,14 +1361,19 @@ tp_account_manager_prepare_finish (TpAccountManager *manager,
     GAsyncResult *result,
     GError **error)
 {
+  GSimpleAsyncResult *simple;
+
   g_return_val_if_fail (TP_IS_ACCOUNT_MANAGER (manager), FALSE);
+  g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
 
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
-          error) ||
-      !g_simple_async_result_is_valid (result, G_OBJECT (manager),
-          tp_account_manager_prepare_finish))
+  simple = G_SIMPLE_ASYNC_RESULT (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 (manager),tp_account_manager_prepare_finish), FALSE);
+
   return TRUE;
 }
 
diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c
index fab49da..6ebf361 100644
--- a/telepathy-glib/account.c
+++ b/telepathy-glib/account.c
@@ -1644,15 +1644,19 @@ tp_account_set_enabled_finish (TpAccount *account,
     GAsyncResult *result,
     GError **error)
 {
+  GSimpleAsyncResult *simple;
+
   g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE);
   g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
 
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
-          error) ||
-      !g_simple_async_result_is_valid (result, G_OBJECT (account),
-          tp_account_set_enabled_finish))
+  simple = G_SIMPLE_ASYNC_RESULT (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 (account), tp_account_set_enabled_finish), FALSE);
+
   return TRUE;
 }
 
@@ -1732,15 +1736,19 @@ tp_account_reconnect_finish (TpAccount *account,
     GAsyncResult *result,
     GError **error)
 {
+  GSimpleAsyncResult *simple;
+
   g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE);
   g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
 
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
-          error) ||
-      !g_simple_async_result_is_valid (result, G_OBJECT (account),
-          tp_account_reconnect_finish))
+  simple = G_SIMPLE_ASYNC_RESULT (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 (account), tp_account_reconnect_finish), FALSE);
+
   return TRUE;
 }
 
@@ -1789,15 +1797,19 @@ tp_account_request_presence_finish (TpAccount *account,
     GAsyncResult *result,
     GError **error)
 {
+  GSimpleAsyncResult *simple;
+
   g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE);
   g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
 
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
-          error) ||
-      !g_simple_async_result_is_valid (result, G_OBJECT (account),
-          tp_account_request_presence_finish))
+  simple = G_SIMPLE_ASYNC_RESULT (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 (account), tp_account_request_presence_finish), FALSE);
+
   return TRUE;
 }
 
@@ -1929,12 +1941,11 @@ tp_account_update_parameters_finish (TpAccount *account,
 
   simple = G_SIMPLE_ASYNC_RESULT (result);
 
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
-      error))
+  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 (account), tp_account_update_parameters_finish), FALSE);
+          G_OBJECT (account), tp_account_update_parameters_finish), FALSE);
 
   if (reconnect_required != NULL)
     *reconnect_required =
@@ -2004,15 +2015,19 @@ tp_account_set_display_name_finish (TpAccount *account,
     GAsyncResult *result,
     GError **error)
 {
+  GSimpleAsyncResult *simple;
+
   g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE);
   g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
 
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
-          error) ||
-      !g_simple_async_result_is_valid (result, G_OBJECT (account),
-          tp_account_set_display_name_finish))
+  simple = G_SIMPLE_ASYNC_RESULT (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 (account), tp_account_set_display_name_finish), FALSE);
+
   return TRUE;
 }
 
@@ -2076,15 +2091,19 @@ tp_account_set_icon_name_finish (TpAccount *account,
     GAsyncResult *result,
     GError **error)
 {
+  GSimpleAsyncResult *simple;
+
   g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE);
   g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
 
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
-          error) ||
-      !g_simple_async_result_is_valid (result, G_OBJECT (account),
-          tp_account_set_icon_name_finish))
+  simple = G_SIMPLE_ASYNC_RESULT (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 (account), tp_account_set_icon_name_finish), FALSE);
+
   return TRUE;
 }
 
@@ -2148,11 +2167,14 @@ tp_account_remove_finish (TpAccount *account,
     GAsyncResult *result,
     GError **error)
 {
+  GSimpleAsyncResult *simple;
+
   g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE);
   g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
 
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
-          error))
+  simple = G_SIMPLE_ASYNC_RESULT (result);
+
+  if (g_simple_async_result_propagate_error (simple, error))
     return FALSE;
 
   g_return_val_if_fail (g_simple_async_result_is_valid (result,
@@ -2232,15 +2254,19 @@ tp_account_set_connect_automatically_finish (TpAccount *account,
     GAsyncResult *result,
     GError **error)
 {
+  GSimpleAsyncResult *simple;
+
   g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE);
   g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
 
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
-          error) ||
-      !g_simple_async_result_is_valid (result, G_OBJECT (account),
-          tp_account_set_connect_automatically_finish))
+  simple = G_SIMPLE_ASYNC_RESULT (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 (account), tp_account_set_connect_automatically_finish), FALSE);
+
   return TRUE;
 }
 
@@ -2386,15 +2412,19 @@ tp_account_set_nickname_finish (TpAccount *account,
     GAsyncResult *result,
     GError **error)
 {
+  GSimpleAsyncResult *simple;
+
   g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE);
   g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
 
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
-          error) ||
-      !g_simple_async_result_is_valid (result, G_OBJECT (account),
-          tp_account_set_nickname_finish))
+  simple = G_SIMPLE_ASYNC_RESULT (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 (account), tp_account_set_nickname_finish), FALSE);
+
   return TRUE;
 }
 
@@ -2517,15 +2547,19 @@ tp_account_get_avatar_finish (TpAccount *account,
     GAsyncResult *result,
     GError **error)
 {
+  GSimpleAsyncResult *simple;
+
   g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE);
   g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
 
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
-          error) ||
-      !g_simple_async_result_is_valid (result, G_OBJECT (account),
-          tp_account_get_avatar_finish))
+  simple = G_SIMPLE_ASYNC_RESULT (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 (account), tp_account_get_avatar_finish), NULL);
+
   return g_simple_async_result_get_op_res_gpointer (
       G_SIMPLE_ASYNC_RESULT (result));
 }
@@ -2646,15 +2680,19 @@ tp_account_prepare_finish (TpAccount *account,
     GAsyncResult *result,
     GError **error)
 {
+  GSimpleAsyncResult *simple;
+
   g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE);
   g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
 
-  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
-          error) ||
-      !g_simple_async_result_is_valid (result, G_OBJECT (account),
-          tp_account_prepare_finish))
+  simple = G_SIMPLE_ASYNC_RESULT (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 (account), tp_account_prepare_finish), FALSE);
+
   return TRUE;
 }
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list