Skip to content
Snippets Groups Projects
Commit bf5245bb authored by Akula Susmitha's avatar Akula Susmitha Committed by Dan Williams
Browse files

messaging: load default storage from modem during initialization

parent 21da676e
No related branches found
No related tags found
1 merge request!1253messaging: load default storage from modem during initialization
Pipeline #1374444 passed
......@@ -7616,6 +7616,104 @@ messaging_load_supported_storages (MMIfaceModemMessaging *_self,
g_object_unref (task);
}
 
/*****************************************************************************/
/* Init current SMS storages (Messaging interface) */
static gboolean
messaging_init_current_storages_finish (MMIfaceModemMessaging *_self,
GAsyncResult *res,
MMSmsStorage *current_storage,
GError **error)
{
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
gssize result;
/* Handle AT URC only fallback */
if (self->priv->messaging_fallback_at_only) {
return iface_modem_messaging_parent->init_current_storages_finish (_self, res, current_storage, error);
}
result = g_task_propagate_int (G_TASK (res), error);
if (result < 0)
return FALSE;
if (current_storage)
*current_storage = (MMSmsStorage)result;
return TRUE;
}
static void
wms_get_routes_ready (QmiClientWms *client,
GAsyncResult *res,
GTask *task)
{
g_autoptr(QmiMessageWmsGetRoutesOutput) output = NULL;
GError *error = NULL;
GArray *route_list;
guint i;
MMSmsStorage storage = MM_SMS_STORAGE_UNKNOWN;
MMBroadbandModemQmi *self;
self = g_task_get_source_object (task);
output = qmi_client_wms_get_routes_finish (client, res, &error);
if (!output) {
g_prefix_error (&error, "QMI operation failed: ");
g_task_return_error (task, error);
} else if (!qmi_message_wms_get_routes_output_get_result (output, &error)) {
g_prefix_error (&error, "Couldn't get SMS routes: ");
g_task_return_error (task, error);
} else if (!qmi_message_wms_get_routes_output_get_route_list (output, &route_list, &error)) {
g_prefix_error (&error, "got invalid SMS routes: ");
g_task_return_error (task, error);
} else {
for (i = 0; i < route_list->len; i++) {
QmiMessageWmsGetRoutesOutputRouteListElement *route;
route = &g_array_index (route_list, QmiMessageWmsGetRoutesOutputRouteListElement, i);
if ((route->message_class == QMI_WMS_MESSAGE_CLASS_0 ||
route->message_class == QMI_WMS_MESSAGE_CLASS_1) &&
(route->receipt_action == QMI_WMS_RECEIPT_ACTION_STORE_AND_NOTIFY)) {
storage = mm_sms_storage_from_qmi_storage_type (route->storage);
}
mm_obj_dbg (self, "Default route defined for SMS Messaging is set to store at: %s",
mm_sms_storage_get_string (storage));
}
g_task_return_int (task, storage);
}
g_object_unref (task);
}
static void
messaging_init_current_storages (MMIfaceModemMessaging *_self,
GAsyncReadyCallback callback,
gpointer user_data)
{
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
QmiClient *client = NULL;
/* Handle AT URC only fallback */
if (self->priv->messaging_fallback_at_only) {
iface_modem_messaging_parent->init_current_storages (_self, callback, user_data);
return;
}
if (!mm_shared_qmi_ensure_client (MM_SHARED_QMI (self),
QMI_SERVICE_WMS, &client,
callback, user_data))
return;
mm_obj_dbg (self, "getting default messaging routes...");
qmi_client_wms_get_routes (QMI_CLIENT_WMS (client),
NULL,
5,
NULL,
(GAsyncReadyCallback)wms_get_routes_ready,
g_task_new (self, NULL, callback, user_data));
}
/*****************************************************************************/
/* Setup SMS format (Messaging interface) */
 
