empathy r1066 - in trunk: . libempathy libempathy-gtk megaphone/src python/pyempathy python/pyempathygtk src



Author: xclaesse
Date: Wed Apr 30 21:44:38 2008
New Revision: 1066
URL: http://svn.gnome.org/viewvc/empathy?rev=1066&view=rev

Log:
Make use of tp-glib debug system.


Modified:
   trunk/configure.ac
   trunk/libempathy-gtk/empathy-account-widget-irc.c
   trunk/libempathy-gtk/empathy-account-widget-sip.c
   trunk/libempathy-gtk/empathy-account-widget.c
   trunk/libempathy-gtk/empathy-accounts-dialog.c
   trunk/libempathy-gtk/empathy-avatar-chooser.c
   trunk/libempathy-gtk/empathy-avatar-image.c
   trunk/libempathy-gtk/empathy-cell-renderer-activatable.c
   trunk/libempathy-gtk/empathy-chat-view.c
   trunk/libempathy-gtk/empathy-chat.c
   trunk/libempathy-gtk/empathy-conf.c
   trunk/libempathy-gtk/empathy-contact-list-store.c
   trunk/libempathy-gtk/empathy-contact-list-view.c
   trunk/libempathy-gtk/empathy-contact-menu.c
   trunk/libempathy-gtk/empathy-geometry.c
   trunk/libempathy-gtk/empathy-irc-network-dialog.c
   trunk/libempathy-gtk/empathy-log-window.c
   trunk/libempathy-gtk/empathy-new-message-dialog.c
   trunk/libempathy-gtk/empathy-presence-chooser.c
   trunk/libempathy-gtk/empathy-smiley-manager.c
   trunk/libempathy-gtk/empathy-spell.c
   trunk/libempathy-gtk/empathy-spell.h
   trunk/libempathy-gtk/empathy-theme-boxes.c
   trunk/libempathy-gtk/empathy-theme-irc.c
   trunk/libempathy-gtk/empathy-theme.c
   trunk/libempathy-gtk/empathy-ui-utils.c
   trunk/libempathy/empathy-avatar.c
   trunk/libempathy/empathy-chatroom-manager.c
   trunk/libempathy/empathy-contact-groups.c
   trunk/libempathy/empathy-contact-manager.c
   trunk/libempathy/empathy-contact.c
   trunk/libempathy/empathy-debug.c
   trunk/libempathy/empathy-debug.h
   trunk/libempathy/empathy-idle.c
   trunk/libempathy/empathy-irc-network-manager.c
   trunk/libempathy/empathy-log-manager.c
   trunk/libempathy/empathy-status-presets.c
   trunk/libempathy/empathy-tp-call.c
   trunk/libempathy/empathy-tp-chat.c
   trunk/libempathy/empathy-tp-contact-factory.c
   trunk/libempathy/empathy-tp-contact-list.c
   trunk/libempathy/empathy-tp-group.c
   trunk/libempathy/empathy-tp-roomlist.c
   trunk/libempathy/empathy-tp-tube.c
   trunk/libempathy/empathy-tube-handler.c
   trunk/libempathy/empathy-utils.c
   trunk/megaphone/src/megaphone-applet.c
   trunk/python/pyempathy/pyempathy.defs
   trunk/python/pyempathygtk/pyempathygtk.defs
   trunk/src/empathy-accounts.c
   trunk/src/empathy-call-window.c
   trunk/src/empathy-chat-window.c
   trunk/src/empathy-filter.c
   trunk/src/empathy-logs.c
   trunk/src/empathy-main-window.c
   trunk/src/empathy-new-chatroom-dialog.c
   trunk/src/empathy-status-icon.c
   trunk/src/empathy.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Wed Apr 30 21:44:38 2008
@@ -104,6 +104,18 @@
 ])
 
 # -----------------------------------------------------------
+# Enable debug
+# -----------------------------------------------------------
+
+AC_ARG_ENABLE(debug,
+  AC_HELP_STRING([--disable-debug],[compile without debug code]),
+    enable_debug=$enableval, enable_debug=yes )
+
+if test x$enable_debug = xyes; then
+  AC_DEFINE(ENABLE_DEBUG, [], [Enable debug code])
+fi
+
+# -----------------------------------------------------------
 # Language Support
 # -----------------------------------------------------------
 

Modified: trunk/libempathy-gtk/empathy-account-widget-irc.c
==============================================================================
--- trunk/libempathy-gtk/empathy-account-widget-irc.c	(original)
+++ trunk/libempathy-gtk/empathy-account-widget-irc.c	Wed Apr 30 21:44:38 2008
@@ -32,7 +32,6 @@
 #include <libmissioncontrol/mc-protocol.h>
 
 #include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-irc-network-manager.h>
 
 #include "empathy-irc-network-dialog.h"
@@ -40,7 +39,8 @@
 #include "empathy-account-widget-irc.h"
 #include "empathy-ui-utils.h"
 
-#define DEBUG_DOMAIN "AccountWidgetIRC"
+#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT | EMPATHY_DEBUG_IRC
+#include <libempathy/empathy-debug.h>
 
 #define IRC_NETWORKS_FILENAME "irc-networks.xml"
 
@@ -73,7 +73,7 @@
 static void
 unset_server_params (EmpathyAccountWidgetIrc *settings)
 {
-  empathy_debug (DEBUG_DOMAIN, "Unset server, port and use-ssl");
+  DEBUG ("Unset server, port and use-ssl");
   mc_account_unset_param (settings->account, "server");
   mc_account_unset_param (settings->account, "port");
   mc_account_unset_param (settings->account, "use-ssl");
@@ -101,7 +101,7 @@
   g_assert (network != NULL);
 
   g_object_get (network, "charset", &charset, NULL);
-  empathy_debug (DEBUG_DOMAIN, "Setting charset to %s", charset);
+  DEBUG ("Setting charset to %s", charset);
   mc_account_set_param_string (settings->account, "charset", charset);
   g_free (charset);
 
@@ -120,12 +120,11 @@
           "ssl", &ssl,
           NULL);
 
-      empathy_debug (DEBUG_DOMAIN, "Setting server to %s", address);
+      DEBUG ("Setting server to %s", address);
       mc_account_set_param_string (settings->account, "server", address);
-      empathy_debug (DEBUG_DOMAIN, "Setting port to %u", port);
+      DEBUG ("Setting port to %u", port);
       mc_account_set_param_int (settings->account, "port", port);
-      empathy_debug (DEBUG_DOMAIN, "Setting use-ssl to %s",
-          ssl ? "TRUE": "FALSE" );
+      DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" );
       mc_account_set_param_boolean (settings->account, "use-ssl", ssl);
 
       g_free (address);
@@ -217,7 +216,7 @@
   g_assert (network != NULL);
 
   g_object_get (network, "name", &name, NULL);
-  empathy_debug (DEBUG_DOMAIN, "Remove network %s", name);
+  DEBUG ("Remove network %s", name);
 
   gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
   empathy_irc_network_manager_remove (settings->network_manager, network);
@@ -378,7 +377,7 @@
           g_object_set (network, "charset", charset, NULL);
 
           g_object_get (network, "name", &name, NULL);
-          empathy_debug (DEBUG_DOMAIN, "Account use network %s", name);
+          DEBUG ("Account use network %s", name);
 
           g_free (name);
         }
@@ -388,7 +387,7 @@
           EmpathyIrcServer *srv;
           GtkTreeIter iter;
 
-          empathy_debug (DEBUG_DOMAIN, "Create a network %s", server);
+          DEBUG ("Create a network %s", server);
           network = empathy_irc_network_new (server);
           srv = empathy_irc_server_new (server, port, ssl);
 

Modified: trunk/libempathy-gtk/empathy-account-widget-sip.c
==============================================================================
--- trunk/libempathy-gtk/empathy-account-widget-sip.c	(original)
+++ trunk/libempathy-gtk/empathy-account-widget-sip.c	Wed Apr 30 21:44:38 2008
@@ -33,14 +33,11 @@
 #include <libmissioncontrol/mc-protocol.h>
 
 #include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-debug.h>
 
 #include "empathy-account-widget.h"
 #include "empathy-account-widget-sip.h"
 #include "empathy-ui-utils.h"
 
-#define DEBUG_DOMAIN "AccountWidgetSIP"
-
 typedef struct {
   McAccount *account;
 

Modified: trunk/libempathy-gtk/empathy-account-widget.c
==============================================================================
--- trunk/libempathy-gtk/empathy-account-widget.c	(original)
+++ trunk/libempathy-gtk/empathy-account-widget.c	Wed Apr 30 21:44:38 2008
@@ -32,13 +32,13 @@
 #include <libmissioncontrol/mc-account.h>
 #include <libmissioncontrol/mc-protocol.h>
 
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 
 #include "empathy-account-widget.h"
 #include "empathy-ui-utils.h"
 
-#define DEBUG_DOMAIN "AccountWidget"
+#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
+#include <libempathy/empathy-debug.h>
 
 static gboolean 
 account_widget_entry_focus_cb (GtkWidget     *widget,
@@ -56,12 +56,12 @@
 
 		mc_account_unset_param (account, param_name);
 		mc_account_get_param_string (account, param_name, &value);
-		empathy_debug (DEBUG_DOMAIN, "Unset %s and restore to %s", param_name, value);
+		DEBUG ("Unset %s and restore to %s", param_name, value);
 		gtk_entry_set_text (GTK_ENTRY (widget), value ? value : "");
 		g_free (value);
 	} else {
-		empathy_debug (DEBUG_DOMAIN, "Setting %s to %s", param_name,
-			       strstr (param_name, "password") ? "***" : str);
+		DEBUG ("Setting %s to %s", param_name,
+			strstr (param_name, "password") ? "***" : str);
 		mc_account_set_param_string (account, param_name, str);
 	}
 
@@ -81,10 +81,10 @@
 	if (value == 0) {
 		mc_account_unset_param (account, param_name);
 		mc_account_get_param_int (account, param_name, &value);
-		empathy_debug (DEBUG_DOMAIN, "Unset %s and restore to %d", param_name, value);
+		DEBUG ("Unset %s and restore to %d", param_name, value);
 		gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
 	} else {
-		empathy_debug (DEBUG_DOMAIN, "Setting %s to %d", param_name, value);
+		DEBUG ("Setting %s to %d", param_name, value);
 		mc_account_set_param_int (account, param_name, value);
 	}
 }
@@ -107,9 +107,9 @@
 	mc_account_get_param_boolean (account, param_name, &default_value);
 
 	if (default_value == value) {
-		empathy_debug (DEBUG_DOMAIN, "Unset %s and restore to %d", param_name, default_value);
+		DEBUG ("Unset %s and restore to %d", param_name, default_value);
 	} else {
-		empathy_debug (DEBUG_DOMAIN, "Setting %s to %d", param_name, value);
+		DEBUG ("Setting %s to %d", param_name, value);
 		mc_account_set_param_boolean (account, param_name, value);
 	}
 }
@@ -124,7 +124,7 @@
 	param_name = g_object_get_data (G_OBJECT (entry), "param_name");
 	account = g_object_get_data (G_OBJECT (entry), "account");
 
-	empathy_debug (DEBUG_DOMAIN, "Unset %s", param_name);
+	DEBUG ("Unset %s", param_name);
 	mc_account_unset_param (account, param_name);
 	gtk_entry_set_text (GTK_ENTRY (entry), "");
 }
@@ -209,9 +209,7 @@
 				  G_CALLBACK (account_widget_checkbutton_toggled_cb),
 				  account);
 	} else {
-		empathy_debug (DEBUG_DOMAIN,
-		               "Unknown type of widget for param %s",
-		               param_name);
+		DEBUG ("Unknown type of widget for param %s", param_name);
 	}
 }
 
@@ -357,9 +355,8 @@
 					  GTK_FILL | GTK_EXPAND, 0,
 					  0, 0);
 		} else {
-			empathy_debug (DEBUG_DOMAIN,
-				       "Unknown signature for param %s: %s",
-				       param_name_formatted, param->signature);
+			DEBUG ("Unknown signature for param %s: %s",
+				param_name_formatted, param->signature);
 		}
 
 		if (widget) {

Modified: trunk/libempathy-gtk/empathy-accounts-dialog.c
==============================================================================
--- trunk/libempathy-gtk/empathy-accounts-dialog.c	(original)
+++ trunk/libempathy-gtk/empathy-accounts-dialog.c	Wed Apr 30 21:44:38 2008
@@ -38,7 +38,6 @@
 #include <libmissioncontrol/mc-account-monitor.h>
 #include <telepathy-glib/util.h>
 
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
 
@@ -48,7 +47,8 @@
 #include "empathy-account-widget-irc.h"
 #include "empathy-account-widget-sip.h"
 
-#define DEBUG_DOMAIN "AccountDialog"
+#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
+#include <libempathy/empathy-debug.h>
 
 /* Flashing delay for icons (milliseconds). */
 #define FLASH_TIMEOUT 500
@@ -402,9 +402,8 @@
 	enabled = mc_account_is_enabled (account);
 	mc_account_set_enabled (account, !enabled);
 
-	empathy_debug (DEBUG_DOMAIN, "%s account %s",
-		       enabled ? "Disabled" : "Enable",
-		       mc_account_get_display_name(account));
+	DEBUG ("%s account %s", enabled ? "Disabled" : "Enable",
+		mc_account_get_display_name(account));
 
 	g_object_unref (account);
 }
