summaryrefslogtreecommitdiff
path: root/clients/cli
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-04-12 11:05:02 +0200
committerThomas Haller <thaller@redhat.com>2017-04-13 10:11:24 +0200
commita498a8fbb6c1835c083053d5de5730e9ce06d1b7 (patch)
treeaaaa412a5fc6bc1126c6d0a2062cac3a58ad938f /clients/cli
parentecec03c8b723191c7aa86946982ddd33e121e6e2 (diff)
downloadNetworkManager-th/cli-meta.tar.gz
WIP: cli: move nmc_setting_get_valid_propertiesth/cli-meta
It looks at GObject properties to determine which properties are valid. That is not correct, because certain properties are not native GObject properties: - vpn.data - bond.options - user.data Instead, that is why we have meta data.
Diffstat (limited to 'clients/cli')
-rw-r--r--clients/cli/connections.c33
-rw-r--r--clients/cli/settings.c31
-rw-r--r--clients/cli/settings.h1
3 files changed, 29 insertions, 36 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 48454099f2..d65dbcc6a9 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -3214,6 +3214,31 @@ is_setting_valid (NMConnection *connection, const NMMetaSettingValidPartItem *co
return nm_connection_get_setting_by_name (connection, setting_name);
}
+static char **
+_get_valid_properties (NMSetting *setting)
+{
+ char **valid_props = NULL;
+ GParamSpec **props, **iter;
+ guint num;
+ int i;
+
+ /* Iterate through properties */
+ i = 0;
+ props = g_object_class_list_properties (G_OBJECT_GET_CLASS (G_OBJECT (setting)), &num);
+ valid_props = g_malloc0 (sizeof (char*) * (num + 1));
+ for (iter = props; iter && *iter; iter++) {
+ const char *key_name = g_param_spec_get_name (*iter);
+
+ /* Add all properties except for "name" that is non-editable */
+ if (g_strcmp0 (key_name, "name") != 0)
+ valid_props[i++] = g_strdup (key_name);
+ }
+ valid_props[i] = NULL;
+ g_free (props);
+
+ return valid_props;
+}
+
static char *
is_property_valid (NMSetting *setting, const char *property, GError **error)
{
@@ -3221,7 +3246,7 @@ is_property_valid (NMSetting *setting, const char *property, GError **error)
const char *prop_name;
char *ret;
- valid_props = nmc_setting_get_valid_properties (setting);
+ valid_props = _get_valid_properties (setting);
prop_name = nmc_string_is_valid (property, (const char **) valid_props, error);
ret = g_strdup (prop_name);
g_strfreev (valid_props);
@@ -5052,7 +5077,7 @@ gen_property_names (const char *text, int state)
}
if (setting) {
- valid_props = nmc_setting_get_valid_properties (setting);
+ valid_props = _get_valid_properties (setting);
ret = nmc_rl_gen_func_basic (text, state, (const char **) valid_props);
}
@@ -6222,7 +6247,7 @@ print_setting_description (NMSetting *setting)
char **all_props;
int i;
- all_props = nmc_setting_get_valid_properties (setting);
+ all_props = _get_valid_properties (setting);
g_print (("<<< %s >>>\n"), nm_setting_get_name (setting));
for (i = 0; all_props && all_props[i]; i++)
print_property_description (setting, all_props[i]);
@@ -6695,7 +6720,7 @@ menu_switch_to_level1 (NmcColorOption color_option,
"nmcli %s> ", setting_name);
menu_ctx->curr_setting = setting;
g_strfreev (menu_ctx->valid_props);
- menu_ctx->valid_props = nmc_setting_get_valid_properties (menu_ctx->curr_setting);
+ menu_ctx->valid_props = _get_valid_properties (menu_ctx->curr_setting);
g_free (menu_ctx->valid_props_str);
menu_ctx->valid_props_str = g_strjoinv (", ", menu_ctx->valid_props);
}
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
index 0f18ec7f67..939f82a91c 100644
--- a/clients/cli/settings.c
+++ b/clients/cli/settings.c
@@ -646,37 +646,6 @@ nmc_setting_remove_property_option (NMSetting *setting,
return TRUE;
}
-/*
- * Get valid property names for a setting.
- *
- * Returns: string array with the properties or NULL on failure.
- * The returned value should be freed with g_strfreev()
- */
-char **
-nmc_setting_get_valid_properties (NMSetting *setting)
-{
- char **valid_props = NULL;
- GParamSpec **props, **iter;
- guint num;
- int i;
-
- /* Iterate through properties */
- i = 0;
- props = g_object_class_list_properties (G_OBJECT_GET_CLASS (G_OBJECT (setting)), &num);
- valid_props = g_malloc0 (sizeof (char*) * (num + 1));
- for (iter = props; iter && *iter; iter++) {
- const char *key_name = g_param_spec_get_name (*iter);
-
- /* Add all properties except for "name" that is non-editable */
- if (g_strcmp0 (key_name, "name") != 0)
- valid_props[i++] = g_strdup (key_name);
- }
- valid_props[i] = NULL;
- g_free (props);
-
- return valid_props;
-}
-
const char *const*
nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop, char ***out_to_free)
{
diff --git a/clients/cli/settings.h b/clients/cli/settings.h
index 7dad622bf8..88b715f0a7 100644
--- a/clients/cli/settings.h
+++ b/clients/cli/settings.h
@@ -33,7 +33,6 @@ void nmc_setting_proxy_connect_handlers (NMSettingProxy *setting);
void nmc_setting_wireless_connect_handlers (NMSettingWireless *setting);
void nmc_setting_connection_connect_handlers (NMSettingConnection *setting, NMConnection *connection);
-char **nmc_setting_get_valid_properties (NMSetting *setting);
char *nmc_setting_get_property_desc (NMSetting *setting, const char *prop);
const char *const*nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop, char ***out_to_free);
char *nmc_setting_get_property (NMSetting *setting,