diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-03-03 22:39:36 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@gnu.org> | 2019-04-02 08:40:26 +0000 |
commit | a0cb8b4dd56d4127f27854e5d58d9eccee5e2c8b (patch) | |
tree | fbd1bc298dea63400760700b71c8c20d929547a9 | |
parent | 5bbcfa831818f12cba77679ca7bbe4d8ca0a5f7d (diff) |
iface-modem-location: allow enabling unmanaged gps even if raw/nmea enabled
But only if the plugin implementation allows to do so.
-rw-r--r-- | src/mm-broadband-modem.c | 12 | ||||
-rw-r--r-- | src/mm-iface-modem-location.c | 29 | ||||
-rw-r--r-- | src/mm-iface-modem-location.h | 3 |
3 files changed, 35 insertions, 9 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index c748e90c..bc26c206 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -114,6 +114,7 @@ enum { PROP_MODEM_MESSAGING_SMS_LIST, PROP_MODEM_MESSAGING_SMS_PDU_MODE, PROP_MODEM_MESSAGING_SMS_DEFAULT_STORAGE, + PROP_MODEM_LOCATION_ALLOW_GPS_UNMANAGED_ALWAYS, PROP_MODEM_VOICE_CALL_LIST, PROP_MODEM_SIMPLE_STATUS, PROP_MODEM_SIM_HOT_SWAP_SUPPORTED, @@ -203,6 +204,7 @@ struct _MMBroadbandModemPrivate { /*<--- Modem Location interface --->*/ /* Properties */ GObject *modem_location_dbus_skeleton; + gboolean modem_location_allow_gps_unmanaged_always; /*<--- Modem Messaging interface --->*/ /* Properties */ @@ -11167,6 +11169,9 @@ set_property (GObject *object, case PROP_MODEM_MESSAGING_SMS_DEFAULT_STORAGE: self->priv->modem_messaging_sms_default_storage = g_value_get_enum (value); break; + case PROP_MODEM_LOCATION_ALLOW_GPS_UNMANAGED_ALWAYS: + self->priv->modem_location_allow_gps_unmanaged_always = g_value_get_boolean (value); + break; case PROP_MODEM_VOICE_CALL_LIST: g_clear_object (&self->priv->modem_voice_call_list); self->priv->modem_voice_call_list = g_value_dup_object (value); @@ -11286,6 +11291,9 @@ get_property (GObject *object, case PROP_MODEM_MESSAGING_SMS_DEFAULT_STORAGE: g_value_set_enum (value, self->priv->modem_messaging_sms_default_storage); break; + case PROP_MODEM_LOCATION_ALLOW_GPS_UNMANAGED_ALWAYS: + g_value_set_boolean (value, self->priv->modem_location_allow_gps_unmanaged_always); + break; case PROP_MODEM_VOICE_CALL_LIST: g_value_set_object (value, self->priv->modem_voice_call_list); break; @@ -11810,6 +11818,10 @@ mm_broadband_modem_class_init (MMBroadbandModemClass *klass) MM_IFACE_MODEM_MESSAGING_SMS_DEFAULT_STORAGE); g_object_class_override_property (object_class, + PROP_MODEM_LOCATION_ALLOW_GPS_UNMANAGED_ALWAYS, + MM_IFACE_MODEM_LOCATION_ALLOW_GPS_UNMANAGED_ALWAYS); + + g_object_class_override_property (object_class, PROP_MODEM_VOICE_CALL_LIST, MM_IFACE_MODEM_VOICE_CALL_LIST); diff --git a/src/mm-iface-modem-location.c b/src/mm-iface-modem-location.c index 2ccb6434..2168140b 100644 --- a/src/mm-iface-modem-location.c +++ b/src/mm-iface-modem-location.c @@ -692,6 +692,7 @@ setup_gathering (MMIfaceModemLocation *self, MMModemLocationSource currently_enabled; MMModemLocationSource source; gchar *str; + gboolean allow_gps_unmanaged_always = FALSE; ctx = g_new (SetupGatheringContext, 1); @@ -699,7 +700,8 @@ setup_gathering (MMIfaceModemLocation *self, g_task_set_task_data (task, ctx, (GDestroyNotify)setup_gathering_context_free); g_object_get (self, - MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &ctx->skeleton, + MM_IFACE_MODEM_LOCATION_DBUS_SKELETON, &ctx->skeleton, + MM_IFACE_MODEM_LOCATION_ALLOW_GPS_UNMANAGED_ALWAYS, &allow_gps_unmanaged_always, NULL); if (!ctx->skeleton) { g_task_return_new_error (task, @@ -745,13 +747,16 @@ setup_gathering (MMIfaceModemLocation *self, } /* When standard GPS retrieval (RAW/NMEA) is enabled, we cannot enable the - * UNMANAGED setup, and viceversa. */ - if ((ctx->to_enable & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED && - currently_enabled & (MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA)) || - (ctx->to_enable & (MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA) && - currently_enabled & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED) || - (ctx->to_enable & (MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA) && - ctx->to_enable & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED)) { + * UNMANAGED setup, and viceversa, unless explicitly allowed to do so by the + * plugin implementation (e.g. if the RAW/NMEA sources don't use the same TTY + * as the GPS UNMANAGED setup. */ + if (!allow_gps_unmanaged_always && + ((ctx->to_enable & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED && + currently_enabled & (MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA)) || + (ctx->to_enable & (MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA) && + currently_enabled & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED) || + (ctx->to_enable & (MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA) && + ctx->to_enable & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED))) { g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, @@ -1887,6 +1892,14 @@ iface_modem_location_init (gpointer g_iface) MM_GDBUS_TYPE_MODEM_LOCATION_SKELETON, G_PARAM_READWRITE)); + g_object_interface_install_property + (g_iface, + g_param_spec_boolean (MM_IFACE_MODEM_LOCATION_ALLOW_GPS_UNMANAGED_ALWAYS, + "Allow unmanaged GPS always", + "Whether to always allow GPS unmanaged, even when raw/nmea GPS sources are enabled", + FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + initialized = TRUE; } diff --git a/src/mm-iface-modem-location.h b/src/mm-iface-modem-location.h index 9128f1e2..c8b045af 100644 --- a/src/mm-iface-modem-location.h +++ b/src/mm-iface-modem-location.h @@ -27,7 +27,8 @@ #define MM_IS_IFACE_MODEM_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_IFACE_MODEM_LOCATION)) #define MM_IFACE_MODEM_LOCATION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_IFACE_MODEM_LOCATION, MMIfaceModemLocation)) -#define MM_IFACE_MODEM_LOCATION_DBUS_SKELETON "iface-modem-location-dbus-skeleton" +#define MM_IFACE_MODEM_LOCATION_DBUS_SKELETON "iface-modem-location-dbus-skeleton" +#define MM_IFACE_MODEM_LOCATION_ALLOW_GPS_UNMANAGED_ALWAYS "iface-modem-location-allow-gps-unmanaged-always" typedef struct _MMIfaceModemLocation MMIfaceModemLocation; |