@@ -663,7 +662,7 @@
 
 	g_return_if_fail (name != NULL);
 
-	empathy_debug (DEBUG_DOMAIN, "Adding new account: %s", name);
+	DEBUG ("Adding new account: %s", name);
 
 	model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
 	gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter,
@@ -747,9 +746,8 @@
 	model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
 	account = mc_account_lookup (unique_name);
 
-	empathy_debug (DEBUG_DOMAIN, "Status changed for account %s: "
-		      "status=%d presence=%d",
-		      unique_name, status, presence);
+	DEBUG ("Status changed for account %s: status=%d presence=%d",
+		unique_name, status, presence);
 
 	if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
 		GtkTreePath *path;
@@ -808,9 +806,9 @@
 	account = mc_account_lookup (unique_name);
 	enabled = mc_account_is_enabled (account);
 
-	empathy_debug (DEBUG_DOMAIN, "Account %s is now %s",
-		       mc_account_get_display_name (account),
-		       enabled ? "enabled" : "disabled");
+	DEBUG ("Account %s is now %s",
+		mc_account_get_display_name (account),
+		enabled ? "enabled" : "disabled");
 
 	if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
 		gtk_list_store_set (GTK_LIST_STORE (model), &iter,

Modified: trunk/libempathy-gtk/empathy-avatar-chooser.c
==============================================================================
--- trunk/libempathy-gtk/empathy-avatar-chooser.c	(original)
+++ trunk/libempathy-gtk/empathy-avatar-chooser.c	Wed Apr 30 21:44:38 2008
@@ -29,13 +29,12 @@
 #include <gtk/gtk.h>
 #include <gio/gio.h>
 
-#include <libempathy/empathy-debug.h>
-
 #include "empathy-avatar-chooser.h"
 #include "empathy-conf.h"
 #include "empathy-ui-utils.h"
 
-#define DEBUG_DOMAIN "AvatarChooser"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_AVATAR_CHOOSER, EmpathyAvatarChooserPriv))
 
@@ -187,8 +186,8 @@
 						&priv->image_data_size,
 						"png",
 						&error, NULL)) {
-			empathy_debug (DEBUG_DOMAIN, "Failed to save pixbuf: %s",
-				       error ? error->message : "No error given");
+			DEBUG ("Failed to save pixbuf: %s",
+				error ? error->message : "No error given");
 			g_clear_error (&error);
 		}
 		image = gtk_image_new_from_pixbuf (pixbuf_view);
@@ -212,8 +211,8 @@
 	GError    *error = NULL;
 
 	if (!(pixbuf = gdk_pixbuf_new_from_file (filename, &error))) {
-		empathy_debug (DEBUG_DOMAIN, "Failed to load pixbuf from file: %s",
-			       error ? error->message : "No error given");
+		DEBUG ("Failed to load pixbuf from file: %s",
+			error ? error->message : "No error given");
 		g_clear_error (&error);
 	}
 

Modified: trunk/libempathy-gtk/empathy-avatar-image.c
==============================================================================
--- trunk/libempathy-gtk/empathy-avatar-image.c	(original)
+++ trunk/libempathy-gtk/empathy-avatar-image.c	Wed Apr 30 21:44:38 2008
@@ -29,13 +29,9 @@
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
 
-#include <libempathy/empathy-debug.h>
-
 #include "empathy-avatar-image.h"
 #include "empathy-ui-utils.h"
 
-#define DEBUG_DOMAIN "AvatarImage"
-
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_AVATAR_IMAGE, EmpathyAvatarImagePriv))
 
 #define MAX_SMALL 64

Modified: trunk/libempathy-gtk/empathy-cell-renderer-activatable.c
==============================================================================
--- trunk/libempathy-gtk/empathy-cell-renderer-activatable.c	(original)
+++ trunk/libempathy-gtk/empathy-cell-renderer-activatable.c	Wed Apr 30 21:44:38 2008
@@ -22,12 +22,8 @@
 
 #include <gtk/gtktreeview.h>
 
-#include <libempathy/empathy-debug.h>
-
 #include "empathy-cell-renderer-activatable.h"
 
-#define DEBUG_DOMAIN "CellRendererActivatable"
-
 static void     empathy_cell_renderer_activatable_init       (EmpathyCellRendererActivatable      *cell);
 static void     empathy_cell_renderer_activatable_class_init (EmpathyCellRendererActivatableClass *klass);
 static gboolean cell_renderer_activatable_activate           (GtkCellRenderer                     *cell,

Modified: trunk/libempathy-gtk/empathy-chat-view.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat-view.c	(original)
+++ trunk/libempathy-gtk/empathy-chat-view.c	Wed Apr 30 21:44:38 2008
@@ -43,7 +43,6 @@
 #include <libmissioncontrol/mc-account.h>
 
 #include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-debug.h>
 
 #include "empathy-chat-view.h"
 #include "empathy-chat.h"
@@ -52,7 +51,8 @@
 #include "empathy-ui-utils.h"
 #include "empathy-smiley-manager.h"
 
-#define DEBUG_DOMAIN "ChatView"
+#define DEBUG_FLAG EMPATHY_DEBUG_CHAT
+#include <libempathy/empathy-debug.h>
 
 /* Number of seconds between timestamps when using normal mode, 5 minutes. */
 #define TIMESTAMP_INTERVAL 300
@@ -208,7 +208,7 @@
 	view = EMPATHY_CHAT_VIEW (object);
 	priv = GET_PRIV (view);
 
-	empathy_debug (DEBUG_DOMAIN, "finalize: %p", object);
+	DEBUG ("finalize: %p", object);
 
 	empathy_conf_notify_remove (empathy_conf_get (), priv->notify_system_fonts_id);
 	empathy_conf_notify_remove (empathy_conf_get (), priv->notify_show_avatars_id);
@@ -780,7 +780,7 @@
 		return;
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Scrolling down");
+	DEBUG ("Scrolling down");
 
 	if (priv->scroll_time) {
 		g_timer_reset (priv->scroll_time);
@@ -933,8 +933,7 @@
 
 	g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
 
-	empathy_debug (DEBUG_DOMAIN, "Scrolling %s",
-		      allow_scrolling ? "enabled" : "disabled");
+	DEBUG ("Scrolling %s", allow_scrolling ? "enabled" : "disabled");
 
 	priv->allow_scrolling = allow_scrolling;
 	if (allow_scrolling) {

Modified: trunk/libempathy-gtk/empathy-chat.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.c	(original)
+++ trunk/libempathy-gtk/empathy-chat.c	Wed Apr 30 21:44:38 2008
@@ -39,7 +39,6 @@
 
 #include <libempathy/empathy-log-manager.h>
 #include <libempathy/empathy-contact-list.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 
 #include "empathy-chat.h"
@@ -51,9 +50,10 @@
 #include "empathy-contact-menu.h"
 #include "empathy-ui-utils.h"
 
-#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CHAT, EmpathyChatPriv))
+#define DEBUG_FLAG EMPATHY_DEBUG_CHAT
+#include <libempathy/empathy-debug.h>
 
-#define DEBUG_DOMAIN "Chat"
+#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CHAT, EmpathyChatPriv))
 
 #define CHAT_DIR_CREATE_MODE  (S_IRUSR | S_IWUSR | S_IXUSR)
 #define CHAT_FILE_CREATE_MODE (S_IRUSR | S_IWUSR)
@@ -184,8 +184,7 @@
 	if (status == TP_CONNECTION_STATUS_CONNECTED && !priv->tp_chat &&
 	    empathy_account_equal (account, priv->account) &&
 	    priv->handle_type != TP_HANDLE_TYPE_NONE) {
-		empathy_debug (DEBUG_DOMAIN,
-			       "Account reconnected, request a new Text channel");
+		DEBUG ("Account reconnected, request a new Text channel");
 		mission_control_request_channel_with_string_handle (mc,
 								    priv->account,
 								    TP_IFACE_CHANNEL_TYPE_TEXT,
@@ -304,8 +303,7 @@
 	priv = GET_PRIV (chat);
 
 	if (!priv->sent_messages) {
-		empathy_debug (DEBUG_DOMAIN, 
-			      "No sent messages, next message is NULL");
+		DEBUG ("No sent messages, next message is NULL");
 		return NULL;
 	}
 
@@ -315,9 +313,7 @@
 		priv->sent_messages_index++;
 	}
 	
-	empathy_debug (DEBUG_DOMAIN, 
-		      "Returning next message index:%d",
-		      priv->sent_messages_index);
+	DEBUG ("Returning next message index:%d", priv->sent_messages_index);
 
 	return g_slist_nth_data (priv->sent_messages, priv->sent_messages_index);
 }
@@ -332,8 +328,7 @@
 	priv = GET_PRIV (chat);
 	
 	if (!priv->sent_messages) {
-		empathy_debug (DEBUG_DOMAIN, 
-			      "No sent messages, last message is NULL");
+		DEBUG ("No sent messages, last message is NULL");
 		return NULL;
 	}
 
@@ -341,9 +336,7 @@
 		priv->sent_messages_index--;
 	}
 
-	empathy_debug (DEBUG_DOMAIN, 
-		      "Returning last message index:%d",
-		      priv->sent_messages_index);
+	DEBUG ("Returning last message index:%d", priv->sent_messages_index);
 
 	return g_slist_nth_data (priv->sent_messages, priv->sent_messages_index);
 }
@@ -446,9 +439,9 @@
 		g_assert_not_reached ();
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Was composing: %s now composing: %s",
-		      was_composing ? "yes" : "no",
-		      priv->compositors ? "yes" : "no");
+	DEBUG ("Was composing: %s now composing: %s",
+		was_composing ? "yes" : "no",
+		priv->compositors ? "yes" : "no");
 
 	if ((was_composing && !priv->compositors) ||
 	    (!was_composing && priv->compositors)) {
@@ -488,18 +481,17 @@
 			/* The message we received is already displayed because
 			 * some jabber chatrooms sends us back logs and we
 			 * already displayed it from localy logged messages. */
-			empathy_debug (DEBUG_DOMAIN, "Skipping message because "
-				       "it is already displayed from logged "
-				       "messages");
+			DEBUG ("Skipping message because it is already "
+				"displayed from logged messages");
 			g_object_unref (log_message);
 			return;
 		}
 		g_object_unref (log_message);
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Appending new message from %s (%d)",
-		       empathy_contact_get_name (sender),
-		       empathy_contact_get_handle (sender));
+	DEBUG ("Appending new message from %s (%d)",
+		empathy_contact_get_name (sender),
+		empathy_contact_get_handle (sender));
 
 	if (priv->id) {
 		gboolean is_chatroom;
@@ -898,7 +890,7 @@
 chat_input_realize_cb (GtkWidget   *widget,
 		       EmpathyChat *chat)
 {
-	empathy_debug (DEBUG_DOMAIN, "Setting focus to the input text view");
+	DEBUG ("Setting focus to the input text view");
 	gtk_widget_grab_focus (widget);
 }
 
@@ -1399,7 +1391,7 @@
 	chat = EMPATHY_CHAT (object);
 	priv = GET_PRIV (chat);
 
-	empathy_debug (DEBUG_DOMAIN, "Finalized: %p", object);
+	DEBUG ("Finalized: %p", object);
 
 	g_slist_foreach (priv->sent_messages, (GFunc) g_free, NULL);
 	g_slist_free (priv->sent_messages);

Modified: trunk/libempathy-gtk/empathy-conf.c
==============================================================================
--- trunk/libempathy-gtk/empathy-conf.c	(original)
+++ trunk/libempathy-gtk/empathy-conf.c	Wed Apr 30 21:44:38 2008
@@ -26,11 +26,10 @@
 
 #include <gconf/gconf-client.h>
 
-#include <libempathy/empathy-debug.h>
-
 #include "empathy-conf.h"
 
-#define DEBUG_DOMAIN "Config"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 #define EMPATHY_CONF_ROOT       "/apps/empathy"
 #define DESKTOP_INTERFACE_ROOT  "/desktop/gnome/interface"
@@ -131,7 +130,7 @@
 
 	g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE);
 
