[at-spi2-core] More error handling fixes
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-core] More error handling fixes
- Date: Mon, 24 Jan 2011 22:17:17 +0000 (UTC)
commit 0ab99d28b6da6589a5522320e395b94cba50f907
Author: Mike Gorse <mgorse novell com>
Date: Mon Jan 24 16:18:34 2011 -0600
More error handling fixes
Set the GError in some more cases where we were previously printing warnings.
Also added an error parameter to event register/deregister functions, as it
makes calls over the wire.
atspi/atspi-accessible.c | 2 +-
atspi/atspi-collection.c | 6 ++--
atspi/atspi-event-listener.c | 54 +++++++++++++++++++++++++----------------
atspi/atspi-event-listener.h | 18 +++++++++----
atspi/atspi-misc-private.h | 2 +-
atspi/atspi-misc.c | 7 +++--
6 files changed, 54 insertions(+), 35 deletions(-)
---
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index 78bdb86..684f5be 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -371,7 +371,7 @@ atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
DBUS_TYPE_STRING, &str_parent,
DBUS_TYPE_INVALID);
- reply = _atspi_dbus_send_with_reply_and_block (message);
+ reply = _atspi_dbus_send_with_reply_and_block (message, error);
if (!reply)
return NULL;
if (strcmp (dbus_message_get_signature (reply), "v") != 0)
diff --git a/atspi/atspi-collection.c b/atspi/atspi-collection.c
index 29f68fa..e4b79f8 100644
--- a/atspi/atspi-collection.c
+++ b/atspi/atspi-collection.c
@@ -138,7 +138,7 @@ atspi_collection_get_matches (AtspiCollection *collection,
DBUS_TYPE_INT32, &d_count,
DBUS_TYPE_BOOLEAN, &d_traverse,
DBUS_TYPE_INVALID);
- reply = _atspi_dbus_send_with_reply_and_block (message);
+ reply = _atspi_dbus_send_with_reply_and_block (message, error);
if (!reply)
return NULL;
return return_accessibles (reply);
@@ -194,7 +194,7 @@ atspi_collection_get_matches_to (AtspiCollection *collection,
DBUS_TYPE_INT32, &d_count,
DBUS_TYPE_BOOLEAN, &d_traverse,
DBUS_TYPE_INVALID);
- reply = _atspi_dbus_send_with_reply_and_block (message);
+ reply = _atspi_dbus_send_with_reply_and_block (message, error);
if (!reply)
return NULL;
return return_accessibles (reply);
@@ -246,7 +246,7 @@ atspi_collection_get_matches_from (AtspiCollection *collection,
DBUS_TYPE_INT32, &d_count,
DBUS_TYPE_BOOLEAN, &d_traverse,
DBUS_TYPE_INVALID);
- reply = _atspi_dbus_send_with_reply_and_block (message);
+ reply = _atspi_dbus_send_with_reply_and_block (message, error);
if (!reply)
return NULL;
return return_accessibles (reply);
diff --git a/atspi/atspi-event-listener.c b/atspi/atspi-event-listener.c
index 0106c79..0083c61 100644
--- a/atspi/atspi-event-listener.c
+++ b/atspi/atspi-event-listener.c
@@ -464,7 +464,8 @@ listener_entry_free (EventListenerEntry *e)
**/
gboolean
atspi_event_listener_register (AtspiEventListener *listener,
- const gchar *event_type)
+ const gchar *event_type,
+ GError **error)
{
/* TODO: Keep track of which events have been registered, so that we
* deregister all of them when the event listener is destroyed */
@@ -472,7 +473,7 @@ atspi_event_listener_register (AtspiEventListener *listener,
return atspi_event_listener_register_from_callback (listener->callback,
listener->user_data,
listener->cb_destroyed,
- event_type);
+ event_type, error);
}
/**
@@ -489,11 +490,12 @@ gboolean
atspi_event_listener_register_from_callback (AtspiEventListenerCB callback,
void *user_data,
GDestroyNotify callback_destroyed,
- const gchar *event_type)
+ const gchar *event_type,
+ GError **error)
{
EventListenerEntry *e;
char *matchrule;
- DBusError error;
+ DBusError d_error;
GList *new_list;
DBusMessage *message, *reply;
@@ -521,11 +523,12 @@ atspi_event_listener_register_from_callback (AtspiEventListenerCB callback,
return FALSE;
}
event_listeners = new_list;
- dbus_error_init (&error);
- dbus_bus_add_match (_atspi_bus(), matchrule, &error);
- if (error.message)
+ dbus_error_init (&d_error);
+ dbus_bus_add_match (_atspi_bus(), matchrule, &d_error);
+ if (d_error.message)
{
- g_warning ("Atspi: Adding match: %s", error.message);
+ g_warning ("Atspi: Adding match: %s", d_error.message);
+ /* TODO: Set error */
}
dbus_error_init (&error);
@@ -536,7 +539,7 @@ atspi_event_listener_register_from_callback (AtspiEventListenerCB callback,
if (!message)
return;
dbus_message_append_args (message, DBUS_TYPE_STRING, &event_type, DBUS_TYPE_INVALID);
- reply = _atspi_dbus_send_with_reply_and_block (message);
+ reply = _atspi_dbus_send_with_reply_and_block (message, error);
if (reply)
dbus_message_unref (reply);
@@ -561,9 +564,12 @@ atspi_event_listener_register_from_callback (AtspiEventListenerCB callback,
gboolean
atspi_event_listener_register_no_data (AtspiEventListenerSimpleCB callback,
GDestroyNotify callback_destroyed,
- const gchar *event_type)
+ const gchar *event_type,
+ GError **error)
{
- return atspi_event_listener_register_from_callback (remove_datum, callback, callback_destroyed, event_type);
+ return atspi_event_listener_register_from_callback (remove_datum, callback,
+ callback_destroyed,
+ event_type, error);
}
static gboolean
@@ -587,9 +593,12 @@ is_superset (const gchar *super, const gchar *sub)
**/
gboolean
atspi_event_listener_deregister (AtspiEventListener *listener,
- const gchar *event_type)
+ const gchar *event_type,
+ GError **error)
{
- atspi_event_listener_deregister_from_callback (listener->callback, listener->user_data, event_type);
+ atspi_event_listener_deregister_from_callback (listener->callback,
+ listener->user_data,
+ event_type, error);
}
/**
@@ -608,7 +617,8 @@ atspi_event_listener_deregister (AtspiEventListener *listener,
gboolean
atspi_event_listener_deregister_from_callback (AtspiEventListenerCB callback,
void *user_data,
- const gchar *event_type)
+ const gchar *event_type,
+ GError **error)
{
char *category, *name, *detail, *matchrule;
GList *l;
@@ -632,15 +642,15 @@ atspi_event_listener_deregister_from_callback (AtspiEventListenerCB callback,
is_superset (detail, e->detail))
{
gboolean need_replace;
- DBusError error;
+ DBusError d_error;
DBusMessage *message, *reply;
need_replace = (l == event_listeners);
l = g_list_remove (l, e);
if (need_replace)
event_listeners = l;
- dbus_error_init (&error);
- dbus_bus_remove_match (_atspi_bus(), matchrule, &error);
- dbus_error_init (&error);
+ dbus_error_init (&d_error);
+ dbus_bus_remove_match (_atspi_bus(), matchrule, &d_error);
+ dbus_error_init (&d_error);
message = dbus_message_new_method_call (atspi_bus_registry,
atspi_path_registry,
atspi_interface_registry,
@@ -648,7 +658,7 @@ atspi_event_listener_deregister_from_callback (AtspiEventListenerCB callback,
if (!message)
return;
dbus_message_append_args (message, DBUS_TYPE_STRING, &event_type, DBUS_TYPE_INVALID);
- reply = _atspi_dbus_send_with_reply_and_block (message);
+ reply = _atspi_dbus_send_with_reply_and_block (message, error);
dbus_message_unref (reply);
listener_entry_free (e);
@@ -676,10 +686,12 @@ atspi_event_listener_deregister_from_callback (AtspiEventListenerCB callback,
**/
gboolean
atspi_event_listener_deregister_no_data (AtspiEventListenerSimpleCB callback,
- const gchar *event_type)
+ const gchar *event_type,
+ GError **error)
{
return atspi_event_listener_deregister_from_callback (remove_datum, callback,
- event_type);
+ event_type,
+ error);
}
static AtspiEvent *
diff --git a/atspi/atspi-event-listener.h b/atspi/atspi-event-listener.h
index 64f31d7..a64c7dd 100644
--- a/atspi/atspi-event-listener.h
+++ b/atspi/atspi-event-listener.h
@@ -81,29 +81,35 @@ atspi_event_listener_new_simple (AtspiEventListenerSimpleCB callback,
gboolean
atspi_event_listener_register (AtspiEventListener *listener,
- const gchar *event_type);
+ const gchar *event_type,
+ GError **error);
gboolean
atspi_event_listener_register_from_callback (AtspiEventListenerCB callback,
void *user_data,
GDestroyNotify callback_destroyed,
- const gchar *event_type);
+ const gchar *event_type,
+ GError **error);
gboolean
atspi_event_listener_register_no_data (AtspiEventListenerSimpleCB callback,
GDestroyNotify callback_destroyed,
- const gchar *event_type);
+ const gchar *event_type,
+ GError **error);
gboolean
atspi_event_listener_deregister (AtspiEventListener *listener,
- const gchar *event_type);
+ const gchar *event_type,
+ GError **error);
gboolean
atspi_event_listener_deregister_from_callback (AtspiEventListenerCB callback,
void *user_data,
- const gchar *event_type);
+ const gchar *event_type,
+ GError **error);
gboolean
atspi_event_listener_deregister_no_data (AtspiEventListenerSimpleCB callback,
- const gchar *event_type);
+ const gchar *event_type,
+ GError **error);
#endif /* _ATSPI_EVENT_LISTENER_H_ */
diff --git a/atspi/atspi-misc-private.h b/atspi/atspi-misc-private.h
index 52ba2fd..87373d8 100644
--- a/atspi/atspi-misc-private.h
+++ b/atspi/atspi-misc-private.h
@@ -131,7 +131,7 @@ DBusMessage *_atspi_dbus_call_partial_va (gpointer obj, const char *interface, c
dbus_bool_t _atspi_dbus_get_property (gpointer obj, const char *interface, const char *name, GError **error, const char *type, void *data);
-DBusMessage * _atspi_dbus_send_with_reply_and_block (DBusMessage *message);
+DBusMessage * _atspi_dbus_send_with_reply_and_block (DBusMessage *message, GError **error);
GHashTable *_atspi_dbus_return_hash_from_message (DBusMessage *message);
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index 5bfade0..1befd8f 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -536,7 +536,7 @@ ref_accessible_desktop (AtspiApplication *app)
"GetChildren");
if (!message)
return;
- reply = _atspi_dbus_send_with_reply_and_block (message);
+ reply = _atspi_dbus_send_with_reply_and_block (message, NULL);
if (!reply || strcmp (dbus_message_get_signature (reply), "a(so)") != 0)
{
g_error ("Couldn't get application list: %s", error.message);
@@ -1171,7 +1171,7 @@ done:
}
DBusMessage *
-_atspi_dbus_send_with_reply_and_block (DBusMessage *message)
+_atspi_dbus_send_with_reply_and_block (DBusMessage *message, GError **error)
{
DBusMessage *reply;
DBusError err;
@@ -1190,7 +1190,8 @@ _atspi_dbus_send_with_reply_and_block (DBusMessage *message)
dbus_message_unref (message);
if (err.message)
{
- g_warning (_("AT-SPI: Got error: %s\n"), err.message);
+ if (error)
+ g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_IPC, err.message);
dbus_error_free (&err);
}
return reply;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]