[Telepathy-commits] [telepathy-salut/master] fill the AvailableSocketTypes hash table

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Fri Nov 21 03:46:43 PST 2008


---
 src/salut-file-transfer-channel.c        |   21 ++++++++++++++++++---
 tests/twisted/avahi/test-receive-file.py |    4 ++--
 tests/twisted/avahi/test-send-file.py    |    4 ++--
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/salut-file-transfer-channel.c b/src/salut-file-transfer-channel.c
index 435ee26..0c7f203 100644
--- a/src/salut-file-transfer-channel.c
+++ b/src/salut-file-transfer-channel.c
@@ -376,6 +376,12 @@ salut_file_transfer_channel_set_property (GObject *object,
     }
 }
 
+static void
+free_array (GArray *array)
+{
+  g_array_free (array, TRUE);
+}
+
 static GObject *
 salut_file_transfer_channel_constructor (GType type, guint n_props,
                                 GObjectConstructParam *props)
@@ -385,6 +391,8 @@ salut_file_transfer_channel_constructor (GType type, guint n_props,
   DBusGConnection *bus;
   TpBaseConnection *base_conn;
   TpHandleRepoIface *contact_repo;
+  GArray *unix_access;
+  TpSocketAccessControl access;
 
   /* Parent constructor chain */
   obj = G_OBJECT_CLASS (salut_file_transfer_channel_parent_class)->
@@ -405,9 +413,16 @@ salut_file_transfer_channel_constructor (GType type, guint n_props,
   dbus_g_connection_register_g_object (bus, self->priv->object_path, obj);
 
   /* Initialise the available socket types hash table */
-  self->priv->available_socket_types = g_hash_table_new (g_int_hash,
-      g_int_equal);
-  /* FIXME: fill this hash table */
+  self->priv->available_socket_types = g_hash_table_new_full (g_direct_hash,
+      g_direct_equal, NULL, (GDestroyNotify) free_array);
+
+  /* Socket_Address_Type_Unix */
+  unix_access = g_array_sized_new (FALSE, FALSE, sizeof (TpSocketAccessControl),
+      1);
+  access = TP_SOCKET_ACCESS_CONTROL_LOCALHOST;
+  g_array_append_val (unix_access, access);
+  g_hash_table_insert (self->priv->available_socket_types,
+      GUINT_TO_POINTER (TP_SOCKET_ADDRESS_TYPE_UNIX), unix_access);
 
   self->priv->last_transferred_bytes_emitted = 0;
 
diff --git a/tests/twisted/avahi/test-receive-file.py b/tests/twisted/avahi/test-receive-file.py
index a6ab080..81b16d5 100644
--- a/tests/twisted/avahi/test-receive-file.py
+++ b/tests/twisted/avahi/test-receive-file.py
@@ -144,8 +144,8 @@ def test(q, bus, conn):
     #assert props[ft_name_prefix + '.Description'] == FILE_DESCRIPTION
     # FIXME: How should we deal with the Date property?
     #assert props[ft_name_prefix + '.Date'] == 1225278834
-    # FIXME
-    assert props[ft_name_prefix + '.AvailableSocketTypes'] == {}
+    assert props[ft_name_prefix + '.AvailableSocketTypes'] == \
+        {SOCKET_ADDRESS_TYPE_UNIX: [SOCKET_ACCESS_CONTROL_LOCALHOST]}
     assert props[ft_name_prefix + '.TransferredBytes'] == 0
     assert props[ft_name_prefix + '.InitialOffset'] == 0
 
diff --git a/tests/twisted/avahi/test-send-file.py b/tests/twisted/avahi/test-send-file.py
index 942bce1..4880909 100644
--- a/tests/twisted/avahi/test-send-file.py
+++ b/tests/twisted/avahi/test-send-file.py
@@ -132,8 +132,8 @@ def test(q, bus, conn):
     assert props[ft_name_prefix + '.ContentHash'] == FILE_HASH
     assert props[ft_name_prefix + '.Description'] == FILE_DESCRIPTION
     assert props[ft_name_prefix + '.Date'] == 1225278834
-    # FIXME
-    assert props[ft_name_prefix + '.AvailableSocketTypes'] == {}
+    assert props[ft_name_prefix + '.AvailableSocketTypes'] == \
+        {SOCKET_ADDRESS_TYPE_UNIX: [SOCKET_ACCESS_CONTROL_LOCALHOST]}
     assert props[ft_name_prefix + '.TransferredBytes'] == 0
     assert props[ft_name_prefix + '.InitialOffset'] == 0
 
-- 
1.5.6.5




More information about the Telepathy-commits mailing list