Changeset 3118

Show
Ignore:
Timestamp:
12/13/07 23:37:34
Author:
pvanhoof
Message:

2007-12-13 Philip Van Hoof <pvanhoof@gnome.org>

changes (for example sheduling a reconnect or asking the user what to
do about the event of a lost connection)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r3111 r3118  
     12007-12-13  Philip Van Hoof <pvanhoof@gnome.org> 
     2 
     3        * Added the TnyConnectionStrategy type for coping with connectivity 
     4        changes (for example sheduling a reconnect or asking the user what to 
     5        do about the event of a lost connection) 
     6 
    172007-12-13  Alberto Garcia Gonzalez  <agarcia@igalia.com> 
    28 
  • trunk/libtinymail-camel/Makefile.am

    r3078 r3118  
    3838        tny-camel-bs-msg.h \ 
    3939        tny-camel-bs-mime-part.h \ 
    40         tny-camel-bs-msg-receive-strategy.h 
     40        tny-camel-bs-msg-receive-strategy.h \ 
     41        tny-camel-default-connection-strategy.h 
    4142 
    4243libtinymail_camel_priv_headers = \ 
     
    9394        tny-camel-bs-mime-part.c \ 
    9495        tny-camel-bs-msg-receive-strategy.c \ 
    95         tny-camel-bs-msg-header.c 
     96        tny-camel-bs-msg-header.c \ 
     97        tny-camel-default-connection-strategy.c 
    9698 
    9799libtinymail_camel_1_0_la_LIBADD = \ 
  • trunk/libtinymail-camel/tny-camel-account-priv.h

    r2993 r3118  
    7676        gchar *delete_this; 
    7777        TnyCamelQueue *queue; 
     78        TnyConnectionStrategy *con_strat; 
    7879}; 
    7980 
  • trunk/libtinymail-camel/tny-camel-account.c

    r3113 r3118  
    4747#include <tny-camel-shared.h> 
    4848#include <tny-status.h> 
     49 
     50#include <tny-camel-default-connection-strategy.h> 
    4951 
    5052#include "tny-session-camel-priv.h" 
     
    13681370        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
    13691371 
     1372        priv->con_strat = tny_camel_default_connection_strategy_new (); 
    13701373        priv->queue = _tny_camel_queue_new (self); 
    13711374        priv->delete_this = NULL; 
     
    17391742 
    17401743 
     1744static TnyConnectionStrategy*  
     1745tny_camel_account_get_connection_strategy (TnyAccount *self) 
     1746{ 
     1747        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
     1748        return TNY_CONNECTION_STRATEGY (g_object_ref (priv->con_strat)); 
     1749} 
     1750 
     1751static void  
     1752tny_camel_account_set_connection_strategy (TnyAccount *self, TnyConnectionStrategy *strategy) 
     1753{ 
     1754        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
     1755        g_object_unref (priv->con_strat); 
     1756        priv->con_strat = TNY_CONNECTION_STRATEGY (g_object_ref (strategy)); 
     1757        return; 
     1758} 
     1759 
     1760 
     1761 
    17411762 
    17421763 
     
    19942015        g_free (priv->cancel_lock); 
    19952016        priv->cancel_lock = NULL; 
    1996  
    19972017        priv->inuse_spin = FALSE; 
    19982018 
     
    20412061 
    20422062        g_object_unref (priv->queue); 
     2063        g_object_unref (priv->con_strat); 
    20432064 
    20442065        camel_exception_free (priv->ex); 
     
    20902111        klass->stop_operation_func =  tny_camel_account_stop_operation; 
    20912112        klass->is_ready_func = tny_camel_account_is_ready; 
     2113        klass->set_connection_strategy_func = tny_camel_account_set_connection_strategy; 
     2114        klass->get_connection_strategy_func = tny_camel_account_get_connection_strategy; 
    20922115 
    20932116        return; 
  • trunk/libtinymail-camel/tny-camel-account.h

    r2825 r3118  
    8989        void (*stop_operation_func) (TnyAccount *self, gboolean *canceled); 
    9090 
    91  
    9291        void (*add_option_func) (TnyCamelAccount *self, const gchar *option); 
    9392        void (*set_online_func) (TnyCamelAccount *self, gboolean online, TnyCamelSetOnlineCallback callback, gpointer user_data); 
  • trunk/libtinymail-camel/tny-camel-folder.c

    r3106 r3118  
    24872487                                nhdr = tny_msg_get_header (retval); 
    24882488                                /* This trick is for forcing owning a TnyCamelHeader reference */ 
    2489                                 _tny_camel_msg_header_set_decorated (nhdr, hdr, TRUE); 
     2489                                _tny_camel_msg_header_set_decorated ((TnyCamelMsgHeader *) nhdr, hdr, TRUE); 
    24902490                                g_object_unref (nhdr); 
    24912491                        } 
  • trunk/libtinymail-camel/tny-camel-store-account.c

    r3113 r3118  
    203203} 
    204204 
     205static gboolean 
     206constrat_notify_connect (gpointer user_data) 
     207{ 
     208        TnyAccount *self = (TnyAccount *) user_data; 
     209        TnyConnectionStrategy *strategy = tny_account_get_connection_strategy (self); 
     210 
     211        tny_connection_strategy_on_connect (strategy, self); 
     212 
     213        g_object_unref (strategy); 
     214 
     215        return FALSE; 
     216} 
     217 
     218 
     219static gboolean 
     220constrat_notify_broken (gpointer user_data) 
     221{ 
     222        TnyAccount *self = (TnyAccount *) user_data; 
     223        TnyConnectionStrategy *strategy = tny_account_get_connection_strategy (self); 
     224 
     225        tny_connection_strategy_on_connection_broken (strategy, self); 
     226 
     227        g_object_unref (strategy); 
     228 
     229        return FALSE; 
     230} 
     231 
     232 
     233static gboolean 
     234constrat_notify_disconnect (gpointer user_data) 
     235{ 
     236        TnyAccount *self = (TnyAccount *) user_data; 
     237        TnyConnectionStrategy *strategy = tny_account_get_connection_strategy (self); 
     238 
     239        tny_connection_strategy_on_disconnect (strategy, self); 
     240 
     241        g_object_unref (strategy); 
     242 
     243        return FALSE; 
     244} 
     245 
     246static void  
     247constrat_notify_destroy (gpointer user_data) 
     248{ 
     249        g_object_unref (user_data); 
     250} 
    205251 
    206252static void  
     
    222268                        emit = TRUE; 
    223269                apriv->status = TNY_CONNECTION_STATUS_DISCONNECTED; 
     270 
     271 
     272                g_idle_add_full (G_PRIORITY_HIGH,  
     273                                constrat_notify_disconnect,  
     274                                g_object_ref (self),  
     275                                constrat_notify_destroy); 
    224276 
    225277                if (emit) 
     
    337389        } 
    338390 
    339         if (emit) 
     391        if (emit) { 
    340392                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        } 
    341410 
    342411} 
  • trunk/libtinymail/Makefile.am

    r3082 r3118  
    4949        tny-password-getter.h \ 
    5050        tny-merge-folder.h \ 
    51         tny-combined-account.h 
     51        tny-combined-account.h \ 
     52        tny-connection-strategy.h 
    5253 
    5354libtinymail_1_0_la_SOURCES = \ 
     
    9293        tny-idle-stopper.c \ 
    9394        tny-progress-info.c \ 
     95        tny-connection-strategy.c \ 
    9496        $(private_headers) 
    9597 
  • trunk/libtinymail/tny-account.c

    r2903 r3118  
    3030 
    3131guint tny_account_signals [TNY_ACCOUNT_LAST_SIGNAL]; 
     32 
     33 
     34/** 
     35 * tny_account_get_connection_strategy: 
     36 * @self: a #TnyAccount object 
     37 * 
     38 * Get the connection strategy for @self. You must unreference the returned  
     39 * value when you are finished with used it. 
     40 * 
     41 * Return value: connection strategy 
     42 **/ 
     43TnyConnectionStrategy*  
     44tny_account_get_connection_strategy (TnyAccount *self) 
     45{ 
     46        TnyConnectionStrategy *retval; 
     47 
     48#ifdef DBC /* require */ 
     49        g_assert (TNY_IS_ACCOUNT (self)); 
     50        g_assert (TNY_ACCOUNT_GET_IFACE (self)->get_connection_strategy_func != NULL); 
     51#endif 
     52 
     53        retval = TNY_ACCOUNT_GET_IFACE (self)->get_connection_strategy_func (self); 
     54 
     55#ifdef DBC /* ensure*/ 
     56        g_assert (TNY_IS_CONNECTION_STRATEGY (retval)); 
     57#endif 
     58 
     59        return retval; 
     60} 
     61 
     62/** 
     63 * tny_account_set_connection_strategy: 
     64 * @self: a #TnyAccount object 
     65 * @strategy: the #TnyConnectionStrategy 
     66 * 
     67 * Set the connection strategy for @self. 
     68 **/ 
     69void  
     70tny_account_set_connection_strategy (TnyAccount *self, TnyConnectionStrategy *strategy) 
     71{ 
     72#ifdef DBC /* require */ 
     73        g_assert (TNY_IS_ACCOUNT (self)); 
     74        g_assert (TNY_IS_CONNECTION_STRATEGY (strategy)); 
     75        g_assert (TNY_ACCOUNT_GET_IFACE (self)->set_connection_strategy_func != NULL); 
     76#endif 
     77 
     78        TNY_ACCOUNT_GET_IFACE (self)->set_connection_strategy_func (self, strategy); 
     79 
     80#ifdef DBC /* ensure*/ 
     81#endif 
     82 
     83        return; 
     84} 
    3285 
    3386 
  • trunk/libtinymail/tny-account.h

    r3080 r3118  
    2525#include <tny-shared.h> 
    2626#include <tny-status.h> 
     27#include <tny-connection-strategy.h> 
    2728 
    2829G_BEGIN_DECLS 
     
    109110        void (*stop_operation_func) (TnyAccount *self, gboolean *canceled); 
    110111        gboolean (*is_ready_func) (TnyAccount *self); 
     112        TnyConnectionStrategy* (*get_connection_strategy_func) (TnyAccount *self); 
     113        void (*set_connection_strategy_func) (TnyAccount *self, TnyConnectionStrategy *strategy); 
    111114 
    112115        /* Signals*/ 
     
    147150void tny_account_stop_operation (TnyAccount *self, gboolean *canceled); 
    148151gboolean tny_account_is_ready (TnyAccount *self); 
     152TnyConnectionStrategy* tny_account_get_connection_strategy (TnyAccount *self); 
     153void tny_account_set_connection_strategy (TnyAccount *self, TnyConnectionStrategy *strategy); 
    149154 
    150155 
  • trunk/libtinymail/tny-shared.h

    r3106 r3118  
    101101typedef struct _TnyCombinedAccount TnyCombinedAccount; 
    102102typedef struct _TnyCombinedAccountClass TnyCombinedAccountClass; 
     103typedef struct _TnyConnectionStrategy TnyConnectionStrategy; 
     104typedef struct _TnyConnectionStrategyIface TnyConnectionStrategyIface; 
    103105 
    104106typedef gchar* (*TnyGetPassFunc) (TnyAccount *self, const gchar *prompt, gboolean *cancel); 
  • trunk/libtinymail/tny.h

    r3086 r3118  
    3636#include <tny-stream.h> 
    3737#include <tny-transport-account.h> 
     38#include <tny-connection-strategy.h> 
    3839 
    3940#endif