Changeset 3820

Show
Ignore:
Timestamp:
11/20/08 14:20:08
Author:
mbonnin
Message:

adding camel_operation_mute/unmute() and use it to filter the progress
events. This prevents to send bad progress when refreshing an
IMAP folder.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r3819 r3820  
     12008-11-20  Martin Bonnin  <martinbonnin@gmail.com> 
     2  
     3        * camel operation: 
     4        adding camel_operation_mute/unmute() and use it to filter the progress 
     5        events. This prevents to send bad progress when refreshing an IMAP folder 
     6 
    172008-11-20  Martin Bonnin  <martinbonnin@gmail.com> 
    28  
  • trunk/libtinymail-camel/camel-lite/camel/camel-operation.c

    r3423 r3820  
    4444#endif 
    4545#define CAMEL_OPERATION_TRANSIENT (1<<1) 
     46#define CAMEL_OPERATION_MUTE      (1<<2) 
    4647 
    4748/* Delay before a transient operation has any effect on the status */ 
     
    112113} 
    113114 
     115static void 
     116co_mute(CamelOperation *cc, gboolean mute) 
     117{ 
     118        struct _status_stack *s; 
     119 
     120        if (cc == NULL) 
     121                cc = co_getcc(); 
     122 
     123        if (cc == NULL) 
     124                return; 
     125 
     126        LOCK(); 
     127 
     128        if (cc->status == NULL || cc->status_stack == NULL) { 
     129                UNLOCK(); 
     130                return; 
     131        } 
     132 
     133        s = cc->status_stack->data; 
     134 
     135        if (mute){ 
     136                s->flags |= CAMEL_OPERATION_MUTE; 
     137        } else { 
     138                s->flags &= ~CAMEL_OPERATION_MUTE; 
     139        }  
     140 
     141        UNLOCK(); 
     142} 
     143 
     144 
    114145/** 
    115146 * camel_operation_mute: 
    116147 * @cc: 
    117148 * 
    118  * mutes a camel operation permanently. from this point on you will never 
     149 * mutes a camel operation. from this point on you will never 
    119150 * receive operation updates, even if more are sent. 
    120151 **/ 
     
    122153camel_operation_mute(CamelOperation *cc) 
    123154{ 
    124         LOCK(); 
    125         cc->status = NULL; 
    126         cc->status_data = NULL; 
    127         UNLOCK(); 
     155        co_mute(cc, TRUE); 
     156
     157 
     158/** 
     159 * camel_operation_unmute: 
     160 * @cc: 
     161 * 
     162 * unmutes a camel operation.  
     163 * Makes the operation send updates again 
     164 **/ 
     165void 
     166camel_operation_unmute(CamelOperation *cc) 
     167
     168        co_mute(cc, FALSE); 
    128169} 
    129170 
     
    578619 
    579620        s = cc->status_stack->data; 
     621 
     622        if( s->flags & CAMEL_OPERATION_MUTE ){ 
     623                UNLOCK(); 
     624                return; 
     625        } 
     626 
    580627        s->sofar = sofar; 
    581628        s->oftotal = oftotal; 
  • trunk/libtinymail-camel/camel-lite/camel/camel-operation.h

    r3423 r3820  
    8282CamelOperation *camel_operation_new(CamelOperationStatusFunc status, void *status_data); 
    8383void camel_operation_mute(CamelOperation *cc); 
     84void camel_operation_unmute(CamelOperation *cc); 
    8485void camel_operation_ref(CamelOperation *cc); 
    8586void camel_operation_unref(CamelOperation *cc); 
  • trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c

    r3819 r3820  
    32853285 
    32863286   camel_operation_start (NULL, _("Fetching summary information for new messages in folder")); 
     3287   camel_operation_mute (NULL); 
    32873288 
    32883289   camel_folder_summary_prepare_hash (folder->summary); 
     
    35523553 
    35533554                                  allhdrs++; 
     3555 
     3556                                  camel_operation_unmute (NULL); 
    35543557                                  camel_operation_progress (NULL, allhdrs , ineed); 
     3558                                  camel_operation_mute (NULL); 
     3559 
    35553560                                  sequence = GPOINTER_TO_INT (g_datalist_get_data (&data, "SEQUENCE")); 
    35563561                                  curlen = camel_folder_summary_count (folder->summary);