api,simple: new 'multiplex' setting in bearer properties

Both the Simple.Connect() and Modem.CreateBearer() are updated to
allow a new 'multiplex' setting in the properties provided by the user
in both of these methods.

The new setting expects a MMBearerMultiplexSupport enum indicating
what kind of multiplex needs the user has:
 * none: if multiplex must not be used.
 * requested: if multiplex should be used if available.
 * required: if multiplex must be used.

The underlying implementations will take care of accepting or
rejecting the setting depending on the system and modem capabilities.
This commit is contained in:
Aleksander Morgado
2021-02-17 15:49:01 +01:00
parent 71bad1d862
commit 064e92e9b7
14 changed files with 201 additions and 24 deletions

View File

@@ -14,6 +14,7 @@ MMBearerType
MMBearerIpFamily
MMBearerIpMethod
MMBearerAllowedAuth
MMBearerMultiplexSupport
MMCallDirection
MMCallState
MMCallStateReason

View File

@@ -872,6 +872,8 @@ mm_simple_connect_properties_get_allow_roaming
mm_simple_connect_properties_set_allow_roaming
mm_simple_connect_properties_get_rm_protocol
mm_simple_connect_properties_set_rm_protocol
mm_simple_connect_properties_get_multiplex
mm_simple_connect_properties_set_multiplex
mm_simple_connect_properties_get_number
mm_simple_connect_properties_set_number
<SUBSECTION Private>
@@ -1189,10 +1191,12 @@ mm_bearer_properties_get_ip_type
mm_bearer_properties_set_ip_type
mm_bearer_properties_get_allow_roaming
mm_bearer_properties_set_allow_roaming
mm_bearer_properties_get_number
mm_bearer_properties_set_number
mm_bearer_properties_get_rm_protocol
mm_bearer_properties_set_rm_protocol
mm_bearer_properties_get_multiplex
mm_bearer_properties_set_multiplex
mm_bearer_properties_get_number
mm_bearer_properties_set_number
<SUBSECTION Private>
mm_bearer_properties_new_from_dictionary
mm_bearer_properties_new_from_string
@@ -1527,6 +1531,7 @@ mm_bearer_type_get_string
mm_bearer_ip_method_get_string
mm_bearer_ip_family_get_string
mm_bearer_allowed_auth_build_string_from_mask
mm_bearer_multiplex_support_get_string
mm_modem_capability_build_string_from_mask
mm_modem_state_get_string
mm_modem_state_failed_reason_get_string
@@ -1589,6 +1594,7 @@ mm_bearer_type_build_string_from_mask
mm_bearer_ip_family_build_string_from_mask
mm_bearer_ip_method_build_string_from_mask
mm_bearer_allowed_auth_get_string
mm_bearer_multiplex_support_build_string_from_mask
mm_modem_cdma_registration_state_build_string_from_mask
mm_modem_cdma_activation_state_build_string_from_mask
mm_modem_cdma_rm_protocol_build_string_from_mask
@@ -1613,6 +1619,7 @@ MM_TYPE_BEARER_TYPE
MM_TYPE_BEARER_IP_FAMILY
MM_TYPE_BEARER_IP_METHOD
MM_TYPE_BEARER_ALLOWED_AUTH
MM_TYPE_BEARER_MULTIPLEX_SUPPORT
MM_TYPE_FIRMWARE_IMAGE_TYPE
MM_TYPE_MODEM_3GPP_FACILITY
MM_TYPE_MODEM_3GPP_NETWORK_AVAILABILITY
@@ -1655,6 +1662,7 @@ mm_bearer_type_get_type
mm_bearer_ip_family_get_type
mm_bearer_ip_method_get_type
mm_bearer_allowed_auth_get_type
mm_bearer_multiplex_support_get_type
mm_firmware_image_type_get_type
mm_modem_3gpp_facility_get_type
mm_modem_3gpp_network_availability_get_type

View File

