NetworkManager r3334 - in trunk: . introspection libnm-glib libnm-util src src/vpn-manager system-settings/src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3334 - in trunk: . introspection libnm-glib libnm-util src src/vpn-manager system-settings/src
- Date: Wed, 20 Feb 2008 22:37:39 +0000 (GMT)
Author: dcbw
Date: Wed Feb 20 22:37:39 2008
New Revision: 3334
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3334&view=rev
Log:
2008-02-20 Dan Williams <dcbw redhat com>
* Global rename of NMConnectionSettings -> NMExportedConnection to cut down
on confusing names
* Add 'path' and 'scope' properties to NMConnection since both NM and the
applet were having to hack this in anyway. Remove the 'path' stuff from
NMExportedConnection
* Internally rename NMConnectionType -> NMConnectionScope
* Provide default implementations of the 'get_id' and 'get_settings' methods
of NMExportedConnection
Added:
trunk/introspection/nm-exported-connection.xml
- copied, changed from r3333, /trunk/introspection/nm-settings-connection.xml
Removed:
trunk/introspection/nm-settings-connection.xml
Modified:
trunk/ChangeLog
trunk/introspection/Makefile.am
trunk/libnm-glib/Makefile.am
trunk/libnm-glib/nm-settings.c
trunk/libnm-glib/nm-settings.h
trunk/libnm-util/nm-connection.c
trunk/libnm-util/nm-connection.h
trunk/src/NetworkManagerPolicy.c
trunk/src/nm-manager.c
trunk/src/nm-manager.h
trunk/src/vpn-manager/nm-vpn-manager.c
trunk/system-settings/src/dbus-settings.c
trunk/system-settings/src/dbus-settings.h
Modified: trunk/introspection/Makefile.am
==============================================================================
--- trunk/introspection/Makefile.am (original)
+++ trunk/introspection/Makefile.am Wed Feb 20 22:37:39 2008
@@ -7,7 +7,7 @@
nm-manager.xml \
nm-manager-client.xml \
nm-settings.xml \
- nm-settings-connection.xml \
+ nm-exported-connection.xml \
nm-vpn-manager.xml \
nm-vpn-plugin.xml \
nm-vpn-connection.xml
Copied: trunk/introspection/nm-exported-connection.xml (from r3333, /trunk/introspection/nm-settings-connection.xml)
==============================================================================
--- /trunk/introspection/nm-settings-connection.xml (original)
+++ trunk/introspection/nm-exported-connection.xml Wed Feb 20 22:37:39 2008
@@ -5,12 +5,12 @@
<interface name="org.freedesktop.NetworkManagerSettings.Connection">
<method name="GetID">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_connection_settings_get_id"/>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_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"/>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_get_settings"/>
<arg name="settings" type="a{sa{sv}}" direction="out"/>
</method>
@@ -27,7 +27,7 @@
<interface name="org.freedesktop.NetworkManagerSettings.Connection.Secrets">
<method name="GetSecrets">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_connection_settings_get_secrets"/>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_get_secrets"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="setting_name" type="s" direction="in"/>
<!-- Array of strings of key names in the Setting for which NM thinks
Modified: trunk/libnm-glib/Makefile.am
==============================================================================
--- trunk/libnm-glib/Makefile.am (original)
+++ trunk/libnm-glib/Makefile.am Wed Feb 20 22:37:39 2008
@@ -8,7 +8,7 @@
nm-device-802-11-wireless-bindings.h \
nm-marshal.h \
nm-marshal.c \
- nm-settings-connection-glue.h \
+ nm-exported-connection-glue.h \
nm-settings-glue.h \
nm-vpn-manager-bindings.h \
nm-vpn-connection-bindings.h \
@@ -111,8 +111,8 @@
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
+nm-exported-connection-glue.h: $(top_srcdir)/introspection/nm-exported-connection.xml
+ dbus-binding-tool --prefix=nm_exported_connection --mode=glib-server --output=nm-exported-connection-glue.h $(top_srcdir)/introspection/nm-exported-connection.xml
nm-vpn-manager-bindings.h: $(top_srcdir)/introspection/nm-vpn-manager.xml
dbus-binding-tool --prefix=nm_vpn_manager --mode=glib-client --output=nm-vpn-manager-bindings.h $(top_srcdir)/introspection/nm-vpn-manager.xml
Modified: trunk/libnm-glib/nm-settings.c
==============================================================================
--- trunk/libnm-glib/nm-settings.c (original)
+++ trunk/libnm-glib/nm-settings.c Wed Feb 20 22:37:39 2008
@@ -1,5 +1,6 @@
#include <NetworkManager.h>
#include <nm-utils.h>
+#include <nm-setting-connection.h>
#include "nm-settings.h"
@@ -87,85 +88,111 @@
}
void
-nm_settings_signal_new_connection (NMSettings *settings, NMConnectionSettings *connection)
+nm_settings_signal_new_connection (NMSettings *settings, NMExportedConnection *connection)
{
g_return_if_fail (NM_IS_SETTINGS (settings));
- g_return_if_fail (NM_IS_CONNECTION_SETTINGS (connection));
+ g_return_if_fail (NM_IS_EXPORTED_CONNECTION (connection));
g_signal_emit (settings, settings_signals[S_NEW_CONNECTION], 0, connection);
}
/*
- * NMConnectionSettings implementation
+ * NMExportedConnection implementation
*/
-static gboolean impl_connection_settings_get_id (NMConnectionSettings *connection,
+static gboolean impl_exported_connection_get_id (NMExportedConnection *connection,
gchar **id,
GError **error);
-static gboolean impl_connection_settings_get_settings (NMConnectionSettings *connection,
+static gboolean impl_exported_connection_get_settings (NMExportedConnection *connection,
GHashTable **settings,
GError **error);
-static void impl_connection_settings_get_secrets (NMConnectionSettings *connection,
+static void impl_exported_connection_get_secrets (NMExportedConnection *connection,
const gchar *setting_name,
const gchar **hints,
gboolean request_new,
DBusGMethodInvocation *context);
-#include "nm-settings-connection-glue.h"
+#include "nm-exported-connection-glue.h"
-#define CONNECTION_SETTINGS_CLASS(o) (NM_CONNECTION_SETTINGS_CLASS (G_OBJECT_GET_CLASS (o)))
+#define EXPORTED_CONNECTION_CLASS(o) (NM_EXPORTED_CONNECTION_CLASS (G_OBJECT_GET_CLASS (o)))
-G_DEFINE_TYPE (NMConnectionSettings, nm_connection_settings, G_TYPE_OBJECT)
+G_DEFINE_TYPE (NMExportedConnection, nm_exported_connection, G_TYPE_OBJECT)
enum {
- CS_UPDATED,
- CS_REMOVED,
+ EC_UPDATED,
+ EC_REMOVED,
- CS_LAST_SIGNAL
+ EC_LAST_SIGNAL
};
-static guint connection_signals[CS_LAST_SIGNAL] = { 0 };
+static guint connection_signals[EC_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);
+enum {
+ PROP_0,
+ PROP_CONNECTION,
+
+ LAST_PROP
+};
+
+typedef struct {
+ NMConnection *wrapped;
+} NMExportedConnectionPrivate;
+
+#define NM_EXPORTED_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+ NM_TYPE_EXPORTED_CONNECTION, \
+ NMExportedConnectionPrivate))
- if (!CONNECTION_SETTINGS_CLASS (connection)->get_id) {
- g_set_error (error, NM_SETTINGS_ERROR, 1,
- "%s.%d - Missing implementation for ConnectionSettings::get_id.",
- __FILE__, __LINE__);
- return FALSE;
- }
- *id = CONNECTION_SETTINGS_CLASS (connection)->get_id (connection);
+static gboolean
+impl_exported_connection_get_id (NMExportedConnection *connection,
+ gchar **id,
+ GError **error)
+{
+ NMExportedConnectionPrivate *priv;
+
+ g_return_val_if_fail (NM_IS_EXPORTED_CONNECTION (connection), FALSE);
+
+ priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (connection);
+ if (!EXPORTED_CONNECTION_CLASS (connection)->get_id) {
+ NMSettingConnection *s_con;
+
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (priv->wrapped, NM_TYPE_SETTING_CONNECTION));
+ if (!s_con || !s_con->id) {
+ g_set_error (error, NM_SETTINGS_ERROR, 1,
+ "%s.%d - Invalid connection.",
+ __FILE__, __LINE__);
+ return FALSE;
+ }
+
+ *id = g_strdup (s_con->id);
+ } else {
+ *id = EXPORTED_CONNECTION_CLASS (connection)->get_id (connection);
+ }
return TRUE;
}
static gboolean
-impl_connection_settings_get_settings (NMConnectionSettings *connection,
+impl_exported_connection_get_settings (NMExportedConnection *connection,
GHashTable **settings,
GError **error)
{
- g_return_val_if_fail (NM_IS_CONNECTION_SETTINGS (connection), FALSE);
+ NMExportedConnectionPrivate *priv;
- if (!CONNECTION_SETTINGS_CLASS (connection)->get_settings) {
- g_set_error (error, NM_SETTINGS_ERROR, 1,
- "%s.%d - Missing implementation for ConnectionSettings::get_settings.",
- __FILE__, __LINE__);
- return FALSE;
- }
+ g_return_val_if_fail (NM_IS_EXPORTED_CONNECTION (connection), FALSE);
+
+ priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (connection);
- *settings = CONNECTION_SETTINGS_CLASS (connection)->get_settings (connection);
+ if (!EXPORTED_CONNECTION_CLASS (connection)->get_settings)
+ *settings = nm_connection_to_hash (priv->wrapped);
+ else
+ *settings = EXPORTED_CONNECTION_CLASS (connection)->get_settings (connection);
return TRUE;
}
static void
-impl_connection_settings_get_secrets (NMConnectionSettings *connection,
+impl_exported_connection_get_secrets (NMExportedConnection *connection,
const gchar *setting_name,
const gchar **hints,
gboolean request_new,
@@ -173,7 +200,7 @@
{
GError *error = NULL;
- if (!NM_IS_CONNECTION_SETTINGS (connection)) {
+ if (!NM_IS_EXPORTED_CONNECTION (connection)) {
g_set_error (&error, NM_SETTINGS_ERROR, 1,
"%s.%d - Invalid connection in ConnectionSettings::get_secrets.",
__FILE__, __LINE__);
@@ -182,7 +209,7 @@
return;
}
- if (!CONNECTION_SETTINGS_CLASS (connection)->get_secrets) {
+ if (!EXPORTED_CONNECTION_CLASS (connection)->get_secrets) {
g_set_error (&error, NM_SETTINGS_ERROR, 1,
"%s.%d - Missing implementation for ConnectionSettings::get_secrets.",
__FILE__, __LINE__);
@@ -191,109 +218,161 @@
return;
}
- CONNECTION_SETTINGS_CLASS (connection)->get_secrets (connection, setting_name, hints, request_new, context);
+ EXPORTED_CONNECTION_CLASS (connection)->get_secrets (connection, setting_name, hints, request_new, context);
}
static void
-nm_connection_settings_init (NMConnectionSettings *connection)
+nm_exported_connection_init (NMExportedConnection *connection)
{
- static guint32 cs_counter = 0;
-
- connection->dbus_path = g_strdup_printf ("%s/%u",
- NM_DBUS_PATH_SETTINGS,
- cs_counter++);
}
static void
-nm_connection_settings_dispose (GObject *object)
+set_property (GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
{
- NMConnectionSettings * self = NM_CONNECTION_SETTINGS (object);
+ NMExportedConnectionPrivate *priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (object);
- if (self->dbus_path) {
- g_free (self->dbus_path);
- self->dbus_path = NULL;
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ if (priv->wrapped)
+ g_object_unref (priv->wrapped);
+ priv->wrapped = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
+}
+
+static void
+get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ NMExportedConnection *exported = NM_EXPORTED_CONNECTION (object);
- G_OBJECT_CLASS (nm_connection_settings_parent_class)->dispose (object);
+ switch (prop_id) {
+ case PROP_CONNECTION:
+ g_value_set_object (value, nm_exported_connection_get_connection (exported));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-nm_connection_settings_finalize (GObject *object)
+nm_exported_connection_dispose (GObject *object)
{
- G_OBJECT_CLASS (nm_connection_settings_parent_class)->finalize (object);
+ NMExportedConnectionPrivate *priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (object);
+
+ if (priv->wrapped) {
+ g_object_unref (priv->wrapped);
+ priv->wrapped = NULL;
+ }
+
+ G_OBJECT_CLASS (nm_exported_connection_parent_class)->dispose (object);
}
#define DBUS_TYPE_G_STRING_VARIANT_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
#define DBUS_TYPE_G_DICT_OF_DICTS (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE))
static void
-nm_connection_settings_class_init (NMConnectionSettingsClass *connection_settings_class)
+nm_exported_connection_class_init (NMExportedConnectionClass *exported_connection_class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (connection_settings_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (exported_connection_class);
- /* virtual methods */
- object_class->finalize = nm_connection_settings_finalize;
- object_class->dispose = nm_connection_settings_dispose;
+ g_type_class_add_private (object_class, sizeof (NMExportedConnectionPrivate));
- connection_settings_class->get_id = NULL;
- connection_settings_class->get_settings = NULL;
- connection_settings_class->get_secrets = NULL;
+ /* virtual methods */
+ object_class->set_property = set_property;
+ object_class->get_property = get_property;
+ object_class->dispose = nm_exported_connection_dispose;
+
+ exported_connection_class->get_id = NULL;
+ exported_connection_class->get_settings = NULL;
+ exported_connection_class->get_secrets = NULL;
+
+ /* Properties */
+ g_object_class_install_property
+ (object_class, PROP_CONNECTION,
+ g_param_spec_object (NM_EXPORTED_CONNECTION_CONNECTION,
+ "Connection",
+ "Wrapped connection",
+ NM_TYPE_CONNECTION,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/* signals */
- connection_signals[CS_UPDATED] =
+ connection_signals[EC_UPDATED] =
g_signal_new ("updated",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMConnectionSettingsClass, updated),
+ G_STRUCT_OFFSET (NMExportedConnectionClass, updated),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
DBUS_TYPE_G_DICT_OF_DICTS);
- connection_signals[CS_REMOVED] =
+
+ connection_signals[EC_REMOVED] =
g_signal_new ("removed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMConnectionSettingsClass, removed),
+ G_STRUCT_OFFSET (NMExportedConnectionClass, 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);
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (exported_connection_class),
+ &dbus_glib_nm_exported_connection_object_info);
+}
+
+NMConnection *
+nm_exported_connection_get_connection (NMExportedConnection *connection)
+{
+ g_return_val_if_fail (NM_IS_EXPORTED_CONNECTION (connection), NULL);
+
+ return NM_EXPORTED_CONNECTION_GET_PRIVATE (connection)->wrapped;
}
void
-nm_connection_settings_register_object (NMConnectionSettings *connection,
+nm_exported_connection_register_object (NMExportedConnection *connection,
+ NMConnectionScope scope,
DBusGConnection *dbus_connection)
{
- g_return_if_fail (NM_IS_CONNECTION_SETTINGS (connection));
+ NMExportedConnectionPrivate *priv;
+ static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+ static guint32 ec_counter = 0;
+ char *path;
+
+ g_return_if_fail (NM_IS_EXPORTED_CONNECTION (connection));
g_return_if_fail (dbus_connection != NULL);
+ priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (connection);
+
+ g_static_mutex_lock (&mutex);
+ path = g_strdup_printf ("%s/%u", NM_DBUS_PATH_SETTINGS, ec_counter++);
+ g_static_mutex_unlock (&mutex);
+
+ nm_connection_set_path (priv->wrapped, path);
+ nm_connection_set_scope (priv->wrapped, scope);
+
dbus_g_connection_register_g_object (dbus_connection,
- connection->dbus_path,
+ path,
G_OBJECT (connection));
+ g_free (path);
}
-const char *
-nm_connection_settings_get_dbus_object_path (NMConnectionSettings *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION_SETTINGS (connection), NULL);
-
- return connection->dbus_path;
-}
-
void
-nm_connection_settings_signal_updated (NMConnectionSettings *connection, GHashTable *settings)
+nm_exported_connection_signal_updated (NMExportedConnection *connection, GHashTable *settings)
{
- g_return_if_fail (NM_IS_CONNECTION_SETTINGS (connection));
+ g_return_if_fail (NM_IS_EXPORTED_CONNECTION (connection));
- g_signal_emit (connection, connection_signals[CS_UPDATED], 0, settings);
+ g_signal_emit (connection, connection_signals[EC_UPDATED], 0, settings);
}
void
-nm_connection_settings_signal_removed (NMConnectionSettings *connection)
+nm_exported_connection_signal_removed (NMExportedConnection *connection)
{
- g_return_if_fail (NM_IS_CONNECTION_SETTINGS (connection));
+ g_return_if_fail (NM_IS_EXPORTED_CONNECTION (connection));
- g_signal_emit (connection, connection_signals[CS_REMOVED], 0);
+ g_signal_emit (connection, connection_signals[EC_REMOVED], 0);
}
Modified: trunk/libnm-glib/nm-settings.h
==============================================================================
--- trunk/libnm-glib/nm-settings.h (original)
+++ trunk/libnm-glib/nm-settings.h Wed Feb 20 22:37:39 2008
@@ -1,6 +1,6 @@
-#ifndef NM_SETTINGS_H
-#define NM_SETTINGS_H 1
+#ifndef __NM_SETTINGS_H__
+#define __NM_SETTINGS_H__
#include <glib-object.h>
#include <dbus/dbus-glib.h>
@@ -10,46 +10,48 @@
#define NM_SETTINGS_ERROR nm_settings_error_quark ()
GQuark nm_settings_error_quark (void);
-#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))
+#define NM_TYPE_EXPORTED_CONNECTION (nm_exported_connection_get_type ())
+#define NM_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnection))
+#define NM_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnectionClass))
+#define NM_IS_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_EXPORTED_CONNECTION))
+#define NM_IS_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_EXPORTED_CONNECTION))
+#define NM_EXPORTED_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnectionClass))
+
+#define NM_EXPORTED_CONNECTION_CONNECTION "connection"
typedef struct {
GObject parent;
-
- /* private */
- char * dbus_path;
-} NMConnectionSettings;
+} NMExportedConnection;
typedef struct {
GObjectClass parent_class;
/* virtual methods */
- gchar * (* get_id) (NMConnectionSettings *connection);
- GHashTable * (* get_settings) (NMConnectionSettings *connection);
- void (* get_secrets) (NMConnectionSettings *connection,
+ gchar * (* get_id) (NMExportedConnection *connection);
+ GHashTable * (* get_settings) (NMExportedConnection *connection);
+ void (* get_secrets) (NMExportedConnection *connection,
const gchar *setting_name,
const gchar **hints,
gboolean request_new,
DBusGMethodInvocation *context);
/* signals */
- void (* updated) (NMConnectionSettings *connection, GHashTable *settings);
- void (* removed) (NMConnectionSettings *connection);
-} NMConnectionSettingsClass;
-
-GType nm_connection_settings_get_type (void);
-void
-nm_connection_settings_register_object (NMConnectionSettings *connection,
- DBusGConnection *dbus_connection);
-const char *nm_connection_settings_get_dbus_object_path (NMConnectionSettings *connection);
+ void (* updated) (NMExportedConnection *connection, GHashTable *settings);
+ void (* removed) (NMExportedConnection *connection);
+} NMExportedConnectionClass;
+
+GType nm_exported_connection_get_type (void);
+
+void nm_exported_connection_register_object (NMExportedConnection *connection,
+ NMConnectionScope scope,
+ DBusGConnection *dbus_connection);
+
+NMConnection *nm_exported_connection_get_connection (NMExportedConnection *connection);
+
+void nm_exported_connection_signal_updated (NMExportedConnection *connection, GHashTable *settings);
+void nm_exported_connection_signal_removed (NMExportedConnection *connection);
-void nm_connection_settings_signal_updated (NMConnectionSettings *connection, GHashTable *settings);
-void nm_connection_settings_signal_removed (NMConnectionSettings *connection);
#define NM_TYPE_SETTINGS (nm_settings_get_type ())
#define NM_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS, NMSettings))
@@ -69,12 +71,12 @@
GPtrArray * (* list_connections) (NMSettings *settings);
/* signals */
- void (* new_connection) (NMSettings *settings, NMConnectionSettings *connection);
+ void (* new_connection) (NMSettings *settings, NMExportedConnection *connection);
} NMSettingsClass;
GType nm_settings_get_type (void);
-void nm_settings_signal_new_connection (NMSettings *settings, NMConnectionSettings *connection);
+void nm_settings_signal_new_connection (NMSettings *settings, NMExportedConnection *connection);
G_END_DECLS
Modified: trunk/libnm-util/nm-connection.c
==============================================================================
--- trunk/libnm-util/nm-connection.c (original)
+++ trunk/libnm-util/nm-connection.c Wed Feb 20 22:37:39 2008
@@ -21,6 +21,12 @@
typedef struct {
GHashTable *settings;
+
+ /* Type of the connection (system or user) */
+ NMConnectionScope scope;
+
+ /* D-Bus path of the connection, if any */
+ char *path;
} NMConnectionPrivate;
#define NM_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CONNECTION, NMConnectionPrivate))
@@ -28,6 +34,14 @@
G_DEFINE_TYPE (NMConnection, nm_connection, G_TYPE_OBJECT)
enum {
+ PROP_0,
+ PROP_SCOPE,
+ PROP_PATH,
+
+ LAST_PROP
+};
+
+enum {
SECRETS_UPDATED,
LAST_SIGNAL
@@ -471,6 +485,48 @@
g_hash_table_foreach (NM_CONNECTION_GET_PRIVATE (connection)->settings, dump_setting, NULL);
}
+void
+nm_connection_set_scope (NMConnection *connection, NMConnectionScope scope)
+{
+ g_return_if_fail (NM_IS_CONNECTION (connection));
+
+ NM_CONNECTION_GET_PRIVATE (connection)->scope = scope;
+}
+
+NMConnectionScope
+nm_connection_get_scope (NMConnection *connection)
+{
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_CONNECTION_SCOPE_UNKNOWN);
+
+ return NM_CONNECTION_GET_PRIVATE (connection)->scope;
+}
+
+void
+nm_connection_set_path (NMConnection *connection, const char *path)
+{
+ NMConnectionPrivate *priv;
+
+ g_return_if_fail (NM_IS_CONNECTION (connection));
+
+ priv = NM_CONNECTION_GET_PRIVATE (connection);
+
+ if (priv->path) {
+ g_free (priv->path);
+ priv->path = NULL;
+ }
+
+ if (path)
+ priv->path = g_strdup (path);
+}
+
+const char *
+nm_connection_get_path (NMConnection *connection)
+{
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
+
+ return NM_CONNECTION_GET_PRIVATE (connection)->path;
+}
+
NMConnection *
nm_connection_new (void)
{
@@ -522,10 +578,51 @@
g_hash_table_destroy (priv->settings);
priv->settings = NULL;
+ g_free (priv->path);
+ priv->path = NULL;
+
G_OBJECT_CLASS (nm_connection_parent_class)->finalize (object);
}
static void
+set_property (GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ NMConnection *connection = NM_CONNECTION (object);
+
+ switch (prop_id) {
+ case PROP_SCOPE:
+ nm_connection_set_scope (connection, g_value_get_uint (value));
+ break;
+ case PROP_PATH:
+ nm_connection_set_path (connection, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ NMConnection *connection = NM_CONNECTION (object);
+
+ switch (prop_id) {
+ case PROP_SCOPE:
+ g_value_set_uint (value, nm_connection_get_scope (connection));
+ break;
+ case PROP_PATH:
+ g_value_set_string (value, nm_connection_get_path (connection));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
nm_connection_class_init (NMConnectionClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -533,8 +630,29 @@
g_type_class_add_private (klass, sizeof (NMConnectionPrivate));
/* virtual methods */
+ object_class->set_property = set_property;
+ object_class->get_property = get_property;
object_class->finalize = finalize;
+ /* Properties */
+ g_object_class_install_property
+ (object_class, PROP_SCOPE,
+ g_param_spec_uint (NM_CONNECTION_SCOPE,
+ "Scope",
+ "Scope",
+ NM_CONNECTION_SCOPE_UNKNOWN,
+ NM_CONNECTION_SCOPE_USER,
+ NM_CONNECTION_SCOPE_UNKNOWN,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (object_class, PROP_PATH,
+ g_param_spec_string (NM_CONNECTION_PATH,
+ "Path",
+ "Path",
+ NULL,
+ G_PARAM_READWRITE));
+
/* Signals */
signals[SECRETS_UPDATED] =
g_signal_new ("secrets-updated",
Modified: trunk/libnm-util/nm-connection.h
==============================================================================
--- trunk/libnm-util/nm-connection.h (original)
+++ trunk/libnm-util/nm-connection.h Wed Feb 20 22:37:39 2008
@@ -16,6 +16,15 @@
#define NM_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_CONNECTION))
#define NM_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CONNECTION, NMConnectionClass))
+typedef enum {
+ NM_CONNECTION_SCOPE_UNKNOWN = 0,
+ NM_CONNECTION_SCOPE_SYSTEM,
+ NM_CONNECTION_SCOPE_USER,
+} NMConnectionScope;
+
+#define NM_CONNECTION_SCOPE "scope"
+#define NM_CONNECTION_PATH "path"
+
typedef struct {
GObject parent;
} NMConnection;
@@ -57,6 +66,16 @@
const char *setting_name,
GHashTable *secrets);
+void nm_connection_set_scope (NMConnection *connection,
+ NMConnectionScope scope);
+
+NMConnectionScope nm_connection_get_scope (NMConnection *connection);
+
+void nm_connection_set_path (NMConnection *connection,
+ const char *path);
+
+const char * nm_connection_get_path (NMConnection *connection);
+
void nm_connection_for_each_setting_value (NMConnection *connection,
NMSettingValueIterFn func,
gpointer user_data);
Modified: trunk/src/NetworkManagerPolicy.c
==============================================================================
--- trunk/src/NetworkManagerPolicy.c (original)
+++ trunk/src/NetworkManagerPolicy.c Wed Feb 20 22:37:39 2008
@@ -97,8 +97,8 @@
return NULL;
/* System connections first, then user connections */
- connections = nm_manager_get_connections (policy->manager, NM_CONNECTION_TYPE_SYSTEM);
- connections = g_slist_concat (connections, nm_manager_get_connections (policy->manager, NM_CONNECTION_TYPE_USER));
+ connections = nm_manager_get_connections (policy->manager, NM_CONNECTION_SCOPE_SYSTEM);
+ connections = g_slist_concat (connections, nm_manager_get_connections (policy->manager, NM_CONNECTION_SCOPE_USER));
/* Remove connections that are in the invalid list. */
elt = connections;
@@ -321,12 +321,12 @@
* don't switch.
*/
if ( old_connection
- && (nm_manager_get_connection_type (old_connection) == NM_CONNECTION_TYPE_SYSTEM)
- && (nm_manager_get_connection_type (connection) == NM_CONNECTION_TYPE_USER))
+ && (nm_manager_get_connection_scope (old_connection) == NM_CONNECTION_SCOPE_SYSTEM)
+ && (nm_manager_get_connection_scope (connection) == NM_CONNECTION_SCOPE_USER))
goto out;
- if ( (nm_manager_get_connection_type (connection) == NM_CONNECTION_TYPE_SYSTEM)
- && (nm_manager_get_connection_type (old_connection) == NM_CONNECTION_TYPE_USER)) {
+ if ( (nm_manager_get_connection_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM)
+ && (nm_manager_get_connection_scope (old_connection) == NM_CONNECTION_SCOPE_USER)) {
do_switch = TRUE;
nm_info ("SWITCH: found system connection '%s (%s)', overrides"
" current connection '%s (%s)'.",
@@ -524,7 +524,7 @@
static void
connections_added (NMManager *manager,
- NMConnectionType connection_type,
+ NMConnectionScope scope,
gpointer user_data)
{
NMPolicy *policy = (NMPolicy *) user_data;
@@ -535,7 +535,7 @@
static void
connection_added (NMManager *manager,
NMConnection *connection,
- NMConnectionType connection_type,
+ NMConnectionScope scope,
gpointer user_data)
{
NMPolicy *policy = (NMPolicy *) user_data;
@@ -546,7 +546,7 @@
static void
connection_updated (NMManager *manager,
NMConnection *connection,
- NMConnectionType connection_type,
+ NMConnectionScope scope,
gpointer user_data)
{
NMPolicy *policy = (NMPolicy *) user_data;
@@ -560,7 +560,7 @@
static void
connection_removed (NMManager *manager,
NMConnection *connection,
- NMConnectionType connection_type,
+ NMConnectionScope scope,
gpointer user_data)
{
NMPolicy *policy = (NMPolicy *) user_data;
Modified: trunk/src/nm-manager.c
==============================================================================
--- trunk/src/nm-manager.c (original)
+++ trunk/src/nm-manager.c Wed Feb 20 22:37:39 2008
@@ -41,19 +41,19 @@
#include "nm-manager-glue.h"
-static void nm_manager_connections_destroy (NMManager *manager, NMConnectionType type);
+static void nm_manager_connections_destroy (NMManager *manager, NMConnectionScope scope);
static void manager_set_wireless_enabled (NMManager *manager, gboolean enabled);
static void connection_added_default_handler (NMManager *manager,
NMConnection *connection,
- NMConnectionType connection_type);
+ NMConnectionScope scope);
#define SSD_POKE_INTERVAL 120000
typedef struct {
DBusGMethodInvocation *context;
NMDevice *device;
- NMConnectionType connection_type;
+ NMConnectionScope scope;
char *connection_path;
char *specific_object_path;
guint timeout_id;
@@ -249,11 +249,11 @@
while (g_slist_length (priv->devices))
nm_manager_remove_device (manager, NM_DEVICE (priv->devices->data), TRUE);
- nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_USER);
+ nm_manager_connections_destroy (manager, NM_CONNECTION_SCOPE_USER);
g_hash_table_destroy (priv->user_connections);
priv->user_connections = NULL;
- nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_SYSTEM);
+ nm_manager_connections_destroy (manager, NM_CONNECTION_SCOPE_SYSTEM);
g_hash_table_destroy (priv->system_connections);
priv->system_connections = NULL;
@@ -431,17 +431,17 @@
#define DBUS_TYPE_G_STRING_VARIANT_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
#define DBUS_TYPE_G_DICT_OF_DICTS (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE))
-static NMConnectionType
+static NMConnectionScope
get_type_for_proxy (DBusGProxy *proxy)
{
const char *bus_name = dbus_g_proxy_get_bus_name (proxy);
if (strcmp (bus_name, NM_DBUS_SERVICE_USER_SETTINGS) == 0)
- return NM_CONNECTION_TYPE_USER;
+ return NM_CONNECTION_SCOPE_USER;
else if (strcmp (bus_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS) == 0)
- return NM_CONNECTION_TYPE_SYSTEM;
+ return NM_CONNECTION_SCOPE_SYSTEM;
- return NM_CONNECTION_TYPE_UNKNOWN;
+ return NM_CONNECTION_SCOPE_UNKNOWN;
}
typedef struct GetSettingsInfo {
@@ -493,7 +493,7 @@
GError *err = NULL;
GHashTable *settings = NULL;
NMConnection *connection;
- NMConnectionType type;
+ NMConnectionScope scope;
NMManager *manager;
g_return_if_fail (info != NULL);
@@ -527,14 +527,14 @@
(GDestroyNotify) g_object_unref);
priv = NM_MANAGER_GET_PRIVATE (manager);
- type = get_type_for_proxy (proxy);
- switch (type) {
- case NM_CONNECTION_TYPE_USER:
+ scope = get_type_for_proxy (proxy);
+ switch (scope) {
+ case NM_CONNECTION_SCOPE_USER:
g_hash_table_insert (priv->user_connections,
g_strdup (path),
connection);
break;
- case NM_CONNECTION_TYPE_SYSTEM:
+ case NM_CONNECTION_SCOPE_SYSTEM:
g_hash_table_insert (priv->system_connections,
g_strdup (path),
connection);
@@ -547,13 +547,13 @@
g_object_set_data (G_OBJECT (connection),
NM_MANAGER_CONNECTION_TYPE_TAG,
- GUINT_TO_POINTER (type));
+ GUINT_TO_POINTER (scope));
/* If the connection-added signal is supposed to be batched, don't
* emit the single connection-added here.
*/
if (!info->calls)
- g_signal_emit (manager, signals[CONNECTION_ADDED], 0, connection, type);
+ g_signal_emit (manager, signals[CONNECTION_ADDED], 0, connection, scope);
} else {
// FIXME: merge settings? or just replace?
nm_warning ("%s (#%d): implement merge settings", __func__, __LINE__);
@@ -580,11 +580,11 @@
*out_path = path;
switch (get_type_for_proxy (proxy)) {
- case NM_CONNECTION_TYPE_USER:
+ case NM_CONNECTION_SCOPE_USER:
*out_hash = priv->user_connections;
connection = g_hash_table_lookup (priv->user_connections, path);
break;
- case NM_CONNECTION_TYPE_SYSTEM:
+ case NM_CONNECTION_SCOPE_SYSTEM:
*out_hash = priv->system_connections;
connection = g_hash_table_lookup (priv->system_connections, path);
break;
@@ -602,7 +602,7 @@
GHashTable *hash,
const char *path)
{
- NMConnectionType type;
+ NMConnectionScope scope;
/* Destroys the connection, then associated DBusGProxy due to the
* weak reference notify function placed on the connection when it
@@ -610,8 +610,8 @@
*/
g_object_ref (connection);
g_hash_table_remove (hash, path);
- type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
- g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, type);
+ scope = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
+ g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, scope);
g_object_unref (connection);
}
@@ -652,11 +652,11 @@
valid = nm_connection_replace_settings (old_connection, settings);
if (valid) {
- NMConnectionType type;
+ NMConnectionScope scope;
- type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (old_connection),
+ scope = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (old_connection),
NM_MANAGER_CONNECTION_TYPE_TAG));
- g_signal_emit (manager, signals[CONNECTION_UPDATED], 0, old_connection, type);
+ g_signal_emit (manager, signals[CONNECTION_UPDATED], 0, old_connection, scope);
} else {
remove_connection (manager, old_connection, hash, path);
}
@@ -771,7 +771,7 @@
static void
query_connections (NMManager *manager,
- NMConnectionType type)
+ NMConnectionScope scope)
{
NMManagerPrivate *priv;
DBusGProxyCall *call;
@@ -781,14 +781,14 @@
g_return_if_fail (NM_IS_MANAGER (manager));
priv = NM_MANAGER_GET_PRIVATE (manager);
- if (type == NM_CONNECTION_TYPE_USER) {
+ if (scope == NM_CONNECTION_SCOPE_USER) {
proxy = &priv->user_proxy;
service = NM_DBUS_SERVICE_USER_SETTINGS;
- } else if (type == NM_CONNECTION_TYPE_SYSTEM) {
+ } else if (scope == NM_CONNECTION_SCOPE_SYSTEM) {
proxy = &priv->system_proxy;
service = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
} else {
- nm_warning ("Unknown NMConnectionType %d", type);
+ nm_warning ("Unknown NMConnectionScope %d", scope);
return;
}
@@ -839,10 +839,10 @@
if (strcmp (name, NM_DBUS_SERVICE_USER_SETTINGS) == 0) {
if (!old_owner_good && new_owner_good) {
/* User Settings service appeared, update stuff */
- query_connections (manager, NM_CONNECTION_TYPE_USER);
+ query_connections (manager, NM_CONNECTION_SCOPE_USER);
} else {
/* User Settings service disappeared, throw them away (?) */
- nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_USER);
+ nm_manager_connections_destroy (manager, NM_CONNECTION_SCOPE_USER);
}
} else if (strcmp (name, NM_DBUS_SERVICE_SYSTEM_SETTINGS) == 0) {
if (!old_owner_good && new_owner_good) {
@@ -852,10 +852,10 @@
}
/* System Settings service appeared, update stuff */
- query_connections (manager, NM_CONNECTION_TYPE_SYSTEM);
+ query_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
} else {
/* System Settings service disappeared, throw them away (?) */
- nm_manager_connections_destroy (manager, NM_CONNECTION_TYPE_SYSTEM);
+ nm_manager_connections_destroy (manager, NM_CONNECTION_SCOPE_SYSTEM);
if (priv->poke_id)
g_source_remove (priv->poke_id);
@@ -905,7 +905,7 @@
if (nm_dbus_manager_name_has_owner (nm_dbus_manager_get (),
NM_DBUS_SERVICE_SYSTEM_SETTINGS)) {
- query_connections (manager, NM_CONNECTION_TYPE_SYSTEM);
+ query_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
} else {
/* Try to activate the system settings daemon */
priv->poke_id = g_idle_add (poke_system_settings_daemon_cb, (gpointer) manager);
@@ -913,7 +913,7 @@
if (nm_dbus_manager_name_has_owner (nm_dbus_manager_get (),
NM_DBUS_SERVICE_USER_SETTINGS))
- query_connections (manager, NM_CONNECTION_TYPE_USER);
+ query_connections (manager, NM_CONNECTION_SCOPE_USER);
return FALSE;
}
@@ -947,19 +947,19 @@
{
NMManager *manager = NM_MANAGER (user_data);
NMConnection *connection = NM_CONNECTION (value);
- NMConnectionType type;
+ NMConnectionScope scope;
- type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
- g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, type);
+ scope = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
+ g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, scope);
}
static void
nm_manager_connections_destroy (NMManager *manager,
- NMConnectionType type)
+ NMConnectionScope scope)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
- if (type == NM_CONNECTION_TYPE_USER) {
+ if (scope == NM_CONNECTION_SCOPE_USER) {
if (priv->user_connections) {
g_hash_table_foreach (priv->user_connections, emit_removed, manager);
g_hash_table_remove_all (priv->user_connections);
@@ -969,7 +969,7 @@
g_object_unref (priv->user_proxy);
priv->user_proxy = NULL;
}
- } else if (type == NM_CONNECTION_TYPE_SYSTEM) {
+ } else if (scope == NM_CONNECTION_SCOPE_SYSTEM) {
if (priv->system_connections) {
g_hash_table_foreach (priv->system_connections, emit_removed, manager);
g_hash_table_remove_all (priv->system_connections);
@@ -980,7 +980,7 @@
priv->system_proxy = NULL;
}
} else {
- nm_warning ("Unknown NMConnectionType %d", type);
+ nm_warning ("Unknown NMConnectionScope %d", scope);
}
}
@@ -1051,8 +1051,8 @@
/* Look for this AP's BSSID in the seen-bssids list of a connection,
* and if a match is found, copy over the SSID */
- connections = nm_manager_get_connections (manager, NM_CONNECTION_TYPE_SYSTEM);
- connections = g_slist_concat (connections, nm_manager_get_connections (manager, NM_CONNECTION_TYPE_USER));
+ connections = nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
+ connections = g_slist_concat (connections, nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_USER));
for (iter = connections; iter && !done; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
@@ -1234,7 +1234,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_return_val_if_fail (s_con != NULL, FALSE);
- system_connections = nm_manager_get_connections (manager, NM_CONNECTION_TYPE_SYSTEM);
+ system_connections = nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
for (iter = system_connections; iter; iter = g_slist_next (iter)) {
NMConnection *system_connection = NM_CONNECTION (iter->data);
@@ -1357,7 +1357,7 @@
static void
connection_added_default_handler (NMManager *manager,
NMConnection *connection,
- NMConnectionType connection_type)
+ NMConnectionScope scope)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
PendingConnectionInfo *info = priv->pending_connection_info;
@@ -1368,7 +1368,7 @@
if (!info)
return;
- if (connection_type != info->connection_type)
+ if (scope != info->scope)
return;
path = nm_manager_get_connection_dbus_path (manager, connection);
@@ -1410,7 +1410,7 @@
DBusGMethodInvocation *context)
{
NMDevice *device;
- NMConnectionType connection_type;
+ NMConnectionScope scope;
NMConnection *connection;
GError *error = NULL;
char *real_sop = NULL;
@@ -1426,9 +1426,9 @@
nm_info ("User request for activation of %s.", nm_device_get_iface (device));
if (!strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS))
- connection_type = NM_CONNECTION_TYPE_USER;
+ scope = NM_CONNECTION_SCOPE_USER;
else if (!strcmp (service_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS))
- connection_type = NM_CONNECTION_TYPE_SYSTEM;
+ scope = NM_CONNECTION_SCOPE_SYSTEM;
else {
g_set_error (&error,
NM_MANAGER_ERROR, NM_MANAGER_ERROR_INVALID_SERVICE,
@@ -1440,7 +1440,7 @@
if (specific_object_path && strcmp (specific_object_path, "/"))
real_sop = g_strdup (specific_object_path);
- connection = nm_manager_get_connection_by_object_path (manager, connection_type, connection_path);
+ connection = nm_manager_get_connection_by_object_path (manager, scope, connection_path);
if (connection) {
gboolean success;
@@ -1471,7 +1471,7 @@
info = g_slice_new0 (PendingConnectionInfo);
info->context = context;
info->device = g_object_ref (device);
- info->connection_type = connection_type;
+ info->scope = scope;
info->connection_path = g_strdup (connection_path);
info->specific_object_path = g_strdup (real_sop);
info->timeout_id = g_timeout_add (5000, wait_for_connection_expired, manager);
@@ -1513,11 +1513,11 @@
type_ptr = g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG);
g_return_val_if_fail (type_ptr != NULL, NULL);
- switch ((NMConnectionType) GPOINTER_TO_UINT (type_ptr)) {
- case NM_CONNECTION_TYPE_USER:
+ switch ((NMConnectionScope) GPOINTER_TO_UINT (type_ptr)) {
+ case NM_CONNECTION_SCOPE_USER:
service_name = NM_DBUS_SERVICE_USER_SETTINGS;
break;
- case NM_CONNECTION_TYPE_SYSTEM:
+ case NM_CONNECTION_SCOPE_SYSTEM:
service_name = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
break;
default:
@@ -1755,7 +1755,7 @@
*/
GSList *
nm_manager_get_connections (NMManager *manager,
- NMConnectionType type)
+ NMConnectionScope scope)
{
NMManagerPrivate *priv;
GSList *list = NULL;
@@ -1763,18 +1763,18 @@
g_return_val_if_fail (NM_IS_MANAGER (manager), NULL);
priv = NM_MANAGER_GET_PRIVATE (manager);
- if (type == NM_CONNECTION_TYPE_USER)
+ if (scope == NM_CONNECTION_SCOPE_USER)
g_hash_table_foreach (priv->user_connections, connections_to_slist, &list);
- else if (type == NM_CONNECTION_TYPE_SYSTEM)
+ else if (scope == NM_CONNECTION_SCOPE_SYSTEM)
g_hash_table_foreach (priv->system_connections, connections_to_slist, &list);
else
- nm_warning ("Unknown NMConnectionType %d", type);
+ nm_warning ("Unknown NMConnectionScope %d", scope);
return list;
}
NMConnection *
nm_manager_get_connection_by_object_path (NMManager *manager,
- NMConnectionType type,
+ NMConnectionScope scope,
const char *path)
{
NMManagerPrivate *priv;
@@ -1784,12 +1784,12 @@
g_return_val_if_fail (path != NULL, NULL);
priv = NM_MANAGER_GET_PRIVATE (manager);
- if (type == NM_CONNECTION_TYPE_USER)
+ if (scope == NM_CONNECTION_SCOPE_USER)
connection = (NMConnection *) g_hash_table_lookup (priv->user_connections, path);
- else if (type == NM_CONNECTION_TYPE_SYSTEM)
+ else if (scope == NM_CONNECTION_SCOPE_SYSTEM)
connection = (NMConnection *) g_hash_table_lookup (priv->system_connections, path);
else
- nm_warning ("Unknown NMConnectionType %d", type);
+ nm_warning ("Unknown NMConnectionScope %d", scope);
return connection;
}
Modified: trunk/src/nm-manager.h
==============================================================================
--- trunk/src/nm-manager.h (original)
+++ trunk/src/nm-manager.h Wed Feb 20 22:37:39 2008
@@ -22,12 +22,6 @@
#define NM_MANAGER_CONNECTION_TYPE_TAG "service-type"
#define NM_MANAGER_CONNECTION_SECRETS_PROXY_TAG "dbus-secrets-proxy"
-typedef enum {
- NM_CONNECTION_TYPE_UNKNOWN = 0,
- NM_CONNECTION_TYPE_SYSTEM,
- NM_CONNECTION_TYPE_USER,
-} NMConnectionType;
-
typedef struct {
GObject parent;
} NMManager;
@@ -41,19 +35,19 @@
void (*state_change) (NMManager *manager, guint state);
void (*properties_changed) (NMManager *manager, GHashTable *properties);
- void (*connections_added) (NMManager *manager, NMConnectionType type);
+ void (*connections_added) (NMManager *manager, NMConnectionScope scope);
void (*connection_added) (NMManager *manager,
NMConnection *connection,
- NMConnectionType connection_type);
+ NMConnectionScope scope);
void (*connection_updated) (NMManager *manager,
NMConnection *connection,
- NMConnectionType connection_type);
+ NMConnectionScope scope);
void (*connection_removed) (NMManager *manager,
NMConnection *connection,
- NMConnectionType connection_type);
+ NMConnectionScope scope);
} NMManagerClass;
GType nm_manager_get_type (void);
@@ -90,23 +84,23 @@
/* Connections */
-GSList *nm_manager_get_connections (NMManager *manager, NMConnectionType type);
+GSList *nm_manager_get_connections (NMManager *manager, NMConnectionScope scope);
NMConnection * nm_manager_get_connection_by_object_path (NMManager *manager,
- NMConnectionType type,
+ NMConnectionScope scope,
const char *path);
-static inline NMConnectionType
-nm_manager_get_connection_type (NMConnection *connection)
+static inline NMConnectionScope
+nm_manager_get_connection_scope (NMConnection *connection)
{
- NMConnectionType type;
+ NMConnectionScope scope;
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_CONNECTION_TYPE_UNKNOWN);
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_CONNECTION_SCOPE_UNKNOWN);
- type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
- if (type != NM_CONNECTION_TYPE_USER && type != NM_CONNECTION_TYPE_SYSTEM)
- type = NM_CONNECTION_TYPE_UNKNOWN;
- return type;
+ scope = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
+ if (scope != NM_CONNECTION_SCOPE_USER && scope != NM_CONNECTION_SCOPE_SYSTEM)
+ scope = NM_CONNECTION_SCOPE_UNKNOWN;
+ return scope;
}
#endif /* NM_MANAGER_H */
Modified: trunk/src/vpn-manager/nm-vpn-manager.c
==============================================================================
--- trunk/src/vpn-manager/nm-vpn-manager.c (original)
+++ trunk/src/vpn-manager/nm-vpn-manager.c Wed Feb 20 22:37:39 2008
@@ -145,11 +145,11 @@
if (!strcmp (connection_type, NM_DBUS_SERVICE_USER_SETTINGS))
connection = nm_manager_get_connection_by_object_path (NM_VPN_MANAGER_GET_PRIVATE (manager)->nm_manager,
- NM_CONNECTION_TYPE_USER,
+ NM_CONNECTION_SCOPE_USER,
connection_path);
else if (!strcmp (connection_type, NM_DBUS_SERVICE_SYSTEM_SETTINGS))
connection = nm_manager_get_connection_by_object_path (NM_VPN_MANAGER_GET_PRIVATE (manager)->nm_manager,
- NM_CONNECTION_TYPE_SYSTEM,
+ NM_CONNECTION_SCOPE_SYSTEM,
connection_path);
if (connection == NULL) {
*err = new_vpn_error ("%s.%d: VPN connection could not be found.",
Modified: trunk/system-settings/src/dbus-settings.c
==============================================================================
--- trunk/system-settings/src/dbus-settings.c (original)
+++ trunk/system-settings/src/dbus-settings.c Wed Feb 20 22:37:39 2008
@@ -30,34 +30,17 @@
#include "nm-system-config-interface.h"
#include "nm-utils.h"
-static gchar *connection_settings_get_id (NMConnectionSettings *connection);
-static void connection_settings_get_secrets (NMConnectionSettings *connection,
+static void exported_connection_get_secrets (NMExportedConnection *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);
+G_DEFINE_TYPE (NMSysconfigExportedConnection, nm_sysconfig_exported_connection, NM_TYPE_EXPORTED_CONNECTION);
/*
- * NMSysconfigConnectionSettings
+ * NMSysconfigExportedConnection
*/
-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 GValue *
string_to_gvalue (const char *str)
{
@@ -108,19 +91,21 @@
}
static void
-connection_settings_get_secrets (NMConnectionSettings *sys_connection,
+exported_connection_get_secrets (NMExportedConnection *sys_connection,
const gchar *setting_name,
const gchar **hints,
gboolean request_new,
DBusGMethodInvocation *context)
{
- NMConnection *connection = NM_SYSCONFIG_CONNECTION_SETTINGS (sys_connection)->connection;
+ NMConnection *connection;
GError *error = NULL;
NMSettingConnection *s_con;
NMSetting *setting;
NMSystemConfigInterface *plugin;
struct AddSecretsData sdata;
+ connection = nm_exported_connection_get_connection (sys_connection);
+
g_return_if_fail (NM_IS_CONNECTION (connection));
g_return_if_fail (setting_name != NULL);
@@ -182,45 +167,43 @@
}
static void
-nm_sysconfig_connection_settings_finalize (GObject *object)
+nm_sysconfig_exported_connection_finalize (GObject *object)
{
- G_OBJECT_CLASS (nm_sysconfig_connection_settings_parent_class)->finalize (object);
+ G_OBJECT_CLASS (nm_sysconfig_exported_connection_parent_class)->finalize (object);
}
static void
-nm_sysconfig_connection_settings_class_init (NMSysconfigConnectionSettingsClass *class)
+nm_sysconfig_exported_connection_class_init (NMSysconfigExportedConnectionClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
- NMConnectionSettingsClass *connection = NM_CONNECTION_SETTINGS_CLASS (class);
+ NMExportedConnectionClass *connection = NM_EXPORTED_CONNECTION_CLASS (class);
- object_class->finalize = nm_sysconfig_connection_settings_finalize;
+ object_class->finalize = nm_sysconfig_exported_connection_finalize;
- connection->get_id = connection_settings_get_id;
- connection->get_settings = connection_settings_get_settings;
- connection->get_secrets = connection_settings_get_secrets;
+ connection->get_secrets = exported_connection_get_secrets;
}
static void
-nm_sysconfig_connection_settings_init (NMSysconfigConnectionSettings *sysconfig_connection_settings)
+nm_sysconfig_exported_connection_init (NMSysconfigExportedConnection *sysconfig_exported_connection)
{
}
-NMSysconfigConnectionSettings *
-nm_sysconfig_connection_settings_new (NMConnection *connection,
+NMSysconfigExportedConnection *
+nm_sysconfig_exported_connection_new (NMConnection *connection,
DBusGConnection *g_conn)
{
- NMSysconfigConnectionSettings *settings;
- NMSettingConnection *s_con;
+ NMSysconfigExportedConnection *exported;
- 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;
+ exported = g_object_new (NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION,
+ NM_EXPORTED_CONNECTION_CONNECTION, connection,
+ NULL);
- nm_connection_settings_register_object (NM_CONNECTION_SETTINGS (settings), g_conn);
-
- return settings;
+ nm_exported_connection_register_object (NM_EXPORTED_CONNECTION (exported),
+ NM_CONNECTION_SCOPE_SYSTEM,
+ g_conn);
+
+ return exported;
}
/*
@@ -242,10 +225,12 @@
connections = g_ptr_array_new ();
for (iter = sysconfig_settings->connections; iter; iter = g_slist_next (iter)) {
- NMConnectionSettings *connection = NM_CONNECTION_SETTINGS (iter->data);
+ NMExportedConnection *exported = NM_EXPORTED_CONNECTION (iter->data);
+ NMConnection *connection;
char *path;
- path = g_strdup (nm_connection_settings_get_dbus_object_path (connection));
+ connection = nm_exported_connection_get_connection (exported);
+ path = g_strdup (nm_connection_get_path (connection));
if (path)
g_ptr_array_add (connections, path);
}
@@ -299,12 +284,12 @@
NMConnection *connection,
DBusGConnection *g_connection)
{
- NMSysconfigConnectionSettings *exported;
+ NMSysconfigExportedConnection *exported;
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings));
g_return_if_fail (NM_IS_CONNECTION (connection));
- exported = nm_sysconfig_connection_settings_new (connection, g_connection);
+ exported = nm_sysconfig_exported_connection_new (connection, g_connection);
if (!exported) {
g_warning ("%s: couldn't export the connection!", __func__);
return;
@@ -313,7 +298,7 @@
settings->connections = g_slist_append (settings->connections, exported);
nm_settings_signal_new_connection (NM_SETTINGS (settings),
- NM_CONNECTION_SETTINGS (exported));
+ NM_EXPORTED_CONNECTION (exported));
}
static void
@@ -326,11 +311,15 @@
g_return_if_fail (NM_IS_CONNECTION (connection));
for (iter = settings->connections; iter; iter = g_slist_next (iter)) {
- NMSysconfigConnectionSettings *item = NM_SYSCONFIG_CONNECTION_SETTINGS (iter->data);
+ NMSysconfigExportedConnection *item = NM_SYSCONFIG_EXPORTED_CONNECTION (iter->data);
+ NMExportedConnection *exported = NM_EXPORTED_CONNECTION (item);
+ NMConnection *wrapped;
+
+ wrapped = nm_exported_connection_get_connection (exported);
- if (item->connection == connection) {
+ if (wrapped == connection) {
settings->connections = g_slist_remove (settings->connections, iter);
- nm_connection_settings_signal_removed (NM_CONNECTION_SETTINGS (item));
+ nm_exported_connection_signal_removed (exported);
g_object_unref (item);
g_slist_free (iter);
break;
@@ -351,15 +340,18 @@
{
GHashTable *hash;
GSList *iter;
- NMSysconfigConnectionSettings *found = NULL;
+ NMSysconfigExportedConnection *found = NULL;
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (settings));
g_return_if_fail (NM_IS_CONNECTION (connection));
for (iter = settings->connections; iter; iter = g_slist_next (iter)) {
- NMSysconfigConnectionSettings *item = NM_SYSCONFIG_CONNECTION_SETTINGS (iter->data);
+ NMSysconfigExportedConnection *item = NM_SYSCONFIG_EXPORTED_CONNECTION (iter->data);
+ NMConnection *wrapped;
+
+ wrapped = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (item));
- if (item->connection == connection) {
+ if (wrapped == connection) {
found = item;
break;
}
@@ -377,7 +369,7 @@
}
hash = nm_connection_to_hash (connection);
- nm_connection_settings_signal_updated (NM_CONNECTION_SETTINGS (found), hash);
+ nm_exported_connection_signal_updated (NM_EXPORTED_CONNECTION (found), hash);
g_hash_table_destroy (hash);
}
Modified: trunk/system-settings/src/dbus-settings.h
==============================================================================
--- trunk/system-settings/src/dbus-settings.h (original)
+++ trunk/system-settings/src/dbus-settings.h Wed Feb 20 22:37:39 2008
@@ -27,35 +27,32 @@
#define NM_SS_PLUGIN_TAG "nm-ss-plugin"
-typedef struct _NMSysconfigConnectionSettings NMSysconfigConnectionSettings;
-typedef struct _NMSysconfigConnectionSettingsClass NMSysconfigConnectionSettingsClass;
+typedef struct _NMSysconfigExportedConnection NMSysconfigExportedConnection;
+typedef struct _NMSysconfigExportedConnectionClass NMSysconfigExportedConnectionClass;
/*
- * NMSysconfigConnectionSettings
+ * NMSysconfigExportedConnection
*/
-#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))
+#define NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION (nm_sysconfig_exported_connection_get_type ())
+#define NM_SYSCONFIG_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION, NMSysconfigExportedConnection))
+#define NM_SYSCONFIG_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION, NMSysconfigExportedConnectionClass))
+#define NM_IS_SYSCONFIG_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION))
+#define NM_IS_SYSCONFIG_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION))
+#define NM_SYSCONFIG_EXPORTED_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_EXPORTED_CONNECTION, NMSysconfigExportedConnectionClass))
-struct _NMSysconfigConnectionSettings
+struct _NMSysconfigExportedConnection
{
- NMConnectionSettings parent_instance;
-
- char *id;
- NMConnection *connection;
+ NMExportedConnection parent_instance;
};
-struct _NMSysconfigConnectionSettingsClass
+struct _NMSysconfigExportedConnectionClass
{
- NMConnectionSettingsClass parent_class;
+ NMExportedConnectionClass parent_class;
};
-GType nm_sysconfig_connection_settings_get_type (void);
-NMSysconfigConnectionSettings *nm_sysconfig_connection_settings_new (NMConnection *connection,
+GType nm_sysconfig_exported_connection_get_type (void);
+NMSysconfigExportedConnection *nm_sysconfig_exported_connection_new (NMConnection *connection,
DBusGConnection *g_conn);
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]