about summary refs log tree commit diff
path: root/src/libnm-core-impl/nm-setting-macvlan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnm-core-impl/nm-setting-macvlan.c')
-rw-r--r--src/libnm-core-impl/nm-setting-macvlan.c116
1 files changed, 28 insertions, 88 deletions
diff --git a/src/libnm-core-impl/nm-setting-macvlan.c b/src/libnm-core-impl/nm-setting-macvlan.c
index 32b30c2c..d26a8086 100644
--- a/src/libnm-core-impl/nm-setting-macvlan.c
+++ b/src/libnm-core-impl/nm-setting-macvlan.c
@@ -28,10 +28,10 @@
 NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, PROP_MODE, PROP_PROMISCUOUS, PROP_TAP, );
 
 typedef struct {
-    char *               parent;
-    NMSettingMacvlanMode mode;
-    bool                 promiscuous;
-    bool                 tap;
+    char   *parent;
+    guint32 mode;
+    bool    promiscuous;
+    bool    tap;
 } NMSettingMacvlanPrivate;
 
 /**
@@ -69,6 +69,7 @@ const char *
 nm_setting_macvlan_get_parent(NMSettingMacvlan *setting)
 {
     g_return_val_if_fail(NM_IS_SETTING_MACVLAN(setting), NULL);
+
     return NM_SETTING_MACVLAN_GET_PRIVATE(setting)->parent;
 }
 
@@ -84,6 +85,7 @@ NMSettingMacvlanMode
 nm_setting_macvlan_get_mode(NMSettingMacvlan *setting)
 {
     g_return_val_if_fail(NM_IS_SETTING_MACVLAN(setting), NM_SETTING_MACVLAN_MODE_UNKNOWN);
+
     return NM_SETTING_MACVLAN_GET_PRIVATE(setting)->mode;
 }
 
@@ -123,7 +125,7 @@ static gboolean
 verify(NMSetting *setting, NMConnection *connection, GError **error)
 {
     NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(setting);
-    NMSettingWired *         s_wired;
+    NMSettingWired          *s_wired;
 
     if (connection)
         s_wired = nm_connection_get_setting_wired(connection);
@@ -180,59 +182,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
 /*****************************************************************************/
 
 static void
-get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
-{
-    NMSettingMacvlan *       setting = NM_SETTING_MACVLAN(object);
-    NMSettingMacvlanPrivate *priv    = NM_SETTING_MACVLAN_GET_PRIVATE(setting);
-
-    switch (prop_id) {
-    case PROP_PARENT:
-        g_value_set_string(value, priv->parent);
-        break;
-    case PROP_MODE:
-        g_value_set_uint(value, priv->mode);
-        break;
-    case PROP_PROMISCUOUS:
-        g_value_set_boolean(value, priv->promiscuous);
-        break;
-    case PROP_TAP:
-        g_value_set_boolean(value, priv->tap);
-        break;
-    default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-        break;
-    }
-}
-
-static void
-set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
-{
-    NMSettingMacvlan *       setting = NM_SETTING_MACVLAN(object);
-    NMSettingMacvlanPrivate *priv    = NM_SETTING_MACVLAN_GET_PRIVATE(setting);
-
-    switch (prop_id) {
-    case PROP_PARENT:
-        g_free(priv->parent);
-        priv->parent = g_value_dup_string(value);
-        break;
-    case PROP_MODE:
-        priv->mode = g_value_get_uint(value);
-        break;
-    case PROP_PROMISCUOUS:
-        priv->promiscuous = g_value_get_boolean(value);
-        break;
-    case PROP_TAP:
-        priv->tap = g_value_get_boolean(value);
-        break;
-    default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-        break;
-    }
-}
-
-/*****************************************************************************/
-
-static void
 nm_setting_macvlan_init(NMSettingMacvlan *self)
 {}
 
@@ -252,28 +201,16 @@ nm_setting_macvlan_new(void)
 }
 
 static void
-finalize(GObject *object)
-{
-    NMSettingMacvlan *       setting = NM_SETTING_MACVLAN(object);
-    NMSettingMacvlanPrivate *priv    = NM_SETTING_MACVLAN_GET_PRIVATE(setting);
-
-    g_free(priv->parent);
-
-    G_OBJECT_CLASS(nm_setting_macvlan_parent_class)->finalize(object);
-}
-
-static void
 nm_setting_macvlan_class_init(NMSettingMacvlanClass *klass)
 {
-    GObjectClass *  object_class        = G_OBJECT_CLASS(klass);
+    GObjectClass   *object_class        = G_OBJECT_CLASS(klass);
     NMSettingClass *setting_class       = NM_SETTING_CLASS(klass);
-    GArray *        properties_override = _nm_sett_info_property_override_create_array();
+    GArray         *properties_override = _nm_sett_info_property_override_create_array();
 
     g_type_class_add_private(klass, sizeof(NMSettingMacvlanPrivate));
 
-    object_class->get_property = get_property;
-    object_class->set_property = set_property;
-    object_class->finalize     = finalize;
+    object_class->get_property = _nm_setting_property_get_property_direct;
+    object_class->set_property = _nm_setting_property_set_property_direct;
 
     setting_class->verify = verify;
 
@@ -287,12 +224,13 @@ nm_setting_macvlan_class_init(NMSettingMacvlanClass *klass)
      *
      * Since: 1.2
      **/
-    obj_properties[PROP_PARENT] = g_param_spec_string(
-        NM_SETTING_MACVLAN_PARENT,
-        "",
-        "",
-        NULL,
-        G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
+    _nm_setting_property_define_direct_string(properties_override,
+                                              obj_properties,
+                                              NM_SETTING_MACVLAN_PARENT,
+                                              PROP_PARENT,
+                                              NM_SETTING_PARAM_INFERRABLE,
+                                              NMSettingMacvlanPrivate,
+                                              parent);
 
     /**
      * NMSettingMacvlan:mode:
@@ -302,14 +240,16 @@ nm_setting_macvlan_class_init(NMSettingMacvlanClass *klass)
      *
      * Since: 1.2
      **/
-    obj_properties[PROP_MODE] =
-        g_param_spec_uint(NM_SETTING_MACVLAN_MODE,
-                          "",
-                          "",
-                          0,
-                          G_MAXUINT,
-                          0,
-                          G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
+    _nm_setting_property_define_direct_uint32(properties_override,
+                                              obj_properties,
+                                              NM_SETTING_MACVLAN_MODE,
+                                              PROP_MODE,
+                                              0,
+                                              G_MAXUINT32,
+                                              NM_SETTING_MACVLAN_MODE_UNKNOWN,
+                                              NM_SETTING_PARAM_INFERRABLE,
+                                              NMSettingMacvlanPrivate,
+                                              mode);
 
     /**
      * NMSettingMacvlan:promiscuous: