diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-10-08 16:15:04 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2019-10-11 07:27:59 +0000 |
commit | 3f15293a0b10bc7e296c2a735f34463d62cb65bf (patch) | |
tree | 2a407cdc1bd99402e31be9414ed5759e2408a0e2 | |
parent | cf0d3f36fdad77999fe5411f6ab5607367f0dd83 (diff) |
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
-rw-r--r-- | src/main.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -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"); |