broadband-modem-qmi: load own numbers using QMI
This commit is contained in:
@@ -550,6 +550,83 @@ modem_load_device_identifier (MMIfaceModem *self,
|
||||
g_object_unref (result);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Own Numbers loading (Modem interface) */
|
||||
|
||||
static GStrv
|
||||
modem_load_own_numbers_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
gchar **own_numbers;
|
||||
|
||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||
return NULL;
|
||||
|
||||
own_numbers = g_new0 (gchar *, 2);
|
||||
own_numbers[0] = g_strdup (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
|
||||
mm_dbg ("loaded own numbers: %s", own_numbers[0]);
|
||||
return own_numbers;
|
||||
}
|
||||
|
||||
static void
|
||||
dms_get_msisdn_ready (QmiClientDms *client,
|
||||
GAsyncResult *res,
|
||||
GSimpleAsyncResult *simple)
|
||||
{
|
||||
QmiMessageDmsGetMsisdnOutput *output = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
output = qmi_client_dms_get_msisdn_finish (client, res, &error);
|
||||
if (!output) {
|
||||
g_prefix_error (&error, "QMI operation failed: ");
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
} else if (!qmi_message_dms_get_msisdn_output_get_result (output, &error)) {
|
||||
g_prefix_error (&error, "Couldn't get MSISDN: ");
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
} else {
|
||||
const gchar *str = NULL;
|
||||
|
||||
qmi_message_dms_get_msisdn_output_get_msisdn (output, &str, NULL);
|
||||
g_simple_async_result_set_op_res_gpointer (simple,
|
||||
g_strdup (str),
|
||||
(GDestroyNotify)g_free);
|
||||
}
|
||||
|
||||
if (output)
|
||||
qmi_message_dms_get_msisdn_output_unref (output);
|
||||
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_load_own_numbers (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *result;
|
||||
QmiClient *client = NULL;
|
||||
|
||||
if (!ensure_qmi_client (MM_BROADBAND_MODEM_QMI (self),
|
||||
QMI_SERVICE_DMS, &client,
|
||||
callback, user_data))
|
||||
return;
|
||||
|
||||
result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
modem_load_own_numbers);
|
||||
|
||||
mm_dbg ("loading own numbers...");
|
||||
qmi_client_dms_get_msisdn (QMI_CLIENT_DMS (client),
|
||||
NULL,
|
||||
5,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)dms_get_msisdn_ready,
|
||||
result);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* First initialization step */
|
||||
|
||||
@@ -757,6 +834,8 @@ iface_modem_init (MMIfaceModem *iface)
|
||||
iface->load_equipment_identifier_finish = modem_load_equipment_identifier_finish;
|
||||
iface->load_device_identifier = modem_load_device_identifier;
|
||||
iface->load_device_identifier_finish = modem_load_device_identifier_finish;
|
||||
iface->load_own_numbers = modem_load_own_numbers;
|
||||
iface->load_own_numbers_finish = modem_load_own_numbers_finish;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user