[balsa/83-add-mbox-name-to-error-msgs] add mailbox name to all IMAP, POP3, SMTP error messages
- From: Albrecht Dreß <albrecht src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/83-add-mbox-name-to-error-msgs] add mailbox name to all IMAP, POP3, SMTP error messages
- Date: Mon, 8 Aug 2022 17:12:36 +0000 (UTC)
commit e8f905bffa3fce743fc5882610daaa49505035e5
Author: Albrecht Dreß <albrecht dress netcologne de>
Date: Mon Aug 8 19:12:27 2022 +0200
add mailbox name to all IMAP, POP3, SMTP error messages
See issue #83: add the mailbox or server name to all IMAP, POP3 and SMTP
error messages (where applicable). Remove the unused Async IMAP issue
macro.
Signed-off-by: Albrecht Dreß <albrecht dress netcologne de>
libbalsa/mailbox_imap.c | 53 ++++++++++++++++++++-----------------------------
libbalsa/mailbox_pop3.c | 18 ++++++++---------
libbalsa/send.c | 5 +++--
3 files changed, 33 insertions(+), 43 deletions(-)
---
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index 19a304068..044273083 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -597,7 +597,7 @@ mi_reconnect(ImapMboxHandle *h)
/* ImapIssue macro handles reconnecting. We might issue a
LIBBALSA_INFORMATION_MESSAGE here but it would be overwritten by
login information... */
-#define II(rc,h,line) \
+#define II(rc,h,name,line) \
{int trials=2;do{\
if(imap_mbox_is_disconnected(h) &&mi_reconnect(h)!=IMAP_SUCCESS)\
{rc=IMR_NO;break;};\
@@ -606,26 +606,15 @@ mi_reconnect(ImapMboxHandle *h)
break;\
else if(rc==IMR_SEVERED) \
libbalsa_information(LIBBALSA_INFORMATION_WARNING, \
- _("IMAP connection has been severed. Reconnecting…")); \
+ _("IMAP mailbox %s: connection has been severed. Reconnecting…"), name); \
else if(rc==IMR_PROTOCOL) \
libbalsa_information(LIBBALSA_INFORMATION_WARNING, \
- _("IMAP protocol error. Try enabling bug workarounds.")); \
+ _("IMAP mailbox %s: protocol error. Try enabling bug workarounds."), name);\
else if(rc==IMR_BYE) {char *text = imap_mbox_handle_get_last_msg(h); \
libbalsa_information(LIBBALSA_INFORMATION_WARNING, \
- _("IMAP server has shut the connection: %s Reconnecting…"), text); \
+ _("IMAP mailbox %s: server has shut down the connection: %s. Reconnecting…"), name, text); \
g_free(text);}\
else break;}while(trials-->0);}
-#define IIA(rc,h,line,cmd) \
- {int trials=2;do{\
- if(imap_mbox_is_disconnected(h) &&mi_reconnect(h)!=IMAP_SUCCESS)\
- {rc=0;break;};\
- rc=line; \
- if(imap_mbox_op_cancelled(h))\
- break;\
- else if(rc != IMR_OK) \
- libbalsa_information(LIBBALSA_INFORMATION_WARNING, \
- _("Async IMAP cmd %s could not be executed. Reconnecting…"),cmd); \
- else break;}while(trials-->0);}
static ImapMboxHandle *
libbalsa_mailbox_imap_get_handle(LibBalsaMailboxImap *mimap, GError **err)
@@ -744,7 +733,7 @@ mi_get_imsg(LibBalsaMailboxImap *mimap, unsigned msgno)
? total_msgs-msgno+1 : MAX_CHUNK_LENGTH;
for(i=0; i<csd.cnt; i++) csd.msgno_arr[i] = msgno+i;
}
- II(rc,mimap->handle,
+ II(rc,mimap->handle,libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(mimap)),
imap_mbox_handle_fetch_set(mimap->handle, csd.msgno_arr,
csd.cnt,
IMFETCH_FLAGS |
@@ -1016,7 +1005,7 @@ libbalsa_mailbox_imap_get_selected_handle(LibBalsaMailboxImap *mimap,
if (!mimap->handle)
return NULL;
}
- II(rc,mimap->handle,
+ II(rc,mimap->handle,libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(mimap)),
imap_mbox_select(mimap->handle, mimap->path, &readonly));
libbalsa_mailbox_set_readonly(LIBBALSA_MAILBOX(mimap), readonly);
if (rc != IMR_OK) {
@@ -1241,7 +1230,7 @@ get_cache_stream(LibBalsaMailboxImap *mimap, guint uid, gboolean peek)
cache = fopen(path, "wb");
if(cache) {
int ferr;
- II(rc,mimap->handle,
+ II(rc,mimap->handle,libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(mimap)),
imap_mbox_handle_fetch_rfc822_uid(mimap->handle, uid, peek,
cache));
ferr = ferror(cache);
@@ -1418,7 +1407,7 @@ libbalsa_mailbox_imap_message_match(LibBalsaMailbox* mailbox, guint msgno,
matchings = g_hash_table_new(NULL, NULL);
query = lbmi_build_imap_query(search_iter->condition, NULL);
- II(rc,mimap->handle,
+ II(rc,mimap->handle,libbalsa_mailbox_get_name(mailbox),
imap_mbox_filter_msgnos(mimap->handle, query, matchings));
imap_search_key_free(query);
if (rc != IMR_OK) {
@@ -1624,7 +1613,7 @@ GHashTable * libbalsa_mailbox_imap_get_matchings(LibBalsaMailboxImap* mbox,
#else
g_warning("Search results ignored. Fixme!");
#endif
- II(rc,mbox->handle,
+ II(rc,mbox->handle,libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(mbox)),
imap_mbox_uid_search(mbox->handle, query,
(void(*)(unsigned,void*))imap_matched,
cbdata));
@@ -1812,7 +1801,7 @@ libbalsa_imap_rename_subfolder(LibBalsaMailboxImap* imap,
return FALSE;
}
- II(rc,handle,
+ II(rc,handle,libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(imap)),
imap_mbox_subscribe(handle, imap->path, FALSE));
delim[0] = imap_mbox_handle_get_delim(handle, new_parent);
delim[1] = '\0';
@@ -1859,7 +1848,7 @@ libbalsa_imap_new_subfolder(const gchar *parent, const gchar *folder,
new_path = g_build_path(delim, parent, folder, NULL);
} else
new_path = g_strdup(folder);
- II(rc,handle,
+ II(rc,handle,libbalsa_server_get_host(server),
imap_mbox_create(handle, new_path));
if (subscribe && rc == IMR_OK)
rc = imap_mbox_subscribe(handle, new_path, TRUE);
@@ -1891,7 +1880,7 @@ libbalsa_imap_delete_folder(LibBalsaMailboxImap *mailbox, GError **err)
* the subscription list should be treated as a list of bookmarks,
* not a list of physically existing mailboxes. */
imap_mbox_subscribe(handle, mailbox->path, FALSE);
- II(rc,handle,
+ II(rc,handle,libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(mailbox)),
imap_mbox_delete(handle, mailbox->path));
if(rc != IMR_OK) {
gchar *msg = imap_mbox_handle_get_last_msg(handle);
@@ -1933,7 +1922,7 @@ libbalsa_mailbox_imap_sync(LibBalsaMailbox * mailbox, gboolean expunge)
/* we are always in sync, we need only to do expunge now and then */
if(expunge) {
ImapResponse rc;
- II(rc,mimap->handle,
+ II(rc,mimap->handle,libbalsa_mailbox_get_name(mailbox),
imap_mbox_expunge(mimap->handle));
res = (rc == IMR_OK);
}
@@ -2295,7 +2284,7 @@ libbalsa_mailbox_imap_fetch_structure(LibBalsaMailbox *mailbox,
if(flags & LB_FETCH_RFC822_HEADERS) ift |= IMFETCH_RFC822HEADERS_SELECTED;
if(flags & LB_FETCH_STRUCTURE) ift |= IMFETCH_BODYSTRUCT;
- II(rc, mimap->handle,
+ II(rc, mimap->handle, libbalsa_mailbox_get_name(mailbox),
imap_mbox_handle_fetch_range(mimap->handle, msgno, msgno, ift));
if(rc == IMR_OK) { /* translate ImapData to LibBalsaMessage */
gchar *hdr;
@@ -2332,7 +2321,7 @@ libbalsa_mailbox_imap_fetch_headers(LibBalsaMailbox *mailbox,
if (msgno > imap_mbox_handle_get_exists(mimap->handle))
return;
- II(rc,mimap->handle,
+ II(rc,mimap->handle,libbalsa_mailbox_get_name(mailbox),
imap_mbox_handle_fetch_range(mimap->handle, msgno, msgno,
IMFETCH_RFC822HEADERS_SELECTED));
if(rc == IMR_OK) { /* translate ImapData to LibBalsaMessage */
@@ -2532,7 +2521,7 @@ lbm_imap_get_msg_part_from_cache(LibBalsaMessage * message,
}
rc = IMR_OK;
if (dt.body->octets > 0)
- II(rc,mimap->handle,
+ II(rc,mimap->handle,libbalsa_mailbox_get_name(mailbox),
imap_mbox_handle_fetch_body(mimap->handle, msgno,
section, FALSE, ifbo, append_str, &dt));
libbalsa_unlock_mailbox(mailbox);
@@ -3120,12 +3109,12 @@ lbm_imap_messages_change_flags(LibBalsaMailbox * mailbox, GArray * seqno,
pretty much of a theoretical character but we do not want to
risk the mail store integrity, do we? */
if (flag_set)
- II(rc, handle,
+ II(rc, handle, libbalsa_mailbox_get_name(mailbox),
imap_mbox_store_flag(handle,
seqno->len, (guint *) seqno->data,
flag_set, TRUE));
if (rc && flag_clr)
- II(rc, handle,
+ II(rc, handle, libbalsa_mailbox_get_name(mailbox),
imap_mbox_store_flag(handle,
seqno->len, (guint *) seqno->data,
flag_clr, FALSE));
@@ -3217,7 +3206,7 @@ libbalsa_mailbox_imap_set_threading(LibBalsaMailbox *mailbox,
switch(thread_type) {
case LB_MAILBOX_THREADING_SIMPLE:
case LB_MAILBOX_THREADING_JWZ:
- II(rc,mimap->handle,
+ II(rc,mimap->handle,libbalsa_mailbox_get_name(mailbox),
imap_mbox_thread(mimap->handle, "REFERENCES", filter));
if(rc == IMR_OK) {
new_tree =
@@ -3237,7 +3226,7 @@ libbalsa_mailbox_imap_set_threading(LibBalsaMailbox *mailbox,
/* fall through */
case LB_MAILBOX_THREADING_FLAT:
if(filter) {
- II(rc,mimap->handle,
+ II(rc,mimap->handle,libbalsa_mailbox_get_name(mailbox),
imap_mbox_sort_filter(mimap->handle,
lbmi_get_imap_sort_key(mailbox),
libbalsa_mailbox_get_view(mailbox)->sort_type ==
@@ -3318,7 +3307,7 @@ libbalsa_mailbox_imap_sort(LibBalsaMailbox *mbox, GArray *array)
if (libbalsa_mailbox_get_view(mbox)->sort_field != LB_MAILBOX_SORT_NO) {
ImapResponse rc;
/* Server-side sort of the whole mailbox. */
- II(rc, LIBBALSA_MAILBOX_IMAP(mbox)->handle,
+ II(rc, LIBBALSA_MAILBOX_IMAP(mbox)->handle, libbalsa_mailbox_get_name(mbox),
imap_mbox_sort_msgno(LIBBALSA_MAILBOX_IMAP(mbox)->handle,
lbmi_get_imap_sort_key(mbox), TRUE,
msgno_arr, len)); /* ignore errors */
diff --git a/libbalsa/mailbox_pop3.c b/libbalsa/mailbox_pop3.c
index 97f347fa0..c2116a291 100644
--- a/libbalsa/mailbox_pop3.c
+++ b/libbalsa/mailbox_pop3.c
@@ -536,11 +536,11 @@ libbalsa_mailbox_pop3_startup(LibBalsaServer *server,
static GList *
-update_msg_list(struct fetch_data *fd,
- const LibBalsaMailboxPOP3 *mailbox_pop3,
- GHashTable **current_uids,
- LibBalsaServer *server,
- GList *msg_list)
+update_msg_list(struct fetch_data *fd,
+ LibBalsaMailboxPOP3 *mailbox_pop3,
+ GHashTable **current_uids,
+ LibBalsaServer *server,
+ GList *msg_list)
{
GHashTable *uids = NULL;
gchar *uid_prefix = NULL;
@@ -571,8 +571,8 @@ update_msg_list(struct fetch_data *fd,
gchar *size_str;
size_str = libbalsa_size_to_gchar(msg_info->size);
- libbalsa_information(LIBBALSA_INFORMATION_WARNING, _("POP3 message %d oversized: %s —
skipped."), msg_info->id,
- size_str);
+ libbalsa_information(LIBBALSA_INFORMATION_WARNING, _("POP3 mailbox %s: message %d
oversized: %s — skipped."),
+ libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(mailbox_pop3)), msg_info->id,
size_str);
g_free(size_str);
skip = TRUE;
}
@@ -698,8 +698,8 @@ libbalsa_mailbox_pop3_check(LibBalsaMailbox * mailbox)
if (!result) {
net_client_shutdown(NET_CLIENT(pop));
- libbalsa_information(LIBBALSA_INFORMATION_ERROR, _("POP3 error: %s"),
- err != NULL ? err->message : "?");
+ libbalsa_information(LIBBALSA_INFORMATION_ERROR, _("POP3 mailbox %s error: %s"),
+ libbalsa_mailbox_get_name(mailbox), err != NULL ? err->message : "?");
if (err != NULL)
g_error_free(err);
}
diff --git a/libbalsa/send.c b/libbalsa/send.c
index 97339479a..e917ec50e 100644
--- a/libbalsa/send.c
+++ b/libbalsa/send.c
@@ -983,8 +983,9 @@ balsa_send_message_error(MessageQueueItem *mqi,
libbalsa_message_change_flags(mqi->orig, LIBBALSA_MESSAGE_FLAG_FLAGGED,
LIBBALSA_MESSAGE_FLAG_DELETED);
}
}
- libbalsa_information(LIBBALSA_INFORMATION_ERROR, _("Sending message failed: %s\nMessage left in your
outbox."),
- error->message);
+ libbalsa_information(LIBBALSA_INFORMATION_ERROR,
+ _("Sending message to SMTP server %s failed: %s\nMessage left in your outbox."),
+ libbalsa_smtp_server_get_name(mqi->smsg_info->smtp_server), error->message);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]