empathy r984 - in trunk: libempathy src
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r984 - in trunk: libempathy src
- Date: Sat, 19 Apr 2008 22:04:23 +0100 (BST)
Author: xclaesse
Date: Sat Apr 19 21:04:23 2008
New Revision: 984
URL: http://svn.gnome.org/viewvc/empathy?rev=984&view=rev
Log:
Change the way tube handler's object-path and bus-name are build.
Modified:
trunk/libempathy/empathy-tube-handler.c
trunk/libempathy/empathy-tube-handler.h
trunk/src/empathy-tubes-chandler.c
Modified: trunk/libempathy/empathy-tube-handler.c
==============================================================================
--- trunk/libempathy/empathy-tube-handler.c (original)
+++ trunk/libempathy/empathy-tube-handler.c Sat Apr 19 21:04:23 2008
@@ -27,6 +27,7 @@
#include <telepathy-glib/connection.h>
#include <telepathy-glib/channel.h>
#include <telepathy-glib/interfaces.h>
+#include <telepathy-glib/util.h>
#include <extensions/extensions.h>
@@ -146,14 +147,21 @@
}
EmpathyTubeHandler *
-empathy_tube_handler_new (const gchar *bus_name,
- const gchar *object_path)
+empathy_tube_handler_new (TpTubeType type, const gchar *service)
{
- EmpathyTubeHandler *thandler;
+ EmpathyTubeHandler *thandler = NULL;
DBusGProxy *proxy;
guint result;
+ gchar *bus_name;
+ gchar *object_path;
GError *error = NULL;
+ g_return_val_if_fail (type <= TP_TUBE_TYPE_STREAM, NULL);
+ g_return_val_if_fail (service != NULL, NULL);
+
+ bus_name = empathy_tube_handler_build_bus_name (type, service);
+ object_path = empathy_tube_handler_build_object_path (type, service);
+
proxy = dbus_g_proxy_new_for_name (tp_get_bus (), DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
@@ -164,15 +172,58 @@
empathy_debug (DEBUG_DOMAIN, "Failed to request name: %s",
error ? error->message : "No error given");
g_clear_error (&error);
- return NULL;
+ goto OUT;
}
- g_object_unref (proxy);
-
thandler = g_object_new (EMPATHY_TYPE_TUBE_HANDLER, NULL);
dbus_g_connection_register_g_object (tp_get_bus (), object_path,
G_OBJECT (thandler));
+OUT:
+ g_object_unref (proxy);
+ g_free (bus_name);
+ g_free (object_path);
+
return thandler;
}
+gchar *
+empathy_tube_handler_build_bus_name (TpTubeType type, const gchar *service)
+{
+ gchar *service_escaped;
+ gchar *str = NULL;
+
+ g_return_val_if_fail (type <= TP_TUBE_TYPE_STREAM, NULL);
+ g_return_val_if_fail (service != NULL, NULL);
+
+ service_escaped = tp_escape_as_identifier (service);
+ if (type == TP_TUBE_TYPE_DBUS)
+ str = g_strdup_printf ("org.gnome.Empathy.DTubeHandler.%s", service);
+ else if (type == TP_TUBE_TYPE_STREAM)
+ str = g_strdup_printf ("org.gnome.Empathy.StreamTubeHandler.%s", service);
+
+ g_free (service_escaped);
+
+ return str;
+}
+
+gchar *
+empathy_tube_handler_build_object_path (TpTubeType type, const gchar *service)
+{
+ gchar *service_escaped;
+ gchar *str = NULL;
+
+ g_return_val_if_fail (type <= TP_TUBE_TYPE_STREAM, NULL);
+ g_return_val_if_fail (service != NULL, NULL);
+
+ service_escaped = tp_escape_as_identifier (service);
+ if (type == TP_TUBE_TYPE_DBUS)
+ str = g_strdup_printf ("/org/gnome/Empathy/DTubeHandler/%s", service);
+ else if (type == TP_TUBE_TYPE_STREAM)
+ str = g_strdup_printf ("/org/gnome/Empathy/StreamTubeHandler/%s", service);
+
+ g_free (service_escaped);
+
+ return str;
+}
+
Modified: trunk/libempathy/empathy-tube-handler.h
==============================================================================
--- trunk/libempathy/empathy-tube-handler.h (original)
+++ trunk/libempathy/empathy-tube-handler.h Sat Apr 19 21:04:23 2008
@@ -24,6 +24,8 @@
#include <glib.h>
+#include <telepathy-glib/enums.h>
+
G_BEGIN_DECLS
#define EMPATHY_TYPE_TUBE_HANDLER (empathy_tube_handler_get_type ())
@@ -50,8 +52,12 @@
};
GType empathy_tube_handler_get_type (void) G_GNUC_CONST;
-EmpathyTubeHandler *empathy_tube_handler_new (const gchar *bus_name,
- const gchar *object_path);
+EmpathyTubeHandler *empathy_tube_handler_new (TpTubeType type,
+ const gchar *service);
+gchar *empathy_tube_handler_build_bus_name (TpTubeType type,
+ const gchar *service);
+gchar *empathy_tube_handler_build_object_path (TpTubeType type,
+ const gchar *service);
G_END_DECLS
Modified: trunk/src/empathy-tubes-chandler.c
==============================================================================
--- trunk/src/empathy-tubes-chandler.c (original)
+++ trunk/src/empathy-tubes-chandler.c Sat Apr 19 21:04:23 2008
@@ -27,6 +27,7 @@
#include <extensions/extensions.h>
+#include <libempathy/empathy-tube-handler.h>
#include <libempathy/empathy-chandler.h>
#include <libempathy/empathy-debug.h>
#include <libempathy/empathy-utils.h>
@@ -80,26 +81,12 @@
if (state != TP_TUBE_STATE_LOCAL_PENDING)
return;
- /* Build the bus-name and object-path of the tube handler */
- if (type == TP_TUBE_TYPE_DBUS)
- {
- thandler_bus_name =
- g_strdup_printf ("org.gnome.Empathy.DTube.%s", service);
- thandler_object_path =
- g_strdup_printf ("/org/gnome/Empathy/DTube/%s", service);
- }
- else if (type == TP_TUBE_TYPE_STREAM)
- {
- thandler_bus_name =
- g_strdup_printf ("org.gnome.Empathy.StreamTube.%s", service);
- thandler_object_path =
- g_strdup_printf ("/org/gnome/Empathy/StreamTube/%s", service);
- }
- else
- return;
+ thandler_bus_name = empathy_tube_handler_build_bus_name (type, service);
+ thandler_object_path = empathy_tube_handler_build_object_path (type, service);
- empathy_debug (DEBUG_DOMAIN, "Dispatching channel %p id=%d",
- channel, id);
+ empathy_debug (DEBUG_DOMAIN, "Dispatching channel %p id=%d to tube handler: ",
+ "object_path=%s bus_name=%s", channel, id, thandler_object_path,
+ thandler_bus_name);
/* Create the proxy for the tube handler */
thandler = g_object_new (TP_TYPE_PROXY,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]