* Migrated Modest to the new send queue API
[modest] / src / modest-tny-send-queue.h
index a82dcd2..6c23f06 100644 (file)
@@ -50,12 +50,23 @@ G_BEGIN_DECLS
 typedef struct _ModestTnySendQueue      ModestTnySendQueue;
 typedef struct _ModestTnySendQueueClass ModestTnySendQueueClass;
 
+typedef enum {
+       MODEST_TNY_SEND_QUEUE_UNKNOWN,
+       MODEST_TNY_SEND_QUEUE_WAITING,
+       MODEST_TNY_SEND_QUEUE_SUSPENDED,
+       MODEST_TNY_SEND_QUEUE_SENDING,
+       MODEST_TNY_SEND_QUEUE_FAILED
+} ModestTnySendQueueStatus;
+
 struct _ModestTnySendQueue {
        TnyCamelSendQueue  parent;
 };
 
 struct _ModestTnySendQueueClass {
        TnyCamelSendQueueClass parent_class;
+
+       /* Signals */
+       void (*status_changed)(ModestTnySendQueue *self, const gchar *msg_id, ModestTnySendQueueStatus status);
 };
 
 /**
@@ -82,16 +93,14 @@ ModestTnySendQueue*    modest_tny_send_queue_new        (TnyCamelTransportAccoun
 
 
 /**
- * modest_tny_send_queue_try_to_send:
+ * modest_tny_send_queue_ADD:
  * @self: a valid #ModestTnySendQueue instance
+ * @msg: a valid #TnyMsg instance to send 
  * 
- * Try to send the messages that are in the queue's outbox folder.
- * This is not always necessary because the queue tries to send 
- * messages as soon as a message is added, and as soon as the queue 
- * is instantiated.
+ * Add @msg to outbox folder waiting to be sent by 
+ * its account send queue. 
  */
-void modest_tny_send_queue_try_to_send (ModestTnySendQueue* self);
-
+void modest_tny_send_queue_add (ModestTnySendQueue *self, TnyMsg *msg, GError **err);
 
 /**
  * modest_tny_send_queue_sending_in_progress:
@@ -110,6 +119,53 @@ gboolean modest_tny_send_queue_sending_in_progress (ModestTnySendQueue* self);
  */
 gboolean modest_tny_send_queue_msg_is_being_sent (ModestTnySendQueue* self, const gchar *msg_id);
 
+/**
+ * modest_tny_send_queue_get_msg_status:
+ * @self: a valid #ModestTnySendQueue instance
+ * @msg_id: The message id to check
+ *
+ * Returns the status of the message identified with @msg_id. The status tells
+ * whether the message is currently being sent, is waiting for being sent or
+ * sending the message failed.
+ */
+ModestTnySendQueueStatus
+modest_tny_send_queue_get_msg_status (ModestTnySendQueue *self, const gchar *msg_id);
+
+gchar *
+modest_tny_send_queue_get_msg_id (TnyHeader *header);
+
+/**
+ * modest_tny_all_send_queues_get_msg_status:
+ * @header: a #TnyHeader
+ *
+ * obtain status of message (searching for it in all queues)
+ *
+ * Returns: a #ModestTnySendQueueStatus
+ */
+ModestTnySendQueueStatus
+modest_tny_all_send_queues_get_msg_status (TnyHeader *header);
+
+
+/**
+ * modest_tny_send_queue_to_string:
+ * @self: a valid #ModestTnySendQueue instance
+ *
+ * get a string representation of a send queue (for debugging)
+ *
+ * Returns: a newly allocated string, or NULL in case of error
+ */
+gchar* modest_tny_send_queue_to_string (ModestTnySendQueue *self);
+
+/**
+ * modest_tny_send_queue_wakeup:
+ * @self: a valid #ModestTnySendQueue instance
+ *
+ * Wakes up all suspended messages in the send queue. This means that
+ * the send queue will try to send them again. Note that you'd
+ * probably need a tny_send_queue_flush to force it
+ */
+void   modest_tny_send_queue_wakeup (ModestTnySendQueue *self);
+
 
 G_END_DECLS