introspection,api: new 'Messages' property in the Messaging interface

https://bugzilla.gnome.org/show_bug.cgi?id=712276
This commit is contained in:
Aleksander Morgado
2013-11-15 19:33:04 +01:00
parent 7f442b777c
commit f7546ad824
4 changed files with 37 additions and 36 deletions

View File

@@ -95,6 +95,13 @@
<arg name="path" type="o" />
</signal>
<!--
Messages:
The list of SMS object paths.
-->
<property name="Messages" type="ao" access="read" />
<!--
SupportedStorages:

View File

@@ -236,7 +236,7 @@ sms_object_list_free (GList *list)
static void
list_sms_context_complete_and_free (ListSmsContext *ctx)
{
g_simple_async_result_complete (ctx->result);
g_simple_async_result_complete_in_idle (ctx->result);
g_strfreev (ctx->sms_paths);
sms_object_list_free (ctx->sms_objects);
@@ -331,32 +331,6 @@ create_next_sms (ListSmsContext *ctx)
NULL);
}
static void
list_ready (MMModemMessaging *self,
GAsyncResult *res,
ListSmsContext *ctx)
{
GError *error = NULL;
mm_gdbus_modem_messaging_call_list_finish (MM_GDBUS_MODEM_MESSAGING (self), &ctx->sms_paths, res, &error);
if (error) {
g_simple_async_result_take_error (ctx->result, error);
list_sms_context_complete_and_free (ctx);
return;
}
/* If no SMS, just end here. */
if (!ctx->sms_paths || !ctx->sms_paths[0]) {
g_simple_async_result_set_op_res_gpointer (ctx->result, NULL, NULL);
list_sms_context_complete_and_free (ctx);
return;
}
/* Got list of paths. If at least one found, start creating objects for each */
ctx->i = 0;
create_next_sms (ctx);
}
/**
* mm_modem_messaging_list:
* @self: A #MMModemMessaging.
@@ -390,10 +364,18 @@ mm_modem_messaging_list (MMModemMessaging *self,
if (cancellable)
ctx->cancellable = g_object_ref (cancellable);
mm_gdbus_modem_messaging_call_list (MM_GDBUS_MODEM_MESSAGING (self),
cancellable,
(GAsyncReadyCallback)list_ready,
ctx);
ctx->sms_paths = mm_gdbus_modem_messaging_dup_messages (MM_GDBUS_MODEM_MESSAGING (self));
/* If no SMS, just end here. */
if (!ctx->sms_paths || !ctx->sms_paths[0]) {
g_simple_async_result_set_op_res_gpointer (ctx->result, NULL, NULL);
list_sms_context_complete_and_free (ctx);
return;
}
/* Got list of paths. If at least one found, start creating objects for each */
ctx->i = 0;
create_next_sms (ctx);
}
/**
@@ -420,11 +402,7 @@ mm_modem_messaging_list_sync (MMModemMessaging *self,
g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), NULL);
if (!mm_gdbus_modem_messaging_call_list_sync (MM_GDBUS_MODEM_MESSAGING (self),
&sms_paths,
cancellable,
error))
return NULL;
sms_paths = mm_gdbus_modem_messaging_dup_messages (MM_GDBUS_MODEM_MESSAGING (self));
/* Only non-empty lists are returned */
if (!sms_paths)

View File

@@ -489,6 +489,17 @@ mm_iface_modem_messaging_is_storage_supported_for_receiving (MMIfaceModemMessagi
/*****************************************************************************/
static void
update_message_list (MmGdbusModemMessaging *skeleton,
MMSmsList *list)
{
gchar **paths;
paths = mm_sms_list_get_paths (list);
mm_gdbus_modem_messaging_set_messages (skeleton, (const gchar *const *)paths);
g_strfreev (paths);
}
static void
sms_added (MMSmsList *list,
const gchar *sms_path,
@@ -498,6 +509,7 @@ sms_added (MMSmsList *list,
mm_dbg ("Added %s SMS at '%s'",
received ? "received" : "local",
sms_path);
update_message_list (skeleton, list);
mm_gdbus_modem_messaging_emit_added (skeleton, sms_path, received);
}
@@ -507,6 +519,7 @@ sms_deleted (MMSmsList *list,
MmGdbusModemMessaging *skeleton)
{
mm_dbg ("Deleted SMS at '%s'", sms_path);
update_message_list (skeleton, list);
mm_gdbus_modem_messaging_emit_deleted (skeleton, sms_path);
}

View File

@@ -225,6 +225,9 @@ mm_sms_list_add_sms (MMSmsList *self,
MMSms *sms)
{
self->priv->list = g_list_prepend (self->priv->list, g_object_ref (sms));
g_signal_emit (self, signals[SIGNAL_ADDED], 0,
mm_sms_get_path (sms),
FALSE);
}
/*****************************************************************************/