|
Packit Service |
b23acc |
// SPDX-License-Identifier: LGPL-2.1+
|
|
Packit Service |
b23acc |
/*
|
|
Packit Service |
b23acc |
* Copyright (C) 2007 - 2008 Novell, Inc.
|
|
Packit Service |
b23acc |
* Copyright (C) 2007 - 2014 Red Hat, Inc.
|
|
Packit Service |
b23acc |
*/
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
#include "nm-default.h"
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
#include "nm-simple-connection.h"
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
#include "nm-setting-private.h"
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
/**
|
|
Packit Service |
b23acc |
* SECTION:nm-simple-connection
|
|
Packit Service |
b23acc |
* @short_description: An unmanaged connection
|
|
Packit Service |
b23acc |
*
|
|
Packit Service |
b23acc |
* An #NMSimpleConnection does not directly represent a D-Bus-exported connection,
|
|
Packit Service |
b23acc |
* but might be used in the process of creating a new one.
|
|
Packit Service |
b23acc |
**/
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
/*****************************************************************************/
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
static void nm_simple_connection_interface_init (NMConnectionInterface *iface);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
G_DEFINE_TYPE_WITH_CODE (NMSimpleConnection, nm_simple_connection, G_TYPE_OBJECT,
|
|
Packit Service |
b23acc |
G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_simple_connection_interface_init);
|
|
Packit Service |
b23acc |
)
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
/*****************************************************************************/
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
static void
|
|
Packit Service |
b23acc |
nm_simple_connection_init (NMSimpleConnection *self)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
/**
|
|
Packit Service |
b23acc |
* nm_simple_connection_new:
|
|
Packit Service |
b23acc |
*
|
|
Packit Service |
b23acc |
* Creates a new #NMSimpleConnection object with no #NMSetting objects.
|
|
Packit Service |
b23acc |
*
|
|
Packit Service |
b23acc |
* Returns: (transfer full): the new empty #NMConnection object
|
|
Packit Service |
b23acc |
**/
|
|
Packit Service |
b23acc |
NMConnection *
|
|
Packit Service |
b23acc |
nm_simple_connection_new (void)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
return (NMConnection *) g_object_new (NM_TYPE_SIMPLE_CONNECTION, NULL);
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
/**
|
|
Packit Service |
b23acc |
* _nm_simple_connection_new_from_dbus:
|
|
Packit Service |
b23acc |
* @dict: a #GVariant of type %NM_VARIANT_TYPE_CONNECTION describing the connection
|
|
Packit Service |
b23acc |
* @error: on unsuccessful return, an error
|
|
Packit Service |
b23acc |
*
|
|
Packit Service |
b23acc |
* Creates a new #NMSimpleConnection from a hash table describing the
|
|
Packit Service |
b23acc |
* connection. See nm_connection_to_dbus() for a description of the expected
|
|
Packit Service |
b23acc |
* hash table.
|
|
Packit Service |
b23acc |
*
|
|
Packit Service |
b23acc |
* Returns: (transfer full): the new #NMSimpleConnection object, populated with
|
|
Packit Service |
b23acc |
* settings created from the values in the hash table, or %NULL if there was
|
|
Packit Service |
b23acc |
* an error.
|
|
Packit Service |
b23acc |
**/
|
|
Packit Service |
b23acc |
NMConnection *
|
|
Packit Service |
b23acc |
_nm_simple_connection_new_from_dbus (GVariant *dict, NMSettingParseFlags parse_flags, GError **error)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
NMConnection *connection;
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
g_return_val_if_fail (dict != NULL, NULL);
|
|
Packit Service |
b23acc |
g_return_val_if_fail (g_variant_is_of_type (dict, NM_VARIANT_TYPE_CONNECTION), NULL);
|
|
Packit Service |
b23acc |
g_return_val_if_fail (!NM_FLAGS_ANY (parse_flags, ~NM_SETTING_PARSE_FLAGS_ALL), NULL);
|
|
Packit Service |
b23acc |
g_return_val_if_fail (!NM_FLAGS_ALL (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT | NM_SETTING_PARSE_FLAGS_BEST_EFFORT), NULL);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
connection = nm_simple_connection_new ();
|
|
Packit Service |
b23acc |
if (!_nm_connection_replace_settings (connection, dict, parse_flags, error))
|
|
Packit Service |
b23acc |
g_clear_object (&connection);
|
|
Packit Service |
b23acc |
return connection;
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
/**
|
|
Packit Service |
b23acc |
* nm_simple_connection_new_from_dbus:
|
|
Packit Service |
b23acc |
* @dict: a #GVariant of type %NM_VARIANT_TYPE_CONNECTION describing the connection
|
|
Packit Service |
b23acc |
* @error: on unsuccessful return, an error
|
|
Packit Service |
b23acc |
*
|
|
Packit Service |
b23acc |
* Creates a new #NMSimpleConnection from a hash table describing the
|
|
Packit Service |
b23acc |
* connection and normalize the connection. See nm_connection_to_dbus() for a
|
|
Packit Service |
b23acc |
* description of the expected hash table.
|
|
Packit Service |
b23acc |
*
|
|
Packit Service |
b23acc |
* Returns: (transfer full): the new #NMSimpleConnection object, populated with
|
|
Packit Service |
b23acc |
* settings created from the values in the hash table, or %NULL if the
|
|
Packit Service |
b23acc |
* connection failed to normalize.
|
|
Packit Service |
b23acc |
**/
|
|
Packit Service |
b23acc |
NMConnection *
|
|
Packit Service |
b23acc |
nm_simple_connection_new_from_dbus (GVariant *dict, GError **error)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
return _nm_simple_connection_new_from_dbus (dict,
|
|
Packit Service |
b23acc |
NM_SETTING_PARSE_FLAGS_NORMALIZE,
|
|
Packit Service |
b23acc |
error);
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
/**
|
|
Packit Service |
b23acc |
* nm_simple_connection_new_clone:
|
|
Packit Service |
b23acc |
* @connection: the #NMConnection to clone
|
|
Packit Service |
b23acc |
*
|
|
Packit Service |
b23acc |
* Clones an #NMConnection as an #NMSimpleConnection.
|
|
Packit Service |
b23acc |
*
|
|
Packit Service |
b23acc |
* Returns: (transfer full): a new #NMConnection containing the same settings
|
|
Packit Service |
b23acc |
* and properties as the source #NMConnection
|
|
Packit Service |
b23acc |
**/
|
|
Packit Service |
b23acc |
NMConnection *
|
|
Packit Service |
b23acc |
nm_simple_connection_new_clone (NMConnection *connection)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
NMConnection *clone;
|
|
Packit Service |
b23acc |
const char *path;
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
clone = nm_simple_connection_new ();
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
path = nm_connection_get_path (connection);
|
|
Packit Service |
b23acc |
if (path)
|
|
Packit Service |
b23acc |
nm_connection_set_path (clone, path);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
nm_connection_replace_settings_from_connection (clone, connection);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
return clone;
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
static void
|
|
Packit Service |
b23acc |
dispose (GObject *object)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
#if NM_MORE_ASSERTS
|
|
Packit Service |
b23acc |
g_signal_handlers_disconnect_by_data (object, (gpointer) &_nmtst_connection_unchanging_user_data);
|
|
Packit Service |
b23acc |
#endif
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
nm_connection_clear_secrets (NM_CONNECTION (object));
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
G_OBJECT_CLASS (nm_simple_connection_parent_class)->dispose (object);
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
static void
|
|
Packit Service |
b23acc |
nm_simple_connection_class_init (NMSimpleConnectionClass *simple_class)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
GObjectClass *object_class = G_OBJECT_CLASS (simple_class);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
object_class->dispose = dispose;
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
static void
|
|
Packit Service |
b23acc |
nm_simple_connection_interface_init (NMConnectionInterface *iface)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
}
|