1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright © 2010 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Authors: Nicolas Dufresne <nicolas.dufresne@colllabora.co.uk>
25 #include "gproxyconnection.h"
27 #include "gtcpconnection.h"
30 #define g_proxy_connection_get_type _g_proxy_connection_get_type
31 G_DEFINE_TYPE (GProxyConnection,
32 g_proxy_connection, G_TYPE_TCP_CONNECTION);
40 struct _GProxyConnectionPrivate
46 g_proxy_connection_get_input_stream (GIOStream *io_stream)
48 GProxyConnection *connection;
49 connection = G_PROXY_PROXY_CONNECTION (io_stream);
50 return g_io_stream_get_input_stream (connection->priv->io_stream);
53 static GOutputStream *
54 g_proxy_connection_get_output_stream (GIOStream *io_stream)
56 GProxyConnection *connection;
57 connection = G_PROXY_PROXY_CONNECTION (io_stream);
58 return g_io_stream_get_output_stream (connection->priv->io_stream);
62 g_proxy_connection_get_property (GObject *object,
67 GProxyConnection *connection = G_PROXY_PROXY_CONNECTION (object);
72 g_value_set_object (value, connection->priv->io_stream);
76 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
81 g_proxy_connection_set_property (GObject *object,
86 GProxyConnection *connection = G_PROXY_PROXY_CONNECTION (object);
91 connection->priv->io_stream = G_IO_STREAM (g_value_dup_object (value));
95 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
100 g_proxy_connection_finalize (GObject *object)
102 GProxyConnection *connection = G_PROXY_PROXY_CONNECTION (object);
104 g_object_unref (connection->priv->io_stream);
106 G_OBJECT_CLASS (g_proxy_connection_parent_class)->finalize (object);
110 g_proxy_connection_class_init (GProxyConnectionClass *klass)
112 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
113 GIOStreamClass *stream_class = G_IO_STREAM_CLASS (klass);
115 g_type_class_add_private (klass, sizeof (GProxyConnectionPrivate));
117 gobject_class->set_property = g_proxy_connection_set_property;
118 gobject_class->get_property = g_proxy_connection_get_property;
119 gobject_class->finalize = g_proxy_connection_finalize;
121 stream_class->get_input_stream = g_proxy_connection_get_input_stream;
122 stream_class->get_output_stream = g_proxy_connection_get_output_stream;
124 g_object_class_install_property (gobject_class,
126 g_param_spec_object ("io-stream",
128 P_("The altered streams"),
129 G_TYPE_SOCKET_CONNECTION,
130 G_PARAM_CONSTRUCT_ONLY |
132 G_PARAM_STATIC_STRINGS));
136 g_proxy_connection_init (GProxyConnection *connection)
138 connection->priv = G_TYPE_INSTANCE_GET_PRIVATE (connection,
139 G_TYPE_PROXY_CONNECTION,
140 GProxyConnectionPrivate);
144 _g_proxy_connection_new (GTcpConnection *connection,
145 GIOStream *io_stream)
149 socket = g_socket_connection_get_socket (G_SOCKET_CONNECTION (connection));
151 return G_SOCKET_CONNECTION (g_object_new (G_TYPE_PROXY_CONNECTION,
152 "io-stream", io_stream,