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 <dbus/dbus-glib.h>
28 #include "nm-setting-team-port.h"
30 #include "nm-utils-private.h"
31 #include "nm-setting-private.h"
34 * SECTION:nm-setting-team-port
35 * @short_description: Describes connection properties for team ports
36 * @include: nm-setting-team-port.h
38 * The #NMSettingTeamPort object is a #NMSetting subclass that describes
39 * optional properties that apply to team ports.
45 * nm_setting_team_port_error_quark:
47 * Registers an error quark for #NMSettingTeamPort if necessary.
49 * Returns: the error quark used for #NMSettingTeamPort errors.
54 nm_setting_team_port_error_quark (void)
58 if (G_UNLIKELY (!quark))
59 quark = g_quark_from_static_string ("nm-setting-team-port-error-quark");
63 G_DEFINE_TYPE_WITH_CODE (NMSettingTeamPort, nm_setting_team_port, NM_TYPE_SETTING,
64 _nm_register_setting (NM_SETTING_TEAM_PORT_SETTING_NAME,
67 NM_SETTING_TEAM_PORT_ERROR))
68 NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_TEAM_PORT)
70 #define NM_SETTING_TEAM_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_TEAM_PORT, NMSettingTeamPortPrivate))
74 } NMSettingTeamPortPrivate;
83 * nm_setting_team_port_new:
85 * Creates a new #NMSettingTeamPort object with default values.
87 * Returns: (transfer full): the new empty #NMSettingTeamPort object
92 nm_setting_team_port_new (void)
94 return (NMSetting *) g_object_new (NM_TYPE_SETTING_TEAM_PORT, NULL);
98 * nm_setting_team_port_get_config:
99 * @setting: the #NMSettingTeamPort
101 * Returns: the #NMSettingTeamPort:config property of the setting
106 nm_setting_team_port_get_config (NMSettingTeamPort *setting)
108 g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), NULL);
110 return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->config;
114 verify (NMSetting *setting, GSList *all_settings, GError **error)
120 nm_setting_team_port_init (NMSettingTeamPort *setting)
125 set_property (GObject *object, guint prop_id,
126 const GValue *value, GParamSpec *pspec)
128 NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (object);
132 g_free (priv->config);
133 priv->config = g_value_dup_string (value);
136 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
142 get_property (GObject *object, guint prop_id,
143 GValue *value, GParamSpec *pspec)
145 NMSettingTeamPort *setting = NM_SETTING_TEAM_PORT (object);
149 g_value_set_string (value, nm_setting_team_port_get_config (setting));
152 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
158 finalize (GObject *object)
160 NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (object);
162 g_free (priv->config);
164 G_OBJECT_CLASS (nm_setting_team_port_parent_class)->finalize (object);
168 nm_setting_team_port_class_init (NMSettingTeamPortClass *setting_class)
170 GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
171 NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
173 g_type_class_add_private (setting_class, sizeof (NMSettingTeamPortPrivate));
175 /* virtual methods */
176 object_class->set_property = set_property;
177 object_class->get_property = get_property;
178 object_class->finalize = finalize;
179 parent_class->verify = verify;
183 * NMSettingTeamPort:config:
185 * The JSON configuration for the team port. The property should contain raw
186 * JSON configuration data suitable for teamd, because the value is passed
187 * directly to teamd. If not specified, the default configuration is
188 * used. See man teamd.conf for the format details.
190 g_object_class_install_property
191 (object_class, PROP_CONFIG,
192 g_param_spec_string (NM_SETTING_TEAM_PORT_CONFIG, "", "",
195 NM_SETTING_PARAM_INFERRABLE |
196 G_PARAM_STATIC_STRINGS));