aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-09-10 12:42:54 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-09-14 07:05:22 +0200
commit83dc9e3e1d32eb72ed60163a066c20d553f4c468 (patch)
treea4b3f0b07c03a3908cf9e44ee1b7d645e306c75a
parentbfa742ae13f36150e7b08fa0e9428a4a4f0f1d96 (diff)
iface-modem-messaging: new methods to check support for storage actions
We can now check whether a specific storage is valid for receiving or storing.
-rw-r--r--src/mm-iface-modem-messaging.c60
-rw-r--r--src/mm-iface-modem-messaging.h8
2 files changed, 51 insertions, 17 deletions
diff --git a/src/mm-iface-modem-messaging.c b/src/mm-iface-modem-messaging.c
index 75e42e47..77665c28 100644
--- a/src/mm-iface-modem-messaging.c
+++ b/src/mm-iface-modem-messaging.c
@@ -365,21 +365,10 @@ mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self,
/*****************************************************************************/
-gboolean
-mm_iface_modem_messaging_set_preferred_storages_finish (MMIfaceModemMessaging *self,
- GAsyncResult *res,
- GError **error)
-{
- if (MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->set_preferred_storages_finish)
- return MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->set_preferred_storages_finish (self, res, error);
-
- return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
-}
-
static gboolean
is_storage_supported (GArray *supported,
MMSmsStorage preferred,
- const gchar *name,
+ const gchar *action,
GError **error)
{
guint i;
@@ -398,12 +387,49 @@ is_storage_supported (GArray *supported,
g_set_error (error,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
- "Storage '%s' is not supported in '%s'",
+ "Storage '%s' is not supported for %s",
mm_sms_storage_get_string (preferred),
- name);
+ action);
return FALSE;
}
+gboolean
+mm_iface_modem_messaging_is_storage_supported_for_storing (MMIfaceModemMessaging *self,
+ MMSmsStorage storage,
+ GError **error)
+{
+ /* mem2 is for storing */
+ return is_storage_supported ((get_storage_context (self))->supported_mem2,
+ storage,
+ "storing",
+ error);
+}
+
+gboolean
+mm_iface_modem_messaging_is_storage_supported_for_receiving (MMIfaceModemMessaging *self,
+ MMSmsStorage storage,
+ GError **error)
+{
+ /* mem3 is for receiving */
+ return is_storage_supported ((get_storage_context (self))->supported_mem3,
+ storage,
+ "receiving",
+ error);
+}
+
+/*****************************************************************************/
+
+gboolean
+mm_iface_modem_messaging_set_preferred_storages_finish (MMIfaceModemMessaging *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ if (MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->set_preferred_storages_finish)
+ return MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->set_preferred_storages_finish (self, res, error);
+
+ return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
+}
+
void
mm_iface_modem_messaging_set_preferred_storages (MMIfaceModemMessaging *self,
MMSmsStorage mem1,
@@ -431,9 +457,9 @@ mm_iface_modem_messaging_set_preferred_storages (MMIfaceModemMessaging *self,
/* Check if the requested storages are really supported */
ctx = get_storage_context (self);
- if (!is_storage_supported (ctx->supported_mem1, mem1, "mem1", &error) ||
- !is_storage_supported (ctx->supported_mem2, mem2, "mem2", &error) ||
- !is_storage_supported (ctx->supported_mem3, mem3, "mem3", &error)) {
+ if (!is_storage_supported (ctx->supported_mem1, mem1, "reading/listing/deleting", &error) ||
+ !is_storage_supported (ctx->supported_mem2, mem2, "storing", &error) ||
+ !is_storage_supported (ctx->supported_mem3, mem3, "receiving", &error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (self),
callback,
user_data,
diff --git a/src/mm-iface-modem-messaging.h b/src/mm-iface-modem-messaging.h
index 23deafc7..1f2537d0 100644
--- a/src/mm-iface-modem-messaging.h
+++ b/src/mm-iface-modem-messaging.h
@@ -180,6 +180,14 @@ gboolean mm_iface_modem_messaging_set_preferred_storages_finish (MMIfaceModemMes
GAsyncResult *res,
GError **error);
+/* Check storage support */
+gboolean mm_iface_modem_messaging_is_storage_supported_for_storing (MMIfaceModemMessaging *self,
+ MMSmsStorage storage,
+ GError **error);
+gboolean mm_iface_modem_messaging_is_storage_supported_for_receiving (MMIfaceModemMessaging *self,
+ MMSmsStorage storage,
+ GError **error);
+
/* SMS creation */
MMSms *mm_iface_modem_messaging_create_sms (MMIfaceModemMessaging *self);