summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathon Jongsma <jonathon@quotidian.org>2010-11-17 16:59:01 -0600
committerJonathon Jongsma <jonathon@quotidian.org>2010-11-18 11:31:34 -0600
commitcbf1dbd2f3e75654614a125640c4d05d3189292e (patch)
tree269b7b603d8122ca7d5089fe55091261aa258854
parent623b2e2a887c4b081034aa306cbe27ea2e972bac (diff)
Add TpyCallContentCodecoffer (and logging framework)
TpyCallContentCodecoffer was stolen from gabble and ported to the latest Call API. Since it contained some logging statements, I decided to add some basic logging to tp-yell as well.
-rw-r--r--.gitignore3
-rw-r--r--telepathy-yell/Makefile.am4
-rw-r--r--telepathy-yell/call-content-codecoffer.c416
-rw-r--r--telepathy-yell/call-content-codecoffer.h85
-rw-r--r--telepathy-yell/debug.c93
-rw-r--r--telepathy-yell/debug.h64
6 files changed, 664 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 4cd12fe..d652dbe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,4 +33,5 @@
Makefile
Makefile.in
_gen
-*~ \ No newline at end of file
+*~
+*.sw?
diff --git a/telepathy-yell/Makefile.am b/telepathy-yell/Makefile.am
index 03913f7..da29bb7 100644
--- a/telepathy-yell/Makefile.am
+++ b/telepathy-yell/Makefile.am
@@ -21,6 +21,10 @@ endif
libtelepathy_yell_la_LIBADD = $(ALL_LIBS)
libtelepathy_yell_la_SOURCES = \
+ call-content-codecoffer.h \
+ call-content-codecoffer.c \
+ debug.h \
+ debug.c \
extensions.c \
extensions-cli.c
diff --git a/telepathy-yell/call-content-codecoffer.c b/telepathy-yell/call-content-codecoffer.c
new file mode 100644
index 0000000..afce188
--- /dev/null
+++ b/telepathy-yell/call-content-codecoffer.c
@@ -0,0 +1,416 @@
+/*
+ * call-content-codecoffer.c - Source for TpyCallContentCodecoffer
+ * Copyright (C) 2009 Collabora Ltd.
+ * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
+ *
+ * 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 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
+ * Lesser General Public License for more details.
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+
+#include <glib.h>
+#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/dbus-properties-mixin.h>
+#include <telepathy-glib/svc-properties-interface.h>
+
+#include "call-content-codecoffer.h"
+#include "extensions.h"
+
+#define DEBUG_FLAG TPY_DEBUG_CALL
+#include "debug.h"
+
+static void call_content_codecoffer_iface_init (gpointer, gpointer);
+
+G_DEFINE_TYPE_WITH_CODE(TpyCallContentCodecoffer,
+ tpy_call_content_codecoffer,
+ G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (TPY_TYPE_SVC_CALL_CONTENT_CODEC_OFFER,
+ call_content_codecoffer_iface_init);
+ G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES,
+ tp_dbus_properties_mixin_iface_init);
+ );
+
+/* properties */
+enum
+{
+ PROP_OBJECT_PATH = 1,
+ PROP_INTERFACES,
+ PROP_REMOTE_CONTACT_CODECS,
+ PROP_REMOTE_CONTACT
+};
+
+/* private structure */
+struct _TpyCallContentCodecofferPrivate
+{
+ gboolean dispose_has_run;
+
+ gchar *object_path;
+
+ TpHandle contact;
+ GPtrArray *codecs;
+
+ GSimpleAsyncResult *result;
+ GCancellable *cancellable;
+ guint handler_id;
+};
+
+#define TPY_CALL_CONTENT_CODECOFFER_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+ TPY_TYPE_CALL_CONTENT_CODECOFFER, TpyCallContentCodecofferPrivate))
+
+static void
+tpy_call_content_codecoffer_init (TpyCallContentCodecoffer *self)
+{
+ TpyCallContentCodecofferPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ TPY_TYPE_CALL_CONTENT_CODECOFFER,
+ TpyCallContentCodecofferPrivate);
+
+ self->priv = priv;
+}
+
+static void tpy_call_content_codecoffer_dispose (GObject *object);
+static void tpy_call_content_codecoffer_finalize (GObject *object);
+
+static const gchar *interfaces[] = {
+ NULL
+};
+
+static void
+tpy_call_content_codecoffer_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TpyCallContentCodecoffer *offer =
+ TPY_CALL_CONTENT_CODECOFFER (object);
+ TpyCallContentCodecofferPrivate *priv = offer->priv;
+
+ switch (property_id)
+ {
+ case PROP_OBJECT_PATH:
+ g_value_set_string (value, priv->object_path);
+ break;
+ case PROP_INTERFACES:
+ g_value_set_boxed (value, interfaces);
+ break;
+ case PROP_REMOTE_CONTACT_CODECS:
+ g_value_set_boxed (value, priv->codecs);
+ break;
+ case PROP_REMOTE_CONTACT:
+ g_value_set_uint (value, priv->contact);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+tpy_call_content_codecoffer_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TpyCallContentCodecoffer *content =
+ TPY_CALL_CONTENT_CODECOFFER (object);
+ TpyCallContentCodecofferPrivate *priv = content->priv;
+
+ switch (property_id)
+ {
+ case PROP_OBJECT_PATH:
+ priv->object_path = g_value_dup_string (value);
+ g_assert (priv->object_path != NULL);
+ break;
+ case PROP_REMOTE_CONTACT_CODECS:
+ priv->codecs = g_value_dup_boxed (value);
+ break;
+ case PROP_REMOTE_CONTACT:
+ priv->contact = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+tpy_call_content_codecoffer_class_init (
+ TpyCallContentCodecofferClass *tpy_call_content_codecoffer_class)
+{
+ GObjectClass *object_class =
+ G_OBJECT_CLASS (tpy_call_content_codecoffer_class);
+ GParamSpec *spec;
+
+ static TpDBusPropertiesMixinPropImpl codecoffer_props[] = {
+ { "Interfaces", "interfaces", NULL },
+ { "RemoteContactCodecs", "remote-contact-codecs", NULL },
+ { "RemoteContact", "remote-contact", NULL },
+ { NULL }
+ };
+
+ static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
+ { TPY_IFACE_CALL_CONTENT_CODEC_OFFER,
+ tp_dbus_properties_mixin_getter_gobject_properties,
+ NULL,
+ codecoffer_props,
+ },
+ { NULL }
+ };
+
+
+ g_type_class_add_private (tpy_call_content_codecoffer_class,
+ sizeof (TpyCallContentCodecofferPrivate));
+
+ object_class->get_property = tpy_call_content_codecoffer_get_property;
+ object_class->set_property = tpy_call_content_codecoffer_set_property;
+
+ object_class->dispose = tpy_call_content_codecoffer_dispose;
+ object_class->finalize = tpy_call_content_codecoffer_finalize;
+
+ spec = g_param_spec_string ("object-path", "D-Bus object path",
+ "The D-Bus object path used for this "
+ "object on the bus.",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_OBJECT_PATH, spec);
+
+ spec = g_param_spec_boxed ("interfaces",
+ "Interfaces",
+ "Extra interfaces provided by this codec offer",
+ G_TYPE_STRV,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_INTERFACES,
+ spec);
+
+ spec = g_param_spec_boxed ("remote-contact-codecs",
+ "RemoteContactCodecs",
+ "A list of codecs the remote contact supports",
+ TPY_ARRAY_TYPE_CODEC_LIST,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_REMOTE_CONTACT_CODECS,
+ spec);
+
+ spec = g_param_spec_uint ("remote-contact",
+ "RemoteContact",
+ "The contact handle that this codec offer applies to",
+ 0, G_MAXUINT, 0,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_REMOTE_CONTACT,
+ spec);
+
+ tpy_call_content_codecoffer_class->dbus_props_class.interfaces
+ = prop_interfaces;
+ tp_dbus_properties_mixin_class_init (object_class,
+ G_STRUCT_OFFSET (TpyCallContentCodecofferClass, dbus_props_class));
+}
+
+void
+tpy_call_content_codecoffer_dispose (GObject *object)
+{
+ TpyCallContentCodecoffer *self = TPY_CALL_CONTENT_CODECOFFER (object);
+ TpyCallContentCodecofferPrivate *priv = self->priv;
+
+ g_assert (priv->result == NULL);
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ if (priv->codecs != NULL)
+ {
+ /* dbus-glib :( */
+ g_boxed_free (TPY_ARRAY_TYPE_CODEC_LIST, priv->codecs);
+ }
+ priv->codecs = NULL;
+
+ /* release any references held by the object here */
+ if (G_OBJECT_CLASS (tpy_call_content_codecoffer_parent_class)->dispose)
+ G_OBJECT_CLASS (tpy_call_content_codecoffer_parent_class)->dispose (
+ object);
+}
+
+void
+tpy_call_content_codecoffer_finalize (GObject *object)
+{
+ TpyCallContentCodecoffer *self = TPY_CALL_CONTENT_CODECOFFER (object);
+ TpyCallContentCodecofferPrivate *priv = self->priv;
+
+ g_free (priv->object_path);
+ /* free any data held directly by the object here */
+
+ G_OBJECT_CLASS (tpy_call_content_codecoffer_parent_class)->finalize (
+ object);
+}
+
+static void
+tpy_call_content_codec_offer_accept (TpySvcCallContentCodecOffer *iface,
+ const GPtrArray *codecs,
+ DBusGMethodInvocation *context)
+{
+ TpyCallContentCodecoffer *self = TPY_CALL_CONTENT_CODECOFFER (iface);
+ TpyCallContentCodecofferPrivate *priv = self->priv;
+ DBusGConnection *bus = tp_get_bus ();
+
+ DEBUG ("%s was accepted", priv->object_path);
+
+ if (priv->cancellable != NULL)
+ {
+ g_cancellable_disconnect (priv->cancellable, priv->handler_id);
+ g_object_unref (priv->cancellable);
+ priv->cancellable = NULL;
+ priv->handler_id = 0;
+ }
+
+ g_simple_async_result_set_op_res_gpointer (priv->result,
+ (gpointer) codecs, NULL);
+ g_simple_async_result_complete (priv->result);
+ g_object_unref (priv->result);
+ priv->result = NULL;
+
+ tpy_svc_call_content_codec_offer_return_from_accept (context);
+
+ dbus_g_connection_unregister_g_object (bus, G_OBJECT (self));
+}
+
+static void
+tpy_call_content_codec_offer_reject (TpySvcCallContentCodecOffer *iface,
+ DBusGMethodInvocation *context)
+{
+ TpyCallContentCodecoffer *self = TPY_CALL_CONTENT_CODECOFFER (iface);
+ TpyCallContentCodecofferPrivate *priv = self->priv;
+ DBusGConnection *bus = tp_get_bus ();
+
+ DEBUG ("%s was rejected", priv->object_path);
+
+ if (priv->cancellable != NULL)
+ {
+ g_cancellable_disconnect (priv->cancellable, priv->handler_id);
+ g_object_unref (priv->cancellable);
+ priv->cancellable = NULL;
+ priv->handler_id = 0;
+ }
+
+ g_simple_async_result_set_error (priv->result,
+ G_IO_ERROR, G_IO_ERROR_FAILED, "Codec offer was rejected");
+ g_simple_async_result_complete (priv->result);
+ g_object_unref (priv->result);
+ priv->result = NULL;
+
+ tpy_svc_call_content_codec_offer_return_from_reject (context);
+
+ dbus_g_connection_unregister_g_object (bus, G_OBJECT (self));
+}
+
+static void
+call_content_codecoffer_iface_init (gpointer iface, gpointer data)
+{
+ TpySvcCallContentCodecOfferClass *klass =
+ (TpySvcCallContentCodecOfferClass *) iface;
+
+#define IMPLEMENT(x) tpy_svc_call_content_codec_offer_implement_##x (\
+ klass, tpy_call_content_codec_offer_##x)
+ IMPLEMENT(accept);
+ IMPLEMENT(reject);
+#undef IMPLEMENT
+}
+
+TpyCallContentCodecoffer *
+tpy_call_content_codecoffer_new (const gchar *object_path,
+ TpHandle remote_contact,
+ GPtrArray *codecs)
+{
+ return g_object_new (TPY_TYPE_CALL_CONTENT_CODECOFFER,
+ "object-path", object_path,
+ "remote-contact", remote_contact,
+ "remote-contact-codecs", codecs,
+ NULL);
+}
+
+static void
+cancelled_cb (GCancellable *cancellable, gpointer user_data)
+{
+ TpyCallContentCodecoffer *offer = user_data;
+ TpyCallContentCodecofferPrivate *priv = offer->priv;
+ DBusGConnection *bus = tp_get_bus ();
+
+ dbus_g_connection_unregister_g_object (bus, G_OBJECT (offer));
+
+ g_simple_async_result_set_error (priv->result,
+ G_IO_ERROR, G_IO_ERROR_CANCELLED, "Offer cancelled");
+ g_simple_async_result_complete_in_idle (priv->result);
+
+ g_object_unref (priv->cancellable);
+ g_object_unref (priv->result);
+ priv->result = NULL;
+ priv->cancellable = NULL;
+ priv->handler_id = 0;
+}
+
+void
+tpy_call_content_codecoffer_offer (TpyCallContentCodecoffer *offer,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ TpyCallContentCodecofferPrivate *priv = offer->priv;
+ DBusGConnection *bus;
+
+ /* FIXME implement cancellable support */
+ if (G_UNLIKELY (priv->result != NULL))
+ goto pending;
+
+ priv->result = g_simple_async_result_new (G_OBJECT (offer),
+ callback, user_data, tpy_call_content_codecoffer_offer_finish);
+
+ /* register object on the bus */
+ bus = tp_get_bus ();
+ DEBUG ("Registering %s", priv->object_path);
+ dbus_g_connection_register_g_object (bus, priv->object_path,
+ G_OBJECT (offer));
+
+ if (cancellable != NULL)
+ {
+ priv->cancellable = cancellable;
+ priv->handler_id = g_cancellable_connect (
+ cancellable, G_CALLBACK (cancelled_cb), offer, NULL);
+ }
+
+ return;
+
+pending:
+ g_simple_async_report_error_in_idle (G_OBJECT (offer), callback, user_data,
+ G_IO_ERROR, G_IO_ERROR_PENDING, "Another offer operation is pending");
+}
+
+GPtrArray *
+tpy_call_content_codecoffer_offer_finish (
+ TpyCallContentCodecoffer *offer,
+ GAsyncResult *result,
+ GError **error)
+{
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
+ error))
+ return FALSE;
+
+ g_return_val_if_fail (g_simple_async_result_is_valid (result,
+ G_OBJECT (offer), tpy_call_content_codecoffer_offer_finish),
+ NULL);
+
+ return g_simple_async_result_get_op_res_gpointer (
+ G_SIMPLE_ASYNC_RESULT (result));
+}
diff --git a/telepathy-yell/call-content-codecoffer.h b/telepathy-yell/call-content-codecoffer.h
new file mode 100644
index 0000000..5b6e1dd
--- /dev/null
+++ b/telepathy-yell/call-content-codecoffer.h
@@ -0,0 +1,85 @@
+/*
+ * call-content-codecoffer.h - Header for TpyCallContentCodecoffer
+ * Copyright (C) 2009 Collabora Ltd.
+ * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
+ *
+ * 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 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
+ * Lesser General Public License for more details.
+ *
+ * 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 __TPY_CALL_CONTENT_CODECOFFER_H__
+#define __TPY_CALL_CONTENT_CODECOFFER_H__
+
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <telepathy-glib/handle.h>
+
+G_BEGIN_DECLS
+
+typedef struct _TpyCallContentCodecoffer TpyCallContentCodecoffer;
+typedef struct _TpyCallContentCodecofferPrivate
+ TpyCallContentCodecofferPrivate;
+typedef struct _TpyCallContentCodecofferClass
+ TpyCallContentCodecofferClass;
+
+struct _TpyCallContentCodecofferClass {
+ GObjectClass parent_class;
+
+ TpDBusPropertiesMixinClass dbus_props_class;
+};
+
+struct _TpyCallContentCodecoffer {
+ GObject parent;
+
+ TpyCallContentCodecofferPrivate *priv;
+};
+
+GType tpy_call_content_codecoffer_get_type (void);
+
+/* TYPE MACROS */
+#define TPY_TYPE_CALL_CONTENT_CODECOFFER \
+ (tpy_call_content_codecoffer_get_type ())
+#define TPY_CALL_CONTENT_CODECOFFER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ TPY_TYPE_CALL_CONTENT_CODECOFFER, TpyCallContentCodecoffer))
+#define TPY_CALL_CONTENT_CODECOFFER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ TPY_TYPE_CALL_CONTENT_CODECOFFER, TpyCallContentCodecofferClass))
+#define TPY_IS_CALL_CONTENT_CODECOFFER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), TPY_TYPE_CALL_CONTENT_CODECOFFER))
+#define TPY_IS_CALL_CONTENT_CODECOFFER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), TPY_TYPE_CALL_CONTENT_CODECOFFER))
+#define TPY_CALL_CONTENT_CODECOFFER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), TPY_TYPE_CALL_CONTENT_CODECOFFER, \
+ TpyCallContentCodecofferClass))
+
+TpyCallContentCodecoffer *tpy_call_content_codecoffer_new (
+ const gchar *object_path,
+ TpHandle remote_contact,
+ GPtrArray *codecs);
+
+void tpy_call_content_codecoffer_offer (TpyCallContentCodecoffer *offer,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+GPtrArray *tpy_call_content_codecoffer_offer_finish (
+ TpyCallContentCodecoffer *offer,
+ GAsyncResult *result,
+ GError **error);
+
+
+G_END_DECLS
+
+#endif /* #ifndef __TPY_CALL_CONTENT_CODECOFFER_H__*/
diff --git a/telepathy-yell/debug.c b/telepathy-yell/debug.c
new file mode 100644
index 0000000..f5de1e6
--- /dev/null
+++ b/telepathy-yell/debug.c
@@ -0,0 +1,93 @@
+/*
+ * debug.c - debugging utilities for telepathy-yell
+ * Copyright (C) 2010 Collabora Ltd.
+ * @author Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>
+ *
+ * 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 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
+ * Lesser General Public License for more details.
+ *
+ * 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 <telepathy-glib/debug.h>
+#include <telepathy-glib/debug-sender.h>
+#include "debug.h"
+
+static TpyDebugFlags flags = 0;
+
+static GDebugKey debug_keys[] = {
+ {"call", TPY_DEBUG_CALL},
+ {NULL, 0}
+};
+
+void
+tpy_debug_set_flags (const char *flags_string)
+{
+ guint nkeys;
+
+ for (nkeys = 0; debug_keys[nkeys].value; nkeys++);
+
+ flags |= g_parse_debug_string (flags_string, debug_keys, nkeys);
+}
+
+static const char *
+debug_flag_to_domain (TpyDebugFlags flag)
+{
+ static GHashTable *flag_to_domains = NULL;
+
+ if (G_UNLIKELY (flag_to_domains == NULL))
+ {
+ guint i;
+
+ flag_to_domains = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+ NULL, g_free);
+
+ for (i = 0; debug_keys[i].value; i++)
+ {
+ GDebugKey key = debug_keys[i];
+ char *val = g_strdup_printf ("%s/%s", G_LOG_DOMAIN, key.key);
+
+ g_hash_table_insert (flag_to_domains,
+ GUINT_TO_POINTER (key.value), val);
+ }
+ }
+
+ return g_hash_table_lookup (flag_to_domains, GUINT_TO_POINTER (flag));
+}
+
+void tpy_log (GLogLevelFlags level,
+ TpyDebugFlags flag,
+ const gchar *format,
+ ...)
+{
+ TpDebugSender *debug_sender = tp_debug_sender_dup ();
+ char *message;
+ va_list args;
+ GTimeVal now;
+
+ va_start (args, format);
+ message = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ if (flag & flags)
+ g_log (G_LOG_DOMAIN, level, "%s", message);
+
+ g_get_current_time (&now);
+
+ tp_debug_sender_add_message (debug_sender, &now, debug_flag_to_domain (flag),
+ level, message);
+
+ g_free (message);
+ g_object_unref (debug_sender);
+}
diff --git a/telepathy-yell/debug.h b/telepathy-yell/debug.h
new file mode 100644
index 0000000..9909115
--- /dev/null
+++ b/telepathy-yell/debug.h
@@ -0,0 +1,64 @@
+/*
+ * debug.h - debugging utilities for telepathy-yell
+ * Copyright (C) 2010 Collabora Ltd.
+ * @author Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>
+ *
+ * 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 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
+ * Lesser General Public License for more details.
+ *
+ * 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 __TPY_DEBUG_H__
+#define __TPY_DEBUG_H__
+
+#include "config.h"
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+ TPY_DEBUG_CALL = 1 << 0
+} TpyDebugFlags;
+
+void tpy_debug_set_flags (const char *flags_string);
+
+void tpy_log (GLogLevelFlags level, TpyDebugFlags flag,
+ const gchar *format, ...) G_GNUC_PRINTF(3, 4);
+
+#ifdef DEBUG_FLAG
+
+#define ERROR(format, ...) \
+ tpy_log (G_LOG_LEVEL_ERROR, DEBUG_FLAG, "%s: " format, \
+ G_STRFUNC, ##__VA_ARGS__)
+#define CRITICAL(format, ...) \
+ tpy_log (G_LOG_LEVEL_CRITICAL, DEBUG_FLAG, "%s: " format, \
+ G_STRFUNC, ##__VA_ARGS__)
+#define WARNING(format, ...) \
+ tpy_log (G_LOG_LEVEL_WARNING, DEBUG_FLAG, "%s: " format, \
+ G_STRFUNC, ##__VA_ARGS__)
+#define MESSAGE(format, ...) \
+ tpy_log (G_LOG_LEVEL_MESSAGE, DEBUG_FLAG, "%s: " format, \
+ G_STRFUNC, ##__VA_ARGS__)
+#define INFO(format, ...) \
+ tpy_log (G_LOG_LEVEL_INFO, DEBUG_FLAG, "%s: " format, \
+ G_STRFUNC, ##__VA_ARGS__)
+#define DEBUG(format, ...) \
+ tpy_log (G_LOG_LEVEL_DEBUG, DEBUG_FLAG, "%s: " format, \
+ G_STRFUNC, ##__VA_ARGS__)
+
+#endif /* DEBUG_FLAG */
+
+G_END_DECLS
+
+#endif /* __TPY_DEBUG_H__ */