Changeset 2445

Show
Ignore:
Timestamp:
07/10/07 16:50:57
Author:
jfernandez
Message:

* Implements and emits msg-sending and msg-sent signals
when a message is just being sent and when is fully sent.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r2444 r2445  
     12007-07-09  Javier Fernández García-Boente <jfernandez@igalia.com> 
     2        * Implements and emits msg-sending and msg-sent signals 
     3        when a message is just being sent and when is fully sent.  
     4 
    152007-07-10  Philip Van Hoof  <pvanhoof@gnome.org> 
    26 
  • trunk/libtinymail-camel/tny-camel-send-queue.c

    r2409 r2445  
    5454        gint i, total; 
    5555} ErrorInfo; 
     56 
     57typedef struct { 
     58       TnySendQueue *self; 
     59       TnyMsg *msg; 
     60       TnyHeader *header; 
     61       gint i, total; 
     62       guint signal_id; 
     63} ControlInfo; 
    5664 
    5765static gboolean  
     
    102110} 
    103111 
     112 
     113static gboolean  
     114emit_control_signals_on_mainloop (gpointer data) 
     115{ 
     116       ControlInfo *info = data; 
     117       g_signal_emit (info->self, tny_send_queue_signals [info->signal_id],  
     118                      0, info->header, info->msg, info->i, info->total); 
     119       return FALSE; 
     120} 
     121 
     122static void 
     123destroy_control_info (gpointer data) 
     124{ 
     125       ControlInfo *info = data; 
     126 
     127       if (info->msg) 
     128               g_object_unref (G_OBJECT (info->msg)); 
     129       if (info->header) 
     130               g_object_unref (G_OBJECT (info->header)); 
     131       if (info->self) 
     132               g_object_unref (G_OBJECT (info->self)); 
     133 
     134       g_slice_free (ControlInfo, info); 
     135} 
     136 
     137static void 
     138emit_control (TnySendQueue *self, TnyHeader *header, TnyMsg *msg, guint signal_id, int i, int total) 
     139{ 
     140       ControlInfo *info = g_slice_new0 (ControlInfo); 
     141 
     142       if (self) 
     143               info->self = TNY_SEND_QUEUE (g_object_ref (G_OBJECT (self))); 
     144       if (msg) 
     145               info->msg = TNY_MSG (g_object_ref (G_OBJECT (msg))); 
     146       if (header) 
     147               info->header = TNY_HEADER (g_object_ref (G_OBJECT (header))); 
     148 
     149       info->signal_id = signal_id; 
     150       info->i = i; 
     151       info->total = total; 
     152        
     153       g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, 
     154                        emit_control_signals_on_mainloop, info, destroy_control_info); 
     155 
     156       return; 
     157} 
     158 
     159 
    104160static gpointer 
    105161thread_main (gpointer data) 
     
    152208        while (length > 0 && priv->do_continue) 
    153209        { 
    154                 TnyHeader *header
     210                TnyHeader *header = NULL
    155211                TnyMsg *msg = NULL; 
    156212 
     
    230286                        msg = tny_folder_get_msg (outbox, header, &err); 
    231287 
    232                         /* hassent is owner now */ 
    233                         g_object_unref (G_OBJECT (header));  
    234  
     288                        /* Emits msg-sending signal to inform a new msg is being sent */ 
     289                        emit_control (self, header, msg, TNY_SEND_QUEUE_MSG_SENDING, i, priv->total); 
     290                         
    235291                        if (err == NULL)  
    236292                        { 
     
    268324                                g_error_free (err); 
    269325 
    270                         i++; 
     326                        /* Emits msg-sent signal to inform msg has been sent */ 
     327                        emit_control (self, header, msg, TNY_SEND_QUEUE_MSG_SENT, i, priv->total); 
     328                         
     329                        i++;                     
     330 
     331                        /* hassent is owner now */ 
     332                        g_object_unref (G_OBJECT (header)); 
    271333                } else  
    272334                { 
  • trunk/libtinymail/tny-send-queue.c

    r2206 r2445  
    141141        static gboolean initialized = FALSE; 
    142142 
    143         if (!initialized)  
    144         { 
     143        if (!initialized) { 
     144/** 
     145 * TnySendQueue::msg-sending 
     146 * @self: the object on which the signal is emitted 
     147 * @arg1: The message that is being  
     148 * @arg2: The current nth number of the message that is being sending 
     149 * @arg3: The total amount of messages currently being processed 
     150 * 
     151 * API WARNING: This API might change 
     152 * 
     153 * Emitted when a message is being proccessed to sending it 
     154 **/ 
     155                tny_send_queue_signals[TNY_SEND_QUEUE_MSG_SENDING] = 
     156                        g_signal_new ("msg_sending", 
     157                                      TNY_TYPE_SEND_QUEUE, 
     158                                      G_SIGNAL_RUN_FIRST, 
     159                                      G_STRUCT_OFFSET (TnySendQueueIface, msg_sending), 
     160                                      NULL, NULL, 
     161                                      tny_marshal_VOID__OBJECT_OBJECT_INT_INT, 
     162                                      G_TYPE_NONE, 4, TNY_TYPE_HEADER, TNY_TYPE_MSG, G_TYPE_UINT, G_TYPE_UINT); 
     163                 
     164 
    145165/** 
    146166 * TnySendQueue::msg-sent 
     
    152172 **/ 
    153173                tny_send_queue_signals[TNY_SEND_QUEUE_MSG_SENT] = 
    154                    g_signal_new ("msg_sent", 
    155                         TNY_TYPE_SEND_QUEUE, 
    156                         G_SIGNAL_RUN_FIRST, 
    157                         G_STRUCT_OFFSET (TnySendQueueIface, msg_sent), 
    158                         NULL, NULL, 
    159                         g_cclosure_marshal_VOID__POINTER
    160                         G_TYPE_NONE, 1, TNY_TYPE_MSG); 
    161  
     174                       g_signal_new ("msg_sent", 
     175                                     TNY_TYPE_SEND_QUEUE, 
     176                                     G_SIGNAL_RUN_FIRST, 
     177                                     G_STRUCT_OFFSET (TnySendQueueIface, msg_sent), 
     178                                     NULL, NULL, 
     179                                     tny_marshal_VOID__OBJECT_OBJECT_INT_INT
     180                                     G_TYPE_NONE, 4, TNY_TYPE_HEADER, TNY_TYPE_MSG, G_TYPE_UINT, G_TYPE_UINT); 
     181                 
    162182/** 
    163183 * TnySendQueue::error-happened 
     
    172192 **/ 
    173193                tny_send_queue_signals[TNY_SEND_QUEUE_ERROR_HAPPENED] = 
    174                    g_signal_new ("error_happened", 
    175                         TNY_TYPE_SEND_QUEUE, 
    176                         G_SIGNAL_RUN_FIRST, 
    177                         G_STRUCT_OFFSET (TnySendQueueIface, error_happened), 
    178                         NULL, NULL, 
    179                         tny_marshal_VOID__OBJECT_OBJECT_POINTER, 
    180                         G_TYPE_NONE, 3, TNY_TYPE_HEADER, TNY_TYPE_MSG, G_TYPE_POINTER); 
    181  
     194                       g_signal_new ("error_happened", 
     195                                     TNY_TYPE_SEND_QUEUE, 
     196                                     G_SIGNAL_RUN_FIRST, 
     197                                     G_STRUCT_OFFSET (TnySendQueueIface, error_happened), 
     198                                     NULL, NULL, 
     199                                     tny_marshal_VOID__OBJECT_OBJECT_POINTER, 
     200                                     G_TYPE_NONE, 3, TNY_TYPE_HEADER, TNY_TYPE_MSG, G_TYPE_POINTER); 
     201                 
    182202                initialized = TRUE; 
    183203        } 
  • trunk/libtinymail/tny-send-queue.h

    r2206 r2445  
    4141enum _TnySendQueueSignal 
    4242{ 
     43        TNY_SEND_QUEUE_MSG_SENDING, 
    4344        TNY_SEND_QUEUE_MSG_SENT, 
    4445        TNY_SEND_QUEUE_ERROR_HAPPENED, 
     
    5455         
    5556        /* Signals */ 
    56         void (*msg_sent) (TnySendQueue *self, TnyMsg *msg, gpointer user_data); 
     57        void (*msg_sending) (TnySendQueue *self, TnyHeader *header, TnyMsg *msg, guint nth, guint total); 
     58        void (*msg_sent) (TnySendQueue *self, TnyHeader *header, TnyMsg *msg, guint nth, guint total); 
    5759        void (*error_happened) (TnySendQueue *self, TnyHeader *header, TnyMsg *msg, GError *err, gpointer user_data); 
    5860 
  • trunk/libtinymail/tny-signals-marshal.list

    r2206 r2445  
    11VOID:OBJECT,OBJECT,POINTER 
     2VOID:OBJECT,OBJECT,INT,INT