From 3f15293a0b10bc7e296c2a735f34463d62cb65bf Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 8 Oct 2019 16:15:04 +0200 Subject: daemon: register G_IO_ERROR_CANCELLED as "Cancelled" in DBus We have deprecated the use of MM_CORE_ERROR_CANCELLED inside the daemon in favor of using G_IO_ERROR_CANCELLED right away, and so, we will now register G_IO_ERROR_CANCELLED as the error mapped to the "Cancelled" error in the ModemManager error domain in DBus. We therefore avoid sending unknown/unmapped errors via DBus, as in this case: $ sudo ./test.sh error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled' successfully disconnected all bearers in the modem error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled' successfully disconnected all bearers in the modem successfully disconnected all bearers in the modem error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled' successfully disconnected all bearers in the modem error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled' successfully disconnected all bearers in the modem error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled' error: couldn't connect the modem: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Cancelled: Connection attempt cancelled' successfully disconnected all bearers in the modem error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled' successfully disconnected all bearers in the modem successfully disconnected all bearers in the modem error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled' error: couldn't connect the modem: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Cancelled: Connection attempt cancelled' successfully disconnected all bearers in the modem error: couldn't connect the modem: 'GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code19: Operation was cancelled' successfully disconnected all bearers in the modem --- src/main.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 96190b84..7a6b4b16 100644 --- a/src/main.c +++ b/src/main.c @@ -130,6 +130,28 @@ name_lost_cb (GDBusConnection *connection, g_main_loop_quit (loop); } +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; + + /* 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 main (int argc, char *argv[]) { @@ -154,6 +176,9 @@ main (int argc, char *argv[]) g_unix_signal_add (SIGTERM, quit_cb, NULL); g_unix_signal_add (SIGINT, quit_cb, NULL); + /* Early register all known errors */ + register_dbus_errors (); + mm_info ("ModemManager (version " MM_DIST_VERSION ") starting in %s bus...", mm_context_get_test_session () ? "session" : "system"); -- cgit v1.2.3-70-g09d2