mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-18 09:18:06 +02:00
* introspection/Makefile.am: * introspection/nm-settings.xml: * introspection/nm-settings-connection.xml: added Settings interfaces. * libnm-glib/nm-settings.[ch]: * libnm-glib/Makefile.am: added abstract class for Settings interfaces containing the DBus implementation. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2656 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
223 lines
5.8 KiB
C
223 lines
5.8 KiB
C
#include "nm-settings.h"
|
|
|
|
static GError *
|
|
new_error (const gchar *format, ...)
|
|
{
|
|
GError *err;
|
|
va_list args;
|
|
gchar *msg;
|
|
static GQuark domain_quark = 0;
|
|
|
|
va_start (args, format);
|
|
msg = g_strdup_vprintf (format, args);
|
|
va_end (args);
|
|
|
|
if (domain_quark == 0) {
|
|
domain_quark = g_quark_from_static_string ("nm-settings-error-quark");
|
|
}
|
|
|
|
err = g_error_new_literal (domain_quark, -1, (const gchar *) msg);
|
|
|
|
g_free (msg);
|
|
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
* NMSettings implementation
|
|
*/
|
|
|
|
static gboolean impl_settings_list_connections (NMSettings *settings, GPtrArray **connections, GError **error);
|
|
|
|
#include "nm-settings-glue.h"
|
|
|
|
#define SETTINGS_CLASS(o) (NM_SETTINGS_CLASS (G_OBJECT_GET_CLASS (o)))
|
|
|
|
G_DEFINE_TYPE (NMSettings, nm_settings, G_TYPE_OBJECT)
|
|
|
|
enum {
|
|
S_NEW_CONNECTION,
|
|
|
|
S_LAST_SIGNAL
|
|
};
|
|
|
|
static guint settings_signals[S_LAST_SIGNAL] = { 0 };
|
|
|
|
static gboolean
|
|
impl_settings_list_connections (NMSettings *settings, GPtrArray **connections, GError **error)
|
|
{
|
|
g_return_val_if_fail (NM_IS_SETTINGS (settings), FALSE);
|
|
|
|
if (!SETTINGS_CLASS (settings)->list_connections) {
|
|
*error = new_error ("%s.%d - Missing implementation for Settings::list_connections.", __FILE__, __LINE__);
|
|
return FALSE;
|
|
}
|
|
|
|
*connections = SETTINGS_CLASS (settings)->list_connections (settings);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
static void
|
|
nm_settings_init (NMSettings *settings)
|
|
{
|
|
}
|
|
|
|
static void
|
|
nm_settings_finalize (GObject *object)
|
|
{
|
|
G_OBJECT_CLASS (nm_settings_parent_class)->finalize (object);
|
|
}
|
|
|
|
static void
|
|
nm_settings_class_init (NMSettingsClass *settings_class)
|
|
{
|
|
GObjectClass *object_class = G_OBJECT_CLASS (settings_class);
|
|
|
|
/* virtual methods */
|
|
object_class->finalize = nm_settings_finalize;
|
|
|
|
settings_class->list_connections = NULL;
|
|
|
|
/* signals */
|
|
settings_signals[S_NEW_CONNECTION] =
|
|
g_signal_new ("new-connection",
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
G_SIGNAL_RUN_FIRST,
|
|
G_STRUCT_OFFSET (NMSettingsClass, new_connection),
|
|
NULL, NULL,
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
G_TYPE_NONE, 1,
|
|
G_TYPE_OBJECT);
|
|
|
|
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (settings_class),
|
|
&dbus_glib_nm_settings_object_info);
|
|
}
|
|
|
|
/*
|
|
* NMConnectionSettings implementation
|
|
*/
|
|
|
|
static gboolean impl_connection_settings_get_id (NMConnectionSettings *connection,
|
|
gchar **id,
|
|
GError **error);
|
|
static gboolean impl_connection_settings_get_settings (NMConnectionSettings *connection,
|
|
GHashTable **settings,
|
|
GError **error);
|
|
static gboolean impl_connection_settings_get_secrets (NMConnectionSettings *connection,
|
|
const gchar *setting_name,
|
|
GHashTable **secrets,
|
|
GError **error);
|
|
|
|
#include "nm-settings-connection-glue.h"
|
|
|
|
#define CONNECTION_SETTINGS_CLASS(o) (NM_CONNECTION_SETTINGS_CLASS (G_OBJECT_GET_CLASS (o)))
|
|
|
|
G_DEFINE_TYPE (NMConnectionSettings, nm_connection_settings, G_TYPE_OBJECT)
|
|
|
|
enum {
|
|
CS_UPDATED,
|
|
CS_REMOVED,
|
|
|
|
CS_LAST_SIGNAL
|
|
};
|
|
|
|
static guint connection_signals[CS_LAST_SIGNAL] = { 0 };
|
|
|
|
static gboolean
|
|
impl_connection_settings_get_id (NMConnectionSettings *connection,
|
|
gchar **id,
|
|
GError **error)
|
|
{
|
|
g_return_val_if_fail (NM_IS_CONNECTION_SETTINGS (connection), FALSE);
|
|
|
|
if (!CONNECTION_SETTINGS_CLASS (connection)->get_id) {
|
|
*error = new_error ("%s.%d - Missing implementation for ConnectionSettings::get_id.", __FILE__, __LINE__);
|
|
return FALSE;
|
|
}
|
|
|
|
*id = CONNECTION_SETTINGS_CLASS (connection)->get_id (connection);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
static gboolean
|
|
impl_connection_settings_get_settings (NMConnectionSettings *connection,
|
|
GHashTable **settings,
|
|
GError **error)
|
|
{
|
|
g_return_val_if_fail (NM_IS_CONNECTION_SETTINGS (connection), FALSE);
|
|
|
|
if (!CONNECTION_SETTINGS_CLASS (connection)->get_settings) {
|
|
*error = new_error ("%s.%d - Missing implementation for ConnectionSettings::get_settings.", __FILE__, __LINE__);
|
|
return FALSE;
|
|
}
|
|
|
|
*settings = CONNECTION_SETTINGS_CLASS (connection)->get_settings (connection);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
static gboolean
|
|
impl_connection_settings_get_secrets (NMConnectionSettings *connection,
|
|
const gchar *setting_name,
|
|
GHashTable **secrets,
|
|
GError **error)
|
|
{
|
|
g_return_val_if_fail (NM_IS_CONNECTION_SETTINGS (connection), FALSE);
|
|
|
|
if (!CONNECTION_SETTINGS_CLASS (connection)->get_secrets) {
|
|
*error = new_error ("%s.%d - Missing implementation for ConnectionSettings::get_secret.", __FILE__, __LINE__);
|
|
return FALSE;
|
|
}
|
|
|
|
*secrets = CONNECTION_SETTINGS_CLASS (connection)->get_secrets (connection, setting_name);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
static void
|
|
nm_connection_settings_init (NMConnectionSettings *connection)
|
|
{
|
|
}
|
|
|
|
static void
|
|
nm_connection_settings_finalize (GObject *object)
|
|
{
|
|
G_OBJECT_CLASS (nm_connection_settings_parent_class)->finalize (object);
|
|
}
|
|
|
|
static void
|
|
nm_connection_settings_class_init (NMConnectionSettingsClass *connection_settings_class)
|
|
{
|
|
GObjectClass *object_class = G_OBJECT_CLASS (connection_settings_class);
|
|
|
|
/* virtual methods */
|
|
object_class->finalize = nm_connection_settings_finalize;
|
|
|
|
connection_settings_class->get_id = NULL;
|
|
connection_settings_class->get_settings = NULL;
|
|
connection_settings_class->get_secrets = NULL;
|
|
|
|
/* signals */
|
|
connection_signals[CS_UPDATED] =
|
|
g_signal_new ("updated",
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
G_SIGNAL_RUN_FIRST,
|
|
G_STRUCT_OFFSET (NMConnectionSettingsClass, updated),
|
|
NULL, NULL,
|
|
g_cclosure_marshal_VOID__POINTER,
|
|
G_TYPE_NONE, 1,
|
|
G_TYPE_POINTER);
|
|
connection_signals[CS_REMOVED] =
|
|
g_signal_new ("removed",
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
G_SIGNAL_RUN_FIRST,
|
|
G_STRUCT_OFFSET (NMConnectionSettingsClass, removed),
|
|
NULL, NULL,
|
|
g_cclosure_marshal_VOID__VOID,
|
|
G_TYPE_NONE, 0);
|
|
|
|
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (connection_settings_class),
|
|
&dbus_glib_nm_connection_settings_object_info);
|
|
}
|