From 692886962aec6022d4fab9cdbd9867f2acd7f75c Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 30 Apr 2008 21:44:38 +0000 Subject: Make use of tp-glib debug system. svn path=/trunk/; revision=1066 --- libempathy/empathy-avatar.c | 19 ++-- libempathy/empathy-chatroom-manager.c | 12 +-- libempathy/empathy-contact-groups.c | 10 +- libempathy/empathy-contact-manager.c | 10 +- libempathy/empathy-contact.c | 6 +- libempathy/empathy-debug.c | 157 ++++++++++++------------------- libempathy/empathy-debug.h | 110 ++++++++++++++-------- libempathy/empathy-idle.c | 44 +++++---- libempathy/empathy-irc-network-manager.c | 29 +++--- libempathy/empathy-log-manager.c | 31 +++--- libempathy/empathy-status-presets.c | 16 ++-- libempathy/empathy-tp-call.c | 69 ++++++-------- libempathy/empathy-tp-chat.c | 64 ++++++------- libempathy/empathy-tp-contact-factory.c | 119 ++++++++++------------- libempathy/empathy-tp-contact-list.c | 93 +++++++++--------- libempathy/empathy-tp-group.c | 67 ++++++------- libempathy/empathy-tp-roomlist.c | 17 ++-- libempathy/empathy-tp-tube.c | 34 ++++--- libempathy/empathy-tube-handler.c | 8 +- libempathy/empathy-utils.c | 24 ++--- 20 files changed, 433 insertions(+), 506 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-avatar.c b/libempathy/empathy-avatar.c index f03178ba6..41395d6e9 100644 --- a/libempathy/empathy-avatar.c +++ b/libempathy/empathy-avatar.c @@ -20,15 +20,16 @@ * Authors: Xavier Claessens */ + #include "config.h" #include #include "empathy-avatar.h" #include "empathy-utils.h" -#include "empathy-debug.h" -#define DEBUG_DOMAIN "Avatar" +#define DEBUG_FLAG EMPATHY_DEBUG_OTHER +#include "empathy-debug.h" GType empathy_avatar_get_type (void) @@ -109,12 +110,11 @@ empathy_avatar_new (const guchar *data, filename = avatar_get_filename (token); if (!g_file_test (filename, G_FILE_TEST_EXISTS)) { if (!g_file_set_contents (filename, data, len, &error)) { - empathy_debug (DEBUG_DOMAIN, - "Failed to save avatar in cache: %s", - error ? error->message : "No error given"); + DEBUG ("Failed to save avatar in cache: %s", + error ? error->message : "No error given"); g_clear_error (&error); } else { - empathy_debug (DEBUG_DOMAIN, "Avatar saved to %s", filename); + DEBUG ("Avatar saved to %s", filename); } } g_free (filename); @@ -137,15 +137,14 @@ empathy_avatar_new_from_cache (const gchar *token) filename = avatar_get_filename (token); if (g_file_test (filename, G_FILE_TEST_EXISTS)) { if (!g_file_get_contents (filename, &data, &len, &error)) { - empathy_debug (DEBUG_DOMAIN, - "Failed to load avatar from cache: %s", - error ? error->message : "No error given"); + DEBUG ("Failed to load avatar from cache: %s", + error ? error->message : "No error given"); g_clear_error (&error); } } if (data) { - empathy_debug (DEBUG_DOMAIN, "Avatar loaded from %s", filename); + DEBUG ("Avatar loaded from %s", filename); avatar = avatar_new (data, len, NULL, g_strdup (token)); } diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c index 0e0c2be2b..80c190bd9 100644 --- a/libempathy/empathy-chatroom-manager.c +++ b/libempathy/empathy-chatroom-manager.c @@ -31,11 +31,11 @@ #include #include -#include "empathy-debug.h" #include "empathy-chatroom-manager.h" #include "empathy-utils.h" -#define DEBUG_DOMAIN "ChatroomManager" +#define DEBUG_FLAG EMPATHY_DEBUG_OTHER +#include "empathy-debug.h" #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CHATROOM_MANAGER, EmpathyChatroomManagerPriv)) @@ -338,7 +338,7 @@ chatroom_manager_file_parse (EmpathyChatroomManager *manager, priv = GET_PRIV (manager); - empathy_debug (DEBUG_DOMAIN, "Attempting to parse file:'%s'...", filename); + DEBUG ("Attempting to parse file:'%s'...", filename); ctxt = xmlNewParserCtxt (); @@ -366,9 +366,7 @@ chatroom_manager_file_parse (EmpathyChatroomManager *manager, } } - empathy_debug (DEBUG_DOMAIN, - "Parsed %d chatrooms", - g_list_length (priv->chatrooms)); + DEBUG ("Parsed %d chatrooms", g_list_length (priv->chatrooms)); xmlFreeDoc(doc); xmlFreeParserCtxt (ctxt); @@ -488,7 +486,7 @@ chatroom_manager_file_save (EmpathyChatroomManager *manager) /* Make sure the XML is indented properly */ xmlIndentTreeOutput = 1; - empathy_debug (DEBUG_DOMAIN, "Saving file:'%s'", file); + DEBUG ("Saving file:'%s'", file); xmlSaveFormatFileEnc (file, doc, "utf-8", 1); xmlFreeDoc (doc); diff --git a/libempathy/empathy-contact-groups.c b/libempathy/empathy-contact-groups.c index b71cf6642..83d920a94 100644 --- a/libempathy/empathy-contact-groups.c +++ b/libempathy/empathy-contact-groups.c @@ -32,11 +32,11 @@ #include #include -#include "empathy-debug.h" #include "empathy-utils.h" #include "empathy-contact-groups.h" -#define DEBUG_DOMAIN "ContactGroups" +#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT +#include "empathy-debug.h" #define CONTACT_GROUPS_XML_FILENAME "contact-groups.xml" #define CONTACT_GROUPS_DTD_FILENAME "empathy-contact-groups.dtd" @@ -87,7 +87,7 @@ contact_groups_file_parse (const gchar *filename) xmlNodePtr account; xmlNodePtr node; - empathy_debug (DEBUG_DOMAIN, "Attempting to parse file:'%s'...", filename); + DEBUG ("Attempting to parse file:'%s'...", filename); ctxt = xmlNewParserCtxt (); @@ -150,7 +150,7 @@ contact_groups_file_parse (const gchar *filename) node = node->next; } - empathy_debug (DEBUG_DOMAIN, "Parsed %d contact groups", g_list_length (groups)); + DEBUG ("Parsed %d contact groups", g_list_length (groups)); xmlFreeDoc(doc); xmlFreeParserCtxt (ctxt); @@ -216,7 +216,7 @@ contact_groups_file_save (void) /* Make sure the XML is indented properly */ xmlIndentTreeOutput = 1; - empathy_debug (DEBUG_DOMAIN, "Saving file:'%s'", file); + DEBUG ("Saving file:'%s'", file); xmlSaveFormatFileEnc (file, doc, "utf-8", 1); xmlFreeDoc (doc); diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c index cad19293e..cb7fcadc9 100644 --- a/libempathy/empathy-contact-manager.c +++ b/libempathy/empathy-contact-manager.c @@ -28,13 +28,13 @@ #include "empathy-contact-manager.h" #include "empathy-contact-list.h" #include "empathy-utils.h" + +#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT #include "empathy-debug.h" #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ EMPATHY_TYPE_CONTACT_MANAGER, EmpathyContactManagerPriv)) -#define DEBUG_DOMAIN "ContactManager" - struct _EmpathyContactManagerPriv { GHashTable *lists; MissionControl *mc; @@ -121,8 +121,7 @@ contact_manager_destroy_cb (EmpathyTpContactList *list, account = empathy_tp_contact_list_get_account (list); - empathy_debug (DEBUG_DOMAIN, "Removing account: %s", - mc_account_get_display_name (account)); + DEBUG ("Removing account: %s", mc_account_get_display_name (account)); contact_manager_disconnect_foreach (account, list, manager); g_hash_table_remove (priv->lists, account); @@ -139,8 +138,7 @@ contact_manager_add_account (EmpathyContactManager *manager, return; } - empathy_debug (DEBUG_DOMAIN, "Adding new account: %s", - mc_account_get_display_name (account)); + DEBUG ("Adding new account: %s", mc_account_get_display_name (account)); list = empathy_tp_contact_list_new (account); if (!list) { diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index 87e7c62be..639cd9388 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -33,10 +33,10 @@ #include "empathy-contact.h" #include "empathy-utils.h" -#include "empathy-debug.h" #include "empathy-enum-types.h" -#define DEBUG_DOMAIN "Contact" +#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT +#include "empathy-debug.h" #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CONTACT, EmpathyContactPriv)) @@ -195,7 +195,7 @@ contact_finalize (GObject *object) priv = GET_PRIV (object); - empathy_debug (DEBUG_DOMAIN, "finalize: %p", object); + DEBUG ("finalize: %p", object); g_free (priv->name); g_free (priv->id); diff --git a/libempathy/empathy-debug.c b/libempathy/empathy-debug.c index d81e6dca7..f34e0be3f 100644 --- a/libempathy/empathy-debug.c +++ b/libempathy/empathy-debug.c @@ -1,134 +1,99 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Copyright (C) 2006-2007 Imendio AB + * Copyright (C) 2007 Collabora Ltd. + * Copyright (C) 2007 Nokia Corporation * - * 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 the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Richard Hult + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.h" +#include +#include #include -#include -#include -#include #include -#include -#include +#include #include -#include #include #include -/* Set EMPATHY_DEBUG to a colon/comma/space separated list of domains, or "all" - * to get all debug output. - */ - #include "empathy-debug.h" -static gchar **debug_strv; -static gboolean all_domains = FALSE; - -static void -debug_init (void) -{ - static gboolean inited = FALSE; - - if (!inited) { - const gchar *env; - gint i; +#ifdef ENABLE_DEBUG - env = g_getenv ("TELEPATHY_GLIB_DEBUG"); - tp_debug_set_flags (env); +static EmpathyDebugFlags flags = 0; - env = g_getenv ("EMPATHY_DEBUG"); +static GDebugKey keys[] = { + { "Tp", EMPATHY_DEBUG_TP }, + { "Chat", EMPATHY_DEBUG_CHAT }, + { "Contact", EMPATHY_DEBUG_CONTACT }, + { "Account", EMPATHY_DEBUG_ACCOUNT }, + { "Irc", EMPATHY_DEBUG_IRC }, + { "Filter", EMPATHY_DEBUG_FILTER }, + { "Other", EMPATHY_DEBUG_OTHER }, + { 0, } +}; - if (env) { - debug_strv = g_strsplit_set (env, ":, ", 0); - } else { - debug_strv = NULL; - } - - for (i = 0; debug_strv && debug_strv[i]; i++) { - if (strcmp ("all", debug_strv[i]) == 0) { - all_domains = TRUE; - } - } - - inited = TRUE; - } +static void +debug_set_flags (EmpathyDebugFlags new_flags) +{ + flags |= new_flags; + g_print ("%d\n", flags); } void -empathy_debug_impl (const gchar *domain, const gchar *msg, ...) +empathy_debug_set_flags (const gchar *flags_string) { - gint i; + guint nkeys; - g_return_if_fail (domain != NULL); - g_return_if_fail (msg != NULL); + for (nkeys = 0; keys[nkeys].value; nkeys++); +g_print ("%s %d\n", flags_string, nkeys); + //tp_debug_set_flags (flags_string); - debug_init (); - - for (i = 0; debug_strv && debug_strv[i]; i++) { - if (all_domains || strcmp (domain, debug_strv[i]) == 0) { - va_list args; - - g_print ("%s: ", domain); + if (flags_string) + debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys)); +} - va_start (args, msg); - g_vprintf (msg, args); - va_end (args); +gboolean +empathy_debug_flag_is_set (EmpathyDebugFlags flag) +{ + return (flag & flags) != 0; +} - g_print ("\n"); - break; - } - } +void +empathy_debug (EmpathyDebugFlags flag, + const gchar *format, + ...) +{ + if (flag & flags) + { + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args); + va_end (args); + } } +#else + void -empathy_debug_set_log_file_from_env (void) +empathy_debug_set_flags (const gchar *flags_string) { - const gchar *output_file; - gint out; - - output_file = g_getenv ("EMPATHY_LOGFILE"); - if (output_file == NULL) { - return; - } - - out = g_open (output_file, O_WRONLY | O_CREAT, 0644); - if (out == -1) { - g_warning ("Can't open logfile '%s': %s", output_file, - g_strerror (errno)); - return; - } - - if (dup2 (out, STDOUT_FILENO) == -1) { - g_warning ("Error when duplicating stdout file descriptor: %s", - g_strerror (errno)); - return; - } - - if (dup2 (out, STDERR_FILENO) == -1) { - g_warning ("Error when duplicating stderr file descriptor: %s", - g_strerror (errno)); - return; - } } +#endif /* ENABLE_DEBUG */ + diff --git a/libempathy/empathy-debug.h b/libempathy/empathy-debug.h index 55827d5c0..f0578640a 100644 --- a/libempathy/empathy-debug.h +++ b/libempathy/empathy-debug.h @@ -1,58 +1,94 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Copyright (C) 2006-2007 Imendio AB + * Copyright (C) 2007 Collabora Ltd. + * Copyright (C) 2007 Nokia Corporation * - * 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 the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Richard Hult + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __EMPATHY_DEBUG_H__ #define __EMPATHY_DEBUG_H__ +#include "config.h" + + #include +#include G_BEGIN_DECLS -#ifdef G_HAVE_ISO_VARARGS -# ifdef EMPATHY_DISABLE_DEBUG -# define empathy_debug(...) -# else -# define empathy_debug(...) empathy_debug_impl (__VA_ARGS__) -# endif -#elif defined(G_HAVE_GNUC_VARARGS) -# if EMPATHY_DISABLE_DEBUG -# define empathy_debug(fmt...) -# else -# define empathy_debug(fmt...) empathy_debug_impl(fmt) -# endif -#else -# if EMPATHY_DISABLE_DEBUG -# define empathy_debug(x) -# else -# define empathy_debug empathy_debug_impl -# endif -#endif - -void empathy_debug_impl (const gchar *domain, - const gchar *msg, - ...); -void empathy_debug_set_log_file_from_env (void); +#ifdef ENABLE_DEBUG + +/* Please keep this enum in sync with #keys in empathy-debug.c */ +typedef enum +{ + EMPATHY_DEBUG_TP = 1 << 1, + EMPATHY_DEBUG_CHAT = 1 << 2, + EMPATHY_DEBUG_CONTACT = 1 << 3, + EMPATHY_DEBUG_ACCOUNT = 1 << 4, + EMPATHY_DEBUG_IRC = 1 << 5, + EMPATHY_DEBUG_FILTER = 1 << 6, + EMPATHY_DEBUG_OTHER = 1 << 7, +} EmpathyDebugFlags; +gboolean empathy_debug_flag_is_set (EmpathyDebugFlags flag); +void empathy_debug (EmpathyDebugFlags flag, const gchar *format, ...) + G_GNUC_PRINTF (2, 3); + +#endif /* ENABLE_DEBUG */ + +void empathy_debug_set_flags (const gchar *flags_string); G_END_DECLS #endif /* __EMPATHY_DEBUG_H__ */ +/* ------------------------------------ */ + +/* Below this point is outside the __DEBUG_H__ guard - so it can take effect + * more than once. So you can do: + * + * #define DEBUG_FLAG EMPATHY_DEBUG_ONE_THING + * #include "internal-debug.h" + * ... + * DEBUG ("if we're debugging one thing"); + * ... + * #undef DEBUG_FLAG + * #define DEBUG_FLAG EMPATHY_DEBUG_OTHER_THING + * #include "internal-debug.h" + * ... + * DEBUG ("if we're debugging the other thing"); + * ... + */ + +#ifdef DEBUG_FLAG +#ifdef ENABLE_DEBUG + +#undef DEBUG +#define DEBUG(format, ...) \ + empathy_debug (DEBUG_FLAG, "%s: " format, G_STRFUNC, ##__VA_ARGS__) + +#undef DEBUGGING +#define DEBUGGING empathy_debug_flag_is_set (DEBUG_FLAG) + +#else /* !defined (ENABLE_DEBUG) */ + +#undef DEBUG +#define DEBUG(format, ...) do {} while (0) + +#undef DEBUGGING +#define DEBUGGING 0 + +#endif /* !defined (ENABLE_DEBUG) */ +#endif /* defined (DEBUG_FLAG) */ diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c index d5ce3bd9b..b6566a6f6 100644 --- a/libempathy/empathy-idle.c +++ b/libempathy/empathy-idle.c @@ -33,11 +33,12 @@ #include "empathy-utils.h" #include "empathy-debug.h" +#define DEBUG_FLAG EMPATHY_DEBUG_OTHER +#include "empathy-debug.h" + #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ EMPATHY_TYPE_IDLE, EmpathyIdlePriv)) -#define DEBUG_DOMAIN "Idle" - /* Number of seconds before entering extended autoaway. */ #define EXT_AWAY_TIME (30*60) @@ -189,14 +190,14 @@ empathy_idle_init (EmpathyIdle *idle) G_CALLBACK (idle_session_idle_changed_cb), idle, NULL); } else { - empathy_debug (DEBUG_DOMAIN, "Failed to get gs proxy"); + DEBUG ("Failed to get gs proxy"); } system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); if (!system_bus) { - empathy_debug (DEBUG_DOMAIN, "Failed to get system bus: %s", - error ? error->message : "No error given"); + DEBUG ("Failed to get system bus: %s", + error ? error->message : "No error given"); } else { priv->nm_proxy = dbus_g_proxy_new_for_name (system_bus, "org.freedesktop.NetworkManager", @@ -210,7 +211,7 @@ empathy_idle_init (EmpathyIdle *idle) G_CALLBACK (idle_nm_state_change_cb), idle, NULL); } else { - empathy_debug (DEBUG_DOMAIN, "Failed to get nm proxy"); + DEBUG ("Failed to get nm proxy"); } priv->nm_connected = TRUE; @@ -398,11 +399,11 @@ empathy_idle_set_presence (EmpathyIdle *idle, priv = GET_PRIV (idle); - empathy_debug (DEBUG_DOMAIN, "Changing presence to %s (%d)", + DEBUG ("Changing presence to %s (%d)", status, state); if (!priv->nm_connected) { - empathy_debug (DEBUG_DOMAIN, "NM not connected"); + DEBUG ("NM not connected"); return; } @@ -468,9 +469,7 @@ empathy_idle_set_use_nm (EmpathyIdle *idle, G_TYPE_INVALID); if (error) { - empathy_debug (DEBUG_DOMAIN, - "Couldn't get NM state: %s", - error->message); + DEBUG ("Couldn't get NM state: %s", error->message); g_clear_error (&error); nm_status = NM_STATE_ASLEEP; } @@ -497,8 +496,7 @@ idle_presence_changed_cb (MissionControl *mc, priv = GET_PRIV (idle); - empathy_debug (DEBUG_DOMAIN, "Presence changed to '%s' (%d)", - status, state); + DEBUG ("Presence changed to '%s' (%d)", status, state); g_free (priv->status); priv->state = state; @@ -520,9 +518,9 @@ idle_session_idle_changed_cb (DBusGProxy *gs_proxy, priv = GET_PRIV (idle); - empathy_debug (DEBUG_DOMAIN, "Session idle state changed, %s -> %s", - priv->is_idle ? "yes" : "no", - is_idle ? "yes" : "no"); + DEBUG ("Session idle state changed, %s -> %s", + priv->is_idle ? "yes" : "no", + is_idle ? "yes" : "no"); if (priv->state <= MC_PRESENCE_OFFLINE || priv->state == MC_PRESENCE_HIDDEN || @@ -550,7 +548,7 @@ idle_session_idle_changed_cb (DBusGProxy *gs_proxy, priv->away_reset_status = FALSE; } - empathy_debug (DEBUG_DOMAIN, "Going to autoaway"); + DEBUG ("Going to autoaway"); empathy_idle_set_state (idle, new_state); idle_ext_away_start (idle); @@ -558,9 +556,9 @@ idle_session_idle_changed_cb (DBusGProxy *gs_proxy, /* We are no more idle, restore state */ idle_ext_away_stop (idle); - empathy_debug (DEBUG_DOMAIN, "Restoring state to %d, reset status: %s", - priv->away_saved_state, - priv->away_reset_status ? "Yes" : "No"); + DEBUG ("Restoring state to %d, reset status: %s", + priv->away_saved_state, + priv->away_reset_status ? "Yes" : "No"); if (priv->nm_connected) { empathy_idle_set_presence (idle, @@ -591,8 +589,8 @@ idle_nm_state_change_cb (DBusGProxy *proxy, priv = GET_PRIV (idle); - empathy_debug (DEBUG_DOMAIN, "New network state (%d), in use = %s", - state, priv->use_nm ? "Yes" : "No"); + DEBUG ("New network state (%d), in use = %s", + state, priv->use_nm ? "Yes" : "No"); if (!priv->use_nm) { return; @@ -655,7 +653,7 @@ idle_ext_away_cb (EmpathyIdle *idle) priv = GET_PRIV (idle); - empathy_debug (DEBUG_DOMAIN, "Going to extended autoaway"); + DEBUG ("Going to extended autoaway"); empathy_idle_set_state (idle, MC_PRESENCE_EXTENDED_AWAY); priv->ext_away_timeout = 0; diff --git a/libempathy/empathy-irc-network-manager.c b/libempathy/empathy-irc-network-manager.c index f88b93bc7..e919d9cbb 100644 --- a/libempathy/empathy-irc-network-manager.c +++ b/libempathy/empathy-irc-network-manager.c @@ -30,7 +30,9 @@ #include "empathy-utils.h" #include "empathy-irc-network-manager.h" -#define DEBUG_DOMAIN "IrcNetworkManager" +#define DEBUG_FLAG EMPATHY_DEBUG_IRC +#include "empathy-debug.h" + #define IRC_NETWORKS_DTD_FILENAME "empathy-irc-networks.dtd" #define SAVE_TIMER 4 @@ -336,12 +338,11 @@ empathy_irc_network_manager_add (EmpathyIrcNetworkManager *self, if (priv->last_id == G_MAXUINT) { - empathy_debug (DEBUG_DOMAIN, - "Can't add network: too many networks using a similiar ID"); + DEBUG ("Can't add network: too many networks using a similiar ID"); return; } - empathy_debug (DEBUG_DOMAIN, "add server with \"%s\" as ID", id); + DEBUG ("add server with \"%s\" as ID", id); network->user_defined = TRUE; add_network (self, network, id); @@ -429,8 +430,7 @@ load_global_file (EmpathyIrcNetworkManager *self) if (!g_file_test (priv->global_file, G_FILE_TEST_EXISTS)) { - empathy_debug (DEBUG_DOMAIN, "Global networks file %s doesn't exist", - priv->global_file); + DEBUG ("Global networks file %s doesn't exist", priv->global_file); return; } @@ -448,8 +448,7 @@ load_user_file (EmpathyIrcNetworkManager *self) if (!g_file_test (priv->user_file, G_FILE_TEST_EXISTS)) { - empathy_debug (DEBUG_DOMAIN, "User networks file %s doesn't exist", - priv->global_file); + DEBUG ("User networks file %s doesn't exist", priv->global_file); return; } @@ -504,8 +503,7 @@ irc_network_manager_parse_irc_server (EmpathyIrcNetwork *network, if (ssl == NULL || strcmp (ssl, "TRUE") == 0) have_ssl = TRUE; - empathy_debug (DEBUG_DOMAIN, "parsed server %s port %d ssl %d", - address, port_nb, have_ssl); + DEBUG ("parsed server %s port %d ssl %d", address, port_nb, have_ssl); server = empathy_irc_server_new (address, port_nb, have_ssl); empathy_irc_network_append_server (network, server); @@ -537,8 +535,7 @@ irc_network_manager_parse_irc_network (EmpathyIrcNetworkManager *self, { if (!user_defined) { - empathy_debug (DEBUG_DOMAIN, "the \"dropped\" attribute shouldn't be" - " used in the global file"); + DEBUG ("the 'dropped' attribute shouldn't be used in the global file"); } network = g_hash_table_lookup (priv->networks, id); @@ -566,7 +563,7 @@ irc_network_manager_parse_irc_network (EmpathyIrcNetworkManager *self, } add_network (self, network, id); - empathy_debug (DEBUG_DOMAIN, "add network %s (id %s)", name, id); + DEBUG ("add network %s (id %s)", name, id); for (child = node->children; child; child = child->next) { @@ -605,7 +602,7 @@ irc_network_manager_file_parse (EmpathyIrcNetworkManager *self, priv = EMPATHY_IRC_NETWORK_MANAGER_GET_PRIVATE (self); - empathy_debug (DEBUG_DOMAIN, "Attempting to parse file:'%s'...", filename); + DEBUG ("Attempting to parse file:'%s'...", filename); ctxt = xmlNewParserCtxt (); @@ -717,11 +714,11 @@ irc_network_manager_file_save (EmpathyIrcNetworkManager *self) if (priv->user_file == NULL) { - empathy_debug (DEBUG_DOMAIN, "can't save: no user file defined"); + DEBUG ("can't save: no user file defined"); return FALSE; } - empathy_debug (DEBUG_DOMAIN, "Saving IRC networks"); + DEBUG ("Saving IRC networks"); doc = xmlNewDoc ("1.0"); root = xmlNewNode (NULL, "networks"); diff --git a/libempathy/empathy-log-manager.c b/libempathy/empathy-log-manager.c index 2904407b5..081807fe7 100644 --- a/libempathy/empathy-log-manager.c +++ b/libempathy/empathy-log-manager.c @@ -31,14 +31,14 @@ #include "empathy-log-manager.h" #include "empathy-contact.h" #include "empathy-time.h" -#include "empathy-debug.h" #include "empathy-utils.h" +#define DEBUG_FLAG EMPATHY_DEBUG_OTHER +#include "empathy-debug.h" + #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ EMPATHY_TYPE_LOG_MANAGER, EmpathyLogManagerPriv)) -#define DEBUG_DOMAIN "LogManager" - #define LOG_DIR_CREATE_MODE (S_IRUSR | S_IWUSR | S_IXUSR) #define LOG_FILE_CREATE_MODE (S_IRUSR | S_IWUSR) #define LOG_DIR_CHATROOMS "chatrooms" @@ -164,14 +164,13 @@ empathy_log_manager_add_message (EmpathyLogManager *manager, filename = log_manager_get_filename (manager, account, chat_id, chatroom); basedir = g_path_get_dirname (filename); if (!g_file_test (basedir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - empathy_debug (DEBUG_DOMAIN, "Creating directory:'%s'", basedir); + DEBUG ("Creating directory:'%s'", basedir); g_mkdir_with_parents (basedir, LOG_DIR_CREATE_MODE); } g_free (basedir); - empathy_debug (DEBUG_DOMAIN, "Adding message: '%s' to file: '%s'", - body_str, filename); + DEBUG ("Adding message: '%s' to file: '%s'", body_str, filename); if (!g_file_test (filename, G_FILE_TEST_EXISTS)) { file = g_fopen (filename, "w+"); @@ -255,12 +254,12 @@ empathy_log_manager_get_dates (EmpathyLogManager *manager, directory = log_manager_get_dir (manager, account, chat_id, chatroom); dir = g_dir_open (directory, 0, NULL); if (!dir) { - empathy_debug (DEBUG_DOMAIN, "Could not open directory:'%s'", directory); + DEBUG ("Could not open directory:'%s'", directory); g_free (directory); return NULL; } - empathy_debug (DEBUG_DOMAIN, "Collating a list of dates in:'%s'", directory); + DEBUG ("Collating a list of dates in:'%s'", directory); while ((filename = g_dir_read_name (dir)) != NULL) { if (!g_str_has_suffix (filename, LOG_FILENAME_SUFFIX)) { @@ -283,7 +282,7 @@ empathy_log_manager_get_dates (EmpathyLogManager *manager, g_free (directory); g_dir_close (dir); - empathy_debug (DEBUG_DOMAIN, "Parsed %d dates", g_list_length (dates)); + DEBUG ("Parsed %d dates", g_list_length (dates)); return dates; } @@ -303,10 +302,10 @@ empathy_log_manager_get_messages_for_file (EmpathyLogManager *manager, g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), NULL); g_return_val_if_fail (filename != NULL, NULL); - empathy_debug (DEBUG_DOMAIN, "Attempting to parse filename:'%s'...", filename); + DEBUG ("Attempting to parse filename:'%s'...", filename); if (!g_file_test (filename, G_FILE_TEST_EXISTS)) { - empathy_debug (DEBUG_DOMAIN, "Filename:'%s' does not exist", filename); + DEBUG ("Filename:'%s' does not exist", filename); return NULL; } @@ -397,7 +396,7 @@ empathy_log_manager_get_messages_for_file (EmpathyLogManager *manager, xmlFree (msg_type_str); } - empathy_debug (DEBUG_DOMAIN, "Parsed %d messages", g_list_length (messages)); + DEBUG ("Parsed %d messages", g_list_length (messages)); xmlFreeDoc (doc); xmlFreeParserCtxt (ctxt); @@ -486,8 +485,7 @@ empathy_log_manager_search_new (EmpathyLogManager *manager, text_casefold = g_utf8_casefold (text, -1); files = log_manager_get_all_files (manager, NULL); - empathy_debug (DEBUG_DOMAIN, "Found %d log files in total", - g_list_length (files)); + DEBUG ("Found %d log files in total", g_list_length (files)); for (l = files; l; l = l->next) { gchar *filename; @@ -516,9 +514,8 @@ empathy_log_manager_search_new (EmpathyLogManager *manager, if (hit) { hits = g_list_prepend (hits, hit); - empathy_debug (DEBUG_DOMAIN, - "Found text:'%s' in file:'%s' on date:'%s'...", - text, hit->filename, hit->date); + DEBUG ("Found text:'%s' in file:'%s' on date:'%s'", + text, hit->filename, hit->date); } } diff --git a/libempathy/empathy-status-presets.c b/libempathy/empathy-status-presets.c index 89b1874f3..b5e1f9bf8 100644 --- a/libempathy/empathy-status-presets.c +++ b/libempathy/empathy-status-presets.c @@ -34,11 +34,11 @@ #include -#include "empathy-debug.h" #include "empathy-utils.h" #include "empathy-status-presets.h" -#define DEBUG_DOMAIN "StatusPresets" +#define DEBUG_FLAG EMPATHY_DEBUG_OTHER +#include "empathy-debug.h" #define STATUS_PRESETS_XML_FILENAME "status-presets.xml" #define STATUS_PRESETS_DTD_FILENAME "empathy-status-presets.dtd" @@ -90,7 +90,7 @@ status_presets_file_parse (const gchar *filename) xmlNodePtr presets_node; xmlNodePtr node; - empathy_debug (DEBUG_DOMAIN, "Attempting to parse file:'%s'...", filename); + DEBUG ("Attempting to parse file:'%s'...", filename); ctxt = xmlNewParserCtxt (); @@ -133,9 +133,9 @@ status_presets_file_parse (const gchar *filename) state = empathy_presence_from_str (state_str); if (is_default) { - empathy_debug (DEBUG_DOMAIN, - "Default status preset state is:'%s', status:'%s'", - state_str, status); + DEBUG ("Default status preset state is:" + " '%s', status:'%s'", state_str, + status); status_presets_set_default (state, status); } else { @@ -156,7 +156,7 @@ status_presets_file_parse (const gchar *filename) status_presets_set_default (MC_PRESENCE_OFFLINE, NULL); } - empathy_debug (DEBUG_DOMAIN, "Parsed %d status presets", g_list_length (presets)); + DEBUG ("Parsed %d status presets", g_list_length (presets)); xmlFreeDoc (doc); xmlFreeParserCtxt (ctxt); @@ -243,7 +243,7 @@ status_presets_file_save (void) /* Make sure the XML is indented properly */ xmlIndentTreeOutput = 1; - empathy_debug (DEBUG_DOMAIN, "Saving file:'%s'", file); + DEBUG ("Saving file:'%s'", file); xmlSaveFormatFileEnc (file, doc, "utf-8", 1); xmlFreeDoc (doc); diff --git a/libempathy/empathy-tp-call.c b/libempathy/empathy-tp-call.c index 73ec8e992..4c3779f28 100644 --- a/libempathy/empathy-tp-call.c +++ b/libempathy/empathy-tp-call.c @@ -28,13 +28,13 @@ #include #include -#include #include #include #include "empathy-tp-call.h" -#define DEBUG_DOMAIN "TpCall" +#define DEBUG_FLAG EMPATHY_DEBUG_TP +#include "empathy-debug.h" #define GET_PRIV(object) (G_TYPE_INSTANCE_GET_PRIVATE \ ((object), EMPATHY_TYPE_TP_CALL, EmpathyTpCallPriv)) @@ -85,8 +85,7 @@ tp_call_add_stream (EmpathyTpCall *call, switch (stream_type) { case TP_MEDIA_STREAM_TYPE_AUDIO: - empathy_debug (DEBUG_DOMAIN, - "Audio stream - id: %d, state: %d, direction: %d", + DEBUG ("Audio stream - id: %d, state: %d, direction: %d", stream_id, stream_state, stream_direction); priv->audio->exists = TRUE; priv->audio->id = stream_id; @@ -95,8 +94,7 @@ tp_call_add_stream (EmpathyTpCall *call, g_object_notify (G_OBJECT (call), "audio-stream"); break; case TP_MEDIA_STREAM_TYPE_VIDEO: - empathy_debug (DEBUG_DOMAIN, - "Video stream - id: %d, state: %d, direction: %d", + DEBUG ("Video stream - id: %d, state: %d, direction: %d", stream_id, stream_state, stream_direction); priv->video->exists = TRUE; priv->video->id = stream_id; @@ -105,8 +103,7 @@ tp_call_add_stream (EmpathyTpCall *call, g_object_notify (G_OBJECT (call), "video-stream"); break; default: - empathy_debug (DEBUG_DOMAIN, "Unknown stream type: %d", - stream_type); + DEBUG ("Unknown stream type: %d", stream_type); } } @@ -118,8 +115,7 @@ tp_call_stream_added_cb (TpChannel *channel, gpointer user_data, GObject *call) { - empathy_debug (DEBUG_DOMAIN, - "Stream added - stream id: %d, contact handle: %d, stream type: %d", + DEBUG ("Stream added - stream id: %d, contact handle: %d, stream type: %d", stream_id, contact_handle, stream_type); tp_call_add_stream (EMPATHY_TP_CALL (call), stream_id, contact_handle, @@ -135,7 +131,7 @@ tp_call_stream_removed_cb (TpChannel *channel, { EmpathyTpCallPriv *priv = GET_PRIV (call); - empathy_debug (DEBUG_DOMAIN, "Stream removed - stream id: %d", stream_id); + DEBUG ("Stream removed - stream id: %d", stream_id); if (stream_id == priv->audio->id) { @@ -158,8 +154,7 @@ tp_call_stream_state_changed_cb (TpChannel *proxy, { EmpathyTpCallPriv *priv = GET_PRIV (call); - empathy_debug (DEBUG_DOMAIN, - "Stream state changed - stream id: %d, state state: %d", + DEBUG ("Stream state changed - stream id: %d, state state: %d", stream_id, stream_state); if (stream_id == priv->audio->id) @@ -184,8 +179,7 @@ tp_call_stream_direction_changed_cb (TpChannel *channel, { EmpathyTpCallPriv *priv = GET_PRIV (call); - empathy_debug (DEBUG_DOMAIN, - "Stream direction changed - stream: %d, direction: %d", + DEBUG ("Stream direction changed - stream: %d, direction: %d", stream_id, stream_direction); if (stream_id == priv->audio->id) @@ -211,7 +205,7 @@ tp_call_request_streams_cb (TpChannel *channel, if (error) { - empathy_debug (DEBUG_DOMAIN, "Error requesting streams: %s", error->message); + DEBUG ("Error requesting streams: %s", error->message); return; } @@ -248,7 +242,7 @@ tp_call_request_streams_for_capabilities (EmpathyTpCall *call, if (capabilities == EMPATHY_CAPABILITIES_UNKNOWN) capabilities = EMPATHY_CAPABILITIES_AUDIO | EMPATHY_CAPABILITIES_VIDEO; - empathy_debug (DEBUG_DOMAIN, "Requesting new stream for capabilities %d", + DEBUG ("Requesting new stream for capabilities %d", capabilities); stream_types = g_array_new (FALSE, FALSE, sizeof (guint)); @@ -342,7 +336,7 @@ tp_call_channel_invalidated_cb (TpChannel *channel, { EmpathyTpCallPriv *priv = GET_PRIV (call); - empathy_debug (DEBUG_DOMAIN, "Channel invalidated: %s", message); + DEBUG ("Channel invalidated: %s", message); priv->status = EMPATHY_TP_CALL_STATUS_CLOSED; g_object_notify (G_OBJECT (call), "status"); } @@ -355,8 +349,7 @@ tp_call_async_cb (TpProxy *proxy, { if (error) { - empathy_debug (DEBUG_DOMAIN, "Error %s: %s", - user_data, error->message); + DEBUG ("Error %s: %s", (gchar*) user_data, error->message); } } @@ -368,7 +361,7 @@ tp_call_close_channel (EmpathyTpCall *call) if (priv->status == EMPATHY_TP_CALL_STATUS_CLOSED) return; - empathy_debug (DEBUG_DOMAIN, "Closing channel"); + DEBUG ("Closing channel"); tp_cli_channel_call_close (priv->channel, -1, NULL, NULL, NULL, NULL); @@ -384,8 +377,7 @@ tp_call_stream_engine_invalidated_cb (TpProxy *stream_engine, gchar *message, EmpathyTpCall *call) { - empathy_debug (DEBUG_DOMAIN, "Stream engine proxy invalidated: %s", - message); + DEBUG ("Stream engine proxy invalidated: %s", message); tp_call_close_channel (call); } @@ -400,13 +392,12 @@ tp_call_stream_engine_watch_name_owner_cb (TpDBusDaemon *daemon, /* G_STR_EMPTY(new_owner) means either stream-engine has not started yet or * has crashed. We want to close the channel if stream-engine has crashed. * */ - empathy_debug (DEBUG_DOMAIN, - "Watch SE: name='%s' SE running='%s' new_owner='%s'", - name, priv->stream_engine_running ? "yes" : "no", - new_owner ? new_owner : "none"); + DEBUG ("Watch SE: name='%s' SE running='%s' new_owner='%s'", + name, priv->stream_engine_running ? "yes" : "no", + new_owner ? new_owner : "none"); if (priv->stream_engine_running && G_STR_EMPTY (new_owner)) { - empathy_debug (DEBUG_DOMAIN, "Stream engine falled off the bus"); + DEBUG ("Stream engine falled off the bus"); tp_call_close_channel (call); return; } @@ -424,7 +415,7 @@ tp_call_stream_engine_handle_channel (EmpathyTpCall *call) guint handle; TpProxy *connection; - empathy_debug (DEBUG_DOMAIN, "Revving up the stream engine"); + DEBUG ("Revving up the stream engine"); priv->stream_engine = g_object_new (TP_TYPE_PROXY, "bus-name", STREAM_ENGINE_BUS_NAME, @@ -514,7 +505,7 @@ tp_call_finalize (GObject *object) { EmpathyTpCallPriv *priv = GET_PRIV (object); - empathy_debug (DEBUG_DOMAIN, "Finalizing: %p", object); + DEBUG ("Finalizing: %p", object); g_slice_free (EmpathyTpCallStream, priv->audio); g_slice_free (EmpathyTpCallStream, priv->video); @@ -677,7 +668,7 @@ empathy_tp_call_accept_incoming_call (EmpathyTpCall *call) g_return_if_fail (EMPATHY_IS_TP_CALL (call)); g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_PENDING); - empathy_debug (DEBUG_DOMAIN, "Accepting incoming call"); + DEBUG ("Accepting incoming call"); self_contact = empathy_tp_group_get_self_contact (priv->group); empathy_tp_group_add_member (priv->group, self_contact, NULL); @@ -694,8 +685,7 @@ empathy_tp_call_request_video_stream_direction (EmpathyTpCall *call, g_return_if_fail (EMPATHY_IS_TP_CALL (call)); g_return_if_fail (priv->status == EMPATHY_TP_CALL_STATUS_ACCEPTED); - empathy_debug (DEBUG_DOMAIN, - "Requesting video stream direction - is_sending: %d", is_sending); + DEBUG ("Requesting video stream direction - is_sending: %d", is_sending); if (!priv->video->exists) { @@ -724,7 +714,7 @@ empathy_tp_call_add_preview_video (EmpathyTpCall *call, g_return_if_fail (EMPATHY_IS_TP_CALL (call)); - empathy_debug (DEBUG_DOMAIN, "Adding preview video"); + DEBUG ("Adding preview video"); emp_cli_stream_engine_call_add_preview_window (priv->stream_engine, -1, preview_video_socket_id, @@ -741,7 +731,7 @@ empathy_tp_call_remove_preview_video (EmpathyTpCall *call, g_return_if_fail (EMPATHY_IS_TP_CALL (call)); - empathy_debug (DEBUG_DOMAIN, "Removing preview video"); + DEBUG ("Removing preview video"); emp_cli_stream_engine_call_remove_preview_window (priv->stream_engine, -1, preview_video_socket_id, @@ -758,8 +748,7 @@ empathy_tp_call_add_output_video (EmpathyTpCall *call, g_return_if_fail (EMPATHY_IS_TP_CALL (call)); - empathy_debug (DEBUG_DOMAIN, "Adding output video - socket: %d", - output_video_socket_id); + DEBUG ("Adding output video - socket: %d", output_video_socket_id); emp_cli_stream_engine_call_set_output_window (priv->stream_engine, -1, TP_PROXY (priv->channel)->object_path, @@ -778,7 +767,7 @@ empathy_tp_call_set_output_volume (EmpathyTpCall *call, g_return_if_fail (EMPATHY_IS_TP_CALL (call)); g_return_if_fail (priv->status != EMPATHY_TP_CALL_STATUS_CLOSED); - empathy_debug (DEBUG_DOMAIN, "Setting output volume: %d", volume); + DEBUG ("Setting output volume: %d", volume); emp_cli_stream_engine_call_set_output_volume (priv->stream_engine, -1, TP_PROXY (priv->channel)->object_path, @@ -796,7 +785,7 @@ empathy_tp_call_mute_output (EmpathyTpCall *call, g_return_if_fail (EMPATHY_IS_TP_CALL (call)); - empathy_debug (DEBUG_DOMAIN, "Setting output mute: %d", is_muted); + DEBUG ("Setting output mute: %d", is_muted); emp_cli_stream_engine_call_mute_output (priv->stream_engine, -1, TP_PROXY (priv->channel)->object_path, @@ -814,7 +803,7 @@ empathy_tp_call_mute_input (EmpathyTpCall *call, g_return_if_fail (EMPATHY_IS_TP_CALL (call)); - empathy_debug (DEBUG_DOMAIN, "Setting input mute: %d", is_muted); + DEBUG ("Setting input mute: %d", is_muted); emp_cli_stream_engine_call_mute_input (priv->stream_engine, -1, TP_PROXY (priv->channel)->object_path, diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index c53bd1b72..61859c96e 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -31,15 +31,15 @@ #include "empathy-contact-factory.h" #include "empathy-contact-list.h" #include "empathy-marshal.h" -#include "empathy-debug.h" #include "empathy-time.h" #include "empathy-utils.h" +#define DEBUG_FLAG EMPATHY_DEBUG_TP | EMPATHY_DEBUG_CHAT +#include "empathy-debug.h" + #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ EMPATHY_TYPE_TP_CHAT, EmpathyTpChatPriv)) -#define DEBUG_DOMAIN "TpChat" - struct _EmpathyTpChatPriv { EmpathyContactFactory *factory; EmpathyContact *user; @@ -98,7 +98,7 @@ tp_chat_invalidated_cb (TpProxy *proxy, gchar *message, EmpathyTpChat *chat) { - empathy_debug (DEBUG_DOMAIN, "Channel invalidated: %s", message); + DEBUG ("Channel invalidated: %s", message); g_signal_emit (chat, signals[DESTROY], 0); } @@ -109,8 +109,7 @@ tp_chat_async_cb (TpChannel *proxy, GObject *weak_object) { if (error) { - empathy_debug (DEBUG_DOMAIN, "Error %s: %s", - user_data, error->message); + DEBUG ("Error %s: %s", (gchar*) user_data, error->message); } } @@ -309,7 +308,7 @@ tp_chat_sender_ready_notify_cb (EmpathyContact *contact, break; } - empathy_debug (DEBUG_DOMAIN, "Queued message ready"); + DEBUG ("Queued message ready"); g_signal_emit (chat, signals[MESSAGE_RECEIVED], 0, message); priv->message_queue = g_slist_remove (priv->message_queue, message); @@ -339,7 +338,7 @@ tp_chat_emit_or_queue_message (EmpathyTpChat *chat, EmpathyContactReady ready; if (priv->message_queue != NULL) { - empathy_debug (DEBUG_DOMAIN, "Message queue not empty"); + DEBUG ("Message queue not empty"); priv->message_queue = g_slist_append (priv->message_queue, g_object_ref (message)); return; @@ -348,12 +347,12 @@ tp_chat_emit_or_queue_message (EmpathyTpChat *chat, sender = empathy_message_get_sender (message); ready = empathy_contact_get_ready (sender); if (ready & EMPATHY_CONTACT_READY_NAME) { - empathy_debug (DEBUG_DOMAIN, "Message queue empty and sender ready"); + DEBUG ("Message queue empty and sender ready"); g_signal_emit (chat, signals[MESSAGE_RECEIVED], 0, message); return; } - empathy_debug (DEBUG_DOMAIN, "Sender not ready"); + DEBUG ("Sender not ready"); priv->message_queue = g_slist_append (priv->message_queue, g_object_ref (message)); g_signal_connect (sender, "notify::ready", @@ -379,7 +378,7 @@ tp_chat_received_cb (TpChannel *channel, return; } - empathy_debug (DEBUG_DOMAIN, "Message received: %s", message_body); + DEBUG ("Message received: %s", message_body); message = tp_chat_build_message (EMPATHY_TP_CHAT (chat), message_type, @@ -416,7 +415,7 @@ tp_chat_sent_cb (TpChannel *channel, { EmpathyMessage *message; - empathy_debug (DEBUG_DOMAIN, "Message sent: %s", message_body); + DEBUG ("Message sent: %s", message_body); message = tp_chat_build_message (EMPATHY_TP_CHAT (chat), message_type, @@ -439,8 +438,7 @@ tp_chat_send_error_cb (TpChannel *channel, { EmpathyMessage *message; - empathy_debug (DEBUG_DOMAIN, "Message sent error: %s (%d)", - message_body, error_code); + DEBUG ("Message sent error: %s (%d)", message_body, error_code); message = tp_chat_build_message (EMPATHY_TP_CHAT (chat), message_type, @@ -466,9 +464,8 @@ tp_chat_state_changed_cb (TpChannel *channel, priv->account, handle); - empathy_debug (DEBUG_DOMAIN, "Chat state changed for %s (%d): %d", - empathy_contact_get_name (contact), - handle, state); + DEBUG ("Chat state changed for %s (%d): %d", + empathy_contact_get_name (contact), handle, state); g_signal_emit (chat, signals[CHAT_STATE_CHANGED], 0, contact, state); g_object_unref (contact); @@ -488,8 +485,7 @@ tp_chat_list_pending_messages_cb (TpChannel *channel, priv->had_pending_messages = TRUE; if (error) { - empathy_debug (DEBUG_DOMAIN, "Error listing pending messages: %s", - error->message); + DEBUG ("Error listing pending messages: %s", error->message); return; } @@ -517,7 +513,7 @@ tp_chat_list_pending_messages_cb (TpChannel *channel, message_flags = g_value_get_uint (g_value_array_get_nth (message_struct, 4)); message_body = g_value_get_string (g_value_array_get_nth (message_struct, 5)); - empathy_debug (DEBUG_DOMAIN, "Message pending: %s", message_body); + DEBUG ("Message pending: %s", message_body); if (message_ids) { g_array_append_val (message_ids, message_id); @@ -572,9 +568,8 @@ tp_chat_property_flags_changed_cb (TpProxy *proxy, property = g_ptr_array_index (priv->properties, j); if (property->id == id) { property->flags = flags; - empathy_debug (DEBUG_DOMAIN, - "property %s flags changed: %d", - property->name, property->flags); + DEBUG ("property %s flags changed: %d", + property->name, property->flags); break; } } @@ -613,8 +608,7 @@ tp_chat_properties_changed_cb (TpProxy *proxy, property->value = tp_g_value_slice_dup (src_value); } - empathy_debug (DEBUG_DOMAIN, "property %s changed", - property->name); + DEBUG ("property %s changed", property->name); g_signal_emit (chat, signals[PROPERTY_CHANGED], 0, property->name, property->value); break; @@ -631,8 +625,7 @@ tp_chat_get_properties_cb (TpProxy *proxy, GObject *chat) { if (error) { - empathy_debug (DEBUG_DOMAIN, "Error getting properties: %s", - error->message); + DEBUG ("Error getting properties: %s", error->message); return; } @@ -653,8 +646,7 @@ tp_chat_list_properties_cb (TpProxy *proxy, priv->had_properties_list = TRUE; if (error) { - empathy_debug (DEBUG_DOMAIN, "Error listing properties: %s", - error->message); + DEBUG ("Error listing properties: %s", error->message); return; } @@ -670,8 +662,8 @@ tp_chat_list_properties_cb (TpProxy *proxy, property->name = g_value_dup_string (g_value_array_get_nth (prop_struct, 1)); property->flags = g_value_get_uint (g_value_array_get_nth (prop_struct, 3)); - empathy_debug (DEBUG_DOMAIN, "Adding property name=%s id=%d flags=%d", - property->name, property->id, property->flags); + DEBUG ("Adding property name=%s id=%d flags=%d", + property->name, property->id, property->flags); g_ptr_array_add (priv->properties, property); if (property->flags & TP_PROPERTY_FLAG_READ) { g_array_append_val (ids, property->id); @@ -722,7 +714,7 @@ empathy_tp_chat_set_property (EmpathyTpChat *chat, properties = g_ptr_array_sized_new (1); g_ptr_array_add (properties, prop); - empathy_debug (DEBUG_DOMAIN, "Set property %s", name); + DEBUG ("Set property %s", name); tp_cli_properties_interface_call_set_properties (priv->channel, -1, properties, (tp_cli_properties_interface_callback_for_set_properties) @@ -745,7 +737,7 @@ tp_chat_channel_ready_cb (EmpathyTpChat *chat) TpConnection *connection; guint handle, handle_type; - empathy_debug (DEBUG_DOMAIN, "Channel ready"); + DEBUG ("Channel ready"); g_object_get (priv->channel, "connection", &connection, @@ -846,7 +838,7 @@ tp_chat_finalize (GObject *object) guint i; if (priv->acknowledge && priv->channel) { - empathy_debug (DEBUG_DOMAIN, "Closing channel..."); + DEBUG ("Closing channel..."); tp_cli_channel_call_close (priv->channel, -1, tp_chat_async_cb, "closing channel", NULL, @@ -1191,7 +1183,7 @@ empathy_tp_chat_send (EmpathyTpChat *chat, message_body = empathy_message_get_body (message); message_type = empathy_message_get_type (message); - empathy_debug (DEBUG_DOMAIN, "Sending message: %s", message_body); + DEBUG ("Sending message: %s", message_body); tp_cli_channel_type_text_call_send (priv->channel, -1, message_type, message_body, @@ -1209,7 +1201,7 @@ empathy_tp_chat_set_state (EmpathyTpChat *chat, g_return_if_fail (EMPATHY_IS_TP_CHAT (chat)); g_return_if_fail (priv->ready); - empathy_debug (DEBUG_DOMAIN, "Set state: %d", state); + DEBUG ("Set state: %d", state); tp_cli_channel_interface_chat_state_call_set_chat_state (priv->channel, -1, state, tp_chat_async_cb, diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c index 25ebceb5f..eeb4ece71 100644 --- a/libempathy/empathy-tp-contact-factory.c +++ b/libempathy/empathy-tp-contact-factory.c @@ -29,13 +29,13 @@ #include "empathy-tp-contact-factory.h" #include "empathy-utils.h" + +#define DEBUG_FLAG EMPATHY_DEBUG_TP | EMPATHY_DEBUG_CONTACT #include "empathy-debug.h" #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ EMPATHY_TYPE_TP_CONTACT_FACTORY, EmpathyTpContactFactoryPriv)) -#define DEBUG_DOMAIN "TpContactFactory" - struct _EmpathyTpContactFactoryPriv { MissionControl *mc; McAccount *account; @@ -96,8 +96,7 @@ tp_contact_factory_weak_notify (gpointer data, { EmpathyTpContactFactoryPriv *priv = GET_PRIV (data); - empathy_debug (DEBUG_DOMAIN, "Remove finalized contact %p", - where_the_object_was); + DEBUG ("Remove finalized contact %p", where_the_object_was); priv->contacts = g_list_remove (priv->contacts, where_the_object_was); } @@ -140,11 +139,11 @@ tp_contact_factory_parse_presence_foreach (guint handle, (GHFunc) tp_contact_factory_presences_table_foreach, contact); - empathy_debug (DEBUG_DOMAIN, "Changing presence for contact %s (%d) to %s (%d)", - empathy_contact_get_id (contact), - handle, - empathy_contact_get_presence_message (contact), - empathy_contact_get_presence (contact)); + DEBUG ("Changing presence for contact %s (%d) to %s (%d)", + empathy_contact_get_id (contact), + handle, + empathy_contact_get_presence_message (contact), + empathy_contact_get_presence (contact)); } static void @@ -155,8 +154,7 @@ tp_contact_factory_get_presence_cb (TpConnection *connection, GObject *tp_factory) { if (error) { - empathy_debug (DEBUG_DOMAIN, "Error getting presence: %s", - error->message); + DEBUG ("Error getting presence: %s", error->message); if (error->domain == TP_DBUS_ERRORS && error->code == TP_DBUS_ERROR_NO_INTERFACE) { guint *handles = user_data; @@ -204,8 +202,7 @@ tp_contact_factory_set_aliases_cb (TpConnection *connection, GObject *tp_factory) { if (error) { - empathy_debug (DEBUG_DOMAIN, "Error setting alias: %s", - error->message); + DEBUG ("Error setting alias: %s", error->message); } } @@ -221,8 +218,7 @@ tp_contact_factory_request_aliases_cb (TpConnection *connection, const gchar **name; if (error) { - empathy_debug (DEBUG_DOMAIN, "Error requesting aliases: %s", - error->message); + DEBUG ("Error requesting aliases: %s", error->message); /* If we failed to get alias set it to NULL, like that if * someone is waiting for the name to be ready it won't wait @@ -251,10 +247,10 @@ tp_contact_factory_request_aliases_cb (TpConnection *connection, continue; } - empathy_debug (DEBUG_DOMAIN, "Renaming contact %s (%d) to %s (request cb)", - empathy_contact_get_id (contact), - empathy_contact_get_handle (contact), - *name); + DEBUG ("Renaming contact %s (%d) to %s (request cb)", + empathy_contact_get_id (contact), + empathy_contact_get_handle (contact), + *name); empathy_contact_set_name (contact, *name); @@ -287,9 +283,9 @@ tp_contact_factory_aliases_changed_cb (TpConnection *connection, continue; } - empathy_debug (DEBUG_DOMAIN, "Renaming contact %s (%d) to %s (changed cb)", - empathy_contact_get_id (contact), - handle, alias); + DEBUG ("Renaming contact %s (%d) to %s (changed cb)", + empathy_contact_get_id (contact), + handle, alias); empathy_contact_set_name (contact, alias); } @@ -303,8 +299,7 @@ tp_contact_factory_set_avatar_cb (TpConnection *connection, GObject *tp_factory) { if (error) { - empathy_debug (DEBUG_DOMAIN, "Error setting avatar: %s", - error->message); + DEBUG ("Error setting avatar: %s", error->message); } } @@ -315,8 +310,7 @@ tp_contact_factory_clear_avatar_cb (TpConnection *connection, GObject *tp_factory) { if (error) { - empathy_debug (DEBUG_DOMAIN, "Error clearing avatar: %s", - error->message); + DEBUG ("Error clearing avatar: %s", error->message); } } @@ -338,9 +332,9 @@ tp_contact_factory_avatar_retrieved_cb (TpConnection *connection, return; } - empathy_debug (DEBUG_DOMAIN, "Avatar retrieved for contact %s (%d)", - empathy_contact_get_id (contact), - handle); + DEBUG ("Avatar retrieved for contact %s (%d)", + empathy_contact_get_id (contact), + handle); avatar = empathy_avatar_new (avatar_data->data, avatar_data->len, @@ -358,8 +352,7 @@ tp_contact_factory_request_avatars_cb (TpConnection *connection, GObject *tp_factory) { if (error) { - empathy_debug (DEBUG_DOMAIN, "Error requesting avatars: %s", - error->message); + DEBUG ("Error requesting avatars: %s", error->message); } } @@ -431,9 +424,7 @@ tp_contact_factory_get_known_avatar_tokens_cb (TpConnection *connection, TokensData data; if (error) { - empathy_debug (DEBUG_DOMAIN, - "Error getting known avatars tokens: %s", - error->message); + DEBUG ("Error getting known avatars tokens: %s", error->message); return; } @@ -443,9 +434,8 @@ tp_contact_factory_get_known_avatar_tokens_cb (TpConnection *connection, tp_contact_factory_avatar_tokens_foreach, &data); - empathy_debug (DEBUG_DOMAIN, "Got %d tokens, need to request %d avatars", - g_hash_table_size (tokens), - data.handles->len); + DEBUG ("Got %d tokens, need to request %d avatars", + g_hash_table_size (tokens), data.handles->len); /* Request needed avatars */ if (data.handles->len > 0) { @@ -475,8 +465,7 @@ tp_contact_factory_avatar_updated_cb (TpConnection *connection, return; } - empathy_debug (DEBUG_DOMAIN, "Need to request avatar for token %s", - new_token); + DEBUG ("Need to request avatar for token %s", new_token); handles = g_array_new (FALSE, FALSE, sizeof (guint)); g_array_append_val (handles, handle); @@ -519,10 +508,10 @@ tp_contact_factory_update_capabilities (EmpathyTpContactFactory *tp_factory, } } - empathy_debug (DEBUG_DOMAIN, "Changing capabilities for contact %s (%d) to %d", - empathy_contact_get_id (contact), - empathy_contact_get_handle (contact), - capabilities); + DEBUG ("Changing capabilities for contact %s (%d) to %d", + empathy_contact_get_id (contact), + empathy_contact_get_handle (contact), + capabilities); empathy_contact_set_capabilities (contact, capabilities); } @@ -538,8 +527,7 @@ tp_contact_factory_get_capabilities_cb (TpConnection *connection, guint i; if (error) { - empathy_debug (DEBUG_DOMAIN, "Error getting capabilities: %s", - error->message); + DEBUG ("Error getting capabilities: %s", error->message); /* FIXME Should set the capabilities of the contacts for which this request * originated to NONE */ return; @@ -662,8 +650,7 @@ tp_contact_factory_request_handles_cb (TpConnection *connection, guint i = 0; if (error) { - empathy_debug (DEBUG_DOMAIN, "Failed to request handles: %s", - error->message); + DEBUG ("Failed to request handles: %s", error->message); return; } @@ -692,8 +679,7 @@ tp_contact_factory_inspect_handles_cb (TpConnection *connection, GList *l; if (error) { - empathy_debug (DEBUG_DOMAIN, "Failed to inspect handles: %s", - error->message); + DEBUG ("Failed to inspect handles: %s", error->message); return; } @@ -719,7 +705,7 @@ tp_contact_factory_connection_invalidated_cb (EmpathyTpContactFactory *tp_factor { EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory); - empathy_debug (DEBUG_DOMAIN, "Connection invalidated"); + DEBUG ("Connection invalidated"); g_object_unref (priv->connection); priv->connection = NULL; @@ -748,12 +734,11 @@ tp_contact_factory_got_self_handle_cb (TpConnection *proxy, GList *id_needed_contacts = NULL; if (error) { - empathy_debug (DEBUG_DOMAIN, "Failed to get self handles: %s", - error->message); + DEBUG ("Failed to get self handles: %s", error->message); return; } - empathy_debug (DEBUG_DOMAIN, "Connection ready"); + DEBUG ("Connection ready"); empathy_contact_set_handle (priv->user, handle); priv->ready = TRUE; @@ -907,9 +892,9 @@ tp_contact_factory_add_contact (EmpathyTpContactFactory *tp_factory, tp_factory); priv->contacts = g_list_prepend (priv->contacts, contact); - empathy_debug (DEBUG_DOMAIN, "Contact added: %s (%d)", - empathy_contact_get_id (contact), - empathy_contact_get_handle (contact)); + DEBUG ("Contact added: %s (%d)", + empathy_contact_get_id (contact), + empathy_contact_get_handle (contact)); } static void @@ -919,8 +904,7 @@ tp_contact_factory_hold_handles_cb (TpConnection *connection, GObject *tp_factory) { if (error) { - empathy_debug (DEBUG_DOMAIN, "Failed to hold handles: %s", - error->message); + DEBUG ("Failed to hold handles: %s", error->message); } } @@ -1093,9 +1077,9 @@ empathy_tp_contact_factory_set_alias (EmpathyTpContactFactory *tp_factory, handle = empathy_contact_get_handle (contact); - empathy_debug (DEBUG_DOMAIN, "Setting alias for contact %s (%d) to %s", - empathy_contact_get_id (contact), - handle, alias); + DEBUG ("Setting alias for contact %s (%d) to %s", + empathy_contact_get_id (contact), + handle, alias); new_alias = g_hash_table_new_full (g_direct_hash, g_direct_equal, @@ -1133,8 +1117,8 @@ empathy_tp_contact_factory_set_avatar (EmpathyTpContactFactory *tp_factory, avatar.data = (gchar*) data; avatar.len = size; - empathy_debug (DEBUG_DOMAIN, "Setting avatar on account %s", - mc_account_get_unique_name (priv->account)); + DEBUG ("Setting avatar on account %s", + mc_account_get_unique_name (priv->account)); tp_cli_connection_interface_avatars_call_set_avatar (priv->connection, -1, @@ -1144,8 +1128,8 @@ empathy_tp_contact_factory_set_avatar (EmpathyTpContactFactory *tp_factory, NULL, NULL, G_OBJECT (tp_factory)); } else { - empathy_debug (DEBUG_DOMAIN, "Clearing avatar on account %s", - mc_account_get_unique_name (priv->account)); + DEBUG ("Clearing avatar on account %s", + mc_account_get_unique_name (priv->account)); tp_cli_connection_interface_avatars_call_clear_avatar (priv->connection, -1, @@ -1210,9 +1194,8 @@ tp_contact_factory_finalize (GObject *object) EmpathyTpContactFactoryPriv *priv = GET_PRIV (object); GList *l; - empathy_debug (DEBUG_DOMAIN, "Finalized: %p (%s)", - object, - mc_account_get_normalized_name (priv->account)); + DEBUG ("Finalized: %p (%s)", object, + mc_account_get_normalized_name (priv->account)); empathy_disconnect_account_status_changed (priv->token); diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index 8b5c5610f..b40042513 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -33,14 +33,14 @@ #include "empathy-tp-contact-list.h" #include "empathy-contact-list.h" #include "empathy-tp-group.h" -#include "empathy-debug.h" #include "empathy-utils.h" +#define DEBUG_FLAG EMPATHY_DEBUG_TP | EMPATHY_DEBUG_CONTACT +#include "empathy-debug.h" + #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ EMPATHY_TYPE_TP_CONTACT_LIST, EmpathyTpContactListPriv)) -#define DEBUG_DOMAIN "TpContactList" - struct _EmpathyTpContactListPriv { McAccount *account; TpConnection *connection; @@ -88,8 +88,7 @@ tp_contact_list_group_destroy_cb (EmpathyTpGroup *group, { EmpathyTpContactListPriv *priv = GET_PRIV (list); - empathy_debug (DEBUG_DOMAIN, "Group destroyed: %s", - empathy_tp_group_get_name (group)); + DEBUG ("Group destroyed: %s", empathy_tp_group_get_name (group)); priv->groups = g_list_remove (priv->groups, group); g_object_unref (group); @@ -121,10 +120,10 @@ tp_contact_list_group_member_added_cb (EmpathyTpGroup *group, group_name = empathy_tp_group_get_name (group); if (!g_list_find_custom (*groups, group_name, (GCompareFunc) strcmp)) { - empathy_debug (DEBUG_DOMAIN, "Contact %s (%d) added to group %s", - empathy_contact_get_id (contact), - empathy_contact_get_handle (contact), - group_name); + DEBUG ("Contact %s (%d) added to group %s", + empathy_contact_get_id (contact), + empathy_contact_get_handle (contact), + group_name); *groups = g_list_prepend (*groups, g_strdup (group_name)); g_signal_emit_by_name (list, "groups-changed", contact, group_name, @@ -155,10 +154,10 @@ tp_contact_list_group_member_removed_cb (EmpathyTpGroup *group, group_name = empathy_tp_group_get_name (group); if ((l = g_list_find_custom (*groups, group_name, (GCompareFunc) strcmp))) { - empathy_debug (DEBUG_DOMAIN, "Contact %s (%d) removed from group %s", - empathy_contact_get_id (contact), - empathy_contact_get_handle (contact), - group_name); + DEBUG ("Contact %s (%d) removed from group %s", + empathy_contact_get_id (contact), + empathy_contact_get_handle (contact), + group_name); *groups = g_list_delete_link (*groups, l); g_signal_emit_by_name (list, "groups-changed", contact, group_name, @@ -240,10 +239,10 @@ tp_contact_list_added_cb (EmpathyTpGroup *group, TpContactListType list_type; list_type = tp_contact_list_get_type (list, group); - empathy_debug (DEBUG_DOMAIN, "Contact %s (%d) added to list type %d", - empathy_contact_get_id (contact), - empathy_contact_get_handle (contact), - list_type); + DEBUG ("Contact %s (%d) added to list type %d", + empathy_contact_get_id (contact), + empathy_contact_get_handle (contact), + list_type); /* We now get the presence of that contact, add it to members */ if (list_type == TP_CONTACT_LIST_TYPE_SUBSCRIBE && @@ -274,10 +273,10 @@ tp_contact_list_removed_cb (EmpathyTpGroup *group, TpContactListType list_type; list_type = tp_contact_list_get_type (list, group); - empathy_debug (DEBUG_DOMAIN, "Contact %s (%d) removed from list type %d", - empathy_contact_get_id (contact), - empathy_contact_get_handle (contact), - list_type); + DEBUG ("Contact %s (%d) removed from list type %d", + empathy_contact_get_id (contact), + empathy_contact_get_handle (contact), + list_type); /* This contact refuses to send us his presence, remove from members. */ if (list_type == TP_CONTACT_LIST_TYPE_SUBSCRIBE && @@ -312,10 +311,10 @@ tp_contact_list_pending_cb (EmpathyTpGroup *group, TpContactListType list_type; list_type = tp_contact_list_get_type (list, group); - empathy_debug (DEBUG_DOMAIN, "Contact %s (%d) pending in list type %d", - empathy_contact_get_id (contact), - empathy_contact_get_handle (contact), - list_type); + DEBUG ("Contact %s (%d) pending in list type %d", + empathy_contact_get_id (contact), + empathy_contact_get_handle (contact), + list_type); /* We want this contact in our contact list but we don't get its * presence yet. Add to members anyway. */ @@ -350,7 +349,7 @@ tp_contact_list_invalidated_cb (TpConnection *connection, EmpathyTpContactListPriv *priv = GET_PRIV (list); GList *l; - empathy_debug (DEBUG_DOMAIN, "Connection invalidated"); + DEBUG ("Connection invalidated"); /* Remove all contacts */ for (l = priv->members; l; l = l->next) { @@ -455,15 +454,12 @@ tp_contact_list_add_channel (EmpathyTpContactList *list, } g_list_free (contacts); } else { - empathy_debug (DEBUG_DOMAIN, - "Type of contact list channel unknown " - "or aleady have that list: %s", - empathy_tp_group_get_name (group)); + DEBUG ("Type of contact list channel unknown or aleady " + "have that list: %s", + empathy_tp_group_get_name (group)); goto OUT; } - empathy_debug (DEBUG_DOMAIN, - "New contact list channel of type: %d", - list_type); + DEBUG ("New contact list channel of type: %d", list_type); g_signal_connect (group, "member-added", G_CALLBACK (tp_contact_list_added_cb), @@ -492,8 +488,7 @@ tp_contact_list_add_channel (EmpathyTpContactList *list, goto OUT; } - empathy_debug (DEBUG_DOMAIN, "New server-side group channel: %s", - group_name); + DEBUG ("New server-side group channel: %s", group_name); priv->groups = g_list_prepend (priv->groups, g_object_ref (group)); @@ -516,9 +511,8 @@ tp_contact_list_add_channel (EmpathyTpContactList *list, } g_list_free (contacts); } else { - empathy_debug (DEBUG_DOMAIN, - "Unknown handle type (%d) for contact list channel", - handle_type); + DEBUG ("Unknown handle type (%d) for contact list channel", + handle_type); } OUT: @@ -555,9 +549,8 @@ tp_contact_list_list_channels_cb (TpConnection *connection, guint i; if (error) { - empathy_debug (DEBUG_DOMAIN, - "Failed to get list of open channels: %s", - error ? error->message : "No error given"); + DEBUG ("Failed to get list of open channels: %s", + error ? error->message : "No error given"); return; } @@ -591,7 +584,7 @@ tp_contact_list_finalize (GObject *object) list = EMPATHY_TP_CONTACT_LIST (object); priv = GET_PRIV (list); - empathy_debug (DEBUG_DOMAIN, "finalize: %p", object); + DEBUG ("finalize: %p", object); if (priv->subscribe) { g_object_unref (priv->subscribe); @@ -893,16 +886,15 @@ tp_contact_list_get_group (EmpathyTpContactList *list, return tp_group; } - empathy_debug (DEBUG_DOMAIN, "creating new group: %s", group); + DEBUG ("creating new group: %s", group); if (!tp_cli_connection_run_request_handles (priv->connection, -1, TP_HANDLE_TYPE_GROUP, names, &handles, &error, NULL)) { - empathy_debug (DEBUG_DOMAIN, - "Failed to RequestHandles: %s", - error ? error->message : "No error given"); + DEBUG ("Failed to RequestHandles: %s", + error ? error->message : "No error given"); g_clear_error (&error); return NULL; } @@ -916,9 +908,8 @@ tp_contact_list_get_group (EmpathyTpContactList *list, TRUE, &object_path, &error, NULL)) { - empathy_debug (DEBUG_DOMAIN, - "Failed to RequestChannel: %s", - error ? error->message : "No error given"); + DEBUG ("Failed to RequestChannel: %s", + error ? error->message : "No error given"); g_clear_error (&error); return NULL; } @@ -981,7 +972,7 @@ tp_contact_list_rename_group (EmpathyContactList *list, return; } - empathy_debug (DEBUG_DOMAIN, "rename group %s to %s", old_group, new_group); + DEBUG ("rename group %s to %s", old_group, new_group); /* Remove all members from the old group */ members = empathy_tp_group_get_members (tp_group); @@ -1013,7 +1004,7 @@ tp_contact_list_remove_group (EmpathyContactList *list, return; } - empathy_debug (DEBUG_DOMAIN, "remove group %s", group); + DEBUG ("remove group %s", group); /* Remove all members of the group */ members = empathy_tp_group_get_members (tp_group); diff --git a/libempathy/empathy-tp-group.c b/libempathy/empathy-tp-group.c index f5cbb7081..62212aaad 100644 --- a/libempathy/empathy-tp-group.c +++ b/libempathy/empathy-tp-group.c @@ -30,15 +30,15 @@ #include "empathy-tp-group.h" #include "empathy-contact-factory.h" -#include "empathy-debug.h" #include "empathy-utils.h" #include "empathy-marshal.h" +#define DEBUG_FLAG EMPATHY_DEBUG_TP +#include "empathy-debug.h" + #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ EMPATHY_TYPE_TP_GROUP, EmpathyTpGroupPriv)) -#define DEBUG_DOMAIN "TpGroup" - struct _EmpathyTpGroupPriv { TpChannel *channel; gboolean ready; @@ -210,18 +210,17 @@ tp_group_update_members (EmpathyTpGroup *group, actor_contact = tp_group_get_contact (group, actor); - empathy_debug (DEBUG_DOMAIN, "Members changed for list %s:\n" - " added-len=%d, current-len=%d\n" - " removed-len=%d\n" - " local-pending-len=%d, current-len=%d\n" - " remote-pending-len=%d, current-len=%d", - priv->group_name, - added ? added->len : 0, g_list_length (priv->members), - removed ? removed->len : 0, - local_pending ? local_pending->len : 0, - g_list_length (priv->local_pendings), - remote_pending ? remote_pending->len : 0, - g_list_length (priv->remote_pendings)); + DEBUG ("Members changed for list %s:\n" + " added-len=%d, current-len=%d\n" + " removed-len=%d\n" + " local-pending-len=%d, current-len=%d\n" + " remote-pending-len=%d, current-len=%d", + priv->group_name, added ? added->len : 0, + g_list_length (priv->members), removed ? removed->len : 0, + local_pending ? local_pending->len : 0, + g_list_length (priv->local_pendings), + remote_pending ? remote_pending->len : 0, + g_list_length (priv->remote_pendings)); /* Contacts added */ contacts = tp_group_get_contacts (group, added); @@ -293,14 +292,13 @@ tp_group_update_members (EmpathyTpGroup *group, g_object_unref (actor_contact); } - empathy_debug (DEBUG_DOMAIN, "Members changed done for list %s:\n" - " members-len=%d\n" - " local-pendings-len=%d\n" - " remote-pendings-len=%d", - priv->group_name, - g_list_length (priv->members), - g_list_length (priv->local_pendings), - g_list_length (priv->remote_pendings)); + DEBUG ("Members changed done for list %s:\n" + " members-len=%d\n" + " local-pendings-len=%d\n" + " remote-pendings-len=%d", + priv->group_name, g_list_length (priv->members), + g_list_length (priv->local_pendings), + g_list_length (priv->remote_pendings)); } static void @@ -335,8 +333,7 @@ tp_group_get_members_cb (TpChannel *channel, EmpathyTpGroupPriv *priv = GET_PRIV (group); if (error) { - empathy_debug (DEBUG_DOMAIN, "Failed to get members: %s", - error->message); + DEBUG ("Failed to get members: %s", error->message); return; } @@ -349,7 +346,7 @@ tp_group_get_members_cb (TpChannel *channel, 0, /* actor */ 0); /* reason */ - empathy_debug (DEBUG_DOMAIN, "Ready"); + DEBUG ("Ready"); priv->ready = TRUE; g_object_notify (group, "ready"); } @@ -365,8 +362,7 @@ tp_group_get_local_pending_cb (TpChannel *channel, guint i = 0; if (error) { - empathy_debug (DEBUG_DOMAIN, "Failed to get local pendings: %s", - error->message); + DEBUG ("Failed to get local pendings: %s", error->message); return; } @@ -407,8 +403,7 @@ tp_group_get_remote_pending_cb (TpChannel *channel, GObject *group) { if (error) { - empathy_debug (DEBUG_DOMAIN, "Failed to get remote pendings: %s", - error->message); + DEBUG ("Failed to get remote pendings: %s", error->message); return; } @@ -432,8 +427,7 @@ tp_group_inspect_handles_cb (TpConnection *connection, EmpathyTpGroupPriv *priv = GET_PRIV (group); if (error) { - empathy_debug (DEBUG_DOMAIN, "Failed to inspect channel handle: %s", - error->message); + DEBUG ("Failed to inspect channel handle: %s", error->message); return; } @@ -447,7 +441,7 @@ tp_group_invalidated_cb (TpProxy *proxy, gchar *message, EmpathyTpGroup *group) { - empathy_debug (DEBUG_DOMAIN, "Channel invalidated: %s", message); + DEBUG ("Channel invalidated: %s", message); g_signal_emit (group, signals[DESTROY], 0); } @@ -465,8 +459,7 @@ tp_group_get_self_handle_cb (TpChannel *proxy, GArray *handles; if (error) { - empathy_debug (DEBUG_DOMAIN, "Failed to get self handle: %s", - error->message); + DEBUG ("Failed to get self handle: %s", error->message); return; } @@ -546,7 +539,7 @@ tp_group_finalize (GObject *object) EmpathyTpGroupPriv *priv = GET_PRIV (object); EmpathyTpContactFactory *tp_factory; - empathy_debug (DEBUG_DOMAIN, "finalize: %p", object); + DEBUG ("finalize: %p", object); tp_factory = empathy_contact_factory_get_tp_factory (priv->factory, priv->account); g_signal_handlers_disconnect_by_func (tp_factory, tp_group_factory_ready_cb, object); @@ -742,7 +735,7 @@ tp_group_async_cb (TpChannel *channel, const gchar *msg = user_data; if (error) { - empathy_debug (DEBUG_DOMAIN, "%s: %s", msg, error->message); + DEBUG ("%s: %s", msg, error->message); } } diff --git a/libempathy/empathy-tp-roomlist.c b/libempathy/empathy-tp-roomlist.c index 4193685dc..c88580a93 100644 --- a/libempathy/empathy-tp-roomlist.c +++ b/libempathy/empathy-tp-roomlist.c @@ -33,11 +33,12 @@ #include "empathy-utils.h" #include "empathy-debug.h" +#define DEBUG_FLAG EMPATHY_DEBUG_TP +#include "empathy-debug.h" + #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ EMPATHY_TYPE_TP_ROOMLIST, EmpathyTpRoomlistPriv)) -#define DEBUG_DOMAIN "TpRoomlist" - struct _EmpathyTpRoomlistPriv { TpConnection *connection; TpChannel *channel; @@ -72,7 +73,7 @@ tp_roomlist_listing_cb (TpChannel *channel, { EmpathyTpRoomlistPriv *priv = GET_PRIV (list); - empathy_debug (DEBUG_DOMAIN, "Listing: %s", listing ? "Yes" : "No"); + DEBUG ("Listing: %s", listing ? "Yes" : "No"); priv->is_listing = listing; g_object_notify (list, "is-listing"); } @@ -139,8 +140,7 @@ tp_roomlist_get_listing_rooms_cb (TpChannel *channel, EmpathyTpRoomlistPriv *priv = GET_PRIV (list); if (error) { - empathy_debug (DEBUG_DOMAIN, "Error geting listing rooms: %s", - error->message); + DEBUG ("Error geting listing rooms: %s", error->message); return; } @@ -155,7 +155,7 @@ tp_roomlist_invalidated_cb (TpChannel *channel, gchar *message, EmpathyTpRoomlist *list) { - empathy_debug (DEBUG_DOMAIN, "Channel invalidated: %s", message); + DEBUG ("Channel invalidated: %s", message); g_signal_emit (list, signals[DESTROY], 0); } @@ -169,8 +169,7 @@ tp_roomlist_request_channel_cb (TpConnection *connection, EmpathyTpRoomlistPriv *priv = GET_PRIV (list); if (error) { - empathy_debug (DEBUG_DOMAIN, "Error requesting channel: %s", - error->message); + DEBUG ("Error requesting channel: %s", error->message); return; } @@ -207,7 +206,7 @@ tp_roomlist_finalize (GObject *object) EmpathyTpRoomlistPriv *priv = GET_PRIV (object); if (priv->channel) { - empathy_debug (DEBUG_DOMAIN, "Closing channel..."); + DEBUG ("Closing channel..."); g_signal_handlers_disconnect_by_func (priv->channel, tp_roomlist_invalidated_cb, object); diff --git a/libempathy/empathy-tp-tube.c b/libempathy/empathy-tp-tube.c index 38f00cbda..b1e6676ff 100644 --- a/libempathy/empathy-tp-tube.c +++ b/libempathy/empathy-tp-tube.c @@ -25,12 +25,12 @@ #include #include "empathy-contact-factory.h" -#include "empathy-debug.h" #include "empathy-enum-types.h" #include "empathy-tp-tube.h" #include "empathy-utils.h" -#define DEBUG_DOMAIN "TpTube" +#define DEBUG_FLAG EMPATHY_DEBUG_TP +#include "empathy-debug.h" #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_TP_TUBE, \ EmpathyTpTubePriv)) @@ -86,7 +86,7 @@ tp_tube_state_changed_cb (TpChannel *channel, if (id != priv->id) return; - empathy_debug (DEBUG_DOMAIN, "Tube state changed"); + DEBUG ("Tube state changed"); priv->state = state; g_object_notify (tube, "state"); @@ -99,7 +99,7 @@ tp_tube_invalidated_cb (TpChannel *channel, gchar *message, EmpathyTpTube *tube) { - empathy_debug (DEBUG_DOMAIN, "Channel invalidated: %s", message); + DEBUG ("Channel invalidated: %s", message); g_signal_emit (tube, signals[DESTROY], 0); } @@ -114,7 +114,7 @@ tp_tube_closed_cb (TpChannel *channel, if (id != priv->id) return; - empathy_debug (DEBUG_DOMAIN, "Tube closed"); + DEBUG ("Tube closed"); g_signal_emit (tube, signals[DESTROY], 0); } @@ -125,7 +125,7 @@ tp_tube_async_cb (TpChannel *channel, GObject *tube) { if (error) - empathy_debug (DEBUG_DOMAIN, "Error %s: %s", user_data, error->message); + DEBUG ("Error %s: %s", (gchar*) user_data, error->message); } static void @@ -217,8 +217,7 @@ tp_tube_constructor (GType type, if (!tp_cli_channel_type_tubes_run_list_tubes (priv->channel, -1, &tubes, &error, NULL)) { - empathy_debug (DEBUG_DOMAIN, "Couldn't list tubes: %s", - error->message); + DEBUG ("Couldn't list tubes: %s", error->message); g_clear_error (&error); return self; } @@ -267,7 +266,7 @@ tp_tube_finalize (GObject *object) { EmpathyTpTubePriv *priv = GET_PRIV (object); - empathy_debug (DEBUG_DOMAIN, "Finalizing: %p", object); + DEBUG ("Finalizing: %p", object); if (priv->channel) { @@ -397,13 +396,13 @@ empathy_tp_tube_new_stream_tube (EmpathyContact *contact, TP_IFACE_CHANNEL_TYPE_TUBES, TP_HANDLE_TYPE_CONTACT, empathy_contact_get_handle (contact), FALSE, &object_path, &error, NULL)) { - empathy_debug (DEBUG_DOMAIN, "Error requesting channel: %s", error->message); + DEBUG ("Error requesting channel: %s", error->message); g_clear_error (&error); g_object_unref (connection); return NULL; } - empathy_debug (DEBUG_DOMAIN, "Offering a new stream tube"); + DEBUG ("Offering a new stream tube"); channel = tp_channel_new (connection, object_path, TP_IFACE_CHANNEL_TYPE_TUBES, TP_HANDLE_TYPE_CONTACT, @@ -421,12 +420,12 @@ empathy_tp_tube_new_stream_tube (EmpathyContact *contact, service, params, type, address, TP_SOCKET_ACCESS_CONTROL_LOCALHOST, control_param, &id, &error, NULL)) { - empathy_debug (DEBUG_DOMAIN, "Couldn't offer tube: %s", error->message); + DEBUG ("Couldn't offer tube: %s", error->message); g_clear_error (&error); goto OUT; } - empathy_debug (DEBUG_DOMAIN, "Stream tube id=%d offered", id); + DEBUG ("Stream tube id=%d offered", id); tube = empathy_tp_tube_new (channel, id); @@ -449,7 +448,7 @@ tp_tube_accept_stream_cb (TpChannel *proxy, GObject *weak_object) { if (error) - empathy_debug (DEBUG_DOMAIN, "Error accepting tube: %s", error->message); + DEBUG ("Error accepting tube: %s", error->message); } void @@ -461,7 +460,7 @@ empathy_tp_tube_accept_stream_tube (EmpathyTpTube *tube, g_return_if_fail (EMPATHY_IS_TP_TUBE (tube)); - empathy_debug (DEBUG_DOMAIN, "Accepting stream tube - id: %d", priv->id); + DEBUG ("Accepting stream tube - id: %d", priv->id); control_param = tp_g_value_slice_new (G_TYPE_STRING); tp_cli_channel_type_tubes_call_accept_stream_tube (priv->channel, -1, priv->id, @@ -483,14 +482,13 @@ empathy_tp_tube_get_socket (EmpathyTpTube *tube, g_return_if_fail (EMPATHY_IS_TP_TUBE (tube)); - empathy_debug (DEBUG_DOMAIN, "Getting stream tube socket address"); + DEBUG ("Getting stream tube socket address"); address = g_slice_new0 (GValue); if (!tp_cli_channel_type_tubes_run_get_stream_tube_socket_address (priv->channel, -1, priv->id, &address_type, &address, &error, NULL)) { - empathy_debug (DEBUG_DOMAIN, "Couldn't get socket address: %s", - error->message); + DEBUG ("Couldn't get socket address: %s", error->message); g_clear_error (&error); return; } diff --git a/libempathy/empathy-tube-handler.c b/libempathy/empathy-tube-handler.c index 3e363837f..2bbaea18c 100644 --- a/libempathy/empathy-tube-handler.c +++ b/libempathy/empathy-tube-handler.c @@ -31,11 +31,11 @@ #include -#include "empathy-debug.h" #include "empathy-tp-tube.h" #include "empathy-tube-handler.h" -#define DEBUG_DOMAIN "TubeHandler" +#define DEBUG_FLAG EMPATHY_DEBUG_OTHER +#include "empathy-debug.h" static void empathy_tube_handler_iface_init (EmpSvcTubeHandlerClass *klass); @@ -71,7 +71,7 @@ tube_handler_handle_tube_idle_cb (gpointer data) EmpathyTpTube *tube; static TpDBusDaemon *daemon = NULL; - empathy_debug (DEBUG_DOMAIN, "New tube to be handled id=%d", idle_data->id); + DEBUG ("New tube to be handled id=%d", idle_data->id); if (!daemon) daemon = tp_dbus_daemon_new (tp_get_bus ()); @@ -169,7 +169,7 @@ empathy_tube_handler_new (TpTubeType type, const gchar *service) G_TYPE_STRING, bus_name, G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE, G_TYPE_INVALID, G_TYPE_UINT, &result, G_TYPE_INVALID)) { - empathy_debug (DEBUG_DOMAIN, "Failed to request name: %s", + DEBUG ("Failed to request name: %s", error ? error->message : "No error given"); g_clear_error (&error); goto OUT; diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index 8f5c72df5..fe6a787bb 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -37,13 +37,13 @@ #include #include -#include "empathy-debug.h" #include "empathy-utils.h" #include "empathy-contact-factory.h" #include "empathy-contact-manager.h" #include "empathy-tp-group.h" -#define DEBUG_DOMAIN "Utils" +#define DEBUG_FLAG EMPATHY_DEBUG_OTHER +#include "empathy-debug.h" static void regex_init (void); @@ -151,9 +151,7 @@ empathy_regex_match (EmpathyRegExType type, } if (type != EMPATHY_REGEX_ALL) { - empathy_debug (DEBUG_DOMAIN, - "Found %d matches for regex type:%d", - num_matches, type); + DEBUG ("Found %d matches for regex type:%d", num_matches, type); return num_matches; } @@ -175,9 +173,7 @@ empathy_regex_match (EmpathyRegExType type, } } - empathy_debug (DEBUG_DOMAIN, - "Found %d matches for ALL regex types", - num_matches); + DEBUG ("Found %d matches for ALL regex types", num_matches); return num_matches; } @@ -222,7 +218,7 @@ empathy_xml_validate (xmlDoc *doc, g_free (path); path = g_build_filename (DATADIR, "empathy", dtd_filename, NULL); } - empathy_debug (DEBUG_DOMAIN, "Loading dtd file %s", path); + DEBUG ("Loading dtd file %s", path); /* The list of valid chars is taken from libxml. */ escaped = xmlURIEscapeStr (path, ":@&=+$,/?;"); @@ -373,9 +369,8 @@ empathy_call_with_contact (EmpathyContact *contact) &object_path, &error, NULL)) { - empathy_debug (DEBUG_DOMAIN, - "Couldn't request channel: %s", - error ? error->message : "No error given"); + DEBUG ("Couldn't request channel: %s", + error ? error->message : "No error given"); g_clear_error (&error); g_object_unref (connection); return; @@ -562,7 +557,7 @@ static void run_until_ready_cb (RunUntilReadyData *data) { if (!data->func || data->func (data->object, data->user_data)) { - empathy_debug (DEBUG_DOMAIN, "Object %p is ready", data->object); + DEBUG ("Object %p is ready", data->object); g_main_loop_quit (data->loop); } } @@ -595,8 +590,7 @@ empathy_run_until_ready_full (gpointer object, return; } - empathy_debug (DEBUG_DOMAIN, "Starting run until ready for object %p", - object); + DEBUG ("Starting run until ready for object %p", object); data.func = func; data.user_data = user_data; -- cgit v1.2.3