network-manager-applet r547 - in trunk: . src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r547 - in trunk: . src
- Date: Wed, 20 Feb 2008 22:41:28 +0000 (GMT)
Author: dcbw
Date: Wed Feb 20 22:41:27 2008
New Revision: 547
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=547&view=rev
Log:
2008-02-20 Dan Williams <dcbw redhat com>
* Adapt to NM changes in NMConnection and NMExportedConnection
* Clean up a lot of the exported connection and settings handling
Modified:
trunk/ChangeLog
trunk/src/applet-dbus-settings.c
trunk/src/applet-dbus-settings.h
trunk/src/applet-device-wireless.c
trunk/src/applet.c
trunk/src/applet.h
Modified: trunk/src/applet-dbus-settings.c
==============================================================================
--- trunk/src/applet-dbus-settings.c (original)
+++ trunk/src/applet-dbus-settings.c Wed Feb 20 22:41:27 2008
@@ -41,22 +41,22 @@
#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 NMConnectionSettings * applet_dbus_connection_settings_new_from_connection (GConfClient *conf_client,
- const gchar *conf_dir,
- NMConnection *connection);
+static AppletExportedConnection * applet_exported_connection_new_from_connection (GConfClient *conf_client,
+ const gchar *conf_dir,
+ NMConnection *connection);
static void connections_changed_cb (GConfClient *conf_client,
guint cnxn_id,
GConfEntry *entry,
gpointer user_data);
-static const char *applet_dbus_connection_settings_get_gconf_path (NMConnectionSettings *connection);
+static const char *applet_exported_connection_get_gconf_path (AppletExportedConnection *exported);
-static AppletDbusConnectionSettings *applet_dbus_settings_get_by_gconf_path (AppletDbusSettings *applet_settings,
- const char *path);
+static AppletExportedConnection *applet_dbus_settings_get_by_gconf_path (AppletDbusSettings *applet_settings,
+ const char *path);
-static gboolean applet_dbus_connection_settings_changed (AppletDbusConnectionSettings *connection,
- GConfEntry *entry);
+static gboolean applet_exported_connection_changed (AppletExportedConnection *connection,
+ GConfEntry *entry);
enum {
@@ -430,13 +430,13 @@
G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN, G_TYPE_POINTER);
}
-NMSettings *
+AppletDbusSettings *
applet_dbus_settings_new (void)
{
- NMSettings *settings;
+ AppletDbusSettings *settings;
AppletDBusManager * manager;
- settings = g_object_new (applet_dbus_settings_get_type (), NULL);
+ settings = APPLET_DBUS_SETTINGS (g_object_new (applet_dbus_settings_get_type (), NULL));
manager = applet_dbus_manager_get ();
dbus_g_connection_register_g_object (applet_dbus_manager_get_connection (manager),
@@ -448,7 +448,7 @@
}
static void
-connection_new_secrets_requested_cb (AppletDbusConnectionSettings *applet_connection,
+connection_new_secrets_requested_cb (AppletExportedConnection *exported,
const char *setting_name,
const char **hints,
gboolean ask_user,
@@ -463,7 +463,7 @@
g_signal_emit (settings,
settings_signals[SETTINGS_NEW_SECRETS_REQUESTED],
0,
- applet_connection,
+ exported,
setting_name,
hints,
ask_user,
@@ -480,7 +480,7 @@
char **dirs = NULL;
guint len;
char *path = NULL;
- AppletDbusConnectionSettings *connection;
+ AppletExportedConnection *exported;
gboolean valid = FALSE;
dirs = g_strsplit (gconf_entry_get_key (entry), "/", -1);
@@ -495,26 +495,23 @@
goto out;
path = g_strconcat ("/", dirs[1], "/", dirs[2], "/", dirs[3], "/", dirs[4], NULL);
- connection = applet_dbus_settings_get_by_gconf_path (settings, path);
-
- if (connection == NULL) {
- NMConnectionSettings *exported;
-
+ exported = applet_dbus_settings_get_by_gconf_path (settings, path);
+ if (exported == NULL) {
/* Maybe a new connection */
- exported = applet_dbus_connection_settings_new (settings->conf_client, path);
+ exported = applet_exported_connection_new (settings->conf_client, path);
if (exported) {
g_signal_connect (G_OBJECT (exported), "new-secrets-requested",
(GCallback) connection_new_secrets_requested_cb,
settings);
settings->connections = g_slist_append (settings->connections, exported);
nm_settings_signal_new_connection (NM_SETTINGS (settings),
- NM_CONNECTION_SETTINGS (exported));
+ NM_EXPORTED_CONNECTION (exported));
}
} else {
/* Updated or removed connection */
- valid = applet_dbus_connection_settings_changed (connection, entry);
+ valid = applet_exported_connection_changed (exported, entry);
if (!valid)
- settings->connections = g_slist_remove (settings->connections, connection);
+ settings->connections = g_slist_remove (settings->connections, exported);
}
out:
@@ -522,7 +519,7 @@
g_strfreev (dirs);
}
-AppletDbusConnectionSettings *
+AppletExportedConnection *
applet_dbus_settings_user_get_by_dbus_path (AppletDbusSettings *applet_settings,
const char *path)
{
@@ -532,9 +529,14 @@
g_return_val_if_fail (path != NULL, NULL);
for (elt = applet_settings->connections; elt; elt = g_slist_next (elt)) {
- const char * sc_path = nm_connection_settings_get_dbus_object_path (elt->data);
+ AppletExportedConnection *exported = APPLET_EXPORTED_CONNECTION (elt->data);
+ NMConnection *connection;
+ const char *sc_path;
+
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ sc_path = nm_connection_get_path (connection);
if (!strcmp (sc_path, path))
- return APPLET_DBUS_CONNECTION_SETTINGS (elt->data);
+ return exported;
}
return NULL;
@@ -581,7 +583,7 @@
return g_hash_table_lookup (settings->system_connections, path);
}
-AppletDbusConnectionSettings *
+AppletExportedConnection *
applet_dbus_settings_user_get_by_connection (AppletDbusSettings *applet_settings,
NMConnection *connection)
{
@@ -591,17 +593,18 @@
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
for (elt = applet_settings->connections; elt; elt = g_slist_next (elt)) {
+ AppletExportedConnection *exported = APPLET_EXPORTED_CONNECTION (elt->data);
NMConnection *list_con;
- list_con = applet_dbus_connection_settings_get_connection (elt->data);
+ list_con = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
if (connection == list_con)
- return APPLET_DBUS_CONNECTION_SETTINGS (elt->data);
+ return exported;
}
return NULL;
}
-static AppletDbusConnectionSettings *
+static AppletExportedConnection *
applet_dbus_settings_get_by_gconf_path (AppletDbusSettings *applet_settings,
const char *path)
{
@@ -611,9 +614,10 @@
g_return_val_if_fail (path != NULL, NULL);
for (elt = applet_settings->connections; elt; elt = g_slist_next (elt)) {
- const char * sc_path = applet_dbus_connection_settings_get_gconf_path (elt->data);
- if (!strcmp (sc_path, path))
- return APPLET_DBUS_CONNECTION_SETTINGS (elt->data);
+ AppletExportedConnection *exported = APPLET_EXPORTED_CONNECTION (elt->data);
+
+ if (!strcmp (applet_exported_connection_get_gconf_path (exported), path))
+ return exported;
}
return NULL;
@@ -632,13 +636,13 @@
}
while (conf_list != NULL) {
- NMConnectionSettings *connection;
+ AppletExportedConnection *exported;
gchar *dir = (gchar *) conf_list->data;
- connection = applet_dbus_connection_settings_new (applet_settings->conf_client, dir);
- if (connection) {
- cnc_list = g_slist_append (cnc_list, connection);
- g_signal_connect (G_OBJECT (connection), "new-secrets-requested",
+ exported = applet_exported_connection_new (applet_settings->conf_client, dir);
+ if (exported) {
+ cnc_list = g_slist_append (cnc_list, exported);
+ g_signal_connect (G_OBJECT (exported), "new-secrets-requested",
(GCallback) connection_new_secrets_requested_cb,
applet_settings);
}
@@ -694,10 +698,11 @@
update_user_connections (applet_settings);
for (iter = applet_settings->connections; iter; iter = g_slist_next (iter)) {
- NMConnectionSettings *cs = NM_CONNECTION_SETTINGS (iter->data);
- NMConnection *con = applet_dbus_connection_settings_get_connection (cs);
+ AppletExportedConnection *exported = APPLET_EXPORTED_CONNECTION (iter->data);
+ NMConnection *connection;
- connections = g_slist_append (connections, con);
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ connections = g_slist_append (connections, connection);
}
return connections;
@@ -717,8 +722,12 @@
connections = g_ptr_array_sized_new (g_slist_length (list));
for (iter = list; iter != NULL; iter = iter->next) {
- char * path = g_strdup (nm_connection_settings_get_dbus_object_path (NM_CONNECTION_SETTINGS (iter->data)));
+ AppletExportedConnection *exported = APPLET_EXPORTED_CONNECTION (iter->data);
+ NMConnection *connection;
+ char *path;
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ path = g_strdup (nm_connection_get_path (connection));
if (path)
g_ptr_array_add (connections, (gpointer) path);
}
@@ -726,11 +735,11 @@
return connections;
}
-AppletDbusConnectionSettings *
+AppletExportedConnection *
applet_dbus_settings_user_add_connection (AppletDbusSettings *applet_settings,
NMConnection *connection)
{
- NMConnectionSettings *exported;
+ AppletExportedConnection *exported;
guint32 i = 0;
char * path = NULL;
@@ -753,41 +762,41 @@
return NULL;
}
- exported = applet_dbus_connection_settings_new_from_connection (applet_settings->conf_client,
- path,
- connection);
- if (exported) {
- g_signal_connect (G_OBJECT (exported), "new-secrets-requested",
- (GCallback) connection_new_secrets_requested_cb,
- applet_settings);
- applet_settings->connections = g_slist_append (applet_settings->connections, exported);
- nm_settings_signal_new_connection (NM_SETTINGS (applet_settings),
- NM_CONNECTION_SETTINGS (exported));
-
- /* Must save connection to GConf _after_ adding it to the connections
- * list to avoid races with GConf notifications.
- */
- applet_dbus_connection_settings_save (NM_CONNECTION_SETTINGS (exported));
- }
-
+ exported = applet_exported_connection_new_from_connection (applet_settings->conf_client,
+ path,
+ connection);
g_free (path);
- return APPLET_DBUS_CONNECTION_SETTINGS (exported);
+ if (!exported)
+ return NULL;
+
+ g_signal_connect (G_OBJECT (exported), "new-secrets-requested",
+ (GCallback) connection_new_secrets_requested_cb,
+ applet_settings);
+ applet_settings->connections = g_slist_append (applet_settings->connections, exported);
+ nm_settings_signal_new_connection (NM_SETTINGS (applet_settings),
+ NM_EXPORTED_CONNECTION (exported));
+
+ /* Must save connection to GConf _after_ adding it to the connections
+ * list to avoid races with GConf notifications.
+ */
+ applet_exported_connection_save (exported);
+
+ return exported;
}
/*
- * AppletDbusConnectionSettings class implementation
+ * AppletExportedConnection class implementation
*/
-static gchar *applet_dbus_connection_settings_get_id (NMConnectionSettings *connection);
-static GHashTable *applet_dbus_connection_settings_get_settings (NMConnectionSettings *connection);
-static void applet_dbus_connection_settings_get_secrets (NMConnectionSettings *connection,
- const gchar *setting_name,
- const gchar **hints,
- gboolean request_new,
- DBusGMethodInvocation *context);
+static GHashTable *applet_exported_connection_get_settings (NMExportedConnection *connection);
+static void applet_exported_connection_get_secrets (NMExportedConnection *connection,
+ const gchar *setting_name,
+ const gchar **hints,
+ gboolean request_new,
+ DBusGMethodInvocation *context);
-G_DEFINE_TYPE (AppletDbusConnectionSettings, applet_dbus_connection_settings, NM_TYPE_CONNECTION_SETTINGS)
+G_DEFINE_TYPE (AppletExportedConnection, applet_exported_connection, NM_TYPE_EXPORTED_CONNECTION)
enum {
CONNECTION_NEW_SECRETS_REQUESTED,
@@ -797,61 +806,48 @@
static guint connection_signals[CONNECTION_LAST_SIGNAL] = { 0 };
static void
-applet_dbus_connection_settings_init (AppletDbusConnectionSettings *applet_connection)
+applet_exported_connection_init (AppletExportedConnection *exported)
{
- applet_connection->conf_client = NULL;
- applet_connection->conf_dir = NULL;
- applet_connection->id = NULL;
- applet_connection->connection = NULL;
+ exported->conf_client = NULL;
+ exported->conf_dir = NULL;
}
static void
-applet_dbus_connection_settings_finalize (GObject *object)
+applet_exported_connection_finalize (GObject *object)
{
- AppletDbusConnectionSettings *applet_connection = (AppletDbusConnectionSettings *) object;
+ AppletExportedConnection *exported = APPLET_EXPORTED_CONNECTION (object);
- if (applet_connection->conf_client) {
- g_object_unref (applet_connection->conf_client);
- applet_connection->conf_client = NULL;
+ if (exported->conf_client) {
+ g_object_unref (exported->conf_client);
+ exported->conf_client = NULL;
}
- if (applet_connection->conf_dir) {
- g_free (applet_connection->conf_dir);
- applet_connection->conf_dir = NULL;
+ if (exported->conf_dir) {
+ g_free (exported->conf_dir);
+ exported->conf_dir = NULL;
}
- if (applet_connection->id) {
- g_free (applet_connection->id);
- applet_connection->id = NULL;
- }
-
- if (applet_connection->connection) {
- g_object_unref (applet_connection->connection);
- applet_connection->connection = NULL;
- }
-
- G_OBJECT_CLASS (applet_dbus_connection_settings_parent_class)->finalize (object);
+ G_OBJECT_CLASS (applet_exported_connection_parent_class)->finalize (object);
}
static void
-applet_dbus_connection_settings_class_init (AppletDbusConnectionSettingsClass *applet_connection_class)
+applet_exported_connection_class_init (AppletExportedConnectionClass *exported_class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (applet_connection_class);
- NMConnectionSettingsClass *connection_class = NM_CONNECTION_SETTINGS_CLASS (applet_connection_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (exported_class);
+ NMExportedConnectionClass *connection_class = NM_EXPORTED_CONNECTION_CLASS (exported_class);
/* virtual methods */
- object_class->finalize = applet_dbus_connection_settings_finalize;
+ object_class->finalize = applet_exported_connection_finalize;
- connection_class->get_id = applet_dbus_connection_settings_get_id;
- connection_class->get_settings = applet_dbus_connection_settings_get_settings;
- connection_class->get_secrets = applet_dbus_connection_settings_get_secrets;
+ connection_class->get_settings = applet_exported_connection_get_settings;
+ connection_class->get_secrets = applet_exported_connection_get_secrets;
/* Signals */
connection_signals[CONNECTION_NEW_SECRETS_REQUESTED] =
g_signal_new ("new-secrets-requested",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (AppletDbusConnectionSettingsClass, new_secrets_requested),
+ G_STRUCT_OFFSET (AppletExportedConnectionClass, new_secrets_requested),
NULL, NULL,
applet_marshal_VOID__STRING_POINTER_BOOLEAN_POINTER,
G_TYPE_NONE, 4,
@@ -875,130 +871,124 @@
}
static gboolean
-applet_dbus_connection_settings_changed (AppletDbusConnectionSettings *applet_connection,
- GConfEntry *entry)
+applet_exported_connection_changed (AppletExportedConnection *exported,
+ GConfEntry *entry)
{
GHashTable *settings;
- NMConnection *connection;
- NMSettingConnection *s_con;
+ NMConnection *wrapped_connection;
+ NMConnection *gconf_connection;
+ GHashTable *new_settings;
+
+ wrapped_connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ if (!wrapped_connection) {
+ g_warning ("Exported connection for '%s' didn't wrap a connection.", exported->conf_dir);
+ goto invalid;
+ }
/* FIXME: just update the modified field, no need to re-read all */
- connection = nm_gconf_read_connection (applet_connection->conf_client,
- applet_connection->conf_dir);
- if (!connection) {
- g_warning ("No connection read from GConf at %s.", applet_connection->conf_dir);
+ gconf_connection = nm_gconf_read_connection (exported->conf_client,
+ exported->conf_dir);
+ if (!gconf_connection) {
+ g_warning ("No connection read from GConf at %s.", exported->conf_dir);
goto invalid;
}
- utils_fill_connection_certs (connection);
- if (!nm_connection_verify (connection)) {
- utils_clear_filled_connection_certs (connection);
- g_warning ("Invalid connection read from GConf at %s.", applet_connection->conf_dir);
+ utils_fill_connection_certs (gconf_connection);
+ if (!nm_connection_verify (gconf_connection)) {
+ utils_clear_filled_connection_certs (gconf_connection);
+ g_warning ("Invalid connection read from GConf at %s.", exported->conf_dir);
goto invalid;
}
- utils_clear_filled_connection_certs (connection);
+ utils_clear_filled_connection_certs (gconf_connection);
/* Ignore the GConf update if nothing changed */
- if (nm_connection_compare (applet_connection->connection, connection))
+ if (nm_connection_compare (wrapped_connection, gconf_connection))
return TRUE;
- if (applet_connection->connection) {
- GHashTable *new_settings;
-
- new_settings = nm_connection_to_hash (connection);
- nm_connection_replace_settings (applet_connection->connection, new_settings);
- g_object_unref (connection);
- } else
- applet_connection->connection = connection;
-
+ new_settings = nm_connection_to_hash (gconf_connection);
+ nm_connection_replace_settings (wrapped_connection, new_settings);
+ g_object_unref (gconf_connection);
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (applet_connection->connection,
- NM_TYPE_SETTING_CONNECTION));
- g_assert (s_con);
- g_free (applet_connection->id);
- applet_connection->id = g_strdup (s_con->id);
+ fill_vpn_user_name (wrapped_connection);
- fill_vpn_user_name (applet_connection->connection);
+ utils_fill_connection_certs (wrapped_connection);
+ settings = nm_connection_to_hash (wrapped_connection);
+ utils_clear_filled_connection_certs (wrapped_connection);
- utils_fill_connection_certs (applet_connection->connection);
- settings = nm_connection_to_hash (applet_connection->connection);
- utils_clear_filled_connection_certs (applet_connection->connection);
-
- nm_connection_settings_signal_updated (NM_CONNECTION_SETTINGS (applet_connection), settings);
+ nm_exported_connection_signal_updated (NM_EXPORTED_CONNECTION (exported), settings);
g_hash_table_destroy (settings);
return TRUE;
invalid:
- nm_connection_settings_signal_removed (NM_CONNECTION_SETTINGS (applet_connection));
+ nm_exported_connection_signal_removed (NM_EXPORTED_CONNECTION (exported));
return FALSE;
}
-NMConnectionSettings *
-applet_dbus_connection_settings_new (GConfClient *conf_client, const gchar *conf_dir)
+AppletExportedConnection *
+applet_exported_connection_new (GConfClient *conf_client, const gchar *conf_dir)
{
- AppletDbusConnectionSettings *applet_connection;
- AppletDBusManager * manager;
- NMSettingConnection *s_con;
+ AppletExportedConnection *exported;
+ AppletDBusManager *manager;
+ NMConnection *gconf_connection;
g_return_val_if_fail (conf_client != NULL, NULL);
g_return_val_if_fail (conf_dir != NULL, NULL);
- applet_connection = g_object_new (APPLET_TYPE_DBUS_CONNECTION_SETTINGS, NULL);
- applet_connection->conf_client = g_object_ref (conf_client);
- applet_connection->conf_dir = g_strdup (conf_dir);
-
/* retrieve GConf data */
- applet_connection->connection = nm_gconf_read_connection (conf_client, conf_dir);
- if (!applet_connection->connection) {
+ gconf_connection = nm_gconf_read_connection (conf_client, conf_dir);
+ if (!gconf_connection) {
g_warning ("No connection read from GConf at %s.", conf_dir);
- g_object_unref (applet_connection);
return NULL;
}
- utils_fill_connection_certs (applet_connection->connection);
- if (!nm_connection_verify (applet_connection->connection)) {
- utils_clear_filled_connection_certs (applet_connection->connection);
+ exported = g_object_new (APPLET_TYPE_EXPORTED_CONNECTION,
+ NM_EXPORTED_CONNECTION_CONNECTION, gconf_connection,
+ NULL);
+ exported->conf_client = g_object_ref (conf_client);
+ exported->conf_dir = g_strdup (conf_dir);
+
+ utils_fill_connection_certs (gconf_connection);
+ if (!nm_connection_verify (gconf_connection)) {
+ utils_clear_filled_connection_certs (gconf_connection);
g_warning ("Invalid connection read from GConf at %s.", conf_dir);
- g_object_unref (applet_connection);
+ g_object_unref (exported);
return NULL;
}
- utils_clear_filled_connection_certs (applet_connection->connection);
-
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (applet_connection->connection,
- NM_TYPE_SETTING_CONNECTION));
- applet_connection->id = g_strdup (s_con->id);
+ utils_clear_filled_connection_certs (gconf_connection);
- fill_vpn_user_name (applet_connection->connection);
+ fill_vpn_user_name (gconf_connection);
manager = applet_dbus_manager_get ();
- nm_connection_settings_register_object ((NMConnectionSettings *) applet_connection,
+ nm_exported_connection_register_object (NM_EXPORTED_CONNECTION (exported),
+ NM_CONNECTION_SCOPE_USER,
applet_dbus_manager_get_connection (manager));
g_object_unref (manager);
- return (NMConnectionSettings *) applet_connection;
+ return exported;
}
void
-applet_dbus_connection_settings_save (NMConnectionSettings *connection)
+applet_exported_connection_save (AppletExportedConnection *exported)
{
- AppletDbusConnectionSettings *applet_connection = (AppletDbusConnectionSettings *) connection;
-
- g_return_if_fail (APPLET_IS_DBUS_CONNECTION_SETTINGS (applet_connection));
+ NMConnection *connection;
- nm_gconf_write_connection (applet_connection->connection,
- applet_connection->conf_client,
- applet_connection->conf_dir);
- gconf_client_notify (applet_connection->conf_client, applet_connection->conf_dir);
- gconf_client_suggest_sync (applet_connection->conf_client, NULL);
-}
+ g_return_if_fail (APPLET_IS_EXPORTED_CONNECTION (exported));
-static NMConnectionSettings *
-applet_dbus_connection_settings_new_from_connection (GConfClient *conf_client,
- const gchar *conf_dir,
- NMConnection *connection)
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ nm_gconf_write_connection (connection,
+ exported->conf_client,
+ exported->conf_dir);
+ gconf_client_notify (exported->conf_client, exported->conf_dir);
+ gconf_client_suggest_sync (exported->conf_client, NULL);
+}
+
+static AppletExportedConnection *
+applet_exported_connection_new_from_connection (GConfClient *conf_client,
+ const gchar *conf_dir,
+ NMConnection *connection)
{
- AppletDbusConnectionSettings *applet_connection;
- AppletDBusManager * manager;
+ AppletExportedConnection *exported;
+ AppletDBusManager *manager;
g_return_val_if_fail (conf_client != NULL, NULL);
g_return_val_if_fail (conf_dir != NULL, NULL);
@@ -1012,68 +1002,34 @@
}
utils_clear_filled_connection_certs (connection);
- applet_connection = g_object_new (APPLET_TYPE_DBUS_CONNECTION_SETTINGS, NULL);
- applet_connection->conf_client = g_object_ref (conf_client);
- applet_connection->conf_dir = g_strdup (conf_dir);
- applet_connection->connection = connection;
+ exported = g_object_new (APPLET_TYPE_EXPORTED_CONNECTION,
+ NM_EXPORTED_CONNECTION_CONNECTION, connection,
+ NULL);
+ exported->conf_client = g_object_ref (conf_client);
+ exported->conf_dir = g_strdup (conf_dir);
- fill_vpn_user_name (applet_connection->connection);
+ fill_vpn_user_name (connection);
manager = applet_dbus_manager_get ();
- nm_connection_settings_register_object ((NMConnectionSettings *) applet_connection,
+ nm_exported_connection_register_object (NM_EXPORTED_CONNECTION (exported),
+ NM_CONNECTION_SCOPE_USER,
applet_dbus_manager_get_connection (manager));
g_object_unref (manager);
- return (NMConnectionSettings *) applet_connection;
-}
-
-static gchar *
-applet_dbus_connection_settings_get_id (NMConnectionSettings *connection)
-{
- AppletDbusConnectionSettings *applet_connection = (AppletDbusConnectionSettings *) connection;
-
- g_return_val_if_fail (APPLET_IS_DBUS_CONNECTION_SETTINGS (applet_connection), NULL);
- g_return_val_if_fail (NM_IS_CONNECTION (applet_connection->connection), NULL);
-
- return g_strdup (applet_connection->id);
+ return exported;
}
static const char *
-applet_dbus_connection_settings_get_gconf_path (NMConnectionSettings *connection)
-{
- AppletDbusConnectionSettings *applet_connection = (AppletDbusConnectionSettings *) connection;
-
- g_return_val_if_fail (APPLET_IS_DBUS_CONNECTION_SETTINGS (applet_connection), NULL);
- g_return_val_if_fail (NM_IS_CONNECTION (applet_connection->connection), NULL);
-
- return applet_connection->conf_dir;
-}
-
-NMConnection *
-applet_dbus_connection_settings_get_connection (NMConnectionSettings *connection)
+applet_exported_connection_get_gconf_path (AppletExportedConnection *exported)
{
- AppletDbusConnectionSettings *applet_connection = (AppletDbusConnectionSettings *) connection;
-
- g_return_val_if_fail (APPLET_IS_DBUS_CONNECTION_SETTINGS (applet_connection), NULL);
- g_return_val_if_fail (NM_IS_CONNECTION (applet_connection->connection), NULL);
-
- return applet_connection->connection;
-}
-
-static
-GHashTable *applet_dbus_connection_settings_get_settings (NMConnectionSettings *connection)
-{
- GHashTable *settings;
- AppletDbusConnectionSettings *applet_connection = (AppletDbusConnectionSettings *) connection;
+ NMConnection *connection;
- g_return_val_if_fail (APPLET_IS_DBUS_CONNECTION_SETTINGS (applet_connection), NULL);
- g_return_val_if_fail (NM_IS_CONNECTION (applet_connection->connection), NULL);
+ g_return_val_if_fail (APPLET_IS_EXPORTED_CONNECTION (exported), NULL);
- utils_fill_connection_certs (applet_connection->connection);
- settings = nm_connection_to_hash (applet_connection->connection);
- utils_clear_filled_connection_certs (applet_connection->connection);
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
- return settings;
+ return exported->conf_dir;
}
static GValue *
@@ -1223,14 +1179,34 @@
return secrets;
}
+static GHashTable *
+applet_exported_connection_get_settings (NMExportedConnection *parent)
+{
+ AppletExportedConnection *exported = APPLET_EXPORTED_CONNECTION (parent);
+ NMConnection *connection;
+ GHashTable *settings;
+
+ g_return_val_if_fail (APPLET_IS_EXPORTED_CONNECTION (exported), NULL);
+
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
+
+ utils_fill_connection_certs (connection);
+ settings = nm_connection_to_hash (connection);
+ utils_clear_filled_connection_certs (connection);
+
+ return settings;
+}
+
static void
-applet_dbus_connection_settings_get_secrets (NMConnectionSettings *connection,
- const gchar *setting_name,
- const gchar **hints,
- gboolean request_new,
- DBusGMethodInvocation *context)
+applet_exported_connection_get_secrets (NMExportedConnection *parent,
+ const gchar *setting_name,
+ const gchar **hints,
+ gboolean request_new,
+ DBusGMethodInvocation *context)
{
- AppletDbusConnectionSettings *applet_connection = (AppletDbusConnectionSettings *) connection;
+ AppletExportedConnection *exported = APPLET_EXPORTED_CONNECTION (parent);
+ NMConnection *connection;
GError *error = NULL;
GHashTable *secrets = NULL;
GList *found_list = NULL;
@@ -1238,11 +1214,13 @@
NMSettingConnection *s_con;
NMSetting *setting;
- g_return_if_fail (APPLET_IS_DBUS_CONNECTION_SETTINGS (applet_connection));
- g_return_if_fail (NM_IS_CONNECTION (applet_connection->connection));
+ g_return_if_fail (APPLET_IS_EXPORTED_CONNECTION (exported));
g_return_if_fail (setting_name != NULL);
- setting = nm_connection_get_setting_by_name (applet_connection->connection, setting_name);
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ g_return_if_fail (NM_IS_CONNECTION (connection));
+
+ setting = nm_connection_get_setting_by_name (connection, setting_name);
if (!setting) {
g_set_error (&error, NM_SETTINGS_ERROR, 1,
"%s.%d - Connection didn't have requested setting '%s'.",
@@ -1253,8 +1231,7 @@
return;
}
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (applet_connection->connection,
- NM_TYPE_SETTING_CONNECTION));
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
if (!s_con || !s_con->id || !strlen (s_con->id) || !s_con->type) {
g_set_error (&error, NM_SETTINGS_ERROR, 1,
"%s.%d - Connection didn't have required '"
@@ -1274,7 +1251,7 @@
if (request_new) {
nm_info ("New secrets for %s/%s requested; ask the user",
s_con->id, setting_name);
- nm_connection_clear_secrets (applet_connection->connection);
+ nm_connection_clear_secrets (connection);
goto get_secrets;
}
@@ -1293,8 +1270,7 @@
goto get_secrets;
}
- secrets = extract_secrets (applet_connection->connection,
- found_list, s_con->id, setting_name, &error);
+ secrets = extract_secrets (connection, found_list, s_con->id, setting_name, &error);
if (error) {
g_warning (error->message);
dbus_g_method_return_error (context, error);
@@ -1314,7 +1290,7 @@
return;
get_secrets:
- g_signal_emit (applet_connection,
+ g_signal_emit (exported,
connection_signals[CONNECTION_NEW_SECRETS_REQUESTED],
0,
setting_name,
Modified: trunk/src/applet-dbus-settings.h
==============================================================================
--- trunk/src/applet-dbus-settings.h (original)
+++ trunk/src/applet-dbus-settings.h Wed Feb 20 22:41:27 2008
@@ -27,37 +27,34 @@
#include <nm-connection.h>
#include <nm-settings.h>
-#define APPLET_TYPE_DBUS_CONNECTION_SETTINGS (applet_dbus_connection_settings_get_type ())
-#define APPLET_IS_DBUS_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLET_TYPE_DBUS_CONNECTION_SETTINGS))
-#define APPLET_DBUS_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLET_TYPE_DBUS_CONNECTION_SETTINGS, AppletDbusConnectionSettings))
+#define APPLET_TYPE_EXPORTED_CONNECTION (applet_exported_connection_get_type ())
+#define APPLET_IS_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLET_TYPE_EXPORTED_CONNECTION))
+#define APPLET_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLET_TYPE_EXPORTED_CONNECTION, AppletExportedConnection))
typedef struct {
- NMConnectionSettings parent;
+ NMExportedConnection parent;
/* private data */
GConfClient *conf_client;
gchar *conf_dir;
gchar *id;
- NMConnection *connection;
-} AppletDbusConnectionSettings;
+} AppletExportedConnection;
typedef struct {
- NMConnectionSettingsClass parent_class;
+ NMExportedConnectionClass parent_class;
/* Signals */
- void (*new_secrets_requested) (AppletDbusConnectionSettings *connection,
+ void (*new_secrets_requested) (AppletExportedConnection *exported,
const char *setting_name,
const char **hints,
gboolean ask_user,
DBusGMethodInvocation *context);
-} AppletDbusConnectionSettingsClass;
+} AppletExportedConnectionClass;
-GType applet_dbus_connection_settings_get_type (void);
-NMConnectionSettings *applet_dbus_connection_settings_new (GConfClient *conf_client, const gchar *conf_dir);
+GType applet_exported_connection_get_type (void);
+AppletExportedConnection *applet_exported_connection_new (GConfClient *conf_client, const gchar *conf_dir);
-NMConnection * applet_dbus_connection_settings_get_connection (NMConnectionSettings *connection);
-
-void applet_dbus_connection_settings_save (NMConnectionSettings *connection);
+void applet_exported_connection_save (AppletExportedConnection *exported);
#define APPLET_TYPE_DBUS_SETTINGS (applet_dbus_settings_get_type ())
@@ -82,7 +79,7 @@
/* Signals */
void (*new_secrets_requested) (AppletDbusSettings *settings,
- AppletDbusConnectionSettings *connection,
+ AppletExportedConnection *exported,
const char *setting_name,
const char **hints,
gboolean ask_user,
@@ -90,16 +87,16 @@
} AppletDbusSettingsClass;
GType applet_dbus_settings_get_type (void);
-NMSettings *applet_dbus_settings_new (void);
+AppletDbusSettings *applet_dbus_settings_new (void);
-AppletDbusConnectionSettings * applet_dbus_settings_user_add_connection (AppletDbusSettings *settings,
- NMConnection *connection);
+AppletExportedConnection * applet_dbus_settings_user_add_connection (AppletDbusSettings *settings,
+ NMConnection *connection);
-AppletDbusConnectionSettings * applet_dbus_settings_user_get_by_dbus_path (AppletDbusSettings *settings,
+AppletExportedConnection * applet_dbus_settings_user_get_by_dbus_path (AppletDbusSettings *settings,
const char *path);
-AppletDbusConnectionSettings * applet_dbus_settings_user_get_by_connection (AppletDbusSettings *settings,
- NMConnection *connection);
+AppletExportedConnection * applet_dbus_settings_user_get_by_connection (AppletDbusSettings *settings,
+ NMConnection *connection);
const char * applet_dbus_settings_system_get_dbus_path (AppletDbusSettings *settings,
NMConnection *connection);
Modified: trunk/src/applet-device-wireless.c
==============================================================================
--- trunk/src/applet-device-wireless.c (original)
+++ trunk/src/applet-device-wireless.c Wed Feb 20 22:41:27 2008
@@ -685,17 +685,20 @@
}
static gboolean
-add_seen_bssid (AppletDbusConnectionSettings *connection, NMAccessPoint *ap)
+add_seen_bssid (AppletExportedConnection *exported, NMAccessPoint *ap)
{
+ NMConnection *connection;
NMSettingWireless *s_wireless;
gboolean found = FALSE;
gboolean added = FALSE;
char *lower_bssid;
GSList *iter;
const char *bssid;
-
- s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection->connection,
- NM_TYPE_SETTING_WIRELESS));
+
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
+
+ s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
if (!s_wireless)
return FALSE;
@@ -733,7 +736,8 @@
GParamSpec *pspec,
NMApplet *applet)
{
- AppletDbusConnectionSettings *connection_settings = NULL;
+ AppletExportedConnection *exported = NULL;
+ NMConnection *connection;
NMSettingWireless *s_wireless;
NMAccessPoint *ap;
const GByteArray *ssid;
@@ -745,12 +749,14 @@
if (!ap)
return;
- connection_settings = applet_get_connection_settings_for_device (NM_DEVICE (device), applet);
- if (!connection_settings)
+ exported = applet_get_exported_connection_for_device (NM_DEVICE (device), applet);
+ if (!exported)
return;
- s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection_settings->connection,
- NM_TYPE_SETTING_WIRELESS));
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ g_return_if_fail (NM_IS_CONNECTION (connection));
+
+ s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
if (!s_wireless)
return;
@@ -758,8 +764,8 @@
if (!ssid || !nm_utils_same_ssid (s_wireless->ssid, ssid, TRUE))
return;
- if (add_seen_bssid (connection_settings, ap))
- applet_dbus_connection_settings_save (NM_CONNECTION_SETTINGS (connection_settings));
+ if (add_seen_bssid (exported, ap))
+ applet_exported_connection_save (exported);
applet_schedule_update_icon (applet);
}
@@ -901,7 +907,7 @@
NMDeviceState state,
NMApplet *applet)
{
- AppletDbusConnectionSettings *connection_settings;
+ AppletExportedConnection *exported;
NMAccessPoint *ap = NULL;
char *msg;
char *esc_ssid = NULL;
@@ -943,9 +949,9 @@
applet);
/* Save this BSSID to seen-bssids list */
- connection_settings = applet_get_connection_settings_for_device (device, applet);
- if (connection_settings && add_seen_bssid (connection_settings, applet->current_ap))
- applet_dbus_connection_settings_save (NM_CONNECTION_SETTINGS (connection_settings));
+ exported = applet_get_exported_connection_for_device (device, applet);
+ if (exported && add_seen_bssid (exported, applet->current_ap))
+ applet_exported_connection_save (exported);
}
msg = g_strdup_printf (_("You are now connected to the wireless network '%s'."),
@@ -1065,8 +1071,7 @@
NMDevice *device = NULL;
NMAccessPoint *ap = NULL;
NMSettingConnection *s_con;
- AppletDbusConnectionSettings *exported_con = NULL;
- const char *con_path;
+ AppletExportedConnection *exported = NULL;
gboolean ignored = FALSE;
if (response != GTK_RESPONSE_OK)
@@ -1111,25 +1116,22 @@
s_con->autoconnect = TRUE;
}
- exported_con = applet_dbus_settings_user_get_by_connection (APPLET_DBUS_SETTINGS (applet->settings),
- connection);
- if (!exported_con) {
- exported_con = applet_dbus_settings_user_add_connection (APPLET_DBUS_SETTINGS (applet->settings),
- connection);
- if (!exported_con) {
+ exported = applet_dbus_settings_user_get_by_connection (applet->settings, connection);
+ if (!exported) {
+ exported = applet_dbus_settings_user_add_connection (applet->settings, connection);
+ if (!exported) {
nm_warning ("Couldn't create other network connection.");
goto done;
}
} else {
/* Save the updated settings to GConf */
- applet_dbus_connection_settings_save (NM_CONNECTION_SETTINGS (exported_con));
+ applet_exported_connection_save (exported);
}
- con_path = nm_connection_settings_get_dbus_object_path (NM_CONNECTION_SETTINGS (exported_con));
nm_client_activate_device (applet->nm_client,
device,
NM_DBUS_SERVICE_USER_SETTINGS,
- con_path,
+ nm_connection_get_path (connection),
ap ? nm_object_get_path (NM_OBJECT (ap)) : NULL,
activate_device_cb,
applet);
@@ -1172,7 +1174,7 @@
{
NMApplet *applet = NM_APPLET (user_data);
DBusGMethodInvocation *context;
- AppletDbusConnectionSettings *applet_connection;
+ AppletExportedConnection *exported;
NMConnection *connection = NULL;
NMDevice *device = NULL;
GHashTable *setting_hash;
@@ -1249,9 +1251,9 @@
* saving to GConf might trigger the GConf change notifiers, resulting
* in the connection being read back in from GConf which clears secrets.
*/
- applet_connection = applet_dbus_settings_user_get_by_connection (APPLET_DBUS_SETTINGS (applet->settings), connection);
- if (applet_connection)
- applet_dbus_connection_settings_save (NM_CONNECTION_SETTINGS (applet_connection));
+ exported = applet_dbus_settings_user_get_by_connection (applet->settings, connection);
+ if (exported)
+ applet_exported_connection_save (exported);
done:
if (error) {
Modified: trunk/src/applet.c
==============================================================================
--- trunk/src/applet.c (original)
+++ trunk/src/applet.c Wed Feb 20 22:41:27 2008
@@ -126,16 +126,16 @@
gpointer user_data)
{
AppletDbusSettings *applet_settings = APPLET_DBUS_SETTINGS (applet->settings);
- AppletDbusConnectionSettings *exported_con = NULL;
+ AppletExportedConnection *exported = NULL;
char *con_path = NULL;
gboolean is_system = FALSE;
g_return_if_fail (NM_IS_DEVICE (device));
if (connection) {
- exported_con = applet_dbus_settings_user_get_by_connection (applet_settings, connection);
- if (exported_con) {
- con_path = (char *) nm_connection_settings_get_dbus_object_path (NM_CONNECTION_SETTINGS (exported_con));
+ exported = applet_dbus_settings_user_get_by_connection (applet_settings, connection);
+ if (exported) {
+ con_path = (char *) nm_connection_get_path (connection);
} else {
con_path = (char *) applet_dbus_settings_system_get_dbus_path (applet_settings, connection);
if (con_path)
@@ -156,8 +156,8 @@
return;
}
- exported_con = applet_dbus_settings_user_add_connection (applet_settings, connection);
- if (!exported_con) {
+ exported = applet_dbus_settings_user_add_connection (applet_settings, connection);
+ if (!exported) {
/* If the setting isn't valid, because it needs more authentication
* or something, ask the user for it.
*/
@@ -169,7 +169,7 @@
return;
}
- con_path = (char *) nm_connection_settings_get_dbus_object_path (NM_CONNECTION_SETTINGS (exported_con));
+ con_path = (char *) nm_connection_get_path (connection);
}
g_assert (con_path);
@@ -283,11 +283,17 @@
}
static const char *
-get_connection_id (AppletDbusConnectionSettings *settings)
+get_connection_id (AppletExportedConnection *exported)
{
NMSettingConnection *conn;
+ NMConnection *connection;
+
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ g_return_val_if_fail (connection != NULL, NULL);
+
+ conn = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+ g_return_val_if_fail (conn != NULL, NULL);
- conn = NM_SETTING_CONNECTION (nm_connection_get_setting (settings->connection, NM_TYPE_SETTING_CONNECTION));
return conn->id;
}
@@ -317,15 +323,16 @@
nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data)
{
NMApplet *applet = NM_APPLET (user_data);
- NMConnectionSettings *connection_settings;
+ NMExportedConnection *exported;
+ NMConnection *wrapped;
NMVPNConnection *connection;
const char *connection_name;
NMDevice *device;
- connection_settings = NM_CONNECTION_SETTINGS (g_object_get_data (G_OBJECT (item), "connection"));
- g_assert (connection_settings);
+ exported = NM_EXPORTED_CONNECTION (g_object_get_data (G_OBJECT (item), "connection"));
+ g_assert (exported);
- connection_name = get_connection_id ((AppletDbusConnectionSettings *) connection_settings);
+ connection_name = get_connection_id (APPLET_EXPORTED_CONNECTION (exported));
connection = (NMVPNConnection *) g_hash_table_lookup (applet->vpn_connections, connection_name);
if (connection)
@@ -334,9 +341,10 @@
/* Connection inactive, activate */
device = applet_get_first_active_device (applet);
+ wrapped = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
connection = nm_vpn_manager_connect (applet->vpn_manager,
NM_DBUS_SERVICE_USER_SETTINGS,
- nm_connection_settings_get_dbus_object_path (connection_settings),
+ nm_connection_get_path (wrapped),
device);
if (connection) {
add_one_vpn_connection (connection, applet);
@@ -519,11 +527,11 @@
if (!strcmp (con->service_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS)) {
connection = applet_dbus_settings_system_get_by_dbus_path (APPLET_DBUS_SETTINGS (applet->settings), con->connection_path);
} else if (!strcmp (con->service_name, NM_DBUS_SERVICE_USER_SETTINGS)) {
- AppletDbusConnectionSettings *tmp;
+ AppletExportedConnection *tmp;
tmp = applet_dbus_settings_user_get_by_dbus_path (APPLET_DBUS_SETTINGS (applet->settings), con->connection_path);
if (tmp) {
- connection = applet_dbus_connection_settings_get_connection (NM_CONNECTION_SETTINGS (tmp));
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (tmp));
break;
}
}
@@ -595,8 +603,8 @@
static int
sort_vpn_connections (gconstpointer a, gconstpointer b)
{
- return strcmp (get_connection_id ((AppletDbusConnectionSettings *) a),
- get_connection_id ((AppletDbusConnectionSettings *) b));
+ return strcmp (get_connection_id ((AppletExportedConnection *) a),
+ get_connection_id ((AppletExportedConnection *) b));
}
static GSList *
@@ -609,22 +617,23 @@
all_connections = applet_dbus_settings_list_connections (APPLET_DBUS_SETTINGS (applet->settings));
for (iter = all_connections; iter; iter = iter->next) {
- AppletDbusConnectionSettings *applet_settings = (AppletDbusConnectionSettings *) iter->data;
+ AppletExportedConnection *exported = APPLET_EXPORTED_CONNECTION (iter->data);
+ NMConnection *connection;
NMSettingConnection *s_con;
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (applet_settings->connection,
- NM_TYPE_SETTING_CONNECTION));
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
if (strcmp (s_con->type, NM_SETTING_VPN_SETTING_NAME))
/* Not a VPN connection */
continue;
- if (!nm_connection_get_setting (applet_settings->connection, NM_TYPE_SETTING_VPN_PROPERTIES)) {
+ if (!nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN_PROPERTIES)) {
const char *name = NM_SETTING (s_con)->name;
g_warning ("%s: VPN connection '%s' didn't have requires vpn-properties setting.", __func__, name);
continue;
}
- list = g_slist_prepend (list, applet_settings);
+ list = g_slist_prepend (list, exported);
}
return g_slist_sort (list, sort_vpn_connections);
@@ -651,8 +660,8 @@
num_vpn_active = g_hash_table_size (applet->vpn_connections);
for (iter = list; iter; iter = iter->next) {
- AppletDbusConnectionSettings *applet_settings = (AppletDbusConnectionSettings *) iter->data;
- const char *connection_name = get_connection_id (applet_settings);
+ AppletExportedConnection *exported = APPLET_EXPORTED_CONNECTION (iter->data);
+ const char *connection_name = get_connection_id (exported);
item = GTK_MENU_ITEM (gtk_check_menu_item_new_with_label (connection_name));
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
@@ -670,7 +679,7 @@
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
g_object_set_data_full (G_OBJECT (item), "connection",
- g_object_ref (applet_settings),
+ g_object_ref (exported),
(GDestroyNotify) g_object_unref);
if (nm_client_get_state (applet->nm_client) != NM_STATE_CONNECTED)
@@ -992,14 +1001,14 @@
}
-AppletDbusConnectionSettings *
-applet_get_connection_settings_for_device (NMDevice *device, NMApplet *applet)
+AppletExportedConnection *
+applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet)
{
GSList *iter;
for (iter = applet->active_connections; iter; iter = g_slist_next (iter)) {
NMClientActiveConnection * act_con = (NMClientActiveConnection *) iter->data;
- AppletDbusConnectionSettings *connection_settings;
+ AppletExportedConnection *exported;
if (strcmp (act_con->service_name, NM_DBUS_SERVICE_USER_SETTINGS) != 0)
continue;
@@ -1007,12 +1016,11 @@
if (!g_slist_find (act_con->devices, device))
continue;
- connection_settings = applet_dbus_settings_user_get_by_dbus_path (APPLET_DBUS_SETTINGS (applet->settings),
- act_con->connection_path);
- if (!connection_settings || !connection_settings->connection)
+ exported = applet_dbus_settings_user_get_by_dbus_path (applet->settings, act_con->connection_path);
+ if (!exported || !nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported)))
continue;
- return connection_settings;
+ return exported;
}
return NULL;
}
@@ -1022,7 +1030,7 @@
NMDeviceState state,
NMApplet *applet)
{
- AppletDbusConnectionSettings *connection_settings;
+ AppletExportedConnection *exported;
NMSettingConnection *s_con;
switch (state) {
@@ -1036,13 +1044,16 @@
/* If the device activation was successful, update the corresponding
* connection object with a current timestamp.
*/
- connection_settings = applet_get_connection_settings_for_device (device, applet);
- if (connection_settings) {
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection_settings->connection,
+ exported = applet_get_exported_connection_for_device (device, applet);
+ if (exported) {
+ NMConnection *connection;
+
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection,
NM_TYPE_SETTING_CONNECTION));
if (s_con && s_con->autoconnect) {
s_con->timestamp = (guint64) time (NULL);
- applet_dbus_connection_settings_save (NM_CONNECTION_SETTINGS (connection_settings));
+ applet_exported_connection_save (exported);
}
}
/* Fall through */
@@ -1351,13 +1362,13 @@
}
static NMDevice *
-find_active_device (AppletDbusConnectionSettings *applet_connection,
+find_active_device (AppletExportedConnection *exported,
NMApplet *applet,
const char **specific_object)
{
GSList *iter;
- g_return_val_if_fail (applet_connection != NULL, NULL);
+ g_return_val_if_fail (exported != NULL, NULL);
g_return_val_if_fail (applet != NULL, NULL);
/* Ensure the active connection list is up-to-date */
@@ -1369,12 +1380,14 @@
*/
for (iter = applet->active_connections; iter; iter = g_slist_next (iter)) {
NMClientActiveConnection *con = (NMClientActiveConnection *) iter->data;
+ NMConnection *connection;
const char *con_path;
if (strcmp (con->service_name, NM_DBUS_SERVICE_USER_SETTINGS))
continue;
- con_path = nm_connection_settings_get_dbus_object_path ((NMConnectionSettings *) applet_connection);
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
+ con_path = nm_connection_get_path (connection);
if (!strcmp (con_path, con->connection_path)) {
*specific_object = con->specific_object;
return NM_DEVICE (con->devices->data);
@@ -1386,7 +1399,7 @@
static void
applet_settings_new_secrets_requested_cb (AppletDbusSettings *settings,
- AppletDbusConnectionSettings *applet_connection,
+ AppletExportedConnection *exported,
const char *setting_name,
const char **hints,
gboolean ask_user,
@@ -1401,11 +1414,10 @@
GError *error = NULL;
const char *specific_object = NULL;
- connection = applet_dbus_connection_settings_get_connection ((NMConnectionSettings *) applet_connection);
+ connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
g_return_if_fail (connection != NULL);
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (applet_connection->connection,
- NM_TYPE_SETTING_CONNECTION));
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_return_if_fail (s_con != NULL);
g_return_if_fail (s_con->type != NULL);
@@ -1416,7 +1428,7 @@
}
/* Find the active device for this connection */
- device = find_active_device (applet_connection, applet, &specific_object);
+ device = find_active_device (exported, applet, &specific_object);
if (!device) {
g_set_error (&error, NM_SETTINGS_ERROR, 1,
"%s.%d (%s): couldn't find details for connection",
Modified: trunk/src/applet.h
==============================================================================
--- trunk/src/applet.h (original)
+++ trunk/src/applet.h Wed Feb 20 22:41:27 2008
@@ -89,7 +89,7 @@
NMAccessPoint *current_ap;
GHashTable *vpn_connections;
- NMSettings * settings;
+ AppletDbusSettings *settings;
GSList * active_connections;
GConfClient * gconf_client;
@@ -178,7 +178,7 @@
NMApplet *applet,
gpointer user_data);
-AppletDbusConnectionSettings *applet_get_connection_settings_for_device (NMDevice *device, NMApplet *applet);
+AppletExportedConnection *applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet);
void applet_do_notify (NMApplet *applet,
NotifyUrgency urgency,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]