@@ -1526,4 +1526,22 @@ typedef enum { /*< underscore_name=mm_modem_firmware_update_method >*/
MM_MODEM_FIRMWARE_UPDATE_METHOD_QMI_PDC = 1 << 1,
} MMModemFirmwareUpdateMethod;
/**
* MMBearerMultiplexSupport:
* @MM_BEARER_MULTIPLEX_SUPPORT_UNKNOWN: Unknown.
* @MM_BEARER_MULTIPLEX_SUPPORT_NONE: No multiplex support should be used.
* @MM_BEARER_MULTIPLEX_SUPPORT_REQUESTED: If available, multiplex support should be used.
* @MM_BEARER_MULTIPLEX_SUPPORT_REQUIRED: Multiplex support must be used or otherwise the connection attempt will fail.
*
* Multiplex support requested by the user.
*
* Since: 1.18
*/
typedef enum { /*< underscore_name=mm_bearer_multiplex_support >*/
MM_BEARER_MULTIPLEX_SUPPORT_UNKNOWN = 0,
MM_BEARER_MULTIPLEX_SUPPORT_NONE = 1,
MM_BEARER_MULTIPLEX_SUPPORT_REQUESTED = 2,
MM_BEARER_MULTIPLEX_SUPPORT_REQUIRED = 3,
} MMBearerMultiplexSupport;
#endif /* _MODEMMANAGER_ENUMS_H_ */

View File

@@ -109,6 +109,13 @@
value (signature <literal>"u"</literal>).
</listitem>
</varlistentry>
<varlistentry><term><literal>"multiplex"</literal></term>
<listitem>
Multiplex support requested by the user, given as a
<link linkend="MMBearerMultiplexSupport">MMBearerMultiplexSupport</link>
value (signature <literal>"u"</literal>). Since 1.18.
</listitem>
</varlistentry>
</variablelist>
-->
<method name="Connect">

View File

@@ -81,6 +81,8 @@
<listitem><para>Protocol of the Rm interface, given as a <link linkend="MMModemCdmaRmProtocol">MMModemCdmaRmProtocol</link> value (signature <literal>"u"</literal>). Optional in CDMA.</para></listitem></varlistentry>
<varlistentry><term><literal>"number"</literal></term>
<listitem><para>Number to dial for the data connection, given as a string value (signature <literal>"s"</literal>). Deprecated since version 1.10.0.</para></listitem></varlistentry>
<varlistentry><term><literal>"multiplex"</literal></term>
<listitem><para>Multiplex support requested by the user, given as a <link linkend="MMBearerMultiplexSupport">MMBearerMultiplexSupport</link> value (signature <literal>"u"</literal>). Since 1.18.</para></listitem></varlistentry>
</variablelist>
Some properties are only applicable to a bearer of certain access

View File

