Commit 0a1fd88d authored by Thomas Haller's avatar Thomas Haller
Browse files

modem: add nm_modem_emit_prepare_result() function

... instead of emitting the signal by name. For one,
we get the casting of the NMDeviceStateReason enum right.
Also, emitting by the guint signal-id is faster then
emitting by name.
parent 9a8f8e8a
......@@ -448,11 +448,12 @@ modem_auth_result (NMModem *modem, GError *error, gpointer user_data)
static void
modem_prepare_result (NMModem *modem,
gboolean success,
NMDeviceStateReason reason,
guint i_reason,
gpointer user_data)
{
NMDeviceBt *self = NM_DEVICE_BT (user_data);
NMDevice *device = NM_DEVICE (self);
NMDeviceStateReason reason = i_reason;
NMDeviceState state;
state = nm_device_get_state (device);
......
......@@ -110,12 +110,13 @@ ppp_failed (NMModem *modem, NMDeviceStateReason reason, gpointer user_data)
static void
modem_prepare_result (NMModem *modem,
gboolean success,
NMDeviceStateReason reason,
guint i_reason,
gpointer user_data)
{
NMDeviceModem *self = NM_DEVICE_MODEM (user_data);
NMDevice *device = NM_DEVICE (self);
NMDeviceState state;
NMDeviceStateReason reason = i_reason;
state = nm_device_get_state (device);
g_return_if_fail (state == NM_DEVICE_STATE_PREPARE);
......
......@@ -407,7 +407,7 @@ connect_ready (MMModemSimple *simple_iface,
if (ip4_method == NM_MODEM_IP_METHOD_UNKNOWN &&
ip6_method == NM_MODEM_IP_METHOD_UNKNOWN) {
_LOGW ("failed to connect modem: invalid bearer IP configuration");
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
nm_modem_emit_prepare_result (NM_MODEM (self), FALSE, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
connect_context_clear (self);
return;
}
......@@ -439,11 +439,10 @@ send_pin_ready (MMSim *sim, GAsyncResult *result, NMModemBroadband *self)
if (error) {
if (g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_SIM_PIN) ||
(g_error_matches (error, MM_CORE_ERROR, MM_CORE_ERROR_UNAUTHORIZED) &&
mm_modem_get_unlock_required (self->_priv.modem_iface) == MM_MODEM_LOCK_SIM_PIN)) {
mm_modem_get_unlock_required (self->_priv.modem_iface) == MM_MODEM_LOCK_SIM_PIN))
ask_for_pin (self);
} else {
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, translate_mm_error (self, error));
}
else
nm_modem_emit_prepare_result (NM_MODEM (self), FALSE, translate_mm_error (self, error));
return;
}
......@@ -506,7 +505,7 @@ connect_context_step (NMModemBroadband *self)
_LOGW ("failed to connect '%s': not a mobile broadband modem",
nm_connection_get_id (ctx->connection));
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED);
nm_modem_emit_prepare_result (NM_MODEM (self), FALSE, NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED);
connect_context_clear (self);
break;
}
......@@ -520,7 +519,7 @@ connect_context_step (NMModemBroadband *self)
error->message);
g_clear_error (&error);
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED);
nm_modem_emit_prepare_result (NM_MODEM (self), FALSE, NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED);
connect_context_clear (self);
break;
}
......@@ -559,9 +558,9 @@ connect_context_step (NMModemBroadband *self)
/* fall through */
case CONNECT_STEP_LAST:
if (self->_priv.ipv4_config || self->_priv.ipv6_config) {
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, TRUE, NM_DEVICE_STATE_REASON_NONE);
} else {
if (self->_priv.ipv4_config || self->_priv.ipv6_config)
nm_modem_emit_prepare_result (NM_MODEM (self), TRUE, NM_DEVICE_STATE_REASON_NONE);
else {
/* If we have a saved error from a previous attempt, use it */
if (!ctx->first_error)
ctx->first_error = g_error_new_literal (NM_DEVICE_ERROR,
......@@ -570,7 +569,7 @@ connect_context_step (NMModemBroadband *self)
_LOGW ("failed to connect modem: %s",
ctx->first_error->message);
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, translate_mm_error (self, ctx->first_error));
nm_modem_emit_prepare_result (NM_MODEM (self), FALSE, translate_mm_error (self, ctx->first_error));
}
connect_context_clear (self);
......
......@@ -724,8 +724,8 @@ stage1_prepare_done (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data
if (error) {
_LOGW ("connection failed: %s", error->message);
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE,
NM_DEVICE_STATE_REASON_MODEM_BUSY);
nm_modem_emit_prepare_result (NM_MODEM (self), FALSE,
NM_DEVICE_STATE_REASON_MODEM_BUSY);
/*
* FIXME: add code to check for InProgress so that the
* connection doesn't continue to try and activate,
......@@ -912,7 +912,7 @@ out:
_LOGI ("emitting PREPARE_RESULT: %s", ret ? "TRUE" : "FALSE");
if (!ret)
reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, ret, reason);
nm_modem_emit_prepare_result (NM_MODEM (self), ret, reason);
} else {
_LOGW ("MODEM_PPP_FAILED");
g_signal_emit_by_name (self, NM_MODEM_PPP_FAILED, NM_DEVICE_STATE_REASON_PPP_FAILED);
......@@ -955,14 +955,14 @@ context_proxy_new_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_dat
priv->context_proxy = g_dbus_proxy_new_for_bus_finish (result, &error);
if (error) {
_LOGE ("failed to create ofono ConnectionContext DBus proxy: %s", error->message);
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE,
NM_DEVICE_STATE_REASON_MODEM_BUSY);
nm_modem_emit_prepare_result (NM_MODEM (self), FALSE,
NM_DEVICE_STATE_REASON_MODEM_BUSY);
return;
}
if (!priv->gprs_attached) {
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE,
NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER);
nm_modem_emit_prepare_result (NM_MODEM (self), FALSE,
NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER);
return;
}
......
......@@ -222,6 +222,14 @@ nm_modem_emit_removed (NMModem *self)
g_signal_emit (self, signals[REMOVED], 0);
}
void
nm_modem_emit_prepare_result (NMModem *self, gboolean success, NMDeviceStateReason reason)
{
nm_assert (NM_IS_MODEM (self));
g_signal_emit (self, signals[PREPARE_RESULT], 0, success, (guint) reason);
}
NMModemIPType
nm_modem_get_supported_ip_types (NMModem *self)
{
......
......@@ -239,6 +239,8 @@ NMModemIPType nm_modem_get_supported_ip_types (NMModem *self);
/* For the modem-manager only */
void nm_modem_emit_removed (NMModem *self);
void nm_modem_emit_prepare_result (NMModem *self, gboolean success, NMDeviceStateReason reason);
GArray *nm_modem_get_connection_ip_type (NMModem *self,
NMConnection *connection,
GError **error);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment