[telepathy-gabble/telepathy-gabble-0.8] tube-dbus: explicitely set the value of the Requested property

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Wed Sep 9 03:25:47 PDT 2009


We can't assume that a D-Bus tube channel has been requested if we
initiated it. If we rejoin a muc containing old tube that we created
previously, we are still the initiator of those tubes but we didn't
request them.
---
 src/tube-dbus.c     |   13 +++++++++----
 src/tube-dbus.h     |    3 ++-
 src/tubes-channel.c |   19 +++++++++++--------
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/src/tube-dbus.c b/src/tube-dbus.c
index e8e3054..8a6b1b4 100644
--- a/src/tube-dbus.c
+++ b/src/tube-dbus.c
@@ -161,6 +161,7 @@ struct _GabbleTubeDBusPrivate
    * incoming tubes, always TRUE.
    */
   gboolean offered;
+  gboolean requested;
 
   /* our unique D-Bus name on the virtual tube bus (NULL for 1-1 D-Bus tubes)*/
   gchar *dbus_local_name;
@@ -755,8 +756,7 @@ gabble_tube_dbus_get_property (GObject *object,
         }
         break;
       case PROP_REQUESTED:
-        g_value_set_boolean (value,
-            (priv->initiator == priv->self_handle));
+        g_value_set_boolean (value, priv->requested);
         break;
       case PROP_INITIATOR_ID:
           {
@@ -863,6 +863,9 @@ gabble_tube_dbus_set_property (GObject *object,
       case PROP_MUC:
         priv->muc = g_value_get_object (value);
         break;
+      case PROP_REQUESTED:
+        priv->requested = g_value_get_boolean (value);
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
         break;
@@ -1138,7 +1141,7 @@ gabble_tube_dbus_class_init (GabbleTubeDBusClass *gabble_tube_dbus_class)
   param_spec = g_param_spec_boolean ("requested", "Requested?",
       "True if this channel was requested by the local user",
       FALSE,
-      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
   g_object_class_install_property (object_class, PROP_REQUESTED, param_spec);
 
   param_spec = g_param_spec_object ("muc", "GabbleMucChannel object",
@@ -1533,7 +1536,8 @@ gabble_tube_dbus_new (GabbleConnection *conn,
                       const gchar *stream_id,
                       guint id,
                       GabbleBytestreamIface *bytestream,
-                      GabbleMucChannel *muc)
+                      GabbleMucChannel *muc,
+                      gboolean requested)
 {
   GabbleTubeDBus *tube;
   gchar *object_path;
@@ -1553,6 +1557,7 @@ gabble_tube_dbus_new (GabbleConnection *conn,
       "stream-id", stream_id,
       "id", id,
       "muc", muc,
+      "requested", requested,
       NULL);
 
   if (bytestream != NULL)
diff --git a/src/tube-dbus.h b/src/tube-dbus.h
index a2f4ef8..f014b83 100644
--- a/src/tube-dbus.h
+++ b/src/tube-dbus.h
@@ -72,7 +72,8 @@ GType gabble_tube_dbus_get_type (void);
 GabbleTubeDBus *gabble_tube_dbus_new (GabbleConnection *conn, TpHandle handle,
     TpHandleType handle_type, TpHandle self_handle, TpHandle initiator,
     const gchar *service, GHashTable *parameters, const gchar *stream_id,
-    guint id, GabbleBytestreamIface *bytestream, GabbleMucChannel *muc);
+    guint id, GabbleBytestreamIface *bytestream, GabbleMucChannel *muc,
+    gboolean requested);
 
 gboolean gabble_tube_dbus_add_name (GabbleTubeDBus *tube, TpHandle handle,
     const gchar *name);
diff --git a/src/tubes-channel.c b/src/tubes-channel.c
index d93326f..fcbf36b 100644
--- a/src/tubes-channel.c
+++ b/src/tubes-channel.c
@@ -539,7 +539,8 @@ create_new_tube (GabbleTubesChannel *self,
                  GHashTable *parameters,
                  const gchar *stream_id,
                  guint tube_id,
-                 GabbleBytestreamIface *bytestream)
+                 GabbleBytestreamIface *bytestream,
+                 gboolean requested)
 {
   GabbleTubesChannelPrivate *priv = GABBLE_TUBES_CHANNEL_GET_PRIVATE (self);
   GabbleTubeIface *tube;
@@ -550,7 +551,8 @@ create_new_tube (GabbleTubesChannel *self,
     case TP_TUBE_TYPE_DBUS:
       tube = GABBLE_TUBE_IFACE (gabble_tube_dbus_new (priv->conn,
           priv->handle, priv->handle_type, priv->self_handle, initiator,
-          service, parameters, stream_id, tube_id, bytestream, self->muc));
+          service, parameters, stream_id, tube_id, bytestream, self->muc,
+          requested));
       break;
     case TP_TUBE_TYPE_STREAM:
       tube = GABBLE_TUBE_IFACE (gabble_tube_stream_new (priv->conn,
@@ -901,7 +903,7 @@ gabble_tubes_channel_presence_updated (GabbleTubesChannel *self,
                 }
 
               tube = create_new_tube (self, type, initiator_handle,
-                  service, parameters, stream_id, tube_id, NULL);
+                  service, parameters, stream_id, tube_id, NULL, FALSE);
 
               tp_channel_manager_emit_new_channel (priv->conn->muc_factory,
                   TP_EXPORTABLE_CHANNEL (tube), NULL);
@@ -1223,7 +1225,8 @@ gabble_tubes_channel_tube_si_offered (GabbleTubesChannel *self,
     }
 
   tube = create_new_tube (self, type, priv->handle, service,
-      parameters, stream_id, tube_id, (GabbleBytestreamIface *) bytestream);
+      parameters, stream_id, tube_id, (GabbleBytestreamIface *) bytestream,
+      FALSE);
 
   tp_channel_manager_emit_new_channel (priv->conn->private_tubes_factory,
       TP_EXPORTABLE_CHANNEL (tube), NULL);
@@ -1401,7 +1404,7 @@ tube_msg_offered (GabbleTubesChannel *self,
     }
 
   tube = create_new_tube (self, type, priv->handle, service,
-      parameters, NULL, tube_id, NULL);
+      parameters, NULL, tube_id, NULL, FALSE);
 
   tp_channel_manager_emit_new_channel (priv->conn->private_tubes_factory,
       TP_EXPORTABLE_CHANNEL (tube), NULL);
@@ -1539,7 +1542,7 @@ GabbleTubeIface *gabble_tubes_channel_tube_request (GabbleTubesChannel *self,
 
   stream_id = gabble_bytestream_factory_generate_stream_id ();
   tube = create_new_tube (self, type, priv->self_handle, service,
-      parameters, stream_id, tube_id, NULL);
+      parameters, stream_id, tube_id, NULL, TRUE);
   g_free (stream_id);
   g_hash_table_destroy (parameters);
 
@@ -1575,7 +1578,7 @@ gabble_tubes_channel_offer_d_bus_tube (TpSvcChannelTypeTubes *iface,
   tube_id = generate_tube_id ();
 
   tube = create_new_tube (self, TP_TUBE_TYPE_DBUS, priv->self_handle,
-      service, parameters, (const gchar *) stream_id, tube_id, NULL);
+      service, parameters, (const gchar *) stream_id, tube_id, NULL, TRUE);
 
   if (!gabble_tube_dbus_offer (GABBLE_TUBE_DBUS (tube), &error))
     {
@@ -1653,7 +1656,7 @@ gabble_tubes_channel_offer_stream_tube (TpSvcChannelTypeTubes *iface,
   tube_id = generate_tube_id ();
 
   tube = create_new_tube (self, TP_TUBE_TYPE_STREAM, priv->self_handle,
-      service, parameters, (const gchar *) stream_id, tube_id, NULL);
+      service, parameters, (const gchar *) stream_id, tube_id, NULL, TRUE);
 
   g_object_set (tube,
       "address-type", address_type,
-- 
1.5.6.5




More information about the telepathy-commits mailing list