Changeset 1092

Show
Ignore:
Timestamp:
11/06/06 15:19:14
Author:
pvanhoof
Message:

Introduction of the TnyMsgRemoveStrategy?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk

    • Property svn:ignore changed from compile tags py* anjuta.anjuta config.h stamp-h1 libtinymail-*.tar.gz libtinymail.spec .anjuta .svnignore .tm_project2.cache configure config.log depcomp TODO.tasks config.guess ltmain.sh config.sub anjuta gtk-doc.make tinymail.anjuta Makefile Makefile.in mkinstalldirs config.status autom4te.cache libtool tm_project2.cache missing aclocal.m4 install-sh to compile tags py* *.anjuta config.h stamp-h1 libtinymail-*.tar.gz libtinymail.spec .anjuta .svnignore .tm_project2.cache configure config.log depcomp TODO.tasks config.guess ltmain.sh config.sub anjuta gtk-doc.make tinymail.anjuta Makefile Makefile.in mkinstalldirs config.status autom4te.cache libtool tm_project2.cache missing aclocal.m4 install-sh
  • trunk/.svnignore

    r802 r1092  
    22tags 
    33py* 
    4 anjuta.anjuta 
     4*.anjuta 
    55config.h 
    66stamp-h1 
  • trunk/ChangeLog

    r1091 r1092  
     12006-11-06  Philip van Hoof <pvanhoof@gnome.org> 
     2 
     3        * Introduction of the TnyMsgRemoveStrategy, which makes it more 
     4        flexible to define how tinymail should remove messages (as this might 
     5        be specific per device). Although this means a major API change, not a 
     6        lot external API has changed. A default remove strategy is used for 
     7        each folder and is implemented as TnyCamelMsgRemoveStrategy. This 
     8        is an overwritable property. 
     9 
     10        * This was a major API change 
     11 
    1122006-11-06  Sergio Villar Senin <svillar@igalia.com> 
    213 
  • trunk/bindings/python/Makefile.am

    r1090 r1092  
    8888        $(top_srcdir)/libtinymail/tny-store-account.h \ 
    8989        $(top_srcdir)/libtinymail/tny-stream.h \ 
    90         $(top_srcdir)/libtinymail/tny-transport-account.h 
     90        $(top_srcdir)/libtinymail/tny-transport-account.h \ 
     91        $(top_srcdir)/libtinymail/tny-msg-remove-strategy.h 
    9192 
    9293tinymail.defs: $(tinymail_h_files) tinymail.defs.extra $(top_srcdir)/bindings/python/filter.py  
  • trunk/libtinymail-camel/Makefile.am

    r1014 r1092  
    1010libtinymail_camel_1_0_headers =                 \ 
    1111        tny-camel-mime-part.h                   \ 
     12        tny-camel-msg-remove-strategy.h         \ 
    1213        tny-camel-header.h                      \ 
    1314        tny-camel-msg.h                         \ 
     
    2930libtinymail_camel_1_0_la_SOURCES =              \ 
    3031        tny-session-camel-priv.h                \ 
     32        tny-camel-msg-remove-strategy.c         \ 
    3133        tny-camel-common.c                      \ 
    3234        tny-camel-common-priv.h                 \ 
  • trunk/libtinymail-camel/tny-camel-folder-priv.h

    r976 r1092  
    4646        TnyFolderType cached_folder_type; 
    4747        GList *possible_headers; 
    48         GMutex *poshdr_lock;     
     48        GMutex *poshdr_lock; 
     49        TnyMsgRemoveStrategy *remove_strat; 
    4950}; 
    5051 
  • trunk/libtinymail-camel/tny-camel-folder.c

    r1087 r1092  
    4444#include <errno.h> 
    4545 
     46#include <tny-camel-msg-remove-strategy.h> 
    4647#include <tny-session-camel.h> 
    4748#include "tny-camel-account-priv.h" 
     
    6465         
    6566        When we know a new message got added to this folder  
    66          
    67         info->uid_added 
    68         info->uid_removed 
    69         info->uid_changed 
    70         info->uid_recent  
     67 
     68       info->uid_added 
     69       info->uid_removed 
     70       info->uid_changed 
     71       info->uid_recent  
    7172} 
    7273*/ 
     
    7576pos_header_check (gpointer data, gpointer udata) 
    7677{ 
    77         /* this is a very ugly check .. let's hope that we can remove this soon */ 
    78      
    79         /* Note: TNY_IS_CAMEL_HEADER crashes if there's a message referenced ( 
     78        /* this is a very ugly check .. let's hope that we can remove this soon */ 
     79        /* Note: TNY_IS_CAMEL_HEADER crashes if there's a message referenced ( 
    8080           this might imply that a header is still referenced and therefore not 
    8181           destroyed) .. I don't know, it's definitely a bug. Also check #1 on  
    8282           the trac's tickets. */ 
    83      
     83 
    8484        if (data) 
    8585        { 
     
    9393{ 
    9494 
    95       if (priv->folder && !CAMEL_IS_FOLDER (priv->folder)) 
     95      if (priv->folder && !CAMEL_IS_FOLDER (priv->folder)) 
    9696        { 
    9797                g_mutex_lock (priv->poshdr_lock); 
     
    103103                priv->possible_headers = NULL; 
    104104                g_mutex_unlock (priv->poshdr_lock); 
    105              
     105 
    106106                if (CAMEL_IS_OBJECT (priv->folder)) 
    107107                { 
    108108                        g_critical ("Killing invalid CamelObject (should be a Camelfolder) at 0x%x\n", priv->folder); 
    109                      
    110109                        while (((CamelObject*)priv->folder)->ref_count >= 1) 
    111110                                camel_object_unref (CAMEL_OBJECT (priv->folder)); 
    112111                } else 
    113                       g_critical ("Corrupted CamelFolder instance at 0x%x (I can't recover from this state, therefore I will leak)\n", priv->folder); 
    114         } 
    115      
     112                      g_critical ("Corrupted CamelFolder instance at 0x%x (I can't recover from this state, therefore I will leak)\n", priv->folder); 
     113        } 
     114 
    116115        if (G_LIKELY (priv->folder) && CAMEL_IS_FOLDER (priv->folder)) 
    117116        { 
    118               /* 
     117              /* 
    119118                if (((CamelObject*)priv->folder)->ref_count) 
    120119                        if (priv->folder_changed_id != 0) 
    121120                                camel_object_remove_event (priv->folder, priv->folder_changed_id); 
    122121                */ 
    123              
     122 
    124123                g_mutex_lock (priv->poshdr_lock); 
    125124                if (priv->possible_headers)  
     
    130129                priv->possible_headers = NULL; 
    131130                g_mutex_unlock (priv->poshdr_lock); 
    132              
     131 
    133132                while (((CamelObject*)priv->folder)->ref_count >= 1) 
    134133                        camel_object_unref (CAMEL_OBJECT (priv->folder)); 
     
    136135        } 
    137136 
    138       priv->folder = NULL; 
     137      priv->folder = NULL; 
    139138        priv->cached_length = 0; 
    140139        priv->cached_folder_type = TNY_FOLDER_TYPE_UNKNOWN; 
     
    158157        if (priv->folder && !CAMEL_IS_FOLDER (priv->folder)) 
    159158                unload_folder_no_lock (priv, FALSE); 
    160      
     159 
    161160        if (!priv->folder && !priv->loaded && priv->folder_name) 
    162161        { 
     
    164163                CamelStore *store = (CamelStore*) _tny_camel_account_get_service  
    165164                        (TNY_CAMEL_ACCOUNT (priv->account)); 
    166              
     165 
    167166                g_mutex_lock (priv->poshdr_lock); 
    168167                if (priv->possible_headers) 
     
    173172                priv->possible_headers = NULL; 
    174173                g_mutex_unlock (priv->poshdr_lock); 
    175              
     174 
    176175                priv->folder = camel_store_get_folder  
    177176                        (store, priv->folder_name, 0, &ex); 
     
    182181                                while (((CamelObject*)priv->folder)->ref_count >= 1) 
    183182                                        camel_object_unref (CAMEL_OBJECT (priv->folder)); 
    184                      
     183 
    185184                        priv->folder = NULL; 
    186185                        priv->loaded = FALSE; 
    187186                        return FALSE; 
    188187                } 
    189              
    190               priv->cached_length = camel_folder_get_message_count (priv->folder); 
     188 
     189      priv->cached_length = camel_folder_get_message_count (priv->folder); 
    191190 
    192191                /* priv->folder_changed_id = camel_object_hook_event (priv->folder,  
     
    211210{ 
    212211        gboolean retval; 
    213      
     212 
    214213        g_mutex_lock (priv->folder_lock); 
    215214        retval = load_folder_no_lock (priv); 
     
    221220 
    222221static void  
    223 tny_camel_folder_remove_message (TnyFolder *self, TnyHeader *header) 
    224 
    225         TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    226         const gchar *id; 
     222tny_camel_folder_remove_msg (TnyFolder *self, TnyHeader *header) 
     223
     224        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
     225 
     226        if (!priv->remove_strat) 
     227                return; 
    227228 
    228229        g_mutex_lock (priv->folder_lock); 
     
    234235                        return; 
    235236                } 
    236      
    237         id = tny_header_get_uid (TNY_HEADER (header)); 
    238         camel_folder_delete_message (priv->folder, id); 
     237 
     238        tny_msg_remove_strategy_remove (priv->remove_strat, self, header); 
    239239 
    240240        g_mutex_unlock (priv->folder_lock); 
     
    257257                        return; 
    258258                } 
    259      
     259 
    260260        camel_folder_sync (priv->folder, TRUE, &ex); 
    261261 
     
    275275                if (!load_folder_no_lock (priv)) 
    276276                        return NULL; 
    277      
     277 
    278278        retval = priv->folder; 
    279279 
     
    420420        gpointer user_data; 
    421421        gboolean cancelled; 
    422       guint depth; 
     422      guint depth; 
    423423} RefreshFolderInfo; 
    424424 
     
    519519                destroy_progress_idle (info); 
    520520        } 
    521      
     521 
    522522        return; 
    523523} 
     
    537537 
    538538        g_mutex_lock (priv->folder_lock); 
    539      
     539 
    540540        if (!load_folder_no_lock (priv)) 
    541541        { 
     
    546546                return NULL; 
    547547        } 
    548      
     548 
    549549        info->cancelled = FALSE; 
    550550        str = g_strdup_printf (_("Reading folder `%s'"), priv->folder->full_name); 
     
    553553        g_free (str); 
    554554        camel_folder_refresh_info (priv->folder, ex); 
    555               priv->cached_length = camel_folder_get_message_count (priv->folder); 
     555      priv->cached_length = camel_folder_get_message_count (priv->folder); 
    556556 
    557557        if (G_LIKELY (priv->folder) && CAMEL_IS_FOLDER (priv->folder) && G_LIKELY (priv->has_summary_cap)) 
     
    563563        g_mutex_unlock (priv->folder_lock); 
    564564 
    565               /* thread reference */ 
     565      /* thread reference */ 
    566566        g_object_unref (G_OBJECT (self)); 
    567567 
     
    581581                } 
    582582        } 
    583    
     583 
    584584        g_thread_exit (NULL); 
    585585 
     
    592592        RefreshFolderInfo *info = g_new0 (RefreshFolderInfo, 1); 
    593593        GThread *thread; 
    594      
     594 
    595595        info->self = self; 
    596596        info->callback = callback; 
     
    598598        info->user_data = user_data; 
    599599        info->depth = g_main_depth (); 
    600      
     600 
    601601        /* thread reference */ 
    602602        g_object_ref (G_OBJECT (self)); 
     
    624624                return; 
    625625        } 
    626      
     626 
    627627        _tny_camel_account_start_camel_operation (TNY_CAMEL_ACCOUNT (priv->account),  
    628628                NULL, NULL, NULL); 
     
    630630        _tny_camel_account_stop_camel_operation (TNY_CAMEL_ACCOUNT (priv->account)); 
    631631 
    632       priv->cached_length = camel_folder_get_message_count (priv->folder);     
     632      priv->cached_length = camel_folder_get_message_count (priv->folder);     
    633633        if (G_LIKELY (priv->folder) && CAMEL_IS_FOLDER (priv->folder) && G_LIKELY (priv->has_summary_cap)) 
    634634                priv->unread_length = (guint)camel_folder_get_unread_message_count (priv->folder); 
     
    656656        } 
    657657 
    658       g_object_ref (G_OBJECT (headers)); 
     658      g_object_ref (G_OBJECT (headers)); 
    659659 
    660660        ptr = g_new (FldAndPriv, 1); 
     
    666666        { 
    667667                camel_folder_refresh_info (priv->folder, &ex); 
    668               priv->cached_length = camel_folder_get_message_count (priv->folder); 
     668              priv->cached_length = camel_folder_get_message_count (priv->folder); 
    669669                if (G_LIKELY (priv->folder) && CAMEL_IS_FOLDER (priv->folder) && G_LIKELY (priv->has_summary_cap)) 
    670670                        priv->unread_length = (guint)camel_folder_get_unread_message_count (priv->folder); 
    671671        } 
    672      
    673672        priv->cached_length = 0; 
    674673 
    675       if (priv->folder && CAMEL_IS_FOLDER (priv->folder)) 
     674      if (priv->folder && CAMEL_IS_FOLDER (priv->folder)) 
    676675                uids = camel_folder_get_uids (priv->folder); 
    677      
     676 
    678677        /* TODO: remove this warning, as it's not really strange. But needed for debugging aid 
    679678           for ticket #1 on the trac. So if we fix this bug, remove this. */ 
    680      
    681       if (uids) 
     679 
     680      if (uids) 
    682681                g_ptr_array_foreach (uids, add_message_with_uid, ptr); 
    683      
    684682        g_free (ptr); 
    685683 
    686684        if (uids) 
    687685                camel_folder_free_uids (priv->folder, uids);  
    688      
     686 
    689687        g_object_unref (G_OBJECT (headers)); 
    690688        g_mutex_unlock (priv->folder_lock); 
     
    695693 
    696694static TnyMsg* 
    697 tny_camel_folder_get_message (TnyFolder *self, TnyHeader *header) 
     695tny_camel_folder_get_msg (TnyFolder *self, TnyHeader *header) 
    698696{ 
    699697        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    700698        TnyMsg *message = NULL; 
    701       CamelMimeMessage *camel_message = NULL; 
     699      CamelMimeMessage *camel_message = NULL; 
    702700        const gchar *id; 
    703701        CamelException *ex = camel_exception_new (); 
    704      
     702 
    705703        g_mutex_lock (priv->folder_lock); 
    706704 
    707705        id = tny_header_get_uid (TNY_HEADER (header)); 
    708      
     706 
    709707        if (!load_folder_no_lock (priv)) 
    710708        { 
     
    720718        if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_NONE) 
    721719        { 
    722                 TnyCamelHeader *nheader = tny_camel_header_new (); 
     720                TnyCamelHeader *nheader = TNY_CAMEL_HEADER (tny_camel_header_new ()); 
    723721 
    724722                /* I don't reuse the header because that would keep a reference 
     
    761759                if (!load_folder (priv)) 
    762760                        return NULL; 
    763              
    764761                name = camel_folder_get_name (priv->folder); 
    765762        } else 
     
    883880{ 
    884881        TnyCamelFolder *self = g_object_new (TNY_TYPE_CAMEL_FOLDER, NULL); 
    885      
     882 
    886883        tny_camel_folder_set_folder (self, camel_folder); 
    887884 
     
    916913        g_mutex_lock (priv->folder_lock); 
    917914 
    918       if (priv->account) 
     915      if (priv->account) 
    919916        { 
    920917                TnyCamelStoreAccountPriv *apriv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (priv->account); 
    921918                apriv->managed_folders = g_list_remove (apriv->managed_folders, self); 
    922919        } 
    923      
     920 
    924921        if (!priv->iter_parented && priv->iter) 
    925922        { 
    926               CamelStore *store = (CamelStore*) _tny_camel_account_get_service (TNY_CAMEL_ACCOUNT (priv->account)); 
     923              CamelStore *store = (CamelStore*) _tny_camel_account_get_service (TNY_CAMEL_ACCOUNT (priv->account)); 
    927924                camel_store_free_folder_info (store, priv->iter); 
    928925        } 
    929     
     926 
    930927        unload_folder_no_lock (priv, TRUE); 
    931928 
     
    940937        priv->cached_name = NULL; 
    941938 
     939        if (G_LIKELY (priv->remove_strat)) 
     940                g_object_unref (G_OBJECT (priv->remove_strat)); 
     941        priv->remove_strat = NULL; 
    942942 
    943943        g_mutex_unlock (priv->folder_lock); 
     
    948948        g_mutex_free (priv->poshdr_lock); 
    949949        priv->poshdr_lock = NULL; 
    950      
     950 
    951951        if (priv->folder_name) 
    952952                g_free (priv->folder_name); 
    953      
     953 
    954954        (*parent_class->finalize) (object); 
    955955 
     
    971971void  
    972972_tny_camel_folder_check_uncache (TnyCamelFolder *self, TnyCamelFolderPriv *priv) 
    973 {     
     973{ 
    974974        if (priv->headers_managed == 0) 
    975975                tny_camel_folder_uncache (self); 
     
    977977 
    978978 
     979static TnyMsgRemoveStrategy*  
     980tny_camel_folder_get_msg_remove_strategy (TnyFolder *self) 
     981{ 
     982        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
     983 
     984        return TNY_MSG_REMOVE_STRATEGY (g_object_ref (G_OBJECT (priv->remove_strat))); 
     985} 
     986 
     987static void  
     988tny_camel_folder_set_msg_remove_strategy (TnyFolder *self, TnyMsgRemoveStrategy *st) 
     989{ 
     990        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
     991 
     992        if (priv->remove_strat) 
     993                g_object_unref (G_OBJECT (priv->remove_strat)); 
     994 
     995        priv->remove_strat = TNY_MSG_REMOVE_STRATEGY (g_object_ref (G_OBJECT (st))); 
     996 
     997        return; 
     998} 
     999 
     1000 
    9791001static void 
    9801002tny_folder_init (gpointer g, gpointer iface_data) 
     
    9821004        TnyFolderIface *klass = (TnyFolderIface *)g; 
    9831005 
     1006        klass->get_msg_remove_strategy_func = tny_camel_folder_get_msg_remove_strategy; 
     1007        klass->set_msg_remove_strategy_func = tny_camel_folder_set_msg_remove_strategy; 
    9841008        klass->get_headers_func = tny_camel_folder_get_headers; 
    985         klass->get_message_func = tny_camel_folder_get_message
     1009        klass->get_msg_func = tny_camel_folder_get_msg
    9861010        klass->get_id_func = tny_camel_folder_get_id; 
    9871011        klass->set_name_func = tny_camel_folder_set_name; 
     
    9941018        klass->refresh_async_func = tny_camel_folder_refresh_async; 
    9951019        klass->refresh_func = tny_camel_folder_refresh; 
    996         klass->remove_message_func = tny_camel_folder_remove_message
     1020        klass->remove_msg_func = tny_camel_folder_remove_msg
    9971021        klass->expunge_func = tny_camel_folder_expunge; 
    9981022 
     
    10151039        TnyCamelFolder *cfol = TNY_CAMEL_FOLDER (folder); 
    10161040        TnyCamelFolderPriv *cpriv = TNY_CAMEL_FOLDER_GET_PRIVATE (cfol); 
    1017       gchar *cfolname; gchar *folname; gint parlen; 
     1041      gchar *cfolname; gchar *folname; gint parlen; 
    10181042        CamelException ex = CAMEL_EXCEPTION_INITIALISER;     
    10191043 
    1020               if (!cpriv->folder_name || !priv->folder_name) 
     1044      if (!cpriv->folder_name || !priv->folder_name) 
    10211045                return; 
    10221046 
     
    10251049        parlen = strlen (folname); 
    10261050 
    1027         /* /INBOX/test  
     1051        /* /INBOX/test 
    10281052           /INBOX/test/test */ 
    1029      
    1030       if (!strncmp (folname, cfolname, parlen)) 
     1053 
     1054      if (!strncmp (folname, cfolname, parlen)) 
    10311055        { 
    10321056                gchar *ccfoln = cfolname + parlen; 
     
    10651089 
    10661090        folname = priv->folder_name; 
    1067       folder = tny_camel_folder_new (); 
     1091      folder = tny_camel_folder_new (); 
    10681092        info = camel_store_create_folder (store, priv->folder_name, name, &ex); 
    1069      
     1093 
    10701094        _tny_camel_folder_set_id (TNY_CAMEL_FOLDER (folder), info->full_name); 
    1071       camel_store_free_folder_info (store, info); 
     1095      camel_store_free_folder_info (store, info); 
    10721096 
    10731097        /* TODO: Error handling using 'ex' */ 
    10741098 
    1075       return folder; 
     1099      return folder; 
    10761100} 
    10771101 
     
    10801104_tny_camel_folder_set_folder_type (TnyCamelFolder *folder, CamelFolderInfo *folder_info) 
    10811105{ 
    1082       TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (folder); 
     1106      TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (folder); 
    10831107 
    10841108        if (!folder_info) 
     
    11131137{ 
    11141138        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (folder); 
    1115      
     1139 
    11161140        priv->iter = iter; 
    1117       priv->iter_parented = TRUE; 
    1118      
     1141      priv->iter_parented = TRUE; 
     1142 
    11191143        return; 
    11201144} 
     
    11321156        TnyCamelStoreAccountPriv *apriv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (priv->account); 
    11331157        CamelFolderInfo *iter; 
    1134  
    11351158 
    11361159        if (!priv->folder_name) 
     
    11441167                priv->iter_parented = FALSE; 
    11451168        }  
    1146      
     1169 
    11471170        iter = priv->iter; 
    1148      
    1149       if (iter) 
    1150         {                       
     1171  
     1172      if (iter) 
     1173        { 
    11511174          iter = iter->child; 
    1152                  
    11531175          while (iter) 
    1154         { 
     1176        { 
    11551177                if (_tny_folder_store_query_passes (query, iter)) 
    11561178                { 
     
    11701192 
    11711193                        tny_list_prepend (list, G_OBJECT (folder)); 
    1172                 }           
     1194                } 
    11731195                iter = iter->next; 
    11741196          } 
    11751197        } 
    1176      
    1177         return; 
    1178 
    1179  
    1180  
    1181 typedef struct { 
    1182     TnyFolderStore *self; 
    1183     TnyList *list; 
    1184     TnyGetFoldersCallback callback; 
    1185     TnyFolderStoreQuery *query; 
    1186     gpointer user_data; 
    1187     guint depth; 
     1198 
     1199        return; 
     1200
     1201 
     1202 
     1203typedef struct  
     1204
     1205        TnyFolderStore *self; 
     1206        TnyList *list; 
     1207        TnyGetFoldersCallback callback; 
     1208        TnyFolderStoreQuery *query; 
     1209        gpointer user_data; 
     1210        guint depth; 
    11881211} GetFoldersInfo; 
    11891212 
     
    11931216{ 
    11941217        GetFoldersInfo *info = thr_user_data; 
    1195      
     1218 
    11961219        /* gidle reference */ 
    11971220        g_object_unref (G_OBJECT (info->self)); 
     
    12181241{ 
    12191242        GetFoldersInfo *info = (GetFoldersInfo*) thr_user_data; 
    1220      
     1243 
    12211244        tny_folder_store_get_folders (TNY_FOLDER_STORE (info->self), 
    12221245                info->list, info->query); 
    1223      
     1246 
    12241247        if (info->query) 
    12251248                g_object_unref (G_OBJECT (info->query)); 
    12261249 
    1227       /* thread reference */ 
     1250      /* thread reference */ 
    12281251        g_object_unref (G_OBJECT (info->self)); 
    12291252        g_object_unref (G_OBJECT (info->list)); 
    1230      
     1253 
    12311254        if (info->callback) 
    12321255        { 
     
    12351258                g_object_ref (G_OBJECT (info->list)); 
    12361259 
    1237               if (info->depth > 0) 
     1260              if (info->depth > 0) 
    12381261                { 
    12391262                        g_idle_add_full (G_PRIORITY_HIGH,  
     
    12461269        } 
    12471270 
    1248  
    12491271        g_thread_exit (NULL); 
    1250      
     1272 
    12511273        return NULL; 
    12521274} 
     
    12551277tny_camel_folder_get_folders_async (TnyFolderStore *self, TnyList *list, TnyGetFoldersCallback callback, TnyFolderStoreQuery *query, gpointer user_data) 
    12561278{ 
    1257       TNY_CAMEL_FOLDER_GET_CLASS (self)->get_folders_async_func (self, list, callback, query, user_data); 
     1279      TNY_CAMEL_FOLDER_GET_CLASS (self)->get_folders_async_func (self, list, callback, query, user_data); 
    12581280} 
    12591281 
     
    12651287 
    12661288        info->self = self; 
    1267       info->list = list; 
     1289      info->list = list; 
    12681290        info->callback = callback; 
    12691291        info->user_data = user_data; 
    12701292        info->query = query; 
    1271       info->depth = g_main_depth (); 
    1272      
     1293      info->depth = g_main_depth (); 
     1294 
    12731295        /* thread reference */ 
    12741296        g_object_ref (G_OBJECT (info->self)); 
     
    12761298        if (info->query) 
    12771299                g_object_ref (G_OBJECT (info->query)); 
    1278      
     1300 
    12791301        thread = g_thread_create (tny_camel_folder_get_folders_async_thread, 
    12801302                        info, FALSE, NULL);     
     
    12931315        klass->get_folders_func = tny_camel_folder_get_folders; 
    12941316        klass->get_folders_async_func = tny_camel_folder_get_folders_async; 
    1295                                          
    1296       return; 
     1317 
     1318      return; 
    12971319} 
    12981320 
     
    13061328        object_class->finalize = tny_camel_folder_finalize; 
    13071329 
    1308       class->get_folders_async_func = tny_camel_folder_get_folders_async_default; 
     1330      class->get_folders_async_func = tny_camel_folder_get_folders_async_default; 
    13091331        class->get_folders_func = tny_camel_folder_get_folders_default; 
    13101332        class->create_folder_func = tny_camel_folder_create_folder_default; 
    13111333        class->remove_folder_func = tny_camel_folder_remove_folder_default; 
    1312      
     1334 
    13131335        g_type_class_add_private (object_class, sizeof (TnyCamelFolderPriv)); 
    13141336 
     
    13241346        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    13251347 
    1326       priv->iter = NULL; 
     1348      priv->iter = NULL; 
    13271349        priv->iter_parented = FALSE; 
    13281350        priv->headers_managed = 0; 
     
    13341356        priv->cached_name = NULL; 
    13351357        priv->cached_folder_type = TNY_FOLDER_TYPE_UNKNOWN; 
    1336          
     1358 
     1359        priv->remove_strat = tny_camel_msg_remove_strategy_new (); 
     1360 
    13371361        return; 
    13381362} 
  • trunk/libtinymail-camel/tny-camel-folder.h

    r900 r1092  
    4949{ 
    5050        GObjectClass parent; 
    51      
    52       /* virtual methods (they have a default implementation in TnyCamelFolder */ 
     51 
     52      /* virtual methods (they have a default implementation in TnyCamelFolder */ 
    5353        void (*get_folders_async_func) (TnyFolderStore *self, TnyList *list, TnyGetFoldersCallback callback, TnyFolderStoreQuery *query, gpointer user_data); 
    5454        void (*get_folders_func) (TnyFolderStore *self, TnyList *list, TnyFolderStoreQuery *query); 
  • trunk/libtinymail-test/tny-folder-test.c

    r965 r1092  
    148148tny_folder_test_remove_message (void) 
    149149{ 
    150       TnyList *headers; 
     150      TnyList *headers; 
    151151        gint orig_length = 0, test_len = 0, new_len = 0, headers_len = 0; 
    152152        TnyIterator *iter; 
    153       TnyHeader *header; 
    154      
    155       if (iface == NULL) 
     153      TnyHeader *header; 
     154         
     155      if (iface == NULL) 
    156156        { 
    157157                GUNIT_WARNING ("Test cannot continue (are you online?)"); 
    158               return; 
     158              return; 
    159159        } 
    160      
    161       headers = tny_simple_list_new (); 
     160         
     161      headers = tny_simple_list_new (); 
    162162        tny_folder_refresh (iface); 
    163163         
    164164        tny_folder_get_headers (iface, headers, FALSE); 
    165165        orig_length = tny_list_get_length (headers); 
    166         test_len = tny_folder_get_all_count (iface); 
    167      
     166       test_len = tny_folder_get_all_count (iface); 
     167         
    168168        str = g_strdup_printf ("I received %d headers, the folder tells me it has %d messages\n", orig_length, test_len); 
    169169        gunit_fail_unless (orig_length == test_len, str); 
    170170        g_free (str); 
    171      
    172       iter = tny_list_create_iterator (headers); 
    173       tny_iterator_first (iter); 
    174       header = (TnyHeader*)tny_iterator_get_current (iter); 
    175  
    176       /* Flag as removed */ 
    177        tny_folder_remove_message (iface, header); 
    178       tny_folder_refresh (iface); 
    179  
    180       g_object_unref (G_OBJECT (headers)); 
    181  
    182      
    183       new_len = tny_folder_get_all_count (iface); 
    184       str = g_strdup_printf ("After removal but not yet expunge, the new length is %d, whereas it should be %d\n", new_len, orig_length); 
     171         
     172      iter = tny_list_create_iterator (headers); 
     173      tny_iterator_first (iter); 
     174      header = (TnyHeader*)tny_iterator_get_current (iter); 
     175         
     176      /* Flag as removed */ 
     177       tny_folder_remove_msg (iface, header); 
     178      tny_folder_refresh (iface); 
     179         
     180      g_object_unref (G_OBJECT (headers)); 
     181         
     182         
     183      new_len = tny_folder_get_all_count (iface); 
     184      str = g_strdup_printf ("After removal but not yet expunge, the new length is %d, whereas it should be %d\n", new_len, orig_length); 
    185185        gunit_fail_unless (new_len == orig_length, str); 
    186186        g_free (str); 
    187  
    188       headers = tny_simple_list_new (); 
    189       tny_folder_get_headers (iface, headers, FALSE); 
     187         
     188      headers = tny_simple_list_new (); 
     189      tny_folder_get_headers (iface, headers, FALSE); 
    190190        headers_len = tny_list_get_length (headers); 
    191191        g_object_unref (G_OBJECT (headers)); 
    192  
    193               str = g_strdup_printf ("After removal but not yet expunge, the header count is %d, whereas it should be %d\n", headers_len, orig_length); 
     192         
     193      str = g_strdup_printf ("After removal but not yet expunge, the header count is %d, whereas it should be %d\n", headers_len, orig_length); 
    194194        gunit_fail_unless (new_len == orig_length, str); 
    195195        g_free (str); 
    196  
    197       /* Expunge ...*/ 
    198       tny_folder_expunge (iface);     
    199         tny_folder_refresh (iface); 
    200      
    201         new_len = tny_folder_get_all_count (iface); 
    202       str = g_strdup_printf ("After removal, the new length is %d, whereas it should be %d\n", new_len, orig_length-1); 
     196         
     197      /* Expunge ...*/ 
     198      tny_folder_expunge (iface);     
     199        tny_folder_refresh (iface); 
     200         
     201       new_len = tny_folder_get_all_count (iface); 
     202      str = g_strdup_printf ("After removal, the new length is %d, whereas it should be %d\n", new_len, orig_length-1); 
    203203        gunit_fail_unless (new_len == orig_length-1, str); 
    204204        g_free (str); 
    205  
    206       headers = tny_simple_list_new (); 
    207       tny_folder_get_headers (iface, headers, FALSE); 
     205         
     206      headers = tny_simple_list_new (); 
     207      tny_folder_get_headers (iface, headers, FALSE); 
    208208        headers_len = tny_list_get_length (headers); 
    209209        g_object_unref (G_OBJECT (headers)); 
    210  
    211               str = g_strdup_printf ("After removal, the header count is %d, whereas it should be %d\n", headers_len, orig_length-1); 
     210         
     211      str = g_strdup_printf ("After removal, the header count is %d, whereas it should be %d\n", headers_len, orig_length-1); 
    212212        gunit_fail_unless (new_len == orig_length-1, str); 
    213213        g_free (str); 
    214  
     214         
    215215} 
    216216 
  • trunk/libtinymail/Makefile.am

    r994 r1092  
    2020        tny-simple-list.h \ 
    2121        tny-folder-store.h \ 
    22         tny-folder-store-query.h 
     22        tny-folder-store-query.h \ 
     23        tny-msg-remove-strategy.h 
    2324 
    2425libtinymail_1_0_la_SOURCES = \ 
     
    4243        tny-simple-list-iterator.c \ 
    4344        tny-folder-store.c \ 
    44         tny-folder-store-query.c 
     45        tny-folder-store-query.c \ 
     46        tny-msg-remove-strategy.c 
    4547 
    4648libtinymail_1_0_la_LIBADD = $(LIBTINYMAIL_LIBS) 
  • trunk/libtinymail/tny-folder.c

    r1012 r1092  
    2626guint tny_folder_signals [TNY_FOLDER_LAST_SIGNAL]; 
    2727 
     28 
     29/** 
     30 * tny_folder_get_msg_remove_strategy: 
     31 * @self: a TnyFolder object 
     32 * 
     33 * Get the strategy for removing a message. The return value of this method 
     34 * must be unreferenced after use. 
     35 *  
     36 * Return value: the strategy for removing a message 
     37 **/ 
     38TnyMsgRemoveStrategy*  
     39tny_folder_get_msg_remove_strategy (TnyFolder *self) 
     40{ 
     41#ifdef DEBUG 
     42        if (!TNY_FOLDER_GET_IFACE (self)->get_msg_remove_strategy_func) 
     43                g_critical ("You must implement tny_folder_get_msg_remove_strategy\n"); 
     44#endif 
     45        return TNY_FOLDER_GET_IFACE (self)->get_msg_remove_strategy_func (self); 
     46} 
     47 
     48/** 
     49 * tny_folder_set_msg_remove_strategy: 
     50 * @self: a TnyFolder object 
     51 * @st: a #TnyMsgRemoveStrategy object 
     52 * 
     53 * Set the strategy for removing a message 
     54 *  
     55 **/ 
     56void  
     57tny_folder_set_msg_remove_strategy (TnyFolder *self, TnyMsgRemoveStrategy *st) 
     58{ 
     59#ifdef DEBUG 
     60        if (!TNY_FOLDER_GET_IFACE (self)->set_msg_remove_strategy_func) 
     61                g_critical ("You must implement tny_folder_set_msg_remove_strategy\n"); 
     62#endif 
     63        TNY_FOLDER_GET_IFACE (self)->set_msg_remove_strategy_func (self, st); 
     64        return; 
     65} 
     66 
    2867/** 
    2968 * tny_folder_expunge: 
     
    3776 * TnyHeader *header = ... 
    3877 * TnyFolder *folder = tny_header_ge