+
+gboolean
+modest_tny_send_queue_msg_is_being_sent (ModestTnySendQueue* self,
+ const gchar *msg_id)
+{
+ ModestTnySendQueueStatus status;
+
+ g_return_val_if_fail (msg_id != NULL, FALSE);
+
+ status = modest_tny_send_queue_get_msg_status (self, msg_id);
+ return status == MODEST_TNY_SEND_QUEUE_SENDING;
+}
+
+gboolean
+modest_tny_send_queue_sending_in_progress (ModestTnySendQueue* self)
+{
+ ModestTnySendQueuePrivate *priv;
+ priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
+
+ return priv->current != NULL;
+}
+
+ModestTnySendQueueStatus
+modest_tny_send_queue_get_msg_status (ModestTnySendQueue *self, const gchar *msg_id)
+{
+ GList *item;
+ item = modest_tny_send_queue_lookup_info (self, msg_id);
+ if(item == NULL) return MODEST_TNY_SEND_QUEUE_SUSPENDED;
+ return ((SendInfo*)item->data)->status;
+}
+
+/* static void */
+/* _on_msg_start_sending (TnySendQueue *self, */
+/* TnyMsg *msg, */
+/* gpointer user_data) */
+/* { */
+/* ModestTnySendQueuePrivate *priv; */
+/* TnyHeader *header; */
+/* GList *item; */
+/* SendInfo *info; */
+
+/* priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self); */
+
+/* header = tny_msg_get_header(msg); */
+/* item = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE (self), tny_header_get_message_id (header)); */
+
+/* if (item != NULL) */
+/* { */
+/* info = item->data; */
+/* info->status = MODEST_TNY_SEND_QUEUE_SENDING; */
+
+/* g_signal_emit (self, signals[STATUS_CHANGED], 0, info->msg_id, info->status); */
+/* } */
+
+/* priv->current = item; */
+/* } */
+
+static void
+_on_msg_has_been_sent (TnySendQueue *self,
+ TnyMsg *msg,
+ gpointer user_data)
+{
+ ModestTnySendQueuePrivate *priv;
+ TnyHeader *header;
+ GList *item;
+
+ priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
+
+ header = tny_msg_get_header (msg);
+
+ /* TODO: Use this version as soon as the msg-sending
+ * notification works */
+#if 0
+ item = priv->current;
+ g_assert(item != NULL);
+#else
+ item = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE (self), tny_header_get_message_id(header));
+ g_assert(item != NULL);
+#endif
+
+ modest_tny_send_queue_info_free (item->data);
+ g_queue_delete_link (priv->queue, item);
+ priv->current = NULL;
+}
+
+static void _on_msg_error_happened (TnySendQueue *self,
+ TnyHeader *header,
+ TnyMsg *msg,
+ GError *err,
+ gpointer user_data)
+{
+ ModestTnySendQueuePrivate *priv;
+ SendInfo *info;
+ GList *item;
+ TnyHeader *msg_header;
+
+ priv = MODEST_TNY_SEND_QUEUE_GET_PRIVATE (self);
+
+ /* TODO: Use this version as soon as the msg-sending
+ * notification works */
+/* #if 0 */
+/* item = priv->current; */
+/* g_assert(item != NULL); */
+/* info = priv->current->data; */
+/* #else */
+/* /\* TODO: Why do we get the msg and its header separately? The docs */
+/* * don't really tell. *\/ */
+/* g_assert(header == tny_msg_get_header (msg)); // ???? */
+ msg_header = tny_msg_get_header (msg);
+ item = modest_tny_send_queue_lookup_info (MODEST_TNY_SEND_QUEUE (self),
+ tny_header_get_message_id (msg_header));
+ g_object_unref (msg_header);
+ g_assert(item != NULL);
+ info = item->data;
+/* #endif */
+
+ /* Keep in queue so that we remember that the opertion has failed
+ * and was not just cancelled */
+ info->status = MODEST_TNY_SEND_QUEUE_FAILED;
+ g_signal_emit (self, signals[STATUS_CHANGED], 0, info->msg_id, info->status);
+}