-	empathy_debug (DEBUG_DOMAIN, "Setting int:'%s' to %d", key, value);
+	DEBUG ("Setting int:'%s' to %d", key, value);
 
 	priv = GET_PRIV (conf);
 
@@ -177,8 +176,8 @@
 
 	g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE);
 
-	empathy_debug (DEBUG_DOMAIN, "Setting bool:'%s' to %d ---> %s",
-		      key, value, value ? "true" : "false");
+	DEBUG ("Setting bool:'%s' to %d ---> %s", key, value,
+		value ? "true" : "false");
 
 	priv = GET_PRIV (conf);
 
@@ -224,8 +223,7 @@
 
 	g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE);
 
-	empathy_debug (DEBUG_DOMAIN, "Setting string:'%s' to '%s'",
-		      key, value);
+	DEBUG ("Setting string:'%s' to '%s'", key, value);
 
 	priv = GET_PRIV (conf);
 

Modified: trunk/libempathy-gtk/empathy-contact-list-store.c
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-list-store.c	(original)
+++ trunk/libempathy-gtk/empathy-contact-list-store.c	Wed Apr 30 21:44:38 2008
@@ -31,13 +31,13 @@
 #include <gtk/gtk.h>
 
 #include <telepathy-glib/util.h>
-#include <libempathy/empathy-debug.h>
 
 #include "empathy-contact-list-store.h"
 #include "empathy-ui-utils.h"
 #include "empathy-gtk-enum-types.h"
 
-#define DEBUG_DOMAIN "ContactListStore"
+#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
+#include <libempathy/empathy-debug.h>
 
 /* Active users are those which have recently changed state
  * (e.g. online, offline or from normal to a busy state).
@@ -786,11 +786,10 @@
 
 	priv = GET_PRIV (store);
 
-	empathy_debug (DEBUG_DOMAIN, 
-		      "Contact %s (%d) %s",
-		      empathy_contact_get_id (contact),
-		      empathy_contact_get_handle (contact),
-		      is_member ? "added" : "removed");
+	DEBUG ("Contact %s (%d) %s",
+		empathy_contact_get_id (contact),
+		empathy_contact_get_handle (contact),
+		is_member ? "added" : "removed");
 
 	if (is_member) {
 		g_signal_connect (contact, "notify::presence",
@@ -831,9 +830,9 @@
 
 	priv = GET_PRIV (store);
 
-	empathy_debug (DEBUG_DOMAIN, "Updating groups for contact %s (%d)",
-		      empathy_contact_get_id (contact),
-		      empathy_contact_get_handle (contact));
+	DEBUG ("Updating groups for contact %s (%d)",
+		empathy_contact_get_id (contact),
+		empathy_contact_get_handle (contact));
 
 	/* We do this to make sure the groups are correct, if not, we
 	 * would have to check the groups already set up for each
@@ -978,18 +977,16 @@
 
 	if (!in_list && !should_be_in_list) {
 		/* Nothing to do. */
-		empathy_debug (DEBUG_DOMAIN,
-			      "Contact:'%s' in list:NO, should be:NO",
-			      empathy_contact_get_name (contact));
+		DEBUG ("Contact:'%s' in list:NO, should be:NO",
+			empathy_contact_get_name (contact));
 
 		g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
 		g_list_free (iters);
 		return;
 	}
 	else if (in_list && !should_be_in_list) {
-		empathy_debug (DEBUG_DOMAIN,
-			      "Contact:'%s' in list:YES, should be:NO",
-			      empathy_contact_get_name (contact));
+		DEBUG ("Contact:'%s' in list:YES, should be:NO",
+			empathy_contact_get_name (contact));
 
 		if (priv->show_active) {
 			do_remove = TRUE;
@@ -997,28 +994,26 @@
 			do_set_refresh = TRUE;
 
 			set_model = TRUE;
-			empathy_debug (DEBUG_DOMAIN, "Remove item (after timeout)");
+			DEBUG ("Remove item (after timeout)");
 		} else {
-			empathy_debug (DEBUG_DOMAIN, "Remove item (now)!");
+			DEBUG ("Remove item (now)!");
 			contact_list_store_remove_contact (store, contact);
 		}
 	}
 	else if (!in_list && should_be_in_list) {
-		empathy_debug (DEBUG_DOMAIN,
-			      "Contact:'%s' in list:NO, should be:YES",
-			      empathy_contact_get_name (contact));
+		DEBUG ("Contact:'%s' in list:NO, should be:YES",
+			empathy_contact_get_name (contact));
 
 		contact_list_store_add_contact (store, contact);
 
 		if (priv->show_active) {
 			do_set_active = TRUE;
 
-			empathy_debug (DEBUG_DOMAIN, "Set active (contact added)");
+			DEBUG ("Set active (contact added)");
 		}
 	} else {
-		empathy_debug (DEBUG_DOMAIN,
-			      "Contact:'%s' in list:YES, should be:YES",
-			      empathy_contact_get_name (contact));
+		DEBUG ("Contact:'%s' in list:YES, should be:YES",
+			empathy_contact_get_name (contact));
 
 		/* Get online state before. */
 		if (iters && g_list_length (iters) > 0) {
@@ -1033,15 +1028,15 @@
 				do_set_active = TRUE;
 				do_set_refresh = TRUE;
 
-				empathy_debug (DEBUG_DOMAIN, "Set active (contact updated %s)",
-					      was_online ? "online  -> offline" :
-							   "offline -> online");
+				DEBUG ("Set active (contact updated %s)",
+					was_online ? "online  -> offline" :
+					"offline -> online");
 			} else {
 				/* Was TRUE for presence updates. */
 				/* do_set_active = FALSE;  */
 				do_set_refresh = TRUE;
 
-				empathy_debug (DEBUG_DOMAIN, "Set active (contact updated)");
+				DEBUG ("Set active (contact updated)");
 			}
 		}
 
@@ -1096,9 +1091,8 @@
 				       GParamSpec              *param,
 				       EmpathyContactListStore *store)
 {
-	empathy_debug (DEBUG_DOMAIN,
-		      "Contact:'%s' updated, checking roster is in sync...",
-		      empathy_contact_get_name (contact));
+	DEBUG ("Contact:'%s' updated, checking roster is in sync...",
+		empathy_contact_get_name (contact));
 
 	contact_list_store_contact_update (store, contact);
 }
@@ -1124,7 +1118,7 @@
 				    EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, active,
 				    -1);
 
-		empathy_debug (DEBUG_DOMAIN, "Set item %s", active ? "active" : "inactive");
+		DEBUG ("Set item %s", active ? "active" : "inactive");
 
 		if (set_changed) {
 			path = gtk_tree_model_get_path (model, l->data);
@@ -1145,10 +1139,9 @@
 {
 	ShowActiveData *data;
 
-	empathy_debug (DEBUG_DOMAIN, 
-		      "Contact:'%s' now active, and %s be removed",
-		      empathy_contact_get_name (contact), 
-		      remove ? "WILL" : "WILL NOT");
+	DEBUG ("Contact:'%s' now active, and %s be removed",
+		empathy_contact_get_name (contact), 
+		remove ? "WILL" : "WILL NOT");
 	
 	data = g_slice_new0 (ShowActiveData);
 
@@ -1178,15 +1171,13 @@
 	if (data->remove &&
 	    !priv->show_offline &&
 	    !empathy_contact_is_online (data->contact)) {
-		empathy_debug (DEBUG_DOMAIN, 
-			      "Contact:'%s' active timeout, removing item",
-			      empathy_contact_get_name (data->contact));
+		DEBUG ("Contact:'%s' active timeout, removing item",
+			empathy_contact_get_name (data->contact));
 		contact_list_store_remove_contact (data->store, data->contact);
 	}
 
-	empathy_debug (DEBUG_DOMAIN, 
-		      "Contact:'%s' no longer active",
-		      empathy_contact_get_name (data->contact));
+	DEBUG ("Contact:'%s' no longer active",
+		empathy_contact_get_name (data->contact));
 
 	contact_list_store_contact_set_active (data->store,
 					       data->contact,

Modified: trunk/libempathy-gtk/empathy-contact-list-view.c
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-list-view.c	(original)
+++ trunk/libempathy-gtk/empathy-contact-list-view.c	Wed Apr 30 21:44:38 2008
@@ -36,7 +36,6 @@
 #include <libempathy/empathy-contact-factory.h>
 #include <libempathy/empathy-contact-list.h>
 #include <libempathy/empathy-contact-groups.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 
 #include "empathy-contact-list-view.h"
@@ -49,7 +48,8 @@
 #include "empathy-gtk-enum-types.h"
 #include "empathy-gtk-marshal.h"
 
-#define DEBUG_DOMAIN "ContactListView"
+#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
+#include <libempathy/empathy-debug.h>
 
 /* Flashing delay for icons (milliseconds). */
 #define FLASH_TIMEOUT 500
@@ -141,10 +141,10 @@
 	priv = GET_PRIV (widget);
 
 	id = (const gchar*) selection->data;
-	empathy_debug (DEBUG_DOMAIN, "Received %s%s drag & drop contact from roster with id:'%s'",
-		      context->action == GDK_ACTION_MOVE ? "move" : "",
-		      context->action == GDK_ACTION_COPY ? "copy" : "",
-		      id);
+	DEBUG ("Received %s%s drag & drop contact from roster with id:'%s'",
+		context->action == GDK_ACTION_MOVE ? "move" : "",
+		context->action == GDK_ACTION_COPY ? "copy" : "",
+		id);
 
 	strv = g_strsplit (id, "/", 2);
 	factory = empathy_contact_factory_new ();
@@ -159,7 +159,7 @@
 	g_strfreev (strv);
 
 	if (!contact) {
-		empathy_debug (DEBUG_DOMAIN, "No contact found associated with drag & drop");
+		DEBUG ("No contact found associated with drag & drop");
 		return;
 	}
 
@@ -190,11 +190,10 @@
 		gtk_tree_path_free (path);
 	}
 
-	empathy_debug (DEBUG_DOMAIN,
-		      "contact %s (%d) dragged from '%s' to '%s'",
-		      empathy_contact_get_id (contact),
-		      empathy_contact_get_handle (contact),
-		      old_group, new_group);
+	DEBUG ("contact %s (%d) dragged from '%s' to '%s'",
+		empathy_contact_get_id (contact),
+		empathy_contact_get_handle (contact),
+		old_group, new_group);
 
 	list = empathy_contact_list_store_get_list_iface (priv->store);
 	if (new_group) {

Modified: trunk/libempathy-gtk/empathy-contact-menu.c
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-menu.c	(original)
+++ trunk/libempathy-gtk/empathy-contact-menu.c	Wed Apr 30 21:44:38 2008
@@ -34,8 +34,6 @@
 #include "empathy-log-window.h"
 #include "empathy-contact-dialogs.h"
 
-#define DEBUG_DOMAIN "ContactMenu"
-
 GtkWidget *
 empathy_contact_menu_new (EmpathyContact             *contact,
 			  EmpathyContactFeatureFlags  features)

Modified: trunk/libempathy-gtk/empathy-geometry.c
==============================================================================
--- trunk/libempathy-gtk/empathy-geometry.c	(original)
+++ trunk/libempathy-gtk/empathy-geometry.c	Wed Apr 30 21:44:38 2008
@@ -29,11 +29,10 @@
 #include <glib.h>
 #include <gdk/gdk.h>
 
-#include <libempathy/empathy-debug.h>
-
 #include "empathy-geometry.h"
 
-#define DEBUG_DOMAIN "Geometry"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 #define GEOMETRY_DIR_CREATE_MODE  (S_IRUSR | S_IWUSR | S_IXUSR)
 #define GEOMETRY_FILE_CREATE_MODE (S_IRUSR | S_IWUSR)
@@ -52,7 +51,7 @@
 
 	dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
 	if (!g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
-		empathy_debug (DEBUG_DOMAIN, "Creating directory:'%s'", dir);
+		DEBUG ("Creating directory:'%s'", dir);
 		g_mkdir_with_parents (dir, GEOMETRY_DIR_CREATE_MODE);
 	}
 
@@ -79,8 +78,8 @@
 	gsize        length;
 	gchar       *str;
 
-	empathy_debug (DEBUG_DOMAIN, "Saving window geometry: x:%d, y:%d, w:%d, h:%d\n",
-		      x, y, w, h);
+	DEBUG ("Saving window geometry: x:%d, y:%d, w:%d, h:%d\n",
+		x, y, w, h);
 
 	screen = gdk_screen_get_default ();
 	max_width = gdk_screen_get_width (screen);
@@ -174,11 +173,8 @@
 		g_free (str);
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Loading window geometry: x:%d, y:%d, w:%d, h:%d\n",
-		      x ? *x : -1,
-		      y ? *y : -1,
-		      w ? *w : -1,
-		      h ? *h : -1);
+	DEBUG ("Loading window geometry: x:%d, y:%d, w:%d, h:%d\n",
+		x ? *x : -1, y ? *y : -1, w ? *w : -1, h ? *h : -1);
 
 	g_free (filename);
 	g_key_file_free (key_file);

Modified: trunk/libempathy-gtk/empathy-irc-network-dialog.c
==============================================================================
--- trunk/libempathy-gtk/empathy-irc-network-dialog.c	(original)
+++ trunk/libempathy-gtk/empathy-irc-network-dialog.c	Wed Apr 30 21:44:38 2008
@@ -32,7 +32,6 @@
 #include <libmissioncontrol/mc-protocol.h>
 
 #include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-debug.h>
 
 #include <libempathy/empathy-irc-network-manager.h>
 #include "empathy-ui-utils.h"
@@ -40,8 +39,6 @@
 
 #include "empathy-irc-network-dialog.h"
 
-#define DEBUG_DOMAIN "AccountWidgetIRC"
-
 typedef struct {
   EmpathyIrcNetwork *network;
 

Modified: trunk/libempathy-gtk/empathy-log-window.c
==============================================================================
--- trunk/libempathy-gtk/empathy-log-window.c	(original)
+++ trunk/libempathy-gtk/empathy-log-window.c	Wed Apr 30 21:44:38 2008
@@ -35,7 +35,6 @@
 #include <libempathy/empathy-chatroom-manager.h>
 #include <libempathy/empathy-chatroom.h>
 #include <libempathy/empathy-message.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-time.h>
 
@@ -44,7 +43,8 @@
 #include "empathy-chat-view.h"
 #include "empathy-ui-utils.h"
 
-#define DEBUG_DOMAIN "LogWindow"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 typedef struct {
 	GtkWidget         *window;
@@ -895,7 +895,7 @@
 			}
 
 
-			empathy_debug (DEBUG_DOMAIN, "Marking date:'%s'", str);
+			DEBUG ("Marking date:'%s'", str);
 			gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats), day);
 
 			if (l->next) {
@@ -986,7 +986,7 @@
 
 	date = g_strdup_printf ("%4.4d%2.2d%2.2d", year, month, day);
 
-	empathy_debug (DEBUG_DOMAIN, "Currently selected date is:'%s'", date);
+	DEBUG ("Currently selected date is:'%s'", date);
 
 	log_window_chats_get_messages (window, date);
 
@@ -1010,7 +1010,7 @@
 
 	if (!log_window_chats_get_selected (window, &account,
 					    &chat_id, &is_chatroom)) {
-		empathy_debug (DEBUG_DOMAIN, "No chat selected to get dates for...");
+		DEBUG ("No chat selected to get dates for...");
 		return;
 	}
 
@@ -1042,7 +1042,7 @@
 		sscanf (str, "%4d%2d%2d", &year, &month, &day);
 
 		if (year == year_selected && month == month_selected) {
-			empathy_debug (DEBUG_DOMAIN, "Marking date:'%s'", str);
+			DEBUG ("Marking date:'%s'", str);
 			gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats), day);
 		}
 	}
@@ -1050,9 +1050,8 @@
 	g_list_foreach (dates, (GFunc) g_free, NULL);
 	g_list_free (dates);
 
-	empathy_debug (DEBUG_DOMAIN,
-		      "Currently showing month %d and year %d",
-		      month_selected, year_selected);
+	DEBUG ("Currently showing month %d and year %d", month_selected,
+		year_selected);
 }
 
 static void

Modified: trunk/libempathy-gtk/empathy-new-message-dialog.c
==============================================================================
--- trunk/libempathy-gtk/empathy-new-message-dialog.c	(original)
+++ trunk/libempathy-gtk/empathy-new-message-dialog.c	Wed Apr 30 21:44:38 2008
@@ -32,7 +32,6 @@
 #include <libmissioncontrol/mission-control.h>
 
 #include <libempathy/empathy-contact-factory.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 
 #include <libempathy-gtk/empathy-ui-utils.h>
@@ -40,8 +39,6 @@
 #include "empathy-new-message-dialog.h"
 #include "empathy-account-chooser.h"
 
-#define DEBUG_DOMAIN "NewMessageDialog"
-
 typedef struct {
 	GtkWidget *dialog;
 	GtkWidget *table_contact;

Modified: trunk/libempathy-gtk/empathy-presence-chooser.c
==============================================================================
--- trunk/libempathy-gtk/empathy-presence-chooser.c	(original)
+++ trunk/libempathy-gtk/empathy-presence-chooser.c	Wed Apr 30 21:44:38 2008
@@ -36,7 +36,6 @@
 
 #include <libempathy/empathy-idle.h>
 #include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-status-presets.h>
 
 #include "empathy-ui-utils.h"
@@ -45,8 +44,6 @@
 
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserPriv))
 
-#define DEBUG_DOMAIN "PresenceChooser"
-
 /* Flashing delay for icons (milliseconds). */
 #define FLASH_TIMEOUT 500
 

Modified: trunk/libempathy-gtk/empathy-smiley-manager.c
==============================================================================
--- trunk/libempathy-gtk/empathy-smiley-manager.c	(original)
+++ trunk/libempathy-gtk/empathy-smiley-manager.c	Wed Apr 30 21:44:38 2008
@@ -24,16 +24,12 @@
 
 #include <string.h>
 
-#include <libempathy/empathy-debug.h>
-
 #include "empathy-smiley-manager.h"
 #include "empathy-ui-utils.h"
 
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
 		       EMPATHY_TYPE_SMILEY_MANAGER, EmpathySmileyManagerPriv))
 
-#define DEBUG_DOMAIN "SmileyManager"
-
 typedef struct {
 	gunichar   c;
 	GdkPixbuf *pixbuf;

Modified: trunk/libempathy-gtk/empathy-spell.c
==============================================================================
--- trunk/libempathy-gtk/empathy-spell.c	(original)
+++ trunk/libempathy-gtk/empathy-spell.c	Wed Apr 30 21:44:38 2008
@@ -32,12 +32,11 @@
 #include <enchant.h>
 #endif
 
-#include <libempathy/empathy-debug.h>
-
 #include "empathy-spell.h"
 #include "empathy-conf.h"
 
-#define DEBUG_DOMAIN "Spell"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 #ifdef HAVE_ENCHANT
 
@@ -166,7 +165,7 @@
 {
 	GList *l;
 
-	empathy_debug (DEBUG_DOMAIN, "Resetting languages due to config change");
+	DEBUG ("Resetting languages due to config change");
 
 	/* We just reset the languages list. */
 	for (l = languages; l; l = l->next) {
@@ -213,7 +212,7 @@
 		while (strv && strv[i]) {
 			SpellLanguage *lang;
 
-			empathy_debug (DEBUG_DOMAIN, "Setting up language:'%s'", strv[i]);
+			DEBUG ("Setting up language:'%s'", strv[i]);
 
 			lang = g_slice_new0 (SpellLanguage);
 
@@ -310,7 +309,7 @@
 	spell_setup_languages ();
 
 	if (!languages) {
-		empathy_debug (DEBUG_DOMAIN, "No languages to check against");
+		DEBUG ("No languages to check against");
 		return TRUE;
 	}
 
@@ -322,7 +321,7 @@
 
 	if (digit) {
 		/* We don't spell check digits. */
-		empathy_debug (DEBUG_DOMAIN, "Not spell checking word:'%s', it is all digits", word);
+		DEBUG ("Not spell checking word:'%s', it is all digits", word);
 		return TRUE;
 	}
 
@@ -382,7 +381,7 @@
 empathy_spell_supported (void)
 {
 	if (g_getenv ("EMPATHY_SPELL_DISABLED")) {
-		empathy_debug (DEBUG_DOMAIN, "EMPATHY_SPELL_DISABLE env variable defined");
+		DEBUG ("EMPATHY_SPELL_DISABLE env variable defined");
 		return FALSE;
 	}
 
@@ -400,7 +399,7 @@
 GList *
 empathy_spell_get_suggestions (const gchar *word)
 {
-	empathy_debug (DEBUG_DOMAIN, "Support disabled, could not get suggestions");
+	DEBUG ("Support disabled, could not get suggestions");
 
 	return NULL;
 }
@@ -408,7 +407,7 @@
 gboolean
 empathy_spell_check (const gchar *word)
 {
-	empathy_debug (DEBUG_DOMAIN, "Support disabled, could not check spelling");
+	DEBUG ("Support disabled, could not check spelling");
 
 	return TRUE;
 }
@@ -416,7 +415,7 @@
 const gchar *
 empathy_spell_get_language_name (const gchar *lang)
 {
-	empathy_debug (DEBUG_DOMAIN, "Support disabled, could not get language name");
+	DEBUG ("Support disabled, could not get language name");
 
 	return NULL;
 }
@@ -424,7 +423,7 @@
 GList *
 empathy_spell_get_language_codes (void)
 {
-	empathy_debug (DEBUG_DOMAIN, "Support disabled, could not get language codes");
+	DEBUG ("Support disabled, could not get language codes");
 
 	return NULL;
 }

Modified: trunk/libempathy-gtk/empathy-spell.h
==============================================================================
--- trunk/libempathy-gtk/empathy-spell.h	(original)
+++ trunk/libempathy-gtk/empathy-spell.h	Wed Apr 30 21:44:38 2008
@@ -24,6 +24,8 @@
 #ifndef __EMPATHY_SPELL_H__
 #define __EMPATHY_SPELL_H__
 
+#include <glib.h>
+
 G_BEGIN_DECLS
 
 gboolean     empathy_spell_supported           (void);

Modified: trunk/libempathy-gtk/empathy-theme-boxes.c
==============================================================================
--- trunk/libempathy-gtk/empathy-theme-boxes.c	(original)
+++ trunk/libempathy-gtk/empathy-theme-boxes.c	Wed Apr 30 21:44:38 2008
@@ -25,12 +25,11 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
-#include <libempathy/empathy-debug.h>
-
 #include "empathy-ui-utils.h"
 #include "empathy-theme-boxes.h"
 
-#define DEBUG_DOMAIN "FancyTheme"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 #define MARGIN 4
 #define HEADER_PADDING 2
@@ -549,7 +548,7 @@
 	last_contact = empathy_chat_view_get_last_contact (view);
 	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
 
-	empathy_debug (DEBUG_DOMAIN, "Maybe add fancy header");
+	DEBUG ("Maybe add fancy header");
 
 	/* Only insert a header if the previously inserted block is not the same
 	 * as this one. This catches all the different cases:

Modified: trunk/libempathy-gtk/empathy-theme-irc.c
==============================================================================
--- trunk/libempathy-gtk/empathy-theme-irc.c	(original)
+++ trunk/libempathy-gtk/empathy-theme-irc.c	Wed Apr 30 21:44:38 2008
@@ -21,14 +21,11 @@
 #include "config.h"
 
 #include <glib/gi18n.h>
-#include <libempathy/empathy-debug.h>
 
 #include "empathy-chat.h"
 #include "empathy-ui-utils.h"
 #include "empathy-theme-irc.h"
 
-#define DEBUG_DOMAIN "Theme"
-
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_THEME_IRC, EmpathyThemeIrcPriv))
 
 typedef struct _EmpathyThemeIrcPriv EmpathyThemeIrcPriv;

Modified: trunk/libempathy-gtk/empathy-theme.c
==============================================================================
--- trunk/libempathy-gtk/empathy-theme.c	(original)
+++ trunk/libempathy-gtk/empathy-theme.c	Wed Apr 30 21:44:38 2008
@@ -24,7 +24,6 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 
 #include "empathy-chat.h"
@@ -32,8 +31,6 @@
 #include "empathy-theme.h"
 #include "empathy-smiley-manager.h"
 
-#define DEBUG_DOMAIN "Theme"
-
 /* Number of seconds between timestamps when using normal mode, 5 minutes. */
 #define TIMESTAMP_INTERVAL 300
 

Modified: trunk/libempathy-gtk/empathy-ui-utils.c
==============================================================================
--- trunk/libempathy-gtk/empathy-ui-utils.c	(original)
+++ trunk/libempathy-gtk/empathy-ui-utils.c	Wed Apr 30 21:44:38 2008
@@ -40,12 +40,11 @@
 
 #include <libmissioncontrol/mc-profile.h>
 
-#include <libempathy/empathy-debug.h>
-
 #include "empathy-ui-utils.h"
 #include "empathy-images.h"
 
-#define DEBUG_DOMAIN "UiUtils"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 struct SizeData {
 	gint     width;
@@ -64,7 +63,7 @@
 	const char *name;
 	GtkWidget **widget_ptr;
 
-	empathy_debug (DEBUG_DOMAIN, "Loading glade file %s", filename);
+	DEBUG ("Loading glade file %s", filename);
 
 	gui = glade_xml_new (filename, root, domain);
 
@@ -259,15 +258,15 @@
 
 	loader = gdk_pixbuf_loader_new ();
 	if (!gdk_pixbuf_loader_write (loader, data, data_size, &error)) {
-		empathy_debug (DEBUG_DOMAIN, "Failed to write to pixbuf loader: %s",
-			       error ? error->message : "No error given");
+		DEBUG ("Failed to write to pixbuf loader: %s",
+			error ? error->message : "No error given");
 		g_clear_error (&error);
 		g_object_unref (loader);
 		return NULL;
 	}
 	if (!gdk_pixbuf_loader_close (loader, &error)) {
-		empathy_debug (DEBUG_DOMAIN, "Failed to close pixbuf loader: %s",
-			       error ? error->message : "No error given");
+		DEBUG ("Failed to close pixbuf loader: %s",
+			error ? error->message : "No error given");
 		g_clear_error (&error);
 		g_object_unref (loader);
 		return NULL;
@@ -527,7 +526,7 @@
 					   0,
 					   &error);
 	if (error) {
-		empathy_debug (DEBUG_DOMAIN, "Error loading icon: %s", error->message);
+		DEBUG ("Error loading icon: %s", error->message);
 		g_clear_error (&error);
 	}
 

Modified: trunk/libempathy/empathy-avatar.c
==============================================================================
--- trunk/libempathy/empathy-avatar.c	(original)
+++ trunk/libempathy/empathy-avatar.c	Wed Apr 30 21:44:38 2008
@@ -20,15 +20,16 @@
  * Authors: Xavier Claessens <xclaesse gmail com>
  */
 
+
 #include "config.h"
 
 #include <telepathy-glib/util.h>
 
 #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 @@
 	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 @@
 	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));
 	}
 

Modified: trunk/libempathy/empathy-chatroom-manager.c
==============================================================================
--- trunk/libempathy/empathy-chatroom-manager.c	(original)
+++ trunk/libempathy/empathy-chatroom-manager.c	Wed Apr 30 21:44:38 2008
@@ -31,11 +31,11 @@
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 
-#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 @@
 
 	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 @@
 		}
 	}
 
-	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 @@
 	/* 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);
 

Modified: trunk/libempathy/empathy-contact-groups.c
==============================================================================
--- trunk/libempathy/empathy-contact-groups.c	(original)
+++ trunk/libempathy/empathy-contact-groups.c	Wed Apr 30 21:44:38 2008
@@ -32,11 +32,11 @@
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 
-#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 @@
 	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 @@
 		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 @@
 	/* 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);
 

Modified: trunk/libempathy/empathy-contact-manager.c
==============================================================================
--- trunk/libempathy/empathy-contact-manager.c	(original)
+++ trunk/libempathy/empathy-contact-manager.c	Wed Apr 30 21:44:38 2008
@@ -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 @@
 
 	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 @@
 		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) {

Modified: trunk/libempathy/empathy-contact.c
==============================================================================
--- trunk/libempathy/empathy-contact.c	(original)
+++ trunk/libempathy/empathy-contact.c	Wed Apr 30 21:44:38 2008
@@ -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 @@
 
 	priv = GET_PRIV (object);
 
-	empathy_debug (DEBUG_DOMAIN, "finalize: %p", object);
+	DEBUG ("finalize: %p", object);
 
 	g_free (priv->name);
 	g_free (priv->id);

Modified: trunk/libempathy/empathy-debug.c
==============================================================================
--- trunk/libempathy/empathy-debug.c	(original)
+++ trunk/libempathy/empathy-debug.c	Wed Apr 30 21:44:38 2008
@@ -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 <richard imendio com>
+ * 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 <errno.h>
+#include <fcntl.h>
 #include <stdarg.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
+#include <unistd.h>
 
 #include <glib.h>
-#include <glib/gprintf.h>
 #include <glib/gstdio.h>
 
 #include <telepathy-glib/debug.h>
 
-/* 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;
+#ifdef ENABLE_DEBUG
 
-static void
-debug_init (void)
-{
-	static gboolean inited = FALSE;
+static EmpathyDebugFlags flags = 0;
 
-	if (!inited) {
-		const gchar *env;
-		gint         i;
-
-		env = g_getenv ("TELEPATHY_GLIB_DEBUG");
-		tp_debug_set_flags (env);
-
-		env = g_getenv ("EMPATHY_DEBUG");
-
-		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;
-			}
-		}
+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, }
+};
 
-		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;
-
-	g_return_if_fail (domain != NULL);
-	g_return_if_fail (msg != NULL);
-
-	debug_init ();
+  guint nkeys;
 
-	for (i = 0; debug_strv && debug_strv[i]; i++) {
-		if (all_domains || strcmp (domain, debug_strv[i]) == 0) {
-			va_list args;
+  for (nkeys = 0; keys[nkeys].value; nkeys++);
+g_print ("%s %d\n", flags_string, nkeys);
+  //tp_debug_set_flags (flags_string);
 
-			g_print ("%s: ", domain);
-
-			va_start (args, msg);
-			g_vprintf (msg, args);
-			va_end (args);
+  if (flags_string)
+      debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys));
+}
 
-			g_print ("\n");
-			break;
-		}
-	}
+gboolean
+empathy_debug_flag_is_set (EmpathyDebugFlags flag)
+{
+  return (flag & flags) != 0;
 }
 
 void
-empathy_debug_set_log_file_from_env (void)
+empathy_debug (EmpathyDebugFlags flag,
+               const gchar *format,
+               ...)
 {
-	const gchar *output_file;
-	gint         out;
+  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
 
-	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;
-	}
+void
+empathy_debug_set_flags (const gchar *flags_string)
+{
 }
 
+#endif /* ENABLE_DEBUG */
+

Modified: trunk/libempathy/empathy-debug.h
==============================================================================
--- trunk/libempathy/empathy-debug.h	(original)
+++ trunk/libempathy/empathy-debug.h	Wed Apr 30 21:44:38 2008
@@ -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 <richard imendio com>
+ * 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 <glib.h>
+#include <telepathy-glib/debug.h>
 
 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) */

Modified: trunk/libempathy/empathy-idle.c
==============================================================================
--- trunk/libempathy/empathy-idle.c	(original)
+++ trunk/libempathy/empathy-idle.c	Wed Apr 30 21:44:38 2008
@@ -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 @@
 					     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 @@
 					     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 @@
 
 	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 @@
 				   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 @@
 
 	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 @@
 
 	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 @@
 			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 @@
 		/* 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 @@
 
 	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 @@
 
 	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;
 

Modified: trunk/libempathy/empathy-irc-network-manager.c
==============================================================================
--- trunk/libempathy/empathy-irc-network-manager.c	(original)
+++ trunk/libempathy/empathy-irc-network-manager.c	Wed Apr 30 21:44:38 2008
@@ -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 @@
 
   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 @@
 
   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 @@
 
   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 @@
           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 @@
     {
       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 @@
     }
 
   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 @@
 
   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 @@
 
   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");

Modified: trunk/libempathy/empathy-log-manager.c
==============================================================================
--- trunk/libempathy/empathy-log-manager.c	(original)
+++ trunk/libempathy/empathy-log-manager.c	Wed Apr 30 21:44:38 2008
@@ -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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 		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 @@
 	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 @@
 
 			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);
 			}
 		}
 

Modified: trunk/libempathy/empathy-status-presets.c
==============================================================================
--- trunk/libempathy/empathy-status-presets.c	(original)
+++ trunk/libempathy/empathy-status-presets.c	Wed Apr 30 21:44:38 2008
@@ -34,11 +34,11 @@
 
 #include <telepathy-glib/util.h>
 
-#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 @@
 	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 @@
 				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_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 @@
 	/* 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);
 

Modified: trunk/libempathy/empathy-tp-call.c
==============================================================================
--- trunk/libempathy/empathy-tp-call.c	(original)
+++ trunk/libempathy/empathy-tp-call.c	Wed Apr 30 21:44:38 2008
@@ -28,13 +28,13 @@
 
 #include <extensions/extensions.h>
 #include <libempathy/empathy-contact-factory.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-tp-group.h>
 #include <libempathy/empathy-utils.h>
 
 #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 @@
   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 @@
         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 @@
         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 @@
                          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 @@
 {
   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 @@
 {
   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 @@
 {
   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 @@
 
   if (error)
     {
-      empathy_debug (DEBUG_DOMAIN, "Error requesting streams: %s", error->message);
+      DEBUG ("Error requesting streams: %s", error->message);
       return;
     }
 
@@ -248,7 +242,7 @@
   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 @@
 {
   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 @@
 {
   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 @@
   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 @@
 				      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 @@
   /* 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 @@
   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 @@
 {
   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 @@
   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 @@
   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 @@
 
   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 @@
 
   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 @@
 
   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 @@
   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 @@
 
   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 @@
 
   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,

Modified: trunk/libempathy/empathy-tp-chat.c
==============================================================================
--- trunk/libempathy/empathy-tp-chat.c	(original)
+++ trunk/libempathy/empathy-tp-chat.c	Wed Apr 30 21:44:38 2008
@@ -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 @@
 			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 @@
 		  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 @@
 			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 @@
 	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 @@
 	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 @@
 		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 @@
 {
 	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 @@
 {
 	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 @@
 							   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 @@
 	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 @@
 		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 @@
 			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 @@
 					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 @@
 			   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 @@
 	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 @@
 		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 @@
 			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 @@
 	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 @@
 	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 @@
 	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 @@
 	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,

Modified: trunk/libempathy/empathy-tp-contact-factory.c
==============================================================================
--- trunk/libempathy/empathy-tp-contact-factory.c	(original)
+++ trunk/libempathy/empathy-tp-contact-factory.c	Wed Apr 30 21:44:38 2008
@@ -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 @@
 {
 	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 @@
 			      (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 @@
 				    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 @@
 				   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 @@
 	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 @@
 			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 @@
 			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 @@
 				  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 @@
 				    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 @@
 		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 @@
 				       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 @@
 	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_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 @@
 		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 @@
 		}
 	}
 
-	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 @@
 	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 @@
 	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 @@
 	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 @@
 {
 	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 @@
 	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_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 @@
 				    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 @@
 
 	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 @@
 		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 @@
 								     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 @@
 	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);
 

Modified: trunk/libempathy/empathy-tp-contact-list.c
==============================================================================
--- trunk/libempathy/empathy-tp-contact-list.c	(original)
+++ trunk/libempathy/empathy-tp-contact-list.c	Wed Apr 30 21:44:38 2008
@@ -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 @@
 {
 	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 @@
 
 	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 @@
 
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 			}
 			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 @@
 			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 @@
 		}
 		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 @@
 	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 @@
 	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 @@
 		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 @@
 						    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 @@
 		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 @@
 		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);

Modified: trunk/libempathy/empathy-tp-group.c
==============================================================================
--- trunk/libempathy/empathy-tp-group.c	(original)
+++ trunk/libempathy/empathy-tp-group.c	Wed Apr 30 21:44:38 2008
@@ -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 @@
 
 	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 @@
 		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 @@
 	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 @@
 				 0,       /* actor */
 				 0);      /* reason */
 
-	empathy_debug (DEBUG_DOMAIN, "Ready");
+	DEBUG ("Ready");
 	priv->ready = TRUE;
 	g_object_notify (group, "ready");
 }
@@ -365,8 +362,7 @@
 	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 @@
 				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 @@
 	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 @@
 			 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 @@
 	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 @@
 	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 @@
 	const gchar *msg = user_data;
 
 	if (error) {
-		empathy_debug (DEBUG_DOMAIN, "%s: %s", msg, error->message);
+		DEBUG ("%s: %s", msg, error->message);
 	}
 }
 

Modified: trunk/libempathy/empathy-tp-roomlist.c
==============================================================================
--- trunk/libempathy/empathy-tp-roomlist.c	(original)
+++ trunk/libempathy/empathy-tp-roomlist.c	Wed Apr 30 21:44:38 2008
@@ -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 @@
 {
 	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 @@
 	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 @@
 			    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 @@
 	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 @@
 	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);

Modified: trunk/libempathy/empathy-tp-tube.c
==============================================================================
--- trunk/libempathy/empathy-tp-tube.c	(original)
+++ trunk/libempathy/empathy-tp-tube.c	Wed Apr 30 21:44:38 2008
@@ -25,12 +25,12 @@
 #include <telepathy-glib/util.h>
 
 #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 @@
   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 @@
                         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 @@
   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 @@
                   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 @@
   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 @@
 {
   EmpathyTpTubePriv *priv = GET_PRIV (object);
 
-  empathy_debug (DEBUG_DOMAIN, "Finalizing: %p", object);
+  DEBUG ("Finalizing: %p", object);
 
   if (priv->channel)
     {
@@ -397,13 +396,13 @@
       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 @@
         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 @@
                           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 @@
 
   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 @@
 
   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;
     }

Modified: trunk/libempathy/empathy-tube-handler.c
==============================================================================
--- trunk/libempathy/empathy-tube-handler.c	(original)
+++ trunk/libempathy/empathy-tube-handler.c	Wed Apr 30 21:44:38 2008
@@ -31,11 +31,11 @@
 
 #include <extensions/extensions.h>
 
-#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 @@
   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 @@
       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;

Modified: trunk/libempathy/empathy-utils.c
==============================================================================
--- trunk/libempathy/empathy-utils.c	(original)
+++ trunk/libempathy/empathy-utils.c	Wed Apr 30 21:44:38 2008
@@ -37,13 +37,13 @@
 #include <telepathy-glib/channel.h>
 #include <telepathy-glib/dbus.h>
 
-#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 @@
 	}
 
 	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_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 @@
 		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 @@
 						    &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 @@
 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 @@
 		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;

Modified: trunk/megaphone/src/megaphone-applet.c
==============================================================================
--- trunk/megaphone/src/megaphone-applet.c	(original)
+++ trunk/megaphone/src/megaphone-applet.c	Wed Apr 30 21:44:38 2008
@@ -39,7 +39,6 @@
 #include <libempathy/empathy-contact.h>
 #include <libempathy/empathy-contact-list.h>
 #include <libempathy/empathy-contact-manager.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 
 #include <libempathy-gtk/empathy-contact-list-view.h>
@@ -49,7 +48,8 @@
 
 #include "megaphone-applet.h"
 
-#define DEBUG_DOMAIN "MegaphoneApplet"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MEGAPHONE_TYPE_APPLET, MegaphoneAppletPriv))
 
@@ -268,7 +268,7 @@
 	McAccount           *account = NULL;
 	gchar              **strv = NULL;
 
-	empathy_debug (DEBUG_DOMAIN, "Setting new contact %s", str);
+	DEBUG ("Setting new contact %s", str);
 
 	/* Release old contact, if any */
 	if (priv->contact) {
@@ -442,9 +442,9 @@
 		return TRUE;
 	}
 	
