broadband-modem: implement default SMS storage loading

This commit is contained in:
Aleksander Morgado
2012-03-15 14:15:03 +01:00
parent 7fb1234015
commit 55ba297fb8
+108
View File
@@ -3502,6 +3502,112 @@ modem_messaging_check_support (MMIfaceModemMessaging *self,
result);
}
/*****************************************************************************/
/* Load supported SMS storages (Messaging interface) */
typedef struct {
GArray *mem1;
GArray *mem2;
GArray *mem3;
} SupportedStoragesResult;
static void
supported_storages_result_free (SupportedStoragesResult *result)
{
if (result->mem1)
g_array_unref (result->mem1);
if (result->mem2)
g_array_unref (result->mem2);
if (result->mem3)
g_array_unref (result->mem3);
g_free (result);
}
static gboolean
modem_messaging_load_supported_storages_finish (MMIfaceModemMessaging *self,
GAsyncResult *res,
GArray **mem1,
GArray **mem2,
GArray **mem3,
GError **error)
{
SupportedStoragesResult *result;
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
return FALSE;
result = (SupportedStoragesResult *)g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
*mem1 = g_array_ref (result->mem1);
*mem2 = g_array_ref (result->mem2);
*mem3 = g_array_ref (result->mem3);
return TRUE;
}
static void
cpms_format_check_ready (MMBroadbandModem *self,
GAsyncResult *res,
GSimpleAsyncResult *simple)
{
const gchar *response;
GError *error = NULL;
SupportedStoragesResult *result;
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
if (error) {
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
return;
}
result = g_new0 (SupportedStoragesResult, 1);
/* Parse reply */
if (!mm_3gpp_parse_cpms_format_response (response,
&result->mem1,
&result->mem2,
&result->mem3)) {
g_simple_async_result_set_error (simple,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Couldn't parse supported storages reply: '%s'",
response);
supported_storages_result_free (result);
g_simple_async_result_complete (simple);
g_object_unref (simple);
return;
}
g_simple_async_result_set_op_res_gpointer (simple,
result,
(GDestroyNotify)supported_storages_result_free);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
static void
modem_messaging_load_supported_storages (MMIfaceModemMessaging *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
modem_messaging_load_supported_storages);
/* Check support storages */
mm_base_modem_at_command (MM_BASE_MODEM (self),
"+CPMS=?",
3,
TRUE,
NULL, /* cancellable */
(GAsyncReadyCallback)cpms_format_check_ready,
result);
}
/*****************************************************************************/
/* Setup SMS format (Messaging interface) */
@@ -6467,6 +6573,8 @@ iface_modem_messaging_init (MMIfaceModemMessaging *iface)
{
iface->check_support = modem_messaging_check_support;
iface->check_support_finish = modem_messaging_check_support_finish;
iface->load_supported_storages = modem_messaging_load_supported_storages;
iface->load_supported_storages_finish = modem_messaging_load_supported_storages_finish;
iface->setup_sms_format = modem_messaging_setup_sms_format;
iface->setup_sms_format_finish = modem_messaging_setup_sms_format_finish;
iface->load_initial_sms_parts = modem_messaging_load_initial_sms_parts;