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.
This commit is contained in:
Aleksander Morgado
2012-11-15 09:37:56 +01:00
parent b74741e642
commit cf46ed4238

View File

@@ -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,