From 2afc1d7c430e577cf0099164732f5f4fd505c7e9 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 15 Nov 2016 15:06:31 +0100 Subject: [PATCH] wwan: don't use generated enum-type NM_TYPE_MODEM_STATE --- src/devices/bluetooth/nm-device-bt.c | 6 ++++-- src/devices/wwan/nm-device-modem.c | 6 ++++-- src/devices/wwan/nm-modem-broadband.c | 2 +- src/devices/wwan/nm-modem-ofono.c | 2 +- src/devices/wwan/nm-modem.c | 20 ++++++++++---------- src/devices/wwan/nm-modem.h | 3 +++ 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index a36681c4a3..ceaa182ccb 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -582,10 +582,12 @@ modem_cleanup (NMDeviceBt *self) static void modem_state_cb (NMModem *modem, - NMModemState new_state, - NMModemState old_state, + int new_state_i, + int old_state_i, gpointer user_data) { + NMModemState new_state = new_state_i; + NMModemState old_state = old_state_i; NMDevice *device = NM_DEVICE (user_data); NMDeviceState dev_state = nm_device_get_state (device); diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index b15a176a57..3f28581b3f 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -287,10 +287,12 @@ ids_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data) static void modem_state_cb (NMModem *modem, - NMModemState new_state, - NMModemState old_state, + int new_state_i, + int old_state_i, gpointer user_data) { + NMModemState new_state = new_state_i; + NMModemState old_state = old_state_i; NMDevice *device = NM_DEVICE (user_data); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE ((NMDeviceModem *) device); NMDeviceState dev_state = nm_device_get_state (device); diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index f5f12a03df..e3f097977a 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -1396,7 +1396,7 @@ nm_modem_broadband_new (GObject *object, GError **error) NM_MODEM_CONTROL_PORT, mm_modem_get_primary_port (modem_iface), NM_MODEM_DATA_PORT, NULL, /* We don't know it until bearer created */ NM_MODEM_IP_TYPES, mm_ip_family_to_nm (mm_modem_get_supported_ip_families (modem_iface)), - NM_MODEM_STATE, mm_state_to_nm (mm_modem_get_state (modem_iface)), + NM_MODEM_STATE, (int) mm_state_to_nm (mm_modem_get_state (modem_iface)), NM_MODEM_DEVICE_ID, mm_modem_get_device_identifier (modem_iface), NM_MODEM_BROADBAND_MODEM, modem_object, NM_MODEM_DRIVER, drivers, diff --git a/src/devices/wwan/nm-modem-ofono.c b/src/devices/wwan/nm-modem-ofono.c index 69582f97c1..c7796e5126 100644 --- a/src/devices/wwan/nm-modem-ofono.c +++ b/src/devices/wwan/nm-modem-ofono.c @@ -1153,7 +1153,7 @@ nm_modem_ofono_new (const char *path) NM_MODEM_DEVICE_ID, basename, NM_MODEM_CONTROL_PORT, "ofono", /* mandatory */ NM_MODEM_DRIVER, "ofono", - NM_MODEM_STATE, NM_MODEM_STATE_INITIALIZING, + NM_MODEM_STATE, (int) NM_MODEM_STATE_INITIALIZING, NULL); } diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index aeb8a987f5..9257fd121e 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, new_state, old_state, reason); + g_signal_emit (self, signals[STATE_CHANGED], 0, (int) new_state, (int) old_state, reason); } } @@ -1366,7 +1366,7 @@ get_property (GObject *object, guint prop_id, g_value_set_uint (value, priv->mm_ip_timeout); break; case PROP_STATE: - g_value_set_enum (value, priv->state); + g_value_set_int (value, priv->state); break; case PROP_DEVICE_ID: g_value_set_string (value, priv->device_id); @@ -1424,10 +1424,11 @@ set_property (GObject *object, guint prop_id, priv->mm_ip_timeout = g_value_get_uint (value); break; case PROP_STATE: - priv->state = g_value_get_enum (value); + /* construct-only */ + priv->state = g_value_get_int (value); break; case PROP_DEVICE_ID: - /* construct only */ + /* construct-only */ priv->device_id = g_value_dup_string (value); break; case PROP_SIM_ID: @@ -1592,11 +1593,10 @@ nm_modem_class_init (NMModemClass *klass) G_PARAM_STATIC_STRINGS); obj_properties[PROP_STATE] = - g_param_spec_enum (NM_MODEM_STATE, "", "", - NM_TYPE_MODEM_STATE, - NM_MODEM_STATE_UNKNOWN, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); + g_param_spec_int (NM_MODEM_STATE, "", "", + NM_MODEM_STATE_UNKNOWN, _NM_MODEM_STATE_LAST, NM_MODEM_STATE_UNKNOWN, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); obj_properties[PROP_DEVICE_ID] = g_param_spec_string (NM_MODEM_DEVICE_ID, "", "", @@ -1701,5 +1701,5 @@ nm_modem_class_init (NMModemClass *klass) G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, - G_TYPE_NONE, 2, NM_TYPE_MODEM_STATE, NM_TYPE_MODEM_STATE); + G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); } diff --git a/src/devices/wwan/nm-modem.h b/src/devices/wwan/nm-modem.h index bc866ca465..299c9bf8d0 100644 --- a/src/devices/wwan/nm-modem.h +++ b/src/devices/wwan/nm-modem.h @@ -98,6 +98,9 @@ typedef enum { /*< underscore_name=nm_modem_state >*/ NM_MODEM_STATE_DISCONNECTING = 10, NM_MODEM_STATE_CONNECTING = 11, NM_MODEM_STATE_CONNECTED = 12, + + _NM_MODEM_STATE_LAST0, + _NM_MODEM_STATE_LAST = _NM_MODEM_STATE_LAST0 -1, } NMModemState; struct _NMModemPrivate;