[glib] tls: Make g_tls_{client|server}_connection_new() return a GIOStream



commit 07fd29c3236e479a217a5ad9875075537dfb3173
Author: Benjamin Otte <otte redhat com>
Date:   Tue Dec 7 16:06:38 2010 +0100

    tls: Make g_tls_{client|server}_connection_new() return a GIOStream
    
    The main use case for these objects is as an IO stream, so it makes
    sense to return them that way from the start.

 gio/gsocketclient.c        |   12 +++++++-----
 gio/gtlsclientconnection.c |    4 ++--
 gio/gtlsclientconnection.h |    2 +-
 gio/gtlsserverconnection.c |    4 ++--
 gio/gtlsserverconnection.h |    2 +-
 gio/tests/socket-client.c  |    2 +-
 gio/tests/socket-server.c  |    4 ++--
 7 files changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/gio/gsocketclient.c b/gio/gsocketclient.c
index e6008a3..f1fe01b 100644
--- a/gio/gsocketclient.c
+++ b/gio/gsocketclient.c
@@ -864,15 +864,16 @@ g_socket_client_connect (GSocketClient       *client,
 
       if (connection && client->priv->tls)
 	{
-	  GTlsClientConnection *tlsconn;
+	  GIOStream *tlsconn;
 
 	  tlsconn = g_tls_client_connection_new (connection, connectable, &last_error);
 	  g_object_unref (connection);
-	  connection = (GIOStream *)tlsconn;
+	  connection = tlsconn;
 
 	  if (tlsconn)
 	    {
-	      g_tls_client_connection_set_validation_flags (tlsconn, client->priv->tls_validation_flags);
+	      g_tls_client_connection_set_validation_flags (G_TLS_CLIENT_CONNECTION (tlsconn),
+                                                            client->priv->tls_validation_flags);
 	      if (!g_tls_connection_handshake (G_TLS_CONNECTION (tlsconn),
 					       cancellable, &last_error))
 		{
@@ -1168,7 +1169,7 @@ g_socket_client_tls_handshake_callback (GObject      *object,
 static void
 g_socket_client_tls_handshake (GSocketClientAsyncConnectData *data)
 {
-  GTlsClientConnection *tlsconn;
+  GIOStream *tlsconn;
 
   if (!data->client->priv->tls)
     {
@@ -1181,7 +1182,8 @@ g_socket_client_tls_handshake (GSocketClientAsyncConnectData *data)
 					 &data->last_error);
   if (tlsconn)
     {
-      g_tls_client_connection_set_validation_flags (tlsconn, data->client->priv->tls_validation_flags);
+      g_tls_client_connection_set_validation_flags (G_TLS_CLIENT_CONNECTION (tlsconn),
+                                                    data->client->priv->tls_validation_flags);
       g_tls_connection_handshake_async (G_TLS_CONNECTION (tlsconn),
 					G_PRIORITY_DEFAULT,
 					data->cancellable,
diff --git a/gio/gtlsclientconnection.c b/gio/gtlsclientconnection.c
index ec50f39..92cd9f5 100644
--- a/gio/gtlsclientconnection.c
+++ b/gio/gtlsclientconnection.c
@@ -158,7 +158,7 @@ g_tls_client_connection_default_init (GTlsClientConnectionInterface *iface)
  *
  * Since: 2.28
  */
-GTlsClientConnection *
+GIOStream *
 g_tls_client_connection_new (GIOStream           *base_io_stream,
 			     GSocketConnectable  *server_identity,
 			     GError             **error)
@@ -172,7 +172,7 @@ g_tls_client_connection_new (GIOStream           *base_io_stream,
 			 "base-io-stream", base_io_stream,
 			 "server-identity", server_identity,
 			 NULL);
-  return G_TLS_CLIENT_CONNECTION (conn);
+  return G_IO_STREAM (conn);
 }
 
 /**
diff --git a/gio/gtlsclientconnection.h b/gio/gtlsclientconnection.h
index 2bfa8c4..2aaaa97 100644
--- a/gio/gtlsclientconnection.h
+++ b/gio/gtlsclientconnection.h
@@ -52,7 +52,7 @@ struct _GTlsClientConnectionInterface
 
 GType                 g_tls_client_connection_get_type             (void) G_GNUC_CONST;
 
-GTlsClientConnection *g_tls_client_connection_new                  (GIOStream               *base_io_stream,
+GIOStream *           g_tls_client_connection_new                  (GIOStream               *base_io_stream,
 								    GSocketConnectable      *server_identity,
 								    GError                 **error);
 
diff --git a/gio/gtlsserverconnection.c b/gio/gtlsserverconnection.c
index 791a0dd..4965656 100644
--- a/gio/gtlsserverconnection.c
+++ b/gio/gtlsserverconnection.c
@@ -78,7 +78,7 @@ g_tls_server_connection_default_init (GTlsServerConnectionInterface *iface)
  *
  * Since: 2.28
  */
-GTlsServerConnection *
+GIOStream *
 g_tls_server_connection_new (GIOStream        *base_io_stream,
 			     GTlsCertificate  *certificate,
 			     GError          **error)
@@ -92,5 +92,5 @@ g_tls_server_connection_new (GIOStream        *base_io_stream,
 			 "base-io-stream", base_io_stream,
 			 "certificate", certificate,
 			 NULL);
-  return G_TLS_SERVER_CONNECTION (conn);
+  return G_IO_STREAM (conn);
 }
diff --git a/gio/gtlsserverconnection.h b/gio/gtlsserverconnection.h
index 976996e..c909d55 100644
--- a/gio/gtlsserverconnection.h
+++ b/gio/gtlsserverconnection.h
@@ -52,7 +52,7 @@ struct _GTlsServerConnectionInterface
 
 GType                 g_tls_server_connection_get_type                 (void) G_GNUC_CONST;
 
-GTlsServerConnection *g_tls_server_connection_new                      (GIOStream        *base_io_stream,
+GIOStream *           g_tls_server_connection_new                      (GIOStream        *base_io_stream,
 									GTlsCertificate  *certificate,
 									GError          **error);
 
diff --git a/gio/tests/socket-client.c b/gio/tests/socket-client.c
index 61997da..6068034 100644
--- a/gio/tests/socket-client.c
+++ b/gio/tests/socket-client.c
@@ -203,7 +203,7 @@ main (int argc,
 
   if (tls)
     {
-      GTlsClientConnection *tls_conn;
+      GIOStream *tls_conn;
 
       tls_conn = g_tls_client_connection_new (connection, connectable, &error);
       if (!tls_conn)
diff --git a/gio/tests/socket-server.c b/gio/tests/socket-server.c
index f151681..a44b158 100644
--- a/gio/tests/socket-server.c
+++ b/gio/tests/socket-server.c
@@ -211,7 +211,7 @@ main (int argc,
 
   if (tlscert)
     {
-      GTlsServerConnection *tls_conn;
+      GIOStream *tls_conn;
 
       tls_conn = g_tls_server_connection_new (connection, tlscert, &error);
       if (!tls_conn)
@@ -230,7 +230,7 @@ main (int argc,
        }
 
       g_object_unref (connection);
-      connection = G_IO_STREAM (tls_conn);
+      connection = tls_conn;
     }
 
   if (connection)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]