Changeset 3119

Show
Ignore:
Timestamp:
12/14/07 00:42:03
Author:
pvanhoof
Message:
        • Added two connection strategies. One that retries every five seconds

to reconnect, and recovers the state (the selected folder)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r3118 r3119  
    44        changes (for example sheduling a reconnect or asking the user what to 
    55        do about the event of a lost connection) 
     6        * Added two connection strategies. One that retries every five seconds 
     7        to reconnect, and recovers the state (the selected folder) 
    68 
    792007-12-13  Alberto Garcia Gonzalez  <agarcia@igalia.com> 
     
    223422362007-05-26  Philip Van Hoof  <pvanhoof@gnome.org> 
    22352237 
    2236         * Experimental connection recovery for IMAP 
     2238        * Experimental connection camel_recovery for IMAP 
    22372239        * Letting IDLE/PushE-mail support code cope with connection failures 
    22382240 
  • trunk/libtinymail-camel/Makefile.am

    r3118 r3119  
    3939        tny-camel-bs-mime-part.h \ 
    4040        tny-camel-bs-msg-receive-strategy.h \ 
    41         tny-camel-default-connection-strategy.h 
     41        tny-camel-default-connection-strategy.h \ 
     42        tny-camel-recover-connection-strategy.h 
    4243 
    4344libtinymail_camel_priv_headers = \ 
     
    9596        tny-camel-bs-msg-receive-strategy.c \ 
    9697        tny-camel-bs-msg-header.c \ 
    97         tny-camel-default-connection-strategy.c 
     98        tny-camel-default-connection-strategy.c \ 
     99        tny-camel-recover-connection-strategy.c 
    98100 
    99101libtinymail_camel_1_0_la_LIBADD = \ 
  • trunk/libtinymail-camel/camel-lite/camel/camel-folder-summary.c

    r3114 r3119  
    22742274        { 
    22752275 
    2276                 /* We are not reloading, so searching for recoverable 
     2276                /* We are not reloading, so searching for camel_recoverable 
    22772277                 * CamelMessageInfo struct instances is avoidable */ 
    22782278                mi = (CamelMessageInfoBase *) camel_message_info_new (s); 
  • trunk/libtinymail-camel/camel-lite/camel/camel-net-utils.c

    r2950 r3119  
    193193                break; 
    194194        default: 
    195                 return NO_RECOVERY; 
     195                return NO_CAMEL_RECOVERY; 
    196196                break; 
    197197        } 
  • trunk/libtinymail-camel/camel-lite/camel/camel-net-utils.h

    r2950 r3119  
    6868#define EAI_NONAME        -2    /* NAME or SERVICE is unknown.  */ 
    6969#define EAI_AGAIN         -3    /* Temporary failure in name resolution.  */ 
    70 #define EAI_FAIL          -4    /* Non-recoverable failure in name res.  */ 
     70#define EAI_FAIL          -4    /* Non-camel_recoverable failure in name res.  */ 
    7171#define EAI_NODATA        -5    /* No address associated with NAME.  */ 
    7272#define EAI_FAMILY        -6    /* `ai_family' not supported.  */ 
  • trunk/libtinymail-camel/camel-lite/camel/camel-store-summary.c

    r2950 r3119  
    941941 
    942942        /* Ok, brown paper bag bug - prior to version 2 of the file, flags are 
    943            stored using the bit number, not the bit. Try to recover as best we can */ 
     943           stored using the bit number, not the bit. Try to camel_recover as best we can */ 
    944944        if (s->version < CAMEL_STORE_SUMMARY_VERSION_2) { 
    945945                guint32 flags = 0; 
  • trunk/libtinymail-camel/camel-lite/camel/camel-text-index.c

    r3068 r3119  
    354354} 
    355355 
    356 /* Attempt to recover index space by compressing the indices */ 
     356/* Attempt to camel_recover index space by compressing the indices */ 
    357357static int 
    358358text_index_compress_nosync(CamelIndex *idx) 
  • trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c

    r3112 r3119  
    1212 * 
    1313 * It has support for CONDSTORE, BINARY and IMAP IDLE. This implementation will 
    14  * write received information to disk as soon as possible, and will try recover 
     14 * write received information to disk as soon as possible, and will try camel_recover 
    1515 * the state using this information as much as possible. 
    1616 * 
  • trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c

    r3091 r3119  
    836836                if (store->ostream && CAMEL_IS_STREAM (store->ostream)) 
    837837                { 
    838                         /* This is a recoverable situation. It's strange though */ 
     838                        /* This is a camel_recoverable situation. It's strange though */ 
    839839                        store->istream = camel_stream_buffer_new (store->ostream, CAMEL_STREAM_BUFFER_READ); 
    840840                } else { 
     
    843843                        camel_service_disconnect (CAMEL_SERVICE (store), FALSE, &ex); 
    844844                        camel_exception_clear (&ex); 
    845                         g_warning ("Something terrible happened with your connection.\nTrying to recover. (%s)\n", 
     845                        g_warning ("Something terrible happened with your connection.\nTrying to camel_recover. (%s)\n", 
    846846                                g_strerror (errno)); 
    847847                        camel_service_connect (CAMEL_SERVICE (store), &ex); 
    848848                        if (camel_exception_is_set (&ex)) 
    849                                 g_warning ("Connection recovery failed: %s", 
     849                                g_warning ("Connection camel_recovery failed: %s", 
    850850                                        camel_exception_get_description (&ex)); 
    851851                        return FALSE; 
  • trunk/libtinymail-camel/camel-lite/camel/providers/local/camel-local-store.c

    r2967 r3119  
    435435        return; 
    436436 
    437         /* The (f)utility of this recovery effort is quesitonable */ 
     437        /* The (f)utility of this camel_recovery effort is quesitonable */ 
    438438 
    439439        xrename(new, old, path, ".cmeta", TRUE, ex); 
  • trunk/libtinymail-camel/camel-lite/camel/providers/local/camel-mbox-folder.c

    r2950 r3119  
    404404                camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID, 
    405405                                     _("Cannot get message: %s from folder %s\n  %s"), uid, lf->folder_path, 
    406                                      _("The folder appears to be irrecoverably corrupted.")); 
     406                                     _("The folder appears to be ircamel_recoverably corrupted.")); 
    407407                goto fail; 
    408408        } 
  • trunk/libtinymail-camel/tny-camel-account-priv.h

    r3118 r3119  
    7373        GList *chooks; 
    7474        TnyConnectionStatus status; 
    75         gboolean is_connecting, is_ready
     75        gboolean is_connecting, is_ready, retry_connect
    7676        gchar *delete_this; 
    7777        TnyCamelQueue *queue; 
  • trunk/libtinymail-camel/tny-camel-account.c

    r3118 r3119  
    13701370        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
    13711371 
     1372        priv->retry_connect = FALSE; 
    13721373        priv->con_strat = tny_camel_default_connection_strategy_new (); 
    13731374        priv->queue = _tny_camel_queue_new (self); 
     
    17001701 
    17011702        if (TNY_IS_CAMEL_STORE_ACCOUNT (self)) { 
     1703                priv->retry_connect = TRUE; 
    17021704                if (online) 
    17031705                        camel_session_set_online ((CamelSession *) session, TRUE);  
  • trunk/libtinymail-camel/tny-camel-default-connection-strategy.c

    r3118 r3119  
    88 
    99static GObjectClass *parent_class = NULL; 
     10 
     11static void 
     12tny_camel_default_connection_strategy_set_current (TnyConnectionStrategy *self, TnyAccount *account, TnyFolder *folder) 
     13{ 
     14        return; 
     15} 
    1016 
    1117static void 
     
    4450        klass->on_connection_broken_func = tny_camel_default_connection_strategy_on_connection_broken; 
    4551        klass->on_disconnect_func = tny_camel_default_connection_strategy_on_disconnect; 
     52        klass->set_current_func = tny_camel_default_connection_strategy_set_current; 
    4653} 
    4754 
  • trunk/libtinymail-camel/tny-camel-folder.c

    r3118 r3119  
    4848#include <tny-simple-list.h> 
    4949#include <tny-merge-folder.h> 
     50#include <tny-connection-strategy.h> 
    5051 
    5152 
     
    446447                                camel_object_unref (CAMEL_OBJECT (priv->folder)); 
    447448                } else 
    448                         g_critical ("Corrupted CamelFolder instance at (I can't recover from this state, therefore I will leak)\n"); 
     449                        g_critical ("Corrupted CamelFolder instance at (I can't camel_recover from this state, therefore I will leak)\n"); 
    449450        } 
    450451 
     
    16401641        TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 
    16411642        TnyFolderChange *change = tny_folder_change_new (self); 
     1643        TnyConnectionStrategy *constrat; 
    16421644 
    16431645        tny_folder_change_set_new_all_count (change, priv->cached_length); 
     
    16511653                tny_lockable_unlock (info->session->priv->ui_lock); 
    16521654        } 
     1655 
     1656        constrat = tny_account_get_connection_strategy (priv->account); 
     1657        tny_connection_strategy_set_current (constrat, priv->account, self); 
     1658        g_object_unref (constrat); 
    16531659 
    16541660        tny_idle_stopper_stop (info->stopper); 
     
    17711777 * It's actually very simple: just store all the interesting info in a struct  
    17721778 * launch a thread and keep that struct-instance around. In the callbacks, 
    1773  * which you stored as function pointers, recover that info and pass it to the 
     1779 * which you stored as function pointers, camel_recover that info and pass it to the 
    17741780 * user of the _async method. 
    17751781 * 
     
    18311837        guint oldlen, oldurlen; 
    18321838        TnyFolderChange *change = NULL; 
     1839        TnyConnectionStrategy *constrat; 
    18331840 
    18341841        if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv),  
     
    18741881        notify_folder_observers_about_in_idle (self, change); 
    18751882        g_object_unref (change); 
     1883 
     1884        constrat = tny_account_get_connection_strategy (priv->account); 
     1885        tny_connection_strategy_set_current (constrat, priv->account, self); 
     1886        g_object_unref (constrat); 
    18761887 
    18771888        return; 
  • trunk/libtinymail-camel/tny-camel-store-account.c

    r3118 r3119  
    250250} 
    251251 
     252 
     253static void 
     254let_connection_strat_know (TnyAccount *self) 
     255{ 
     256        TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
     257 
     258        if (apriv->status == TNY_CONNECTION_STATUS_CONNECTED_BROKEN) 
     259                g_idle_add_full (G_PRIORITY_HIGH,  
     260                        constrat_notify_broken,  
     261                        g_object_ref (self),  
     262                        constrat_notify_destroy); 
     263        else if (apriv->status == TNY_CONNECTION_STATUS_CONNECTED) 
     264                g_idle_add_full (G_PRIORITY_HIGH,  
     265                        constrat_notify_connect,  
     266                        g_object_ref (self),  
     267                        constrat_notify_destroy); 
     268        else if (apriv->status == TNY_CONNECTION_STATUS_DISCONNECTED) 
     269                g_idle_add_full (G_PRIORITY_HIGH,  
     270                        constrat_notify_disconnect,  
     271                        g_object_ref (self),  
     272                        constrat_notify_destroy); 
     273 
     274        return; 
     275} 
     276 
    252277static void  
    253278disconnection (CamelService *service, gboolean suc, TnyAccount *self) 
     
    295320        TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
    296321        TnyCamelStoreAccountPriv *priv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self); 
    297         gboolean emit = FALSE; 
     322        gboolean emit = apriv->retry_connect; 
     323 
     324        apriv->retry_connect = FALSE; 
    298325 
    299326        priv->cant_reuse_iter = TRUE; 
     
    391418        if (emit) { 
    392419                tny_camel_store_account_do_emit (TNY_CAMEL_STORE_ACCOUNT (self)); 
    393  
    394                 if (apriv->status == TNY_CONNECTION_STATUS_DISCONNECTED_BROKEN) 
    395                         g_idle_add_full (G_PRIORITY_HIGH,  
    396                                 constrat_notify_broken,  
    397                                 g_object_ref (self),  
    398                                 constrat_notify_destroy); 
    399                 else if (apriv->status == TNY_CONNECTION_STATUS_CONNECTED) 
    400                         g_idle_add_full (G_PRIORITY_HIGH,  
    401                                 constrat_notify_connect,  
    402                                 g_object_ref (self),  
    403                                 constrat_notify_destroy); 
    404                 else if (apriv->status == TNY_CONNECTION_STATUS_DISCONNECTED) 
    405                         g_idle_add_full (G_PRIORITY_HIGH,  
    406                                 constrat_notify_disconnect,  
    407                                 g_object_ref (self),  
    408                                 constrat_notify_destroy); 
    409         } 
    410  
     420                let_connection_strat_know (self); 
     421        } 
    411422} 
    412423 
  • trunk/libtinymail/tny-connection-strategy.c

    r3118 r3119  
    2020#include <config.h> 
    2121#include <tny-account.h> 
     22#include <tny-folder.h> 
    2223#include <tny-connection-strategy.h> 
    2324#include <tny-list.h> 
     25 
     26 
     27/** 
     28 * tny_connection_strategy_set_current: 
     29 * @self: A #TnyConnectionStrategy instance 
     30 * @account: the current #TnyAccount instance 
     31 * @folder: the current #TnyFolder instance 
     32 * 
     33 * Used to set the current situation (in case @self wants to restore this  
     34 * situation in case of a connection event). 
     35 **/ 
     36void  
     37tny_connection_strategy_set_current (TnyConnectionStrategy *self, TnyAccount *account, TnyFolder *folder) 
     38{ 
     39#ifdef DBC /* require */ 
     40        g_assert (TNY_IS_CONNECTION_STRATEGY (self)); 
     41        g_assert (TNY_IS_ACCOUNT (account)); 
     42        g_assert (TNY_IS_FOLDER (folder)); 
     43 
     44        g_assert (TNY_CONNECTION_STRATEGY_GET_IFACE (self)->set_current_func != NULL); 
     45#endif 
     46 
     47        TNY_CONNECTION_STRATEGY_GET_IFACE (self)->set_current_func (self, account, folder); 
     48 
     49        return; 
     50} 
    2451 
    2552/** 
  • trunk/libtinymail/tny-connection-strategy.h

    r3118 r3119  
    4545        void (*on_connection_broken_func) (TnyConnectionStrategy *self, TnyAccount *account); 
    4646        void (*on_disconnect_func) (TnyConnectionStrategy *self, TnyAccount *account); 
     47        void (*set_current_func) (TnyConnectionStrategy *self, TnyAccount *account, TnyFolder *folder); 
     48 
    4749}; 
    4850 
     
    5254void tny_connection_strategy_on_disconnect (TnyConnectionStrategy *self, TnyAccount *account); 
    5355void tny_connection_strategy_on_connection_broken (TnyConnectionStrategy *self, TnyAccount *account); 
     56void tny_connection_strategy_set_current (TnyConnectionStrategy *self, TnyAccount *account, TnyFolder *folder); 
    5457 
    5558G_END_DECLS 
  • trunk/libtinymail/tny-mime-part.c

    r3070 r3119  
    323323 * Using the tny_msg_rewrite_cache API on a message instance will rewrite its  
    324324 * purged mime parts with an empty body (saving storage space). The storage  
    325  * space is recovered after using tny_msg_rewrite_cache. Only setting a mime  
     325 * space is camel_recovered after using tny_msg_rewrite_cache. Only setting a mime  
    326326 * part to purged might not remove it. 
    327327 *