@@ -40,6 +40,7 @@ G_DEFINE_TYPE (MMBearerProperties, mm_bearer_properties, G_TYPE_OBJECT);
#define PROPERTY_IP_TYPE "ip-type"
#define PROPERTY_ALLOW_ROAMING "allow-roaming"
#define PROPERTY_RM_PROTOCOL "rm-protocol"
#define PROPERTY_MULTIPLEX "multiplex"
/* no longer used properties */
#define DEPRECATED_PROPERTY_NUMBER "number"
@@ -60,6 +61,8 @@ struct _MMBearerPropertiesPrivate {
gboolean allow_roaming;
/* Protocol of the Rm interface */
MMModemCdmaRmProtocol rm_protocol;
/* Multiplex support */
MMBearerMultiplexSupport multiplex;
};
/*****************************************************************************/
@@ -389,6 +392,44 @@ mm_bearer_properties_get_rm_protocol (MMBearerProperties *self)
/*****************************************************************************/
/**
* mm_bearer_properties_set_multiplex:
* @self: a #MMBearerProperties.
* @multiplex: a #MMBearerMultiplexSupport.
*
* Gets the type of multiplex support requested by the user.
*
* Since: 1.18
*/
void
mm_bearer_properties_set_multiplex (MMBearerProperties *self,
MMBearerMultiplexSupport multiplex)
{
g_return_if_fail (MM_IS_BEARER_PROPERTIES (self));
self->priv->multiplex = multiplex;
}
/**
* mm_bearer_properties_get_multiplex:
* @self: a #MMBearerProperties.
*
* Gets the type of multiplex support requested by the user.
*
* Returns: a #MMBearerMultiplexSupport.
*
* Since: 1.18
*/
MMBearerMultiplexSupport
mm_bearer_properties_get_multiplex (MMBearerProperties *self)
{
g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), MM_BEARER_MULTIPLEX_SUPPORT_UNKNOWN);
return self->priv->multiplex;
}
/*****************************************************************************/
/**
* mm_bearer_properties_get_dictionary: (skip)
*/
@@ -447,6 +488,12 @@ mm_bearer_properties_get_dictionary (MMBearerProperties *self)
PROPERTY_RM_PROTOCOL,
g_variant_new_uint32 (self->priv->rm_protocol));
if (self->priv->multiplex)
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_MULTIPLEX,
g_variant_new_uint32 (self->priv->multiplex));
return g_variant_ref_sink (g_variant_builder_end (&builder));
}
@@ -509,6 +556,16 @@ mm_bearer_properties_consume_string (MMBearerProperties *self,
return FALSE;
}
mm_bearer_properties_set_rm_protocol (self, protocol);
} else if (g_str_equal (key, PROPERTY_MULTIPLEX)) {
GError *inner_error = NULL;
MMBearerMultiplexSupport multiplex;
multiplex = mm_common_get_multiplex_support_from_string (value, &inner_error);
if (inner_error) {
g_propagate_error (error, inner_error);
return FALSE;
}
mm_bearer_properties_set_multiplex (self, multiplex);
} else if (g_str_equal (key, DEPRECATED_PROPERTY_NUMBER)) {
/* NO-OP */
} else {
@@ -606,6 +663,10 @@ mm_bearer_properties_consume_variant (MMBearerProperties *properties,
mm_bearer_properties_set_rm_protocol (
properties,
g_variant_get_uint32 (value));
else if (g_str_equal (key, PROPERTY_MULTIPLEX))
mm_bearer_properties_set_multiplex (
properties,
g_variant_get_uint32 (value));
else if (g_str_equal (key, DEPRECATED_PROPERTY_NUMBER)) {
/* NO-OP */
} else {
@@ -651,10 +712,7 @@ mm_bearer_properties_new_from_dictionary (GVariant *dictionary,
g_variant_iter_init (&iter, dictionary);
while (!inner_error &&
g_variant_iter_next (&iter, "{sv}", &key, &value)) {
mm_bearer_properties_consume_variant (properties,
key,
value,
&inner_error);
mm_bearer_properties_consume_variant (properties, key, value, &inner_error);
g_free (key);
g_variant_unref (value);
}
@@ -766,6 +824,8 @@ mm_bearer_properties_cmp (MMBearerProperties *a,
}
if (a->priv->rm_protocol != b->priv->rm_protocol)
return FALSE;
if (a->priv->multiplex != b->priv->multiplex)
return FALSE;
return TRUE;
}
@@ -799,6 +859,7 @@ mm_bearer_properties_init (MMBearerProperties *self)
self->priv->rm_protocol = MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN;
self->priv->allowed_auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN;
self->priv->ip_type = MM_BEARER_IP_FAMILY_NONE;
self->priv->multiplex = MM_BEARER_MULTIPLEX_SUPPORT_UNKNOWN;
}
static void

View File

@@ -72,14 +72,17 @@ void mm_bearer_properties_set_allow_roaming (MMBearerProperties *self,
gboolean allow_roaming);
void mm_bearer_properties_set_rm_protocol (MMBearerProperties *self,
MMModemCdmaRmProtocol protocol);
void mm_bearer_properties_set_multiplex (MMBearerProperties *self,
MMBearerMultiplexSupport multiplex);
const gchar *mm_bearer_properties_get_apn (MMBearerProperties *self);
MMBearerAllowedAuth mm_bearer_properties_get_allowed_auth (MMBearerProperties *self);
const gchar *mm_bearer_properties_get_user (MMBearerProperties *self);
const gchar *mm_bearer_properties_get_password (MMBearerProperties *self);
MMBearerIpFamily mm_bearer_properties_get_ip_type (MMBearerProperties *self);
gboolean mm_bearer_properties_get_allow_roaming (MMBearerProperties *self);
MMModemCdmaRmProtocol mm_bearer_properties_get_rm_protocol (MMBearerProperties *self);
const gchar *mm_bearer_properties_get_apn (MMBearerProperties *self);
MMBearerAllowedAuth mm_bearer_properties_get_allowed_auth (MMBearerProperties *self);
const gchar *mm_bearer_properties_get_user (MMBearerProperties *self);
const gchar *mm_bearer_properties_get_password (MMBearerProperties *self);
MMBearerIpFamily mm_bearer_properties_get_ip_type (MMBearerProperties *self);
gboolean mm_bearer_properties_get_allow_roaming (MMBearerProperties *self);
MMModemCdmaRmProtocol mm_bearer_properties_get_rm_protocol (MMBearerProperties *self);
MMBearerMultiplexSupport mm_bearer_properties_get_multiplex (MMBearerProperties *self);
#ifndef MM_DISABLE_DEPRECATED
G_DEPRECATED

View File

@@ -857,6 +857,16 @@ mm_common_get_eps_ue_mode_operation_from_string (const gchar *str,
error);
}
MMBearerMultiplexSupport
mm_common_get_multiplex_support_from_string (const gchar *str,
GError **error)
{
return _enum_from_string (MM_TYPE_BEARER_MULTIPLEX_SUPPORT,
str,
MM_BEARER_MULTIPLEX_SUPPORT_UNKNOWN,
error);
}
GArray *
mm_common_oma_pending_network_initiated_sessions_variant_to_garray (GVariant *variant)
{

View File

@@ -82,6 +82,9 @@ MMModem3gppEpsUeModeOperation mm_common_get_eps_ue_mode_operation_from_string (c
MMModemAccessTechnology mm_common_get_access_technology_from_string (const gchar *str,
GError **error);
MMBearerMultiplexSupport mm_common_get_multiplex_support_from_string (const gchar *str,
GError **error);
GArray *mm_common_ports_variant_to_garray (GVariant *variant);
MMModemPortInfo *mm_common_ports_variant_to_array (GVariant *variant,
guint *n_ports);

View File

@@ -404,6 +404,44 @@ mm_simple_connect_properties_get_rm_protocol (MMSimpleConnectProperties *self)
/*****************************************************************************/
/**
* mm_simple_connect_properties_set_multiplex:
* @self: a #MMSimpleConnectProperties.
* @multiplex: a #MMBearerMultiplexSupport.
*
* Sets the multiplex support requested by the user.
*
* Since: 1.18
*/
void
mm_simple_connect_properties_set_multiplex (MMSimpleConnectProperties *self,
MMBearerMultiplexSupport multiplex)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
mm_bearer_properties_set_multiplex (self->priv->bearer_properties, multiplex);
}
/**
* mm_simple_connect_properties_get_multiplex:
* @self: a #MMSimpleConnectProperties.
*
* Get the multiplex support requested by the user.
*
* Returns: a #MMBearerMultiplexSupport.
*
* Since: 1.18
*/
MMBearerMultiplexSupport
mm_simple_connect_properties_get_multiplex (MMSimpleConnectProperties *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), MM_BEARER_MULTIPLEX_SUPPORT_UNKNOWN);
return mm_bearer_properties_get_multiplex (self->priv->bearer_properties);
}
/*****************************************************************************/
#ifndef MM_DISABLE_DEPRECATED
/**

View File

@@ -78,16 +78,19 @@ void mm_simple_connect_properties_set_allow_roaming (MMSimpleConnectProperties *
gboolean allow_roaming);
void mm_simple_connect_properties_set_rm_protocol (MMSimpleConnectProperties *self,
MMModemCdmaRmProtocol protocol);
void mm_simple_connect_properties_set_multiplex (MMSimpleConnectProperties *self,
MMBearerMultiplexSupport multiplex);
const gchar *mm_simple_connect_properties_get_pin (MMSimpleConnectProperties *self);
const gchar *mm_simple_connect_properties_get_operator_id (MMSimpleConnectProperties *self);
const gchar *mm_simple_connect_properties_get_apn (MMSimpleConnectProperties *self);
MMBearerAllowedAuth mm_simple_connect_properties_get_allowed_auth (MMSimpleConnectProperties *self);
const gchar *mm_simple_connect_properties_get_user (MMSimpleConnectProperties *self);
const gchar *mm_simple_connect_properties_get_password (MMSimpleConnectProperties *self);
MMBearerIpFamily mm_simple_connect_properties_get_ip_type (MMSimpleConnectProperties *self);
gboolean mm_simple_connect_properties_get_allow_roaming (MMSimpleConnectProperties *self);
MMModemCdmaRmProtocol mm_simple_connect_properties_get_rm_protocol (MMSimpleConnectProperties *self);
const gchar *mm_simple_connect_properties_get_pin (MMSimpleConnectProperties *self);
const gchar *mm_simple_connect_properties_get_operator_id (MMSimpleConnectProperties *self);
const gchar *mm_simple_connect_properties_get_apn (MMSimpleConnectProperties *self);
MMBearerAllowedAuth mm_simple_connect_properties_get_allowed_auth (MMSimpleConnectProperties *self);
const gchar *mm_simple_connect_properties_get_user (MMSimpleConnectProperties *self);
const gchar *mm_simple_connect_properties_get_password (MMSimpleConnectProperties *self);
MMBearerIpFamily mm_simple_connect_properties_get_ip_type (MMSimpleConnectProperties *self);
gboolean mm_simple_connect_properties_get_allow_roaming (MMSimpleConnectProperties *self);
MMModemCdmaRmProtocol mm_simple_connect_properties_get_rm_protocol (MMSimpleConnectProperties *self);
MMBearerMultiplexSupport mm_simple_connect_properties_get_multiplex (MMSimpleConnectProperties *self);
#ifndef MM_DISABLE_DEPRECATED
G_DEPRECATED

View File

@@ -183,6 +183,15 @@ connect (MMBaseBearer *self,
GTask *task;
MMBaseModem *modem = NULL;
task = g_task_new (self, cancellable, callback, user_data);
if (mm_bearer_properties_get_multiplex (mm_base_bearer_peek_config (self)) == MM_BEARER_MULTIPLEX_SUPPORT_REQUIRED) {
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
"Multiplex support not available");
g_object_unref (task);
return;
}
g_object_get (self,
MM_BASE_BEARER_MODEM, &modem,
NULL);
@@ -194,8 +203,6 @@ connect (MMBaseBearer *self,
/* In this context, we only keep the stuff we'll need later */
ctx = g_new0 (ConnectContext, 1);
ctx->primary = mm_base_modem_get_port_primary (modem);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_task_data (task, ctx, (GDestroyNotify) connect_context_free);
/* Bearer service type set to 9600bps (V.110), which behaves better than the

View File

@@ -1125,6 +1125,14 @@ _connect (MMBaseBearer *self,
if (!peek_ports (self, &device, &data, callback, user_data))
return;
if (mm_bearer_properties_get_multiplex (mm_base_bearer_peek_config (self)) == MM_BEARER_MULTIPLEX_SUPPORT_REQUIRED) {
g_task_report_new_error (
self, callback, user_data, _connect,
MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
"Multiplex support not available");
return;
}
g_object_get (self,
MM_BASE_BEARER_MODEM, &modem,
NULL);

View File

@@ -1692,6 +1692,14 @@ _connect (MMBaseBearer *_self,
GTask *task;
GCancellable *operation_cancellable = NULL;
if (mm_bearer_properties_get_multiplex (mm_base_bearer_peek_config (_self)) == MM_BEARER_MULTIPLEX_SUPPORT_REQUIRED) {
g_task_report_new_error (
self, callback, user_data, _connect,
MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
"Multiplex support not available");
goto out;
}
g_object_get (self,
MM_BASE_BEARER_MODEM, &modem,
NULL);