1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301 USA.
18 * Copyright 2013 Jiri Pirko <jiri@resnulli.us>
21 #include "nm-default.h"
26 #include "nm-setting-team.h"
28 #include "nm-utils-private.h"
29 #include "nm-connection-private.h"
32 * SECTION:nm-setting-team
33 * @short_description: Describes connection properties for teams
35 * The #NMSettingTeam object is a #NMSetting subclass that describes properties
36 * necessary for team connections.
39 G_DEFINE_TYPE_WITH_CODE (NMSettingTeam, nm_setting_team, NM_TYPE_SETTING,
40 _nm_register_setting (TEAM, 1))
41 NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_TEAM)
43 #define NM_SETTING_TEAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_TEAM, NMSettingTeamPrivate))
47 } NMSettingTeamPrivate;
56 * nm_setting_team_new:
58 * Creates a new #NMSettingTeam object with default values.
60 * Returns: (transfer full): the new empty #NMSettingTeam object
63 nm_setting_team_new (void)
65 return (NMSetting *) g_object_new (NM_TYPE_SETTING_TEAM, NULL);
69 * nm_setting_team_get_config:
70 * @setting: the #NMSettingTeam
72 * Returns: the #NMSettingTeam:config property of the setting
75 nm_setting_team_get_config (NMSettingTeam *setting)
77 g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), NULL);
79 return NM_SETTING_TEAM_GET_PRIVATE (setting)->config;
83 verify (NMSetting *setting, NMConnection *connection, GError **error)
85 return _nm_connection_verify_required_interface_name (connection, error);
89 nm_setting_team_init (NMSettingTeam *setting)
94 finalize (GObject *object)
96 NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (object);
98 g_free (priv->config);
100 G_OBJECT_CLASS (nm_setting_team_parent_class)->finalize (object);
104 set_property (GObject *object, guint prop_id,
105 const GValue *value, GParamSpec *pspec)
107 NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (object);
111 g_free (priv->config);
112 priv->config = g_value_dup_string (value);
115 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
121 get_property (GObject *object, guint prop_id,
122 GValue *value, GParamSpec *pspec)
124 NMSettingTeam *setting = NM_SETTING_TEAM (object);
128 g_value_set_string (value, nm_setting_team_get_config (setting));
131 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
137 nm_setting_team_class_init (NMSettingTeamClass *setting_class)
139 GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
140 NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
142 g_type_class_add_private (setting_class, sizeof (NMSettingTeamPrivate));
144 /* virtual methods */
145 object_class->set_property = set_property;
146 object_class->get_property = get_property;
147 object_class->finalize = finalize;
148 parent_class->verify = verify;
152 * NMSettingTeam:config:
154 * The JSON configuration for the team network interface. The property
155 * should contain raw JSON configuration data suitable for teamd, because
156 * the value is passed directly to teamd. If not specified, the default
157 * configuration is used. See man teamd.conf for the format details.
161 * variable: TEAM_CONFIG
162 * description: Team configuration in JSON. See man teamd.conf for details.
165 g_object_class_install_property
166 (object_class, PROP_CONFIG,
167 g_param_spec_string (NM_SETTING_TEAM_CONFIG, "", "",
170 NM_SETTING_PARAM_INFERRABLE |
171 G_PARAM_STATIC_STRINGS));
174 * property: interface-name
176 * description: Deprecated in favor of connection.interface-name, but can
177 * be used for backward-compatibility with older daemons, to set the
178 * team's interface name.
181 _nm_setting_class_add_dbus_only_property (parent_class, "interface-name",
182 G_VARIANT_TYPE_STRING,
183 _nm_setting_get_deprecated_virtual_interface_name,