#include <glib/gi18n.h>
#include <libxml/uri.h>
-#include <libmissioncontrol/mc-account.h>
+#include <libtelepathy/tp-helpers.h>
#include "gossip-debug.h"
#include "gossip-utils.h"
-#include "gossip-paths.h"
-#include "empathy-session.h"
#include "empathy-contact-manager.h"
#define DEBUG_DOMAIN "Utils"
xmlDtd *dtd;
gboolean ret;
- path = gossip_paths_get_dtd_path (dtd_filename);
+ path = g_build_filename (DATADIR, "empathy", dtd_filename, NULL);
/* The list of valid chars is taken from libxml. */
escaped = xmlURIEscapeStr (path, ":@&=+$,/?;");
return g_str_equal (name_a, name_b);
}
-GossipContact *
-gossip_get_own_contact_from_contact (GossipContact *contact)
+MissionControl *
+gossip_mission_control_new (void)
{
- EmpathyContactManager *manager;
- McAccount *account;
+ static MissionControl *mc = NULL;
- g_return_val_if_fail (GOSSIP_IS_CONTACT (contact), NULL);
+ if (!mc) {
+ mc = mission_control_new (tp_get_bus ());
+ g_object_add_weak_pointer (G_OBJECT (mc), (gpointer) &mc);
+ } else {
+ g_object_ref (mc);
+ }
+
+ return mc;
+}
+
+gchar *
+gossip_get_channel_id (McAccount *account,
+ TpChan *tp_chan)
+{
+ MissionControl *mc;
+ TpConn *tp_conn;
+ GArray *handles;
+ gchar **names;
+ gchar *name;
+ GError *error;
+
+ g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
+ g_return_val_if_fail (TELEPATHY_IS_CHAN (tp_chan), NULL);
+
+ mc = gossip_mission_control_new ();
+ tp_conn = mission_control_get_connection (mc, account, NULL);
+ g_object_unref (mc);
+
+ if (!tp_conn) {
+ return NULL;
+ }
+
+ /* Get the handle's name */
+ handles = g_array_new (FALSE, FALSE, sizeof (guint));
+ g_array_append_val (handles, tp_chan->handle);
+ if (!tp_conn_inspect_handles (DBUS_G_PROXY (tp_conn),
+ tp_chan->handle_type,
+ handles,
+ &names,
+ &error)) {
+ gossip_debug (DEBUG_DOMAIN,
+ "Couldn't get id: %s",
+ error ? error->message : "No error given");
+
+ g_clear_error (&error);
+ g_array_free (handles, TRUE);
+ g_object_unref (tp_conn);
+
+ return NULL;
+ }
- manager = empathy_session_get_contact_manager ();
- account = gossip_contact_get_account (contact);
+ name = *names;
+ g_free (names);
+ g_object_unref (tp_conn);
- return empathy_contact_manager_get_own (manager, account);
+ return name;
}