summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2016-03-14 12:36:54 +0100
committerLubomir Rintel <lkundrak@v3.sk>2016-03-14 16:36:53 +0100
commitb97560bc1ffb907f2d794c19d865a401a767c16d (patch)
treec7ed582a5751e68d09df018ae6b5e7870612b1c9
parent0a112e12ceac65f923de0d78e645cc882ea40d9d (diff)
ifupdown: don't remove the object in its constructor
This is wrong an all the complexity of a property and associated bookkeeping is completely unnecessary. (cherry picked from commit 0cb45af97761e47d97c8f76346f7f1bef46ce2cb)
-rw-r--r--src/settings/plugins/ifupdown/nm-ifupdown-connection.c107
-rw-r--r--src/settings/plugins/ifupdown/nm-ifupdown-connection.h2
2 files changed, 10 insertions, 99 deletions
diff --git a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c
index c6073bd7e5..c7f7a93dee 100644
--- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c
+++ b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c
@@ -36,63 +36,15 @@
G_DEFINE_TYPE (NMIfupdownConnection, nm_ifupdown_connection, NM_TYPE_SETTINGS_CONNECTION)
-#define NM_IFUPDOWN_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IFUPDOWN_CONNECTION, NMIfupdownConnectionPrivate))
-
-typedef struct {
- if_block *ifblock;
-} NMIfupdownConnectionPrivate;
-
-enum {
- PROP_ZERO,
- PROP_IFBLOCK,
- _PROP_END,
-};
-
-
NMIfupdownConnection*
nm_ifupdown_connection_new (if_block *block)
{
- g_return_val_if_fail (block != NULL, NULL);
-
- return (NMIfupdownConnection *) g_object_new (NM_TYPE_IFUPDOWN_CONNECTION,
- NM_IFUPDOWN_CONNECTION_IFBLOCK, block,
- NULL);
-}
-
-static gboolean
-supports_secrets (NMSettingsConnection *connection, const char *setting_name)
-{
- nm_log_info (LOGD_SETTINGS, "supports_secrets() for setting_name: '%s'", setting_name);
-
- return (strcmp (setting_name, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) == 0);
-}
-
-static void
-nm_ifupdown_connection_init (NMIfupdownConnection *connection)
-{
-}
-
-static GObject *
-constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
GObject *object;
- NMIfupdownConnectionPrivate *priv;
GError *error = NULL;
- object = G_OBJECT_CLASS (nm_ifupdown_connection_parent_class)->constructor (type, n_construct_params, construct_params);
- g_return_val_if_fail (object, NULL);
+ g_return_val_if_fail (block != NULL, NULL);
- priv = NM_IFUPDOWN_CONNECTION_GET_PRIVATE (object);
- if (!priv) {
- nm_log_warn (LOGD_SETTINGS, "%s.%d - no private instance.", __FILE__, __LINE__);
- goto err;
- }
- if (!priv->ifblock) {
- nm_log_warn (LOGD_SETTINGS, "(ifupdown) ifblock not provided to constructor.");
- goto err;
- }
+ object = g_object_new (NM_TYPE_IFUPDOWN_CONNECTION, NULL);
if (!ifupdown_update_connection_from_if_block (NM_CONNECTION (object), priv->ifblock, &error)) {
nm_log_warn (LOGD_SETTINGS, "%s.%d - invalid connection read from /etc/network/interfaces: (%d) %s",
@@ -100,70 +52,31 @@ constructor (GType type,
__LINE__,
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
- goto err;
+ g_object_unref (object);
+ return NULL;
}
- return object;
-
- err:
- g_object_unref (object);
- return NULL;
+ return (NMIfupdownConnection *) object;
}
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+static gboolean
+supports_secrets (NMSettingsConnection *connection, const char *setting_name)
{
- NMIfupdownConnectionPrivate *priv = NM_IFUPDOWN_CONNECTION_GET_PRIVATE (object);
- g_return_if_fail (priv);
+ nm_log_info (LOGD_SETTINGS, "supports_secrets() for setting_name: '%s'", setting_name);
- switch (prop_id) {
- case PROP_IFBLOCK:
- priv->ifblock = g_value_get_pointer (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ return (strcmp (setting_name, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) == 0);
}
static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+nm_ifupdown_connection_init (NMIfupdownConnection *connection)
{
- NMIfupdownConnectionPrivate *priv = NM_IFUPDOWN_CONNECTION_GET_PRIVATE (object);
- g_return_if_fail (priv);
-
- switch (prop_id) {
- case PROP_IFBLOCK:
- g_value_set_pointer (value, priv->ifblock);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
}
static void
nm_ifupdown_connection_class_init (NMIfupdownConnectionClass *ifupdown_connection_class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (ifupdown_connection_class);
NMSettingsConnectionClass *connection_class = NM_SETTINGS_CONNECTION_CLASS (ifupdown_connection_class);
- g_type_class_add_private (ifupdown_connection_class, sizeof (NMIfupdownConnectionPrivate));
-
- /* Virtual methods */
- object_class->constructor = constructor;
- object_class->set_property = set_property;
- object_class->get_property = get_property;
-
connection_class->supports_secrets = supports_secrets;
-
- /* Properties */
- g_object_class_install_property
- (object_class, PROP_IFBLOCK,
- g_param_spec_pointer (NM_IFUPDOWN_CONNECTION_IFBLOCK, "", "",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
}
diff --git a/src/settings/plugins/ifupdown/nm-ifupdown-connection.h b/src/settings/plugins/ifupdown/nm-ifupdown-connection.h
index be2ebc0a3e..a2f4b5a996 100644
--- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.h
+++ b/src/settings/plugins/ifupdown/nm-ifupdown-connection.h
@@ -36,8 +36,6 @@ G_BEGIN_DECLS
#define NM_IS_IFUPDOWN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IFUPDOWN_CONNECTION))
#define NM_IFUPDOWN_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IFUPDOWN_CONNECTION, NMIfupdownConnectionClass))
-#define NM_IFUPDOWN_CONNECTION_IFBLOCK "ifblock"
-
typedef struct {
NMSettingsConnection parent;
} NMIfupdownConnection;