......@@ -13987,6 +14085,8 @@ iface_modem_messaging_init (MMIfaceModemMessagingInterface *iface)
iface->disable_unsolicited_events = messaging_disable_unsolicited_events;
iface->disable_unsolicited_events_finish = messaging_disable_unsolicited_events_finish;
iface->create_sms = messaging_create_sms;
iface->init_current_storages = messaging_init_current_storages;
iface->init_current_storages_finish = messaging_init_current_storages_finish;
}
 
static void
......
......@@ -6981,9 +6981,18 @@ modem_messaging_load_supported_storages (MMIfaceModemMessaging *self,
static gboolean
modem_messaging_init_current_storages_finish (MMIfaceModemMessaging *_self,
GAsyncResult *res,
MMSmsStorage *current_storage,
GError **error)
{
return g_task_propagate_boolean (G_TASK (res), error);
gssize result;
result = g_task_propagate_int (G_TASK (res), error);
if (result < 0)
return FALSE;
if (current_storage)
*current_storage = (MMSmsStorage)result;
return TRUE;
}
 
static void
......@@ -7025,7 +7034,7 @@ cpms_query_ready (MMBroadbandModem *self,
mm_obj_dbg (self, " mem2 (write/send) storages: '%s'", aux);
g_free (aux);
 
g_task_return_boolean (task, TRUE);
g_task_return_int (task, mem2);
}
g_object_unref (task);
}
......
......@@ -1041,17 +1041,26 @@ interface_enabling_step (GTask *task)
case ENABLING_STEP_STORAGE_DEFAULTS: {
MMSmsStorage default_storage;
/* Is there only one single storage supported? if so, we don't care if
* setting default storage is implemented or not. */
default_storage = get_single_default_sms_storage (self);
if (default_storage == MM_SMS_STORAGE_UNKNOWN)
default_storage = get_best_initial_default_sms_storage (self);
/* Already bound to the 'default-storage' property in the skeleton */
g_object_set (self,
MM_IFACE_MODEM_MESSAGING_SMS_DEFAULT_STORAGE, default_storage,
/* Get default storage that is set by init_current_storage */
g_object_get (self,
MM_IFACE_MODEM_MESSAGING_SMS_DEFAULT_STORAGE, &default_storage,
NULL);
/* if current_storage is set to unknown, get the best initial
* default_storage */
if (default_storage == MM_SMS_STORAGE_UNKNOWN) {
/* Is there only one single storage supported? if so, we don't care if
* setting default storage is implemented or not. */
default_storage = get_single_default_sms_storage (self);
if (default_storage == MM_SMS_STORAGE_UNKNOWN)
default_storage = get_best_initial_default_sms_storage (self);
/* Already bound to the 'default-storage' property in the skeleton */
g_object_set (self,
MM_IFACE_MODEM_MESSAGING_SMS_DEFAULT_STORAGE, default_storage,
NULL);
}
if (default_storage == MM_SMS_STORAGE_UNKNOWN)
mm_obj_warn (self, "cannot set default storage, none of the suggested ones supported");
else if (MM_IFACE_MODEM_MESSAGING_GET_IFACE (self)->set_default_storage &&
......@@ -1300,15 +1309,21 @@ init_current_storages_ready (MMIfaceModemMessaging *self,
{
InitializationContext *ctx;
GError *error = NULL;
MMSmsStorage current_storage = MM_SMS_STORAGE_UNKNOWN;
if (!MM_IFACE_MODEM_MESSAGING_GET_IFACE (self)->init_current_storages_finish (
self,
res,
&current_storage,
&error)) {
mm_obj_dbg (self, "couldn't initialize current storages: %s", error->message);
g_error_free (error);
} else
} else {
g_object_set (self,
MM_IFACE_MODEM_MESSAGING_SMS_DEFAULT_STORAGE, current_storage,
NULL);
mm_obj_dbg (self, "current storages initialized");
}
/* Go on to next step */
ctx = g_task_get_task_data (task);
......
......@@ -66,6 +66,7 @@ struct _MMIfaceModemMessagingInterface {
gpointer user_data);
gboolean (*init_current_storages_finish) (MMIfaceModemMessaging *self,
GAsyncResult *res,
MMSmsStorage *current_storage,
GError **error);
/* Set default storage (async) */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment