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.
This commit is contained in:
Benjamin Otte 2010-12-07 16:06:38 +01:00
parent c59ba60fbe
commit 07fd29c323
7 changed files with 16 additions and 14 deletions

View File

@ -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,

View File

@ -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);
}
/**

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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)

View File

@ -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)