[Vala] How to use TlsServerConnection in Vala?



Hi,

I am trying to get representation of code below in Vala.

Especially I mean the line

 test->server_connection = g_tls_server_connection_new
(G_IO_STREAM(connection), cert, &error);

I just want to use TlsServerConnection on my SocketService to handle
TLS streams. I've checked n the vapi that TlsServerConnection seems to
be interface not class or struct so obviously trying to initialize it
in that way:

new TlsServerConnection(connection)

does not work.

How to do that? Any help will be appreciated,


The original code:

static gboolean
on_incoming_connection (GSocketService *service,
 GSocketConnection *connection,
 GObject *source_object,
 gpointer user_data)
{
 Test *test = user_data;
 GOutputStream *stream;
 GTlsCertificate *cert;
 GError *error = NULL;
 gchar *path;

 path = g_build_filename (SRCDIR, "tls-tests", "server-and-key.pem", NULL);
 cert = g_tls_certificate_new_from_file (path, &error);
 g_assert_no_error (error);
 g_free (path);

 test->server_connection = g_tls_server_connection_new
(G_IO_STREAM(connection), cert, &error);
 g_assert_no_error (error);
 g_object_unref (cert);

 stream = g_io_stream_get_output_stream (test->server_connection);

 g_output_stream_write_async (stream, TEST_DATA, TEST_DATA_LENGTH,
G_PRIORITY_DEFAULT, NULL, on_output_write_finish, test);
 return FALSE;
}


Marcin



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