api,modem: new 'MaxActiveMultiplexedBearers' property
In addition to the amount of bearers a user may connect without multiplexing enabled (the default until now), we now also expose the maximum number of bearers a user may connect after enabling multiplexing over one single network interface (if supported). The method responsible for creating the MMBearerList is now also subclassable, so that implementations supporting multiplexing can provide their own version with their own thresholds.
This commit is contained in:
+26
-1
@@ -35,6 +35,7 @@ enum {
|
||||
PROP_0,
|
||||
PROP_NUM_BEARERS,
|
||||
PROP_MAX_ACTIVE_BEARERS,
|
||||
PROP_MAX_ACTIVE_MULTIPLEXED_BEARERS,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
@@ -45,6 +46,7 @@ struct _MMBearerListPrivate {
|
||||
GList *bearers;
|
||||
/* Max number of active bearers */
|
||||
guint max_active_bearers;
|
||||
guint max_active_multiplexed_bearers;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -55,6 +57,12 @@ mm_bearer_list_get_max_active (MMBearerList *self)
|
||||
return self->priv->max_active_bearers;
|
||||
}
|
||||
|
||||
guint
|
||||
mm_bearer_list_get_max_active_multiplexed (MMBearerList *self)
|
||||
{
|
||||
return self->priv->max_active_multiplexed_bearers;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_bearer_list_add_bearer (MMBearerList *self,
|
||||
MMBaseBearer *bearer,
|
||||
@@ -238,11 +246,13 @@ mm_bearer_list_disconnect_all_bearers (MMBearerList *self,
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBearerList *
|
||||
mm_bearer_list_new (guint max_active_bearers)
|
||||
mm_bearer_list_new (guint max_active_bearers,
|
||||
guint max_active_multiplexed_bearers)
|
||||
{
|
||||
/* Create the object */
|
||||
return g_object_new (MM_TYPE_BEARER_LIST,
|
||||
MM_BEARER_LIST_MAX_ACTIVE_BEARERS, max_active_bearers,
|
||||
MM_BEARER_LIST_MAX_ACTIVE_MULTIPLEXED_BEARERS, max_active_multiplexed_bearers,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -261,6 +271,9 @@ set_property (GObject *object,
|
||||
case PROP_MAX_ACTIVE_BEARERS:
|
||||
self->priv->max_active_bearers = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_MAX_ACTIVE_MULTIPLEXED_BEARERS:
|
||||
self->priv->max_active_multiplexed_bearers = g_value_get_uint (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -282,6 +295,9 @@ get_property (GObject *object,
|
||||
case PROP_MAX_ACTIVE_BEARERS:
|
||||
g_value_set_uint (value, self->priv->max_active_bearers);
|
||||
break;
|
||||
case PROP_MAX_ACTIVE_MULTIPLEXED_BEARERS:
|
||||
g_value_set_uint (value, self->priv->max_active_multiplexed_bearers);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -342,4 +358,13 @@ mm_bearer_list_class_init (MMBearerListClass *klass)
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_MAX_ACTIVE_BEARERS, properties[PROP_MAX_ACTIVE_BEARERS]);
|
||||
|
||||
properties[PROP_MAX_ACTIVE_MULTIPLEXED_BEARERS] =
|
||||
g_param_spec_uint (MM_BEARER_LIST_MAX_ACTIVE_MULTIPLEXED_BEARERS,
|
||||
"Max active multiplexed bearers",
|
||||
"Maximum number of active multiplexed bearers the list can handle",
|
||||
1,
|
||||
G_MAXUINT,
|
||||
1,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_MAX_ACTIVE_MULTIPLEXED_BEARERS, properties[PROP_MAX_ACTIVE_MULTIPLEXED_BEARERS]);
|
||||
}
|
||||
|
||||
@@ -30,8 +30,9 @@
|
||||
#define MM_IS_BEARER_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BEARER_LIST))
|
||||
#define MM_BEARER_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BEARER_LIST, MMBearerListClass))
|
||||
|
||||
#define MM_BEARER_LIST_NUM_BEARERS "num-bearers"
|
||||
#define MM_BEARER_LIST_MAX_ACTIVE_BEARERS "max-active-bearers"
|
||||
#define MM_BEARER_LIST_NUM_BEARERS "num-bearers"
|
||||
#define MM_BEARER_LIST_MAX_ACTIVE_BEARERS "max-active-bearers"
|
||||
#define MM_BEARER_LIST_MAX_ACTIVE_MULTIPLEXED_BEARERS "max-active-multiplexed-bearers"
|
||||
|
||||
typedef struct _MMBearerList MMBearerList;
|
||||
typedef struct _MMBearerListClass MMBearerListClass;
|
||||
@@ -49,10 +50,12 @@ struct _MMBearerListClass {
|
||||
GType mm_bearer_list_get_type (void);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMBearerList, g_object_unref)
|
||||
|
||||
MMBearerList *mm_bearer_list_new (guint max_active_bearers);
|
||||
MMBearerList *mm_bearer_list_new (guint max_active_bearers,
|
||||
guint max_active_multiplexed_bearers);
|
||||
|
||||
GStrv mm_bearer_list_get_paths (MMBearerList *self);
|
||||
guint mm_bearer_list_get_max_active (MMBearerList *self);
|
||||
GStrv mm_bearer_list_get_paths (MMBearerList *self);
|
||||
guint mm_bearer_list_get_max_active (MMBearerList *self);
|
||||
guint mm_bearer_list_get_max_active_multiplexed (MMBearerList *self);
|
||||
|
||||
gboolean mm_bearer_list_add_bearer (MMBearerList *self,
|
||||
MMBaseBearer *bearer,
|
||||
|
||||
@@ -417,6 +417,23 @@ modem_create_bearer (MMIfaceModem *self,
|
||||
task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Create Bearer List (Modem interface) */
|
||||
|
||||
static MMBearerList *
|
||||
modem_create_bearer_list (MMIfaceModem *self)
|
||||
{
|
||||
guint n;
|
||||
|
||||
/* The maximum number of available/connected modems is guessed from
|
||||
* the size of the data ports list. */
|
||||
n = g_list_length (mm_base_modem_peek_data_ports (MM_BASE_MODEM (self)));
|
||||
mm_obj_dbg (self, "allowed up to %u active bearers", n);
|
||||
|
||||
/* by default, no multiplexing support */
|
||||
return mm_bearer_list_new (n, 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Create SIM (Modem interface) */
|
||||
|
||||
@@ -12425,6 +12442,7 @@ iface_modem_init (MMIfaceModem *iface)
|
||||
iface->load_power_state_finish = modem_load_power_state_finish;
|
||||
iface->load_supported_ip_families = modem_load_supported_ip_families;
|
||||
iface->load_supported_ip_families_finish = modem_load_supported_ip_families_finish;
|
||||
iface->create_bearer_list = modem_create_bearer_list;
|
||||
|
||||
/* Enabling steps */
|
||||
iface->modem_power_up = modem_power_up;
|
||||
|
||||
+12
-21
@@ -5083,47 +5083,38 @@ interface_initialization_step (GTask *task)
|
||||
/* fall-through */
|
||||
|
||||
case INITIALIZATION_STEP_BEARERS: {
|
||||
MMBearerList *list = NULL;
|
||||
g_autoptr(MMBearerList) list = NULL;
|
||||
|
||||
/* Bearers setup is meant to be loaded only once during the whole
|
||||
* lifetime of the modem. The list may have been created by the object
|
||||
* implementing the interface; if so use it. */
|
||||
* lifetime of the modem, so check if it exists; and if it doesn't,
|
||||
* create it right away. */
|
||||
g_object_get (self,
|
||||
MM_IFACE_MODEM_BEARER_LIST, &list,
|
||||
NULL);
|
||||
|
||||
if (!list) {
|
||||
guint n;
|
||||
|
||||
/* The maximum number of available/connected modems is guessed from
|
||||
* the size of the data ports list. */
|
||||
n = g_list_length (mm_base_modem_peek_data_ports (MM_BASE_MODEM (self)));
|
||||
mm_obj_dbg (self, "allowed up to %u active bearers", n);
|
||||
|
||||
/* Create new default list */
|
||||
list = mm_bearer_list_new (n);
|
||||
list = MM_IFACE_MODEM_GET_INTERFACE (self)->create_bearer_list (self);
|
||||
g_signal_connect (list,
|
||||
"notify::" MM_BEARER_LIST_NUM_BEARERS,
|
||||
G_CALLBACK (bearer_list_updated),
|
||||
self);
|
||||
g_object_set (self,
|
||||
MM_IFACE_MODEM_BEARER_LIST, list,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (mm_gdbus_modem_get_max_active_bearers (ctx->skeleton) == 0)
|
||||
mm_gdbus_modem_set_max_active_bearers (
|
||||
ctx->skeleton,
|
||||
mm_bearer_list_get_max_active (list));
|
||||
mm_gdbus_modem_set_max_active_multiplexed_bearers (
|
||||
ctx->skeleton,
|
||||
mm_bearer_list_get_max_active_multiplexed (list));
|
||||
|
||||
/* MaxBearers set equal to MaxActiveBearers */
|
||||
if (mm_gdbus_modem_get_max_bearers (ctx->skeleton) == 0)
|
||||
/* MaxBearers set equal to MaxActiveBearers */
|
||||
mm_gdbus_modem_set_max_bearers (
|
||||
ctx->skeleton,
|
||||
mm_gdbus_modem_get_max_active_bearers (ctx->skeleton));
|
||||
|
||||
g_object_unref (list);
|
||||
|
||||
g_object_set (self,
|
||||
MM_IFACE_MODEM_BEARER_LIST, list,
|
||||
NULL);
|
||||
}
|
||||
ctx->step++;
|
||||
} /* fall-through */
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "mm-port-serial-at.h"
|
||||
#include "mm-base-bearer.h"
|
||||
#include "mm-base-sim.h"
|
||||
#include "mm-bearer-list.h"
|
||||
|
||||
#define MM_TYPE_IFACE_MODEM (mm_iface_modem_get_type ())
|
||||
#define MM_IFACE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_IFACE_MODEM, MMIfaceModem))
|
||||
@@ -372,6 +373,10 @@ struct _MMIfaceModem {
|
||||
MMBaseBearer * (*create_bearer_finish) (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
/* Create new bearer list object */
|
||||
MMBearerList * (* create_bearer_list) (MMIfaceModem *self);
|
||||
|
||||
/* Setup SIM hot swap */
|
||||
void (*setup_sim_hot_swap) (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
|
||||
Reference in New Issue
Block a user