[libsoup/http2: 1/10] rename SoupIOStream to SoupSocketIOStream
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/http2: 1/10] rename SoupIOStream to SoupSocketIOStream
- Date: Tue, 10 Dec 2013 17:28:42 +0000 (UTC)
commit 1d5a0aec0cac88fd6d7d85724494e96aa4dff50b
Author: Dan Winship <danw gnome org>
Date: Mon Aug 26 21:37:26 2013 -0400
rename SoupIOStream to SoupSocketIOStream
libsoup/Makefile.am | 4 +-
libsoup/soup-io-stream.c | 205 ---------------------------------------
libsoup/soup-io-stream.h | 40 --------
libsoup/soup-socket-io-stream.c | 186 +++++++++++++++++++++++++++++++++++
libsoup/soup-socket-io-stream.h | 39 ++++++++
libsoup/soup-socket.c | 20 ++---
6 files changed, 234 insertions(+), 260 deletions(-)
---
diff --git a/libsoup/Makefile.am b/libsoup/Makefile.am
index 60920bd..3d3452e 100644
--- a/libsoup/Makefile.am
+++ b/libsoup/Makefile.am
@@ -139,8 +139,6 @@ libsoup_2_4_la_SOURCES = \
soup-filter-input-stream.h \
soup-form.c \
soup-headers.c \
- soup-io-stream.h \
- soup-io-stream.c \
soup-logger.c \
soup-message.c \
soup-message-body.c \
@@ -176,6 +174,8 @@ libsoup_2_4_la_SOURCES = \
soup-session-private.h \
soup-session-sync.c \
soup-socket.c \
+ soup-socket-io-stream.h \
+ soup-socket-io-stream.c \
soup-status.c \
soup-tld.c \
soup-tld-private.h \
diff --git a/libsoup/soup-socket-io-stream.c b/libsoup/soup-socket-io-stream.c
new file mode 100644
index 0000000..a1a9426
--- /dev/null
+++ b/libsoup/soup-socket-io-stream.c
@@ -0,0 +1,186 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * soup-socket-io-stream.c
+ *
+ * Copyright 2012, 2013 Red Hat, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "soup-socket-io-stream.h"
+#include "soup.h"
+#include "soup-filter-input-stream.h"
+
+struct _SoupSocketIOStreamPrivate {
+ GIOStream *base_iostream;
+
+ GInputStream *istream;
+ GOutputStream *ostream;
+ gboolean disposing;
+};
+
+enum {
+ PROP_0,
+
+ PROP_BASE_IOSTREAM
+};
+
+G_DEFINE_TYPE (SoupSocketIOStream, soup_socket_io_stream, G_TYPE_IO_STREAM)
+
+static void
+soup_socket_io_stream_init (SoupSocketIOStream *stream)
+{
+ stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
+ SOUP_TYPE_SOCKET_IO_STREAM,
+ SoupSocketIOStreamPrivate);
+}
+
+static void
+soup_socket_io_stream_set_property (GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ SoupSocketIOStream *ssios = SOUP_SOCKET_IO_STREAM (object);
+ GIOStream *io;
+
+ switch (prop_id) {
+ case PROP_BASE_IOSTREAM:
+ io = ssios->priv->base_iostream = g_value_dup_object (value);
+ if (io) {
+ ssios->priv->istream =
+ soup_filter_input_stream_new (g_io_stream_get_input_stream (io));
+ ssios->priv->ostream =
+ g_object_ref (g_io_stream_get_output_stream (io));
+ } else {
+ g_clear_object (&ssios->priv->istream);
+ g_clear_object (&ssios->priv->ostream);
+ }
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+soup_socket_io_stream_get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ SoupSocketIOStream *ssios = SOUP_SOCKET_IO_STREAM (object);
+
+ switch (prop_id) {
+ case PROP_BASE_IOSTREAM:
+ g_value_set_object (value, ssios->priv->base_iostream);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+soup_socket_io_stream_dispose (GObject *object)
+{
+ SoupSocketIOStream *ssios = SOUP_SOCKET_IO_STREAM (object);
+
+ ssios->priv->disposing = TRUE;
+
+ G_OBJECT_CLASS (soup_socket_io_stream_parent_class)->dispose (object);
+}
+
+static void
+soup_socket_io_stream_finalize (GObject *object)
+{
+ SoupSocketIOStream *ssios = SOUP_SOCKET_IO_STREAM (object);
+
+ g_clear_object (&ssios->priv->base_iostream);
+ g_clear_object (&ssios->priv->istream);
+ g_clear_object (&ssios->priv->ostream);
+
+ G_OBJECT_CLASS (soup_socket_io_stream_parent_class)->finalize (object);
+}
+
+static GInputStream *
+soup_socket_io_stream_get_input_stream (GIOStream *stream)
+{
+ return SOUP_SOCKET_IO_STREAM (stream)->priv->istream;
+}
+
+static GOutputStream *
+soup_socket_io_stream_get_output_stream (GIOStream *stream)
+{
+ return SOUP_SOCKET_IO_STREAM (stream)->priv->ostream;
+}
+
+
+static gboolean
+soup_socket_io_stream_close (GIOStream *stream,
+ GCancellable *cancellable,
+ GError **error)
+{
+ SoupSocketIOStream *ssios = SOUP_SOCKET_IO_STREAM (stream);
+
+ if (ssios->priv->disposing)
+ return TRUE;
+
+ return g_io_stream_close (ssios->priv->base_iostream,
+ cancellable, error);
+}
+
+static void
+soup_socket_io_stream_close_async (GIOStream *stream,
+ int io_priority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_io_stream_close_async (SOUP_SOCKET_IO_STREAM (stream)->priv->base_iostream,
+ io_priority, cancellable, callback, user_data);
+}
+
+static gboolean
+soup_socket_io_stream_close_finish (GIOStream *stream,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_io_stream_close_finish (SOUP_SOCKET_IO_STREAM (stream)->priv->base_iostream,
+ result, error);
+}
+
+static void
+soup_socket_io_stream_class_init (SoupSocketIOStreamClass *stream_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (stream_class);
+ GIOStreamClass *io_stream_class = G_IO_STREAM_CLASS (stream_class);
+
+ g_type_class_add_private (stream_class, sizeof (SoupSocketIOStreamPrivate));
+
+ object_class->set_property = soup_socket_io_stream_set_property;
+ object_class->get_property = soup_socket_io_stream_get_property;
+ object_class->dispose = soup_socket_io_stream_dispose;
+ object_class->finalize = soup_socket_io_stream_finalize;
+
+ io_stream_class->get_input_stream = soup_socket_io_stream_get_input_stream;
+ io_stream_class->get_output_stream = soup_socket_io_stream_get_output_stream;
+ io_stream_class->close_fn = soup_socket_io_stream_close;
+ io_stream_class->close_async = soup_socket_io_stream_close_async;
+ io_stream_class->close_finish = soup_socket_io_stream_close_finish;
+
+ g_object_class_install_property (
+ object_class, PROP_BASE_IOSTREAM,
+ g_param_spec_object ("base-iostream",
+ "Base IOStream",
+ "Base GIOStream",
+ G_TYPE_IO_STREAM,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+GIOStream *
+soup_socket_io_stream_new (GIOStream *base_iostream)
+{
+ return g_object_new (SOUP_TYPE_SOCKET_IO_STREAM,
+ "base-iostream", base_iostream,
+ NULL);
+}
diff --git a/libsoup/soup-socket-io-stream.h b/libsoup/soup-socket-io-stream.h
new file mode 100644
index 0000000..b98ac00
--- /dev/null
+++ b/libsoup/soup-socket-io-stream.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright 2012 Red Hat, Inc.
+ */
+
+#ifndef __SOUP_SOCKET_IO_STREAM_H__
+#define __SOUP_SOCKET_IO_STREAM_H__ 1
+
+#include <libsoup/soup-types.h>
+
+G_BEGIN_DECLS
+
+#define SOUP_TYPE_SOCKET_IO_STREAM (soup_socket_io_stream_get_type ())
+#define SOUP_SOCKET_IO_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
SOUP_TYPE_SOCKET_IO_STREAM, SoupSocketIOStream))
+#define SOUP_SOCKET_IO_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_SOCKET_IO_STREAM,
SoupSocketIOStreamClass))
+#define SOUP_IS_SOCKET_IO_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
SOUP_TYPE_SOCKET_IO_STREAM))
+#define SOUP_IS_SOCKET_IO_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_SOCKET_IO_STREAM))
+#define SOUP_SOCKET_IO_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_SOCKET_IO_STREAM,
SoupSocketIOStreamClass))
+
+typedef struct _SoupSocketIOStreamPrivate SoupSocketIOStreamPrivate;
+
+typedef struct {
+ GIOStream parent;
+
+ SoupSocketIOStreamPrivate *priv;
+} SoupSocketIOStream;
+
+typedef struct {
+ GIOStreamClass parent_class;
+
+} SoupSocketIOStreamClass;
+
+GType soup_socket_io_stream_get_type (void);
+
+GIOStream *soup_socket_io_stream_new (GIOStream *base_iostream);
+
+G_END_DECLS
+
+#endif /* __SOUP_SOCKET_IO_STREAM_H__ */
diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c
index c101fa5..0a9ed9a 100644
--- a/libsoup/soup-socket.c
+++ b/libsoup/soup-socket.c
@@ -16,7 +16,7 @@
#include "soup-socket.h"
#include "soup.h"
#include "soup-filter-input-stream.h"
-#include "soup-io-stream.h"
+#include "soup-socket-io-stream.h"
#include "soup-misc-private.h"
/**
@@ -144,8 +144,6 @@ soup_socket_finalize (GObject *object)
g_clear_object (&priv->conn);
g_clear_object (&priv->iostream);
- g_clear_object (&priv->istream);
- g_clear_object (&priv->ostream);
g_clear_object (&priv->local_addr);
g_clear_object (&priv->remote_addr);
@@ -175,11 +173,9 @@ finish_socket_setup (SoupSocketPrivate *priv)
if (!priv->conn)
priv->conn = (GIOStream *)g_socket_connection_factory_create_connection (priv->gsock);
if (!priv->iostream)
- priv->iostream = soup_io_stream_new (priv->conn, FALSE);
- if (!priv->istream)
- priv->istream = g_object_ref (g_io_stream_get_input_stream (priv->iostream));
- if (!priv->ostream)
- priv->ostream = g_object_ref (g_io_stream_get_output_stream (priv->iostream));
+ priv->iostream = soup_socket_io_stream_new (priv->conn);
+ priv->istream = g_io_stream_get_input_stream (priv->iostream);
+ priv->ostream = g_io_stream_get_output_stream (priv->iostream);
g_socket_set_timeout (priv->gsock, priv->timeout);
}
@@ -1162,12 +1158,10 @@ soup_socket_setup_ssl (SoupSocket *sock,
g_signal_connect (priv->conn, "notify::peer-certificate",
G_CALLBACK (soup_socket_peer_certificate_changed), sock);
- g_clear_object (&priv->istream);
- g_clear_object (&priv->ostream);
g_clear_object (&priv->iostream);
- priv->iostream = soup_io_stream_new (priv->conn, FALSE);
- priv->istream = g_object_ref (g_io_stream_get_input_stream (priv->iostream));
- priv->ostream = g_object_ref (g_io_stream_get_output_stream (priv->iostream));
+ priv->iostream = soup_socket_io_stream_new (priv->conn);
+ priv->istream = g_io_stream_get_input_stream (priv->iostream);
+ priv->ostream = g_io_stream_get_output_stream (priv->iostream);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]