]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-tp-tube.c
tp-tube: remove priv->initiator_contact and priv->factory as they are not used
[empathy.git] / libempathy / empathy-tp-tube.c
index 0772ac27195b96ab6b35b2f2b98c1d0111977863..008559338b48420e3736dbe0b6273d5091c77a66 100644 (file)
@@ -25,7 +25,6 @@
 #include <telepathy-glib/util.h>
 #include <extensions/extensions.h>
 
-#include "empathy-contact-factory.h"
 #include "empathy-enum-types.h"
 #include "empathy-tp-tube.h"
 #include "empathy-utils.h"
@@ -64,14 +63,10 @@ free_empathy_tp_tube_accept_data (gpointer data)
 typedef struct
 {
   TpChannel *channel;
-  guint initiator;
-  guint type;
   gchar *service;
   /* FIXME readd support for parameters.. */
   GHashTable *parameters;
-  guint state;
-  EmpathyContact *initiator_contact;
-  EmpathyContactFactory *factory;
+  EmpTubeChannelState state;
 } EmpathyTpTubePriv;
 
 enum
@@ -93,7 +88,7 @@ G_DEFINE_TYPE (EmpathyTpTube, empathy_tp_tube, G_TYPE_OBJECT)
 
 static void
 tp_tube_state_changed_cb (TpProxy *proxy,
-                          guint state,
+                          EmpTubeChannelState state,
                           gpointer user_data,
                           GObject *tube)
 {
@@ -204,10 +199,6 @@ tp_tube_finalize (GObject *object)
         "closing tube", NULL, NULL);
       g_object_unref (priv->channel);
     }
-  if (priv->initiator_contact)
-      g_object_unref (priv->initiator_contact);
-  if (priv->factory)
-      g_object_unref (priv->factory);
 
   g_free (priv->service);
 
@@ -229,13 +220,12 @@ empathy_tp_tube_class_init (EmpathyTpTubeClass *klass)
 
   g_object_class_install_property (object_class, PROP_CHANNEL,
       g_param_spec_object ("channel", "channel", "channel", TP_TYPE_CHANNEL,
-      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME |
-        G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_property (object_class, PROP_STATE,
-      g_param_spec_uint ("state", "state", "state", 0, G_MAXUINT, 0,
-        G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
-        G_PARAM_STATIC_BLURB));
+      g_param_spec_uint ("state", "state", "state",
+        0, NUM_EMP_TUBE_CHANNEL_STATES, 0,
+        G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_STRINGS));
 
   signals[DESTROY] = g_signal_new ("destroy",
       G_TYPE_FROM_CLASS (klass),
@@ -254,8 +244,6 @@ empathy_tp_tube_init (EmpathyTpTube *tube)
                EMPATHY_TYPE_TP_TUBE, EmpathyTpTubePriv);
 
   tube->priv = priv;
-
-  priv->factory = empathy_contact_factory_dup_singleton ();
 }
 
 EmpathyTpTube *
@@ -271,7 +259,8 @@ empathy_tp_tube_new_stream_tube (EmpathyContact *contact,
                                  TpSocketAddressType type,
                                  const gchar *hostname,
                                  guint port,
-                                 const gchar *service)
+                                 const gchar *service,
+                                 GHashTable *parameters)
 {
   MissionControl *mc;
   McAccount *account;
@@ -291,7 +280,7 @@ empathy_tp_tube_new_stream_tube (EmpathyContact *contact,
   g_return_val_if_fail (hostname != NULL, NULL);
   g_return_val_if_fail (service != NULL, NULL);
 
-  mc = empathy_mission_control_new ();
+  mc = empathy_mission_control_dup_singleton ();
   account = empathy_contact_get_account (contact);
   connection = mission_control_get_tpconnection (mc, account, NULL);
   g_object_unref (mc);
@@ -346,9 +335,16 @@ empathy_tp_tube_new_stream_tube (EmpathyContact *contact,
   dbus_g_type_struct_set (address, 0, hostname, 1, port, G_MAXUINT);
   control_param = tp_g_value_slice_new (G_TYPE_STRING);
 
+  if (parameters == NULL)
+    /* Pass an empty dict as parameters */
+    parameters = g_hash_table_new (g_str_hash, g_str_equal);
+  else
+    g_hash_table_ref (parameters);
+
   if (!emp_cli_channel_type_stream_tube_run_offer_stream_tube (
         TP_PROXY(channel), -1, type, address,
-        TP_SOCKET_ACCESS_CONTROL_LOCALHOST, control_param, &error, NULL))
+        TP_SOCKET_ACCESS_CONTROL_LOCALHOST, control_param, parameters,
+        &error, NULL))
     {
       DEBUG ("Couldn't offer tube: %s", error->message);
       g_clear_error (&error);
@@ -367,6 +363,7 @@ OUT:
   tp_g_value_slice_free (address);
   tp_g_value_slice_free (control_param);
   g_object_unref (connection);
+  g_hash_table_unref (parameters);
 
   return tube;
 }