Detects when new message is being procesed by send-queue



I added a new signal in tny-send-queue impementation to detect when a 
new message, stored into OUTBOX folder, is being procesed by send queue 
to send it (msg-sending signal). When this message was finnaly sent, 
send-queue will emit 
mgs-sent signal. 

Greetings, 

-- 
Javier Fernández García-Boente
Ingeniero en Informática                 
mailto:jfernandez igalia com                    
Igalia http://www.igalia.com
Telf. +34 981 91 39 91  
Fax.  +34 981 91 39 49
 
Index: libtinymail-camel/tny-camel-send-queue.c
===================================================================
--- libtinymail-camel/tny-camel-send-queue.c	(revision 2078)
+++ libtinymail-camel/tny-camel-send-queue.c	(working copy)
@@ -123,8 +123,9 @@
 			goto errorhandler;
 		}
 
+		/* I dont expect total is being changed  */
 		length = tny_list_get_length (list);
-		priv->total = length;
+/* 		priv->total = length; */
 	}
 	g_mutex_unlock (priv->todo_lock);
 
@@ -157,10 +158,10 @@
 				goto errorhandler;
 			}
 
+			/* I dont expect total is being changed  */
 			length = tny_list_get_length (headers);
+/* 			priv->total = length; */
 
-			priv->total = length;
-
 			if (length <= 0)
 			{
 				g_object_unref (G_OBJECT (headers));
@@ -177,7 +178,6 @@
 		}
 		g_mutex_unlock (priv->todo_lock);
 
-
 		if (header && TNY_IS_HEADER (header))
 		{
 			TnyList *hassent = tny_simple_list_new ();
@@ -187,6 +187,10 @@
 			msg = tny_folder_get_msg (outbox, header, &err);
 			g_object_unref (G_OBJECT (header));	
 
+			/* Emits msg-sending signal to inform a new msg is being sent */
+			g_signal_emit (self, tny_send_queue_signals [TNY_SEND_QUEUE_MSG_SENDING], 
+				       0, msg, err, i, priv->total);
+		
 			if (err == NULL) 
 			{
 				tny_transport_account_send (priv->trans_account, msg, &err);
@@ -208,9 +212,14 @@
 						emit_error (self, msg, newerr, i, priv->total);
 						g_error_free (newerr);
 					}
-					priv->total--;
+/* 					priv->total--; */
 				}
 			}
+
+			/* Emits msg-sent signal to inform msg has been sent */
+			g_signal_emit (self, tny_send_queue_signals [TNY_SEND_QUEUE_MSG_SENT], 
+				       0, msg, err, i, priv->total);
+
 			g_mutex_unlock (priv->todo_lock);
 
 			g_object_unref (G_OBJECT (hassent));
@@ -390,6 +399,7 @@
 
 		g_object_unref (G_OBJECT (outbox));
 	}
+
 	g_mutex_unlock (priv->todo_lock);
 
 	return;
Index: po/Makefile.in.in
===================================================================
--- po/Makefile.in.in	(revision 2078)
+++ po/Makefile.in.in	(working copy)
@@ -25,7 +25,6 @@
 
 prefix = @prefix@
 exec_prefix = @exec_prefix@
-datarootdir = @datarootdir@
 datadir = @datadir@
 libdir = @libdir@
 localedir = $(libdir)/locale
@@ -41,7 +40,6 @@
 GENCAT = @GENCAT@
 GMSGFMT = @GMSGFMT@
 MSGFMT = @MSGFMT@
-MSGFMT_OPTS = @MSGFMT_OPTS@
 XGETTEXT = @XGETTEXT@
 MSGMERGE = msgmerge
 
@@ -80,7 +78,7 @@
 
 .po.gmo:
 	file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \
-	  && rm -f $$file && $(GMSGFMT) $(MSGFMT_OPTS) -o $$file $<
+	  && rm -f $$file && $(GMSGFMT) -c -o $$file $<
 
 .po.cat:
 	sed -f ../intl/po2msg.sed < $< > $*.msg \
Index: libtinymail-queues/tny-generic-send-queue.c
===================================================================
--- libtinymail-queues/tny-generic-send-queue.c	(revision 2078)
+++ libtinymail-queues/tny-generic-send-queue.c	(working copy)
@@ -182,6 +182,10 @@
 		info->self = TNY_GENERIC_SEND_QUEUE (g_object_ref (self));
 		info->msg = tny_folder_get_msg (outbox, header, &err);
 
+		/* Emits msg-sending signal to inform a new msg is being sent */
+		g_signal_emit (self, tny_send_queue_signals [TNY_SEND_QUEUE_MSG_SENDING], 
+			       0, info->msg, err, i, total);
+		
 		if (err != NULL)
 		{
 			emit_error (TNY_SEND_QUEUE (self), NULL, err, info->i, info->total);
@@ -205,7 +209,11 @@
 		tny_queue_task_set_callback (task, generic_send_callback);
 
 		item = tny_queue_add_task (priv->queue, task);
-
+		
+		/* Emits msg-sent signal to inform msg has been sent */
+		g_signal_emit (self, tny_send_queue_signals [TNY_SEND_QUEUE_MSG_SENT], 
+			       0, info->msg, err, i, total);
+		
 		g_object_unref (header);
 		tny_iterator_next (iter); 
 		i++;
Index: libtinymail/tny-send-queue.c
===================================================================
--- libtinymail/tny-send-queue.c	(revision 2078)
+++ libtinymail/tny-send-queue.c	(working copy)
@@ -142,6 +142,26 @@
 	if (!initialized) 
 	{
 /**
+ * TnySendQueue::msg-sending
+ * @self: the object on which the signal is emitted
+ * @arg1: The message that is being 
+ * @arg2: The current nth number of the message that is being sending
+ * @arg3: The total amount of messages currently being processed
+ *
+ * API WARNING: This API might change
+ *
+ * Emitted when a message is being proccessed to sending it
+ **/
+		tny_send_queue_signals[TNY_SEND_QUEUE_MSG_SENDING] =
+			g_signal_new ("msg_sending",
+				      TNY_TYPE_SEND_QUEUE,
+				      G_SIGNAL_RUN_FIRST,
+				      G_STRUCT_OFFSET (TnySendQueueIface, msg_sending),
+				      NULL, NULL,
+				      g_cclosure_marshal_VOID__POINTER,
+				      G_TYPE_NONE, 3, TNY_TYPE_MSG, G_TYPE_UINT, G_TYPE_UINT);
+		
+/**
  * TnySendQueue::msg-sent
  * @self: the object on which the signal is emitted
  * @arg1: The message that got sent
Index: libtinymail/tny-send-queue.h
===================================================================
--- libtinymail/tny-send-queue.h	(revision 2078)
+++ libtinymail/tny-send-queue.h	(working copy)
@@ -40,6 +40,7 @@
 
 enum _TnySendQueueSignal
 {
+	TNY_SEND_QUEUE_MSG_SENDING,
 	TNY_SEND_QUEUE_MSG_SENT,
 	TNY_SEND_QUEUE_ERROR_HAPPENED,
 	TNY_SEND_QUEUE_LAST_SIGNAL
@@ -53,6 +54,7 @@
 	GTypeInterface parent;
 	
 	/* Signals */
+	void (*msg_sending) (TnySendQueue *self, TnyMsg *msg, guint nth, guint total);
 	void (*msg_sent) (TnySendQueue *self, TnyMsg *msg, guint nth, guint total);
 	void (*error_happened) (TnySendQueue *self, TnyMsg *msg, guint nth, guint total);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]