diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-04-20 02:36:22 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-04-20 02:36:22 +0800 |
commit | 5151e57366bbbe7b04ab03bcb6cda8afcd240a61 (patch) | |
tree | 83818fbc7da2bbe377873ef15602fcc2eb4a8294 /libempathy | |
parent | 6bb385c3ada233409a10088f2de1a134d0707fda (diff) | |
download | gsoc2013-empathy-5151e57366bbbe7b04ab03bcb6cda8afcd240a61.tar gsoc2013-empathy-5151e57366bbbe7b04ab03bcb6cda8afcd240a61.tar.gz gsoc2013-empathy-5151e57366bbbe7b04ab03bcb6cda8afcd240a61.tar.bz2 gsoc2013-empathy-5151e57366bbbe7b04ab03bcb6cda8afcd240a61.tar.lz gsoc2013-empathy-5151e57366bbbe7b04ab03bcb6cda8afcd240a61.tar.xz gsoc2013-empathy-5151e57366bbbe7b04ab03bcb6cda8afcd240a61.tar.zst gsoc2013-empathy-5151e57366bbbe7b04ab03bcb6cda8afcd240a61.zip |
Drop Chandler and Filter, do not use MC for dispatching channels, do it ourself.
svn path=/trunk/; revision=967
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/Makefile.am | 4 | ||||
-rw-r--r-- | libempathy/empathy-chandler.c | 183 | ||||
-rw-r--r-- | libempathy/empathy-chandler.h | 53 | ||||
-rw-r--r-- | libempathy/empathy-filter.c | 262 | ||||
-rw-r--r-- | libempathy/empathy-filter.h | 62 | ||||
-rw-r--r-- | libempathy/empathy-utils.c | 56 |
6 files changed, 32 insertions, 588 deletions
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am index 19873bee1..e18088cf1 100644 --- a/libempathy/Makefile.am +++ b/libempathy/Makefile.am @@ -35,8 +35,6 @@ libempathy_la_SOURCES = \ empathy-tp-chat.c \ empathy-tp-roomlist.c \ empathy-tp-call.c \ - empathy-chandler.c \ - empathy-filter.c \ empathy-idle.c \ empathy-log-manager.c \ empathy-irc-network-manager.c \ @@ -75,8 +73,6 @@ libempathy_headers = \ empathy-tp-chat.h \ empathy-tp-roomlist.h \ empathy-tp-call.h \ - empathy-chandler.h \ - empathy-filter.h \ empathy-idle.h \ empathy-log-manager.h \ empathy-irc-network-manager.h \ diff --git a/libempathy/empathy-chandler.c b/libempathy/empathy-chandler.c deleted file mode 100644 index 2fdb37294..000000000 --- a/libempathy/empathy-chandler.c +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * 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 - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#include <config.h> - -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/connection.h> -#include <telepathy-glib/channel.h> - -#include <extensions/extensions.h> -#include "empathy-chandler.h" -#include "empathy-debug.h" - -#define DEBUG_DOMAIN "EmpathyChandler" - -static void chandler_iface_init (EmpSvcChandlerClass *klass); - -enum { - NEW_CHANNEL, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -G_DEFINE_TYPE_WITH_CODE (EmpathyChandler, empathy_chandler, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (EMP_TYPE_SVC_CHANDLER, - chandler_iface_init)); - -typedef struct { - EmpathyChandler *chandler; - gchar *bus_name; - gchar *connection; - gchar *channel_type; - gchar *channel; - guint handle_type; - guint handle; -} IdleData; - -static gboolean -handle_channel_idle_cb (gpointer data) -{ - IdleData *idle_data = data; - TpChannel *chan; - TpConnection *conn; - static TpDBusDaemon *daemon = NULL; - - if (!daemon) { - daemon = tp_dbus_daemon_new (tp_get_bus ()); - } - - conn = tp_connection_new (daemon, idle_data->bus_name, - idle_data->connection, NULL); - chan = tp_channel_new (conn, idle_data->channel, idle_data->channel_type, - idle_data->handle_type, idle_data->handle, NULL); - tp_channel_run_until_ready (chan, NULL, NULL); - - empathy_debug (DEBUG_DOMAIN, "New channel to be handled: " - "type=%s handle=%d", - idle_data->channel_type, idle_data->handle); - g_signal_emit (idle_data->chandler, signals[NEW_CHANNEL], 0, chan); - - g_object_unref (chan); - g_object_unref (conn); - g_free (idle_data->bus_name); - g_free (idle_data->connection); - g_free (idle_data->channel_type); - g_free (idle_data->channel); - g_slice_free (IdleData, idle_data); - - return FALSE; -} - -static void -my_handle_channel (EmpSvcChandler *self, - const gchar *bus_name, - const gchar *connection, - const gchar *channel_type, - const gchar *channel, - guint handle_type, - guint handle, - DBusGMethodInvocation *context) -{ - EmpathyChandler *chandler = EMPATHY_CHANDLER (self); - IdleData *data; - - data = g_slice_new (IdleData); - data->chandler = chandler; - data->bus_name = g_strdup (bus_name); - data->connection = g_strdup (connection); - data->channel_type = g_strdup (channel_type); - data->channel = g_strdup (channel); - data->handle_type = handle_type; - data->handle = handle; - g_idle_add_full (G_PRIORITY_HIGH, - handle_channel_idle_cb, - data, NULL); - - emp_svc_chandler_return_from_handle_channel (context); -} - -static void -empathy_chandler_class_init (EmpathyChandlerClass *klass) -{ - signals[NEW_CHANNEL] = - g_signal_new ("new-channel", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, - 1, TP_TYPE_CHANNEL); -} - -static void -chandler_iface_init (EmpSvcChandlerClass *klass) -{ -#define IMPLEMENT(x) emp_svc_chandler_implement_##x \ - (klass, my_##x) - IMPLEMENT (handle_channel); -#undef IMPLEMENT -} - -static void -empathy_chandler_init (EmpathyChandler *chandler) -{ -} - -EmpathyChandler * -empathy_chandler_new (const gchar *bus_name, - const gchar *object_path) -{ - EmpathyChandler *chandler; - DBusGProxy *proxy; - guint result; - GError *error = NULL; - - proxy = dbus_g_proxy_new_for_name (tp_get_bus (), - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - if (!dbus_g_proxy_call (proxy, "RequestName", &error, - 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", - error ? error->message : "No error given"); - g_clear_error (&error); - - return NULL; - } - g_object_unref (proxy); - - chandler = g_object_new (EMPATHY_TYPE_CHANDLER, NULL); - dbus_g_connection_register_g_object (tp_get_bus (), - object_path, - G_OBJECT (chandler)); - - return chandler; -} - diff --git a/libempathy/empathy-chandler.h b/libempathy/empathy-chandler.h deleted file mode 100644 index 6835ddaf9..000000000 --- a/libempathy/empathy-chandler.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * 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 - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_CHANDLER_H__ -#define __EMPATHY_CHANDLER_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_CHANDLER (empathy_chandler_get_type ()) -#define EMPATHY_CHANDLER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CHANDLER, EmpathyChandler)) -#define EMPATHY_CHANDLER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_CHANDLER, EmpathyChandlerClass)) -#define EMPATHY_IS_CHANDLER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CHANDLER)) -#define EMPATHY_IS_CHANDLER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CHANDLER)) -#define EMPATHY_CHANDLER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CHANDLER, EmpathyChandlerClass)) - -typedef struct _EmpathyChandler EmpathyChandler; -typedef struct _EmpathyChandlerClass EmpathyChandlerClass; - -struct _EmpathyChandler { - GObject parent; -}; - -struct _EmpathyChandlerClass { - GObjectClass parent_class; -}; - -GType empathy_chandler_get_type (void) G_GNUC_CONST; -EmpathyChandler *empathy_chandler_new (const gchar *bus_name, - const gchar *object_path); - -G_END_DECLS - -#endif /* __EMPATHY_CHANDLER_H__ */ diff --git a/libempathy/empathy-filter.c b/libempathy/empathy-filter.c deleted file mode 100644 index 08f9ee6c7..000000000 --- a/libempathy/empathy-filter.c +++ /dev/null @@ -1,262 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * 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 - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#include <config.h> - -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/connection.h> - -#include <extensions/extensions.h> -#include "empathy-filter.h" -#include "empathy-debug.h" -#include "empathy-utils.h" - -#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ - EMPATHY_TYPE_FILTER, EmpathyFilterPriv)) - -#define DEBUG_DOMAIN "EmpathyFilter" - -struct _EmpathyFilterPriv { - GHashTable *table; -}; - -static void empathy_filter_class_init (EmpathyFilterClass *klass); -static void empathy_filter_init (EmpathyFilter *filter); -static void filter_iface_init (EmpSvcFilterClass *klass); - -enum { - NEW_CHANNEL, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -G_DEFINE_TYPE_WITH_CODE (EmpathyFilter, empathy_filter, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (EMP_TYPE_SVC_FILTER, - filter_iface_init)); - -typedef struct { - EmpathyFilter *filter; - gchar *bus_name; - gchar *connection; - gchar *channel_type; - gchar *channel; - guint handle_type; - guint handle; - guint id; -} IdleData; - -static gboolean -filter_channel_idle_cb (gpointer data) -{ - IdleData *idle_data = data; - EmpathyFilterPriv *priv = GET_PRIV (idle_data->filter); - TpChannel *chan; - TpConnection *conn; - static TpDBusDaemon *daemon = NULL; - - if (!daemon) { - daemon = tp_dbus_daemon_new (tp_get_bus ()); - } - - conn = tp_connection_new (daemon, idle_data->bus_name, - idle_data->connection, NULL); - tp_connection_run_until_ready (conn, FALSE, NULL, NULL); - chan = tp_channel_new (conn, idle_data->channel, idle_data->channel_type, - idle_data->handle_type, idle_data->handle, NULL); - tp_channel_run_until_ready (chan, NULL, NULL); - - g_hash_table_insert (priv->table, chan, GUINT_TO_POINTER (idle_data->id)); - - empathy_debug (DEBUG_DOMAIN, "New channel to be filtred: " - "type=%s handle=%d id=%d", - idle_data->channel_type, idle_data->handle, - idle_data->id); - - g_signal_emit (idle_data->filter, signals[NEW_CHANNEL], 0, chan); - - g_object_unref (conn); - g_free (idle_data->bus_name); - g_free (idle_data->connection); - g_free (idle_data->channel_type); - g_free (idle_data->channel); - g_slice_free (IdleData, idle_data); - - return FALSE; -} - -static void -my_filter_channel (EmpSvcFilter *self, - const gchar *bus_name, - const gchar *connection, - const gchar *channel_type, - const gchar *channel, - guint handle_type, - guint handle, - guint id, - DBusGMethodInvocation *context) -{ - EmpathyFilter *filter = EMPATHY_FILTER (self); - IdleData *data; - - data = g_slice_new (IdleData); - data->filter = filter; - data->bus_name = g_strdup (bus_name); - data->connection = g_strdup (connection); - data->channel_type = g_strdup (channel_type); - data->channel = g_strdup (channel); - data->handle_type = handle_type; - data->handle = handle; - data->id = id; - g_idle_add_full (G_PRIORITY_HIGH, - filter_channel_idle_cb, - data, NULL); - - emp_svc_filter_return_from_filter_channel (context); -} - -static void -filter_finalize (GObject *object) -{ - EmpathyFilterPriv *priv; - - priv = GET_PRIV (object); - - g_hash_table_destroy (priv->table); -} - -static void -empathy_filter_class_init (EmpathyFilterClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = filter_finalize; - - signals[NEW_CHANNEL] = - g_signal_new ("new-channel", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, - 1, TP_TYPE_CHANNEL); - - g_type_class_add_private (object_class, sizeof (EmpathyFilterPriv)); -} - -static void -filter_iface_init (EmpSvcFilterClass *klass) -{ -#define IMPLEMENT(x) emp_svc_filter_implement_##x \ - (klass, my_##x) - IMPLEMENT (filter_channel); -#undef IMPLEMENT -} - -static void -empathy_filter_init (EmpathyFilter *filter) -{ - EmpathyFilterPriv *priv; - - priv = GET_PRIV (filter); - - priv->table = g_hash_table_new_full (g_direct_hash, g_direct_equal, - (GDestroyNotify) g_object_unref, - NULL); -} - -EmpathyFilter * -empathy_filter_new (const gchar *bus_name, - const gchar *object_path, - const gchar *channel_type, - guint priority, - guint flags) -{ - MissionControl *mc; - EmpathyFilter *filter; - DBusGProxy *proxy; - guint result; - GError *error = NULL; - - proxy = dbus_g_proxy_new_for_name (tp_get_bus (), - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - if (!dbus_g_proxy_call (proxy, "RequestName", &error, - 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", - error ? error->message : "No error given"); - g_clear_error (&error); - - return NULL; - } - g_object_unref (proxy); - - filter = g_object_new (EMPATHY_TYPE_FILTER, NULL); - dbus_g_connection_register_g_object (tp_get_bus (), - object_path, - G_OBJECT (filter)); - - mc = empathy_mission_control_new (); - - mission_control_register_filter (mc, - bus_name, - object_path, - channel_type, - priority, - flags, - NULL); - g_object_unref (mc); - - return filter; -} - -void -empathy_filter_process (EmpathyFilter *filter, - TpChannel *channel, - gboolean process) -{ - EmpathyFilterPriv *priv; - guint id; - - g_return_if_fail (EMPATHY_IS_FILTER (filter)); - g_return_if_fail (TP_IS_CHANNEL (channel)); - - priv = GET_PRIV (filter); - - id = GPOINTER_TO_UINT (g_hash_table_lookup (priv->table, channel)); - g_return_if_fail (id != 0); - - empathy_debug (DEBUG_DOMAIN, "Processing channel id %d: %s", - id, process ? "Yes" : "No"); - - emp_svc_filter_emit_process (filter, id, process); - - g_hash_table_remove (priv->table, channel); -} - diff --git a/libempathy/empathy-filter.h b/libempathy/empathy-filter.h deleted file mode 100644 index 3e383ce59..000000000 --- a/libempathy/empathy-filter.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * 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 - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __EMPATHY_FILTER_H__ -#define __EMPATHY_FILTER_H__ - -#include <glib.h> - -#include <telepathy-glib/channel.h> - -G_BEGIN_DECLS - -#define EMPATHY_TYPE_FILTER (empathy_filter_get_type ()) -#define EMPATHY_FILTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_FILTER, EmpathyFilter)) -#define EMPATHY_FILTER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_FILTER, EmpathyFilterClass)) -#define EMPATHY_IS_FILTER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_FILTER)) -#define EMPATHY_IS_FILTER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_FILTER)) -#define EMPATHY_FILTER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_FILTER, EmpathyFilterClass)) - -typedef struct _EmpathyFilter EmpathyFilter; -typedef struct _EmpathyFilterClass EmpathyFilterClass; -typedef struct _EmpathyFilterPriv EmpathyFilterPriv; - -struct _EmpathyFilter { - GObject parent; -}; - -struct _EmpathyFilterClass { - GObjectClass parent_class; -}; - -GType empathy_filter_get_type (void) G_GNUC_CONST; -EmpathyFilter *empathy_filter_new (const gchar *bus_name, - const gchar *object_path, - const gchar *channel_type, - guint priority, - guint flags); -void empathy_filter_process (EmpathyFilter *filter, - TpChannel *channel, - gboolean process); - -G_END_DECLS - -#endif /* __EMPATHY_FILTER_H__ */ diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index 3876cdf48..9132cbfc9 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -353,21 +353,19 @@ empathy_call_with_contact (EmpathyContact *contact) g_return_if_fail (EMPATHY_IS_CONTACT (contact)); - /* StreamedMedia channels must have handle=0 and handle_type=none. - * To call a contact we have to add him in the group interface of the - * channel. MissionControl will detect the channel creation and - * dispatch it to the VoIP chandler automatically. */ - mc = empathy_mission_control_new (); account = empathy_contact_get_account (contact); connection = mission_control_get_tpconnection (mc, account, NULL); tp_connection_run_until_ready (connection, FALSE, NULL, NULL); + g_object_unref (mc); + /* We abuse of suppress_handler, TRUE means OUTGOING. The channel + * will be catched in EmpathyFilter */ if (!tp_cli_connection_run_request_channel (connection, -1, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, TP_HANDLE_TYPE_NONE, 0, - FALSE, + TRUE, &object_path, &error, NULL)) { @@ -375,7 +373,6 @@ empathy_call_with_contact (EmpathyContact *contact) "Couldn't request channel: %s", error ? error->message : "No error given"); g_clear_error (&error); - g_object_unref (mc); g_object_unref (connection); return; } @@ -399,7 +396,6 @@ empathy_call_with_contact (EmpathyContact *contact) g_object_unref (factory); g_object_unref (self_contact); g_object_unref (group); - g_object_unref (mc); g_object_unref (connection); g_object_unref (channel); g_free (object_path); @@ -427,31 +423,43 @@ empathy_call_with_contact_id (McAccount *account, const gchar *contact_id) void empathy_chat_with_contact (EmpathyContact *contact) { - MissionControl *mc; + MissionControl *mc; + McAccount *account; + TpConnection *connection; + + g_return_if_fail (EMPATHY_IS_CONTACT (contact)); mc = empathy_mission_control_new (); - mission_control_request_channel (mc, - empathy_contact_get_account (contact), - TP_IFACE_CHANNEL_TYPE_TEXT, - empathy_contact_get_handle (contact), - TP_HANDLE_TYPE_CONTACT, - NULL, NULL); + account = empathy_contact_get_account (contact); + connection = mission_control_get_tpconnection (mc, account, NULL); + tp_connection_run_until_ready (connection, FALSE, NULL, NULL); g_object_unref (mc); + + /* We abuse of suppress_handler, TRUE means OUTGOING. The channel + * will be catched in EmpathyFilter */ + tp_cli_connection_call_request_channel (connection, -1, + TP_IFACE_CHANNEL_TYPE_TEXT, + TP_HANDLE_TYPE_CONTACT, + empathy_contact_get_handle (contact), + TRUE, + NULL, NULL, NULL, NULL); + g_object_unref (connection); } void empathy_chat_with_contact_id (McAccount *account, const gchar *contact_id) { - MissionControl *mc; + EmpathyContactFactory *factory; + EmpathyContact *contact; - mc = empathy_mission_control_new (); - mission_control_request_channel_with_string_handle (mc, - account, - TP_IFACE_CHANNEL_TYPE_TEXT, - contact_id, - TP_HANDLE_TYPE_CONTACT, - NULL, NULL); - g_object_unref (mc); + factory = empathy_contact_factory_new (); + contact = empathy_contact_factory_get_from_id (factory, account, contact_id); + empathy_contact_run_until_ready (contact, EMPATHY_CONTACT_READY_HANDLE, NULL); + + empathy_chat_with_contact (contact); + + g_object_unref (contact); + g_object_unref (factory); } const gchar * |