From cf46ed42384e9fbd4872e2f98d743755d8f9a571 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Thu, 15 Nov 2012 09:37:56 +0100 Subject: [PATCH] libmm-glib,manager: register DBus error associations in advance In order to have a proper conversion between DBus error names and GErrors for our known domains, the associations need to be registered before any DBus call attempt. Given that the high-level API of libmm-glib has its entry point always in the MMManager, just register them as soon as the first such object is created. --- libmm-glib/mm-manager.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libmm-glib/mm-manager.c b/libmm-glib/mm-manager.c index 37f3ac4f..81f2041a 100644 --- a/libmm-glib/mm-manager.c +++ b/libmm-glib/mm-manager.c @@ -595,9 +595,28 @@ initable_init_async (GAsyncInitable *initable, /*****************************************************************************/ +static void +register_dbus_errors (void) +{ + static volatile guint32 aux = 0; + + if (aux) + return; + + /* Register all known own errors */ + aux |= MM_CORE_ERROR; + aux |= MM_MOBILE_EQUIPMENT_ERROR; + aux |= MM_CONNECTION_ERROR; + aux |= MM_SERIAL_ERROR; + aux |= MM_MESSAGE_ERROR; + aux |= MM_CDMA_ACTIVATION_ERROR; +} + static void mm_manager_init (MMManager *manager) { + register_dbus_errors (); + /* Setup private data */ manager->priv = G_TYPE_INSTANCE_GET_PRIVATE ((manager), MM_TYPE_MANAGER,