Changeset 2216

Show
Ignore:
Timestamp:
06/19/07 10:58:45
Author:
pvanhoof
Message:

Better connection state detection and handling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r2215 r2216  
    22 
    33        * Fixed reading the unread and total counts from Maildir folders 
     4        * First baby steps into better connection state detection and handling 
    45 
    562007-06-19  Dirk-Jan C. Binnema <dirk-jan.binnema@nokia.com> 
  • trunk/libtinymail-camel/camel-lite/camel/camel-object.c

    r2113 r2216  
    12801280 
    12811281        g_return_if_fail (CAMEL_IS_OBJECT (obj)); 
    1282         g_return_if_fail (id != 0); 
     1282 
     1283        if (id == 0) 
     1284                return; 
    12831285 
    12841286        if (obj->hooks == NULL) { 
  • trunk/libtinymail-camel/camel-lite/camel/camel-service.c

    r2109 r2216  
    8888        camel_service_class->get_name = get_name; 
    8989        camel_service_class->get_path = get_path; 
     90 
     91        camel_object_class_add_event(object_class, "disconnection", NULL); 
     92        camel_object_class_add_event(object_class, "connection", NULL); 
    9093} 
    9194 
     
    111114                camel_exception_init (&ex); 
    112115                CSERV_CLASS (service)->disconnect (service, TRUE, &ex); 
     116 
     117                camel_object_trigger_event (CAMEL_OBJECT (service),  
     118                        "disconnection", (gpointer) TRUE); 
     119 
    113120                if (camel_exception_is_set (&ex)) { 
    114121                        w(g_warning ("camel_service_finalize: silent disconnect failure: %s", 
     
    382389                service->connect_op = NULL; 
    383390        } 
     391 
     392        camel_object_trigger_event (CAMEL_OBJECT (service),  
     393                "connection", NULL); 
     394 
    384395        CAMEL_SERVICE_UNLOCK (service, connect_op_lock); 
    385396 
     
    444455                        camel_operation_unref (service->connect_op); 
    445456                service->connect_op = NULL; 
     457 
     458                camel_object_trigger_event (CAMEL_OBJECT (service),  
     459                        "disconnection", (gpointer) clean); 
     460 
    446461                CAMEL_SERVICE_UNLOCK (service, connect_op_lock); 
    447462        } 
  • trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-command.c

    r2214 r2216  
    348348        g_return_val_if_fail(store->ostream!=NULL, NULL); 
    349349        g_return_val_if_fail(store->istream!=NULL, NULL); 
    350          
     350 
    351351        if (camel_stream_write (store->ostream, cmd, cmdlen) == -1 || 
    352352            camel_stream_write (store->ostream, "\r\n", 2) == -1) { 
     
    357357                        camel_imap_recon (store, &mex); 
    358358                        imap_debug ("Recon in cont: %s\n", camel_exception_get_description (&mex)); 
     359                        CAMEL_SERVICE_REC_UNLOCK (store, connect_lock); 
     360                        return NULL; 
    359361                } else 
    360362                        camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 
     
    629631                                        camel_imap_recon (store, &mex); 
    630632                                        imap_debug ("Recon in untagged: %s\n", camel_exception_get_description (&mex)); 
    631                                 } else 
     633                                } else { 
    632634                                        camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 
    633635                                                             g_strerror (errno)); 
    634                                 camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); 
     636                                        camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); 
     637                                } 
    635638                                g_string_free (str, TRUE); 
    636639                                goto lose; 
     
    782785                                        camel_imap_recon (store, &mex); 
    783786                                        imap_debug ("Recon in untagged idle: %s\n", camel_exception_get_description (&mex)); 
    784                                 } else 
     787                                } else { 
    785788                                        camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 
    786789                                                             g_strerror (errno)); 
    787                                 camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); 
     790                                        camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); 
     791                                } 
    788792                                g_string_free (str, TRUE); 
    789793                                goto lose; 
  • trunk/libtinymail-camel/tny-camel-account-priv.h

    r2194 r2216  
    6464        TnyAccountType account_type; 
    6565        gboolean custom_url_string; 
    66  
     66        guint dsid, csid; 
    6767        RefreshStatusInfo *csyncop; 
    6868}; 
  • trunk/libtinymail-camel/tny-camel-store-account.c

    r2194 r2216  
    112112 
    113113static void  
     114disconnection (CamelService *service, gpointer data, TnyAccount *self) 
     115{ 
     116#ifdef DEBUG 
     117        g_print ("TNY_DEBUG: %s disconnected\n", tny_account_get_name (self)); 
     118#endif 
     119} 
     120 
     121static void  
     122connection (CamelService *service, gpointer data, TnyAccount *self) 
     123{ 
     124#ifdef DEBUG 
     125        g_print ("TNY_DEBUG: %s connected\n", tny_account_get_name (self)); 
     126#endif 
     127} 
     128 
     129static void  
    114130tny_camel_store_account_prepare (TnyCamelAccount *self) 
    115131{ 
     
    198214                if (apriv->service) { 
    199215                        apriv->service->data = self; 
     216 
     217                        apriv->dsid = camel_object_hook_event (apriv->service,  
     218                                "disconnection", (CamelObjectEventHookFunc)disconnection, self); 
     219                        apriv->csid = camel_object_hook_event (apriv->service,  
     220                                "connection", (CamelObjectEventHookFunc)connection, self); 
     221 
    200222                } 
    201223