Rework how we strip remote DBus errors

* This is necessary because sometimes we don't want to complain,
   for expected errors, when running nested operations.
 * The fact that we have to do this is silly, and soon there
   will be a solution in glib itself.

https://bugzilla.gnome.org/show_bug.cgi?id=688165
This commit is contained in:
Stef Walter 2012-11-14 10:57:10 +01:00
parent 430b217e3e
commit a23ee598c7
9 changed files with 49 additions and 51 deletions

View File

@ -714,7 +714,7 @@ secret_collection_async_initable_init_finish (GAsyncInitable *initable,
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (initable),
secret_collection_async_initable_init_async), FALSE);
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
if (_secret_util_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
return FALSE;
self->pv->constructing = FALSE;
@ -865,7 +865,7 @@ secret_collection_load_items_finish (SecretCollection *self,
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self),
secret_collection_load_items), FALSE);
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
if (_secret_util_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
return FALSE;
return TRUE;
@ -1146,7 +1146,7 @@ secret_collection_create_finish (GAsyncResult *result,
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return NULL;
closure = g_simple_async_result_get_op_res_gpointer (res);
@ -1487,7 +1487,7 @@ secret_collection_search_finish (SecretCollection *self,
secret_collection_search), NULL);
async = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (async, error))
if (_secret_util_propagate_error (async, error))
return NULL;
search = g_simple_async_result_get_op_res_gpointer (async);
@ -1681,7 +1681,7 @@ secret_collection_delete_finish (SecretCollection *self,
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self),
secret_collection_delete), FALSE);
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
if (_secret_util_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
return FALSE;
return TRUE;
@ -2178,7 +2178,7 @@ secret_collection_for_alias_finish (GAsyncResult *result,
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
async = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (async, error))
if (_secret_util_propagate_error (async, error))
return NULL;
read = g_simple_async_result_get_op_res_gpointer (async);
if (read->collection)

View File

@ -595,7 +595,7 @@ secret_item_async_initable_init_finish (GAsyncInitable *initable,
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (initable),
secret_item_async_initable_init_async), FALSE);
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
if (_secret_util_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
return FALSE;
return TRUE;
@ -842,7 +842,7 @@ secret_item_create_finish (GAsyncResult *result,
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return NULL;
closure = g_simple_async_result_get_op_res_gpointer (res);
@ -1002,7 +1002,7 @@ secret_item_delete_finish (SecretItem *self,
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return FALSE;
return g_simple_async_result_get_op_res_gboolean (res);
@ -1169,7 +1169,6 @@ on_item_load_secret (GObject *source,
}
if (error != NULL) {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
}
@ -1271,7 +1270,7 @@ secret_item_load_secret_finish (SecretItem *self,
secret_item_load_secret), FALSE);
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return FALSE;
return TRUE;
@ -1370,10 +1369,8 @@ on_get_secrets_complete (GObject *source,
g_variant_unref (retval);
}
if (error != NULL) {
_secret_util_strip_remote_error (&error);
if (error != NULL)
g_simple_async_result_take_error (async, error);
}
g_simple_async_result_complete (async);
g_object_unref (async);
@ -1499,7 +1496,7 @@ secret_item_load_secrets_finish (GAsyncResult *result,
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
async = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (async, error))
if (_secret_util_propagate_error (async, error))
return FALSE;
return TRUE;
@ -1583,7 +1580,6 @@ on_item_set_secret (GObject *source,
if (error == NULL) {
_secret_item_set_cached_secret (self, set->value);
} else {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
}
if (retval != NULL)
@ -1688,7 +1684,7 @@ secret_item_set_secret_finish (SecretItem *self,
secret_item_set_secret), FALSE);
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return FALSE;
return TRUE;

View File

@ -361,7 +361,7 @@ secret_service_search_finish (SecretService *service,
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return FALSE;
closure = g_simple_async_result_get_op_res_gpointer (res);
@ -708,7 +708,7 @@ service_xlock_finish (SecretService *service,
service_xlock_async), -1);
async = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (async, error))
if (_secret_util_propagate_error (async, error))
return -1;
xlock = g_simple_async_result_get_op_res_gpointer (async);
@ -1181,7 +1181,7 @@ secret_service_store_finish (SecretService *service,
secret_service_store), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
if (_secret_util_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
return FALSE;
return TRUE;
@ -1476,7 +1476,7 @@ secret_service_lookup_finish (SecretService *service,
secret_service_lookup), NULL);
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return NULL;
closure = g_simple_async_result_get_op_res_gpointer (res);
@ -1728,7 +1728,7 @@ secret_service_clear_finish (SecretService *service,
secret_service_clear), FALSE);
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return FALSE;
closure = g_simple_async_result_get_op_res_gpointer (res);
@ -1933,7 +1933,7 @@ secret_service_set_alias_finish (SecretService *service,
secret_service_set_alias), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
if (_secret_util_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
return FALSE;
return TRUE;

View File

@ -300,7 +300,6 @@ on_search_items_complete (GObject *source,
response = g_dbus_proxy_call_finish (G_DBUS_PROXY (source), result, &error);
if (error != NULL) {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
} else {
g_simple_async_result_set_op_res_gpointer (res, response,
@ -393,7 +392,7 @@ secret_collection_search_for_dbus_paths_finish (SecretCollection *collection,
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
async = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (async, error))
if (_secret_util_propagate_error (async, error))
return FALSE;
retval= g_simple_async_result_get_op_res_gpointer (async);
@ -564,7 +563,7 @@ secret_service_search_for_dbus_paths_finish (SecretService *self,
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return FALSE;
if (unlocked || locked) {
@ -687,7 +686,6 @@ on_get_secrets_complete (GObject *source,
closure->out = g_dbus_proxy_call_finish (G_DBUS_PROXY (source), result, &error);
if (error != NULL) {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
}
g_simple_async_result_complete (res);
@ -794,7 +792,7 @@ secret_service_get_secret_for_dbus_path_finish (SecretService *self,
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return NULL;
closure = g_simple_async_result_get_op_res_gpointer (res);
@ -926,7 +924,7 @@ secret_service_get_secrets_for_dbus_paths_finish (SecretService *self,
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return NULL;
closure = g_simple_async_result_get_op_res_gpointer (res);
@ -1047,7 +1045,6 @@ on_xlock_called (GObject *source,
retval = g_dbus_proxy_call_finish (G_DBUS_PROXY (source), result, &error);
if (error != NULL) {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
g_simple_async_result_complete (res);
@ -1110,7 +1107,7 @@ _secret_service_xlock_paths_finish (SecretService *self,
gint count;
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return -1;
closure = g_simple_async_result_get_op_res_gpointer (res);
@ -1442,7 +1439,6 @@ on_delete_complete (GObject *source,
g_variant_unref (retval);
} else {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
g_simple_async_result_complete (res);
}
@ -1496,7 +1492,7 @@ _secret_service_delete_path_finish (SecretService *self,
_secret_service_delete_path), FALSE);
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return FALSE;
closure = g_simple_async_result_get_op_res_gpointer (res);
@ -1671,7 +1667,6 @@ on_create_collection_called (GObject *source,
g_variant_unref (retval);
} else {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
g_simple_async_result_complete (res);
}
@ -1789,7 +1784,7 @@ secret_service_create_collection_dbus_path_finish (SecretService *self,
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return NULL;
closure = g_simple_async_result_get_op_res_gpointer (res);
@ -1941,7 +1936,6 @@ on_create_item_called (GObject *source,
g_variant_unref (retval);
} else {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
g_simple_async_result_complete (res);
}
@ -2085,7 +2079,7 @@ secret_service_create_item_dbus_path_finish (SecretService *self,
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return NULL;
closure = g_simple_async_result_get_op_res_gpointer (res);

View File

@ -65,6 +65,9 @@ SecretPrompt * _secret_prompt_instance (SecretService *se
void _secret_util_strip_remote_error (GError **error);
gboolean _secret_util_propagate_error (GSimpleAsyncResult *async,
GError **error);
gchar * _secret_util_parent_path (const gchar *path);
gboolean _secret_util_empty_path (const gchar *path);

View File

@ -334,7 +334,6 @@ on_prompt_prompted (GObject *source,
g_clear_error (&error);
if (error != NULL) {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
perform_prompt_complete (res, TRUE);
@ -381,7 +380,6 @@ on_prompt_dismissed (GObject *source,
g_clear_error (&error);
if (error != NULL) {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
perform_prompt_complete (res, TRUE);
}
@ -529,7 +527,7 @@ secret_prompt_perform_finish (SecretPrompt *self,
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return NULL;
closure = g_simple_async_result_get_op_res_gpointer (res);

View File

@ -354,7 +354,7 @@ secret_service_real_prompt_finish (SecretService *self,
secret_service_real_prompt_async), NULL);
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return NULL;
retval = g_simple_async_result_get_op_res_gpointer (res);
@ -716,7 +716,7 @@ secret_service_async_initable_init_finish (GAsyncInitable *initable,
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (initable),
secret_service_async_initable_init_async), FALSE);
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
if (_secret_util_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
return FALSE;
return TRUE;
@ -824,7 +824,7 @@ secret_service_get_finish (GAsyncResult *result,
/* Just ensuring that the service matches flags */
if (g_simple_async_result_is_valid (result, source_object, secret_service_get)) {
if (!g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
if (!_secret_util_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
service = g_object_ref (source_object);
/* Creating a whole new service */
@ -1543,7 +1543,7 @@ secret_service_load_collections_finish (SecretService *self,
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self),
secret_service_load_collections), FALSE);
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
if (_secret_util_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
return FALSE;
return TRUE;

View File

@ -248,7 +248,6 @@ on_service_open_session_plain (GObject *source,
g_variant_unref (response);
} else {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
g_simple_async_result_complete (res);
}
@ -297,7 +296,6 @@ on_service_open_session_aes (GObject *source,
/* Other errors result in a failure */
} else {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
g_simple_async_result_complete (res);
}
@ -344,7 +342,7 @@ gboolean
_secret_session_open_finish (GAsyncResult *result,
GError **error)
{
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
if (_secret_util_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
return FALSE;
return TRUE;

View File

@ -96,6 +96,17 @@ secret_error_get_quark (void)
return quark;
}
gboolean
_secret_util_propagate_error (GSimpleAsyncResult *async,
GError **error)
{
if (!g_simple_async_result_propagate_error (async, error))
return FALSE;
_secret_util_strip_remote_error (error);
return TRUE;
}
void
_secret_util_strip_remote_error (GError **error)
{
@ -206,7 +217,6 @@ on_get_properties (GObject *source,
if (error == NULL) {
process_get_all_reply (proxy, retval);
} else {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
}
if (retval != NULL)
@ -256,7 +266,7 @@ _secret_util_get_properties_finish (GDBusProxy *proxy,
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return FALSE;
return TRUE;
@ -291,7 +301,6 @@ on_set_property (GObject *source,
retval = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source),
result, &error);
if (error != NULL) {
_secret_util_strip_remote_error (&error);
g_simple_async_result_take_error (res, error);
}
if (retval != NULL)
@ -357,7 +366,7 @@ _secret_util_set_property_finish (GDBusProxy *proxy,
res = G_SIMPLE_ASYNC_RESULT (result);
if (g_simple_async_result_propagate_error (res, error))
if (_secret_util_propagate_error (res, error))
return FALSE;
closure = g_simple_async_result_get_op_res_gpointer (res);