[gnio/connection-factory: 4/6] Use the generic socket connection constructor in GSocketListener
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnio/connection-factory: 4/6] Use the generic socket connection constructor in GSocketListener
- Date: Fri, 8 May 2009 10:25:53 -0400 (EDT)
commit bf1afd0859a83f682e45ae133e18f5fe963e9204
Author: Alexander Larsson <alexl redhat com>
Date: Fri May 8 14:48:45 2009 +0200
Use the generic socket connection constructor in GSocketListener
We now use g_socket_connection_factory_create_connection to create
the connection, deleting all the connection_factory implementations
from the subclasses.
---
gio/gsocketlistener.c | 12 ++++++++----
gio/gsocketlistener.h | 2 --
gio/gtcplistener.c | 8 --------
gio/gunixlistener.c | 8 --------
4 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/gio/gsocketlistener.c b/gio/gsocketlistener.c
index 6f796f5..53304d3 100644
--- a/gio/gsocketlistener.c
+++ b/gio/gsocketlistener.c
@@ -97,6 +97,7 @@ g_socket_listener_accept (GSocketListener *listener,
GError **error)
{
GSocket *socket;
+ GSocketConnection *connection;
g_return_val_if_fail (G_IS_SOCKET_LISTENER (listener), NULL);
@@ -115,8 +116,11 @@ g_socket_listener_accept (GSocketListener *listener,
if (!(socket = g_socket_accept (listener->priv->socket, error)))
return NULL;
- return G_SOCKET_LISTENER_GET_CLASS (listener)
- ->connection_factory (listener, socket);
+ connection = g_socket_connection_factory_create_connection (socket);
+
+ g_object_unref (socket);
+
+ return connection;
}
static gboolean
@@ -138,10 +142,10 @@ g_socket_listener_accept_ready (GSocketListener *listener,
if (socket)
{
- GSocketListenerClass *class = G_SOCKET_LISTENER_GET_CLASS (listener);
GSocketConnection *connection;
- connection = class->connection_factory (listener, socket);
+ connection = g_socket_connection_factory_create_connection (socket);
+
g_simple_async_result_set_op_res_gpointer (simple, connection,
g_object_unref);
g_object_unref (socket);
diff --git a/gio/gsocketlistener.h b/gio/gsocketlistener.h
index 6c27a3a..dfa1b1a 100644
--- a/gio/gsocketlistener.h
+++ b/gio/gsocketlistener.h
@@ -48,8 +48,6 @@ struct _GSocketListenerClass
GSocket * (* socket_factory) (GSocketListener *listener,
GError **error);
- GSocketConnection * (* connection_factory) (GSocketListener *listener,
- GSocket *socket);
gpointer padding[6];
};
diff --git a/gio/gtcplistener.c b/gio/gtcplistener.c
index 02a2c1a..cc0ef93 100644
--- a/gio/gtcplistener.c
+++ b/gio/gtcplistener.c
@@ -33,13 +33,6 @@ struct _GTcpListenerPrivate
G_DEFINE_TYPE (GTcpListener, g_tcp_listener, G_TYPE_SOCKET_LISTENER);
-static GSocketConnection *
-g_tcp_listener_connection_factory (GSocketListener *listener,
- GSocket *socket)
-{
- return g_object_new (G_TYPE_TCP_CONNECTION, "socket", socket, NULL);
-}
-
static GSocket *
g_tcp_listener_socket_factory (GSocketListener *listener,
GError **error)
@@ -171,7 +164,6 @@ g_tcp_listener_class_init (GTcpListenerClass *class)
g_type_class_add_private (class, sizeof (GTcpListenerPrivate));
listener_class->socket_factory = g_tcp_listener_socket_factory;
- listener_class->connection_factory = g_tcp_listener_connection_factory;
object_class->set_property = g_tcp_listener_set_property;
object_class->get_property = g_tcp_listener_get_property;
diff --git a/gio/gunixlistener.c b/gio/gunixlistener.c
index 4cba4ca..92678d4 100644
--- a/gio/gunixlistener.c
+++ b/gio/gunixlistener.c
@@ -30,13 +30,6 @@ struct _GUnixListenerPrivate
G_DEFINE_TYPE (GUnixListener, g_unix_listener, G_TYPE_SOCKET_LISTENER);
-static GSocketConnection *
-g_unix_listener_connection_factory (GSocketListener *listener,
- GSocket *socket)
-{
- return g_object_new (G_TYPE_UNIX_CONNECTION, "socket", socket, NULL);
-}
-
static GSocket *
g_unix_listener_socket_factory (GSocketListener *listener,
GError **error)
@@ -114,7 +107,6 @@ g_unix_listener_class_init (GUnixListenerClass *class)
g_type_class_add_private (class, sizeof (GUnixListenerPrivate));
listener_class->socket_factory = g_unix_listener_socket_factory;
- listener_class->connection_factory = g_unix_listener_connection_factory;
object_class->set_property = g_unix_listener_set_property;
object_class->get_property = g_unix_listener_get_property;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]