libmm-glib: setup common helper to register DBus errors
This commit is contained in:
@@ -1889,3 +1889,25 @@ mm_utils_check_for_single_value (guint32 value)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* DBus error handling */
|
||||
|
||||
gboolean
|
||||
mm_common_register_errors (void)
|
||||
{
|
||||
static volatile guint32 aux = 0;
|
||||
|
||||
if (G_LIKELY (aux))
|
||||
return FALSE;
|
||||
|
||||
/* 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;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -201,4 +201,7 @@ gboolean mm_utils_ishexstr (const gchar *hex);
|
||||
|
||||
gboolean mm_utils_check_for_single_value (guint32 value);
|
||||
|
||||
/* DBus error handling */
|
||||
gboolean mm_common_register_errors (void);
|
||||
|
||||
#endif /* MM_COMMON_HELPERS_H */
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <ModemManager.h>
|
||||
|
||||
#include "mm-helpers.h"
|
||||
#include "mm-common-helpers.h"
|
||||
#include "mm-errors-types.h"
|
||||
#include "mm-gdbus-manager.h"
|
||||
#include "mm-manager.h"
|
||||
@@ -960,27 +961,10 @@ mm_manager_uninhibit_device_sync (MMManager *manager,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
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 ();
|
||||
mm_common_register_errors ();
|
||||
|
||||
/* Setup private data */
|
||||
manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
|
||||
|
23
src/main.c
23
src/main.c
@@ -133,23 +133,14 @@ name_lost_cb (GDBusConnection *connection,
|
||||
static void
|
||||
register_dbus_errors (void)
|
||||
{
|
||||
static volatile guint32 aux = 0;
|
||||
/* This method will always return success once during runtime */
|
||||
if (!mm_common_register_errors ())
|
||||
return;
|
||||
|
||||
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;
|
||||
|
||||
/* We no longer use MM_CORE_ERROR_CANCELLED in the daemon, we rely on
|
||||
* G_IO_ERROR_CANCELLED internally */
|
||||
g_dbus_error_unregister_error (MM_CORE_ERROR, MM_CORE_ERROR_CANCELLED, MM_CORE_ERROR_DBUS_PREFIX ".Cancelled");
|
||||
g_dbus_error_register_error (G_IO_ERROR, G_IO_ERROR_CANCELLED, MM_CORE_ERROR_DBUS_PREFIX ".Cancelled");
|
||||
/* We no longer use MM_CORE_ERROR_CANCELLED in the daemon, we rely on
|
||||
* G_IO_ERROR_CANCELLED internally */
|
||||
g_dbus_error_unregister_error (MM_CORE_ERROR, MM_CORE_ERROR_CANCELLED, MM_CORE_ERROR_DBUS_PREFIX ".Cancelled");
|
||||
g_dbus_error_register_error (G_IO_ERROR, G_IO_ERROR_CANCELLED, MM_CORE_ERROR_DBUS_PREFIX ".Cancelled");
|
||||
}
|
||||
|
||||
int
|
||||
|
Reference in New Issue
Block a user