[balsa/cleanup-logging: 60/62] unify console logging
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/cleanup-logging: 60/62] unify console logging
- Date: Thu, 11 Jun 2020 18:12:50 +0000 (UTC)
commit 677724f4aa3371a8a48da8691213eb6ab5a3327e
Author: Albrecht Dreß <albrecht dress arcor de>
Date: Mon May 4 18:59:04 2020 +0200
unify console logging
This larger change is an attempt to consolidate the various methods used
for console logging throughout the project. See #32 for further details
and discussion.
common changes:
* define appropriate G_LOG_DOMAIN where applicable
* remove conditional compilation depending upon DEBUG and similar
defines; remove related print macros; use class getters instead of
objects public fields
* replace puts(), printf(), fprintf(), g_print(), g_message() by
g_warning(), g_debug() or g_critical(), whatever seems to be appropriate
* remove newlines and l10n from g_warning() and g_debug() strings
* replace strerror() by g_strerror()
* remove the “Debug” configuration setting (balsa_app.debug); use
g_debug() instead
* clean commented out debugging code
specific changes:
* README: document new log domains
* libbalsa/address-book-gpe.c, libbalsa/address-book-text.c,
libbalsa/address-book-osmo.c: replace printf(), g_message(), g_warning()
by libbalsa_address_book_set_status()
* libbalsa/identity.c: replace g_print() by libbalsa_information()
* libbalsa/information.c: fix CRITICAL when no icon has been set
* libbalsa/libbalsa.[ch]: remove unused function libbalsa_message()
* libbalsa/mailbox_imap.c, libbalsa/mailbox_local.c: replace
libbalsa_information() debug message by g_debug()
* libbalsa/mailbox_local.c, libbalsa/misc.c, src/mailbox-node.c: use
LIBBALSA_INFORMATION_MESSAGE instead of LIBBALSA_INFORMATION_DEBUG or
g_print() for more meaningful information
* src/save-restore.c: eject when loading an out-of-range value
Signed-off-by: Albrecht Dreß <albrecht dress arcor de>
README | 11 ++++++
libbalsa/address-book-extern.c | 17 ++++----
libbalsa/address-book-gpe.c | 14 ++++---
libbalsa/address-book-ldap.c | 15 ++++---
libbalsa/address-book-osmo.c | 7 +++-
libbalsa/address-book-text.c | 37 +++++++++---------
libbalsa/address.c | 14 +++----
libbalsa/application-helpers.c | 4 +-
libbalsa/body.c | 2 +-
libbalsa/filter.c | 2 +-
libbalsa/identity.c | 5 ++-
libbalsa/imap/auth-gssapi.c | 1 -
libbalsa/imap/imap-commands.c | 8 ++--
libbalsa/imap/imap-handle.c | 12 ++----
libbalsa/information.c | 14 +++----
libbalsa/libbalsa-conf.c | 37 +++++-------------
libbalsa/libbalsa.c | 11 ------
libbalsa/libbalsa.h | 2 -
libbalsa/macosx-helpers.c | 4 +-
libbalsa/mailbox.c | 34 +++++-----------
libbalsa/mailbox_imap.c | 89 +++++++++++++++++++++---------------------
libbalsa/mailbox_local.c | 31 +++++++--------
libbalsa/mailbox_maildir.c | 38 ++++++++----------
libbalsa/mailbox_mbox.c | 89 +++++++++++++++++-------------------------
libbalsa/mailbox_mh.c | 37 ++++++++----------
libbalsa/mailbox_pop3.c | 7 +++-
libbalsa/message.c | 8 +---
libbalsa/misc.c | 14 ++++---
libbalsa/send.c | 19 +++++----
src/ab-main.c | 17 ++++----
src/balsa-app.c | 19 +++------
src/balsa-app.h | 1 -
src/balsa-icons.c | 25 +++++-------
src/balsa-index.c | 21 +++++-----
src/balsa-mblist.c | 4 +-
src/balsa-message.c | 9 ++---
src/balsa-print-object-image.c | 2 +-
src/filter-run-callbacks.c | 4 +-
src/folder-conf.c | 5 +--
src/mailbox-conf.c | 4 +-
src/mailbox-node.c | 16 ++++----
src/main-window.c | 16 ++++----
src/main-window.h | 10 -----
src/main.c | 16 ++++----
src/message-window.c | 8 ++--
src/pref-manager.c | 11 +-----
src/print-gtk.c | 2 +-
src/save-restore.c | 13 +++---
src/sendmsg-window.c | 48 +++++++++--------------
src/spell-check.c | 36 ++++++-----------
src/toolbar-factory.c | 2 +-
src/toolbar-prefs.c | 68 ++------------------------------
52 files changed, 381 insertions(+), 559 deletions(-)
---
diff --git a/README b/README
index 35c996744..a18ab3b35 100644
--- a/README
+++ b/README
@@ -240,7 +240,18 @@ following custom domains are implemented in Balsa:
- imap: IMAP server interaction. Warning: the output may contain
plain-text passwords.
- crypto: GnuPG and S/MIME crypto operations
+- autocrypt: Autocrypt operations
- html: HTML rendering with webkit2
+- address-book: address book backend operations (GPE, LDAP, …)
+- icons:
+- mbox-imap: IMAP mailbox operations
+- mbox-local: local mailbox operations
+- mbox-maildir: Maildir mailbox operations
+- mbox-mbox: MBox mailbox operations
+- mbox-mh: MH mailbox operations
+- mbox-pop3: POP3 mailbox operations
+- send: message transmission
+- spell-check: internal spell checker
Reporting Bugs:
diff --git a/libbalsa/address-book-extern.c b/libbalsa/address-book-extern.c
index b0fe4bc55..0ddd9bfa0 100644
--- a/libbalsa/address-book-extern.c
+++ b/libbalsa/address-book-extern.c
@@ -45,6 +45,11 @@
#include "libbalsa-conf.h"
#include <glib/gi18n.h>
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "address-book"
+
/* FIXME: Arbitrary constant */
#define LINE_LEN 256
#define LINE_LEN_STR "256"
@@ -235,9 +240,7 @@ parse_externq_file(LibBalsaAddressBookExternq *ab_externq,
if (fgets(string, sizeof(string), gc)) {
/* The first line should be junk, just debug output */
-#ifdef DEBUG
- printf("%s\n", string);
-#endif
+ g_debug("%s", string);
} /* FIXME check error */
while (fgets(string, sizeof(string), gc)) {
@@ -245,13 +248,9 @@ parse_externq_file(LibBalsaAddressBookExternq *ab_externq,
"%" LINE_LEN_STR "[^\t]"
"%" LINE_LEN_STR "[^\n]",
email, name, tmp);
-#ifdef DEBUG
- printf("%s =>%i\n", string, i);
-#endif
+ g_debug("%s =>%i", string, i);
if(i<2) continue;
-#ifdef DEBUG
- printf("%s,%s,%s\n",email,name,tmp);
-#endif
+ g_debug("%s,%s,%s",email,name,tmp);
cb(email, name, data);
}
pclose(gc);
diff --git a/libbalsa/address-book-gpe.c b/libbalsa/address-book-gpe.c
index b2f7c7afd..92d63cbb1 100644
--- a/libbalsa/address-book-gpe.c
+++ b/libbalsa/address-book-gpe.c
@@ -31,6 +31,11 @@
#if defined(HAVE_SQLITE)
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "address-book"
+
#include "address-book-gpe.h"
#ifdef HAVE_SQLITE3
@@ -176,7 +181,7 @@ libbalsa_address_book_gpe_open_db(LibBalsaAddressBookGpe * ab_gpe)
g_free(dir);
if (sqlite3_open(name, &ab_gpe->db) != SQLITE_OK) {
- printf("Cannot open “%s”: %s\n", name, sqlite3_errmsg(ab_gpe->db));
+ libbalsa_address_book_set_status(LIBBALSA_ADDRESS_BOOK(ab_gpe), sqlite3_errmsg(ab_gpe->db));
g_free(name);
sqlite3_close(ab_gpe->db);
ab_gpe->db = NULL;
@@ -194,7 +199,7 @@ libbalsa_address_book_gpe_open_db(LibBalsaAddressBookGpe * ab_gpe)
ab_gpe->db = sqlite_open(name, 0, &errmsg);
g_free(name);
if(ab_gpe->db == NULL) {
- printf("Cannot open: %s\n", errmsg);
+ libbalsa_address_book_set_status(LIBBALSA_ADDRESS_BOOK(ab_gpe), errmsg);
free(errmsg);
return 0;
}
@@ -388,7 +393,6 @@ libbalsa_address_book_gpe_load(LibBalsaAddressBook * ab,
#endif /* HAVE_SQLITE3 */
if(r != SQLITE_OK) {
- printf("r=%d err=%s\n", r, err);
libbalsa_address_book_set_status(ab, err);
#ifdef HAVE_SQLITE3
sqlite3_free(err);
@@ -816,7 +820,7 @@ libbalsa_address_book_gpe_alias_complete(LibBalsaAddressBook * ab,
"select distinct urn from contacts_urn",
gpe_read_completion, &gcc, &err);
if(err) {
- printf("r=%d err=%s\n", r, err);
+ g_debug("r=%d err=%s", r, err);
sqlite3_free(err);
}
#else /* HAVE_SQLITE3 */
@@ -828,7 +832,7 @@ libbalsa_address_book_gpe_alias_complete(LibBalsaAddressBook * ab,
r = sqlite_exec(ab_gpe->db, "select distinct urn from contacts_urn",
gpe_read_completion, &gcc, &err);
if(err) {
- printf("r=%d err=%s\n", r, err);
+ g_debug("r=%d err=%s", r, err);
free(err);
}
#endif /* HAVE_SQLITE3 */
diff --git a/libbalsa/address-book-ldap.c b/libbalsa/address-book-ldap.c
index 50990d606..52f6b46c5 100644
--- a/libbalsa/address-book-ldap.c
+++ b/libbalsa/address-book-ldap.c
@@ -53,7 +53,7 @@
#ifdef G_LOG_DOMAIN
# undef G_LOG_DOMAIN
#endif
-#define G_LOG_DOMAIN "ab-ldap"
+#define G_LOG_DOMAIN "address-book"
/* don't search when prefix has length shorter than LDAP_MIN_LEN */
@@ -246,7 +246,7 @@ abl_interaction(unsigned flags, sasl_interact_t *interact,
case SASL_CB_USER:
case SASL_CB_NOECHOPROMPT:
case SASL_CB_ECHOPROMPT:
- g_warning("unhandled SASL request %d", interact->id);
+ g_debug("unhandled SASL request %d", interact->id);
return LDAP_INAVAILABLE;
}
@@ -352,7 +352,7 @@ libbalsa_address_book_ldap_open_connection(LibBalsaAddressBookLdap * ab_ldap)
gchar *uri;
uri = ldap_connection_get_uri(ab_ldap->directory);
- g_message("LDAP address book '%s', URI '%s', uses TLS, ignore STARTTLS option",
+ g_debug("LDAP address book '%s', URI '%s', uses TLS, ignore STARTTLS option",
libbalsa_address_book_get_name(ab), uri);
ldap_memfree(uri);
} else {
@@ -437,7 +437,6 @@ libbalsa_address_book_ldap_load(LibBalsaAddressBook * ab,
* we use the asynchronous lookup to fetch the results in chunks
* in case we exceed administrative limits.
*/
- /* g_print("Performing full lookup…\n"); */
ldap_filter = filter
? g_strdup_printf("(&(objectClass=organizationalPerson)(mail=*)"
"(|(cn=%s*)(sn=%s*)(mail=%s*@*)))",
@@ -723,7 +722,7 @@ libbalsa_address_book_ldap_add_address(LibBalsaAddressBook *ab,
}
/* fall through */
default:
- g_warning("ldap_add for dn=“%s” failed[0x%x]: %s",
+ g_debug("ldap_add for dn=“%s” failed[0x%x]: %s",
dn, rc, ldap_err2string(rc));
}
} while(cnt++<1);
@@ -767,7 +766,7 @@ libbalsa_address_book_ldap_remove_address(LibBalsaAddressBook *ab,
}
/* fall through */
default:
- g_warning("ldap_delete for dn=“%s” failed[0x%x]: %s",
+ g_debug("ldap_delete for dn=“%s” failed[0x%x]: %s",
dn, rc, ldap_err2string(rc));
}
} while(cnt++<1);
@@ -890,7 +889,7 @@ libbalsa_address_book_ldap_modify_address(LibBalsaAddressBook *ab,
}
/* fall through */
default:
- g_warning("ldap_modify for dn=“%s” failed[0x%x]: %s",
+ g_debug("ldap_modify for dn=“%s” failed[0x%x]: %s",
dn, rc, ldap_err2string(rc));
}
} while(cnt++<1);
@@ -1104,7 +1103,7 @@ libbalsa_address_book_ldap_alias_complete(LibBalsaAddressBook * ab,
/*
* Until we know for sure, complain about all other errors.
*/
- g_warning("alias_complete::ldap_search_st: %s",
+ g_debug("alias_complete::ldap_search_st: %s",
ldap_err2string(rc));
break;
}
diff --git a/libbalsa/address-book-osmo.c b/libbalsa/address-book-osmo.c
index 8c43dd076..1bb043f12 100644
--- a/libbalsa/address-book-osmo.c
+++ b/libbalsa/address-book-osmo.c
@@ -36,6 +36,11 @@
#include <glib/gi18n.h>
#include "rfc6350.h"
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "address-book"
+
/* for the time being, osmo svn rev. 1099 accepts only reading via DBus, not writing new or modified records
*/
#undef OSMO_CAN_WRITE
@@ -232,7 +237,7 @@ libbalsa_address_book_osmo_alias_complete(LibBalsaAddressBook *ab,
g_debug("%s: filter for %s", __func__, prefix);
addresses = osmo_read_addresses(ab_osmo, prefix, &error);
if (error != NULL) {
- g_warning("%s: cannot read contacts from Osmo: %s", __func__, error->message);
+ libbalsa_address_book_set_status(ab, error->message);
g_error_free(error);
} else {
GList *p;
diff --git a/libbalsa/address-book-text.c b/libbalsa/address-book-text.c
index 424503c58..ac47fe153 100644
--- a/libbalsa/address-book-text.c
+++ b/libbalsa/address-book-text.c
@@ -41,6 +41,13 @@
/* FIXME: Arbitrary constant */
#define LINE_LEN 256
+
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "address-book"
+
+
static void
libbalsa_address_book_text_finalize(GObject * object);
@@ -437,10 +444,8 @@ lbab_text_open_temp(LibBalsaAddressBookText * ab_text, gchar ** path,
*path = g_strconcat(priv->path, ".tmp", NULL);
*stream = fopen(*path, "w");
if (*stream == NULL) {
-#if DEBUG
- g_message("Failed to open temporary address book file “%s”\n"
- " changes not saved", *path);
-#endif /* DEBUG */
+ libbalsa_address_book_set_status(LIBBALSA_ADDRESS_BOOK(ab_text), g_strerror(errno));
+ g_debug("Failed to open temporary address book file “%s”, changes not saved", *path);
g_free(*path);
*path = NULL;
return LBABERR_CANNOT_WRITE;
@@ -457,20 +462,15 @@ lbab_text_close_temp(LibBalsaAddressBookText * ab_text, const gchar * path)
if (unlink(priv->path) < 0
&& g_file_error_from_errno(errno) != G_FILE_ERROR_NOENT) {
-#if DEBUG
- g_message("Failed to unlink address book file “%s”\n"
- " new address book file saved as “%s”", priv->path,
- path);
- perror("TEXT");
-#endif /* DEBUG */
+ libbalsa_address_book_set_status(LIBBALSA_ADDRESS_BOOK(ab_text), g_strerror(errno));
+ g_debug("Failed to unlink address book file “%s” new address book file saved as “%s”. Error: %s",
+ priv->path, path, g_strerror(errno));
return LBABERR_CANNOT_WRITE;
}
if (rename(path, priv->path) < 0) {
-#if DEBUG
- g_message("Failed to rename temporary address book file “%s”\n",
- path);
-#endif /* DEBUG */
+ libbalsa_address_book_set_status(LIBBALSA_ADDRESS_BOOK(ab_text), g_strerror(errno));
+ g_debug("Failed to rename temporary address book file “%s”", path);
return LBABERR_CANNOT_WRITE;
}
@@ -666,11 +666,10 @@ libbalsa_address_book_text_modify_address(LibBalsaAddressBook * ab,
if (res == LBABERR_OK)
res = lbab_text_close_temp(ab_text, path);
-#if DEBUG
- else
- g_message("Failed to write to temporary address book file “%s”\n"
- " changes not saved", path);
-#endif /* DEBUG */
+ else {
+ libbalsa_address_book_set_status(ab, g_strerror(errno));
+ g_debug("Failed to write to temporary address book file “%s”, changes not saved", path);
+ }
g_free(path);
/* Invalidate the time stamp, so the book will be reloaded. */
diff --git a/libbalsa/address.c b/libbalsa/address.c
index 4e1f8f0d9..000bbaf9c 100644
--- a/libbalsa/address.c
+++ b/libbalsa/address.c
@@ -645,7 +645,7 @@ lba_get_name_or_mailbox(InternetAddressList * addr_list,
retval = INTERNET_ADDRESS_MAILBOX (ia)->addr;
else {
if (in_group)
- g_message("Ignoring nested group address");
+ g_debug("Ignoring nested group address");
else
retval = lba_get_name_or_mailbox(INTERNET_ADDRESS_GROUP(ia)->members,
get_name, TRUE);
@@ -899,7 +899,7 @@ addrlist_drag_received_cb(GtkWidget * widget, GdkDragContext * context,
gboolean dnd_success = FALSE;
LibBalsaAddress *addr;
- printf("drag_received:\n");
+ g_debug("drag_received");
/* Deal with what we are given from source */
if(selection_data
&& gtk_selection_data_get_length(selection_data) >= 0) {
@@ -908,7 +908,7 @@ addrlist_drag_received_cb(GtkWidget * widget, GdkDragContext * context,
addr = *(LibBalsaAddress **)
gtk_selection_data_get_data(selection_data);
if (addr != NULL && addr->addr_list != NULL) {
- g_print ("string: %s\n", (gchar*)addr->addr_list->data);
+ g_debug("string: %s", (gchar*)addr->addr_list->data);
gtk_list_store_insert_with_values(GTK_LIST_STORE(model),
&iter, 99999,
0,
@@ -918,14 +918,14 @@ addrlist_drag_received_cb(GtkWidget * widget, GdkDragContext * context,
}
break;
case LIBBALSA_ADDRESS_TRG_STRING:
- g_print("text/plain target not implemented.\n");
+ g_debug("text/plain target not implemented");
break;
- default: g_print ("nothing good");
+ default: g_debug("nothing good");
}
}
if (!dnd_success)
- g_print ("DnD data transfer failed!\n");
+ g_warning("DnD data transfer failed!");
gtk_drag_finish(context, dnd_success, FALSE, time);
}
@@ -949,7 +949,7 @@ addrlist_drag_drop_cb(GtkWidget *widget, GdkDragContext *context,
(g_list_nth_data (targets, LIBBALSA_ADDRESS_TRG_ADDRESS));
/* Request the data from the source. */
- printf("drag_drop requests target=%p\n", target_type);
+ g_debug("drag_drop requests target=%p", target_type);
gtk_drag_get_data
(
widget, /* will receive 'drag-data-received' signal */
diff --git a/libbalsa/application-helpers.c b/libbalsa/application-helpers.c
index c6f9ce71e..e352dba56 100644
--- a/libbalsa/application-helpers.c
+++ b/libbalsa/application-helpers.c
@@ -254,7 +254,7 @@ libbalsa_window_add_accelerator(GtkApplicationWindow * window,
gtk_accelerator_parse(accel, &accel_key, &accel_mods);
if (!accel_key) {
- g_print("%s: could not parse accelerator “%s”\n", __func__,
+ g_warning("%s: could not parse accelerator “%s”", __func__,
accel);
return;
}
@@ -263,7 +263,7 @@ libbalsa_window_add_accelerator(GtkApplicationWindow * window,
basename = basename ? basename + 1 : action_name;
action = g_action_map_lookup_action(action_map, basename);
if (!action) {
- g_print("%s: could not lookup action “%s”\n", __func__,
+ g_warning("%s: could not lookup action “%s”", __func__,
action_name);
return;
}
diff --git a/libbalsa/body.c b/libbalsa/body.c
index 4db6f7cf7..5d2a80cd7 100644
--- a/libbalsa/body.c
+++ b/libbalsa/body.c
@@ -566,7 +566,7 @@ libbalsa_message_body_get_message_part_stream(LibBalsaMessageBody * body,
bytes_written =
g_mime_object_write_to_stream(GMIME_OBJECT(msg), NULL, stream);
libbalsa_mailbox_unlock_store(mailbox);
- printf("Written %ld bytes of embedded message\n",
+ g_debug("Written %ld bytes of embedded message",
(long) bytes_written);
if (bytes_written < 0) {
diff --git a/libbalsa/filter.c b/libbalsa/filter.c
index d5cbf4101..91ae2be81 100644
--- a/libbalsa/filter.c
+++ b/libbalsa/filter.c
@@ -255,7 +255,7 @@ libbalsa_filter_mailbox_messages(LibBalsaFilter * filt,
screen = gdk_screen_get_default();
rc = ca_context_play(ca_gtk_context_get_for_screen(screen), 0,
CA_PROP_MEDIA_FILENAME, filt->sound, NULL);
- g_message("(%s) play %s, %s", __func__, filt->sound, ca_strerror(rc));
+ g_debug("(%s) play %s, %s", __func__, filt->sound, ca_strerror(rc));
}
#endif /* HAVE_CANBERRA */
if (filt->popup_text)
diff --git a/libbalsa/identity.c b/libbalsa/identity.c
index 448296e33..037711ab0 100644
--- a/libbalsa/identity.c
+++ b/libbalsa/identity.c
@@ -1607,8 +1607,9 @@ help_ident_cb(GtkWidget * widget)
gtk_get_current_event_time(), &err);
if (err) {
- g_print(_("Error displaying help for identities: %s\n"),
- err->message);
+ libbalsa_information(LIBBALSA_INFORMATION_WARNING,
+ _("Error displaying help for identities: %s"),
+ err->message);
g_error_free(err);
}
}
diff --git a/libbalsa/imap/auth-gssapi.c b/libbalsa/imap/auth-gssapi.c
index 061e83ef7..e5bcd6973 100644
--- a/libbalsa/imap/auth-gssapi.c
+++ b/libbalsa/imap/auth-gssapi.c
@@ -159,7 +159,6 @@ imap_auth_gssapi(ImapMboxHandle* handle)
g_strfreev(auth_data);
if (error != NULL) {
- g_message("%s: %s", __func__, error->message);
imap_mbox_handle_set_msg(handle, _("GSSAPI authentication failed: %s"), error->message);
g_error_free(error);
}
diff --git a/libbalsa/imap/imap-commands.c b/libbalsa/imap/imap-commands.c
index 4b82e1bda..09319c760 100644
--- a/libbalsa/imap/imap-commands.c
+++ b/libbalsa/imap/imap-commands.c
@@ -502,8 +502,8 @@ append_commit(ImapMboxHandle *handle, unsigned cmdno, ImapSequence *uid_seq)
uid_seq->uid_validity = handle->uidplus.dst_uid_validity;
uid_seq->ranges = handle->uidplus.dst;
} else if(uid_seq->uid_validity != handle->uidplus.dst_uid_validity) {
- printf("The IMAP server keeps changing UID validity, "
- "ignoring UIDPLUS response (%u -> %u)\n",
+ g_debug("The IMAP server keeps changing UID validity, "
+ "ignoring UIDPLUS response (%u -> %u)",
uid_seq->uid_validity, handle->uidplus.dst_uid_validity);
uid_seq->uid_validity = handle->uidplus.dst_uid_validity;
g_list_free(uid_seq->ranges);
@@ -1858,8 +1858,8 @@ imap_mbox_sort_msgno_client(ImapMboxHandle *handle, ImapSortKey key,
if(fetch_cnt>0) {
ImapResponse rc;
qsort(seqno_to_fetch, fetch_cnt, sizeof(unsigned), comp_unsigned);
- printf("Should the client side sorting code "
- "be sorry about your bandwidth usage?\n");
+ g_debug("Should the client side sorting code "
+ "be sorry about your bandwidth usage?");
rc = imap_mbox_handle_fetch_set_unlocked(handle, seqno_to_fetch,
fetch_cnt, fetch_type);
if(rc != IMR_OK)
diff --git a/libbalsa/imap/imap-handle.c b/libbalsa/imap/imap-handle.c
index fb90c6429..625a121eb 100644
--- a/libbalsa/imap/imap-handle.c
+++ b/libbalsa/imap/imap-handle.c
@@ -315,7 +315,7 @@ async_process_real(ImapMboxHandle *h)
if (h->idle_state == IDLE_RESPONSE_PENDING) {
int c;
if(rc != IMR_RESPOND) {
- g_message("%s: expected IMR_RESPOND but got %d", __func__, rc);
+ g_debug("%s: expected IMR_RESPOND but got %d", __func__, rc);
imap_handle_disconnect(h);
return G_SOURCE_REMOVE;
}
@@ -694,7 +694,7 @@ imap_mbox_connect(ImapMboxHandle* handle)
handle->state = IMHS_CONNECTED;
if ( (resp=imap_cmd_step(handle, 0)) != IMR_UNTAGGED) {
- g_message("imap_mbox_connect:unexpected initial response(%d): %s",
+ g_debug("imap_mbox_connect:unexpected initial response(%d): %s",
resp, handle->last_msg);
imap_handle_disconnect(handle);
return IMAP_PROTOCOL_ERROR;
@@ -1835,20 +1835,16 @@ imap_cmd_step(ImapMboxHandle* handle, unsigned lastcmd)
executing. We store the response in the hash table so that we
can provide a proper response when somebody asks. */
ci = cmdi_find_by_no(handle->cmd_info, cmdno);
-#ifdef DEBUG
if(lastcmd != cmdno)
g_debug("Looking for %x and encountered response to %x (%p)",
lastcmd, cmdno, ci);
-#endif
if(ci) {
if(ci->complete_cb && !ci->complete_cb(handle, ci->cb_data)) {
ci->rc = rc;
ci->completed = 1;
g_debug("Cmd %x marked as completed with rc=%d", cmdno, rc);
} else {
-#ifdef DEBUG
g_debug("CmdInfo for cmd %x removed", cmdno);
-#endif
handle->cmd_info = g_list_remove(handle->cmd_info, ci);
g_free(ci);
}
@@ -3844,8 +3840,8 @@ ir_body_section(NetClientSioBuf *sio, unsigned seqno,
if(i>0 && isalpha(buf[i])) /* we have \[[.0-9]something] */
body_type = IMAP_BODY_TYPE_HEADER;
- if(c != ']') { puts("] expected"); return IMR_PROTOCOL; }
- if(sio_getc(sio) != ' ') { puts("space expected"); return IMR_PROTOCOL;}
+ if(c != ']') { g_debug("] expected"); return IMR_PROTOCOL; }
+ if(sio_getc(sio) != ' ') { g_debug("space expected"); return IMR_PROTOCOL;}
bs = imap_get_binary_string(sio);
if(bs) {
if(bs->str && body_cb)
diff --git a/libbalsa/information.c b/libbalsa/information.c
index 74d7c0010..456772c50 100644
--- a/libbalsa/information.c
+++ b/libbalsa/information.c
@@ -43,7 +43,6 @@ libbalsa_information_varg(GtkWindow *parent, LibBalsaInformationType type,
{
gchar *msg;
const gchar *icon_str;
- GIcon *icon;
gboolean send;
if (notification == NULL)
@@ -66,9 +65,13 @@ libbalsa_information_varg(GtkWindow *parent, LibBalsaInformationType type,
break;
}
- icon = g_themed_icon_new(icon_str);
- g_notification_set_icon(notification, icon);
- g_object_unref(icon);
+ if (icon_str != NULL) {
+ GIcon *icon;
+
+ icon = g_themed_icon_new(icon_str);
+ g_notification_set_icon(notification, icon);
+ g_object_unref(icon);
+ }
msg = g_strdup_vprintf(fmt, ap);
g_notification_set_body(notification, msg);
@@ -91,9 +94,6 @@ libbalsa_information(LibBalsaInformationType type,
{
va_list va_args;
-#ifndef DEBUG
- if (type == LIBBALSA_INFORMATION_DEBUG) return;
-#endif
va_start(va_args, fmt);
libbalsa_information_varg(NULL, type, fmt, va_args);
va_end(va_args);
diff --git a/libbalsa/libbalsa-conf.c b/libbalsa/libbalsa-conf.c
index 735b10551..7945907be 100644
--- a/libbalsa/libbalsa-conf.c
+++ b/libbalsa/libbalsa-conf.c
@@ -52,7 +52,6 @@ static gchar * libbalsa_rot(const gchar * pass)
G_GNUC_WARN_UNUSED_RESULT;
#define BALSA_KEY_FILE "config"
-#define DEBUG FALSE
#define LBC_KEY_FILE(priv) \
((priv) ? lbc_conf_priv.key_file : lbc_conf.key_file)
#define LBC_CHANGED(priv) \
@@ -65,9 +64,7 @@ lbc_readfile(const gchar * filename)
gchar **split;
if (!g_file_get_contents(filename, &buf, NULL, NULL)) {
-#if DEBUG
- g_message("Failed to read “%s”\n", filename);
-#endif /* DEBUG */
+ g_debug("Failed to read “%s”", filename);
return NULL;
}
@@ -114,10 +111,8 @@ lbc_init(LibBalsaConf * conf, const gchar * filename,
old_path =
g_build_filename(g_get_home_dir(), old_dir, "balsa", NULL);
-#if DEBUG
- g_message("Could not load config from “%s”:\n %s\n"
+ g_debug("Could not load config from “%s”: %s;"
" trying “%s”", conf->path, error->message, old_path);
-#endif /* DEBUG */
g_clear_error(&error);
key_file_text = lbc_readfile(old_path);
@@ -132,11 +127,9 @@ lbc_init(LibBalsaConf * conf, const gchar * filename,
g_key_file_set_list_separator(conf->key_file, ';');
}
if (key_file_text == NULL || error != NULL) {
-#if DEBUG
- g_message("Could not load key file from file “%s”: %s",
+ g_debug("Could not load key file from file “%s”: %s",
old_path,
error ? error->message : g_strerror(errno));
-#endif /* DEBUG */
g_clear_error(&error);
warn = FALSE;
}
@@ -529,10 +522,8 @@ lbc_sync(LibBalsaConf * conf)
buf = g_key_file_to_data(conf->key_file, &len, &error);
if (error) {
-#if DEBUG
- g_message("Failed to sync config file “%s”: %s\n"
+ g_warning("Failed to sync config file “%s”: %s;"
" changes not saved", conf->path, error->message);
-#endif /* DEBUG */
g_error_free(error);
g_free(buf);
return;
@@ -541,16 +532,12 @@ lbc_sync(LibBalsaConf * conf)
conf->mtime = time(NULL);
if (!g_file_set_contents(conf->path, buf, len, &error)) {
if (error) {
-#if DEBUG
- g_message("Failed to rewrite config file “%s”: %s\n"
+ g_warning("Failed to rewrite config file “%s”: %s;"
" changes not saved", conf->path, error->message);
-#endif /* DEBUG */
g_error_free(error);
-#if DEBUG
} else {
- g_message("Failed to rewrite config file “%s”;"
+ g_warning("Failed to rewrite config file “%s”;"
" changes not saved", conf->path);
-#endif /* DEBUG */
}
} else if (conf->private) {
g_chmod(conf->path, 0600);
@@ -566,9 +553,7 @@ void
libbalsa_conf_sync(void)
{
G_LOCK(lbc_sync_idle_id);
-#if DEBUG
- g_print("%s id %d, will be cleared\n", __func__, lbc_sync_idle_id);
-#endif /* DEBUG */
+ g_debug("%s id %d, will be cleared", __func__, lbc_sync_idle_id);
if (lbc_sync_idle_id) {
g_source_remove(lbc_sync_idle_id);
lbc_sync_idle_id = 0;
@@ -592,15 +577,11 @@ void
libbalsa_conf_queue_sync(void)
{
G_LOCK(lbc_sync_idle_id);
-#if DEBUG
- g_print("%s id %d, will be set if zero\n", __func__, lbc_sync_idle_id);
-#endif /* DEBUG */
+ g_debug("%s id %d, will be set if zero", __func__, lbc_sync_idle_id);
if (!lbc_sync_idle_id)
lbc_sync_idle_id =
g_idle_add((GSourceFunc) libbalsa_conf_sync_idle_cb, NULL);
-#if DEBUG
- g_print("%s id now %d\n", __func__, lbc_sync_idle_id);
-#endif /* DEBUG */
+ g_debug("%s id now %d", __func__, lbc_sync_idle_id);
G_UNLOCK(lbc_sync_idle_id);
}
diff --git a/libbalsa/libbalsa.c b/libbalsa/libbalsa.c
index a3487239c..fe48f1a41 100644
--- a/libbalsa/libbalsa.c
+++ b/libbalsa/libbalsa.c
@@ -51,17 +51,6 @@
static GThread *main_thread_id;
-void
-libbalsa_message(const char *fmt, ...)
-{
- va_list va_args;
-
- va_start(va_args, fmt);
- libbalsa_information_varg(NULL, LIBBALSA_INFORMATION_MESSAGE,
- fmt, va_args);
- va_end(va_args);
-}
-
void
libbalsa_init(void)
{
diff --git a/libbalsa/libbalsa.h b/libbalsa/libbalsa.h
index 6982f555e..deac03796 100644
--- a/libbalsa/libbalsa.h
+++ b/libbalsa/libbalsa.h
@@ -136,8 +136,6 @@ void libbalsa_certs_destroy(void);
GThread *libbalsa_get_main_thread(void);
gboolean libbalsa_am_i_subthread(void);
-void libbalsa_message(const char *fmt, ...)
- G_GNUC_PRINTF(1, 2);
typedef enum {
LIBBALSA_PROGRESS_NO = 0,
diff --git a/libbalsa/macosx-helpers.c b/libbalsa/macosx-helpers.c
index 4b025a167..c94daa9e6 100644
--- a/libbalsa/macosx-helpers.c
+++ b/libbalsa/macosx-helpers.c
@@ -3,7 +3,7 @@
*
* Helper functions for managing the IGE Mac Integration stuff
*
- * Copyright (C) 2004 Albrecht Dre� <albrecht dress arcor de>
+ * Copyright (C) 2004 Albrecht Dreß <albrecht dress arcor de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -49,7 +49,7 @@ libbalsa_macosx_menu_for_parent(GtkWidget *window, GtkWindow *parent)
g_signal_connect(window, "focus-in-event",
G_CALLBACK(update_osx_menubar), parent);
else
- g_message("called %s for widget %p with NULL parent", __func__, window);
+ g_debug("called %s for widget %p with NULL parent", __func__, window);
}
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index e9c924bd7..e3e864acb 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -1064,8 +1064,7 @@ copy_iterator(LibBalsaMessageFlag *flags, GMimeStream **stream, void * arg)
/* Copy stream */
*stream = libbalsa_mailbox_get_message_stream(mailbox, msgno, TRUE);
if(!*stream) {
- printf("Connection broken for message %u\n",
- (unsigned)msgno);
+ g_warning("Connection broken for message %u", msgno);
return FALSE;
}
@@ -1308,11 +1307,8 @@ lbm_msgnos_changed_idle_cb(LibBalsaMailbox * mailbox)
if (!priv->msgnos_changed)
return FALSE;
-#define DEBUG FALSE
-#if DEBUG
- g_print("%s %s %d requested\n", __func__, priv->name,
+ g_debug("%s %s %d requested", __func__, priv->name,
priv->msgnos_changed->len);
-#endif
g_mutex_lock(&msgnos_changed_lock);
for (i = 0; i < priv->msgnos_changed->len; i++) {
@@ -1322,19 +1318,15 @@ lbm_msgnos_changed_idle_cb(LibBalsaMailbox * mailbox)
if (!MAILBOX_OPEN(mailbox))
break;
-#if DEBUG
- g_print("%s %s msgno %d\n", __func__, priv->name, msgno);
-#endif
+ g_debug("%s %s msgno %d", __func__, priv->name, msgno);
g_mutex_unlock(&msgnos_changed_lock);
iter.user_data = NULL;
lbm_msgno_row_changed(mailbox, msgno, &iter);
g_mutex_lock(&msgnos_changed_lock);
}
-#if DEBUG
- g_print("%s %s %d processed\n", __func__, priv->name,
+ g_debug("%s %s %d processed", __func__, priv->name,
priv->msgnos_changed->len);
-#endif
priv->msgnos_changed->len = 0;
g_mutex_unlock(&msgnos_changed_lock);
@@ -2054,7 +2046,7 @@ libbalsa_mailbox_get_message(LibBalsaMailbox * mailbox, guint msgno)
libbalsa_lock_mailbox(mailbox);
if (!MAILBOX_OPEN(mailbox)) {
- g_message(_("libbalsa_mailbox_get_message: mailbox %s is closed"),
+ g_debug("libbalsa_mailbox_get_message: mailbox %s is closed",
priv->name);
libbalsa_unlock_mailbox(mailbox);
return NULL;
@@ -3122,10 +3114,8 @@ lbm_get_index_entry_real(LibBalsaMailbox * mailbox)
LibBalsaMailboxPrivate *priv = libbalsa_mailbox_get_instance_private(mailbox);
guint i;
-#if DEBUG
- g_print("%s %s %d requested\n", __func__, priv->name,
+ g_debug("%s %s %d requested", __func__, priv->name,
priv->msgnos_pending->len);
-#endif
g_mutex_lock(&get_index_entry_lock);
for (i = 0; i < priv->msgnos_pending->len; i++) {
guint msgno = g_array_index(priv->msgnos_pending, guint, i);
@@ -3134,9 +3124,7 @@ lbm_get_index_entry_real(LibBalsaMailbox * mailbox)
if (!MAILBOX_OPEN(mailbox))
break;
-#if DEBUG
- g_print("%s %s msgno %d\n", __func__, priv->name, msgno);
-#endif
+ g_debug("%s %s msgno %d", __func__, priv->name, msgno);
g_mutex_unlock(&get_index_entry_lock);
if ((message = libbalsa_mailbox_get_message(mailbox, msgno)))
/* get-message has cached the message info, so we just unref
@@ -3145,10 +3133,8 @@ lbm_get_index_entry_real(LibBalsaMailbox * mailbox)
g_mutex_lock(&get_index_entry_lock);
}
-#if DEBUG
- g_print("%s %s %d processed\n", __func__, priv->name,
+ g_debug("%s %s %d processed", __func__, priv->name,
priv->msgnos_pending->len);
-#endif
priv->msgnos_pending->len = 0;
g_mutex_unlock(&get_index_entry_lock);
@@ -3986,7 +3972,7 @@ mailbox_set_sort_func(GtkTreeSortable * sortable,
GtkTreeIterCompareFunc func,
gpointer data, GDestroyNotify destroy)
{
- g_warning("%s called but not implemented.\n", __func__);
+ g_warning("%s called but not implemented.", __func__);
}
static void
@@ -3994,7 +3980,7 @@ mailbox_set_default_sort_func(GtkTreeSortable * sortable,
GtkTreeIterCompareFunc func,
gpointer data, GDestroyNotify destroy)
{
- g_warning("%s called but not implemented.\n", __func__);
+ g_warning("%s called but not implemented.", __func__);
}
/* called from gtk-tree-view-column */
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index 1828db2a8..b124646fc 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -57,6 +57,11 @@
#include <glib/gi18n.h>
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "mbox-imap"
+
#define ENABLE_CLIENT_SIDE_SORT 1
struct _LibBalsaMailboxImap {
@@ -185,9 +190,9 @@ static struct message_info *message_info_from_msgno(
struct message_info *msg_info;
if (msgno > mimap->messages_info->len) {
- printf("%s %s msgno %d > messages_info len %d\n", __func__,
- libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(mimap)), msgno,
- mimap->messages_info->len);
+ g_debug("%s msgno %d > messages_info len %d",
+ libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(mimap)), msgno,
+ mimap->messages_info->len);
msg_info = NULL;
} else
msg_info =
@@ -529,7 +534,7 @@ clean_dir(const char *dir_name, off_t cache_size)
struct file_info *fi = (struct file_info*)(lst->data);
sz += fi->size;
if(sz>cache_size) {
- /* printf("removing %s\n", fi->name); */
+ g_debug("removing %s", fi->name);
unlink(fi->name);
}
g_free(fi->name);
@@ -826,8 +831,8 @@ imap_exists_idle(gpointer data)
- the only sensible scenario is that the connection was
severed. Still, we need to recover from this somehow... -
We invalidate all the cache now. */
- printf("%s: expunge ignored? Had %u messages and now only %u. "
- "Bug in the program or broken connection\n",
+ g_debug("%s: expunge ignored? Had %u messages and now only %u. "
+ "Bug in the program or broken connection",
__func__, mimap->messages_info->len, cnt);
for(i=0; i<mimap->messages_info->len; i++) {
gchar *msgid;
@@ -1099,11 +1104,9 @@ libbalsa_mailbox_imap_open(LibBalsaMailbox * mailbox, GError **err)
else
mimap->search_stamp = libbalsa_mailbox_get_stamp(mailbox);
-#ifdef DEBUG
- g_print(_("%s: Opening %s Refcount: %d\n"),
- "LibBalsaMailboxImap", libbalsa_mailbox_get_name(mailbox),
+ g_debug("%s: Opening %s Refcount: %d",
+ __func__, libbalsa_mailbox_get_name(mailbox),
libbalsa_mailbox_get_open_ref(mailbox));
-#endif
return TRUE;
}
@@ -1201,7 +1204,7 @@ get_cache_stream(LibBalsaMailboxImap *mimap, guint uid, gboolean peek)
ferr = ferror(cache);
fclose(cache);
if(ferr || rc != IMR_OK) {
- printf("Error fetching RFC822 message, removing cache.\n");
+ g_debug("Error fetching RFC822 message, removing cache.");
unlink(path);
}
}
@@ -1320,7 +1323,7 @@ libbalsa_mailbox_imap_check(LibBalsaMailbox * mailbox)
if (LIBBALSA_MAILBOX_IMAP(mailbox)->handle)
libbalsa_mailbox_imap_noop(LIBBALSA_MAILBOX_IMAP(mailbox));
else
- g_warning("mailbox has open_ref>0 but no handle!\n");
+ g_warning("mailbox has open_ref>0 but no handle!");
}
/* Search iters */
@@ -1540,7 +1543,7 @@ imap_matched(unsigned uid, ImapSearchData* data)
if(m)
g_hash_table_insert(data->res, m, m);
else
- printf("Could not find UID: %u in message list\n", uid);
+ g_debug("Could not find UID: %u in message list", uid);
}
/* Gets the messages matching the conditions via the IMAP search command
@@ -1573,7 +1576,7 @@ GHashTable * libbalsa_mailbox_imap_get_matchings(LibBalsaMailboxImap* mbox,
g_hash_table_insert(cbdata->uids,
GUINT_TO_POINTER(imsg->uid), m);
} else
- g_warning("Msg %d out of range\n", m->msgno);
+ g_warning("Msg %d out of range", m->msgno);
}
#else
g_warning("Search results ignored. Fixme!");
@@ -1590,10 +1593,8 @@ GHashTable * libbalsa_mailbox_imap_get_matchings(LibBalsaMailboxImap* mbox,
g_hash_table_destroy(cbdata->res);
cbdata->res = NULL;
*err = TRUE;
- libbalsa_information(LIBBALSA_INFORMATION_DEBUG,
- _("IMAP SEARCH command failed for mailbox %s\n"
- "falling back to default searching method"),
- libbalsa_mailbox_get_url(LIBBALSA_MAILBOX(mbox)));
+ g_debug("IMAP SEARCH command failed for mailbox %s, falling back to default searching method",
+ libbalsa_mailbox_get_url(LIBBALSA_MAILBOX(mbox)));
}
result = cbdata->res;
@@ -1703,9 +1704,9 @@ libbalsa_mailbox_imap_force_disconnect(LibBalsaMailboxImap* mimap)
if (mimap->handle) {/* we do not attempt to reconnect here */
const gchar *name = libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(mimap));
- printf("Disconnecting %s (%u)\n", name, (unsigned)time(NULL));
+ g_debug("Disconnecting %s (%u)", name, (unsigned)time(NULL));
imap_handle_force_disconnect(mimap->handle);
- printf("Disconnected %s (%u)\n", name, (unsigned)time(NULL));
+ g_debug("Disconnected %s (%u)", name, (unsigned)time(NULL));
}
}
@@ -1718,13 +1719,13 @@ libbalsa_mailbox_imap_reconnect(LibBalsaMailboxImap* mimap)
imap_mbox_is_disconnected (mimap->handle)) {
gboolean readonly;
- printf("Reconnecting %s (%u)\n",
- libbalsa_server_get_host(LIBBALSA_MAILBOX_REMOTE_GET_SERVER(mimap)),
- (unsigned)time(NULL));
+ g_debug("Reconnecting %s (%u)",
+ libbalsa_server_get_host(LIBBALSA_MAILBOX_REMOTE_GET_SERVER(mimap)),
+ (unsigned)time(NULL));
if (imap_mbox_handle_reconnect(mimap->handle, &readonly) == IMAP_SUCCESS) {
- printf("Reconnected %s (%u)\n",
- libbalsa_server_get_host(LIBBALSA_MAILBOX_REMOTE_GET_SERVER(mimap)),
- (unsigned)time(NULL));
+ g_debug("Reconnected %s (%u)",
+ libbalsa_server_get_host(LIBBALSA_MAILBOX_REMOTE_GET_SERVER(mimap)),
+ (unsigned)time(NULL));
}
libbalsa_mailbox_set_readonly(LIBBALSA_MAILBOX(mimap), readonly);
}
@@ -1999,7 +2000,7 @@ libbalsa_mailbox_imap_load_envelope(LibBalsaMailboxImap *mimap,
if(!imsg || !imsg->envelope) {/* Connection severed and and restore
* failed - deal with it! */
- fprintf(stderr, "load_envelope failed!\n");
+ g_debug("load_envelope failed!");
return FALSE;
}
@@ -2338,7 +2339,7 @@ print_structure(LibBalsaMessageBody *part, LibBalsaMessageBody* m, int ind)
int j,i=1;
while(part) {
for(j=0; j<ind; j++) putchar(' ');
- printf("%d: %s%s\n", i++, t[part->body_type],
+ g_debug("%d: %s%s", i++, t[part->body_type],
part == m ? " <--" : "");
if(part->parts)
print_structure(part->parts, m, ind+2);
@@ -2357,7 +2358,7 @@ get_section_for(LibBalsaMessage *message, LibBalsaMessageBody *part)
parent = parent->parts;
if (!is_child_of(parent, part, section, TRUE)) {
- g_warning("Internal error, part %p not found in message %p.\n",
+ g_warning("Internal error, part %p not found in message %p.",
part, message);
g_string_free(section, TRUE);
@@ -2374,9 +2375,8 @@ append_str(unsigned seqno, const char *buf, size_t buflen, void *arg)
struct part_data *dt = (struct part_data*)arg;
if(dt->pos + buflen > dt->body->octets) {
- /*
- fprintf(stderr, "IMAP server sends too much data but we just "
- "reallocate the block.\n"); */
+ g_debug("IMAP server sends too much data but we just "
+ "reallocate the block.");
dt->body->octets = dt->pos + buflen;
dt->block = g_realloc(dt->block, dt->body->octets);
}
@@ -2455,7 +2455,7 @@ lbm_imap_get_msg_part_from_cache(LibBalsaMessage * message,
body structures but still try refetching the
message. This can be simulated by randomly
disconnecting from the IMAP server. */
- fprintf(stderr, "Cannot find data for section %s\n", section);
+ g_debug("Cannot find data for section %s", section);
g_strfreev(pair);
return FALSE;
}
@@ -2487,7 +2487,7 @@ lbm_imap_get_msg_part_from_cache(LibBalsaMessage * message,
section, FALSE, ifbo, append_str, &dt));
libbalsa_unlock_mailbox(mailbox);
if(rc != IMR_OK) {
- fprintf(stderr, "Error fetching imap message no %lu section %s\n",
+ g_debug("Error fetching imap message no %ld section %s",
msgno, section);
g_set_error(err,
LIBBALSA_MAILBOX_ERROR, LIBBALSA_MAILBOX_ACCESS_ERROR,
@@ -2681,10 +2681,9 @@ libbalsa_mailbox_imap_duplicate_msgnos(LibBalsaMailbox *mailbox)
}
}
g_hash_table_destroy(dupes);
- printf("total elements: %d\n", res->len);
+ g_debug("total elements: %u", res->len);
for(i=0; i<res->len; i++)
- printf("%u ", GPOINTER_TO_UINT(g_array_index(res, unsigned, i)));
- puts("");
+ g_debug(" %u", GPOINTER_TO_UINT(g_array_index(res, unsigned, i)));
return res;
}
@@ -3465,7 +3464,7 @@ imap_cache_manager_new_from_file(const char *header_cache_path)
return NULL;
}
if(fread(&i, sizeof(i), 1, f) != 1) {
- printf("Could not read cache table size.\n");
+ g_debug("Could not read cache table size.");
fclose(f);
return NULL;
}
@@ -3475,7 +3474,7 @@ imap_cache_manager_new_from_file(const char *header_cache_path)
fread(&icm->uidnext, sizeof(uint32_t), 1, f) != 1 ||
fread(&icm->exists, sizeof(uint32_t), 1, f) != 1) {
imap_cache_manager_free(icm);
- printf("Couldn't read cache - aborting…\n");
+ g_debug("Couldn't read cache - aborting…");
fclose(f);
return NULL;
}
@@ -3535,7 +3534,7 @@ icm_restore_from_cache(ImapMboxHandle *h, struct ImapCacheManager *icm)
exists = imap_mbox_handle_get_exists(h);
uidnext = imap_mbox_handle_get_uidnext(h);
if(icm->uidvalidity != uidvalidity) {
- printf("Different validities old: %u new: %u - cache invalidated\n",
+ g_debug("Different validities old: %u new: %u - cache invalidated",
icm->uidvalidity, uidvalidity);
return;
}
@@ -3549,16 +3548,16 @@ icm_restore_from_cache(ImapMboxHandle *h, struct ImapCacheManager *icm)
sizeof(uint32_t), icm->exists);
ImapSearchKey *k;
unsigned lo = icm->uidmap->len+1, hi = 0;
- /* printf("UIDSYNC:Searching range [1:%u]\n", icm->uidmap->len); */
+ g_debug("UIDSYNC:Searching range [1:%u]", icm->uidmap->len);
for(i=1; i<=icm->uidmap->len; i++)
if(g_array_index(icm->uidmap, uint32_t, i-1)) {lo=i; break; }
for(i=icm->uidmap->len; i>=lo; i--)
if(g_array_index(icm->uidmap, uint32_t, i-1)) {hi=i; break; }
k = imap_search_key_new_range(FALSE, FALSE, lo, hi);
- /* printf("UIDSYNC: Old vs new: exists: %u %u uidnext: %u %u "
- "- syncing uid map for msgno [%u:%u].\n",
- icm->exists, exists, icm->uidnext, uidnext, lo, hi); */
+ g_debug("UIDSYNC: Old vs new: exists: %u %u uidnext: %u %u "
+ "- syncing uid map for msgno [%u:%u].",
+ icm->exists, exists, icm->uidnext, uidnext, lo, hi);
if(k) {
uidmap->len = lo-1;
rc = imap_search_exec(h, TRUE, k, set_uid, uidmap);
@@ -3569,7 +3568,7 @@ icm_restore_from_cache(ImapMboxHandle *h, struct ImapCacheManager *icm)
return;
}
g_array_free(icm->uidmap, TRUE); icm->uidmap = uidmap;
- /* printf("New uidmap has length: %u\n", icm->uidmap->len); */
+ g_debug("New uidmap has length: %u", icm->uidmap->len);
}
/* One way or another, we have a valid uid->seqno map now;
* The mailbox data can be resynced easily. */
diff --git a/libbalsa/mailbox_local.c b/libbalsa/mailbox_local.c
index dd8a27b71..0019a2264 100644
--- a/libbalsa/mailbox_local.c
+++ b/libbalsa/mailbox_local.c
@@ -36,6 +36,11 @@
#include "misc.h"
#include <glib/gi18n.h>
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "mbox-local"
+
typedef struct _LibBalsaMailboxLocalPrivate LibBalsaMailboxLocalPrivate;
struct _LibBalsaMailboxLocalPrivate {
guint sync_id; /* id of the idle mailbox sync job */
@@ -214,13 +219,13 @@ libbalsa_mailbox_local_new(const gchar * path, gboolean create)
else if(magic_type == LIBBALSA_TYPE_MAILBOX_MAILDIR)
return libbalsa_mailbox_maildir_new(path, create);
else if(magic_type == LIBBALSA_TYPE_MAILBOX_IMAP) {
- g_warning("IMAP path given as a path to local mailbox.\n");
+ g_warning("IMAP path given as a path to local mailbox.");
return NULL;
} else { /* mailbox non-existent or unreadable */
if(create)
return libbalsa_mailbox_mbox_new(path, TRUE);
else {
- g_warning("Unknown mailbox type\n");
+ g_warning("Unknown mailbox type");
return NULL;
}
}
@@ -600,9 +605,7 @@ lbm_local_restore_tree(LibBalsaMailboxLocal * local, guint * total)
/* No error, but we return FALSE so the caller can grab all the
* message info needed to rethread from scratch. */
if (libbalsa_mailbox_total_messages(mailbox) > 0)
- libbalsa_information(LIBBALSA_INFORMATION_DEBUG,
- _("Cache file for mailbox %s "
- "will be created"), name);
+ g_debug("Cache file for mailbox %s will be created", name);
g_free(filename);
g_free(name);
return FALSE;
@@ -627,7 +630,7 @@ lbm_local_restore_tree(LibBalsaMailboxLocal * local, guint * total)
/* Total must be > 0 (no file is created for empty tree). */
|| info->value.total == 0
|| info->value.total > libbalsa_mailbox_total_messages(mailbox)) {
- libbalsa_information(LIBBALSA_INFORMATION_DEBUG,
+ libbalsa_information(LIBBALSA_INFORMATION_MESSAGE,
_("Cache file for mailbox %s "
"will be repaired"), name);
g_free(contents);
@@ -644,7 +647,7 @@ lbm_local_restore_tree(LibBalsaMailboxLocal * local, guint * total)
LibBalsaMailboxLocalMessageInfo *msg_info;
if (info->msgno == 0 || info->msgno > *total
|| seen[info->msgno - 1]) {
- libbalsa_information(LIBBALSA_INFORMATION_DEBUG,
+ libbalsa_information(LIBBALSA_INFORMATION_MESSAGE,
_("Cache file for mailbox %s "
"will be repaired"), name);
g_free(seen);
@@ -667,7 +670,7 @@ lbm_local_restore_tree(LibBalsaMailboxLocal * local, guint * total)
parent = parent->parent;
if (parent == NULL) {
/* We got to the root without finding the parent. */
- libbalsa_information(LIBBALSA_INFORMATION_DEBUG,
+ libbalsa_information(LIBBALSA_INFORMATION_MESSAGE,
_("Cache file for mailbox %s "
"will be repaired"), name);
g_free(seen);
@@ -1205,9 +1208,7 @@ libbalsa_mailbox_local_set_threading(LibBalsaMailbox * mailbox,
libbalsa_mailbox_local_get_instance_private(local);
lbm_local_set_threading_info(local);
-#if defined(DEBUG_LOADING_AND_THREADING)
- printf("before load_messages: time=%lu\n", (unsigned long) time(NULL));
-#endif
+ g_debug("before load_messages: time=%lu", (unsigned long) time(NULL));
if (libbalsa_mailbox_get_msg_tree(mailbox) == NULL) { /* first reference */
guint total = 0;
gboolean natural = (thread_type == LB_MAILBOX_THREADING_FLAT
@@ -1239,9 +1240,7 @@ libbalsa_mailbox_local_set_threading(LibBalsaMailbox * mailbox,
libbalsa_mailbox_local_check(mailbox);
}
-#if defined(DEBUG_LOADING_AND_THREADING)
- printf("after load messages: time=%lu\n", (unsigned long) time(NULL));
-#endif
+ g_debug("after load messages: time=%lu", (unsigned long) time(NULL));
if (natural) {
/* No need to thread. */
return;
@@ -1256,9 +1255,7 @@ libbalsa_mailbox_local_set_threading(LibBalsaMailbox * mailbox,
g_idle_add((GSourceFunc) lbml_set_threading_idle_cb, local);
}
-#if defined(DEBUG_LOADING_AND_THREADING)
- printf("after threading time=%lu\n", (unsigned long) time(NULL));
-#endif
+ g_debug("after threading time=%lu", (unsigned long) time(NULL));
lbm_local_queue_save_tree(local);
}
diff --git a/libbalsa/mailbox_maildir.c b/libbalsa/mailbox_maildir.c
index 0ec1828d7..eae00bf07 100644
--- a/libbalsa/mailbox_maildir.c
+++ b/libbalsa/mailbox_maildir.c
@@ -37,6 +37,11 @@
#include "mime-stream-shared.h"
#include <glib/gi18n.h>
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "mbox-maildir"
+
struct message_info {
LibBalsaMailboxLocalMessageInfo local_info;
LibBalsaMessageFlag orig_flags; /* Has only real flags */
@@ -177,7 +182,7 @@ lbm_maildir_check_files(const gchar * path, gboolean create)
if (mkdir(path, S_IRWXU)) {
libbalsa_information(LIBBALSA_INFORMATION_WARNING,
_("Could not create a Maildir directory at %s (%s)"),
- path, strerror(errno));
+ path, g_strerror(errno));
return -1;
}
@@ -185,7 +190,7 @@ lbm_maildir_check_files(const gchar * path, gboolean create)
if (mkdir(tmp, S_IRWXU)) {
libbalsa_information(LIBBALSA_INFORMATION_WARNING,
_("Could not create a Maildir at %s (%s)"),
- path, strerror(errno));
+ path, g_strerror(errno));
rmdir(path);
return -1;
}
@@ -194,7 +199,7 @@ lbm_maildir_check_files(const gchar * path, gboolean create)
if (mkdir(tmp, S_IRWXU)) {
libbalsa_information(LIBBALSA_INFORMATION_WARNING,
_("Could not create a Maildir at %s (%s)"),
- path, strerror(errno));
+ path, g_strerror(errno));
snprintf(tmp, sizeof(tmp), "%s/cur", path);
rmdir(tmp);
rmdir(path);
@@ -205,7 +210,7 @@ lbm_maildir_check_files(const gchar * path, gboolean create)
if (mkdir(tmp, S_IRWXU)) {
libbalsa_information(LIBBALSA_INFORMATION_WARNING,
_("Could not create a Maildir at %s (%s)"),
- path, strerror(errno));
+ path, g_strerror(errno));
snprintf(tmp, sizeof(tmp), "%s/cur", path);
rmdir(tmp);
snprintf(tmp, sizeof(tmp), "%s/new", path);
@@ -306,18 +311,18 @@ lbm_maildir_remove_files(LibBalsaMailboxLocal *mailbox)
g_return_if_fail(LIBBALSA_IS_MAILBOX_MAILDIR(mailbox));
path = libbalsa_mailbox_local_get_path((LibBalsaMailboxLocal *) mailbox);
- g_print("DELETE MAILDIR\n");
+ g_debug("DELETE MAILDIR");
if (!libbalsa_delete_directory_contents(path)) {
libbalsa_information(LIBBALSA_INFORMATION_ERROR,
_("Could not remove contents of %s:\n%s"),
- path, strerror(errno));
+ path, g_strerror(errno));
return;
}
if ( rmdir(path) == -1 ) {
libbalsa_information(LIBBALSA_INFORMATION_ERROR,
_("Could not remove %s:\n%s"),
- path, strerror(errno));
+ path, g_strerror(errno));
}
LIBBALSA_MAILBOX_LOCAL_CLASS(libbalsa_mailbox_maildir_parent_class)->remove_files(mailbox);
}
@@ -404,11 +409,8 @@ lbm_maildir_parse(LibBalsaMailboxMaildir *mdir,
g_free(msg_info->filename);
msg_info->filename = g_strdup(filename);
if (FLAGS_REALLY_DIFFER(msg_info->orig_flags, flags)) {
-#undef DEBUG /* #define DEBUG TRUE */
-#ifdef DEBUG
- g_message("Message flags for “%s” changed\n",
+ g_debug("Message flags for “%s” changed",
msg_info->key);
-#endif
msg_info->orig_flags = flags;
}
} else {
@@ -480,11 +482,9 @@ libbalsa_mailbox_maildir_open(LibBalsaMailbox * mailbox, GError **err)
libbalsa_mailbox_clear_unread_messages(mailbox);
lbm_maildir_parse_subdirs(mdir);
-#ifdef DEBUG
- g_print(_("%s: Opening %s Refcount: %d\n"),
- "LibBalsaMailboxMaildir", libbalsa_mailbox_get_name(mailbox),
+ g_debug("%s: Opening %s Refcount: %d",
+ __func__, libbalsa_mailbox_get_name(mailbox),
libbalsa_mailbox_get_open_ref(mailbox));
-#endif
return TRUE;
}
@@ -689,9 +689,7 @@ maildir_sync_add(struct message_info *msg_info, const gchar * path)
g_build_filename(path, msg_info->subdir, msg_info->filename, NULL);
if (strcmp(orig, new)) {
while (g_file_test(new, G_FILE_TEST_EXISTS)) {
-#ifdef DEBUG
- g_message("File “%s” exists, requesting new key.\n", new);
-#endif
+ g_debug("File “%s” exists, requesting new key.", new);
g_free(msg_info->key);
msg_info->key = lbm_mdir_get_key();
g_free(filename);
@@ -704,10 +702,8 @@ maildir_sync_add(struct message_info *msg_info, const gchar * path)
if (rename(orig, new) >= 0) /* FIXME: change to safe_rename??? */
msg_info->subdir = subdir;
else {
-#ifdef DEBUG
- g_message("Rename “%s” “%s”: %s\n", orig, new,
+ g_debug("Rename “%s” “%s”: %s", orig, new,
g_strerror(errno));
-#endif
retval = FALSE;
}
}
diff --git a/libbalsa/mailbox_mbox.c b/libbalsa/mailbox_mbox.c
index f221ddb76..f663d5f17 100644
--- a/libbalsa/mailbox_mbox.c
+++ b/libbalsa/mailbox_mbox.c
@@ -44,7 +44,11 @@
#include <glib/gi18n.h>
-/* #define DEBUG_SEEK TRUE */
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "mbox-mbox"
+
struct message_info {
LibBalsaMailboxLocalMessageInfo local_info;
@@ -173,9 +177,9 @@ lbm_mbox_check_files(const gchar * path, gboolean create)
gint fd;
if ((fd = creat(path, S_IRUSR | S_IWUSR)) == -1) {
- g_warning("An error:\n%s\n occurred while trying to "
- "create the mailbox “%s”\n",
- strerror(errno), path);
+ g_warning("error “%s” occurred while trying to "
+ "create the mailbox “%s”",
+ g_strerror(errno), path);
return -1;
} else
close(fd);
@@ -218,10 +222,8 @@ lbm_mbox_stream_seek_to_message(GMimeStream * stream, off_t offset)
if (nread == sizeof buffer)
--nread;
buffer[nread] = 0;
-#if DEBUG_SEEK
- g_print("%s at %ld failed: read %ld chars, saw “%s”\n", __func__,
+ g_debug("%s at %ld failed: read %ld chars, saw “%s”", __func__,
(long) offset, (long) nread, buffer);
-#endif
}
g_mime_stream_seek(stream, offset, GMIME_STREAM_SEEK_SET);
@@ -274,9 +276,9 @@ libbalsa_mailbox_mbox_remove_files(LibBalsaMailboxLocal *mailbox)
{
if ( unlink(libbalsa_mailbox_local_get_path(mailbox)) == -1 )
libbalsa_information(LIBBALSA_INFORMATION_ERROR,
- _("Could not remove %s:\n%s"),
+ _("Could not remove %s: %s"),
libbalsa_mailbox_local_get_path(mailbox),
- strerror(errno));
+ g_strerror(errno));
LIBBALSA_MAILBOX_LOCAL_CLASS(libbalsa_mailbox_mbox_parent_class)->remove_files(mailbox);
}
@@ -393,7 +395,7 @@ lbm_mbox_save(LibBalsaMailboxMbox * mbox)
libbalsa_information(LIBBALSA_INFORMATION_WARNING,
_("Failed to create temporary file "
"“%s”: %s"), template,
- strerror(errno));
+ g_strerror(errno));
g_free(template);
g_free(filename);
g_array_free(messages_info, TRUE);
@@ -405,21 +407,19 @@ lbm_mbox_save(LibBalsaMailboxMbox * mbox)
libbalsa_information(LIBBALSA_INFORMATION_WARNING,
_("Failed to save cache file “%s”: %s. "
"New version saved as “%s”"),
- filename, strerror(errno), template);
+ filename, g_strerror(errno), template);
g_free(template);
#endif /* !defined(__APPLE__) */
g_array_free(messages_info, TRUE);
} else if (unlink(filename) < 0)
libbalsa_information(LIBBALSA_INFORMATION_WARNING,
_("Could not unlink file %s: %s"),
- filename, strerror(errno));
+ filename, g_strerror(errno));
g_free(filename);
-#ifdef DEBUG
- g_print("%s: %s saved %d messages\n", __func__,
- LIBBALSA_MAILBOX(mbox)->name,
+ g_debug("%s: %s saved %d messages", __func__,
+ libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(mbox)),
mbox->msgno_2_msg_info->len);
-#endif
}
static LibBalsaMessage *lbm_mbox_message_new(GMimeMessage * mime_message,
@@ -551,11 +551,9 @@ lbm_mbox_restore(LibBalsaMailboxMbox * mbox)
return;
}
-#ifdef DEBUG
- g_print("%s: %s file has %zd messages\n", __func__,
- LIBBALSA_MAILBOX(mbox)->name,
+ g_debug("%s: %s file has %zd messages", __func__,
+ libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(mbox)),
length / sizeof(struct message_info));
-#endif
msg_info = (struct message_info *) contents;
@@ -587,11 +585,9 @@ lbm_mbox_restore(LibBalsaMailboxMbox * mbox)
g_memdup(msg_info, sizeof *msg_info));
} while (++msg_info < (struct message_info *) (contents + length));
-#ifdef DEBUG
- g_print("%s: %s restored %zd messages\n", __func__,
- LIBBALSA_MAILBOX(mbox)->name,
+ g_debug("%s: %s restored %zd messages", __func__,
+ libbalsa_mailbox_get_name(LIBBALSA_MAILBOX(mbox)),
msg_info - (struct message_info *) contents);
-#endif
mbox_stream = mbox->gmime_stream;
libbalsa_mime_stream_shared_lock(mbox_stream);
@@ -686,10 +682,8 @@ libbalsa_mailbox_mbox_open(LibBalsaMailbox * mailbox, GError **err)
}
mbox->size = st.st_size;
-#if DEBUG_SEEK
- g_print("%s %s set size from stat %d\n", __func__, mailbox->name,
+ g_debug("%s %s set size from stat %ld", __func__, libbalsa_mailbox_get_name(mailbox),
mbox->size);
-#endif
libbalsa_mailbox_set_mtime(mailbox, st.st_mtime);
mbox->gmime_stream = gmime_stream;
@@ -706,10 +700,9 @@ libbalsa_mailbox_mbox_open(LibBalsaMailbox * mailbox, GError **err)
mbox_unlock(mailbox, gmime_stream);
libbalsa_mime_stream_shared_unlock(gmime_stream);
-#ifdef DEBUG
- g_print(_("%s: Opening %s Refcount: %d\n"),
- "LibBalsaMailboxMbox", mailbox->name, mailbox->open_ref);
-#endif
+ g_debug("%s: Opening %s Refcount: %u",
+ __func__, libbalsa_mailbox_get_name(mailbox),
+ libbalsa_mailbox_get_open_ref(mailbox));
return TRUE;
}
@@ -958,10 +951,8 @@ libbalsa_mailbox_mbox_check(LibBalsaMailbox * mailbox)
/* First check--just cache the mtime and size. */
libbalsa_mailbox_set_mtime(mailbox, st.st_mtime);
mbox->size = st.st_size;
-#if DEBUG_SEEK
- g_print("%s %s set size from stat %d\n", __func__, mailbox->name,
+ g_debug("%s %s set size from stat %ld", __func__, libbalsa_mailbox_get_name(mailbox),
mbox->size);
-#endif
return;
}
if (st.st_mtime == mtime && st.st_size == mbox->size)
@@ -975,10 +966,8 @@ libbalsa_mailbox_mbox_check(LibBalsaMailbox * mailbox)
path));
/* Cache the file size, so we don't check the next time. */
mbox->size = st.st_size;
-#if DEBUG_SEEK
- g_print("%s %s set size from stat %d\n", __func__, mailbox->name,
+ g_debug("%s %s set size from stat %ld", __func__, libbalsa_mailbox_get_name(mailbox),
mbox->size);
-#endif
return;
}
@@ -1033,9 +1022,7 @@ libbalsa_mailbox_mbox_check(LibBalsaMailbox * mailbox)
* the first new message--start parsing here. */
break;
-#if DEBUG_SEEK
- g_print(" backing up over message %d\n", msgno);
-#endif
+ g_debug(" backing up over message %d", msgno);
/* Back up over this message and try again. */
msg_info = message_info_from_msgno(mbox, msgno);
start = msg_info->start;
@@ -1060,16 +1047,12 @@ libbalsa_mailbox_mbox_check(LibBalsaMailbox * mailbox)
}
if(msgno == 0)
g_mime_stream_seek(mbox_stream, 0, GMIME_STREAM_SEEK_SET);
-#ifdef DEBUG
- g_print("%s: start parsing at msgno %d of %d\n", __func__, msgno,
+ g_debug("%s: start parsing at msgno %d of %d", __func__, msgno,
mbox->msgno_2_msg_info->len);
-#endif
parse_mailbox(mbox);
mbox->size = g_mime_stream_tell(mbox_stream);
-#if DEBUG_SEEK
- g_print("%s %s set size from tell %d\n", __func__, mailbox->name,
+ g_debug("%s %s set size from tell %ld", __func__, libbalsa_mailbox_get_name(mailbox),
mbox->size);
-#endif
libbalsa_mime_stream_shared_unlock(mbox_stream);
mbox_unlock(mailbox, mbox_stream);
@@ -1458,7 +1441,7 @@ libbalsa_mailbox_mbox_sync(LibBalsaMailbox * mailbox, gboolean expunge)
utime(path, &utimebuf);
}
if (g_mime_stream_flush(mbox_stream) < 0)
- g_warning("can't flush mailbox stream\n");
+ g_warning("can't flush mailbox stream");
if (fstat(GMIME_STREAM_FS(mbox_stream)->fd, &st))
g_warning("can't stat “%s”", path);
else
@@ -1546,7 +1529,7 @@ libbalsa_mailbox_mbox_sync(LibBalsaMailbox * mailbox, gboolean expunge)
if (i < messages) {
/* We broke on an error. */
- g_warning("error making temporary copy\n");
+ g_warning("error making temporary copy");
g_object_unref(temp_stream);
unlink(tempfile);
g_free(tempfile);
@@ -1557,7 +1540,7 @@ libbalsa_mailbox_mbox_sync(LibBalsaMailbox * mailbox, gboolean expunge)
g_mime_stream_set_bounds(mbox_stream, 0, -1);
if (g_mime_stream_flush(temp_stream) == -1)
{
- g_warning("can't flush temporary copy\n");
+ g_warning("can't flush temporary copy");
g_object_unref(temp_stream);
unlink(tempfile);
g_free(tempfile);
@@ -1568,15 +1551,13 @@ libbalsa_mailbox_mbox_sync(LibBalsaMailbox * mailbox, gboolean expunge)
save_failed = TRUE;
libbalsa_mime_stream_shared_lock(mbox_stream);
if (g_mime_stream_reset(temp_stream) == -1) {
- g_warning("mbox_sync: can't rewind temporary copy.\n");
+ g_warning("mbox_sync: can't rewind temporary copy.");
} else if (!lbm_mbox_stream_seek_to_message(mbox_stream, offset))
- g_warning("mbox_sync: message not in expected position.\n");
+ g_warning("mbox_sync: message not in expected position.");
else if (g_mime_stream_write_to_stream(temp_stream, mbox_stream) != -1) {
mbox->size = g_mime_stream_tell(mbox_stream);
-#if DEBUG_SEEK
- g_print("%s %s set size from tell %d\n", __func__, mailbox->name,
+ g_debug("%s %s set size from tell %ld", __func__, libbalsa_mailbox_get_name(mailbox),
mbox->size);
-#endif
if (ftruncate(GMIME_STREAM_FS(mbox_stream)->fd, mbox->size) == 0)
save_failed = FALSE;
}
diff --git a/libbalsa/mailbox_mh.c b/libbalsa/mailbox_mh.c
index 11db73860..5c12845c1 100644
--- a/libbalsa/mailbox_mh.c
+++ b/libbalsa/mailbox_mh.c
@@ -40,6 +40,11 @@
#include "mime-stream-shared.h"
#include <glib/gi18n.h>
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "mbox-mh"
+
struct message_info {
LibBalsaMailboxLocalMessageInfo local_info;
LibBalsaMessageFlag orig_flags; /* Has only real flags */
@@ -158,7 +163,7 @@ lbm_mh_check_files(const gchar * path, gboolean create)
if (mkdir(path, S_IRWXU)) {
libbalsa_information(LIBBALSA_INFORMATION_WARNING,
_("Could not create MH directory at %s (%s)"),
- path, strerror(errno));
+ path, g_strerror(errno));
return -1;
}
@@ -170,7 +175,7 @@ lbm_mh_check_files(const gchar * path, gboolean create)
libbalsa_information
(LIBBALSA_INFORMATION_WARNING,
_("Could not create MH structure at %s (%s)"),
- path, strerror(errno));
+ path, g_strerror(errno));
rmdir(path);
return -1;
} else
@@ -264,14 +269,14 @@ lbm_mh_remove_files(LibBalsaMailboxLocal *mailbox)
if (!libbalsa_delete_directory_contents(path)) {
libbalsa_information(LIBBALSA_INFORMATION_ERROR,
- _("Could not remove contents of %s:\n%s"),
- path, strerror(errno));
+ _("Could not remove contents of %s: %s"),
+ path, g_strerror(errno));
return;
}
if ( rmdir(path) == -1 ) {
libbalsa_information(LIBBALSA_INFORMATION_ERROR,
- _("Could not remove %s:\n%s"),
- path, strerror(errno));
+ _("Could not remove %s: %s"),
+ path, g_strerror(errno));
}
LIBBALSA_MAILBOX_LOCAL_CLASS(libbalsa_mailbox_mh_parent_class)->remove_files(mailbox);
}
@@ -377,7 +382,7 @@ lbm_mh_set_flag(LibBalsaMailboxMh * mh, guint fileno, LibBalsaMessageFlag flag)
msg_info = g_hash_table_lookup(mh->messages_info, GINT_TO_POINTER(fileno));
if (!msg_info) {
- g_print("MH sequence info for nonexistent message %d\n", fileno);
+ g_debug("MH sequence info for nonexistent message %d", fileno);
return;
}
@@ -515,10 +520,8 @@ libbalsa_mailbox_mh_open(LibBalsaMailbox * mailbox, GError **err)
libbalsa_mailbox_clear_unread_messages(mailbox);
lbm_mh_parse_both(mh);
-#ifdef DEBUG
- g_print(_("%s: Opening %s Refcount: %d\n"),
- "LibBalsaMailboxMh", mailbox->name, mailbox->open_ref);
-#endif
+ g_debug("%s: Opening %s Refcount: %u",
+ __func__, libbalsa_mailbox_get_name(mailbox), libbalsa_mailbox_get_open_ref(mailbox));
return TRUE;
}
@@ -884,9 +887,7 @@ libbalsa_mailbox_mh_sync(LibBalsaMailbox * mailbox, gboolean expunge)
g_object_unref(recent.line);
if (sequences_fd >= 0)
libbalsa_unlock_file(sequences_filename, sequences_fd, 1);
-#ifdef DEBUG
- g_print("MH sync “%s”: cannot open temp file.\n", path);
-#endif
+ g_warning("MH sync “%s”: cannot open temp file.", path);
return retval;
}
temp_stream = g_mime_stream_fs_new(fd);
@@ -932,9 +933,7 @@ libbalsa_mailbox_mh_sync(LibBalsaMailbox * mailbox, gboolean expunge)
g_object_unref(recent.line);
if (sequences_fd >= 0)
libbalsa_unlock_file(sequences_filename, sequences_fd, 1);
-#ifdef DEBUG
- g_print("MH sync “%s”: error finishing sequences line.\n", path);
-#endif
+ g_warning("MH sync “%s”: error finishing sequences line.", path);
return retval;
}
@@ -946,10 +945,8 @@ libbalsa_mailbox_mh_sync(LibBalsaMailbox * mailbox, gboolean expunge)
/* rename tempfile to '.mh_sequences' */
retval = (libbalsa_safe_rename(name_used, sequences_filename) != -1);
-#ifdef DEBUG
if (!retval)
- g_print("MH sync “%s”: error renaming sequences file.\n", path);
-#endif
+ g_warning("MH sync “%s”: error renaming sequences file.", path);
if (!retval)
unlink (name_used);
diff --git a/libbalsa/mailbox_pop3.c b/libbalsa/mailbox_pop3.c
index 2ca77d5be..97f347fa0 100644
--- a/libbalsa/mailbox_pop3.c
+++ b/libbalsa/mailbox_pop3.c
@@ -37,6 +37,11 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "mbox-pop3"
+
enum {
LAST_SIGNAL
};
@@ -136,7 +141,7 @@ libbalsa_mailbox_pop3_open(LibBalsaMailbox * mailbox, GError **err)
{
/* FIXME: it should never be called. */
- g_print("Opened a POP3 mailbox!\n");
+ g_debug("Opened a POP3 mailbox!");
return TRUE;
}
diff --git a/libbalsa/message.c b/libbalsa/message.c
index f48ed2c85..ca444db8f 100644
--- a/libbalsa/message.c
+++ b/libbalsa/message.c
@@ -817,11 +817,9 @@ has_attached_part(LibBalsaMessageBody *body)
LibBalsaMessageBody *lbbody;
/* the condition matches the one used in add_multipart_mixed() */
for (lbbody = body; lbbody; lbbody = lbbody->next) {
- /* printf("part %s has disposition %s\n",
- lbbody->content_type, lbbody->content_dsp); */
+ g_debug("part %s has disposition %s", lbbody->content_type, lbbody->content_dsp);
if (!libbalsa_message_body_is_multipart(lbbody) &&
!libbalsa_message_body_is_inline(lbbody)) {
- /* puts("Attachment found!"); */
return TRUE;
}
@@ -1254,10 +1252,8 @@ lbmsg_set_header(LibBalsaMessage *message,
libbalsa_utf8_sanitize(&tmp, TRUE, NULL);
val = g_mime_utils_header_encode_text(NULL, tmp, NULL);
g_free(tmp);
-#ifdef DEBUG
- g_print("%s: non-ascii “%s” header “%s” encoded as “%s”\n",
+ g_debug("%s: non-ascii “%s” header “%s” encoded as “%s”",
__func__, name, value, val);
-#endif /* DEBUG */
value = val;
}
diff --git a/libbalsa/misc.c b/libbalsa/misc.c
index ffe31d7f9..3474a2169 100644
--- a/libbalsa/misc.c
+++ b/libbalsa/misc.c
@@ -328,7 +328,7 @@ libbalsa_utf8_sanitize(gchar **text, gboolean fallback,
*target = use_enc;
return FALSE;
}
- g_message("conversion %s -> utf8 failed: %s", use_enc,
+ g_debug("conversion %s -> utf8 failed: %s", use_enc,
conv_error->message);
g_error_free(conv_error);
}
@@ -724,11 +724,11 @@ libbalsa_lock_file (const char *path, int fd, int excl, int dot, int timeout)
while (fcntl (fd, F_SETLK, &lck) == -1)
{
struct stat sb;
- g_print("%s(): fcntl errno %d.\n", __FUNCTION__, errno);
+ g_debug("%s(): fcntl errno %d.", __func__, errno);
if (errno != EAGAIN && errno != EACCES)
{
libbalsa_information
- (LIBBALSA_INFORMATION_DEBUG, "fcntl failed, errno=%d.", errno);
+ (LIBBALSA_INFORMATION_MESSAGE, _("fcntl failed: %s."), g_strerror(errno));
return -1;
}
@@ -764,7 +764,7 @@ while (flock (fd, (excl ? LOCK_EX : LOCK_SH) | LOCK_NB) == -1)
struct stat sb;
if (errno != EWOULDBLOCK)
{
- libbalsa_message ("flock: %s", strerror(errno));
+ libbalsa_information(LIBBALSA_INFORMATION_WARNING, "flock: %s", g_strerror(errno));
r = -1;
break;
}
@@ -779,14 +779,16 @@ while (flock (fd, (excl ? LOCK_EX : LOCK_SH) | LOCK_NB) == -1)
if (prev_sb.st_size == sb.st_size && ++count >= (timeout?MAXLOCKATTEMPT:0))
{
if (timeout)
- libbalsa_message (_("Timeout exceeded while attempting flock lock!"));
+ libbalsa_information(LIBBALSA_INFORMATION_WARNING,
+ _("Timeout exceeded while attempting flock lock!"));
r = -1;
break;
}
prev_sb = sb;
- libbalsa_message (_("Waiting for flock attempt… %d"), ++attempt);
+ libbalsa_information(LIBBALSA_INFORMATION_MESSAGE,
+ _("Waiting for flock attempt… %d"), ++attempt);
sleep (1);
}
#endif /* USE_FLOCK */
diff --git a/libbalsa/send.c b/libbalsa/send.c
index c7faa3bfd..18b72c4da 100644
--- a/libbalsa/send.c
+++ b/libbalsa/send.c
@@ -49,6 +49,11 @@
#include <glib/gi18n.h>
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "send"
+
typedef struct _MessageQueueItem MessageQueueItem;
typedef struct _SendMessageInfo SendMessageInfo;
@@ -296,7 +301,7 @@ add_mime_body_plain(LibBalsaMessageBody *body,
gchar *type, *subtype;
/* FIXME: test sending with different mime types */
- g_message("path active");
+ g_debug("path active");
type = g_strdup (body->content_type);
if ((subtype = strchr (type, '/')) != NULL) {
*subtype++ = 0;
@@ -401,9 +406,9 @@ static void
dump_queue(const char *msg)
{
MessageQueueItem *mqi = message_queue;
- printf("dumping message queue at %s:\n", msg);
+ g_debug("dumping message queue at %s:", msg);
while (mqi) {
- printf("item: %p\n", mqi);
+ g_debug("item: %p", mqi);
mqi = mqi->next_message;
}
}
@@ -907,7 +912,7 @@ libbalsa_process_queue(LibBalsaMailbox *outbox,
}
} else {
update_send_timer(TRUE);
- g_message("%s: no messages pending", __func__);
+ g_debug("%s: no messages pending", __func__);
}
libbalsa_mailbox_close(outbox, FALSE);
@@ -1073,7 +1078,7 @@ balsa_send_message_real(SendMessageInfo *info)
if (mailbox != NULL) {
libbalsa_message_change_flags(mqi->orig, 0, LIBBALSA_MESSAGE_FLAG_FLAGGED);
} else {
- g_message("mqi: %p mqi->orig: %p mailbox: %p\n",
+ g_debug("mqi: %p mqi->orig: %p mailbox: %p",
mqi, mqi->orig, mailbox);
}
@@ -1525,9 +1530,7 @@ libbalsa_message_create_mime_message(LibBalsaMessage *message,
gchar **pair = list->data;
g_strchug(pair[1]);
g_mime_object_append_header(GMIME_OBJECT(mime_message), pair[0], pair[1], NULL);
-#if DEBUG_USER_HEADERS
- printf("adding header '%s:%s'\n", pair[0], pair[1]);
-#endif
+ g_debug("adding header '%s:%s'", pair[0], pair[1]);
}
tmp = g_strdup_printf("Balsa %s", VERSION);
diff --git a/src/ab-main.c b/src/ab-main.c
index bfb1f5db2..547df66e5 100644
--- a/src/ab-main.c
+++ b/src/ab-main.c
@@ -182,7 +182,7 @@ bab_set_address_book(LibBalsaAddressBook * ab,
libbalsa_address_book_load(ab, filter,
(LibBalsaAddressBookLoadFunc)
bab_load_cb, model)) != LBABERR_OK) {
- printf("error loading address book from %s: %d\n", libbalsa_address_book_get_name(ab),
+ g_warning("error loading address book from %s: %d", libbalsa_address_book_get_name(ab),
ab_err);
}
@@ -586,7 +586,7 @@ get_main_menu(GtkApplication * application)
contacts_app.file_menu =
G_MENU(gtk_builder_get_object(builder, "file-menu"));
} else {
- g_print("%s error: %s\n", __func__, err->message);
+ g_critical("%s error: %s", __func__, err->message);
g_error_free(err);
}
g_object_unref(builder);
@@ -658,7 +658,7 @@ list_row_activated_cb(GtkTreeView *tree, gpointer data)
address = LIBBALSA_ADDRESS(g_value_get_object(&gv));
if (address) {
ab_set_edit_widget(address, TRUE);
- printf("Switch page..\n");
+ g_debug("Switch page");
gtk_notebook_set_current_page(GTK_NOTEBOOK(contacts_app.notebook), 1);
} else
ab_clear_edit_widget();
@@ -694,9 +694,9 @@ addrlist_drag_get_cb(GtkWidget* widget, GdkDragContext* drag_context,
sizeof(LibBalsaAddress*));
break;
case LIBBALSA_ADDRESS_TRG_STRING:
- g_print("Text/plain cannot be sent.\n");
+ g_warning("Text/plain cannot be sent.");
break;
- default: g_print("Do not know what to do!\n");
+ default: g_debug("Do not know what to do!");
}
}
@@ -1103,11 +1103,14 @@ main(int argc, char *argv[])
LibBalsaAddressBook *ab;
GtkWidget *ab_window;
GList *l;
+ GError *error = NULL;
application =
gtk_application_new("org.desktop.BalsaAb", G_APPLICATION_FLAGS_NONE);
- if (!g_application_register(G_APPLICATION(application), NULL, NULL))
- g_message("Could not register address book editor");
+ if (!g_application_register(G_APPLICATION(application), NULL, &error)) {
+ g_warning("Could not register address book editor: %s", error->message);
+ g_error_free(error);
+ }
if (g_application_get_is_remote(G_APPLICATION(application))) {
g_object_unref(application);
return 1;
diff --git a/src/balsa-app.c b/src/balsa-app.c
index 873001389..f50e747e3 100644
--- a/src/balsa-app.c
+++ b/src/balsa-app.c
@@ -318,7 +318,6 @@ balsa_app_init(void)
balsa_app.check_mail_auto = TRUE;
balsa_app.check_mail_timer = 10;
- balsa_app.debug = FALSE;
balsa_app.previewpane = TRUE;
balsa_app.pgdownmod = FALSE;
balsa_app.pgdown_percent = 50;
@@ -462,7 +461,7 @@ balsa_app_destroy(void)
balsa_app.fcc_mru = NULL;
- if(balsa_app.debug) g_print("balsa_app: Finished cleaning up.\n");
+ g_debug("balsa_app: Finished cleaning up.");
}
static gboolean
@@ -470,8 +469,7 @@ check_new_messages_auto_cb(gpointer data)
{
check_new_messages_real(balsa_app.main_window, TRUE);
- if (balsa_app.debug)
- fprintf(stderr, "Auto-checked for new messages…\n");
+ g_debug("Auto-checked for new messages…");
/* preserver timer */
return TRUE;
@@ -520,9 +518,7 @@ open_mailbox_by_url(const gchar * url, gboolean hidden)
LibBalsaMailbox *mailbox;
mailbox = balsa_find_mailbox_by_url(url);
- if (balsa_app.debug)
- fprintf(stderr, "balsa_open_mailbox_list: opening %s => %p..\n",
- url, mailbox);
+ g_debug("balsa_open_mailbox_list: opening %s => %p.", url, mailbox);
if (mailbox) {
if (hidden)
balsa_mblist_open_mailbox_hidden(mailbox);
@@ -852,7 +848,7 @@ ba_remove_children_mailbox_nodes(GtkTreeModel * model, GtkTreeIter * parent,
valid =
gtk_tree_store_remove(balsa_app.mblist_tree_store, &iter);
} else {
- printf("sparing %s %s\n",
+ g_debug("sparing %s %s",
mailbox != NULL ? "mailbox" : "folder ",
mailbox != NULL ?
libbalsa_mailbox_get_name(mailbox) :
@@ -870,14 +866,11 @@ balsa_remove_children_mailbox_nodes(BalsaMailboxNode * mbnode)
GtkTreeIter parent;
GtkTreeIter *iter = NULL;
GSList *specials = NULL, *l;
+ const gchar *name;
- if (balsa_app.debug) {
- const gchar *name;
-
- printf("Destroying children of %p %s\n", mbnode,
+ g_debug("Destroying children of %p %s", mbnode,
(mbnode != NULL &&
(name = balsa_mailbox_node_get_name(mbnode)) != NULL) ? name : "");
- }
if (mbnode && balsa_find_iter_by_data(&parent, mbnode))
iter = &parent;
diff --git a/src/balsa-app.h b/src/balsa-app.h
index c37c752a1..49a16bed4 100644
--- a/src/balsa-app.h
+++ b/src/balsa-app.h
@@ -255,7 +255,6 @@ extern struct BalsaApplication {
gboolean empty_trash_on_exit;
gboolean previewpane;
- gboolean debug;
/* Source viewer */
gboolean source_escape_specials;
diff --git a/src/balsa-icons.c b/src/balsa-icons.c
index fb064db01..084f3898f 100644
--- a/src/balsa-icons.c
+++ b/src/balsa-icons.c
@@ -28,18 +28,11 @@
#include "mailbox.h"
#include "address-view.h"
-/* comment out the next line to suppress info about loading images */
-#if 0
-#define BICONS_VERBOSE
-#endif
-#ifdef BICONS_VERBOSE
-# define BICONS_LOG(...) g_message(__VA_ARGS__)
-# define BICONS_ERR(...) g_warning(__VA_ARGS__)
-#else
-# define BICONS_LOG(...)
-# define BICONS_ERR(...)
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
#endif
+#define G_LOG_DOMAIN "icons"
#define BALSA_PIXMAP_SIZES 2
@@ -69,7 +62,7 @@ load_balsa_pixmap(GtkIconTheme *icon_theme, const balsa_pixmap_t *bpixmap)
{ "folder-drag-accept", "document-open"},
{ NULL, NULL } };
- BICONS_LOG("loading icon %s (stock id %s)", bpixmap->name,
+ g_debug("loading icon %s (stock id %s)", bpixmap->name,
bpixmap->stock_id);
/* check if the icon theme knows the icon and try to fall back to an
@@ -79,22 +72,22 @@ load_balsa_pixmap(GtkIconTheme *icon_theme, const balsa_pixmap_t *bpixmap)
while (fb->def_id && g_strcmp0(fb->def_id, bpixmap->stock_id) != 0)
fb++;
if (!fb->def_id) {
- BICONS_LOG("No GTK or custom icon for %s\n", bpixmap);
+ g_debug("No GTK or custom icon for %s", bpixmap->stock_id);
return;
}
if (fb->def_id) {
use_id = fb->fb_id;
- BICONS_LOG("\t(%s not found, fall back to %s)",
+ g_debug("\t(%s not found, fall back to %s)",
bpixmap->stock_id, use_id);
} else {
- BICONS_ERR("icon %s unknown, no fallback", bpixmap->stock_id);
+ g_debug("icon %s unknown, no fallback", bpixmap->stock_id);
use_id = "image-missing";
}
} else {
use_id = bpixmap->stock_id;
}
- BICONS_LOG("\tuse_id %s", use_id);
+ g_debug("\tuse_id %s", use_id);
g_hash_table_insert(balsa_icon_table, g_strdup(bpixmap->name),
g_strdup(use_id));
}
@@ -233,7 +226,7 @@ balsa_register_pixbufs(GtkWidget * widget)
gtk_icon_theme_load_icon(icon_theme, use_id, width,
GTK_ICON_LOOKUP_USE_BUILTIN, &err);
if (err) {
- g_print("%s %s size %d err %s\n", __func__, use_id,
+ g_warning("%s %s size %d err %s", __func__, use_id,
width, err->message);
g_clear_error(&err);
} else {
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 234a4e8fe..2dc11c168 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -1941,7 +1941,7 @@ bndx_do_popup(BalsaIndex * index, const GdkEvent *event)
guint i;
gboolean readonly;
- BALSA_DEBUG();
+ g_debug("%s:%s", __FILE__, __func__);
mailbox = balsa_mailbox_node_get_mailbox(index->mailbox_node);
for (i = 0; i < selected->len; i++) {
@@ -2331,10 +2331,10 @@ pipe_in_watch(GIOChannel *channel, GIOCondition condition, gpointer data)
if ((condition & (G_IO_HUP | G_IO_ERR)) != 0) {
if ((condition & G_IO_HUP) != 0) {
- fprintf(stderr, "pipe_in_watch: broken pipe. Aborts writing.\n");
+ g_warning("%s: broken pipe. Aborts writing.", __func__);
}
if ((condition & G_IO_ERR) != 0) {
- fprintf(stderr, "pipe_in_watch encountered error. Aborts writing.\n");
+ g_warning("%s: encountered error. Aborts writing.", __func__);
}
pipe_data_destroy(pipe);
return FALSE;
@@ -2360,12 +2360,12 @@ pipe_in_watch(GIOChannel *channel, GIOCondition condition, gpointer data)
pipe->chars_written += chars_written;
break;
case G_IO_STATUS_EOF:
- printf("pipe_in::write_chars received premature EOF %s\n",
+ g_warning("%s::write_chars received premature EOF %s", __func__,
error ? error->message : "unknown");
pipe_data_destroy(pipe);
return FALSE;
case G_IO_STATUS_AGAIN:
- printf("pipe_in::write_chars again?\n");
+ g_debug("pipe_in::write_chars again?");
break;
}
}
@@ -2396,7 +2396,7 @@ pipe_out_watch(GIOChannel *channel, GIOCondition condition, gpointer data)
switch(status) {
case G_IO_STATUS_ERROR:
pipe_data_destroy(pipe);
- fprintf(stderr, "Reading characters from pipe failed: %s\n",
+ g_warning("Reading characters from pipe failed: %s",
error ? error->message : "unknown");
g_clear_error(&error);
return FALSE;
@@ -2407,7 +2407,7 @@ pipe_out_watch(GIOChannel *channel, GIOCondition condition, gpointer data)
/* if(fwrite(buf, 1, bytes_read, stdout) != bytes_read); */
break;
case G_IO_STATUS_EOF:
- printf("pipe_out got EOF\n");
+ g_debug("pipe_out got EOF");
pipe_data_destroy(pipe);
g_clear_error(&error);
return FALSE;
@@ -2425,8 +2425,7 @@ pipe_out_watch(GIOChannel *channel, GIOCondition condition, gpointer data)
}
if ( (condition & G_IO_ERR) == G_IO_ERR) {
- fprintf(stderr,
- "pipe_out_watch encountered error…\n");
+ g_warning("%s: encountered error…", __func__);
pipe_data_destroy(pipe);
return FALSE;
}
@@ -2473,7 +2472,7 @@ bndx_pipe_queue_last(struct BndxPipeQueue *queue)
}
if(queue->msgnos->len == 0 && !stream) {
- printf("Piping finished. Destroying the context.\n");
+ g_debug("Piping finished. Destroying the context.");
libbalsa_mailbox_unregister_msgnos(queue->mailbox, queue->msgnos);
libbalsa_mailbox_close(queue->mailbox, FALSE);
g_array_free(queue->msgnos, TRUE);
@@ -2536,7 +2535,7 @@ bndx_pipe_queue_last(struct BndxPipeQueue *queue)
g_io_channel_set_close_on_unref(pipe->out_channel, TRUE);
g_io_channel_set_close_on_unref(pipe->err_channel, TRUE);
} else {
- printf("Could not spawn pipe %s : %s\n", queue->pipe_cmd,
+ g_warning("Could not spawn pipe %s : %s", queue->pipe_cmd,
error ? error->message : "unknown");
g_clear_error(&error);
g_free(pipe->message);
diff --git a/src/balsa-mblist.c b/src/balsa-mblist.c
index fc9f81e58..9bb94f654 100644
--- a/src/balsa-mblist.c
+++ b/src/balsa-mblist.c
@@ -1130,7 +1130,7 @@ bmbl_open_mailbox(LibBalsaMailbox * mailbox, gboolean set_current)
mbnode = balsa_find_mailbox(mailbox);
if (mbnode == NULL) {
- g_warning(_("Failed to find mailbox"));
+ g_warning("Failed to find mailbox");
return;
}
@@ -1179,7 +1179,7 @@ balsa_mblist_close_mailbox(LibBalsaMailbox * mailbox)
mbnode = balsa_find_mailbox(mailbox);
if (!mbnode) {
- g_warning(_("Failed to find mailbox"));
+ g_warning("Failed to find mailbox");
return;
}
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 2c4f5b646..aea3f608f 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -1757,7 +1757,7 @@ part_context_dump_all_cb(GtkWidget * menu_item, GList * info_list)
gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dump_dialog));
LibbalsaVfs * dir_uri;
- g_message("store to URI: %s", dir_name);
+ g_debug("store to URI: %s", dir_name);
if (!(dir_uri = libbalsa_vfs_new_from_uri(dir_name)))
balsa_information(LIBBALSA_INFORMATION_ERROR,
_("Could not create URI for %s"),
@@ -1790,7 +1790,7 @@ part_context_dump_all_cb(GtkWidget * menu_item, GList * info_list)
save_uri = libbalsa_vfs_dir_append(dir_uri, p);
g_free(p);
}
- g_message("store to file: %s", libbalsa_vfs_get_uri_utf8(save_uri));
+ g_debug("store to file: %s", libbalsa_vfs_get_uri_utf8(save_uri));
/* don't overwrite existing files, append (1), (2), ... instead */
if (libbalsa_vfs_file_exists(save_uri)) {
@@ -1807,7 +1807,7 @@ part_context_dump_all_cb(GtkWidget * menu_item, GList * info_list)
} while (libbalsa_vfs_file_exists(save_uri));
g_object_unref(base_uri);
}
- g_message("store to file: %s", libbalsa_vfs_get_uri_utf8(save_uri));
+ g_debug("store to file: %s", libbalsa_vfs_get_uri_utf8(save_uri));
/* try to save the file */
result =
@@ -2951,8 +2951,7 @@ libbalsa_msg_try_mp_signed(LibBalsaMessage * message, LibBalsaMessageBody *body,
if (body->parts->next->sig_info) {
switch (libbalsa_message_body_protect_state(body->parts->next)) {
case LIBBALSA_MSG_PROTECT_SIGN_GOOD:
- libbalsa_information(LIBBALSA_INFORMATION_DEBUG,
- _("Detected a good signature"));
+ g_debug("Detected a good signature");
break;
case LIBBALSA_MSG_PROTECT_SIGN_NOTRUST:
if (g_mime_gpgme_sigstat_protocol(body->parts->next->sig_info) == GPGME_PROTOCOL_CMS)
diff --git a/src/balsa-print-object-image.c b/src/balsa-print-object-image.c
index a0606a8ed..e18a2ad66 100644
--- a/src/balsa-print-object-image.c
+++ b/src/balsa-print-object-image.c
@@ -88,7 +88,7 @@ balsa_print_object_image(GList * list, GtkPrintContext *context,
/* check if we can handle the image */
pixbuf = libbalsa_message_body_get_pixbuf(body, &err);
if (err) {
- g_message("Error loading image from file: %s", err->message);
+ g_warning("Error loading image from file: %s", err->message);
g_error_free(err);
}
diff --git a/src/filter-run-callbacks.c b/src/filter-run-callbacks.c
index db2930d56..31f31d6fd 100644
--- a/src/filter-run-callbacks.c
+++ b/src/filter-run-callbacks.c
@@ -283,9 +283,7 @@ fr_add_pressed_func(GtkTreeModel * model, GtkTreePath * path,
GtkTreeIter sel_iter;
mf->actual_filter = fil;
-#if DEBUG
- printf("fr_add_presed adds fil=%p\n", fil);
-#endif
+ g_debug("%s adds fil=%p", __func__, fil);
mf->when = FILTER_WHEN_NEVER;
gtk_list_store_append(GTK_LIST_STORE(sel_model), &sel_iter);
gtk_list_store_set(GTK_LIST_STORE(sel_model), &sel_iter,
diff --git a/src/folder-conf.c b/src/folder-conf.c
index c78c708ca..c2dcc0469 100644
--- a/src/folder-conf.c
+++ b/src/folder-conf.c
@@ -660,8 +660,7 @@ subfolder_conf_clicked_ok(SubfolderDialogData * sub_folder_data)
parent = gtk_editable_get_chars(GTK_EDITABLE(sub_folder_data->parent_folder), 0, -1);
folder = gtk_editable_get_chars(GTK_EDITABLE(sub_folder_data->folder_name), 0, -1);
- if (balsa_app.debug)
- g_print("sub_folder_data->old_parent=%s\nsub_folder_data->old_folder=%s\n",
+ g_debug("sub_folder_data->old_parent=%s; sub_folder_data->old_folder=%s",
sub_folder_data->old_parent, sub_folder_data->old_folder);
if (sub_folder_data->common_data.mbnode) {
@@ -737,7 +736,7 @@ folder, parent);
balsa_mailbox_node_rescan(mbnode);
g_object_unref(mbnode);
} else
- printf("Parent not found!?\n");
+ g_debug("Parent not found!?");
} else if (sub_folder_data->old_parent != NULL
&& g_str_has_prefix(parent, sub_folder_data->old_parent)) {
/* moved it down the tree */
diff --git a/src/mailbox-conf.c b/src/mailbox-conf.c
index 1e9cf32e5..408c94f88 100644
--- a/src/mailbox-conf.c
+++ b/src/mailbox-conf.c
@@ -544,7 +544,7 @@ mailbox_conf_update(MailboxConfWindow *mcw)
if (i != 0) {
balsa_information(LIBBALSA_INFORMATION_WARNING,
_("Rename of %s to %s failed:\n%s"),
- path, filename, strerror(i));
+ path, filename, g_strerror(i));
g_free(filename);
g_free(path);
return;
@@ -661,7 +661,7 @@ create_dialog(MailboxConfWindow *mcw)
} else if (g_type_is_a(mcw->mailbox_type, LIBBALSA_TYPE_MAILBOX_POP3)) {
return create_pop_mailbox_dialog(mcw);
} else {
- g_warning("Unknown mailbox type: %s\n", g_type_name(mcw->mailbox_type));
+ g_warning("Unknown mailbox type: %s", g_type_name(mcw->mailbox_type));
return NULL;
}
}
diff --git a/src/mailbox-node.c b/src/mailbox-node.c
index 72e960ac7..d7b9ba7bf 100644
--- a/src/mailbox-node.c
+++ b/src/mailbox-node.c
@@ -794,7 +794,7 @@ balsa_mailbox_node_scan_children(BalsaMailboxNode * mbnode)
g_object_unref(mn);
}
} else
- g_print("balsa_mailbox_node_scan_children: didn't find mbnode.\n");
+ g_warning("balsa_mailbox_node_scan_children: didn't find mbnode.");
if (list && !g_object_get_data(G_OBJECT(mbnode),
BALSA_MAILBOX_NODE_LIST_KEY)) {
@@ -838,10 +838,11 @@ bmbn_scan_children_idle(BalsaMailboxNode ** mbnode)
libbalsa_mailbox_set_has_unread_messages
(mn->mailbox, has_unread_messages);
mn->scanned = TRUE;
- } else if (balsa_app.debug)
- g_print("%s: %s “%s” was already scanned\n", __func__,
+ } else {
+ g_debug("%s: %s “%s” was already scanned", __func__,
mn->mailbox ? "mailbox" : "folder",
mn->mailbox ? libbalsa_mailbox_get_name(mn->mailbox) : mn->name);
+ }
g_object_remove_weak_pointer(G_OBJECT(mn), & l->data);
}
g_slist_free(list);
@@ -962,7 +963,8 @@ mb_filter_cb(GtkWidget * widget, BalsaMailboxNode * mbnode)
problems of infinite recursion (when one mailbox being
filtered is also the destination of the filter action (eg a
copy)). So let's see that later :) */
- g_print("You can apply filters only on mailbox\n");
+ libbalsa_information_parented(GTK_WINDOW(balsa_app.main_window),
+ LIBBALSA_INFORMATION_MESSAGE, _("You can apply filters only on mailbox"));
}
static void
@@ -1172,8 +1174,7 @@ add_local_mailbox(BalsaMailboxNode *root, const gchar * name,
mbnode = balsa_mailbox_node_new_from_mailbox(mailbox);
- if (balsa_app.debug)
- g_print(_("Local mailbox %s loaded as: %s\n"),
+ g_debug("Local mailbox %s loaded as: %s",
libbalsa_mailbox_get_name(mailbox),
g_type_name(G_OBJECT_TYPE(mailbox)));
if (balsa_app.check_mail_upon_startup
@@ -1203,8 +1204,7 @@ add_local_folder(BalsaMailboxNode * root, const char *d_name,
mbnode = balsa_mailbox_node_new_from_dir(path);
mbnode->parent = root;
balsa_mblist_mailbox_node_append(root, mbnode);
- if (balsa_app.debug)
- g_print(_("Local folder %s\n"), path);
+ g_debug("Local folder %s", path);
return mbnode;
}
diff --git a/src/main-window.c b/src/main-window.c
index eddc210e4..2f9d4c0ce 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -271,7 +271,7 @@ print_network_status(gboolean available)
datetime_string = g_date_time_format(datetime, "%c");
g_date_time_unref(datetime);
- g_print("Network is %s (%s)\n",
+ g_debug("Network is %s (%s)",
available ? "available " : "unavailable",
datetime_string);
g_free(datetime_string);
@@ -756,7 +756,7 @@ bw_get_action(BalsaWindow * window,
action = g_action_map_lookup_action(action_map, action_name);
}
if (!action)
- g_print("%s action “%s” not found\n", __func__, action_name);
+ g_warning("%s action “%s” not found", __func__, action_name);
return action;
}
@@ -1921,7 +1921,7 @@ header_change_state(GSimpleAction * action,
else if (strcmp(value, "all") == 0)
sh = HEADERS_ALL;
else {
- g_print("%s unknown value “%s”\n", __func__, value);
+ g_warning("%s unknown value “%s”", __func__, value);
return;
}
@@ -2096,8 +2096,8 @@ bw_set_menus(BalsaWindow * window)
win_entries,
G_N_ELEMENTS(win_entries),
resource_path, &error, window);
- if (error) {
- g_print("%s %s\n", __func__, error->message);
+ if (error != NULL) {
+ g_warning("%s error: %s", __func__, error->message);
g_error_free(error);
return;
}
@@ -2814,7 +2814,7 @@ bw_notebook_label_new(BalsaMailboxNode * mbnode)
"font-weight:normal;"
"}",
-1, NULL))
- g_print("Could not load label CSS data.\n");
+ g_warning("Could not load label CSS data.");
gtk_style_context_add_provider(gtk_widget_get_style_context(lab) ,
GTK_STYLE_PROVIDER(css_provider),
@@ -3121,9 +3121,7 @@ bw_close_mailbox_on_timer(BalsaWindow * window)
if (balsa_app.close_mailbox_auto &&
(delta_time = current_time - balsa_index_get_last_use_time(index)) >
balsa_app.close_mailbox_timeout) {
- if (balsa_app.debug)
- fprintf(stderr, "Closing Page %d unused for %d s\n",
- i, delta_time);
+ g_debug("Closing Page %d unused for %d s", i, delta_time);
balsa_window_real_close_mbnode(window, balsa_index_get_mailbox_node(index));
if (i < c)
c--;
diff --git a/src/main-window.h b/src/main-window.h
index e19714fc1..2373e55f1 100644
--- a/src/main-window.h
+++ b/src/main-window.h
@@ -117,14 +117,4 @@ void balsa_window_set_statusbar(BalsaWindow * window,
GtkStatusbar * balsa_window_get_statusbar(BalsaWindow * window);
-#if defined(__FILE__) && defined(__LINE__)
-# ifdef __FUNCTION__
-# define BALSA_DEBUG_MSG(message) if (balsa_app.debug) fprintf(stderr, "[%lu] %12s | %4d | %30s: %s\n",
(unsigned long) time(NULL), __FILE__, __LINE__, __FUNCTION__, message)
-# define BALSA_DEBUG() if (balsa_app.debug) fprintf (stderr, "[%lu] %12s | %4d | %30s\n", (unsigned long)
time(NULL), __FILE__, __LINE__, __FUNCTION__)
-# else
-# define BALSA_DEBUG_MSG(message) if (balsa_app.debug) fprintf(stderr, "[%lu] %12s | %4d: %s\n",
(unsigned long) time(NULL), __FILE__, __LINE__, message)
-# define BALSA_DEBUG() if (balsa_app.debug) fprintf(stderr, "[%lu] %12s | %4d\n", (unsigned long)
time(NULL), __FILE__, __LINE__)
-# endif
-#endif
-
#endif /* __MAIN_WINDOW_H__ */
diff --git a/src/main.c b/src/main.c
index 47df8181f..b90b55158 100644
--- a/src/main.c
+++ b/src/main.c
@@ -147,7 +147,7 @@ mailboxes_init(gboolean check_only)
{
check_special_mailboxes();
if (!balsa_app.inbox && !check_only) {
- g_warning("*** error loading mailboxes\n");
+ g_warning("*** error loading mailboxes");
balsa_init_begin();
config_defclient_save();
return;
@@ -169,7 +169,7 @@ initial_open_unread_mailboxes()
for (l = gl; l; l = l->next) {
LibBalsaMailbox *mailbox = LIBBALSA_MAILBOX(l->data);
- printf("opening %s..\n", libbalsa_mailbox_get_name(mailbox));
+ g_debug("opening %s..", libbalsa_mailbox_get_name(mailbox));
balsa_mblist_open_mailbox(mailbox);
}
g_list_free(gl);
@@ -184,7 +184,7 @@ initial_open_inbox()
if (!balsa_app.inbox)
return FALSE;
- printf("opening %s..\n", libbalsa_mailbox_get_name(balsa_app.inbox));
+ g_debug("opening %s..", libbalsa_mailbox_get_name(balsa_app.inbox));
balsa_mblist_open_mailbox_hidden(balsa_app.inbox);
return FALSE;
@@ -306,7 +306,7 @@ scan_mailboxes_idle_cb()
if (cmd_get_stats) {
long unread, unsent;
balsa_get_stats(&unread, &unsent);
- printf("Unread: %ld Unsent: %ld\n", unread, unsent);
+ g_debug("Unread: %ld Unsent: %ld", unread, unsent);
}
return FALSE;
@@ -339,8 +339,8 @@ periodic_expunge_cb(void)
if (!balsa_app.expunge_auto)
return TRUE;
- libbalsa_information(LIBBALSA_INFORMATION_DEBUG,
- _("Compressing mail folders…"));
+ balsa_information(LIBBALSA_INFORMATION_DEBUG,
+ _("Compressing mail folders…"));
gtk_tree_model_foreach(GTK_TREE_MODEL(balsa_app.mblist_tree_store),
(GtkTreeModelForeachFunc)mbnode_expunge_func,
&list);
@@ -719,7 +719,7 @@ balsa_handle_local_options_cb(GApplication *application,
gpointer user_data)
{
if (g_variant_dict_contains(options, "version")) {
- g_print("Balsa email client %s\n", BALSA_VERSION);
+ g_message("Balsa email client %s", BALSA_VERSION);
return 0;
}
@@ -748,7 +748,7 @@ balsa_command_line_cb(GApplication * application,
balsa_app.outbox =
libbalsa_mailbox_new_from_config("mailbox-Outbox", FALSE);
balsa_get_stats(&unread, &unsent);
- printf("Unread: %ld Unsent: %ld\n", unread, unsent);
+ g_debug("Unread: %ld Unsent: %ld", unread, unsent);
g_object_unref(balsa_app.outbox);
g_object_unref(balsa_app.inbox);
} else {
diff --git a/src/message-window.c b/src/message-window.c
index 909641b65..5eacd8b75 100644
--- a/src/message-window.c
+++ b/src/message-window.c
@@ -72,7 +72,7 @@ mw_set_enabled(MessageWindow * mw, const gchar * action_name,
if (action)
g_simple_action_set_enabled(G_SIMPLE_ACTION(action), enabled);
else
- g_print("%s action “%s” not found\n", __func__, action_name);
+ g_warning("%s action “%s” not found", __func__, action_name);
}
/*
@@ -89,7 +89,7 @@ mw_set_active(MessageWindow * mw,
if (action)
g_action_change_state(action, g_variant_new_boolean(state));
else
- g_print("%s action “%s” not found\n", __func__, action_name);
+ g_warning("%s action “%s” not found", __func__, action_name);
}
/*
@@ -269,7 +269,7 @@ mw_header_change_state(GSimpleAction * action,
else if (strcmp(value, "all") == 0)
sh = HEADERS_ALL;
else {
- g_print("%s unknown value “%s”\n", __func__, value);
+ g_warning("%s unknown value “%s”", __func__, value);
return;
}
@@ -475,7 +475,7 @@ mw_forward_default_activated(GSimpleAction * action, GVariant * parameter,
g_return_if_fail(mw != NULL);
sendmsg_window_forward(libbalsa_message_get_mailbox(mw->message),
- libbalsa_message(get_msgno(mw->message),
+ libbalsa_message_get_msgno(mw->message),
balsa_app.forward_attached);
}
#endif
diff --git a/src/pref-manager.c b/src/pref-manager.c
index 3ba341aaf..383b7f54d 100644
--- a/src/pref-manager.c
+++ b/src/pref-manager.c
@@ -106,7 +106,6 @@ typedef struct _PropertyUI {
GtkWidget *pgdownmod;
GtkWidget *pgdown_percent;
GtkWidget *view_allheaders;
- GtkWidget *debug; /* enable/disable debugging */
GtkWidget *empty_trash;
GtkWidget *recv_progress_dlg;
GtkWidget *send_progress_dlg;
@@ -304,7 +303,7 @@ pm_selection_changed(GtkTreeSelection * selection, gpointer user_data)
gtk_stack_set_visible_child(stack, child);
g_object_unref(child);
} else {
- g_print("%s no child\n", G_STRLOC);
+ g_warning("%s no child", G_STRLOC);
}
}
@@ -414,8 +413,6 @@ apply_prefs(GtkDialog * pbox)
balsa_app.recv_progress_dialog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->recv_progress_dlg));
balsa_app.send_progress_dialog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->send_progress_dlg));
- balsa_app.debug =
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->debug));
balsa_app.previewpane =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->previewpane));
@@ -696,8 +693,6 @@ set_prefs(void)
gtk_widget_set_sensitive(pui->pgdown_percent,
gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON(pui->pgdownmod)));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->debug),
- balsa_app.debug);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
(pui->mblist_show_mb_content_info),
@@ -2878,8 +2873,6 @@ pm_grid_add_misc_group(GtkWidget * grid_widget)
pm_grid_attach(grid, pm_group_label(_("Miscellaneous")), 0, row, 3, 1);
- pui->debug =
- pm_grid_attach_check(grid, 1, ++row, 3, 1, _("Debug"));
pui->empty_trash =
pm_grid_attach_check(grid, 1, ++row, 3, 1, _("Empty trash on exit"));
@@ -3358,8 +3351,6 @@ open_preferences_manager(GtkWidget * widget, gpointer data)
G_CALLBACK(pgdown_modified_cb), property_box);
g_signal_connect(pui->pgdown_percent, "changed",
G_CALLBACK(pgdown_modified_cb), property_box);
- g_signal_connect(pui->debug, "toggled",
- G_CALLBACK(properties_modified_cb), property_box);
g_signal_connect(pui->mblist_show_mb_content_info, "toggled",
G_CALLBACK(properties_modified_cb), property_box);
diff --git a/src/print-gtk.c b/src/print-gtk.c
index 939053ac8..421191dfc 100644
--- a/src/print-gtk.c
+++ b/src/print-gtk.c
@@ -464,7 +464,7 @@ get_default_user_units(void)
if (strcmp(e, "default:inch")==0)
return GTK_UNIT_INCH;
else if (strcmp(e, "default:mm"))
- g_warning("Whoever translated default:mm did so wrongly.\n");
+ g_warning("Whoever translated default:mm did so wrongly.");
return GTK_UNIT_MM;
}
diff --git a/src/save-restore.c b/src/save-restore.c
index 7c7072099..fbbf90886 100644
--- a/src/save-restore.c
+++ b/src/save-restore.c
@@ -1121,8 +1121,6 @@ config_global_load(void)
balsa_app.open_inbox_upon_startup =
libbalsa_conf_get_bool("OpenInboxOnStartup=false");
- /* debugging enabled */
- balsa_app.debug = libbalsa_conf_get_bool("Debug=false");
balsa_app.close_mailbox_auto = libbalsa_conf_get_bool("AutoCloseMailbox=true");
/* timeouts in minutes in config file for backwards compat */
@@ -1507,7 +1505,6 @@ config_save(void)
libbalsa_conf_set_bool("OpenInboxOnStartup",
balsa_app.open_inbox_upon_startup);
- libbalsa_conf_set_bool("Debug", balsa_app.debug);
libbalsa_conf_set_bool("AutoCloseMailbox", balsa_app.close_mailbox_auto);
libbalsa_conf_set_int("AutoCloseMailboxTimeout", balsa_app.close_mailbox_timeout/60);
@@ -1930,8 +1927,10 @@ config_filter_load(const gchar * key, const gchar * value, gpointer data)
long int dummy;
dummy = strtol(value, &endptr, 10);
- if (dummy == LONG_MIN || dummy == LONG_MAX)
- g_message("Value is too large");
+ if (dummy == LONG_MIN || dummy == LONG_MAX) {
+ g_warning("%s: Value %ld is too large", __func__, dummy);
+ return FALSE;
+ }
if (*endptr) { /* Bad format. */
libbalsa_conf_remove_group(key);
return FALSE;
@@ -1982,7 +1981,7 @@ config_filters_save(void)
fil = (LibBalsaFilter*)(list->data);
i=snprintf(tmp,tmp_len,"%d",nb++);
if (i >= tmp_len)
- g_message("Group name was truncated");
+ g_warning("Group name was truncated");
libbalsa_conf_push_group(buffer);
libbalsa_filter_save_config(fil);
libbalsa_conf_pop_group();
@@ -1992,7 +1991,7 @@ config_filters_save(void)
while (TRUE) {
i=snprintf(tmp,tmp_len,"%d",nb++);
if (i >= tmp_len)
- g_message("Group name was truncated");
+ g_warning("Group name was truncated");
if (libbalsa_conf_has_group(buffer)) {
libbalsa_conf_remove_group(buffer);
}
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 9d840c627..53ac38386 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -335,8 +335,7 @@ balsa_attach_info_finalize(GObject * object)
gchar * folder_name;
/* unlink the file */
- if (balsa_app.debug)
- fprintf (stderr, "%s:%s: unlink `%s'\n", __FILE__, __FUNCTION__,
+ g_debug("%s:%s: unlink `%s'", __FILE__, __func__,
libbalsa_vfs_get_uri_utf8(info->file_uri));
libbalsa_vfs_file_unlink(info->file_uri, NULL);
@@ -344,8 +343,7 @@ balsa_attach_info_finalize(GObject * object)
folder_name = g_filename_from_uri(libbalsa_vfs_get_folder(info->file_uri),
NULL, NULL);
if (folder_name) {
- if (balsa_app.debug)
- fprintf (stderr, "%s:%s: rmdir `%s'\n", __FILE__, __FUNCTION__,
+ g_debug("%s:%s: rmdir `%s'", __FILE__, __func__,
folder_name);
g_rmdir(folder_name);
g_free(folder_name);
@@ -465,8 +463,7 @@ delete_handler(BalsaSendmsg * bsmsg)
gint reply;
GtkWidget *d;
- if (balsa_app.debug)
- printf("%s\n", __func__);
+ g_debug("%s", __func__);
if (bsmsg->state == SENDMSG_STATE_CLEAN)
return FALSE;
@@ -530,12 +527,12 @@ sw_close_activated(GSimpleAction * action,
{
BalsaSendmsg *bsmsg = data;
- BALSA_DEBUG_MSG("close_window_cb: start\n");
+ g_debug("close_window_cb: start");
g_object_set_data(G_OBJECT(bsmsg->window), "destroying",
GINT_TO_POINTER(TRUE));
if(!delete_handler(bsmsg))
gtk_widget_destroy(bsmsg->window);
- BALSA_DEBUG_MSG("close_window_cb: end\n");
+ g_debug("close_window_cb: end");
}
static gint
@@ -569,7 +566,7 @@ balsa_sendmsg_destroy_handler(BalsaSendmsg * bsmsg)
g_object_weak_unref(G_OBJECT(balsa_app.main_window),
(GWeakNotify) gtk_widget_destroy, bsmsg->window);
}
- if(balsa_app.debug) g_message("balsa_sendmsg_destroy()_handler: Start.");
+ g_debug("balsa_sendmsg_destroy()_handler: Start.");
if (bsmsg->parent_message != NULL) {
LibBalsaMailbox *mailbox;
@@ -595,8 +592,7 @@ balsa_sendmsg_destroy_handler(BalsaSendmsg * bsmsg)
g_object_unref(bsmsg->draft_message);
}
- if (balsa_app.debug)
- printf("balsa_sendmsg_destroy_handler: Freeing bsmsg\n");
+ g_debug("balsa_sendmsg_destroy_handler: Freeing bsmsg");
gtk_widget_destroy(bsmsg->window);
quit_on_close = bsmsg->quit_on_close;
g_free(bsmsg->fcc_url);
@@ -632,7 +628,7 @@ balsa_sendmsg_destroy_handler(BalsaSendmsg * bsmsg)
libbalsa_wait_for_sending_thread(-1);
gtk_main_quit();
}
- if(balsa_app.debug) g_message("balsa_sendmsg_destroy(): Stop.");
+ g_debug("balsa_sendmsg_destroy(): Stop.");
}
/* language menu helper functions */
@@ -948,7 +944,7 @@ sw_get_action(BalsaSendmsg * bsmsg, const gchar * action_name)
action = g_action_map_lookup_action(G_ACTION_MAP(bsmsg->window),
action_name);
if (!action)
- g_print("%s %s not found\n", __func__, action_name);
+ g_warning("%s %s not found", __func__, action_name);
return action;
}
@@ -1428,7 +1424,7 @@ on_open_url_cb(GtkWidget * menu_item, BalsaAttachInfo * info)
uri = libbalsa_vfs_get_uri(info->file_uri);
g_return_if_fail(uri != NULL);
- g_message("open URL %s", uri);
+ g_debug("open URL %s", uri);
toplevel = gtk_widget_get_toplevel(GTK_WIDGET(menu_item));
if (gtk_widget_is_toplevel(toplevel)) {
gtk_show_uri_on_window(GTK_WINDOW(toplevel), uri,
@@ -1666,8 +1662,7 @@ add_attachment(BalsaSendmsg * bsmsg, const gchar *filename,
GtkWidget *menu_item;
gchar *content_desc;
- if (balsa_app.debug)
- fprintf(stderr, "Trying to attach '%s'\n", filename);
+ g_debug("Trying to attach '%s'", filename);
if (!(file_uri = libbalsa_vfs_new_from_uri(filename))) {
balsa_information_parented(GTK_WINDOW(bsmsg->window),
LIBBALSA_INFORMATION_ERROR,
@@ -1860,8 +1855,7 @@ add_urlref_attachment(BalsaSendmsg * bsmsg, gchar *url)
GdkPixbuf * pixbuf;
GtkWidget *menu_item;
- if (balsa_app.debug)
- fprintf(stderr, "Trying to attach '%s'\n", url);
+ g_debug("Trying to attach '%s'", url);
/* get the pixbuf for the attachment's content type */
pixbuf =
@@ -2160,8 +2154,7 @@ attachments_add(GtkWidget * widget,
{
gboolean drag_result = TRUE;
- if (balsa_app.debug)
- printf("attachments_add: info %d\n", info);
+ g_debug("attachments_add: info %d", info);
if (info == TARGET_MESSAGES) {
BalsaIndex *index =
*(BalsaIndex **) gtk_selection_data_get_data(selection_data);
@@ -2217,11 +2210,6 @@ to_add(GtkWidget * widget,
{
gboolean drag_result = FALSE;
-#ifdef DEBUG
- /* This leaks the name: */
- g_print("%s atom name %s\n", __func__,
- gdk_atom_name(gtk_selection_data_get_target(selection_data)));
-#endif
if (info == TARGET_STRING) {
const gchar *address;
@@ -4713,7 +4701,7 @@ do_insert_string_select_ch(BalsaSendmsg* bsmsg, GtkTextBuffer *buffer,
if (info->win && (attr & LIBBALSA_TEXT_HI_CTRL))
charset = info->win;
- g_print("Trying charset: %s\n", charset);
+ g_debug("Trying charset: %s", charset);
if (sw_can_convert(string, len, "UTF-8", charset, &s)) {
gtk_text_buffer_insert_at_cursor(buffer, s, -1);
g_free(s);
@@ -6279,7 +6267,7 @@ sw_gpg_mode_change_state(GSimpleAction * action,
else if (strcmp(mode, "smime") == 0)
rfc_flag = LIBBALSA_PROTECT_SMIMEV3;
else {
- g_print("%s unknown mode “%s”\n", __func__, mode);
+ g_warning("%s unknown mode “%s”", __func__, mode);
return;
}
@@ -6885,7 +6873,7 @@ sendmsg_window_new()
G_N_ELEMENTS(win_entries),
resource_path, &error, bsmsg);
if (error) {
- g_print("%s %s\n", __func__, error->message);
+ g_warning("%s %s", __func__, error->message);
g_error_free(error);
return NULL;
}
@@ -7032,7 +7020,7 @@ sendmsg_window_reply(LibBalsaMailbox * mailbox, guint msgno,
case SEND_REPLY_ALL:
bsmsg = sendmsg_window_new();
bsmsg->type = reply_type; break;
- default: printf("reply_type: %d\n", reply_type); g_assert_not_reached();
+ default: g_error("reply_type: %d", reply_type);
}
bsmsg->parent_message = message;
set_identity(bsmsg, message);
@@ -7077,7 +7065,7 @@ sendmsg_window_reply_embedded(LibBalsaMessageBody *part,
case SEND_REPLY_ALL:
case SEND_REPLY_GROUP:
bsmsg->type = reply_type; break;
- default: printf("reply_type: %d\n", reply_type); g_assert_not_reached();
+ default: g_error("reply_type: %d", reply_type);
}
bsm_prepare_for_setup(g_object_ref(part->message));
headers = part->embhdrs;
diff --git a/src/spell-check.c b/src/spell-check.c
index 581ce9815..844495e07 100644
--- a/src/spell-check.c
+++ b/src/spell-check.c
@@ -35,6 +35,12 @@
#define BALSA_SPELL_CHECK_PADDING 6
+#ifdef G_LOG_DOMAIN
+# undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "spell-check"
+
+
/* the basic structures */
struct _BalsaSpellCheck {
GtkWindow window;
@@ -623,9 +629,7 @@ balsa_spell_check_start(BalsaSpellCheck *spell_check)
&start, &end);
#endif /* HAVE_GTKSOURCEVIEW */
- if (balsa_app.debug)
- balsa_information(LIBBALSA_INFORMATION_DEBUG,
- "BalsaSpellCheck: Start\n");
+ g_debug("start");
/*
* compile the quoted-text regular expression (note:
@@ -741,9 +745,7 @@ balsa_spell_check_learn(BalsaSpellCheck *spell_check,
gtk_text_buffer_get_text(buffer, &spell_check->start_iter,
&spell_check->end_iter, FALSE);
- if (balsa_app.debug)
- balsa_information(LIBBALSA_INFORMATION_DEBUG,
- "BalsaSpellCheck: Learn %s\n", word);
+ g_debug("learn %s", word);
if (learn_type == SESSION_DICT)
enchant_dict_add_to_session(spell_check->dict, word, -1);
@@ -794,11 +796,7 @@ balsa_spell_check_fix(BalsaSpellCheck *spell_check,
return;
}
- if (balsa_app.debug) {
- balsa_information(LIBBALSA_INFORMATION_DEBUG,
- "BalsaSpellCheck: Replace %s with %s\n",
- old_word, new_word);
- }
+ g_debug("replace %s with %s", old_word, new_word);
switch_word(spell_check, new_word);
@@ -903,9 +901,7 @@ spch_finish(BalsaSpellCheck *spell_check,
spell_check->broker = NULL;
}
- if (balsa_app.debug)
- balsa_information(LIBBALSA_INFORMATION_DEBUG,
- "BalsaSpellCheck: Finished\n");
+ g_debug("finished");
gtk_widget_destroy((GtkWidget *) spell_check);
}
@@ -960,9 +956,7 @@ check_word(BalsaSpellCheck *spell_check)
if (word) {
gint enchant_check;
- if (balsa_app.debug)
- balsa_information(LIBBALSA_INFORMATION_DEBUG,
- "BalsaSpellCheck: Check %s", word);
+ g_debug("check %s…", word);
enchant_check = enchant_dict_check(spell_check->dict, word, -1);
@@ -978,17 +972,13 @@ check_word(BalsaSpellCheck *spell_check)
if (!correct) {
gsize n_suggs;
- if (balsa_app.debug)
- balsa_information(LIBBALSA_INFORMATION_DEBUG,
- " …incorrect.\n");
+ g_debug(" …incorrect.");
spell_check->suggestions =
enchant_dict_suggest(spell_check->dict, word, -1, &n_suggs);
setup_suggestions(spell_check, n_suggs);
} else {
- if (balsa_app.debug)
- balsa_information(LIBBALSA_INFORMATION_DEBUG,
- " …correct.\n");
+ g_debug(" …correct.");
}
g_free(word);
diff --git a/src/toolbar-factory.c b/src/toolbar-factory.c
index d79378112..06bb446fe 100644
--- a/src/toolbar-factory.c
+++ b/src/toolbar-factory.c
@@ -370,7 +370,7 @@ balsa_toolbar_model_append_icon(BalsaToolbarModel * model,
entry.icon = g_strdup(real_button);
g_array_append_val(model->current, entry);
} else
- g_warning(_("Unknown toolbar icon “%s”"), icon);
+ g_warning("Unknown toolbar icon “%s”", icon);
}
/* Remove all icons from the BalsaToolbarModel.
diff --git a/src/toolbar-prefs.c b/src/toolbar-prefs.c
index 8bcf46c97..800c7e8e7 100644
--- a/src/toolbar-prefs.c
+++ b/src/toolbar-prefs.c
@@ -36,12 +36,6 @@
# include "macosx-helpers.h"
#endif
-#ifndef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
-/* Uncomment the next line to check for invalid action names */
-/* #define BALSA_TOOLBAR_DEBUG_ACTIONS */
/* Enumeration for GtkTreeModel columns. */
enum {
@@ -94,11 +88,7 @@ static GtkWidget *create_toolbar_page(BalsaToolbarModel * model,
static GtkWidget *tp_list_new(void);
static gboolean tp_list_iter_is_first(GtkWidget * list, GtkTreeIter * iter);
static gboolean tp_list_iter_is_last(GtkWidget * list, GtkTreeIter * iter);
-#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
static void tp_page_refresh_available(ToolbarPage * page);
-#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
-static void tp_page_refresh_available(ToolbarPage * page, GActionMap * map);
-#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
static void tp_page_refresh_current(ToolbarPage * page);
static void tp_page_refresh_preview(ToolbarPage * page);
static void tp_page_swap_rows(ToolbarPage * page, gboolean forward);
@@ -106,7 +96,6 @@ static void tp_page_add_selected(ToolbarPage * page);
static void tp_page_remove_selected(ToolbarPage * page);
static void tp_store_set(GtkListStore * store, GtkTreeIter * iter,
gint item);
-static void replace_nl_with_space(char* str);
/* Public methods. */
@@ -162,9 +151,7 @@ customize_dialog_cb(GtkWidget * widget, gpointer data)
model = balsa_window_get_toolbar_model();
group = g_simple_action_group_new();
balsa_window_add_action_entries(G_ACTION_MAP(group));
-#ifdef BALSA_TOOLBAR_DEBUG_ACTIONS
- g_print("main window\n");
-#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
+ g_debug("%s: main window", __func__);
child = create_toolbar_page(model, G_ACTION_MAP(group));
g_object_unref(group);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), child,
@@ -173,9 +160,7 @@ customize_dialog_cb(GtkWidget * widget, gpointer data)
model = sendmsg_window_get_toolbar_model();
group = g_simple_action_group_new();
sendmsg_window_add_action_entries(G_ACTION_MAP(group));
-#ifdef BALSA_TOOLBAR_DEBUG_ACTIONS
- g_print("compose window\n");
-#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
+ g_debug("%s: compose window", __func__);
child = create_toolbar_page(model, G_ACTION_MAP(group));
g_object_unref(group);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), child,
@@ -184,9 +169,7 @@ customize_dialog_cb(GtkWidget * widget, gpointer data)
model = message_window_get_toolbar_model();
group = g_simple_action_group_new();
message_window_add_action_entries(G_ACTION_MAP(group));
-#ifdef BALSA_TOOLBAR_DEBUG_ACTIONS
- g_print("message window\n");
-#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
+ g_debug("%s: message window", __func__);
child = create_toolbar_page(model, G_ACTION_MAP(group));
g_object_unref(group);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), child,
@@ -292,11 +275,7 @@ standard_button_cb(GtkWidget *widget, ToolbarPage * page)
{
balsa_toolbar_model_clear(page->model);
gtk_widget_set_sensitive(page->standard_button, FALSE);
-#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
tp_page_refresh_available(page);
-#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
- tp_page_refresh_available(page, NULL);
-#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
tp_page_refresh_current(page);
balsa_toolbar_model_changed(page->model);
}
@@ -566,11 +545,7 @@ create_toolbar_page(BalsaToolbarModel * model, GActionMap * map)
gtk_widget_set_sensitive(page->standard_button,
!balsa_toolbar_model_is_standard(model));
-#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
tp_page_refresh_available(page);
-#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
- tp_page_refresh_available(page, map);
-#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
tp_page_refresh_current(page);
return outer_box;
@@ -591,11 +566,7 @@ tp_find_icon(GArray * array, const gchar * icon)
}
static void
-#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
tp_page_refresh_available(ToolbarPage * page)
-#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
-tp_page_refresh_available(ToolbarPage * page, GActionMap * map)
-#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
{
GtkTreeSelection *selection =
gtk_tree_view_get_selection(GTK_TREE_VIEW(page->available));
@@ -616,17 +587,6 @@ tp_page_refresh_available(ToolbarPage * page, GActionMap * map)
gtk_list_store_clear(GTK_LIST_STORE(model));
for (item = 0; item < toolbar_button_count; item++) {
-#ifdef BALSA_TOOLBAR_DEBUG_ACTIONS
- if (map) {
- if (item > 0) {
- gchar *action;
-
- action = g_hash_table_lookup(legal, toolbar_buttons[item].pixmap_id);
- if (action && !g_action_map_lookup_action(map, action))
- g_print("undefined action: “%s”\n", action);
- }
- }
-#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
if (item > 0
&& (!g_hash_table_lookup(legal,
toolbar_buttons[item].pixmap_id)
@@ -829,7 +789,7 @@ tp_store_set(GtkListStore * store, GtkTreeIter * iter, gint item)
gchar *text;
text = g_strdup(balsa_toolbar_button_text(item));
- replace_nl_with_space(text);
+ g_strdelimit(text, "\n", ' ');
if (item > 0) {
const gchar *icon_id;
@@ -886,11 +846,7 @@ tp_page_add_selected(ToolbarPage * page)
gtk_widget_set_sensitive(page->standard_button, TRUE);
tp_page_refresh_preview(page);
-#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
tp_page_refresh_available(page);
-#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
- tp_page_refresh_available(page, NULL);
-#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
balsa_toolbar_model_changed(page->model);
}
@@ -921,22 +877,6 @@ tp_page_remove_selected(ToolbarPage * page)
gtk_widget_set_sensitive(page->standard_button, TRUE);
tp_page_refresh_preview(page);
-#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
tp_page_refresh_available(page);
-#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
- tp_page_refresh_available(page, NULL);
-#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
balsa_toolbar_model_changed(page->model);
}
-
-/* Unwrap text.
- */
-static void
-replace_nl_with_space(char* str)
-{
- while(*str) {
- if(*str == '\n')
- *str=' ';
- str++;
- }
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]