Commit 8fa04018 authored by Rodrigo Moya's avatar Rodrigo Moya

2007-08-03 Rodrigo Moya <rodrigo@gnome-db.org>

	* 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
parent bf5c2498
2007-08-03 Rodrigo Moya <rodrigo@gnome-db.org>
* 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.
2007-07-26 Dan Williams <dcbw@redhat.com>
Patch from Bernhard Miklautz <bernhard.miklautz@shacknet.at>
......
......@@ -4,4 +4,6 @@ EXTRA_DIST = \
nm-device-802-3-ethernet.xml \
nm-device.xml \
nm-ip4-config.xml \
nm-manager.xml
nm-manager.xml \
nm-settings.xml \
nm-settings-connection.xml
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/">
<interface name="org.freedesktop.NetworkManager.Settings.Connection">
<method name="GetID">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_connection_settings_get_id"/>
<arg name="id" type="s" direction="out"/>
</method>
<method name="GetSettings">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_connection_settings_get_settings"/>
<arg name="settings" type="a{sa{sv}}" direction="out"/>
</method>
<method name="GetSecrets">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_connection_settings_get_secrets"/>
<arg name="setting_name" type="s" direction="in"/>
<arg name="secrets" type="a{sv}" direction="out"/>
</method>
<signal name="Updated">
<arg name="settings" type="a{sa{sv}}"/>
</signal>
<signal name="Removed">
</signal>
</interface>
</node>
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/">
<interface name="org.freedesktop.NetworkManager.Settings">
<method name="ListConnections">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_list_connections"/>
<arg name="connections" type="ao" direction="out"/>
</method>
<signal name="NewConnection">
<arg name="connection" type="o"/>
</signal>
</interface>
</node>
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/libnm-util
BUILT_SOURCES = \
nm-access-point-bindings.h \
nm-client-bindings.h \
nm-device-bindings.h \
nm-device-802-3-ethernet-bindings.h \
nm-device-802-11-wireless-bindings.h \
nm-access-point-bindings.h \
nm-marshal.h \
nm-marshal.c
nm-marshal.c \
nm-settings-connection-glue.h \
nm-settings-glue.h
lib_LTLIBRARIES = libnm-glib.la
libnm_glib_la_CFLAGS = \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS)
libnm_glib_la_CFLAGS = \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
$(GCONF_CFLAGS) \
$(GNOME_KEYRING_CFLAGS)
libnmincludedir = $(includedir)/libnm-glib
......@@ -25,6 +29,7 @@ libnminclude_HEADERS = \
nm-device-802-11-wireless.h \
nm-access-point.h \
nm-ip4-config.h \
nm-settings.h \
nm-vpn-connection.h
libnm_glib_la_SOURCES = \
......@@ -36,13 +41,16 @@ libnm_glib_la_SOURCES = \
nm-device-802-11-wireless.c \
nm-access-point.c \
nm-ip4-config.c \
nm-settings.c \
nm-vpn-connection.c \
nm-marshal-main.c
libnm_glib_la_LIBADD = \
$(top_builddir)/libnm-util/libnm-util.la \
$(GLIB_LIBS) \
$(DBUS_LIBS)
$(DBUS_LIBS) \
$(GCONF_LIBS) \
$(GNOME_KEYRING_LIBS)
noinst_PROGRAMS = libnm-glib-test
......@@ -79,6 +87,11 @@ nm-device-802-11-wireless-bindings.h: $(top_srcdir)/introspection/nm-device-802-
nm-access-point-bindings.h: $(top_srcdir)/introspection/nm-access-point.xml
dbus-binding-tool --prefix=nm_access_point --mode=glib-client --output=nm-access-point-bindings.h $(top_srcdir)/introspection/nm-access-point.xml
nm-settings-glue.h: $(top_srcdir)/introspection/nm-settings.xml
dbus-binding-tool --prefix=nm_settings --mode=glib-server --output=nm-settings-glue.h $(top_srcdir)/introspection/nm-settings.xml
nm-settings-connection-glue.h: $(top_srcdir)/introspection/nm-settings-connection.xml
dbus-binding-tool --prefix=nm_connection_settings --mode=glib-server --output=nm-settings-connection-glue.h $(top_srcdir)/introspection/nm-settings-connection.xml
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libnm-glib.pc
......
#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);
}
#ifndef NM_SETTINGS_H
#define NM_SETTINGS_H 1
#include <glib-object.h>
#define NM_TYPE_CONNECTION_SETTINGS (nm_connection_settings_get_type ())
#define NM_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION_SETTINGS, NMConnectionSettings))
#define NM_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CONNECTION_SETTINGS, NMConnectionSettingsClass))
#define NM_IS_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION_SETTINGS))
#define NM_IS_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_CONNECTION_SETTINGS))
#define NM_CONNECTION_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CONNECTION_SETTINGS, NMConnectionSettingsClass))
typedef struct {
GObject parent;
} NMConnectionSettings;
typedef struct {
GObjectClass parent_class;
/* virtual methods */
gchar * (* get_id) (NMConnectionSettings *connection);
GHashTable * (* get_settings) (NMConnectionSettings *connection);
GHashTable * (* get_secrets) (NMConnectionSettings *connection, const gchar *setting_name);
/* signals */
void (* updated) (NMConnectionSettings *connection, GHashTable *settings);
void (* removed) (NMConnectionSettings *connection);
} NMConnectionSettingsClass;
GType nm_connection_settings_get_type (void);
#define NM_TYPE_SETTINGS (nm_settings_get_type ())
#define NM_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS, NMSettings))
#define NM_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTINGS, NMSettingsClass))
#define NM_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS))
#define NM_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SETTINGS))
#define NM_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTINGS, NMSettingsClass))
typedef struct {
GObject parent;
} NMSettings;
typedef struct {
GObjectClass parent_class;
/* virtual methods */
GPtrArray * (* list_connections) (NMSettings *settings);
/* signals */
void (* new_connection) (NMSettings *settings, NMConnectionSettings *connection);
} NMSettingsClass;
GType nm_settings_get_type (void);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment