Changeset 1305

Show
Ignore:
Timestamp:
12/08/06 13:52:19
Author:
pvanhoof
Message:

Bleh, small bugfixes but still a stinky solution

Files:

Legend:

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

    r1304 r1305  
    160160        GThread *thread; 
    161161 
    162         g_mutex_lock (priv->cancel_lock);       
     162        g_mutex_lock (priv->cancel_lock); 
    163163 
    164164        /* I know this isn't polite. But it works ;-) */ 
     
    260260{ 
    261261        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
    262          
     262 
    263263        g_static_rec_mutex_lock (priv->service_lock); 
    264264 
     
    499499        if (!priv->service) 
    500500                return; 
    501          
     501 
    502502        _tny_camel_account_start_camel_operation (self, NULL, NULL, NULL); 
    503          
     503 
     504        g_static_rec_mutex_lock (priv->service_lock); 
     505 
    504506        if (offline) 
    505507                camel_service_cancel_connect (priv->service); 
     
    537539                                                                  TRUE, priv->ex); 
    538540        done: 
    539                  
     541                g_static_rec_mutex_unlock (priv->service_lock); 
    540542                _tny_camel_account_stop_camel_operation (self); 
    541543         
     
    546548tny_camel_account_finalize (GObject *object) 
    547549{ 
    548         TnyCamelAccount *self = (TnyCamelAccount *)object;      
     550        TnyCamelAccount *self = (TnyCamelAccount *)object; 
    549551        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
    550552 
  • trunk/libtinymail-camel/tny-camel-store-account.c

    r1304 r1305  
    7474tny_camel_store_account_reconnect (TnyCamelAccount *self) 
    7575{ 
    76         TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
    77  
    78         if (G_LIKELY (priv->session) && G_UNLIKELY (priv->proto) &&  
    79                 G_UNLIKELY (priv->user) && G_UNLIKELY (priv->host)) 
    80         { 
    81                 if (!priv->url_string) 
     76        TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
     77 
     78        if (G_LIKELY (apriv->session) && G_UNLIKELY (apriv->proto) &&  
     79                G_UNLIKELY (apriv->user) && G_UNLIKELY (apriv->host)) 
     80        { 
     81                if (!apriv->url_string) 
    8282                { 
    8383                        CamelURL *url = NULL; 
    84                         GList *options = priv->options; 
    85  
    86                         gchar *proto = g_strdup_printf ("%s://", priv->proto);  
    87  
    88                         url = camel_url_new (proto, priv->ex); 
     84                        GList *options = apriv->options; 
     85                        gchar *proto = g_strdup_printf ("%s://", apriv->proto);  
     86 
     87                        url = camel_url_new (proto, apriv->ex); 
    8988                        g_free (proto); 
    90                  
    91                         camel_url_set_protocol (url, priv->proto);  
    92                         camel_url_set_user (url, priv->user); 
    93                         camel_url_set_host (url, priv->host); 
    94                  
     89 
     90                        camel_url_set_protocol (url, apriv->proto);  
     91                        camel_url_set_user (url, apriv->user); 
     92                        camel_url_set_host (url, apriv->host); 
     93 
    9594                        while (options) 
    9695                        { 
    9796                                gchar *ptr, *dup = g_strdup (options->data); 
    9897                                gchar *option, *value; 
    99  
    10098                                ptr = strchr (dup, '='); 
    101  
    102                                 if (ptr)  
    103                                 { 
     99                                if (ptr) { 
    104100                                        ptr++; 
    105101                                        value = g_strdup (ptr); ptr--; 
     
    109105                                        value = g_strdup ("1"); 
    110106                                } 
    111  
    112107                                camel_url_set_param (url, option, value); 
    113  
    114108                                g_free (value); 
    115  
    116109                                g_free (dup); 
    117  
    118110                                options = g_list_next (options); 
    119111                        } 
    120112 
    121                         if (G_LIKELY (priv->url_string)) 
    122                                 g_free (priv->url_string); 
    123  
    124                         priv->url_string = camel_url_to_string (url, 0); 
    125  
     113                        if (G_LIKELY (apriv->url_string)) 
     114                                g_free (apriv->url_string); 
     115 
     116                        apriv->url_string = camel_url_to_string (url, 0); 
    126117                        camel_url_free (url); 
    127118 
    128                         /* TODO: lock ->service */ 
    129                         priv->service = camel_session_get_service 
    130                                 ((CamelSession*) priv->session, priv->url_string,  
    131                                 priv->type, priv->ex); 
    132  
    133                         /* TODO: lock ->service */ 
    134                         if (priv->service == NULL) 
    135                                 report_error (priv); 
     119                        g_static_rec_mutex_lock (apriv->service_lock); 
     120                        apriv->service = camel_session_get_service 
     121                                ((CamelSession*) apriv->session, apriv->url_string,  
     122                                apriv->type, apriv->ex); 
     123                        if (apriv->service == NULL) 
     124                                report_error (apriv); 
     125                        g_static_rec_mutex_unlock (apriv->service_lock); 
     126 
     127                        /* TODO: Handle priv->ex using GError */ 
    136128                } 
    137         } else if (G_LIKELY (priv->session) && (priv->url_string)) 
    138         { 
    139                 /* un officially supported provider */ 
    140  
    141                 /* TODO: lock ->service */ 
    142                 priv->service = camel_session_get_service 
    143                         ((CamelSession*) priv->session, priv->url_string,  
    144                         priv->type, priv->ex); 
    145  
    146                 /* TODO: lock ->service */ 
    147                 if (priv->service == NULL) 
    148                         report_error (priv); 
    149         } 
    150  
    151         if ( G_LIKELY (priv->service) && G_UNLIKELY (priv->pass_func_set) 
    152                 && G_UNLIKELY (priv->forget_pass_func_set) ) 
    153         { 
    154                 priv->connected = FALSE; 
    155  
    156                 if (!camel_service_connect (priv->service, priv->ex)) 
    157                 { 
    158                         g_warning (_("Not connected with %s: %s\n"), priv->url_string, 
    159                                    camel_exception_get_description (priv->ex)); 
    160                         camel_exception_clear (priv->ex); 
    161                         /* camel_service_cancel_connect (priv->service); 
    162                         camel_service_disconnect (priv->service, FALSE, priv->ex); */ 
     129        } else if (G_LIKELY (apriv->session) && (apriv->url_string)) 
     130        { 
     131                g_static_rec_mutex_lock (apriv->service_lock); 
     132                /* camel_session_get_service can launch GUI things */ 
     133                apriv->service = camel_session_get_service 
     134                        ((CamelSession*) apriv->session, apriv->url_string,  
     135                        apriv->type, apriv->ex); 
     136                if (apriv->service == NULL) 
     137                        report_error (apriv); 
     138                g_static_rec_mutex_unlock (apriv->service_lock); 
     139                 
     140                /* TODO: Handle priv->ex using GError */ 
     141        } 
     142 
     143        if ( G_LIKELY (apriv->service) && G_UNLIKELY (apriv->pass_func_set) 
     144                && G_UNLIKELY (apriv->forget_pass_func_set) ) 
     145        { 
     146                apriv->connected = FALSE; 
     147 
     148                g_static_rec_mutex_lock (apriv->service_lock); 
     149                /* camel_service_connect can launch GUI things */ 
     150                if (!camel_service_connect (apriv->service, apriv->ex)) 
     151                { 
     152                        /* TODO: Handle priv->ex using GError */ 
     153                        g_warning (_("Not connected with %s: %s\n"), apriv->url_string, 
     154                                   camel_exception_get_description (apriv->ex)); 
     155                        camel_exception_clear (apriv->ex); 
    163156                } else { 
    164                         priv->connected = TRUE; 
     157                        apriv->connected = TRUE; 
    165158                } 
     159                g_static_rec_mutex_unlock (apriv->service_lock); 
     160                 
     161                /* TODO: Handle priv->ex using GError */ 
    166162        } 
    167163 
  • trunk/libtinymail-camel/tny-camel-transport-account.c

    r1304 r1305  
    5757tny_camel_transport_account_reconnect (TnyCamelAccount *self) 
    5858{ 
    59         TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
    60  
    61         printf ("recon\n"); 
    62  
    63         if (G_LIKELY (priv->session) && G_UNLIKELY (priv->proto) && G_UNLIKELY (priv->host)) 
     59        TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
     60        CamelException ex = CAMEL_EXCEPTION_INITIALISER; 
     61 
     62        if (G_LIKELY (apriv->session) && G_UNLIKELY (apriv->proto) && G_UNLIKELY (apriv->host)) 
    6463        { 
    6564                GString *urlstr = g_string_new (""); 
    6665 
    67                 if (priv->url_string) 
    68                         g_free (priv->url_string); 
    69  
    70                 urlstr = g_string_append (urlstr, priv->proto); 
     66                if (apriv->url_string) 
     67                        g_free (apriv->url_string); 
     68 
     69                urlstr = g_string_append (urlstr, apriv->proto); 
    7170                urlstr = g_string_append (urlstr, "://"); 
    7271 
    73                 if (priv->user) 
     72                if (apriv->user) 
    7473                { 
    75                         urlstr = g_string_append (urlstr, priv->user); 
     74                        urlstr = g_string_append (urlstr, apriv->user); 
    7675                        urlstr = g_string_append (urlstr, "@"); 
    7776                } 
    7877 
    79                 urlstr = g_string_append (urlstr, priv->host); 
    80  
    81                 priv->url_string = urlstr->str; 
    82  
    83                 /* TODO: lock ->service */ 
    84                 priv->service = camel_session_get_service 
    85                         ((CamelSession*) priv->session, priv->url_string,  
    86                         priv->type, priv->ex); 
     78                urlstr = g_string_append (urlstr, apriv->host); 
     79 
     80                apriv->url_string = urlstr->str; 
     81 
     82                /* TODO: check for old instance and clear it */ 
     83                g_static_rec_mutex_lock (apriv->service_lock); 
     84                /* camel_session_get_service can launch GUI things */ 
     85                apriv->service = camel_session_get_service 
     86                        ((CamelSession*) apriv->session, apriv->url_string,  
     87                        apriv->type, &ex); 
    8788                /* TODO: check ex and handle it with a GError */ 
    88                 if (camel_exception_is_set (priv->ex)) 
     89                if (camel_exception_is_set (&ex)) 
    8990                        g_error ("Can't get service for transport account (%s)\n",  
    90                                          camel_exception_get_description (priv->ex)); 
    91  
    92                 if (!camel_service_connect (priv->service, priv->ex)) 
    93                 { 
    94                         g_warning (_("Not connected with %s: %s\n"), priv->url_string, 
    95                                    camel_exception_get_description (priv->ex)); 
    96                         camel_exception_clear (priv->ex); 
    97                 } 
    98          
     91                                         camel_exception_get_description (&ex)); 
     92                g_static_rec_mutex_unlock (apriv->service_lock); 
     93 
    9994                g_string_free (urlstr, FALSE); 
    100         } else if (priv->url_string) 
    101         { 
    102                  
    103                 /* TODO: lock ->service */ 
     95        } else if (apriv->url_string) 
     96        { 
     97 
    10498                /* TODO: check for old instance and clear it */ 
    105  
    106                 priv->service = camel_session_get_service 
    107                         ((CamelSession*) priv->session, priv->url_string,  
    108                         priv->type, priv->ex); 
    109  
    110                 if (camel_exception_is_set (priv->ex)) 
     99                g_static_rec_mutex_lock (apriv->service_lock); 
     100                /* camel_session_get_service can launch GUI things */ 
     101                apriv->service = camel_session_get_service 
     102                        ((CamelSession*) apriv->session, apriv->url_string,  
     103                        apriv->type, &ex); 
     104                /* TODO: check ex and handle it with a GError */ 
     105                if (camel_exception_is_set (&ex)) 
    111106                        g_error ("Can't get service for transport account (%s)\n",  
    112                                          camel_exception_get_description (priv->ex)); 
    113                 /* TODO: check ex and handle it with a GError */ 
    114                  
    115                 if (!camel_service_connect (priv->service, priv->ex)) 
    116                 { 
    117                         g_warning (_("Not connected with %s: %s\n"), priv->url_string, 
    118                                    camel_exception_get_description (priv->ex)); 
    119                         camel_exception_clear (priv->ex); 
    120                 } 
     107                                         camel_exception_get_description (&ex)); 
     108                g_static_rec_mutex_unlock (apriv->service_lock); 
    121109        } 
    122110} 
     
    137125        TnyHeader *header; CamelMimeMessage *message; 
    138126        CamelException ex =  CAMEL_EXCEPTION_INITIALISER; 
    139         CamelTransport *transport; 
    140         const gchar *str = NULL; 
     127        CamelTransport *transport; const gchar *str = NULL; 
    141128        CamelInternetAddress *from, *recipients; 
    142129 
    143130        g_assert (TNY_IS_CAMEL_MSG (msg)); 
    144131        g_assert (CAMEL_IS_SESSION (apriv->session)); 
    145  
    146         /* TODO: lock ->service */ 
    147         if (!apriv->service) 
    148         { /* TODO do some more checking on ->service */ 
    149                 g_critical ("No service, going to try getting a forced online one"); 
    150                 transport = camel_session_get_transport ((CamelSession*) apriv->session,  
    151                         apriv->url_string, &ex); 
     132        g_assert (CAMEL_IS_SERVICE (apriv->service)); 
     133        transport = (CamelTransport *) apriv->service; 
     134        g_assert (CAMEL_IS_TRANSPORT (transport)); 
     135 
     136        g_static_rec_mutex_lock (apriv->service_lock); 
     137        /* camel_service_connect can launch GUI things */ 
     138        if (!apriv->connected && !camel_service_connect (apriv->service, &ex)) 
     139        { 
    152140                if (camel_exception_is_set (&ex)) 
    153                         g_critical ("Didn't work (%s)", 
     141                { 
     142                        g_set_error (err, TNY_TRANSPORT_ACCOUNT_ERROR,  
     143                                TNY_TRANSPORT_ACCOUNT_ERROR_SEND, 
    154144                                camel_exception_get_description (&ex)); 
    155                 apriv->service = (CamelService*) transport; 
    156         } else 
    157         { 
    158                 if (!camel_service_connect (apriv->service, apriv->ex)) 
    159                 { 
    160                         g_warning (_("Not connected with %s: %s\n"), apriv->url_string, 
    161                                    camel_exception_get_description (apriv->ex)); 
    162                         camel_exception_clear (apriv->ex); 
     145                        g_static_rec_mutex_unlock (apriv->service_lock); 
     146                        return; 
    163147                } 
    164         } 
    165  
    166         if (camel_exception_is_set (&ex) || !transport) 
    167         { 
    168                 g_set_error (err, TNY_TRANSPORT_ACCOUNT_ERROR,  
    169                         TNY_TRANSPORT_ACCOUNT_ERROR_SEND, 
    170                         camel_exception_get_description (&ex)); 
    171  
    172                 if (transport && CAMEL_IS_OBJECT (transport)) 
    173                         camel_object_unref (CAMEL_OBJECT (transport)); 
    174  
    175                 return; 
    176         } 
    177  
    178         g_assert (CAMEL_IS_TRANSPORT (transport)); 
     148        } else { 
     149                apriv->connected = TRUE; 
     150        } 
     151        g_static_rec_mutex_unlock (apriv->service_lock); 
    179152 
    180153        header = tny_msg_get_header (msg); 
  • trunk/libtinymail-camel/tny-session-camel.c

    r1304 r1305  
    203203} 
    204204 
     205 
     206/* Will be called at camel_service_connect in case the account needs a password. 
     207   its implementation can contani GUI things. */ 
    205208static char * 
    206209tny_session_camel_get_password (CamelSession *session, CamelService *service, const char *domain, 
     
    256259} 
    257260 
     261 
     262/* Will be called at camel_service_connect in case the entered password was wrong */ 
    258263static void 
    259264tny_session_camel_forget_password (CamelSession *session, CamelService *service, const char *domain, const char *item, CamelException *ex) 
     
    283288        return; 
    284289} 
     290 
     291/* tny_session_camel_alert_user will for example be called when SSL is on and  
     292   camel_session_get_service is issued (for example TnyCamelTransportAccount and 
     293   TnyCamelStore account issue this function). Its implementation is often done 
     294   with GUI components (it should therefore not be called from a thread). This 
     295   is a known issue (and the person who fixed this, please remove this warning) */ 
    285296 
    286297static gboolean 
  • trunk/tinymail/tny-demoui-summary-view.c

    r1304 r1305  
    556556                                { 
    557557 
    558 /* DEBUG                */ 
     558/* DEBUG                 
    559559                                        TnyAccountStore *astore = priv->account_store; 
    560560                                        TnyList *accs = tny_simple_list_new (); 
     
    573573                                        g_object_unref (G_OBJECT (iter)); 
    574574                                        g_object_unref (G_OBJECT (accs)); 
    575  
     575*/ 
    576576 
    577577                                        msgwin = tny_gtk_msg_window_new (