Changeset 1498

Show
Ignore:
Timestamp:
01/29/07 01:49:11
Author:
pvanhoof
Message:

Some bugfixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libtinymail-camel/tny-camel-account-priv.h

    r1490 r1498  
    4949void _tny_camel_account_start_camel_operation (TnyCamelAccount *self, CamelOperationStatusFunc func, gpointer user_data, const gchar *what); 
    5050void _tny_camel_account_stop_camel_operation (TnyCamelAccount *self); 
     51void _tny_camel_account_try_connect (TnyCamelAccount *self, GError **err); 
    5152 
    5253#define TNY_CAMEL_ACCOUNT_GET_PRIVATE(o)        \ 
  • trunk/libtinymail-camel/tny-camel-account.c

    r1490 r1498  
    2929#include <tny-folder.h> 
    3030#include <tny-camel-folder.h> 
     31#include <tny-error.h> 
    3132 
    3233#include <camel/camel.h> 
     
    9495} 
    9596 
    96 static void 
    97 tny_camel_account_try_connect (TnyAccount *self, GError **err) 
    98 
    99         TNY_CAMEL_ACCOUNT_GET_CLASS (self)->try_connect_func (self, err); 
    100 
    101  
    102 static void 
    103 tny_camel_account_try_connect_default (TnyAccount *self, GError **err) 
    104 
     97void  
     98_tny_camel_account_try_connect (TnyCamelAccount *self, GError **err) 
     99
     100        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
     101 
    105102        TNY_CAMEL_ACCOUNT_GET_CLASS (self)->prepare_func (TNY_CAMEL_ACCOUNT (self)); 
    106103 
    107         return; 
    108 
     104        if (camel_exception_is_set (priv->ex)) 
     105        { 
     106                g_set_error (err, TNY_ACCOUNT_ERROR,  
     107                        TNY_ACCOUNT_ERROR_TRY_CONNECT, 
     108                        camel_exception_get_description (priv->ex)); 
     109        } 
     110 
     111        return; 
     112
     113 
     114 
    109115 
    110116 
     
    703709 **/ 
    704710void  
    705 tny_camel_account_set_online_status (TnyCamelAccount *self, gboolean offline
    706 { 
    707         TNY_CAMEL_ACCOUNT_GET_CLASS (self)->set_online_status_func (self, offline); 
     711tny_camel_account_set_online_status (TnyCamelAccount *self, gboolean offline, GError **err
     712{ 
     713        TNY_CAMEL_ACCOUNT_GET_CLASS (self)->set_online_status_func (self, offline, err); 
    708714} 
    709715 
    710716void  
    711 tny_camel_account_set_online_status_default (TnyCamelAccount *self, gboolean offline) 
    712 
    713         TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
    714  
    715         /* TODO locking & error handling */ 
     717tny_camel_account_set_online_status_default (TnyCamelAccount *self, gboolean offline, GError **err) 
     718
     719        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
     720        CamelException ex = CAMEL_EXCEPTION_INITIALISER; 
    716721 
    717722        if (!priv->service || !CAMEL_IS_SERVICE (priv->service)) 
     723        { 
     724                if (camel_exception_is_set (priv->ex)) 
     725                { 
     726                        g_set_error (err, TNY_ACCOUNT_ERROR,  
     727                                TNY_ACCOUNT_ERROR_TRY_CONNECT, 
     728                                camel_exception_get_description (priv->ex)); 
     729                } else { 
     730                        g_set_error (err, TNY_ACCOUNT_ERROR,  
     731                                TNY_ACCOUNT_ERROR_TRY_CONNECT, 
     732                                _("Account not yet fully configured")); 
     733                } 
     734 
    718735                return; 
    719  
    720         /* _tny_camel_account_start_camel_operation (self, NULL, NULL, NULL); */ 
    721  
    722         /* g_static_rec_mutex_lock (priv->service_lock); */ 
     736        } 
    723737 
    724738        if (offline) 
    725739                camel_service_cancel_connect (priv->service); 
    726          
     740 
    727741        if (CAMEL_IS_DISCO_STORE (priv->service)) { 
    728742                if (!offline) { 
    729743                        camel_disco_store_set_status (CAMEL_DISCO_STORE (priv->service), 
    730                                                                                   CAMEL_DISCO_STORE_ONLINE, priv->ex); 
     744                                                                                  CAMEL_DISCO_STORE_ONLINE, &ex); 
    731745                        goto done; 
    732746                } else if (camel_disco_store_can_work_offline (CAMEL_DISCO_STORE (priv->service))) { 
     
    734748                        camel_disco_store_set_status (CAMEL_DISCO_STORE (priv->service), 
    735749                                                                                  CAMEL_DISCO_STORE_OFFLINE, 
    736                                                                                   priv->ex); 
     750                                                                                  &ex); 
    737751                        goto done; 
    738752                } 
     
    743757                        camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (priv->service), 
    744758                                                                                                   CAMEL_OFFLINE_STORE_NETWORK_AVAIL, 
    745                                                                                                    priv->ex); 
     759                                                                                                   &ex); 
    746760                        goto done; 
    747761                } else { 
    748762                        camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (priv->service), 
    749763                                                                                                   CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL, 
    750                                                                                                    priv->ex); 
     764                                                                                                   &ex); 
    751765                        goto done; 
    752766                } 
    753767        } 
    754          
     768 
    755769        if (offline) 
    756770                camel_service_disconnect (CAMEL_SERVICE (priv->service), 
    757                                                                   TRUE, priv->ex); 
     771                                                                  TRUE, &ex); 
    758772 
    759773done: 
    760                 /* g_static_rec_mutex_unlock (priv->service_lock); */ 
    761                 /* _tny_camel_account_stop_camel_operation (self); */ 
     774 
     775        if (camel_exception_is_set (&ex)) 
     776        { 
     777                g_set_error (err, TNY_ACCOUNT_ERROR,  
     778                        TNY_ACCOUNT_ERROR_TRY_CONNECT, 
     779                        camel_exception_get_description (&ex)); 
     780        } 
    762781 
    763782        return; 
     
    835854        TnyAccountIface *klass = (TnyAccountIface *)g; 
    836855 
    837         klass->try_connect_func = tny_camel_account_try_connect; 
    838856        klass->get_port_func = tny_camel_account_get_port; 
    839857        klass->set_port_func = tny_camel_account_set_port; 
     
    870888        object_class = (GObjectClass*) class; 
    871889 
    872         class->try_connect_func = tny_camel_account_try_connect_default; 
    873890        class->get_port_func = tny_camel_account_get_port_default; 
    874891        class->set_port_func = tny_camel_account_set_port_default; 
  • trunk/libtinymail-camel/tny-camel-account.h

    r1485 r1498  
    7575 
    7676        void (*add_option_func) (TnyCamelAccount *self, const gchar *option); 
    77         void (*set_online_status_func) (TnyCamelAccount *self, gboolean offline); 
     77        void (*set_online_status_func) (TnyCamelAccount *self, gboolean offline, GError **err); 
    7878 
    7979        /* Abstract methods */ 
     
    8585void tny_camel_account_add_option (TnyCamelAccount *self, const gchar *option); 
    8686void tny_camel_account_set_session (TnyCamelAccount *self, TnySessionCamel *session); 
    87 void tny_camel_account_set_online_status (TnyCamelAccount *self, gboolean offline); 
     87void tny_camel_account_set_online_status (TnyCamelAccount *self, gboolean offline, GError **err); 
    8888 
    8989G_END_DECLS 
  • trunk/libtinymail-camel/tny-session-camel.c

    r1496 r1498  
    559559                GError *err = NULL; 
    560560 
    561                 tny_account_try_connect (TNY_ACCOUNT (data), &err); 
     561                _tny_camel_account_try_connect (TNY_CAMEL_ACCOUNT (data), &err); 
     562 
    562563                if (err == NULL) 
    563                         tny_camel_account_set_online_status (TNY_CAMEL_ACCOUNT (data), !online); 
    564                 else  
     564                        tny_camel_account_set_online_status (TNY_CAMEL_ACCOUNT (data), !online, &err); 
     565 
     566                if (err != NULL)  
     567                { 
    565568                        tny_session_camel_alert_user (session, CAMEL_SESSION_ALERT_ERROR, err->message, FALSE); 
     569                        g_error_free (err); 
     570                } 
    566571        } 
    567572} 
  • trunk/libtinymail-olpc/tny-olpc-account-store.c

    r1485 r1498  
    288288                                        tny_account_set_port (TNY_ACCOUNT (account), port); 
    289289 
     290                                if (err != NULL) 
     291                                        g_error_free (err); 
     292 
    290293                                g_free (hostname); g_free (user); 
    291294                        } else { 
  • trunk/libtinymail/tny-account.c

    r1485 r1498  
    2222#include <tny-account.h> 
    2323 
    24  
    25 /** 
    26  * tny_account_try_connect: 
    27  * @self: a #TnyAccount object 
    28  * @err: a #GError instance or NULL 
    29  *  
    30  * Try to connect. This can put a reason why connecting failed in @err. 
    31  **/ 
    32 void 
    33 tny_account_try_connect (TnyAccount *self, GError **err) 
    34 { 
    35 #ifdef DEBUG 
    36         if (!TNY_ACCOUNT_GET_IFACE (self)->try_connect_func) 
    37                 g_critical ("You must implement tny_account_get_id\n"); 
    38 #endif 
    39  
    40         return TNY_ACCOUNT_GET_IFACE (self)->try_connect_func (self, err); 
    41 } 
    4224 
    4325/** 
  • trunk/libtinymail/tny-account.h

    r1485 r1498  
    7272        const gchar* (*get_url_string_func) (TnyAccount *self); 
    7373        TnyAccountType (*get_account_type_func) (TnyAccount *self); 
    74         void (*try_connect_func) (TnyAccount *self, GError **err); 
    7574}; 
    7675 
     
    10099void tny_account_set_forget_pass_func (TnyAccount *self, TnyForgetPassFunc forget_pass_func); 
    101100TnyForgetPassFunc tny_account_get_forget_pass_func (TnyAccount *self); 
    102 void tny_account_try_connect (TnyAccount *self, GError **err); 
    103101 
    104102G_END_DECLS