summary refs log tree commit diff
path: root/libnm-core/nm-setting-serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-core/nm-setting-serial.c')
-rw-r--r--libnm-core/nm-setting-serial.c170
1 files changed, 85 insertions, 85 deletions
diff --git a/libnm-core/nm-setting-serial.c b/libnm-core/nm-setting-serial.c
index b173197d..36bc4f69 100644
--- a/libnm-core/nm-setting-serial.c
+++ b/libnm-core/nm-setting-serial.c
@@ -22,9 +22,8 @@
 
 #include "nm-default.h"
 
-#include <string.h>
-
 #include "nm-setting-serial.h"
+
 #include "nm-setting-private.h"
 
 /**
@@ -37,9 +36,15 @@
  * such as mobile broadband or analog telephone connections.
  **/
 
-G_DEFINE_TYPE (NMSettingSerial, nm_setting_serial, NM_TYPE_SETTING)
+/*****************************************************************************/
 
-#define NM_SETTING_SERIAL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_SERIAL, NMSettingSerialPrivate))
+NM_GOBJECT_PROPERTIES_DEFINE_BASE (
+	PROP_BAUD,
+	PROP_BITS,
+	PROP_PARITY,
+	PROP_STOPBITS,
+	PROP_SEND_DELAY,
+);
 
 typedef struct {
 	guint baud;
@@ -49,29 +54,11 @@ typedef struct {
 	guint64 send_delay;
 } NMSettingSerialPrivate;
 
-enum {
-	PROP_0,
-	PROP_BAUD,
-	PROP_BITS,
-	PROP_PARITY,
-	PROP_STOPBITS,
-	PROP_SEND_DELAY,
+G_DEFINE_TYPE (NMSettingSerial, nm_setting_serial, NM_TYPE_SETTING)
 
-	LAST_PROP
-};
+#define NM_SETTING_SERIAL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_SERIAL, NMSettingSerialPrivate))
 
-/**
- * nm_setting_serial_new:
- *
- * Creates a new #NMSettingSerial object with default values.
- *
- * Returns: (transfer full): the new empty #NMSettingSerial object
- **/
-NMSetting *
-nm_setting_serial_new (void)
-{
-	return (NMSetting *) g_object_new (NM_TYPE_SETTING_SERIAL, NULL);
-}
+/*****************************************************************************/
 
 /**
  * nm_setting_serial_get_baud:
@@ -143,11 +130,6 @@ nm_setting_serial_get_send_delay (NMSettingSerial *setting)
 	return NM_SETTING_SERIAL_GET_PRIVATE (setting)->send_delay;
 }
 
-static void
-nm_setting_serial_init (NMSettingSerial *setting)
-{
-}
-
 static GVariant *
 parity_to_dbus (const GValue *from)
 {
@@ -179,27 +161,29 @@ parity_from_dbus (GVariant *from, GValue *to)
 	}
 }
 
+/*****************************************************************************/
+
 static void
-set_property (GObject *object, guint prop_id,
-              const GValue *value, GParamSpec *pspec)
+get_property (GObject *object, guint prop_id,
+              GValue *value, GParamSpec *pspec)
 {
-	NMSettingSerialPrivate *priv = NM_SETTING_SERIAL_GET_PRIVATE (object);
+	NMSettingSerial *setting = NM_SETTING_SERIAL (object);
 
 	switch (prop_id) {
 	case PROP_BAUD:
-		priv->baud = g_value_get_uint (value);
+		g_value_set_uint (value, nm_setting_serial_get_baud (setting));
 		break;
 	case PROP_BITS:
-		priv->bits = g_value_get_uint (value);
+		g_value_set_uint (value, nm_setting_serial_get_bits (setting));
 		break;
 	case PROP_PARITY:
-		priv->parity = g_value_get_enum (value);
+		g_value_set_enum (value, nm_setting_serial_get_parity (setting));
 		break;
 	case PROP_STOPBITS:
-		priv->stopbits = g_value_get_uint (value);
+		g_value_set_uint (value, nm_setting_serial_get_stopbits (setting));
 		break;
 	case PROP_SEND_DELAY:
-		priv->send_delay = g_value_get_uint64 (value);
+		g_value_set_uint64 (value, nm_setting_serial_get_send_delay (setting));
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -208,26 +192,26 @@ set_property (GObject *object, guint prop_id,
 }
 
 static void
-get_property (GObject *object, guint prop_id,
-              GValue *value, GParamSpec *pspec)
+set_property (GObject *object, guint prop_id,
+              const GValue *value, GParamSpec *pspec)
 {
-	NMSettingSerial *setting = NM_SETTING_SERIAL (object);
+	NMSettingSerialPrivate *priv = NM_SETTING_SERIAL_GET_PRIVATE (object);
 
 	switch (prop_id) {
 	case PROP_BAUD:
-		g_value_set_uint (value, nm_setting_serial_get_baud (setting));
+		priv->baud = g_value_get_uint (value);
 		break;
 	case PROP_BITS:
-		g_value_set_uint (value, nm_setting_serial_get_bits (setting));
+		priv->bits = g_value_get_uint (value);
 		break;
 	case PROP_PARITY:
-		g_value_set_enum (value, nm_setting_serial_get_parity (setting));
+		priv->parity = g_value_get_enum (value);
 		break;
 	case PROP_STOPBITS:
-		g_value_set_uint (value, nm_setting_serial_get_stopbits (setting));
+		priv->stopbits = g_value_get_uint (value);
 		break;
 	case PROP_SEND_DELAY:
-		g_value_set_uint64 (value, nm_setting_serial_get_send_delay (setting));
+		priv->send_delay = g_value_get_uint64 (value);
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -235,6 +219,26 @@ get_property (GObject *object, guint prop_id,
 	}
 }
 
+/*****************************************************************************/
+
+static void
+nm_setting_serial_init (NMSettingSerial *setting)
+{
+}
+
+/**
+ * nm_setting_serial_new:
+ *
+ * Creates a new #NMSettingSerial object with default values.
+ *
+ * Returns: (transfer full): the new empty #NMSettingSerial object
+ **/
+NMSetting *
+nm_setting_serial_new (void)
+{
+	return (NMSetting *) g_object_new (NM_TYPE_SETTING_SERIAL, NULL);
+}
+
 static void
 nm_setting_serial_class_init (NMSettingSerialClass *klass)
 {
@@ -244,8 +248,8 @@ nm_setting_serial_class_init (NMSettingSerialClass *klass)
 
 	g_type_class_add_private (klass, sizeof (NMSettingSerialPrivate));
 
-	object_class->set_property = set_property;
 	object_class->get_property = get_property;
+	object_class->set_property = set_property;
 
 	/**
 	 * NMSettingSerial:baud:
@@ -254,26 +258,24 @@ nm_setting_serial_class_init (NMSettingSerialClass *klass)
 	 * value usually has no effect for mobile broadband modems as they generally
 	 * ignore speed settings and use the highest available speed.
 	 **/
-	g_object_class_install_property
-		(object_class, PROP_BAUD,
-		 g_param_spec_uint (NM_SETTING_SERIAL_BAUD, "", "",
-		                    0, G_MAXUINT, 57600,
-		                    G_PARAM_READWRITE |
-		                    G_PARAM_CONSTRUCT |
-		                    G_PARAM_STATIC_STRINGS));
+	obj_properties[PROP_BAUD] =
+	    g_param_spec_uint (NM_SETTING_SERIAL_BAUD, "", "",
+	                       0, G_MAXUINT, 57600,
+	                       G_PARAM_READWRITE |
+	                       G_PARAM_CONSTRUCT |
+	                       G_PARAM_STATIC_STRINGS);
 
 	/**
 	 * NMSettingSerial:bits:
 	 *
 	 * Byte-width of the serial communication. The 8 in "8n1" for example.
 	 **/
-	g_object_class_install_property
-		(object_class, PROP_BITS,
-		 g_param_spec_uint (NM_SETTING_SERIAL_BITS, "", "",
-		                    5, 8, 8,
-		                    G_PARAM_READWRITE |
-		                    G_PARAM_CONSTRUCT |
-		                    G_PARAM_STATIC_STRINGS));
+	obj_properties[PROP_BITS] =
+	    g_param_spec_uint (NM_SETTING_SERIAL_BITS, "", "",
+	                       5, 8, 8,
+	                       G_PARAM_READWRITE |
+	                       G_PARAM_CONSTRUCT |
+	                       G_PARAM_STATIC_STRINGS);
 
 	/**
 	 * NMSettingSerial:parity:
@@ -295,18 +297,16 @@ nm_setting_serial_class_init (NMSettingSerialClass *klass)
 	 *   111 (ASCII 'o') for odd, 110 (ASCII 'n') for none.
 	 * ---end---
 	 */
-	g_object_class_install_property
-		(object_class, PROP_PARITY,
-		 g_param_spec_enum (NM_SETTING_SERIAL_PARITY, "", "",
-		                    NM_TYPE_SETTING_SERIAL_PARITY,
-		                    NM_SETTING_SERIAL_PARITY_NONE,
-		                    G_PARAM_READWRITE |
-		                    G_PARAM_CONSTRUCT |
-		                    G_PARAM_STATIC_STRINGS));
+	obj_properties[PROP_PARITY] =
+	    g_param_spec_enum (NM_SETTING_SERIAL_PARITY, "", "",
+	                       NM_TYPE_SETTING_SERIAL_PARITY,
+	                       NM_SETTING_SERIAL_PARITY_NONE,
+	                       G_PARAM_READWRITE |
+	                       G_PARAM_CONSTRUCT |
+	                       G_PARAM_STATIC_STRINGS);
 
 	_properties_override_add_transform (properties_override,
-	                                    g_object_class_find_property (G_OBJECT_CLASS (setting_class),
-	                                                                  NM_SETTING_SERIAL_PARITY),
+	                                    obj_properties[PROP_PARITY],
 	                                    G_VARIANT_TYPE_BYTE,
 	                                    parity_to_dbus,
 	                                    parity_from_dbus);
@@ -317,26 +317,26 @@ nm_setting_serial_class_init (NMSettingSerialClass *klass)
 	 * Number of stop bits for communication on the serial port.  Either 1 or 2.
 	 * The 1 in "8n1" for example.
 	 **/
-	g_object_class_install_property
-		(object_class, PROP_STOPBITS,
-		 g_param_spec_uint (NM_SETTING_SERIAL_STOPBITS, "", "",
-		                    1, 2, 1,
-		                    G_PARAM_READWRITE |
-		                    G_PARAM_CONSTRUCT |
-		                    G_PARAM_STATIC_STRINGS));
+	obj_properties[PROP_STOPBITS] =
+	    g_param_spec_uint (NM_SETTING_SERIAL_STOPBITS, "", "",
+	                       1, 2, 1,
+	                       G_PARAM_READWRITE |
+	                       G_PARAM_CONSTRUCT |
+	                       G_PARAM_STATIC_STRINGS);
 
 	/**
 	 * NMSettingSerial:send-delay:
 	 *
 	 * Time to delay between each byte sent to the modem, in microseconds.
 	 **/
-	g_object_class_install_property
-		(object_class, PROP_SEND_DELAY,
-		 g_param_spec_uint64 (NM_SETTING_SERIAL_SEND_DELAY, "", "",
-		                      0, G_MAXUINT64, 0,
-		                      G_PARAM_READWRITE |
-		                      G_PARAM_CONSTRUCT |
-		                      G_PARAM_STATIC_STRINGS));
+	obj_properties[PROP_SEND_DELAY] =
+	    g_param_spec_uint64 (NM_SETTING_SERIAL_SEND_DELAY, "", "",
+	                         0, G_MAXUINT64, 0,
+	                         G_PARAM_READWRITE |
+	                         G_PARAM_CONSTRUCT |
+	                         G_PARAM_STATIC_STRINGS);
+
+	g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
 
 	_nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_SERIAL,
 	                               NULL, properties_override);