[telepathy-gabble/master] generate FT channel path in the channel constructor and using its address to ensure it's unique

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Fri Apr 3 09:26:12 PDT 2009


---
 src/file-transfer-channel.c |    5 +++--
 src/file-transfer-channel.h |    2 +-
 src/ft-manager.c            |   31 ++-----------------------------
 3 files changed, 6 insertions(+), 32 deletions(-)

diff --git a/src/file-transfer-channel.c b/src/file-transfer-channel.c
index 3608e5e..9c3be5a 100644
--- a/src/file-transfer-channel.c
+++ b/src/file-transfer-channel.c
@@ -439,6 +439,9 @@ gabble_file_transfer_channel_constructor (GType type,
 
   tp_handle_ref (contact_repo, self->priv->handle);
 
+  self->priv->object_path = g_strdup_printf ("%s/FileTransferChannel/%p",
+      base_conn->object_path, self);
+
   /* Connect to the bus */
   bus = tp_get_bus ();
   dbus_g_connection_register_g_object (bus, self->priv->object_path, obj);
@@ -1641,7 +1644,6 @@ setup_local_socket (GabbleFileTransferChannel *self)
 
 GabbleFileTransferChannel *
 gabble_file_transfer_channel_new (GabbleConnection *conn,
-                                  const gchar *path,
                                   TpHandle handle,
                                   TpHandle initiator_handle,
                                   TpFileTransferState state,
@@ -1658,7 +1660,6 @@ gabble_file_transfer_channel_new (GabbleConnection *conn,
 {
   return g_object_new (GABBLE_TYPE_FILE_TRANSFER_CHANNEL,
       "connection", conn,
-      "object-path", path,
       "handle", handle,
       "initiator-handle", initiator_handle,
       "state", state,
diff --git a/src/file-transfer-channel.h b/src/file-transfer-channel.h
index cf1385c..7a11baa 100644
--- a/src/file-transfer-channel.h
+++ b/src/file-transfer-channel.h
@@ -63,7 +63,7 @@ GType gabble_file_transfer_channel_get_type (void);
                               GabbleFileTransferChannelClass))
 
 GabbleFileTransferChannel *
-gabble_file_transfer_channel_new (GabbleConnection *conn, const gchar *path,
+gabble_file_transfer_channel_new (GabbleConnection *conn,
     TpHandle handle, TpHandle initiator_handle, TpFileTransferState state,
     const gchar *content_type, const gchar *filename, guint64 size,
     TpFileHashType content_hash_type, const gchar *content_hash,
diff --git a/src/ft-manager.c b/src/ft-manager.c
index 0f64861..39e2970 100644
--- a/src/ft-manager.c
+++ b/src/ft-manager.c
@@ -79,23 +79,6 @@ gabble_ft_manager_init (GabbleFtManager *obj)
   priv->channels = NULL;
 }
 
-static gchar *
-generate_object_path (GabbleFtManager *self,
-                      TpHandle handle)
-{
-  GabbleFtManagerPrivate *priv = GABBLE_FT_MANAGER_GET_PRIVATE (self);
-  TpBaseConnection *base_connection = TP_BASE_CONNECTION (priv->connection);
-  /* Increasing guint to make sure object paths are random */
-  static guint id = 0;
-  gchar *path;
-
-  path = g_strdup_printf ("%s/FileTransferChannel/%u/%u",
-      base_connection->object_path, handle, id++);
-
-  DEBUG ("Object path of file channel is %s", path);
-  return path;
-}
-
 static void gabble_ft_manager_dispose (GObject *object);
 static void gabble_ft_manager_finalize (GObject *object);
 
@@ -245,7 +228,6 @@ gabble_ft_manager_handle_request (TpChannelManager *manager,
   TpFileHashType content_hash_type;
   GError *error = NULL;
   gboolean valid;
-  gchar *path = NULL;
 
   DEBUG ("File transfer request");
 
@@ -347,15 +329,11 @@ gabble_ft_manager_handle_request (TpChannelManager *manager,
 
   DEBUG ("Requested outgoing channel for handle: %d", handle);
 
-  path = generate_object_path (self, handle);
-
-  chan = gabble_file_transfer_channel_new (priv->connection, path,
+  chan = gabble_file_transfer_channel_new (priv->connection,
       handle, base_connection->self_handle, TP_FILE_TRANSFER_STATE_PENDING,
       content_type, filename, size, content_hash_type, content_hash,
       description, date, initial_offset, NULL);
 
-  g_free (path);
-
   if (!gabble_file_transfer_channel_offer_file (chan, &error))
     {
       /* Pretend the chan was closed so it's removed from the channels
@@ -435,7 +413,6 @@ void gabble_ft_manager_handle_si_request (GabbleFtManager *self,
   guint64 date = 0;
   TpFileHashType content_hash_type;
   GabbleFileTransferChannel *chan;
-  gchar *path;
 
   si_node = lm_message_node_get_child_with_namespace (msg->node, "si", NS_SI);
   g_assert (si_node != NULL);
@@ -500,17 +477,13 @@ void gabble_ft_manager_handle_si_request (GabbleFtManager *self,
         date = (guint64) mktime (&tm);
     }
 
-  path = generate_object_path (self, handle);
-
   /* TODO: initial offset */
-  chan = gabble_file_transfer_channel_new (priv->connection, path,
+  chan = gabble_file_transfer_channel_new (priv->connection,
       handle, handle, TP_FILE_TRANSFER_STATE_PENDING,
       content_type, filename, size, content_hash_type, content_hash,
       description, date, 0, bytestream);
 
   gabble_ft_manager_channel_created (self, chan, NULL);
-
-  g_free (path);
 }
 
 static void
-- 
1.5.6.5




More information about the telepathy-commits mailing list