-	empathy_debug (DEBUG_DOMAIN, "Requesting text channel for contact %s (%d)",
-		       empathy_contact_get_id (priv->contact),
-		       empathy_contact_get_handle (priv->contact));
+	DEBUG ("Requesting text channel for contact %s (%d)",
+		empathy_contact_get_id (priv->contact),
+		empathy_contact_get_handle (priv->contact));
 
 	mc = empathy_mission_control_new ();
 	mission_control_request_channel (mc,
@@ -492,7 +492,7 @@
 
 	key = gconf_entry_get_key (entry);
 	value = gconf_entry_get_value (entry);
-	empathy_debug (DEBUG_DOMAIN, "GConf notification for key '%s'", key);
+	DEBUG ("GConf notification for key '%s'", key);
 
 	if (value && g_str_has_suffix (key, "/contact_id")) {
 		megaphone_applet_set_contact (applet,
@@ -514,7 +514,7 @@
 		return FALSE;
 	}
 	
-	empathy_debug (DEBUG_DOMAIN, "Starting up new instance!");
+	DEBUG ("Starting up new instance!");
 
 	/* Set up the right-click menu */
 	panel_applet_setup_menu_from_file (applet,

Modified: trunk/python/pyempathy/pyempathy.defs
==============================================================================
--- trunk/python/pyempathy/pyempathy.defs	(original)
+++ trunk/python/pyempathy/pyempathy.defs	Wed Apr 30 21:44:38 2008
@@ -143,6 +143,21 @@
 
 ;; Enumerations and flags ...
 
+(define-flags DebugFlags
+  (in-module "Empathy")
+  (c-name "EmpathyDebugFlags")
+  (gtype-id "EMPATHY_TYPE_DEBUG_FLAGS")
+  (values
+    '("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")
+  )
+)
+
 (define-enum RegExType
   (in-module "Empathy")
   (c-name "EmpathyRegExType")
@@ -359,19 +374,30 @@
 
 ;; From empathy-debug.h
 
-(define-function empathy_debug_impl
-  (c-name "empathy_debug_impl")
+(define-function empathy_debug_flag_is_set
+  (c-name "empathy_debug_flag_is_set")
+  (return-type "gboolean")
+  (parameters
+    '("EmpathyDebugFlags" "flag")
+  )
+)
+
+(define-function empathy_debug
+  (c-name "empathy_debug")
   (return-type "none")
   (parameters
-    '("const-gchar*" "domain")
-    '("const-gchar*" "msg")
+    '("EmpathyDebugFlags" "flag")
+    '("const-gchar*" "format")
   )
   (varargs #t)
 )
 
-(define-function empathy_debug_set_log_file_from_env
-  (c-name "empathy_debug_set_log_file_from_env")
+(define-function empathy_debug_set_flags
+  (c-name "empathy_debug_set_flags")
   (return-type "none")
+  (parameters
+    '("const-gchar*" "flags_string")
+  )
 )
 
 

Modified: trunk/python/pyempathygtk/pyempathygtk.defs
==============================================================================
--- trunk/python/pyempathygtk/pyempathygtk.defs	(original)
+++ trunk/python/pyempathygtk/pyempathygtk.defs	Wed Apr 30 21:44:38 2008
@@ -374,8 +374,8 @@
   (c-name "empathy_chat_correct_word")
   (return-type "none")
   (parameters
-    '("GtkTextIter" "start")
-    '("GtkTextIter" "end")
+    '("GtkTextIter*" "start")
+    '("GtkTextIter*" "end")
     '("const-gchar*" "new_word")
   )
 )
@@ -402,8 +402,8 @@
   (return-type "none")
   (parameters
     '("EmpathyChat*" "chat")
-    '("GtkTextIter" "start")
-    '("GtkTextIter" "end")
+    '("GtkTextIter*" "start")
+    '("GtkTextIter*" "end")
     '("const-gchar*" "word")
   )
 )

Modified: trunk/src/empathy-accounts.c
==============================================================================
--- trunk/src/empathy-accounts.c	(original)
+++ trunk/src/empathy-accounts.c	Wed Apr 30 21:44:38 2008
@@ -28,6 +28,7 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 
+#include <libempathy/empathy-debug.h>
 #include <libempathy-gtk/empathy-accounts-dialog.h>
 
 static void
@@ -44,6 +45,12 @@
 
 	gtk_init (&argc, &argv);
 
+	if (g_getenv ("EMPATHY_TIMING") != NULL) {
+		g_log_set_default_handler (tp_debug_timestamped_log_handler, NULL);
+	}
+	empathy_debug_set_flags (g_getenv ("EMPATHY_DEBUG"));
+	tp_debug_divert_messages (g_getenv ("EMPATHY_LOGFILE"));
+
 	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
 					   PKGDATADIR G_DIR_SEPARATOR_S "icons");
 	dialog = empathy_accounts_dialog_show (NULL);

Modified: trunk/src/empathy-call-window.c
==============================================================================
--- trunk/src/empathy-call-window.c	(original)
+++ trunk/src/empathy-call-window.c	Wed Apr 30 21:44:38 2008
@@ -30,13 +30,13 @@
 
 #include <libempathy/empathy-contact.h>
 #include <libempathy/empathy-tp-call.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
 
 #include "empathy-call-window.h"
 
-#define DEBUG_DOMAIN "CallWindow"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 typedef struct 
 {
@@ -98,7 +98,7 @@
 static void
 call_window_stop_timeout (EmpathyCallWindow *window)
 {
-  empathy_debug (DEBUG_DOMAIN, "Timer stopped");
+  DEBUG ("Timer stopped");
 
   if (window->timeout_event_id)
     {
@@ -111,8 +111,7 @@
 call_window_set_output_video_is_drawing (EmpathyCallWindow *window,
                                          gboolean is_drawing)
 {
-  empathy_debug (DEBUG_DOMAIN,
-      "Setting output video is drawing - %d", is_drawing);
+  DEBUG ("Setting output video is drawing - %d", is_drawing);
 
   if (is_drawing && !window->is_drawing)
     {
@@ -162,12 +161,12 @@
 {
   if (widget == window->preview_video_socket)
     {
-      empathy_debug (DEBUG_DOMAIN, "Preview socket realized");
+      DEBUG ("Preview socket realized");
       empathy_tp_call_add_preview_video (window->call,
           gtk_socket_get_id (GTK_SOCKET (window->preview_video_socket)));
     }
   else
-      empathy_debug (DEBUG_DOMAIN, "Output socket realized");
+      DEBUG ("Output socket realized");
 }
 
 static void
@@ -179,7 +178,7 @@
 
   is_sending = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
 
-  empathy_debug (DEBUG_DOMAIN, "Send video toggled - %d", is_sending);
+  DEBUG ("Send video toggled - %d", is_sending);
 
   g_object_get (window->call, "status", &status, NULL);
   if (status == EMPATHY_TP_CALL_STATUS_ACCEPTED)
@@ -190,7 +189,7 @@
 call_window_hang_up_button_clicked_cb (GtkWidget *widget,
                                        EmpathyCallWindow *window)
 {
-  empathy_debug (DEBUG_DOMAIN, "Call clicked, end call");
+  DEBUG ("Call clicked, end call");
   call_window_finalize (window);
 }
 
@@ -238,7 +237,7 @@
   gint result;
   guint status = EMPATHY_TP_CALL_STATUS_CLOSED;
 
-  empathy_debug (DEBUG_DOMAIN, "Delete event occurred");
+  DEBUG ("Delete event occurred");
 
   if (window->call)
       g_object_get (window->call, "status", &status, NULL);
@@ -349,7 +348,7 @@
   else
       stream_state = audio_stream->state;
 
-  empathy_debug (DEBUG_DOMAIN, "Status changed - status: %d, stream state: %d, "
+  DEBUG ("Status changed - status: %d, stream state: %d, "
       "is-incoming: %d video-stream direction: %d",
       window->status, stream_state, is_incoming, video_stream->direction);
 

Modified: trunk/src/empathy-chat-window.c
==============================================================================
--- trunk/src/empathy-chat-window.c	(original)
+++ trunk/src/empathy-chat-window.c	Wed Apr 30 21:44:38 2008
@@ -40,7 +40,6 @@
 #include <libempathy/empathy-contact-factory.h>
 #include <libempathy/empathy-contact.h>
 #include <libempathy/empathy-message.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 
 #include <libempathy-gtk/empathy-images.h>
@@ -53,9 +52,10 @@
 #include "empathy-chat-window.h"
 #include "empathy-about-dialog.h"
 
-#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CHAT_WINDOW, EmpathyChatWindowPriv))
+#define DEBUG_FLAG EMPATHY_DEBUG_CHAT
+#include <libempathy/empathy-debug.h>
 
-#define DEBUG_DOMAIN "ChatWindow"
+#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CHAT_WINDOW, EmpathyChatWindowPriv))
 
 struct _EmpathyChatWindowPriv {
 	EmpathyChat *current_chat;
@@ -297,7 +297,7 @@
 	name = chat_window_get_chat_name (priv->current_chat);
 	n_chats = g_list_length (priv->chats);
 
-	empathy_debug (DEBUG_DOMAIN, "Update window");
+	DEBUG ("Update window");
 
 	/* Update menu */
 	gtk_widget_set_sensitive (priv->menu_tabs_next, !last_page);
@@ -351,8 +351,8 @@
 	subject = empathy_chat_get_subject (chat);
 	remote_contact = empathy_chat_get_remote_contact (chat);
 
-	empathy_debug (DEBUG_DOMAIN, "Updating chat tab, name=%s, subject=%s, "
-		       "remote_contact=%p", name, subject, remote_contact);
+	DEBUG ("Updating chat tab, name=%s, subject=%s, remote_contact=%p",
+		name, subject, remote_contact);
 
 	/* Update tab image */
 	if (g_list_find (priv->chats_new_msg, chat)) {
@@ -713,7 +713,7 @@
 
 	priv = GET_PRIV (window);
 
-	empathy_debug (DEBUG_DOMAIN, "Delete event received");
+	DEBUG ("Delete event received");
 
 	list = g_list_copy (priv->chats);
 
@@ -752,8 +752,7 @@
 
 	priv = GET_PRIV (window);
 
-	empathy_debug (DEBUG_DOMAIN, "Turning %s urgency hint",
-		       urgent ? "on" : "off");
+	DEBUG ("Turning %s urgency hint", urgent ? "on" : "off");
 	gtk_window_set_urgency_hint (GTK_WINDOW (priv->dialog), urgent);
 }
 
@@ -807,7 +806,7 @@
 	new_window = empathy_chat_window_new ();
 	priv = GET_PRIV (new_window);
 
-	empathy_debug (DEBUG_DOMAIN, "Detach hook called");
+	DEBUG ("Detach hook called");
 
 	empathy_chat_window_move_chat (window, new_window, chat);
 
@@ -827,7 +826,7 @@
 	EmpathyChat           *chat;
 	GtkWidget            *child;
 
-	empathy_debug (DEBUG_DOMAIN, "Page switched");
+	DEBUG ("Page switched");
 
 	priv = GET_PRIV (window);
 
@@ -864,12 +863,12 @@
 	 * it, so we return here and in "page-added".
 	 */
 	if (priv->dnd_same_window) {
-		empathy_debug (DEBUG_DOMAIN, "Page added (back to the same window)");
+		DEBUG ("Page added (back to the same window)");
 		priv->dnd_same_window = FALSE;
 		return;
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Page added");
+	DEBUG ("Page added");
 
 	/* Get chat object */
 	chat = EMPATHY_CHAT (child);
@@ -909,11 +908,11 @@
 	 * it, so we return here and in "page-added".
 	 */
 	if (priv->dnd_same_window) {
-		empathy_debug (DEBUG_DOMAIN, "Page removed (and will be readded to same window)");
+		DEBUG ("Page removed (and will be readded to same window)");
 		return;
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Page removed");
+	DEBUG ("Page removed");
 
 	/* Get chat object */
 	chat = EMPATHY_CHAT (child);
@@ -945,7 +944,7 @@
 {
 	EmpathyChatWindowPriv *priv;
 
-	empathy_debug (DEBUG_DOMAIN, "Focus in event, updating title");
+	DEBUG ("Focus in event, updating title");
 
 	priv = GET_PRIV (window);
 
@@ -978,7 +977,7 @@
 
 		id = (const gchar*) selection->data;
 
-		empathy_debug (DEBUG_DOMAIN, "DND contact from roster with id:'%s'", id);
+		DEBUG ("DND contact from roster with id:'%s'", id);
 		
 		strv = g_strsplit (id, "/", 2);
 		account = mc_account_lookup (strv[0]);
@@ -1019,7 +1018,7 @@
 		EmpathyChat        **chat;
 		EmpathyChatWindow   *old_window = NULL;
 
-		empathy_debug (DEBUG_DOMAIN, "DND tab");
+		DEBUG ("DND tab");
 
 		chat = (void*) selection->data;
 		old_window = chat_window_find_chat (*chat);
@@ -1030,7 +1029,7 @@
 			priv = GET_PRIV (window);
 
 			if (old_window == window) {
-				empathy_debug (DEBUG_DOMAIN, "DND tab (within same window)");
+				DEBUG ("DND tab (within same window)");
 				priv->dnd_same_window = TRUE;
 				gtk_drag_finish (context, TRUE, FALSE, time);
 				return;
@@ -1046,7 +1045,7 @@
 		 */
 		gtk_drag_finish (context, TRUE, FALSE, time);
 	} else {
-		empathy_debug (DEBUG_DOMAIN, "DND from unknown source");
+		DEBUG ("DND from unknown source");
 		gtk_drag_finish (context, FALSE, FALSE, time);
 	}
 }
@@ -1060,7 +1059,7 @@
 	window = EMPATHY_CHAT_WINDOW (object);
 	priv = GET_PRIV (window);
 
-	empathy_debug (DEBUG_DOMAIN, "Finalized: %p", object);
+	DEBUG ("Finalized: %p", object);
 
 	if (priv->save_geometry_id != 0) {
 		g_source_remove (priv->save_geometry_id);
@@ -1343,9 +1342,7 @@
 	gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (priv->notebook), child,
 					    TRUE, TRUE, GTK_PACK_START); 
 
-	empathy_debug (DEBUG_DOMAIN, 
-		      "Chat added (%d references)",
-		      G_OBJECT (chat)->ref_count);
+	DEBUG ("Chat added (%d references)", G_OBJECT (chat)->ref_count);
 }
 
 void
@@ -1376,9 +1373,7 @@
 					  GTK_WIDGET (chat));
 	gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), position);
 
-	empathy_debug (DEBUG_DOMAIN, 
-		      "Chat removed (%d references)", 
-		      G_OBJECT (chat)->ref_count - 1);
+	DEBUG ("Chat removed (%d references)", G_OBJECT (chat)->ref_count - 1);
 
 	g_object_unref (chat);
 }
@@ -1396,10 +1391,8 @@
 
 	widget = GTK_WIDGET (chat);
 
-	empathy_debug (DEBUG_DOMAIN,
-		      "Chat moving with widget:%p (%d references)", 
-		      widget,
-		      G_OBJECT (widget)->ref_count);
+	DEBUG ("Chat moving with widget:%p (%d references)", widget,
+		G_OBJECT (widget)->ref_count);
 
 	/* We reference here to make sure we don't loose the widget
 	 * and the EmpathyChat object during the move.

Modified: trunk/src/empathy-filter.c
==============================================================================
--- trunk/src/empathy-filter.c	(original)
+++ trunk/src/empathy-filter.c	Wed Apr 30 21:44:38 2008
@@ -41,7 +41,6 @@
 #include <libempathy/empathy-tp-call.h>
 #include <libempathy/empathy-tp-group.h>
 #include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-tube-handler.h>
 #include <libempathy/empathy-contact-factory.h>
 
@@ -53,11 +52,12 @@
 #include "empathy-chat-window.h"
 #include "empathy-call-window.h"
 
+#define DEBUG_FLAG EMPATHY_DEBUG_FILTER
+#include <libempathy/empathy-debug.h>
+
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
 		       EMPATHY_TYPE_FILTER, EmpathyFilterPriv))
 
-#define DEBUG_DOMAIN "Filter"
-
 struct _EmpathyFilterPriv {
 	GSList         *events;
 	GHashTable     *accounts;
@@ -121,8 +121,7 @@
 	EmpathyFilterPriv     *priv = GET_PRIV (filter);
 	EmpathyFilterEventExt *event;
 
-	empathy_debug (DEBUG_DOMAIN, "Emit event, icon_name=%s message='%s'",
-		       icon_name, message);
+	DEBUG ("Emit event, icon_name=%s message='%s'", icon_name, message);
 
 	event = g_slice_new0 (EmpathyFilterEventExt);
 	event->func = func;
@@ -152,7 +151,7 @@
 		return;
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Activating event");
+	DEBUG ("Activating event");
 
 	is_top = (l == priv->events);
 	priv->events = g_slist_delete_link (priv->events, l);
@@ -243,8 +242,7 @@
 {
 	EmpathyTpChat *tp_chat;
 
-	empathy_debug (DEBUG_DOMAIN, "New text channel to be filtered: %p",
-		       channel);
+	DEBUG ("New text channel to be filtered: %p", channel);
 
 	tp_chat = empathy_tp_chat_new (channel, FALSE);
 	empathy_run_until_ready (tp_chat);
@@ -301,8 +299,7 @@
 {
 	EmpathyTpCall *call;
 
-	empathy_debug (DEBUG_DOMAIN, "New media channel to be filtered: %p",
-		       channel);
+	DEBUG ("New media channel to be filtered: %p", channel);
 
 	call = empathy_tp_call_new (channel);
 	if (is_incoming) {
@@ -334,7 +331,7 @@
 {
 	GString *str;
 
-	empathy_debug (DEBUG_DOMAIN, "New local pending contact");
+	DEBUG ("New local pending contact");
 
 	empathy_contact_run_until_ready (contact,
 					 EMPATHY_CONTACT_READY_NAME,
@@ -366,7 +363,7 @@
 		return;
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Publish contact list ready");
+	DEBUG ("Publish contact list ready");
 
 	g_signal_connect (group, "local-pending",
 			  G_CALLBACK (filter_contact_list_local_pending_cb),
@@ -391,8 +388,7 @@
 		       GObject      *filter)
 {
 	if (error) {
-		empathy_debug (DEBUG_DOMAIN, "Error %s: %s",
-			       user_data, error->message);
+		DEBUG ("Error %s: %s", (gchar*) user_data, error->message);
 	}
 }
 
@@ -435,7 +431,7 @@
 			      "handle", &handle,
 			      NULL);
 
-		empathy_debug (DEBUG_DOMAIN, "Dispatching tube");
+		DEBUG ("Dispatching tube");
 		emp_cli_tube_handler_call_handle_tube (thandler, -1,
 						       connection->bus_name,
 						       connection->object_path,
@@ -470,7 +466,7 @@
 				  G_CALLBACK (gtk_widget_destroy),
 				  NULL);
 
-		empathy_debug (DEBUG_DOMAIN, "Tube can't be handled, closing");
+		DEBUG ("Tube can't be handled, closing");
 		tp_cli_channel_type_tubes_call_close_tube (data->channel, -1,
 							   data->id,
 							   NULL, NULL, NULL,
@@ -511,8 +507,7 @@
 	number = GPOINTER_TO_UINT (g_hash_table_lookup (priv->tubes, channel));
 	g_hash_table_replace (priv->tubes, g_object_ref (channel),
 			      GUINT_TO_POINTER (++number));
-	empathy_debug (DEBUG_DOMAIN, "Increased tube count for channel %p: %d",
-		       channel, number);
+	DEBUG ("Increased tube count for channel %p: %d", channel, number);
 
 	/* We dispatch only local pending tubes */
 	if (state != TP_TUBE_STATE_LOCAL_PENDING) {
@@ -541,7 +536,7 @@
 	tp_cli_dbus_daemon_run_name_has_owner (daemon, -1, data->bus_name,
 					       &running, NULL, NULL);
 	if (running) {
-		empathy_debug (DEBUG_DOMAIN, "Tube handler running");
+		DEBUG ("Tube handler running");
 		data->activatable = TRUE;
 		filter_tubes_dispatch (EMPATHY_FILTER (filter), data);
 		return;
@@ -552,8 +547,7 @@
 	if (!tp_cli_dbus_daemon_run_list_activatable_names (daemon, -1,
 							    &names, &error,
 							    NULL)) {
-		empathy_debug (DEBUG_DOMAIN, "Error listing activatable names: %s",
-			       error->message);
+		DEBUG ("Error listing activatable names: %s", error->message);
 		g_clear_error (&error);
 	} else {
 		gchar **name;
@@ -599,8 +593,7 @@
 	guint i;
 
 	if (error) {
-		empathy_debug (DEBUG_DOMAIN, "Error listing tubes: %s",
-			       error->message);
+		DEBUG ("Error listing tubes: %s", error->message);
 		return;
 	}
 
@@ -628,7 +621,7 @@
 {
 	EmpathyFilterPriv *priv = GET_PRIV (filter);
 
-	empathy_debug (DEBUG_DOMAIN, "Channel %p invalidated: %s", proxy, message);
+	DEBUG ("Channel %p invalidated: %s", proxy, message);
 
 	g_hash_table_remove (priv->tubes, proxy);
 }
@@ -644,13 +637,12 @@
 
 	number = GPOINTER_TO_UINT (g_hash_table_lookup (priv->tubes, channel));
 	if (number == 1) {
-		empathy_debug (DEBUG_DOMAIN, "Ended tube count for channel %p, "
-			       "closing channel", channel);
+		DEBUG ("Ended tube count for channel %p, closing channel",
+			channel);
 		tp_cli_channel_call_close (channel, -1, NULL, NULL, NULL, NULL);
 	}
 	else if (number > 1) {
-		empathy_debug (DEBUG_DOMAIN, "Decrease tube count for channel %p: %d",
-			       channel, number);
+		DEBUG ("Decrease tube count for channel %p: %d", channel, number);
 		g_hash_table_replace (priv->tubes, g_object_ref (channel),
 				      GUINT_TO_POINTER (--number));
 	}
@@ -667,7 +659,7 @@
 		return;
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Handling new channel");
+	DEBUG ("Handling new channel");
 
 	g_hash_table_insert (priv->tubes, g_object_ref (channel),
 			     GUINT_TO_POINTER (0));
@@ -724,7 +716,7 @@
 	GHashTableIter     iter;
 	gpointer           key, value;
 
-	empathy_debug (DEBUG_DOMAIN, "connection invalidated: %s", message);
+	DEBUG ("connection invalidated: %s", message);
 
 	g_hash_table_iter_init (&iter, priv->accounts);
 	while (g_hash_table_iter_next (&iter, &key, &value)) {
@@ -770,8 +762,7 @@
 	else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_TUBES)) {
 		func = filter_tubes_handle_channel;
 	} else {
-		empathy_debug (DEBUG_DOMAIN, "Unknown channel type %s",
-			       channel_type);
+		DEBUG ("Unknown channel type %s", channel_type);
 		return;
 	}
 
@@ -795,8 +786,7 @@
 	guint i;
 
 	if (error) {
-		empathy_debug (DEBUG_DOMAIN, "Error listing channels: %s",
-			       error->message);
+		DEBUG ("Error listing channels: %s", error->message);
 		return;
 	}
 
@@ -824,8 +814,7 @@
 					     GObject         *filter)
 {
 	if (error) {
-		empathy_debug (DEBUG_DOMAIN, "Error advertising capabilities: %s",
-			       error->message);
+		DEBUG ("Error advertising capabilities: %s", error->message);
 	}
 }
 
@@ -839,7 +828,7 @@
 	GValue       cap = {0, };
 	const gchar *remove = NULL;
 
-	empathy_debug (DEBUG_DOMAIN, "Connection ready, accepting new channels");
+	DEBUG ("Connection ready, accepting new channels");
 
 	tp_cli_connection_connect_to_new_channel (connection,
 						  filter_conection_new_channel_cb,

Modified: trunk/src/empathy-logs.c
==============================================================================
--- trunk/src/empathy-logs.c	(original)
+++ trunk/src/empathy-logs.c	Wed Apr 30 21:44:38 2008
@@ -28,6 +28,7 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 
+#include <libempathy/empathy-debug.h>
 #include <libempathy-gtk/empathy-log-window.h>
 
 static void
@@ -44,6 +45,12 @@
 
 	gtk_init (&argc, &argv);
 
+	if (g_getenv ("EMPATHY_TIMING") != NULL) {
+		g_log_set_default_handler (tp_debug_timestamped_log_handler, NULL);
+	}
+	empathy_debug_set_flags (g_getenv ("EMPATHY_DEBUG"));
+	tp_debug_divert_messages (g_getenv ("EMPATHY_LOGFILE"));
+
 	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
 					   PKGDATADIR G_DIR_SEPARATOR_S "icons");
 	window = empathy_log_window_show (NULL, NULL, FALSE, NULL);

Modified: trunk/src/empathy-main-window.c
==============================================================================
--- trunk/src/empathy-main-window.c	(original)
+++ trunk/src/empathy-main-window.c	Wed Apr 30 21:44:38 2008
@@ -29,7 +29,6 @@
 #include <glib/gi18n.h>
 
 #include <libempathy/empathy-contact.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-chatroom-manager.h>
 #include <libempathy/empathy-chatroom.h>
@@ -57,7 +56,8 @@
 #include "empathy-new-chatroom-dialog.h"
 #include "empathy-chatrooms-window.h"
 
-#define DEBUG_DOMAIN "MainWindow"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 /* Minimum width of roster window if something goes wrong. */
 #define MIN_WIDTH 50
@@ -309,7 +309,7 @@
 		/* Use the defaults from the glade file if we
 		 * don't have good w, h geometry.
 		 */
-		empathy_debug (DEBUG_DOMAIN, "Configuring window default size w:%d, h:%d", w, h);
+		DEBUG ("Configuring window default size w:%d, h:%d", w, h);
 		gtk_window_set_default_size (GTK_WINDOW (window->window), w, h);
 	}
 
@@ -317,7 +317,7 @@
 		/* Let the window manager position it if we
 		 * don't have good x, y coordinates.
 		 */
-		empathy_debug (DEBUG_DOMAIN, "Configuring window default position x:%d, y:%d", x, y);
+		DEBUG ("Configuring window default position x:%d, y:%d", x, y);
 		gtk_window_move (GTK_WINDOW (window->window), x, y);
 	}
 
@@ -506,7 +506,7 @@
 	account = empathy_chatroom_get_account (chatroom);
 	room = empathy_chatroom_get_room (chatroom);
 
-	empathy_debug (DEBUG_DOMAIN, "Requesting channel for '%s'", room);
+	DEBUG ("Requesting channel for '%s'", room);
 
 	mission_control_request_channel_with_string_handle (mc,
 							    account,
@@ -1009,7 +1009,7 @@
 
 	filename = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, ACCELS_FILENAME, NULL);
 	if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
-		empathy_debug (DEBUG_DOMAIN, "Loading from:'%s'", filename);
+		DEBUG ("Loading from:'%s'", filename);
 		gtk_accel_map_load (filename);
 	}
 
@@ -1027,7 +1027,7 @@
 	file_with_path = g_build_filename (dir, ACCELS_FILENAME, NULL);
 	g_free (dir);
 
-	empathy_debug (DEBUG_DOMAIN, "Saving to:'%s'", file_with_path);
+	DEBUG ("Saving to:'%s'", file_with_path);
 	gtk_accel_map_save (file_with_path);
 
 	g_free (file_with_path);

Modified: trunk/src/empathy-new-chatroom-dialog.c
==============================================================================
--- trunk/src/empathy-new-chatroom-dialog.c	(original)
+++ trunk/src/empathy-new-chatroom-dialog.c	Wed Apr 30 21:44:38 2008
@@ -39,7 +39,6 @@
 #include <libempathy/empathy-tp-roomlist.h>
 #include <libempathy/empathy-chatroom.h>
 #include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-debug.h>
 
 #include <libempathy-gtk/empathy-account-chooser.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
@@ -47,7 +46,8 @@
 #include "empathy-new-chatroom-dialog.h"
 #include "ephy-spinner.h"
 
-#define DEBUG_DOMAIN "NewChatroomDialog"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 typedef struct {
 	EmpathyTpRoomlist *room_list;
@@ -397,9 +397,9 @@
 	GtkListStore     *store;
 	GtkTreeIter       iter;
 
-	empathy_debug (DEBUG_DOMAIN, "New chatroom listed: %s (%s)",
-		       empathy_chatroom_get_name (chatroom),
-		       empathy_chatroom_get_room (chatroom));
+	DEBUG ("New chatroom listed: %s (%s)",
+		empathy_chatroom_get_name (chatroom),
+		empathy_chatroom_get_room (chatroom));
 
 	/* Add to model */
 	view = GTK_TREE_VIEW (dialog->treeview);
@@ -506,7 +506,7 @@
 		room_name = g_strdup (room);
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Requesting channel for '%s'", room_name);
+	DEBUG ("Requesting channel for '%s'", room_name);
 
 	mc = empathy_mission_control_new ();
 	mission_control_request_channel_with_string_handle (mc,

Modified: trunk/src/empathy-status-icon.c
==============================================================================
--- trunk/src/empathy-status-icon.c	(original)
+++ trunk/src/empathy-status-icon.c	Wed Apr 30 21:44:38 2008
@@ -27,7 +27,6 @@
 #include <glade/glade.h>
 #include <glib/gi18n.h>
 
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-idle.h>
 
@@ -42,11 +41,12 @@
 #include "empathy-preferences.h"
 #include "empathy-filter.h"
 
+#define DEBUG_FLAG EMPATHY_DEBUG_FILTER
+#include <libempathy/empathy-debug.h>
+
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
 		       EMPATHY_TYPE_STATUS_ICON, EmpathyStatusIconPriv))
 
-#define DEBUG_DOMAIN "StatusIcon"
-
 /* Number of ms to wait when blinking */
 #define BLINK_TIMEOUT 500
 
@@ -95,8 +95,7 @@
 		if (accounts) {
 			mc_accounts_list_free (accounts);
 		} else {
-			empathy_debug (DEBUG_DOMAIN,
-				      "No enabled account, Showing account dialog");
+			DEBUG ("No enabled account, Showing account dialog");
 			empathy_accounts_dialog_show (GTK_WINDOW (priv->window));
 		}
 	}
@@ -182,8 +181,7 @@
 {
 	EmpathyStatusIconPriv *priv = GET_PRIV (icon);
 
-	empathy_debug (DEBUG_DOMAIN, "Activated: %s",
-		       priv->event ? "event" : "toggle");
+	DEBUG ("Activated: %s", priv->event ? "event" : "toggle");
 
 	if (priv->event) {
 		empathy_filter_activate_event (priv->filter, priv->event);

Modified: trunk/src/empathy.c
==============================================================================
--- trunk/src/empathy.c	(original)
+++ trunk/src/empathy.c	Wed Apr 30 21:44:38 2008
@@ -38,7 +38,6 @@
 
 #include <libempathy/empathy-idle.h>
 #include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-debug.h>
 
 #include <libempathy-gtk/empathy-conf.h>
 
@@ -46,7 +45,8 @@
 #include "empathy-status-icon.h"
 #include "bacon-message-connection.h"
 
-#define DEBUG_DOMAIN "EmpathyMain"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 static BaconMessageConnection *connection = NULL;
 
@@ -54,7 +54,7 @@
 service_ended_cb (MissionControl *mc,
 		  gpointer        user_data)
 {
-	empathy_debug (DEBUG_DOMAIN, "Mission Control stopped");
+	DEBUG ("Mission Control stopped");
 }
 
 static void
@@ -109,8 +109,7 @@
 		message = _("Unknown error code");
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Error during operation %d: %s",
-		       operation_id, message);
+	DEBUG ("Error during operation %d: %s", operation_id, message);
 }
 
 static void
@@ -151,13 +150,13 @@
 		return;
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Try to add a salut account...");
+	DEBUG ("Try to add a salut account...");
 
 	/* Check if the salut CM is installed */
 	profile = mc_profile_lookup ("salut");
 	protocol = mc_profile_get_protocol (profile);
 	if (!protocol) {
-		empathy_debug (DEBUG_DOMAIN, "Salut not installed");
+		DEBUG ("Salut not installed");
 		g_object_unref (profile);
 		return;
 	}
@@ -165,8 +164,8 @@
 
 	/* Get self EContact from EDS */
 	if (!e_book_get_self (&contact, &book, &error)) {
-		empathy_debug (DEBUG_DOMAIN, "Failed to get self econtact: %s",
-			       error ? error->message : "No error given");
+		DEBUG ("Failed to get self econtact: %s",
+			error ? error->message : "No error given");
 		g_clear_error (&error);
 		g_object_unref (profile);
 		return;
@@ -179,7 +178,7 @@
 	/* Check if there is already a salut account */
 	accounts = mc_accounts_list_by_profile (profile);
 	if (accounts) {
-		empathy_debug (DEBUG_DOMAIN, "There is already a salut account");
+		DEBUG ("There is already a salut account");
 		mc_accounts_list_free (accounts);
 		g_object_unref (profile);
 		return;
@@ -199,13 +198,9 @@
 		nickname = NULL;
 	}
 
-	empathy_debug (DEBUG_DOMAIN, "Salut account created:\n"
-				     "  nickname=%s\n"
-				     "  first-name=%s\n"
-				     "  last-name=%s\n"
-				     "  email=%s\n"
-				     "  jid=%s\n",
-		       nickname, first_name, last_name, email, jid);
+	DEBUG ("Salut account created:\nnickname=%s\nfirst-name=%s\n"
+		"last-name=%s\nemail=%s\njid=%s\n",
+		nickname, first_name, last_name, email, jid);
 
 	mc_account_set_param_string (account, "nickname", nickname ? nickname : "");
 	mc_account_set_param_string (account, "first-name", first_name ? first_name : "");
@@ -238,9 +233,8 @@
 
 	g_return_if_fail (message != NULL);
 
-	empathy_debug (DEBUG_DOMAIN,
-		       "Other instance launched, presenting the main window "
-		       "(message is '%s')", message);
+	DEBUG ("Other instance launched, presenting the main window. message='%s'",
+		message);
 
 	startup_timestamp = atoi (message);
 
@@ -251,7 +245,7 @@
 	 * has been realized otherwise it will not work. lame. */
 	if (startup_timestamp == 0) {
 		/* Work if launched from the terminal */
-		empathy_debug (DEBUG_DOMAIN, "Using X server timestamp as a fallback");
+		DEBUG ("Using X server timestamp as a fallback");
 
 		if (!GTK_WIDGET_REALIZED (window)) {
 			gtk_widget_realize (GTK_WIDGET (window));
@@ -329,11 +323,15 @@
 	if (!gtk_init_with_args (&argc, &argv,
 				 _("- Empathy Instant Messenger"),
 				 options, GETTEXT_PACKAGE, &error)) {
-		empathy_debug (DEBUG_DOMAIN, error->message);
+		g_warning ("Error in gtk init: %s", error->message);
 		return EXIT_FAILURE;
 	}
 
-	empathy_debug_set_log_file_from_env ();
+	if (g_getenv ("EMPATHY_TIMING") != NULL) {
+		g_log_set_default_handler (tp_debug_timestamped_log_handler, NULL);
+	}
+	empathy_debug_set_flags (g_getenv ("EMPATHY_DEBUG"));
+	tp_debug_divert_messages (g_getenv ("EMPATHY_LOGFILE"));
 
 	g_set_application_name (PACKAGE_NAME);
 
@@ -347,7 +345,7 @@
 		if (!bacon_message_connection_get_is_server (connection)) {
 			gchar *message;
 
-			empathy_debug (DEBUG_DOMAIN, "Activating existing instance");
+			DEBUG ("Activating existing instance");
 
 			message = g_strdup_printf ("%" G_GUINT32_FORMAT,
 						   startup_timestamp);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]