diff options
author | Thomas Haller <thaller@redhat.com> | 2017-02-23 13:35:41 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-02-23 13:35:41 +0100 |
commit | 04c8517ea271c76be09288ebcd7a48515f96236f (patch) | |
tree | 8445bb08f73f9823f341c505ff2e3a1af4ca7959 | |
parent | fcb0fffb85bd4cb7486227167f2150bed309bf99 (diff) | |
parent | 434e7b2aa36d8bd5d9988276ae126ae8d646bbcd (diff) | |
download | NetworkManager-04c8517ea271c76be09288ebcd7a48515f96236f.tar.gz |
modem: merge branch 'th/modem-signal-cleanup'
-rw-r--r-- | src/devices/bluetooth/nm-device-bt.c | 22 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-device-bt.h | 2 | ||||
-rw-r--r-- | src/devices/wwan/nm-device-modem.c | 8 | ||||
-rw-r--r-- | src/devices/wwan/nm-modem-broadband.c | 21 | ||||
-rw-r--r-- | src/devices/wwan/nm-modem-ofono.c | 16 | ||||
-rw-r--r-- | src/devices/wwan/nm-modem.c | 40 | ||||
-rw-r--r-- | src/devices/wwan/nm-modem.h | 4 | ||||
-rw-r--r-- | src/ppp/nm-ppp-manager.c | 7 |
8 files changed, 78 insertions, 42 deletions
diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index 10b236c574..aed3c3c330 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -362,18 +362,24 @@ complete_connection (NMDevice *device, static void ppp_stats (NMModem *modem, - guint32 in_bytes, - guint32 out_bytes, + guint i_in_bytes, + guint i_out_bytes, gpointer user_data) { - g_signal_emit (NM_DEVICE_BT (user_data), signals[PPP_STATS], 0, in_bytes, out_bytes); + guint32 in_bytes = i_in_bytes; + guint32 out_bytes = i_out_bytes; + + g_signal_emit (NM_DEVICE_BT (user_data), signals[PPP_STATS], 0, (guint) in_bytes, (guint) out_bytes); } static void -ppp_failed (NMModem *modem, NMDeviceStateReason reason, gpointer user_data) +ppp_failed (NMModem *modem, + guint i_reason, + gpointer user_data) { NMDevice *device = NM_DEVICE (user_data); NMDeviceBt *self = NM_DEVICE_BT (user_data); + NMDeviceStateReason reason = i_reason; switch (nm_device_get_state (device)) { case NM_DEVICE_STATE_PREPARE: @@ -448,11 +454,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); @@ -1194,12 +1201,13 @@ nm_device_bt_class_init (NMDeviceBtClass *klass) g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); signals[PPP_STATS] = - g_signal_new ("ppp-stats", + g_signal_new (NM_DEVICE_BT_PPP_STATS, G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, 2, - G_TYPE_UINT, G_TYPE_UINT); + G_TYPE_UINT /*guint32 in_bytes*/, + G_TYPE_UINT /*guint32 out_bytes*/); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_BLUETOOTH_SKELETON, diff --git a/src/devices/bluetooth/nm-device-bt.h b/src/devices/bluetooth/nm-device-bt.h index 43bd42576b..9bcf6ca861 100644 --- a/src/devices/bluetooth/nm-device-bt.h +++ b/src/devices/bluetooth/nm-device-bt.h @@ -37,6 +37,8 @@ #define NM_DEVICE_BT_CAPABILITIES "bt-capabilities" #define NM_DEVICE_BT_DEVICE "bt-device" +#define NM_DEVICE_BT_PPP_STATS "ppp-stats" + typedef struct _NMDeviceBt NMDeviceBt; typedef struct _NMDeviceBtClass NMDeviceBtClass; diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index b05692c367..3c4ed4d9df 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -68,10 +68,13 @@ G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE) /*****************************************************************************/ static void -ppp_failed (NMModem *modem, NMDeviceStateReason reason, gpointer user_data) +ppp_failed (NMModem *modem, + guint i_reason, + gpointer user_data) { NMDevice *device = NM_DEVICE (user_data); NMDeviceModem *self = NM_DEVICE_MODEM (user_data); + NMDeviceStateReason reason = i_reason; switch (nm_device_get_state (device)) { case NM_DEVICE_STATE_PREPARE: @@ -110,12 +113,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); diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index 322964514c..8eef83b26f 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -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); diff --git a/src/devices/wwan/nm-modem-ofono.c b/src/devices/wwan/nm-modem-ofono.c index 0fa9e6292f..5f11f739ce 100644 --- a/src/devices/wwan/nm-modem-ofono.c +++ b/src/devices/wwan/nm-modem-ofono.c @@ -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,10 +912,10 @@ 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); + nm_modem_emit_ppp_failed (NM_MODEM (self), 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; } diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index 2b33100ea7..e959cffa3d 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -158,7 +158,7 @@ nm_modem_set_state (NMModem *self, priv->state = new_state; _notify (self, PROP_STATE); - g_signal_emit (self, signals[STATE_CHANGED], 0, (int) new_state, (int) old_state, reason); + g_signal_emit (self, signals[STATE_CHANGED], 0, (int) new_state, (int) old_state); } } @@ -201,7 +201,7 @@ nm_modem_set_mm_enabled (NMModem *self, /* Try to unlock the modem if it's being enabled */ if (enabled) - g_signal_emit_by_name (self, NM_MODEM_AUTH_REQUESTED, 0); + g_signal_emit (self, signals[AUTH_REQUESTED], 0); return; } @@ -222,6 +222,22 @@ 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); +} + +void +nm_modem_emit_ppp_failed (NMModem *self, NMDeviceStateReason reason) +{ + nm_assert (NM_IS_MODEM (self)); + + g_signal_emit (self, signals[PPP_FAILED], 0, (guint) reason); +} + NMModemIPType nm_modem_get_supported_ip_types (NMModem *self) { @@ -382,10 +398,10 @@ ppp_state_changed (NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_ { switch (status) { case NM_PPP_STATUS_DISCONNECT: - g_signal_emit (NM_MODEM (user_data), signals[PPP_FAILED], 0, NM_DEVICE_STATE_REASON_PPP_DISCONNECT); + nm_modem_emit_ppp_failed (user_data, NM_DEVICE_STATE_REASON_PPP_DISCONNECT); break; case NM_PPP_STATUS_DEAD: - g_signal_emit (NM_MODEM (user_data), signals[PPP_FAILED], 0, NM_DEVICE_STATE_REASON_PPP_FAILED); + nm_modem_emit_ppp_failed (user_data, NM_DEVICE_STATE_REASON_PPP_FAILED); break; default: break; @@ -479,18 +495,19 @@ ppp_ip6_config (NMPPPManager *ppp_manager, static void ppp_stats (NMPPPManager *ppp_manager, - guint32 in_bytes, - guint32 out_bytes, + guint i_in_bytes, + guint i_out_bytes, gpointer user_data) { NMModem *self = NM_MODEM (user_data); NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self); + guint32 in_bytes = i_in_bytes; + guint32 out_bytes = i_out_bytes; if (priv->in_bytes != in_bytes || priv->out_bytes != out_bytes) { priv->in_bytes = in_bytes; priv->out_bytes = out_bytes; - - g_signal_emit (self, signals[PPP_STATS], 0, in_bytes, out_bytes); + g_signal_emit (self, signals[PPP_STATS], 0, (guint) in_bytes, (guint) out_bytes); } } @@ -1663,15 +1680,16 @@ nm_modem_class_init (NMModemClass *klass) g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); signals[PPP_STATS] = - g_signal_new ("ppp-stats", + g_signal_new (NM_MODEM_PPP_STATS, G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, 2, - G_TYPE_UINT, G_TYPE_UINT); + G_TYPE_UINT /*guint32 in_bytes*/, + G_TYPE_UINT /*guint32 out_bytes*/); signals[PPP_FAILED] = - g_signal_new ("ppp-failed", + g_signal_new (NM_MODEM_PPP_FAILED, G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, diff --git a/src/devices/wwan/nm-modem.h b/src/devices/wwan/nm-modem.h index 13320080e5..df437b317f 100644 --- a/src/devices/wwan/nm-modem.h +++ b/src/devices/wwan/nm-modem.h @@ -239,6 +239,10 @@ 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); + +void nm_modem_emit_ppp_failed (NMModem *self, NMDeviceStateReason reason); + GArray *nm_modem_get_connection_ip_type (NMModem *self, NMConnection *connection, GError **error); diff --git a/src/ppp/nm-ppp-manager.c b/src/ppp/nm-ppp-manager.c index bb7821e97b..010866ff65 100644 --- a/src/ppp/nm-ppp-manager.c +++ b/src/ppp/nm-ppp-manager.c @@ -150,8 +150,8 @@ monitor_cb (gpointer user_data) _LOGW ("could not read ppp stats: %s", strerror (errno)); } else { g_signal_emit (manager, signals[STATS], 0, - stats.p.ppp_ibytes, - stats.p.ppp_obytes); + (guint) stats.p.ppp_ibytes, + (guint) stats.p.ppp_obytes); } return TRUE; @@ -1277,7 +1277,8 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class) 0, NULL, NULL, NULL, G_TYPE_NONE, 2, - G_TYPE_UINT, G_TYPE_UINT); + G_TYPE_UINT /*guint32 in_bytes*/, + G_TYPE_UINT /*guint32 out_bytes*/); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (manager_class), NMDBUS_TYPE_PPP_MANAGER_SKELETON, |