qmi-port: allow allocating more than one client of a given service
We'll uniquely identify each client generated by the service ID and a user defined flag, so that we then allow to peek/get the specific client.
This commit is contained in:
+7
-2
@@ -248,7 +248,9 @@ qmi_port_allocate_client_ready (MMQmiPort *qmi,
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->client = QMI_CLIENT_WDS (mm_qmi_port_get_client (qmi, QMI_SERVICE_WDS));
|
||||
ctx->client = QMI_CLIENT_WDS (mm_qmi_port_get_client (qmi,
|
||||
QMI_SERVICE_WDS,
|
||||
MM_QMI_PORT_FLAG_DEFAULT));
|
||||
|
||||
/* Keep on */
|
||||
ctx->step++;
|
||||
@@ -309,10 +311,13 @@ connect_context_step (ConnectContext *ctx)
|
||||
case CONNECT_STEP_WDS_CLIENT: {
|
||||
QmiClient *client;
|
||||
|
||||
client = mm_qmi_port_get_client (ctx->qmi, QMI_SERVICE_WDS);
|
||||
client = mm_qmi_port_get_client (ctx->qmi,
|
||||
QMI_SERVICE_WDS,
|
||||
MM_QMI_PORT_FLAG_DEFAULT);
|
||||
if (!client) {
|
||||
mm_qmi_port_allocate_client (ctx->qmi,
|
||||
QMI_SERVICE_WDS,
|
||||
MM_QMI_PORT_FLAG_DEFAULT,
|
||||
ctx->cancellable,
|
||||
(GAsyncReadyCallback)qmi_port_allocate_client_ready,
|
||||
ctx);
|
||||
|
||||
@@ -90,7 +90,9 @@ ensure_qmi_client (MMBroadbandModemQmi *self,
|
||||
{
|
||||
QmiClient *client;
|
||||
|
||||
client = mm_qmi_port_peek_client (mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self)), service);
|
||||
client = mm_qmi_port_peek_client (mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self)),
|
||||
service,
|
||||
MM_QMI_PORT_FLAG_DEFAULT);
|
||||
if (!client) {
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (self),
|
||||
callback,
|
||||
@@ -5097,6 +5099,7 @@ allocate_next_client (InitializationStartedContext *ctx)
|
||||
/* Otherwise, allocate next client */
|
||||
mm_qmi_port_allocate_client (ctx->qmi,
|
||||
ctx->services[ctx->service_index],
|
||||
MM_QMI_PORT_FLAG_DEFAULT,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)qmi_port_allocate_client_ready,
|
||||
ctx);
|
||||
|
||||
+11
-5
@@ -29,6 +29,7 @@ G_DEFINE_TYPE (MMQmiPort, mm_qmi_port, MM_TYPE_PORT)
|
||||
typedef struct {
|
||||
QmiService service;
|
||||
QmiClient *client;
|
||||
MMQmiPortFlag flag;
|
||||
} ServiceInfo;
|
||||
|
||||
struct _MMQmiPortPrivate {
|
||||
@@ -41,14 +42,16 @@ struct _MMQmiPortPrivate {
|
||||
|
||||
QmiClient *
|
||||
mm_qmi_port_peek_client (MMQmiPort *self,
|
||||
QmiService service)
|
||||
QmiService service,
|
||||
MMQmiPortFlag flag)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
for (l = self->priv->services; l; l = g_list_next (l)) {
|
||||
ServiceInfo *info = l->data;
|
||||
|
||||
if (info->service == service)
|
||||
if (info->service == service &&
|
||||
info->flag == flag)
|
||||
return info->client;
|
||||
}
|
||||
|
||||
@@ -57,11 +60,12 @@ mm_qmi_port_peek_client (MMQmiPort *self,
|
||||
|
||||
QmiClient *
|
||||
mm_qmi_port_get_client (MMQmiPort *self,
|
||||
QmiService service)
|
||||
QmiService service,
|
||||
MMQmiPortFlag flag)
|
||||
{
|
||||
QmiClient *client;
|
||||
|
||||
client = mm_qmi_port_peek_client (self, service);
|
||||
client = mm_qmi_port_peek_client (self, service, flag);
|
||||
return (client ? g_object_ref (client) : NULL);
|
||||
}
|
||||
|
||||
@@ -120,13 +124,14 @@ allocate_client_ready (QmiDevice *qmi_device,
|
||||
void
|
||||
mm_qmi_port_allocate_client (MMQmiPort *self,
|
||||
QmiService service,
|
||||
MMQmiPortFlag flag,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
AllocateClientContext *ctx;
|
||||
|
||||
if (!!mm_qmi_port_peek_client (self, service)) {
|
||||
if (!!mm_qmi_port_peek_client (self, service, flag)) {
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -145,6 +150,7 @@ mm_qmi_port_allocate_client (MMQmiPort *self,
|
||||
mm_qmi_port_allocate_client);
|
||||
ctx->info = g_new0 (ServiceInfo, 1);
|
||||
ctx->info->service = service;
|
||||
ctx->info->flag = flag;
|
||||
|
||||
qmi_device_allocate_client (self->priv->qmi_device,
|
||||
service,
|
||||
|
||||
+9
-2
@@ -58,8 +58,13 @@ gboolean mm_qmi_port_open_finish (MMQmiPort *self,
|
||||
gboolean mm_qmi_port_is_open (MMQmiPort *self);
|
||||
void mm_qmi_port_close (MMQmiPort *self);
|
||||
|
||||
typedef enum {
|
||||
MM_QMI_PORT_FLAG_DEFAULT = 0
|
||||
} MMQmiPortFlag;
|
||||
|
||||
void mm_qmi_port_allocate_client (MMQmiPort *self,
|
||||
QmiService service,
|
||||
MMQmiPortFlag flag,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
@@ -68,8 +73,10 @@ gboolean mm_qmi_port_allocate_client_finish (MMQmiPort *self,
|
||||
GError **error);
|
||||
|
||||
QmiClient *mm_qmi_port_peek_client (MMQmiPort *self,
|
||||
QmiService service);
|
||||
QmiService service,
|
||||
MMQmiPortFlag flag);
|
||||
QmiClient *mm_qmi_port_get_client (MMQmiPort *self,
|
||||
QmiService service);
|
||||
QmiService service,
|
||||
MMQmiPortFlag flag);
|
||||
|
||||
#endif /* MM_QMI_PORT_H */
|
||||
|
||||
+3
-1
@@ -45,7 +45,9 @@ ensure_qmi_client (MMSimQmi *self,
|
||||
NULL);
|
||||
g_assert (MM_IS_BASE_MODEM (modem));
|
||||
|
||||
client = mm_qmi_port_peek_client (mm_base_modem_peek_port_qmi (modem), service);
|
||||
client = mm_qmi_port_peek_client (mm_base_modem_peek_port_qmi (modem),
|
||||
service,
|
||||
MM_QMI_PORT_FLAG_DEFAULT);
|
||||
if (!client)
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (self),
|
||||
callback,
|
||||
|
||||
Reference in New Issue
Block a user