QmiClient * mm_port_qmi_get_client (MMPortQmi *self, QmiService service, MMPortQmiFlag flag) { QmiClient *client; client = mm_port_qmi_peek_client (self, service, flag); return (client ? g_object_ref (client) : NULL); }
static gboolean ensure_qmi_client (GTask *task, MMSimQmi *self, QmiService service, QmiClient **o_client) { MMBaseModem *modem = NULL; QmiClient *client; MMPortQmi *port; g_object_get (self, MM_BASE_SIM_MODEM, &modem, NULL); g_assert (MM_IS_BASE_MODEM (modem)); port = mm_base_modem_peek_port_qmi (modem); g_object_unref (modem); if (!port) { if (task) { g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Couldn't peek QMI port"); g_object_unref (task); } return FALSE; } client = mm_port_qmi_peek_client (port, service, MM_PORT_QMI_FLAG_DEFAULT); if (!client) { if (task) { g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Couldn't peek client for service '%s'", qmi_service_get_string (service)); g_object_unref (task); } return FALSE; } *o_client = client; return TRUE; }
void mm_port_qmi_allocate_client (MMPortQmi *self, QmiService service, MMPortQmiFlag flag, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { AllocateClientContext *ctx; if (!!mm_port_qmi_peek_client (self, service, flag)) { g_simple_async_report_error_in_idle (G_OBJECT (self), callback, user_data, MM_CORE_ERROR, MM_CORE_ERROR_EXISTS, "Client for service '%s' already allocated", qmi_service_get_string (service)); return; } ctx = g_new0 (AllocateClientContext, 1); ctx->self = g_object_ref (self); ctx->result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, mm_port_qmi_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, QMI_CID_NONE, 10, cancellable, (GAsyncReadyCallback)allocate_client_ready, ctx); }