aboutsummaryrefslogtreecommitdiff
path: root/src/mm-iface-modem-messaging.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-02-01 17:01:22 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-15 14:14:59 +0100
commit19ce344df8986b88190f538e7c8a5c8bbd43ac05 (patch)
tree9f8a3e4ce663a0474301db66e1b3b2f62bb28db8 /src/mm-iface-modem-messaging.c
parent7956fc4e17dbc53c602c0723739c6390c4a05541 (diff)
iface-modem-messaging: handle SMS deletion requests
Diffstat (limited to 'src/mm-iface-modem-messaging.c')
-rw-r--r--src/mm-iface-modem-messaging.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/mm-iface-modem-messaging.c b/src/mm-iface-modem-messaging.c
index 71758c45..f63b115b 100644
--- a/src/mm-iface-modem-messaging.c
+++ b/src/mm-iface-modem-messaging.c
@@ -37,6 +37,79 @@ mm_iface_modem_messaging_bind_simple_status (MMIfaceModemMessaging *self,
/*****************************************************************************/
+typedef struct {
+ MmGdbusModemMessaging *skeleton;
+ GDBusMethodInvocation *invocation;
+ MMIfaceModemMessaging *self;
+} DbusCallContext;
+
+static void
+dbus_call_context_free (DbusCallContext *ctx)
+{
+ g_object_unref (ctx->skeleton);
+ g_object_unref (ctx->invocation);
+ g_object_unref (ctx->self);
+ g_free (ctx);
+}
+
+static DbusCallContext *
+dbus_call_context_new (MmGdbusModemMessaging *skeleton,
+ GDBusMethodInvocation *invocation,
+ MMIfaceModemMessaging *self)
+{
+ DbusCallContext *ctx;
+
+ ctx = g_new (DbusCallContext, 1);
+ ctx->skeleton = g_object_ref (skeleton);
+ ctx->invocation = g_object_ref (invocation);
+ ctx->self = g_object_ref (self);
+ return ctx;
+}
+
+/*****************************************************************************/
+
+static void
+delete_sms_ready (MMSmsList *list,
+ GAsyncResult *res,
+ DbusCallContext *ctx)
+{
+ GError *error = NULL;
+
+ if (!mm_sms_list_delete_sms_finish (list, res, &error))
+ g_dbus_method_invocation_take_error (ctx->invocation,
+ error);
+ else
+ mm_gdbus_modem_messaging_complete_delete (ctx->skeleton,
+ ctx->invocation);
+ dbus_call_context_free (ctx);
+}
+
+static gboolean
+handle_delete (MmGdbusModemMessaging *skeleton,
+ GDBusMethodInvocation *invocation,
+ const gchar *path,
+ MMIfaceModemMessaging *self)
+{
+ MMSmsList *list = NULL;
+
+ g_object_get (self,
+ MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
+ NULL);
+ g_assert (list != NULL);
+
+ mm_sms_list_delete_sms (list,
+ path,
+ (GAsyncReadyCallback)delete_sms_ready,
+ dbus_call_context_new (skeleton,
+ invocation,
+ self));
+ g_object_unref (list);
+
+ return TRUE;
+}
+
+/*****************************************************************************/
+
gboolean
mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self,
MMSmsPart *sms_part,
@@ -511,6 +584,12 @@ interface_initialization_step (InitializationContext *ctx)
case INITIALIZATION_STEP_LAST:
/* We are done without errors! */
+ /* Handle method invocations */
+ g_signal_connect (ctx->skeleton,
+ "handle-delete",
+ G_CALLBACK (handle_delete),
+ ctx->self);
+
/* Finally, export the new interface */
mm_gdbus_object_skeleton_set_modem_messaging (MM_GDBUS_OBJECT_SKELETON (ctx->self),
MM_GDBUS_MODEM_MESSAGING (ctx->skeleton));