[telepathy-doc/master] Clean up typing after fixing my stupid bug in the gnio-utils tp-glib branch

Davyd Madeley davyd at madeley.id.au
Wed Jul 22 22:35:13 PDT 2009


---
 docs/book/C/filetransfer.xml                 |   21 +++++++++++++++++++--
 docs/book/C/tubes.xml                        |   10 +---------
 docs/examples/glib_stream_tube/accept-tube.c |   21 +++++++++++++++------
 3 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/docs/book/C/filetransfer.xml b/docs/book/C/filetransfer.xml
index f75655a..4a86bea 100644
--- a/docs/book/C/filetransfer.xml
+++ b/docs/book/C/filetransfer.xml
@@ -276,6 +276,7 @@
        <row>
         <entry>Socket Type</entry>
 	<entry>D-Bus Type</entry>
+	<entry>GLib Type</entry>
 	<entry>Structure</entry>
 	<entry>Example</entry>
        </row>
@@ -284,6 +285,7 @@
        <row>
         <entry>Unix</entry>
 	<entry morerows="1" valign="middle"><literal>ay</literal></entry>
+	<entry morerows="1" valign="middle"><type>DBUS_TYPE_G_UCHAR_ARRAY</type></entry>
 	<entry morerows="1" valign="middle">Address as a character array</entry>
 	<entry morerows="1" valign="middle">/tmp/tp-ft-1612616106</entry>
        </row>
@@ -293,14 +295,16 @@
        <row>
         <entry>IPv4</entry>
 	<entry morerows="1" valign="middle"><literal>(sq)</literal></entry>
+	<entry><type>TP_STRUCT_TYPE_SOCKET_ADDRESS_IPV4</type></entry>
 	<entry morerows="1" valign="middle">
 	 IP address (as a string in the canonical form) and a port number
-	 (as an integer)
+	 (as an unsigned integer)
 	</entry>
 	<entry>127.0.0.1, 12001</entry>
        </row>
        <row>
         <entry>IPv6</entry>
+	<entry><type>TP_STRUCT_TYPE_SOCKET_ADDRESS_IPV6</type></entry>
 	<entry>::1, 22222</entry>
        </row>
       </tbody>
@@ -327,7 +331,6 @@
 
 	case TP_SOCKET_ADDRESS_TYPE_IPV4:
 	case TP_SOCKET_ADDRESS_TYPE_IPV6:
-		g_return_if_fail (G_VALUE_HOLDS (addressv, G_TYPE_VALUE_ARRAY));
 		GValueArray *address = g_value_get_boxed (addressv);
 		const char *host = g_value_get_string (
 			g_value_array_get_nth (address, 0));
@@ -340,6 +343,20 @@
 		g_return_if_reached ();
 }]]></programlisting>
     </example>
+    <para>
+     Be aware that abstract Unix sockets can contain the NUL character
+     (usually as their first character) so should be copied with
+     <function>memcpy</function> instead of <function>strcpy</function>.
+    </para>
+
+    <para>
+     If you're using a recent GLib you can connect to the socket using GIO,
+     <application>telepathy-glib</application> provides utilities for
+     converting between <classname>GSocketAddress</classname> objects and
+     Telepathy's address types. The functions are
+     <function>tp_address_variant_from_g_socket_address</function> and
+     <function>tp_g_socket_address_from_variant</function>.
+    </para>
    </tip>
   </sect2>
 
diff --git a/docs/book/C/tubes.xml b/docs/book/C/tubes.xml
index 12c49a1..1e93d9c 100644
--- a/docs/book/C/tubes.xml
+++ b/docs/book/C/tubes.xml
@@ -455,14 +455,6 @@
      information is provided in
      <xref linkend="tip.filetransfer.sending.decoding-address"/>.
     </para>
-
-    <para>
-     Alternatively, <application>telepathy-glib</application> provides API
-     to convert between address variants and
-     <classname>GSocketAddress</classname> objects:
-     <function>tp_address_variant_from_g_socket_address</function> and
-     <function>tp_g_socket_address_from_address_variant</function>.
-    </para>
    </note>
 
    <sect3 id="sect.tubes.stream.setup.gnio">
@@ -485,7 +477,7 @@
      between Telepathy address variants and
      <classname>GSocketAddress</classname> objects:
      <function>tp_address_variant_from_g_socket_address</function> and
-     <function>tp_g_socket_address_from_address_variant</function>.
+     <function>tp_g_socket_address_from_variant</function>.
     </para>
 
    </sect3>
diff --git a/docs/examples/glib_stream_tube/accept-tube.c b/docs/examples/glib_stream_tube/accept-tube.c
index dc00d12..1202c68 100644
--- a/docs/examples/glib_stream_tube/accept-tube.c
+++ b/docs/examples/glib_stream_tube/accept-tube.c
@@ -9,6 +9,7 @@
 #include <telepathy-glib/interfaces.h>
 #include <telepathy-glib/gtypes.h>
 #include <telepathy-glib/util.h>
+#include <telepathy-glib/gnio-util.h>
 #include <telepathy-glib/enums.h>
 #include <telepathy-glib/debug.h>
 
@@ -16,8 +17,7 @@ static GMainLoop *loop = NULL;
 static TpDBusDaemon *bus_daemon = NULL;
 static TpConnection *conn = NULL;
 
-static char *host;
-static guint port;
+static GSocketAddress *sockaddr = NULL;
 
 static void
 handle_error (const GError *error)
@@ -51,13 +51,22 @@ tube_accept_cb (TpChannel	*channel,
 	        gpointer	 user_data,
 	        GObject		*weak_obj)
 {
-	handle_error (in_error);
+	GError *error = NULL;
 
-	GValueArray *array = g_value_get_boxed (address);
-	host = g_value_dup_string (g_value_array_get_nth (array, 0));
-	port = g_value_get_uint (g_value_array_get_nth (array, 1));
+	handle_error (in_error);
 
-	g_print (" > tube_accept_cb (%s:%u)\n", host, port);
+	g_print ("variant type = %s\n", G_VALUE_TYPE_NAME (address));
+	sockaddr = tp_g_socket_address_from_variant (
+			TP_SOCKET_ADDRESS_TYPE_IPV4,
+			address);
+
+	/* FIXME: I _think_ the spec says you need to wait for state Open and 
+	 * this callback -- seeking spec clarification */
+	GSocketClient *client = g_socket_client_new ();
+	GSocketConnection *conn = g_socket_client_connect (client,
+			G_SOCKET_CONNECTABLE (sockaddr),
+			NULL, &error);
+	handle_error (error);
 }
 
 static void
-- 
1.5.6.5




More information about the telepathy-commits mailing list