Changeset 3280

Show
Ignore:
Timestamp:
01/20/08 15:12:13
Author:
pvanhoof
Message:

2008-01-20 Philip Van Hoof <pvanhoof@gnome.org>

        • Refactoring of all error reporting situations, errors and handling

of connection failures, reconnecting and getting messages in case of a
previous connection failure.

        • Several bugfixes related to connection failures
        • Several bugfixes related to connection problems when fetching

messages

        • POP and IMAP now behave the same in case of connection problems

while fetching a message (they try to re-authenticate and re-connect)

        • More finegrained error reporting (IO errors, SERVICE errors, SYSTEM

errors and unknown errors).

        • This was a major API change for all modules
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r3279 r3280  
     12008-01-20  Philip Van Hoof <pvanhoof@gnome.org> 
     2 
     3        * Refactoring of all error reporting situations, errors and handling 
     4        of connection failures, reconnecting and getting messages in case of a 
     5        previous connection failure. 
     6        * Several bugfixes related to connection failures 
     7        * Several bugfixes related to connection problems when fetching 
     8        messages 
     9        * POP and IMAP now behave the same in case of connection problems 
     10        while fetching a message (they try to re-authenticate and re-connect) 
     11        * More finegrained error reporting (IO errors, SERVICE errors, SYSTEM 
     12        errors and unknown errors). 
     13 
     14        * This was a major API change for all modules 
     15 
    1162008-01-19  Philip Van Hoof <pvanhoof@gnome.org> 
    217 
  • trunk/libtinymail-camel/camel-lite/camel/camel-exception-list.def

    r2815 r3280  
    1414CAMEL_EXCEPTION_USER_CANCEL, 
    1515 
     16CAMEL_EXCEPTION_SYSTEM_IO_WRITE, 
     17CAMEL_EXCEPTION_SYSTEM_IO_READ, 
     18CAMEL_EXCEPTION_SYSTEM_MEMORY, 
     19 
    1620/* CamelFolderException */ 
    1721CAMEL_EXCEPTION_FOLDER_NULL = 100, 
     
    2125CAMEL_EXCEPTION_FOLDER_NON_UID, 
    2226CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION, 
    23 CAMEL_EXCEPTION_FOLDER_INVALID_PATH, 
     27CAMEL_EXCEPTION_FOLDER_CREATE, 
     28CAMEL_EXCEPTION_FOLDER_DELETE, 
     29CAMEL_EXCEPTION_FOLDER_RENAME, 
    2430CAMEL_EXCEPTION_FOLDER_INVALID_UID, 
     31CAMEL_EXCEPTION_FOLDER_UID_NOT_AVAILABLE, 
    2532CAMEL_EXCEPTION_FOLDER_SUMMARY_INVALID, 
     33 
    2634 
    2735/* CamelStoreException */ 
     
    3745CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, /* Authentication method not supported. */ 
    3846CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED, 
    39 CAMEL_EXCEPTION_SERVICE_CERTIFICATE /* Certificate problems. */ 
     47CAMEL_EXCEPTION_SERVICE_CERTIFICATE, /* Certificate problems. */ 
     48CAMEL_EXCEPTION_SERVICE_LOST_CONNECTION, /* Network problem */ 
     49CAMEL_EXCEPTION_SERVICE_PROTOCOL, /* Proto problem, like a BAD from IMAP */ 
     50CAMEL_EXCEPTION_SERVICE_CONNECT,  
     51CAMEL_EXCEPTION_SERVICE_NOT_SUPPORTED,  
  • trunk/libtinymail-camel/camel-lite/camel/camel-store.c

    r3177 r3280  
    271271                     camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store)))); 
    272272 
    273         camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_INVALID
     273        camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER
    274274                              _("Cannot get folder: Invalid operation on this store")); 
    275275 
     
    368368                     camel_type_to_name (CAMEL_OBJECT_GET_TYPE (store)))); 
    369369 
    370         camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_INVALID
     370        camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_CREATE
    371371                              _("Cannot create folder: Invalid operation on this store")); 
    372372 
     
    396396            && (((store->flags & CAMEL_STORE_VTRASH) && strcmp(folder_name, CAMEL_VTRASH_NAME) == 0) 
    397397                || ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0))) { 
    398                 camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_INVALID
     398                camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_CREATE
    399399                                     _("Cannot create folder: %s: folder exists"), folder_name); 
    400400                return NULL; 
  • trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-command.c

    r3249 r3280  
    366366                                             _("Operation cancelled")); 
    367367                } else 
    368                         camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     368                        camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_LOST_CONNECTION
    369369                                             g_strerror (errno)); 
    370370 
     
    418418                        return NULL; 
    419419                } else 
    420                         camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     420                        camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_LOST_CONNECTION
    421421                                             g_strerror (errno)); 
    422422                camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); 
     
    471471                        /* Connection was lost, no more data to fetch */ 
    472472                        camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); 
    473                         camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     473                        camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_LOST_CONNECTION
    474474                                              _("Server unexpectedly disconnected: %s"), 
    475475                                              _("Unknown error")); /* g_strerror (104));  FIXME after 1.0 is released */ 
     
    540540                        /* Connection was lost, no more data to fetch */ 
    541541                        camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); 
    542                         camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     542                        camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_LOST_CONNECTION
    543543                                              _("Server unexpectedly disconnected: %s"), 
    544544                                              _("Unknown error")); /* g_strerror (104));  FIXME after 1.0 is released */ 
     
    635635                g_warning ("Unexpected response from IMAP server: %s", 
    636636                           respbuf); 
    637                 camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     637                camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_PROTOCOL
    638638                                      _("Unexpected response from IMAP " 
    639639                                        "server: %s"), respbuf); 
     
    645645        if (!*p++) 
    646646                p = NULL; 
    647         camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_INVALID
     647        camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_PROTOCOL
    648648                              _("IMAP command failed: %s"), 
    649649                              p ? p : _("Unknown error")); 
     
    715715                                        camel_exception_clear (&mex); 
    716716                                } else { 
    717                                         camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     717                                        camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_LOST_CONNECTION
    718718                                                             g_strerror (errno)); 
    719719                                        camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); 
     
    735735                                camel_exception_clear (&mex); 
    736736                        } else { 
    737                                 camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     737                                camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_LOST_CONNECTION
    738738                                             _("Server response ended too soon.")); 
    739739                                camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); 
     
    880880                                        camel_exception_clear (&mex); 
    881881                                } else { 
    882                                         camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     882                                        camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_LOST_CONNECTION
    883883                                                             g_strerror (errno)); 
    884884                                        camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); 
     
    900900                                camel_exception_clear (&mex); 
    901901                        } else { 
    902                                 camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     902                                camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_LOST_CONNECTION
    903903                                             _("Server response ended too soon.")); 
    904904                                camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); 
     
    11161116        } else { 
    11171117                resp = NULL; 
    1118                 camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     1118                camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_PROTOCOL
    11191119                                      _("IMAP server response did not contain " 
    11201120                                        "%s information"), type); 
     
    11521152        } 
    11531153 
    1154         camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     1154        camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_PROTOCOL
    11551155                              _("Unexpected OK response from IMAP server: %s"), 
    11561156                              response->status); 
  • trunk/libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c

    r3279 r3280  
    297297 
    298298        if (e_util_mkdir_hier (folder_dir, S_IRWXU) != 0) { 
    299                 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM
     299                camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM_IO_WRITE
    300300                                      _("Could not create directory %s: %s"), 
    301301                                      folder_dir, g_strerror (errno)); 
     
    320320        if (!folder->summary) { 
    321321                camel_object_unref (CAMEL_OBJECT (folder)); 
    322                 camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM
     322                camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM_IO_READ
    323323                                      _("Could not load summary for %s"), 
    324324                                      folder_name); 
     
    26852685        camel_object_unref (CAMEL_OBJECT (stream)); 
    26862686        if (ret == -1) { 
    2687                 camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     2687                camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM_MEMORY
    26882688                                      _("Unable to retrieve message: %s"), 
    26892689                                      g_strerror (errno)); 
     
    27392739        if (camel_disco_store_status (CAMEL_DISCO_STORE (folder->parent_store)) == CAMEL_DISCO_STORE_OFFLINE) 
    27402740        { 
    2741                 camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 
     2741                camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_UID_NOT_AVAILABLE, 
    27422742                             _("This message is not currently available")); 
    27432743                goto fail; 
     
    27722772                                if (!camel_disco_store_check_online ((CamelDiscoStore*)store, ex)) { 
    27732773                                        CAMEL_SERVICE_REC_UNLOCK(store, connect_lock); 
    2774                                         camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 
     2774                                        camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_UID_NOT_AVAILABLE, 
    27752775                                                             _("This message is not currently available")); 
    27762776                                        goto fail; 
     
    43434343                        camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Operation cancelled")); 
    43444344                else 
    4345                         camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     4345                        camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_LOST_CONNECTION
    43464346                                              _("Server unexpectedly disconnected: %s"), 
    43474347                                              g_strerror (errno)); 
     
    43884388        gboolean amcon = FALSE; 
    43894389 
     4390 
    43904391        g_static_mutex_lock (&gmsgstore_lock); /* A */ 
    43914392 
     
    43974398        } else 
    43984399        { 
     4400 
     4401                if (CAMEL_SERVICE (folder->parent_store)->status == CAMEL_SERVICE_DISCONNECTED) { 
     4402                        CamelException tex = CAMEL_EXCEPTION_INITIALISER; 
     4403                        camel_service_connect (CAMEL_SERVICE (folder->parent_store), &tex); 
     4404                        if (camel_exception_is_set (&tex)) { 
     4405                                camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_UID_NOT_AVAILABLE, 
     4406                                                _("This message is not currently available" 
     4407                                                " and can't go online to fetch it: %s"), 
     4408                                                camel_exception_get_description (&tex)); 
     4409                                g_static_mutex_unlock (&gmsgstore_lock); 
     4410                                camel_exception_clear (&tex); 
     4411                                return NULL; 
     4412                        } 
     4413                } 
     4414 
    43994415                store = CAMEL_IMAP_STORE (camel_object_new (CAMEL_IMAP_STORE_TYPE)); 
    44004416                imap_debug ("Get-Message service created\n"); 
     
    44164432                amcon = camel_service_connect (CAMEL_SERVICE (store), ex); 
    44174433 
    4418                 if (!amcon || camel_exception_is_set (ex) || !camel_disco_store_check_online (CAMEL_DISCO_STORE (store), ex)) 
    4419                 { 
     4434                if (!amcon || camel_exception_is_set (ex) || !camel_disco_store_check_online (CAMEL_DISCO_STORE (store), ex)) { 
    44204435                        camel_object_unref (store); 
    44214436                        if (!camel_exception_is_set (ex)) 
    4422                                 camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 
     4437                                camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_UID_NOT_AVAILABLE, 
    44234438                                                _("This message is not currently available" 
    4424                                                 " (can't let a new connection go online)")); 
     4439                                                " and can't go online to fetch it")); 
    44254440                        else if (camel_strstrcase (camel_exception_get_description (ex), "summary") != NULL) 
    4426                         { 
    4427                                 camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 
    4428                                                 _("This message is not currently available" 
    4429                                                 " and can't be retrieved due to insufficient " 
     4441                                camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM_IO_WRITE, 
     4442                                                _("This message can't be retrieved due to insufficient " 
    44304443                                                " storage space resources.")); 
    4431                         } 
    44324444 
    44334445                        CAMEL_IMAP_FOLDER_REC_UNLOCK (imap_folder, cache_lock); 
     
    45074519  CamelImapFolder *imap_folder = (CamelImapFolder *) folder; 
    45084520  gchar *path = g_strdup_printf ("%s/%s_%s_CONVERTED", imap_folder->cache->path, uid, spec); 
    4509   gint ex_id
     4521  gint ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
    45104522  gboolean err = FALSE, found = FALSE; 
    45114523  gchar *err_message; 
     
    45214533        if (!camel_disco_store_check_online (CAMEL_DISCO_STORE (folder->parent_store), ex)) { 
    45224534 
    4523                 camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 
     4535                camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_UID_NOT_AVAILABLE, 
    45244536                                     _("This message is not currently available")); 
    45254537                g_free (path); 
     
    45404552                if (!fil || fd == -1) { 
    45414553                        err = TRUE; 
    4542                         ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE; 
    4543                         err_message = g_strdup_printf ("Can't write %s", path); 
     4554                        ex_id = CAMEL_EXCEPTION_SYSTEM_IO_WRITE; 
     4555                        err_message = g_strdup_printf (_("Write to cache failed: %s"), g_strerror (errno)); 
    45444556                        goto convert_errorhandler; 
    45454557                } 
     
    45904602                                if (f > 1023 || nread <= 0) { 
    45914603                                        err = TRUE; 
    4592                                         ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
    4593                                         err_message = g_strdup_printf ("Read from service failed: Long " 
    4594                                                 " first line during binary fetch for uid=%s", uid); 
     4604                                        ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
     4605                                        err_message = g_strdup_printf (_("Read from service failed: Long " 
     4606                                                " first line during binary fetch for uid=%s"), uid); 
    45954607                                        goto convert_berrorhander; 
    45964608                                } 
     
    46024614                                                ptr += 3; 
    46034615                                        err = TRUE; 
    4604                                         ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
     4616                                        ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
    46054617                                        err_message = g_strdup_printf ("%s",  
    4606                                                 ptr?ptr:"BAD from IMAP server while CONVERT"); 
     4618                                                ptr?ptr:_("BAD from IMAP server while CONVERT")); 
    46074619                                        store->capabilities &= ~IMAP_CAPABILITY_CONVERT; 
    46084620                                        goto convert_errorhandler; 
     
    46124624                                { 
    46134625                                        err = TRUE; 
    4614                                         ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
    4615                                         err_message = g_strdup_printf ("Read from service failed: Line doesn't start " 
    4616                                                 " with \"* \" for uid=%s (in stead it started with %s)", uid, line); 
     4626                                        ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
     4627                                        err_message = g_strdup_printf (_("Read from service failed: Line doesn't start " 
     4628                                                " with \"* \" for uid=%s (in stead it started with %s)"), uid, line); 
    46174629                                        goto convert_berrorhander; 
    46184630                                } 
     
    46404652                        { 
    46414653                                err = TRUE; 
    4642                                 ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
    4643                                 err_message = g_strdup_printf ("Read from service failed: " 
    4644                                         "strtol failed for uid=%s (the line was: %s)", uid, line); 
     4654                                ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
     4655                                err_message = g_strdup_printf (_("Read from service failed: " 
     4656                                        "strtol failed for uid=%s (the line was: %s)"), uid, line); 
    46454657                                goto convert_berrorhander; 
    46464658                        } 
     
    46594671                                        { 
    46604672                                                err = TRUE; 
    4661                                                 err_message = g_strdup_printf ("Write to cache failed: %s", g_strerror (errno)); 
     4673                                                ex_id = CAMEL_EXCEPTION_SYSTEM_IO_WRITE; 
     4674                                                err_message = g_strdup_printf (_("Write to cache failed: %s"), g_strerror (errno)); 
    46624675                                                goto convert_berrorhander; 
    46634676                                        } 
     
    46674680                                        if (hread != 0) { 
    46684681                                                err = TRUE; 
    4669                                                 ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
    4670                                                 err_message = g_strdup_printf ("Read from service failed, UID=%s", uid); 
     4682                                                ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
     4683                                                err_message = g_strdup_printf (_("Read from service failed, UID=%s"), uid); 
    46714684                                                goto convert_berrorhander; 
    46724685                                        } 
     
    46884701                } else { 
    46894702                        err = TRUE; 
    4690                         ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
    4691                         err_message = g_strdup_printf ("CONVERT not supported on this server"); 
     4703                        ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
     4704                        err_message = g_strdup (_("CONVERT not supported on this server")); 
    46924705                        goto convert_errorhandler; 
    46934706                } 
     
    47124725 
    47134726        if (!err_message) 
    4714                 camel_exception_setv (ex, ex_id, "Could not find message body in response."); 
     4727                camel_exception_setv (ex, ex_id, _("Could not find message body in response")); 
    47154728        else { 
    47164729                camel_exception_setv (ex, ex_id, err_message); 
     
    47324745  gchar *path = g_strdup_printf ("%s/%s_%s", imap_folder->cache->path, uid, spec); 
    47334746  gboolean retry = TRUE; 
    4734   gint ex_id
     4747  gint ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
    47354748  gboolean err = FALSE, found = FALSE; 
    47364749  gchar *err_message; 
     
    47634776        if (!camel_disco_store_check_online (CAMEL_DISCO_STORE (folder->parent_store), ex)) { 
    47644777 
    4765                 camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 
     4778                camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_UID_NOT_AVAILABLE, 
    47664779                                     _("This message is not currently available")); 
    47674780                g_free (path); 
     
    47874800                        if (!fil || fd == -1) { 
    47884801                                err = TRUE; 
    4789                                 ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE; 
    4790                                 err_message = g_strdup_printf ("Can't write %s", path); 
     4802                                ex_id = CAMEL_EXCEPTION_SYSTEM_IO_WRITE; 
     4803                                err_message = g_strdup_printf (_("Write to cache failed: %s"), g_strerror (errno)); 
    47914804                                goto fetch_errorhandler; 
    47924805                        } 
     
    48404853                                        if (f > 1023 || nread <= 0) { 
    48414854                                                err = TRUE; 
    4842                                                 ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
    4843                                                 err_message = g_strdup_printf ("Read from service failed: Long " 
    4844                                                         " first line during binary fetch for uid=%s", uid); 
     4855                                                ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
     4856                                                err_message = g_strdup_printf (_("Read from service failed: Long " 
     4857                                                        " first line during binary fetch for uid=%s"), uid); 
    48454858                                                goto fetch_berrorhander; 
    48464859                                        } 
     
    48644877                                        { 
    48654878                                                err = TRUE; 
    4866                                                 ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
    4867                                                 err_message = g_strdup_printf ("Read from service failed: Line doesn't start " 
    4868                                                         " with \"* \" for uid=%s (in stead it started with %s)", uid, line); 
     4879                                                ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
     4880                                                err_message = g_strdup_printf (_("Read from service failed: Line doesn't start " 
     4881                                                        " with \"* \" for uid=%s (in stead it started with %s)"), uid, line); 
    48694882                                                goto fetch_berrorhander; 
    48704883                                        } 
     
    48924905                                { 
    48934906                                        err = TRUE; 
    4894                                         ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
    4895                                         err_message = g_strdup_printf ("Read from service failed: " 
    4896                                                 "strtol failed for uid=%s (the line was: %s)", uid, line); 
     4907                                        ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
     4908                                        err_message = g_strdup_printf (_("Read from service failed: " 
     4909                                                "strtol failed for uid=%s (the line was: %s)"), uid, line); 
    48974910                                        goto fetch_berrorhander; 
    48984911                                } 
     
    49114924                                                { 
    49124925                                                        err = TRUE; 
    4913                                                         err_message = g_strdup_printf ("Write to cache failed: %s", g_strerror (errno)); 
     4926                                                        ex_id = CAMEL_EXCEPTION_SYSTEM_IO_WRITE; 
     4927                                                        err_message = g_strdup_printf (_("Write to cache failed: %s"), g_strerror (errno)); 
    49144928                                                        goto fetch_berrorhander; 
    49154929                                                } 
     
    49194933                                                if (hread != 0) { 
    49204934                                                        err = TRUE; 
    4921                                                         ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
    4922                                                         err_message = g_strdup_printf ("Read from service failed, UID=%s", uid); 
     4935                                                        ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
     4936                                                        err_message = g_strdup_printf (_("Read from service failed, UID=%s"), uid); 
    49234937                                                        goto fetch_berrorhander; 
    49244938                                                } 
     
    49754989                                if (!server_stream) { 
    49764990                                        err = TRUE; 
    4977                                         ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
    4978                                         err_message = g_strdup ("Read from service failed: Service unavailable"); 
     4991                                        ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
     4992                                        err_message = g_strdup (_("Read from service failed: Service unavailable")); 
    49794993                                } else 
    49804994                                        store->command++; 
     
    50005014                                        if (linenum == 0 && (line [0] != '*' || line[1] != ' ')) 
    50015015                                        { 
    5002                                                 ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
    5003                                                 err_message = g_strdup ("Read from service failed: Unexpected result from service"); 
     5016                                                ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
     5017                                                err_message = g_strdup (_("Read from service failed: Unexpected result from service")); 
    50045018                                                err=TRUE; 
    50055019                                                break; 
     
    50315045                                                        { 
    50325046                                                                err = TRUE; 
    5033                                                                 err_message = g_strdup_printf ("Write to cache failed: %s", g_strerror (errno)); 
     5047                                                                ex_id = CAMEL_EXCEPTION_SYSTEM_IO_WRITE; 
     5048                                                                err_message = g_strdup_printf (_("Write to cache failed: %s"), g_strerror (errno)); 
    50345049                                                                break; 
    50355050                                                        } 
     
    50385053                                                        { 
    50395054                                                                err = TRUE; 
    5040                                                                 err_message = g_strdup_printf ("Write to cache failed: %s", g_strerror (errno)); 
     5055                                                                ex_id = CAMEL_EXCEPTION_SYSTEM_IO_WRITE; 
     5056                                                                err_message = g_strdup_printf (_("Write to cache failed: %s"), g_strerror (errno)); 
    50415057                                                                break; 
    50425058                                                        } 
     
    50505066                                        if (write (fd, line, llen) != llen) { 
    50515067                                                err = TRUE; 
    5052                                                 err_message = g_strdup_printf ("Write to cache failed: %s", g_strerror (errno)); 
     5068                                                ex_id = CAMEL_EXCEPTION_SYSTEM_IO_WRITE; 
     5069                                                err_message = g_strdup_printf (_("Write to cache failed: %s"), g_strerror (errno)); 
    50535070                                                break; 
    50545071                                        } 
     
    50675084                                if (nread <= 0) { 
    50685085                                        err = TRUE; 
    5069                                         ex_id = CAMEL_EXCEPTION_SERVICE_UNAVAILABLE
    5070                                         err_message = g_strdup_printf ("Read from service failed: %s", g_strerror (errno)); 
     5086                                        ex_id = CAMEL_EXCEPTION_SERVICE_PROTOCOL
     5087                                        err_message = g_strdup_printf (_("Read from service failed: %s"), g_strerror (errno)); 
    50715088                                } 
    50725089 
     
    51075124 
    51085125        if (!err_message) 
    5109                 camel_exception_setv (ex, ex_id, "Could not find message body in response."); 
     5126                camel_exception_setv (ex, ex_id, _("Could not find message body in response")); 
    51105127        else { 
    51115128                camel_exception_setv (ex, ex_id, err_message); 
     
    51705187 
    51715188                if (!camel_disco_store_check_online (CAMEL_DISCO_STORE (folder->parent_store), ex)) { 
    5172                         camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, 
     5189                        camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_UID_NOT_AVAILABLE, 
    51735190                                             _("This message is not currently available")); 
    51745191                } else { 
     
    51935210                                "UID FETCH %s BODYSTRUCTURE", uid); 
    51945211 
    5195                         for (i = 0; i < response->untagged->len; i++) 
    5196                         { 
    5197                                 resp = ((char*)response->untagged->pdata[i]) + 2; 
    5198                                 walk_the_string (resp, bodyst); 
     5212                        if (response) { 
     5213                                for (i = 0; i < response->untagged->len; i++) { 
     5214                                        resp = ((char*)response->untagged->pdata[i]) + 2; 
     5215                                        walk_the_string (resp, bodyst); 
     5216                                } 
     5217 
     5218                                camel_imap_response_free (store, response); 
     5219                         
     5220                                retval = bodyst->str; 
     5221                                g_string_free (bodyst, FALSE); 
     5222                        } else { 
     5223                                camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_PROTOCOL, 
     5224                                             _("Failure fetchting BODYSTRUCTURE from IMAP server")); 
     5225                                g_string_free (bodyst, TRUE); 
     5226                                retval = NULL; 
    51995227                        } 
    5200  
    5201                         camel_imap_response_free (store, response); 
    5202  
    5203                         retval = bodyst->str; 
    5204                         g_string_free (bodyst, FALSE); 
    52055228 
    52065229                        stop_gmsgstore (imap_folder, ctchecker, FALSE); 
     
    52145237                                fputs (retval, file); 
    52155238                                fclose (file); 
     5239                        } else { 
     5240                                gchar *mss = g_strdup_printf (_("Write to cache failed: %s"), g_strerror (errno)); 
     5241                                camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM_IO_WRITE, mss); 
     5242                                g_free (mss); 
    52165243                        } 
    52175244                } 
     
    52665293        if (!camel_disco_store_check_online (CAMEL_DISCO_STORE (folder->paren