aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-02-09 23:47:10 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-15 14:15:03 +0100
commit55ba297fb8418cde124a5cdc3c1a8837b9e1fd5e (patch)
treee8e348552acd4dfc0b26a83c039e23e5f29e84c4
parent7fb1234015f68d3139400b9ec184e6dae1fe0f78 (diff)
broadband-modem: implement default SMS storage loading
-rw-r--r--src/mm-broadband-modem.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index ecf73a1a..7322e7c9 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -3503,6 +3503,112 @@ modem_messaging_check_support (MMIfaceModemMessaging *self,
}
/*****************************************************************************/
+/* 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) */
static gboolean
@@ -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;