mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-23 03:04:18 +00:00
libnm-core: move some fake NMConnection methods over to NMSetting
nm_connection_lookup_setting_type() and nm_connection_lookup_setting_type_by_quark() have nothing to do with NMConnection. So move them to NMSetting (and rename them to nm_setting_lookup_type() and nm_setting_lookup_type_by_quark()).
This commit is contained in:
parent
2bfccab710
commit
32c26a859b
|
@ -1539,7 +1539,7 @@ nmc_setting_new_for_name (const char *name)
|
|||
NMSetting *setting = NULL;
|
||||
|
||||
if (name) {
|
||||
stype = nm_connection_lookup_setting_type (name);
|
||||
stype = nm_setting_lookup_type (name);
|
||||
if (stype != G_TYPE_INVALID) {
|
||||
setting = g_object_new (stype, NULL);
|
||||
g_warn_if_fail (NM_IS_SETTING (setting));
|
||||
|
@ -7225,7 +7225,7 @@ setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop)
|
|||
g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
|
||||
|
||||
while (iter->sname) {
|
||||
if (nm_connection_lookup_setting_type (iter->sname) == G_OBJECT_TYPE (setting))
|
||||
if (nm_setting_lookup_type (iter->sname) == G_OBJECT_TYPE (setting))
|
||||
return iter->func (setting, nmc, one_prop);
|
||||
iter++;
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ nm_editor_utils_create_connection (GType type,
|
|||
master_s_con = nm_connection_get_setting_connection (master);
|
||||
master_setting_type = nm_setting_connection_get_connection_type (master_s_con);
|
||||
master_uuid = nm_setting_connection_get_uuid (master_s_con);
|
||||
master_type = nm_connection_lookup_setting_type (master_setting_type);
|
||||
master_type = nm_setting_lookup_type (master_setting_type);
|
||||
}
|
||||
|
||||
types = nm_editor_utils_get_connection_type_list ();
|
||||
|
@ -401,7 +401,7 @@ nm_editor_utils_get_connection_type_data (NMConnection *conn)
|
|||
g_return_val_if_fail (s_con != NULL, NULL);
|
||||
|
||||
conn_type = nm_setting_connection_get_connection_type (s_con);
|
||||
conn_gtype = nm_connection_lookup_setting_type (conn_type);
|
||||
conn_gtype = nm_setting_lookup_type (conn_type);
|
||||
g_return_val_if_fail (conn_gtype != G_TYPE_INVALID, NULL);
|
||||
|
||||
types = nm_editor_utils_get_connection_type_list ();
|
||||
|
|
|
@ -698,7 +698,7 @@ nmtst_create_minimal_connection (const char *id, const char *uuid, const char *t
|
|||
uuid = uuid_free = nm_utils_uuid_generate ();
|
||||
|
||||
if (type) {
|
||||
GType type_g = nm_connection_lookup_setting_type (type);
|
||||
GType type_g = nm_setting_lookup_type (type);
|
||||
|
||||
g_assert (type_g != G_TYPE_INVALID);
|
||||
|
||||
|
|
|
@ -124,35 +124,6 @@ static NMSettingVerifyResult _nm_connection_verify (NMConnection *connection, GE
|
|||
|
||||
/*************************************************************/
|
||||
|
||||
/**
|
||||
* nm_connection_lookup_setting_type:
|
||||
* @name: a setting name
|
||||
*
|
||||
* Returns the #GType of the setting's class for a given setting name.
|
||||
*
|
||||
* Returns: the #GType of the setting's class
|
||||
**/
|
||||
GType
|
||||
nm_connection_lookup_setting_type (const char *name)
|
||||
{
|
||||
return _nm_setting_lookup_setting_type (name);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_connection_lookup_setting_type_by_quark:
|
||||
* @error_quark: a setting error quark
|
||||
*
|
||||
* Returns the #GType of the setting's class for a given setting error quark.
|
||||
* Useful for figuring out which setting a returned error is for.
|
||||
*
|
||||
* Returns: the #GType of the setting's class
|
||||
**/
|
||||
GType
|
||||
nm_connection_lookup_setting_type_by_quark (GQuark error_quark)
|
||||
{
|
||||
return _nm_setting_lookup_setting_type_by_quark (error_quark);
|
||||
}
|
||||
|
||||
static void
|
||||
setting_changed_cb (NMSetting *setting,
|
||||
GParamSpec *pspec,
|
||||
|
@ -259,7 +230,7 @@ nm_connection_get_setting_by_name (NMConnection *connection, const char *name)
|
|||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
type = nm_connection_lookup_setting_type (name);
|
||||
type = nm_setting_lookup_type (name);
|
||||
|
||||
return type ? nm_connection_get_setting (connection, type) : NULL;
|
||||
}
|
||||
|
@ -327,7 +298,7 @@ hash_to_connection (NMConnection *connection, GHashTable *new, GError **error)
|
|||
|
||||
g_hash_table_iter_init (&iter, new);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, (gpointer) &setting_hash)) {
|
||||
GType type = nm_connection_lookup_setting_type (setting_name);
|
||||
GType type = nm_setting_lookup_type (setting_name);
|
||||
|
||||
if (type) {
|
||||
NMSetting *setting = nm_setting_new_from_hash (type, setting_hash);
|
||||
|
@ -964,7 +935,7 @@ nm_connection_update_secrets (NMConnection *connection,
|
|||
*/
|
||||
g_hash_table_iter_init (&iter, secrets);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer) &key, NULL)) {
|
||||
if (_nm_setting_lookup_setting_type (key) != G_TYPE_INVALID) {
|
||||
if (nm_setting_lookup_type (key) != G_TYPE_INVALID) {
|
||||
/* @secrets looks like a hashed connection */
|
||||
hashed_connection = TRUE;
|
||||
break;
|
||||
|
|
|
@ -209,10 +209,6 @@ GHashTable *nm_connection_to_hash (NMConnection *connection,
|
|||
|
||||
void nm_connection_dump (NMConnection *connection);
|
||||
|
||||
GType nm_connection_lookup_setting_type (const char *name);
|
||||
|
||||
GType nm_connection_lookup_setting_type_by_quark (GQuark error_quark);
|
||||
|
||||
/* Helpers */
|
||||
const char * nm_connection_get_uuid (NMConnection *connection);
|
||||
const char * nm_connection_get_id (NMConnection *connection);
|
||||
|
|
|
@ -56,8 +56,6 @@ void _nm_register_setting (const char *name,
|
|||
|
||||
gboolean _nm_setting_is_base_type (NMSetting *setting);
|
||||
gboolean _nm_setting_type_is_base_type (GType type);
|
||||
GType _nm_setting_lookup_setting_type (const char *name);
|
||||
GType _nm_setting_lookup_setting_type_by_quark (GQuark error_quark);
|
||||
gint _nm_setting_compare_priority (gconstpointer a, gconstpointer b);
|
||||
|
||||
typedef enum NMSettingUpdateSecretResult {
|
||||
|
|
|
@ -225,8 +225,16 @@ _nm_setting_is_base_type (NMSetting *setting)
|
|||
return _nm_setting_type_is_base_type (G_OBJECT_TYPE (setting));
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_lookup_type:
|
||||
* @name: a setting name
|
||||
*
|
||||
* Returns the #GType of the setting's class for a given setting name.
|
||||
*
|
||||
* Returns: the #GType of the setting's class
|
||||
**/
|
||||
GType
|
||||
_nm_setting_lookup_setting_type (const char *name)
|
||||
nm_setting_lookup_type (const char *name)
|
||||
{
|
||||
SettingInfo *info;
|
||||
|
||||
|
@ -238,8 +246,17 @@ _nm_setting_lookup_setting_type (const char *name)
|
|||
return info ? info->type : G_TYPE_INVALID;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_lookup_type_by_quark:
|
||||
* @error_quark: a setting error quark
|
||||
*
|
||||
* Returns the #GType of the setting's class for a given setting error quark.
|
||||
* Useful for figuring out which setting a returned error is for.
|
||||
*
|
||||
* Returns: the #GType of the setting's class
|
||||
**/
|
||||
GType
|
||||
_nm_setting_lookup_setting_type_by_quark (GQuark error_quark)
|
||||
nm_setting_lookup_type_by_quark (GQuark error_quark)
|
||||
{
|
||||
SettingInfo *info;
|
||||
GHashTableIter iter;
|
||||
|
|
|
@ -229,6 +229,9 @@ typedef void (*NMSettingValueIterFn) (NMSetting *setting,
|
|||
|
||||
GType nm_setting_get_type (void);
|
||||
|
||||
GType nm_setting_lookup_type (const char *name);
|
||||
GType nm_setting_lookup_type_by_quark (GQuark error_quark);
|
||||
|
||||
/**
|
||||
* NMSettingHashFlags:
|
||||
* @NM_SETTING_HASH_FLAG_ALL: hash all properties (including secrets)
|
||||
|
|
|
@ -119,8 +119,6 @@ global:
|
|||
nm_connection_get_virtual_device_description;
|
||||
nm_connection_get_virtual_iface_name;
|
||||
nm_connection_is_type;
|
||||
nm_connection_lookup_setting_type;
|
||||
nm_connection_lookup_setting_type_by_quark;
|
||||
nm_connection_need_secrets;
|
||||
nm_connection_new;
|
||||
nm_connection_new_from_hash;
|
||||
|
@ -678,6 +676,8 @@ global:
|
|||
nm_setting_ip6_config_remove_dns_search_by_value;
|
||||
nm_setting_ip6_config_remove_route;
|
||||
nm_setting_ip6_config_remove_route_by_value;
|
||||
nm_setting_lookup_type;
|
||||
nm_setting_lookup_type_by_quark;
|
||||
nm_setting_need_secrets;
|
||||
nm_setting_new_from_hash;
|
||||
nm_setting_olpc_mesh_error_get_type;
|
||||
|
|
|
@ -532,7 +532,7 @@ impl_vpn_plugin_need_secrets (NMVpnPlugin *plugin,
|
|||
NM_VPN_PLUGIN_ERROR,
|
||||
NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
|
||||
"The connection was invalid: '%s' / '%s' invalid: %d.",
|
||||
g_type_name (nm_connection_lookup_setting_type_by_quark (cnfh_err->domain)),
|
||||
g_type_name (nm_setting_lookup_type_by_quark (cnfh_err->domain)),
|
||||
cnfh_err->message, cnfh_err->code);
|
||||
g_error_free (cnfh_err);
|
||||
return FALSE;
|
||||
|
|
|
@ -835,7 +835,7 @@ claim_connection (NMSettings *self,
|
|||
|
||||
if (!nm_connection_normalize (NM_CONNECTION (connection), NULL, NULL, &error)) {
|
||||
nm_log_warn (LOGD_SETTINGS, "plugin provided invalid connection: '%s' / '%s' invalid: %d",
|
||||
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
|
||||
g_type_name (nm_setting_lookup_type_by_quark (error->domain)),
|
||||
error->message, error->code);
|
||||
g_error_free (error);
|
||||
return;
|
||||
|
|
|
@ -199,7 +199,7 @@ update_connection_settings_commit_cb (NMSettingsConnection *orig, GError *error,
|
|||
if (error) {
|
||||
nm_log_warn (LOGD_SETTINGS, "%s: '%s' / '%s' invalid: %d",
|
||||
__func__,
|
||||
error ? g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)) : "(none)",
|
||||
error ? g_type_name (nm_setting_lookup_type_by_quark (error->domain)) : "(none)",
|
||||
(error && error->message) ? error->message : "(none)",
|
||||
error ? error->code : -1);
|
||||
g_clear_error (&error);
|
||||
|
|
|
@ -1172,7 +1172,7 @@ read_setting (GKeyFile *file, const char *keyfile_path, const char *group)
|
|||
if (alias)
|
||||
group = alias;
|
||||
|
||||
type = nm_connection_lookup_setting_type (group);
|
||||
type = nm_setting_lookup_type (group);
|
||||
if (type) {
|
||||
setting = g_object_new (type, NULL);
|
||||
nm_setting_enumerate_values (setting, read_one_setting_value, &info);
|
||||
|
@ -1289,7 +1289,7 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error)
|
|||
NMSetting *base_setting;
|
||||
GType base_setting_type;
|
||||
|
||||
base_setting_type = nm_connection_lookup_setting_type (ctype);
|
||||
base_setting_type = nm_setting_lookup_type (ctype);
|
||||
if (base_setting_type != G_TYPE_INVALID) {
|
||||
base_setting = (NMSetting *) g_object_new (base_setting_type, NULL);
|
||||
g_assert (base_setting);
|
||||
|
@ -1334,7 +1334,7 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error)
|
|||
if (!nm_connection_verify (connection, &verify_error)) {
|
||||
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
|
||||
"invalid or missing connection property '%s/%s'",
|
||||
verify_error ? g_type_name (nm_connection_lookup_setting_type_by_quark (verify_error->domain)) : "(unknown)",
|
||||
verify_error ? g_type_name (nm_setting_lookup_type_by_quark (verify_error->domain)) : "(unknown)",
|
||||
(verify_error && verify_error->message) ? verify_error->message : "(unknown)");
|
||||
g_clear_error (&verify_error);
|
||||
g_object_unref (connection);
|
||||
|
|
Loading…
Reference in a new issue