[gnio] Add getter and setters for GSocketClient properties
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnio] Add getter and setters for GSocketClient properties
- Date: Fri, 15 May 2009 13:57:12 -0400 (EDT)
commit 048931823c9e35bb31286f4113e5aed2caa9dae8
Author: Alexander Larsson <alexl redhat com>
Date: Fri May 15 11:39:41 2009 +0200
Add getter and setters for GSocketClient properties
Also use setters for property changes so we get change notification on
properties.
---
gio/gsocketclient.c | 101 ++++++++++++++++++++++++++++++++++++++++++++-------
gio/gsocketclient.h | 13 +++++++
2 files changed, 100 insertions(+), 14 deletions(-)
diff --git a/gio/gsocketclient.c b/gio/gsocketclient.c
index bfaab29..ea2d381 100644
--- a/gio/gsocketclient.c
+++ b/gio/gsocketclient.c
@@ -162,25 +162,98 @@ g_socket_client_set_property (GObject *object,
switch (prop_id)
{
- case PROP_FAMILY:
- client->priv->family = g_value_get_enum (value);
- break;
+ case PROP_FAMILY:
+ g_socket_client_set_family (client, g_value_get_enum (value));
+ break;
- case PROP_TYPE:
- client->priv->type = g_value_get_enum (value);
- break;
+ case PROP_TYPE:
+ g_socket_client_set_socket_type (client, g_value_get_enum (value));
+ break;
- case PROP_PROTOCOL:
- client->priv->protocol = g_value_dup_string (value);
- break;
+ case PROP_PROTOCOL:
+ g_socket_client_set_protocol (client, g_value_get_string (value));
+ break;
- case PROP_LOCAL_ADDRESS:
- client->priv->local_address = g_value_dup_object (value);
- break;
+ case PROP_LOCAL_ADDRESS:
+ g_socket_client_set_local_address (client, g_value_get_object (value));
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+GSocketFamily
+g_socket_client_get_family (GSocketClient *client)
+{
+ return client->priv->family;
+}
+
+void
+g_socket_client_set_family (GSocketClient *client,
+ GSocketFamily family)
+{
+ if (client->priv->family == family)
+ return;
+
+ client->priv->family = family;
+ g_object_notify (G_OBJECT (client), "family");
+}
+
+GSocketType
+g_socket_client_get_socket_type (GSocketClient *client)
+{
+ return client->priv->type;
+}
+
+void
+g_socket_client_set_socket_type (GSocketClient *client,
+ GSocketType type)
+{
+ if (client->priv->type == type)
+ return;
+
+ client->priv->type = type;
+ g_object_notify (G_OBJECT (client), "type");
+}
+
+const char *
+g_socket_client_get_protocol (GSocketClient *client)
+{
+ return client->priv->protocol;
+}
+
+void
+g_socket_client_set_protocol (GSocketClient *client,
+ const char *protocol)
+{
+ if (g_strcmp0 (client->priv->protocol, protocol) == 0)
+ return;
+
+ g_free (client->priv->protocol);
+ client->priv->protocol = g_strdup (protocol);
+ g_object_notify (G_OBJECT (client), "protocol");
+}
+
+GSocketAddress *
+g_socket_client_get_local_address (GSocketClient *client)
+{
+ return client->priv->local_address;
+}
+
+void
+g_socket_client_set_local_address (GSocketClient *client,
+ GSocketAddress *address)
+{
+ if (address)
+ g_object_ref (address);
+
+ if (client->priv->local_address)
+ {
+ g_object_unref (client->priv->local_address);
}
+ client->priv->local_address = address;
+ g_object_notify (G_OBJECT (client), "local-address");
}
static void
diff --git a/gio/gsocketclient.h b/gio/gsocketclient.h
index 5549db4..aba1132 100644
--- a/gio/gsocketclient.h
+++ b/gio/gsocketclient.h
@@ -56,6 +56,19 @@ GType g_socket_client_get_type (void);
GSocketClient *g_socket_client_new (void);
+GSocketFamily g_socket_client_get_family (GSocketClient *client);
+void g_socket_client_set_family (GSocketClient *client,
+ GSocketFamily family);
+GSocketType g_socket_client_get_socket_type (GSocketClient *client);
+void g_socket_client_set_socket_type (GSocketClient *client,
+ GSocketType type);
+const char *g_socket_client_get_protocol (GSocketClient *client);
+void g_socket_client_set_protocol (GSocketClient *client,
+ const char *protocol);
+GSocketAddress *g_socket_client_get_local_address (GSocketClient *client);
+void g_socket_client_set_local_address (GSocketClient *client,
+ GSocketAddress *address);
+
GSocketConnection * g_socket_client_connect (GSocketClient *client,
GSocketConnectable *connectable,
GCancellable *cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]