aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-04-20 05:04:16 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-04-20 05:04:16 +0800
commit80c96c4a4b5ba3b356165c5fd89922af91e7b82a (patch)
treea2b8670ae86f6b598ce5f1c9bec29a9f865cdaa2
parent9551be139814df14b0b6670bcf9687c0ea8de847 (diff)
downloadgsoc2013-empathy-80c96c4a4b5ba3b356165c5fd89922af91e7b82a.tar
gsoc2013-empathy-80c96c4a4b5ba3b356165c5fd89922af91e7b82a.tar.gz
gsoc2013-empathy-80c96c4a4b5ba3b356165c5fd89922af91e7b82a.tar.bz2
gsoc2013-empathy-80c96c4a4b5ba3b356165c5fd89922af91e7b82a.tar.lz
gsoc2013-empathy-80c96c4a4b5ba3b356165c5fd89922af91e7b82a.tar.xz
gsoc2013-empathy-80c96c4a4b5ba3b356165c5fd89922af91e7b82a.tar.zst
gsoc2013-empathy-80c96c4a4b5ba3b356165c5fd89922af91e7b82a.zip
Add empathy_offer_ipv4_stream_tube().
svn path=/trunk/; revision=980
-rw-r--r--libempathy/empathy-tp-tube.c76
-rw-r--r--libempathy/empathy-tp-tube.h5
-rw-r--r--libempathy/empathy-tube-handler.c2
3 files changed, 81 insertions, 2 deletions
diff --git a/libempathy/empathy-tp-tube.c b/libempathy/empathy-tp-tube.c
index efd9336b2..b789bf07f 100644
--- a/libempathy/empathy-tp-tube.c
+++ b/libempathy/empathy-tp-tube.c
@@ -23,7 +23,6 @@
#include <telepathy-glib/connection.h>
-#include "empathy-contact.h"
#include "empathy-contact-factory.h"
#include "empathy-debug.h"
#include "empathy-enum-types.h"
@@ -487,6 +486,7 @@ empathy_tp_tube_get_ipv4_socket (EmpathyTpTube *tube,
empathy_debug (DEBUG_DOMAIN, "Getting stream tube socket address");
+ /* FIXME: Same than for empathy_tp_tube_get_unix_socket() */
if (!tp_cli_channel_type_tubes_run_get_stream_tube_socket_address (priv->channel,
-1, priv->id, &address_type, &address, &error, NULL))
{
@@ -501,3 +501,77 @@ empathy_tp_tube_get_ipv4_socket (EmpathyTpTube *tube,
g_free (address);
}
+void
+empathy_offer_ipv4_stream_tube (EmpathyContact *contact,
+ const gchar *hostname,
+ guint port,
+ const gchar *service)
+{
+ MissionControl *mc;
+ McAccount *account;
+ TpConnection *connection;
+ TpChannel *channel;
+ gchar *object_path;
+ guint id;
+ GHashTable *params;
+ GValue *address;
+ GValue *control_param;
+ GError *error = NULL;
+
+ mc = empathy_mission_control_new ();
+ account = empathy_contact_get_account (contact);
+ connection = mission_control_get_tpconnection (mc, account, NULL);
+
+ if (!tp_cli_connection_run_request_channel (connection, -1,
+ TP_IFACE_CHANNEL_TYPE_TUBES, TP_HANDLE_TYPE_CONTACT,
+ empathy_contact_get_handle (contact), FALSE, &object_path, &error, NULL))
+ {
+ g_clear_error (&error);
+ g_object_unref (mc);
+ g_object_unref (account);
+ g_object_unref (connection);
+ return;
+ }
+
+ empathy_debug (DEBUG_DOMAIN, "Offering a new stream tube");
+
+ channel = tp_channel_new (connection, object_path,
+ TP_IFACE_CHANNEL_TYPE_TUBES, TP_HANDLE_TYPE_CONTACT,
+ empathy_contact_get_handle (contact), NULL);
+
+ params = g_hash_table_new (g_str_hash, g_str_equal);
+ address = g_new0 (GValue, 1);
+ g_value_init (address,
+ dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_UINT,
+ G_TYPE_INVALID));
+ g_value_take_boxed (address,
+ dbus_g_type_specialized_construct (dbus_g_type_get_struct ("GValueArray",
+ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID)));
+ dbus_g_type_struct_set (address, 0, hostname, 1, port, G_MAXUINT);
+
+ /* localhost access control, variant is ignored */
+ control_param = g_new0 (GValue, 1);
+ g_value_init (control_param, G_TYPE_STRING);
+
+ if (!tp_cli_channel_type_tubes_run_offer_stream_tube (channel, -1,
+ service, params, TP_SOCKET_ADDRESS_TYPE_IPV4, address,
+ TP_SOCKET_ACCESS_CONTROL_LOCALHOST, control_param, &id, &error, NULL))
+ {
+ empathy_debug (DEBUG_DOMAIN, "Couldn't offer tube: %s", error->message);
+ g_clear_error (&error);
+ }
+
+ empathy_debug (DEBUG_DOMAIN, "Stream tube id=%d offered", id);
+
+ g_object_unref (channel);
+ g_free (object_path);
+ g_hash_table_destroy (params);
+ g_value_reset (address);
+ g_value_reset (control_param);
+ g_free (address);
+ g_free (control_param);
+ g_object_unref (mc);
+ g_object_unref (account);
+ g_object_unref (connection);
+}
+
diff --git a/libempathy/empathy-tp-tube.h b/libempathy/empathy-tp-tube.h
index 22f6b8dc8..b4c009ba1 100644
--- a/libempathy/empathy-tp-tube.h
+++ b/libempathy/empathy-tp-tube.h
@@ -26,6 +26,8 @@
#include <telepathy-glib/channel.h>
+#include "empathy-contact.h"
+
G_BEGIN_DECLS
#define EMPATHY_TYPE_TP_TUBE (empathy_tp_tube_get_type ())
@@ -59,6 +61,9 @@ void empathy_tp_tube_get_ipv4_socket (EmpathyTpTube *tube, gchar **hostname,
guint *port);
gchar * empathy_tp_tube_get_unix_socket (EmpathyTpTube *tube);
+void empathy_offer_ipv4_stream_tube (EmpathyContact *contact,
+ const gchar *hostname, guint port, const gchar *service);
+
G_END_DECLS
#endif /* __EMPATHY_TP_TUBE_H__ */
diff --git a/libempathy/empathy-tube-handler.c b/libempathy/empathy-tube-handler.c
index b7eb66948..0005a369d 100644
--- a/libempathy/empathy-tube-handler.c
+++ b/libempathy/empathy-tube-handler.c
@@ -70,7 +70,7 @@ tube_handler_handle_tube_idle_cb (gpointer data)
EmpathyTpTube *tube;
static TpDBusDaemon *daemon = NULL;
- empathy_debug (DEBUG_DOMAIN, "New tube to be handled");
+ empathy_debug (DEBUG_DOMAIN, "New tube to be handled id=%d", idle_data->id);
if (!daemon)
daemon = tp_dbus_daemon_new (tp_get_bus ());