OSDN Git Service

obexd: Handle message status events
authorChristian Fetzer <christian.fetzer@bmw-carit.de>
Tue, 24 Sep 2013 14:16:03 +0000 (16:16 +0200)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 3 Oct 2013 13:46:41 +0000 (16:46 +0300)
For outgoing messages, the message status is changed when an event
indicates that the sending/delivery has failed or succeeded.

obexd/client/map.c

index a8b12db..20946fe 100644 (file)
@@ -1838,6 +1838,25 @@ static void map_handle_new_message(struct map_data *map,
        map_msg_create(map, event->handle, event->folder, event->msg_type);
 }
 
+static void map_handle_status_changed(struct map_data *map,
+                                                       struct map_event *event,
+                                                       const char *status)
+{
+       struct map_msg *msg = g_hash_table_lookup(map->messages, event->handle);
+
+       if (msg == NULL)
+               return;
+
+       if (g_strcmp0(msg->status, status) == 0)
+               return;
+
+       g_free(msg->status);
+       msg->status = g_strdup(status);
+
+       g_dbus_emit_property_changed(conn, msg->path, MAP_MSG_INTERFACE,
+                                                               "Status");
+}
+
 static void map_handle_notification(struct map_event *event, void *user_data)
 {
        struct map_data *map = user_data;
@@ -1852,6 +1871,18 @@ static void map_handle_notification(struct map_event *event, void *user_data)
        case MAP_ET_NEW_MESSAGE:
                map_handle_new_message(map, event);
                break;
+       case MAP_ET_DELIVERY_SUCCESS:
+               map_handle_status_changed(map, event, "delivery-success");
+               break;
+       case MAP_ET_SENDING_SUCCESS:
+               map_handle_status_changed(map, event, "sending-success");
+               break;
+       case MAP_ET_DELIVERY_FAILURE:
+               map_handle_status_changed(map, event, "delivery-failure");
+               break;
+       case MAP_ET_SENDING_FAILURE:
+               map_handle_status_changed(map, event, "sending-failure");
+               break;
        default:
                break;
        }