Commit ac5206aa authored by Dan Williams's avatar Dan Williams

2007-11-21 Dan Williams <dcbw@redhat.com>

	* system-settings/*
		- Add Soren's system settings service.  Needs work for distros other
			than Fedora; the backends from NM should mostly migrate to here
			and be converted to GObjects



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3104 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 36650e4a
2007-11-21 Dan Williams <dcbw@redhat.com>
* system-settings/*
- Add Soren's system settings service. Needs work for distros other
than Fedora; the backends from NM should mostly migrate to here
and be converted to GObjects
2007-11-21 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-setting-vpn-properties.c
......
......@@ -9,7 +9,8 @@ SUBDIRS = \
man \
include \
introspection \
callouts
callouts \
system-settings
EXTRA_DIST = \
CONTRIBUTING \
......
......@@ -273,6 +273,7 @@ libnm-glib/libnm_glib.pc
libnm-glib/Makefile
callouts/Makefile
dispatcher-daemon/Makefile
system-settings/Makefile
test/Makefile
test/test-common/Makefile
initscript/Makefile
......
INCLUDES = -I${top_srcdir} \
-I${top_srcdir}/include \
-I${top_srcdir}/libnm-util \
-I${top_srcdir}/libnm-glib
sbin_PROGRAMS = nm-system-settings
nm_system_settings_SOURCES = \
dbus-settings.c \
dbus-settings.h \
main.c \
shvar.c \
shvar.h
nm_system_settings_CPPFLAGS = \
$(DBUS_CFLAGS) \
$(GTHREAD_CFLAGS) \
-DDBUS_API_SUBJECT_TO_CHANGE \
-DG_DISABLE_DEPRECATED \
-DBINDIR=\"$(bindir)\" \
-DSBINDIR=\"$(sbindir)\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DDATADIR=\"$(datadir)\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DLOCALSTATEDIR=\"$(localstatedir)\" \
-DNM_RUN_DIR=\"$(rundir)\" \
-DGNOMELOCALEDIR=\"$(datadir)/locale\"
nm_system_settings_LDADD = \
$(DBUS_LIBS) \
$(GTHREAD_LIBS) \
$(top_builddir)/libnm-util/libnm-util.la \
$(top_builddir)/libnm-glib/libnm_glib.la
nm_system_settings_LDFLAGS = -rdynamic
dbusservicedir = $(DBUS_SYS_DIR)
dbusservice_DATA = nm-system-settings.conf
EXTRA_DIST = \
$(dbusservice_DATA)
/* NetworkManager system settings service
*
* Søren Sandmann <sandmann@daimi.au.dk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2007 Red Hat, Inc.
*/
#include <NetworkManager.h>
#include <nm-connection.h>
#include <dbus/dbus.h>
#include <nm-setting-connection.h>
#include "dbus-settings.h"
#include "nm-utils.h"
static gchar *connection_settings_get_id (NMConnectionSettings *connection);
static void connection_settings_get_secrets (NMConnectionSettings *connection,
const gchar *setting_name,
const gchar **hints,
gboolean request_new,
DBusGMethodInvocation *context);
G_DEFINE_TYPE (NMSysconfigConnectionSettings, nm_sysconfig_connection_settings, NM_TYPE_CONNECTION_SETTINGS);
/*
* NMSysconfigConnectionSettings
*/
static gchar *
connection_settings_get_id (NMConnectionSettings *connection)
{
NMSysconfigConnectionSettings *c = NM_SYSCONFIG_CONNECTION_SETTINGS (connection);
return g_strdup (c->id);
}
static GHashTable *
connection_settings_get_settings (NMConnectionSettings *connection)
{
NMSysconfigConnectionSettings *c = NM_SYSCONFIG_CONNECTION_SETTINGS (connection);
return nm_connection_to_hash (c->connection);
}
static void
connection_settings_get_secrets (NMConnectionSettings *connection,
const gchar *setting_name,
const gchar **hints,
gboolean request_new,
DBusGMethodInvocation *context)
{
}
static void
nm_sysconfig_connection_settings_finalize (GObject *object)
{
G_OBJECT_CLASS (nm_sysconfig_connection_settings_parent_class)->finalize (object);
}
static void
nm_sysconfig_connection_settings_class_init (NMSysconfigConnectionSettingsClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
NMConnectionSettingsClass *connection = NM_CONNECTION_SETTINGS_CLASS (class);
object_class->finalize = nm_sysconfig_connection_settings_finalize;
connection->get_id = connection_settings_get_id;
connection->get_settings = connection_settings_get_settings;
connection->get_secrets = connection_settings_get_secrets;
}
static void
nm_sysconfig_connection_settings_init (NMSysconfigConnectionSettings *sysconfig_connection_settings)
{
}
NMSysconfigConnectionSettings *
nm_sysconfig_connection_settings_new (NMConnection *connection,
DBusGConnection *g_conn)
{
NMSysconfigConnectionSettings *settings;
NMSettingConnection *s_con;
settings = g_object_new (nm_sysconfig_connection_settings_get_type(), NULL);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
settings->id = g_strdup (s_con->id);
settings->connection = connection;
nm_connection_settings_register_object (NM_CONNECTION_SETTINGS (settings), g_conn);
return settings;
}
/*
* NMSettings
*/
static GPtrArray *nm_sysconfig_settings_list_connections (NMSettings *settings);
G_DEFINE_TYPE (NMSysconfigSettings, nm_sysconfig_settings, NM_TYPE_SETTINGS);
static GPtrArray *
nm_sysconfig_settings_list_connections (NMSettings *settings)
{
GPtrArray *connections;
NMSysconfigSettings *sysconfig_settings;
GSList *iter;
g_return_val_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings), NULL);
sysconfig_settings = NM_SYSCONFIG_SETTINGS (settings);
connections = g_ptr_array_new ();
for (iter = sysconfig_settings->connections; iter; iter = g_slist_next (iter)) {
NMConnectionSettings *connection = NM_CONNECTION_SETTINGS (iter->data);
char *path;
path = g_strdup (nm_connection_settings_get_dbus_object_path (connection));
if (path)
g_ptr_array_add (connections, path);
}
/* Return a list of strings with paths to connection settings objects */
return connections;
}
static void
nm_sysconfig_settings_finalize (GObject *object)
{
NMSysconfigSettings *settings = NM_SYSCONFIG_SETTINGS (object);
if (settings->connections) {
g_slist_foreach (settings->connections, (GFunc) g_object_unref, NULL);
g_slist_free (settings->connections);
settings->connections = NULL;
}
G_OBJECT_CLASS (nm_sysconfig_settings_parent_class)->finalize (object);
}
static void
nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
NMSettingsClass *settings_class = NM_SETTINGS_CLASS (class);
object_class->finalize = nm_sysconfig_settings_finalize;
settings_class->list_connections = nm_sysconfig_settings_list_connections;
}
static void
nm_sysconfig_settings_init (NMSysconfigSettings *sysconfig_settings)
{
sysconfig_settings->connections = NULL;
}
NMSysconfigSettings *
nm_sysconfig_settings_new (DBusGConnection *g_conn)
{
NMSysconfigSettings *settings;
settings = g_object_new (nm_sysconfig_settings_get_type (), NULL);
dbus_g_connection_register_g_object (g_conn, NM_DBUS_PATH_SETTINGS, G_OBJECT (settings));
return settings;
}
void
nm_sysconfig_settings_add_connection (NMSysconfigSettings *settings,
NMSysconfigConnectionSettings *connection)
{
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings));
g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION_SETTINGS (connection));
settings->connections = g_slist_append (settings->connections, connection);
nm_settings_signal_new_connection (NM_SETTINGS (settings),
NM_CONNECTION_SETTINGS (connection));
}
/* NetworkManager system settings service
*
* Søren Sandmann <sandmann@daimi.au.dk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2007 Red Hat, Inc.
*/
#include <nm-connection.h>
#include <nm-settings.h>
typedef struct _NMSysconfigConnectionSettings NMSysconfigConnectionSettings;
typedef struct _NMSysconfigConnectionSettingsClass NMSysconfigConnectionSettingsClass;
/*
* NMSysconfigConnectionSettings
*/
#define NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS (nm_sysconfig_connection_settings_get_type ())
#define NM_SYSCONFIG_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS, NMSysconfigConnectionSettings))
#define NM_SYSCONFIG_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS, NMSysconfigConnectionSettingsClass))
#define NM_IS_SYSCONFIG_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS))
#define NM_IS_SYSCONFIG_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS))
#define NM_SYSCONFIG_CONNECTION_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_CONNECTION_SETTINGS, NMSysconfigConnectionSettingsClass))
struct _NMSysconfigConnectionSettings
{
NMConnectionSettings parent_instance;
char *id;
NMConnection *connection;
};
struct _NMSysconfigConnectionSettingsClass
{
NMConnectionSettingsClass parent_class;
};
GType nm_sysconfig_connection_settings_get_type (void);
NMSysconfigConnectionSettings *nm_sysconfig_connection_settings_new (NMConnection *connection,
DBusGConnection *g_conn);
/*
* NMSysconfigSetttings
*/
typedef struct _NMSysconfigSettings NMSysconfigSettings;
typedef struct _NMSysconfigSettingsClass NMSysconfigSettingsClass;
#define NM_TYPE_SYSCONFIG_SETTINGS (nm_sysconfig_settings_get_type ())
#define NM_SYSCONFIG_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettings))
#define NM_SYSCONFIG_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettingsClass))
#define NM_IS_SYSCONFIG_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SYSCONFIG_SETTINGS))
#define NM_IS_SYSCONFIG_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SYSCONFIG_SETTINGS))
#define NM_SYSCONFIG_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettingsClass))
struct _NMSysconfigSettings
{
NMSettings parent_instance;
GSList *connections;
};
struct _NMSysconfigSettingsClass
{
NMSettingsClass parent_class;
};
GType nm_sysconfig_settings_get_type (void);
NMSysconfigSettings *nm_sysconfig_settings_new (DBusGConnection *g_conn);
void nm_sysconfig_settings_add_connection (NMSysconfigSettings *settings,
NMSysconfigConnectionSettings *connection);
This diff is collapsed.
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="root">
<allow own="org.freedesktop.NetworkManagerSystemSettings"/>
<allow send_destination="org.freedesktop.NetworkManagerSystemSettings"/>
<allow send_interface="org.freedesktop.NetworkManagerSystemSettings"/>
</policy>
<policy context="default">
<deny own="org.freedesktop.NetworkManagerSystemSettings"/>
<deny send_destination="org.freedesktop.NetworkManagerSystemSettings"/>
<deny send_interface="org.freedesktop.NetworkManagerSystemSettings"/>
</policy>
<limit name="max_replies_per_connection">512</limit>
</busconfig>
This diff is collapsed.
/*
* shvar.h
*
* Interface for non-destructively reading/writing files containing
* only shell variable declarations and full-line comments.
*
* Includes explicit inheritance mechanism intended for use with
* Red Hat Linux ifcfg-* files. There is no protection against
* inheritance loops; they will generally cause stack overflows.
* Furthermore, they are only intended for one level of inheritance;
* the value setting algorithm assumes this.
*
* Copyright 1999 Red Hat, Inc.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef _SHVAR_H
#define _SHVAR_H
#include <glib.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _shvarFile shvarFile;
struct _shvarFile {
char *fileName; /* read-only */
int fd; /* read-only */
char *arena; /* ignore */
GList *lineList; /* read-only */
GList *freeList; /* ignore */
GList *current; /* set implicitly or explicitly,
points to element of lineList */
shvarFile *parent; /* set explicitly */
int modified; /* ignore */
};
/* Create the file <name>, return shvarFile on success, NULL on failure */
shvarFile *
svCreateFile(const char *name);
/* Open the file <name>, return shvarFile on success, NULL on failure */
shvarFile *
svNewFile(const char *name);
/* Get the value associated with the key, and leave the current pointer
* pointing at the line containing the value. The char* returned MUST
* be freed by the caller.
*/
char *
svGetValue(shvarFile *s, const char *key);
/* return 1 if <key> resolves to any truth value (e.g. "yes", "y", "true")
* return 0 if <key> resolves to any non-truth value (e.g. "no", "n", "false")
* return <def> otherwise
*/
int
svTrueValue(shvarFile *s, const char *key, int def);
/* Set the variable <key> equal to the value <value>.
* If <key> does not exist, and the <current> pointer is set, append
* the key=value pair after that line. Otherwise, prepend the pair
* to the top of the file.
*/
void
svSetValue(shvarFile *s, const char *key, const char *value);
/* Write the current contents iff modified. Returns -1 on error
* and 0 on success. Do not write if no values have been modified.
* The mode argument is only used if creating the file, not if
* re-writing an existing file, and is passed unchanged to the
* open() syscall.
*/
int
svWriteFile(shvarFile *s, int mode);
/* Close the file descriptor (if open) and delete the shvarFile.
* Returns -1 on error and 0 on success.
*/
int
svCloseFile(shvarFile *s);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ! _SHVAR_H */
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