Changeset 3291

Show
Ignore:
Timestamp:
01/23/08 23:52:50
Author:
svillar
Message:
  • Added queue-start and queue-stop signals to the send queue
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r3290 r3291  
    66        (tny_send_queue_add_async): added this method that was available in 
    77        the Camel implementation to the interface 
     8        (create_worker) 
     9        (thread_main): added the "queue-start" and "queue-stop" signals that 
     10        are emitted before and after the queue processes the messages 
    811 
    9122008-01-22  Philip Van Hoof <pvanhoof@gnome.org> 
  • trunk/libtinymail-camel/tny-camel-send-queue.c

    r3290 r3291  
    175175                tny_lockable_lock (apriv->session->priv->ui_lock); 
    176176        g_signal_emit (info->self, tny_send_queue_signals [info->signal_id],  
    177                 0, info->header, info->msg, info->i, info->total); 
     177                       0, info->header, info->msg, info->i, info->total);       
    178178        if (apriv) 
    179179                tny_lockable_unlock (apriv->session->priv->ui_lock); 
     
    282282} 
    283283 
     284 
     285static gboolean 
     286emit_queue_control_signals_on_mainloop (gpointer data) 
     287{ 
     288        ControlInfo *info = data; 
     289        TnyCamelSendQueuePriv *priv = TNY_CAMEL_SEND_QUEUE_GET_PRIVATE (info->self); 
     290        TnyCamelAccountPriv *apriv = NULL; 
     291 
     292        if (priv && priv->trans_account) 
     293                apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (priv->trans_account); 
     294        if (apriv) 
     295                tny_lockable_lock (apriv->session->priv->ui_lock); 
     296        g_signal_emit (info->self, tny_send_queue_signals [info->signal_id], 0);         
     297        if (apriv) 
     298                tny_lockable_unlock (apriv->session->priv->ui_lock); 
     299 
     300        return NULL; 
     301} 
     302 
     303static void 
     304emit_queue_control_signals (TnySendQueue *self, guint signal_id) 
     305{ 
     306        ControlInfo *info = g_slice_new0 (ControlInfo); 
     307 
     308        info->self = g_object_ref (self); 
     309        info->signal_id = signal_id; 
     310 
     311        g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, 
     312                         emit_queue_control_signals_on_mainloop, info,  
     313                         destroy_control_info); 
     314         
     315        return; 
     316} 
     317 
    284318typedef struct { 
    285319        TnySendQueue *self; 
     
    528562        g_slice_free (MainThreadInfo, info); 
    529563 
     564        /* Emit the queue-stop signal */ 
     565        emit_queue_control_signals (self, TNY_SEND_QUEUE_STOP); 
     566 
    530567        return NULL; 
    531568} 
     
    542579 
    543580                if (spriv->device && TNY_IS_DEVICE (spriv->device)) { 
    544                         MainThreadInfo *info = g_slice_new0 (MainThreadInfo); 
     581                        MainThreadInfo *info; 
     582 
     583                        info = g_slice_new0 (MainThreadInfo); 
    545584                        info->self = g_object_ref (self); 
    546585                        info->device = g_object_ref (spriv->device); 
     586 
     587                        emit_queue_control_signals (self, TNY_SEND_QUEUE_START); 
     588 
    547589                        priv->thread = g_thread_create (thread_main, info, FALSE, NULL); 
     590 
     591                        if (priv->thread == NULL) 
     592                                emit_queue_control_signals (self, TNY_SEND_QUEUE_STOP); 
    548593                } 
    549594        } 
  • trunk/libtinymail/tny-send-queue.c

    r3290 r3291  
    242242                                      tny_marshal_VOID__OBJECT_OBJECT_POINTER, 
    243243                                      G_TYPE_NONE, 3, TNY_TYPE_HEADER, TNY_TYPE_MSG, G_TYPE_POINTER); 
     244 
     245/** 
     246 * TnySendQueue::queue-start 
     247 * @self: a #TnySendQueue, the object on which the signal is emitted 
     248 * 
     249 * Emitted when the queue starts to process messages 
     250 **/ 
     251                tny_send_queue_signals[TNY_SEND_QUEUE_START] = 
     252                        g_signal_new ("queue-start", 
     253                                      TNY_TYPE_SEND_QUEUE, 
     254                                      G_SIGNAL_RUN_FIRST, 
     255                                      G_STRUCT_OFFSET (TnySendQueueIface, queue_start), 
     256                                      NULL, NULL, 
     257                                      g_cclosure_marshal_VOID__VOID, 
     258                                      G_TYPE_NONE, 0); 
     259 
     260/** 
     261 * TnySendQueue::queue-stop 
     262 * @self: a #TnySendQueue, the object on which the signal is emitted 
     263 * 
     264 * Emitted when the queue stops to process messages 
     265 **/ 
     266                tny_send_queue_signals[TNY_SEND_QUEUE_STOP] = 
     267                        g_signal_new ("queue-stop", 
     268                                      TNY_TYPE_SEND_QUEUE, 
     269                                      G_SIGNAL_RUN_FIRST, 
     270                                      G_STRUCT_OFFSET (TnySendQueueIface, queue_stop), 
     271                                      NULL, NULL, 
     272                                      g_cclosure_marshal_VOID__VOID, 
     273                                      G_TYPE_NONE, 0); 
     274 
    244275                 
    245276                initialized = TRUE; 
  • trunk/libtinymail/tny-send-queue.h

    r3290 r3291  
    4646        TNY_SEND_QUEUE_MSG_SENT, 
    4747        TNY_SEND_QUEUE_ERROR_HAPPENED, 
     48        TNY_SEND_QUEUE_START, 
     49        TNY_SEND_QUEUE_STOP, 
    4850        TNY_SEND_QUEUE_LAST_SIGNAL 
    4951}; 
     
    6668        void (*msg_sent) (TnySendQueue *self, TnyHeader *header, TnyMsg *msg, guint nth, guint total); 
    6769        void (*error_happened) (TnySendQueue *self, TnyHeader *header, TnyMsg *msg, GError *err, gpointer user_data); 
     70        void (*queue_start) (TnySendQueue *self, gpointer user_data); 
     71        void (*queue_stop) (TnySendQueue *self, gpointer user_data); 
    6872 
    6973        /* methods */