[PATCH] sim-mbim: implement operator identifier and name loading

Dan Williams dcbw at redhat.com
Tue Dec 3 08:11:56 PST 2013


Pushed, thanks!

Dan

On Sat, 2013-11-30 at 13:19 -0800, Ben Chan wrote:
> diff --git a/src/mm-sim-mbim.c b/src/mm-sim-mbim.c
> index 66d908a..77e83ea 100644
> --- a/src/mm-sim-mbim.c
> +++ b/src/mm-sim-mbim.c
> @@ -200,6 +200,134 @@ load_imsi (MMSim *self,
>  }
>  
>  /*****************************************************************************/
> +/* Load operator identifier */
> +
> +static gchar *
> +load_operator_identifier_finish (MMSim *self,
> +                                 GAsyncResult *res,
> +                                 GError **error)
> +{
> +    if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
> +        return NULL;
> +    return (gchar *)g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
> +}
> +
> +static void
> +load_operator_identifier_ready (MbimDevice *device,
> +                                GAsyncResult *res,
> +                                GSimpleAsyncResult *simple)
> +{
> +    MbimMessage *response;
> +    GError *error = NULL;
> +    MbimProvider *provider;
> +
> +    response = mbim_device_command_finish (device, res, &error);
> +    if (response &&
> +        mbim_message_command_done_get_result (response, &error) &&
> +        mbim_message_home_provider_response_parse (
> +            response,
> +            &provider,
> +            &error)) {
> +        g_simple_async_result_set_op_res_gpointer (simple, g_strdup (provider->provider_id), NULL);
> +        mbim_provider_free (provider);
> +    } else
> +        g_simple_async_result_take_error (simple, error);
> +
> +    if (response)
> +        mbim_message_unref (response);
> +    g_simple_async_result_complete (simple);
> +    g_object_unref (simple);
> +}
> +
> +static void
> +load_operator_identifier (MMSim *self,
> +                          GAsyncReadyCallback callback,
> +                          gpointer user_data)
> +{
> +    MbimDevice *device;
> +    MbimMessage *message;
> +    GSimpleAsyncResult *result;
> +
> +    if (!peek_device (self, &device, callback, user_data))
> +        return;
> +
> +    result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, load_operator_identifier);
> +
> +    message = mbim_message_home_provider_query_new (NULL);
> +    mbim_device_command (device,
> +                         message,
> +                         10,
> +                         NULL,
> +                         (GAsyncReadyCallback)load_operator_identifier_ready,
> +                         result);
> +    mbim_message_unref (message);
> +}
> +
> +/*****************************************************************************/
> +/* Load operator name */
> +
> +static gchar *
> +load_operator_name_finish (MMSim *self,
> +                           GAsyncResult *res,
> +                           GError **error)
> +{
> +    if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
> +        return NULL;
> +    return (gchar *)g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
> +}
> +
> +static void
> +load_operator_name_ready (MbimDevice *device,
> +                          GAsyncResult *res,
> +                          GSimpleAsyncResult *simple)
> +{
> +    MbimMessage *response;
> +    GError *error = NULL;
> +    MbimProvider *provider;
> +
> +    response = mbim_device_command_finish (device, res, &error);
> +    if (response &&
> +        mbim_message_command_done_get_result (response, &error) &&
> +        mbim_message_home_provider_response_parse (
> +            response,
> +            &provider,
> +            &error)) {
> +        g_simple_async_result_set_op_res_gpointer (simple, g_strdup (provider->provider_name), NULL);
> +        mbim_provider_free (provider);
> +    } else
> +        g_simple_async_result_take_error (simple, error);
> +
> +    if (response)
> +        mbim_message_unref (response);
> +    g_simple_async_result_complete (simple);
> +    g_object_unref (simple);
> +}
> +
> +static void
> +load_operator_name (MMSim *self,
> +                    GAsyncReadyCallback callback,
> +                    gpointer user_data)
> +{
> +    MbimDevice *device;
> +    MbimMessage *message;
> +    GSimpleAsyncResult *result;
> +
> +    if (!peek_device (self, &device, callback, user_data))
> +        return;
> +
> +    result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, load_operator_name);
> +
> +    message = mbim_message_home_provider_query_new (NULL);
> +    mbim_device_command (device,
> +                         message,
> +                         10,
> +                         NULL,
> +                         (GAsyncReadyCallback)load_operator_name_ready,
> +                         result);
> +    mbim_message_unref (message);
> +}
> +
> +/*****************************************************************************/
>  /* Send PIN */
>  
>  static gboolean
> @@ -594,6 +722,10 @@ mm_sim_mbim_class_init (MMSimMbimClass *klass)
>      sim_class->load_sim_identifier_finish = load_sim_identifier_finish;
>      sim_class->load_imsi = load_imsi;
>      sim_class->load_imsi_finish = load_imsi_finish;
> +    sim_class->load_operator_identifier = load_operator_identifier;
> +    sim_class->load_operator_identifier_finish = load_operator_identifier_finish;
> +    sim_class->load_operator_name = load_operator_name;
> +    sim_class->load_operator_name_finish = load_operator_name_finish;
>      sim_class->send_pin = send_pin;
>      sim_class->send_pin_finish = send_pin_finish;
>      sim_class->send_puk = send_puk;
> @@ -602,10 +734,4 @@ mm_sim_mbim_class_init (MMSimMbimClass *klass)
>      sim_class->enable_pin_finish = enable_pin_finish;
>      sim_class->change_pin = change_pin;
>      sim_class->change_pin_finish = change_pin_finish;
> -
> -    /* TODO: use MBIM_CID_HOME_PROVIDER */
> -    sim_class->load_operator_identifier = NULL;
> -    sim_class->load_operator_identifier_finish = NULL;
> -    sim_class->load_operator_name = NULL;
> -    sim_class->load_operator_name_finish = NULL;
>  }




More information about the ModemManager-devel mailing list