[network-manager-applet/rm-userset] applet: port remaining applet pieces to NM 0.9
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/rm-userset] applet: port remaining applet pieces to NM 0.9
- Date: Fri, 14 Jan 2011 21:31:56 +0000 (UTC)
commit 2f521e3817b6078ca4e6008d1c0b6167df3c7030
Author: Dan Williams <dcbw redhat com>
Date: Thu Jan 13 17:29:04 2011 -0600
applet: port remaining applet pieces to NM 0.9
Still need to implement the Agent interfaces.
src/Makefile.am | 2 -
src/applet-dbus-manager.c | 517 ---------------------------------------------
src/applet-dbus-manager.h | 81 -------
src/applet-device-bt.c | 71 +++----
src/applet-device-cdma.c | 91 ++++-----
src/applet-device-gsm.c | 121 +++++------
src/applet-device-wifi.c | 275 ++++++++----------------
src/applet-device-wired.c | 54 +++---
src/applet-dialogs.c | 8 +-
src/applet.c | 386 ++++++++++------------------------
src/applet.h | 28 ++--
src/vpn-password-dialog.c | 23 +--
src/vpn-password-dialog.h | 6 +-
src/wired-dialog.c | 6 +-
src/wired-dialog.h | 6 +-
src/wireless-dialog.c | 112 ++++-------
16 files changed, 423 insertions(+), 1364 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 5ee3db1..2c5e7e8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,8 +25,6 @@ nm_applet_SOURCES = \
main.c \
applet.c \
applet.h \
- applet-dbus-manager.c \
- applet-dbus-manager.h \
vpn-password-dialog.c \
vpn-password-dialog.h \
wired-dialog.h \
diff --git a/src/applet-device-bt.c b/src/applet-device-bt.c
index 29c9a86..b5bbc5e 100644
--- a/src/applet-device-bt.c
+++ b/src/applet-device-bt.c
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2008 Red Hat, Inc.
+ * (C) Copyright 2008 - 2011 Red Hat, Inc.
* (C) Copyright 2008 Novell, Inc.
*/
@@ -35,6 +35,7 @@
#include <nm-setting-gsm.h>
#include <nm-device-bt.h>
#include <nm-utils.h>
+#include <nm-secret-agent.h>
#include "applet.h"
#include "applet-device-bt.h"
@@ -254,7 +255,7 @@ typedef struct {
NMANewSecretsRequestedFunc callback;
gpointer callback_data;
NMApplet *applet;
- NMSettingsConnectionInterface *connection;
+ NMRemoteConnection *connection;
NMActiveConnection *active_connection;
GtkWidget *dialog;
GtkEntry *secret_entry;
@@ -277,26 +278,15 @@ destroy_secrets_dialog (gpointer user_data, GObject *finalized)
}
static void
-update_cb (NMSettingsConnectionInterface *connection,
- GError *error,
- gpointer user_data)
-{
- if (error) {
- g_warning ("%s: failed to update connection: (%d) %s",
- __func__, error->code, error->message);
- }
-}
-
-static void
get_bt_secrets_cb (GtkDialog *dialog,
gint response,
gpointer user_data)
{
NMBtSecretsInfo *info = user_data;
NMSetting *setting;
- GHashTable *settings_hash;
+ GHashTable *settings_hash = NULL;
GHashTable *secrets;
- GError *err = NULL;
+ GError *error = NULL;
/* Got a user response, clear the NMActiveConnection destroy handler for
* this dialog since this function will now take over dialog destruction.
@@ -304,9 +294,9 @@ get_bt_secrets_cb (GtkDialog *dialog,
g_object_weak_unref (G_OBJECT (info->active_connection), destroy_secrets_dialog, info);
if (response != GTK_RESPONSE_OK) {
- g_set_error (&err,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): canceled",
__FILE__, __LINE__, __func__);
goto done;
@@ -314,9 +304,9 @@ get_bt_secrets_cb (GtkDialog *dialog,
setting = nm_connection_get_setting_by_name (NM_CONNECTION (info->connection), info->setting_name);
if (!setting) {
- g_set_error (&err,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): unhandled setting '%s'",
__FILE__, __LINE__, __func__, info->setting_name);
goto done;
@@ -336,9 +326,9 @@ get_bt_secrets_cb (GtkDialog *dialog,
secrets = nm_setting_to_hash (NM_SETTING (setting));
if (!secrets) {
- g_set_error (&err,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): failed to hash setting '%s'.",
__FILE__, __LINE__, __func__,
nm_setting_get_name (NM_SETTING (setting)));
@@ -350,24 +340,13 @@ get_bt_secrets_cb (GtkDialog *dialog,
*/
settings_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify) g_hash_table_destroy);
-
g_hash_table_insert (settings_hash, g_strdup (nm_setting_get_name (NM_SETTING (setting))), secrets);
- info->callback (info->connection, settings_hash, NULL, info->callback_data);
- g_hash_table_destroy (settings_hash);
-
- /* Save the connection back to GConf _after_ hashing it, because
- * saving to GConf might trigger the GConf change notifiers, resulting
- * in the connection being read back in from GConf which clears secrets.
- */
- if (NMA_IS_GCONF_CONNECTION (info->connection))
- nm_settings_connection_interface_update (info->connection, update_cb, NULL);
done:
- if (err) {
- g_warning ("%s", err->message);
- info->callback (info->connection, NULL, err, info->callback_data);
- g_error_free (err);
- }
+ info->callback (info->connection, settings_hash, error, info->callback_data);
+ if (settings_hash)
+ g_hash_table_destroy (settings_hash);
+ g_clear_error (&error);
nm_connection_clear_secrets (NM_CONNECTION (info->connection));
destroy_secrets_dialog (info, NULL);
@@ -375,7 +354,7 @@ get_bt_secrets_cb (GtkDialog *dialog,
static gboolean
bt_get_secrets (NMDevice *device,
- NMSettingsConnectionInterface *connection,
+ NMRemoteConnection *connection,
NMActiveConnection *active_connection,
const char *setting_name,
const char **hints,
@@ -390,8 +369,8 @@ bt_get_secrets (NMDevice *device,
if (!hints || !g_strv_length ((char **) hints)) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): missing secrets hints.",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -402,8 +381,8 @@ bt_get_secrets (NMDevice *device,
widget = applet_mobile_password_dialog_new (device, NM_CONNECTION (connection), &secret_entry);
else {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): unknown secrets hint '%s'.",
__FILE__, __LINE__, __func__, hints[0]);
return FALSE;
@@ -411,8 +390,8 @@ bt_get_secrets (NMDevice *device,
if (!widget || !secret_entry) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): error asking for CDMA secrets.",
__FILE__, __LINE__, __func__);
return FALSE;
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index e4a401b..7b9c7d7 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2008 - 2010 Red Hat, Inc.
+ * (C) Copyright 2008 - 2011 Red Hat, Inc.
*/
#ifdef HAVE_CONFIG_H
@@ -34,6 +34,7 @@
#include <nm-setting-ppp.h>
#include <nm-cdma-device.h>
#include <nm-utils.h>
+#include <nm-secret-agent.h>
#include "applet.h"
#include "applet-device-cdma.h"
@@ -48,6 +49,7 @@ typedef struct {
NMApplet *applet;
NMDevice *device;
+ DBusGConnection *bus;
DBusGProxy *props_proxy;
DBusGProxy *cdma_proxy;
gboolean quality_valid;
@@ -451,7 +453,7 @@ typedef struct {
NMANewSecretsRequestedFunc callback;
gpointer callback_data;
NMApplet *applet;
- NMSettingsConnectionInterface *connection;
+ NMRemoteConnection *connection;
NMActiveConnection *active_connection;
GtkWidget *dialog;
GtkEntry *secret_entry;
@@ -472,26 +474,15 @@ destroy_cdma_dialog (gpointer user_data, GObject *finalized)
}
static void
-update_cb (NMSettingsConnectionInterface *connection,
- GError *error,
- gpointer user_data)
-{
- if (error) {
- g_warning ("%s: failed to update connection: (%d) %s",
- __func__, error->code, error->message);
- }
-}
-
-static void
get_cdma_secrets_cb (GtkDialog *dialog,
gint response,
gpointer user_data)
{
NMCdmaInfo *info = (NMCdmaInfo *) user_data;
NMSettingCdma *setting;
- GHashTable *settings_hash;
+ GHashTable *settings_hash = NULL;
GHashTable *secrets;
- GError *err = NULL;
+ GError *error = NULL;
/* Got a user response, clear the NMActiveConnection destroy handler for
* this dialog since this function will now take over dialog destruction.
@@ -499,11 +490,10 @@ get_cdma_secrets_cb (GtkDialog *dialog,
g_object_weak_unref (G_OBJECT (info->active_connection), destroy_cdma_dialog, info);
if (response != GTK_RESPONSE_OK) {
- g_set_error (&err,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
- "%s.%d (%s): canceled",
- __FILE__, __LINE__, __func__);
+ g_set_error (&error,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
+ "%s.%d (%s): canceled", __FILE__, __LINE__, __func__);
goto done;
}
@@ -511,15 +501,15 @@ get_cdma_secrets_cb (GtkDialog *dialog,
if (!strcmp (info->secret_name, NM_SETTING_CDMA_PASSWORD)) {
g_object_set (setting,
- NM_SETTING_CDMA_PASSWORD, gtk_entry_get_text (info->secret_entry),
- NULL);
+ NM_SETTING_CDMA_PASSWORD, gtk_entry_get_text (info->secret_entry),
+ NULL);
}
secrets = nm_setting_to_hash (NM_SETTING (setting));
if (!secrets) {
- g_set_error (&err,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): failed to hash setting '%s'.",
__FILE__, __LINE__, __func__, nm_setting_get_name (NM_SETTING (setting)));
goto done;
@@ -530,32 +520,21 @@ get_cdma_secrets_cb (GtkDialog *dialog,
*/
settings_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify) g_hash_table_destroy);
-
g_hash_table_insert (settings_hash, g_strdup (nm_setting_get_name (NM_SETTING (setting))), secrets);
- info->callback (info->connection, settings_hash, NULL, info->callback_data);
- g_hash_table_destroy (settings_hash);
-
- /* Save the connection back to GConf _after_ hashing it, because
- * saving to GConf might trigger the GConf change notifiers, resulting
- * in the connection being read back in from GConf which clears secrets.
- */
- if (NMA_IS_GCONF_CONNECTION (info->connection))
- nm_settings_connection_interface_update (info->connection, update_cb, NULL);
done:
- if (err) {
- g_warning ("%s", err->message);
- info->callback (info->connection, NULL, err, info->callback_data);
- g_error_free (err);
- }
-
+ info->callback (info->connection, settings_hash, error, info->callback_data);
+ if (settings_hash)
+ g_hash_table_destroy (settings_hash);
+ g_clear_error (&error);
+
nm_connection_clear_secrets (NM_CONNECTION (info->connection));
destroy_cdma_dialog (info, NULL);
}
static gboolean
cdma_get_secrets (NMDevice *device,
- NMSettingsConnectionInterface *connection,
+ NMRemoteConnection *connection,
NMActiveConnection *active_connection,
const char *setting_name,
const char **hints,
@@ -570,8 +549,8 @@ cdma_get_secrets (NMDevice *device,
if (!hints || !g_strv_length ((char **) hints)) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): missing secrets hints.",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -581,8 +560,8 @@ cdma_get_secrets (NMDevice *device,
widget = applet_mobile_password_dialog_new (device, NM_CONNECTION (connection), &secret_entry);
else {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): unknown secrets hint '%s'.",
__FILE__, __LINE__, __func__, hints[0]);
return FALSE;
@@ -590,8 +569,8 @@ cdma_get_secrets (NMDevice *device,
if (!widget || !secret_entry) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): error asking for CDMA secrets.",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -630,6 +609,8 @@ cdma_device_info_free (gpointer data)
g_object_unref (info->props_proxy);
if (info->cdma_proxy)
g_object_unref (info->cdma_proxy);
+ if (info->bus)
+ dbus_g_connection_unref (info->bus);
if (info->poll_id)
g_source_remove (info->poll_id);
if (info->providers)
@@ -894,18 +875,26 @@ static void
cdma_device_added (NMDevice *device, NMApplet *applet)
{
NMCdmaDevice *cdma = NM_CDMA_DEVICE (device);
- AppletDBusManager *dbus_mgr = applet_dbus_manager_get ();
- DBusGConnection *bus = applet_dbus_manager_get_connection (dbus_mgr);
CdmaDeviceInfo *info;
+ DBusGConnection *bus;
const char *udi;
+ GError *error = NULL;
udi = nm_device_get_udi (device);
if (!udi)
return;
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (!bus) {
+ g_warning ("%s: failed to connect to D-Bus: (%d) %s", __func__, error->code, error->message);
+ g_clear_error (&error);
+ return;
+ }
+
info = g_malloc0 (sizeof (CdmaDeviceInfo));
info->applet = applet;
info->device = device;
+ info->bus = bus;
info->quality_valid = FALSE;
info->providers = nmn_mobile_providers_parse (NULL);
@@ -964,8 +953,6 @@ cdma_device_added (NMDevice *device, NMApplet *applet)
G_TYPE_STRING, MM_DBUS_INTERFACE_MODEM,
G_TYPE_STRING, "Enabled",
G_TYPE_INVALID);
-
- g_object_unref (dbus_mgr);
}
NMADeviceClass *
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index 184297a..f1ecd95 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2008 - 2010 Red Hat, Inc.
+ * (C) Copyright 2008 - 2011 Red Hat, Inc.
* (C) Copyright 2008 Novell, Inc.
*/
@@ -36,6 +36,7 @@
#include <nm-setting-ppp.h>
#include <nm-gsm-device.h>
#include <nm-utils.h>
+#include <nm-secret-agent.h>
#include "applet.h"
#include "applet-device-gsm.h"
@@ -64,6 +65,7 @@ typedef struct {
NMApplet *applet;
NMDevice *device;
+ DBusGConnection *bus;
DBusGProxy *props_proxy;
DBusGProxy *card_proxy;
DBusGProxy *net_proxy;
@@ -499,7 +501,7 @@ typedef struct {
NMANewSecretsRequestedFunc callback;
gpointer callback_data;
NMActiveConnection *active_connection;
- NMSettingsConnectionInterface *connection;
+ NMRemoteConnection *connection;
} NMGsmSecretsInfo;
@@ -517,24 +519,14 @@ secrets_dialog_destroy (gpointer user_data, GObject *finalized)
}
static void
-update_cb (NMSettingsConnectionInterface *connection,
- GError *error,
- gpointer user_data)
-{
- if (error) {
- g_warning ("%s: failed to update connection: (%d) %s",
- __func__, error->code, error->message);
- }
-}
-
-static void
-get_existing_secrets_cb (NMSettingsConnectionInterface *connection,
+get_existing_secrets_cb (NMSecretAgent *agent,
+ NMConnection *connection,
GHashTable *existing_secrets,
GError *secrets_error,
gpointer user_data)
{
NMGsmSecretsInfo *info = (NMGsmSecretsInfo *) user_data;
- GHashTable *settings;
+ GHashTable *settings_hash = NULL;
GError *error = NULL;
gboolean save_secret = FALSE;
const char *new_secret = NULL;
@@ -545,10 +537,10 @@ get_existing_secrets_cb (NMSettingsConnectionInterface *connection,
}
/* Be a bit paranoid */
- if (connection != info->connection) {
+ if (NM_REMOTE_CONNECTION (connection) != info->connection) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): unexpected reply for wrong connection.",
__FILE__, __LINE__, __func__);
goto done;
@@ -567,7 +559,7 @@ get_existing_secrets_cb (NMSettingsConnectionInterface *connection,
const char *setting_name = key;
GHashTable *setting_hash = value;
- /* Keep track of whether or not the user originall saved the secret */
+ /* Keep track of whether or not the user originally saved the secret */
if (!strcmp (setting_name, NM_SETTING_GSM_SETTING_NAME)) {
if (g_hash_table_lookup (setting_hash, info->secret_name))
save_secret = TRUE;
@@ -599,22 +591,20 @@ get_existing_secrets_cb (NMSettingsConnectionInterface *connection,
}
}
- settings = nm_connection_to_hash (NM_CONNECTION (info->connection));
- info->callback (info->connection, settings, NULL, info->callback_data);
- g_hash_table_destroy (settings);
+ settings_hash = nm_connection_to_hash (NM_CONNECTION (info->connection));
+
+ done:
+ info->callback (info->connection, settings_hash, error, info->callback_data);
+ if (settings_hash)
+ g_hash_table_destroy (settings_hash);
+ g_clear_error (&error);
/* Save secrets back to GConf if the user had entered them into the
* connection originally. This lets users enter their secret every time if
* they want.
*/
- if (new_secret && save_secret)
- nm_settings_connection_interface_update (info->connection, update_cb, NULL);
-
- done:
- if (error) {
- g_warning ("%s", error->message);
- info->callback (info->connection, NULL, error, info->callback_data);
- g_clear_error (&error);
+ if (new_secret && save_secret) {
+ /* FIXME: save secret back to the keyring */
}
nm_connection_clear_secrets (NM_CONNECTION (info->connection));
@@ -628,44 +618,37 @@ get_gsm_secrets_cb (GtkDialog *dialog,
{
NMGsmSecretsInfo *info = (NMGsmSecretsInfo *) user_data;
GError *error = NULL;
+ const char *hints[2] = { info->secret_name, NULL };
/* Got a user response, clear the NMActiveConnection destroy handler for
* this dialog since this function will now take over dialog destruction.
*/
g_object_weak_unref (G_OBJECT (info->active_connection), secrets_dialog_destroy, info);
- if (response == GTK_RESPONSE_OK) {
- const char *hints[2] = { info->secret_name, NULL };
-
- /* Get existing connection secrets since NM will want those too */
- if (!nm_settings_connection_interface_get_secrets (info->connection,
- NM_SETTING_GSM_SETTING_NAME,
- (const char **) &hints,
- FALSE,
- get_existing_secrets_cb,
- info)) {
- g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
- "%s.%d (%s): failed to get existing connection secrets",
- __FILE__, __LINE__, __func__);
- }
- } else {
+ if (response != GTK_RESPONSE_OK) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): canceled",
__FILE__, __LINE__, __func__);
- }
- if (error) {
g_warning ("%s", error->message);
info->callback (info->connection, NULL, error, info->callback_data);
g_error_free (error);
nm_connection_clear_secrets (NM_CONNECTION (info->connection));
secrets_dialog_destroy (info, NULL);
+ return;
}
+
+ /* Get existing connection secrets since NM will want those too */
+ nm_secret_agent_get_secrets (info->applet->agent,
+ NM_CONNECTION (info->connection),
+ NM_SETTING_GSM_SETTING_NAME,
+ (const char **) &hints,
+ FALSE,
+ get_existing_secrets_cb,
+ info);
}
static void
@@ -746,7 +729,7 @@ ask_for_pin (NMDevice *device, GtkEntry **out_secret_entry)
static gboolean
gsm_get_secrets (NMDevice *device,
- NMSettingsConnectionInterface *connection,
+ NMRemoteConnection *connection,
NMActiveConnection *active_connection,
const char *setting_name,
const char **hints,
@@ -761,8 +744,8 @@ gsm_get_secrets (NMDevice *device,
if (!hints || !g_strv_length ((char **) hints)) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): missing secrets hints.",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -781,8 +764,8 @@ gsm_get_secrets (NMDevice *device,
widget = applet_mobile_password_dialog_new (device, NM_CONNECTION (connection), &secret_entry);
else {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): unknown secrets hint '%s'.",
__FILE__, __LINE__, __func__, hints[0]);
return FALSE;
@@ -790,8 +773,8 @@ gsm_get_secrets (NMDevice *device,
if (!widget || !secret_entry) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): error asking for GSM secrets.",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -1022,6 +1005,8 @@ gsm_device_info_free (gpointer data)
g_object_unref (info->card_proxy);
if (info->net_proxy)
g_object_unref (info->net_proxy);
+ if (info->bus)
+ dbus_g_connection_unref (info->bus);
if (info->providers)
g_hash_table_destroy (info->providers);
@@ -1417,20 +1402,28 @@ static void
gsm_device_added (NMDevice *device, NMApplet *applet)
{
NMGsmDevice *gsm = NM_GSM_DEVICE (device);
- AppletDBusManager *dbus_mgr = applet_dbus_manager_get ();
- DBusGConnection *bus = applet_dbus_manager_get_connection (dbus_mgr);
GsmDeviceInfo *info;
const char *udi;
+ DBusGConnection *bus;
+ GError *error = NULL;
udi = nm_device_get_udi (device);
if (!udi)
return;
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (!bus) {
+ g_warning ("%s: failed to connect to D-Bus: (%d) %s", __func__, error->code, error->message);
+ g_clear_error (&error);
+ return;
+ }
+
info = g_malloc0 (sizeof (GsmDeviceInfo));
info->applet = applet;
info->device = device;
+ info->bus = bus;
- info->props_proxy = dbus_g_proxy_new_for_name (bus,
+ info->props_proxy = dbus_g_proxy_new_for_name (info->bus,
"org.freedesktop.ModemManager",
udi,
"org.freedesktop.DBus.Properties");
@@ -1440,7 +1433,7 @@ gsm_device_added (NMDevice *device, NMApplet *applet)
return;
}
- info->card_proxy = dbus_g_proxy_new_for_name (bus,
+ info->card_proxy = dbus_g_proxy_new_for_name (info->bus,
"org.freedesktop.ModemManager",
udi,
"org.freedesktop.ModemManager.Modem.Gsm.Card");
@@ -1450,7 +1443,7 @@ gsm_device_added (NMDevice *device, NMApplet *applet)
return;
}
- info->net_proxy = dbus_g_proxy_new_for_name (bus,
+ info->net_proxy = dbus_g_proxy_new_for_name (info->bus,
"org.freedesktop.ModemManager",
udi,
MM_DBUS_INTERFACE_MODEM_GSM_NETWORK);
@@ -1507,8 +1500,6 @@ gsm_device_added (NMDevice *device, NMApplet *applet)
G_TYPE_STRING, MM_DBUS_INTERFACE_MODEM_GSM_NETWORK,
G_TYPE_STRING, "AccessTechnology",
G_TYPE_INVALID);
-
- g_object_unref (dbus_mgr);
}
NMADeviceClass *
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 439994d..d2028f9 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2008 - 2010 Red Hat, Inc.
+ * (C) Copyright 2008 - 2011 Red Hat, Inc.
*/
#ifdef HAVE_CONFIG_H
@@ -39,6 +39,7 @@
#include <nm-device-wifi.h>
#include <nm-setting-8021x.h>
#include <nm-utils.h>
+#include <nm-secret-agent.h>
#include "applet.h"
#include "applet-device-wifi.h"
@@ -870,34 +871,11 @@ out:
}
static void
-add_seen_bssid (NMSettingsConnectionInterface *connection, NMAccessPoint *ap)
-{
- NMSettingWireless *s_wireless;
- const char *bssid;
-
- if (!NMA_GCONF_CONNECTION (connection))
- return;
-
- s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_WIRELESS));
- if (!s_wireless)
- return;
-
- bssid = nm_access_point_get_hw_address (ap);
- if (!bssid || !utils_ether_addr_valid (ether_aton (bssid)))
- return;
-
- if (nm_setting_wireless_add_seen_bssid (s_wireless, bssid)) {
- /* Ignore secrets since we don't have any here and we're just adding a BSSID */
- nma_gconf_connection_update (NMA_GCONF_CONNECTION (connection), TRUE);
- }
-}
-
-static void
notify_active_ap_changed_cb (NMDeviceWifi *device,
GParamSpec *pspec,
NMApplet *applet)
{
- NMSettingsConnectionInterface *connection;
+ NMRemoteConnection *connection;
NMSettingWireless *s_wireless;
NMAccessPoint *new;
const GByteArray *ssid;
@@ -921,8 +899,6 @@ notify_active_ap_changed_cb (NMDeviceWifi *device,
if (!ssid || !nm_utils_same_ssid (nm_setting_wireless_get_ssid (s_wireless), ssid, TRUE))
return;
- add_seen_bssid (connection, new);
-
applet_schedule_update_icon (applet);
}
@@ -1114,8 +1090,8 @@ access_point_removed_cb (NMDeviceWifi *device,
}
static void
-on_new_connection (NMSettingsInterface *settings,
- NMSettingsConnectionInterface *connection,
+on_new_connection (NMRemoteSettings *settings,
+ NMRemoteConnection *connection,
gpointer datap)
{
struct ap_notification_data *data = datap;
@@ -1126,7 +1102,7 @@ static void
free_ap_notification_data (gpointer user_data)
{
struct ap_notification_data *data = user_data;
- NMSettingsInterface *settings = applet_get_settings (data->applet);
+ NMRemoteSettings *settings = applet_get_settings (data->applet);
if (data->id)
g_source_remove (data->id);
@@ -1172,7 +1148,7 @@ wireless_device_added (NMDevice *device, NMApplet *applet)
* when the device is destroyed.
*/
id = g_signal_connect (applet_get_settings (applet),
- NM_SETTINGS_INTERFACE_NEW_CONNECTION,
+ NM_REMOTE_SETTINGS_NEW_CONNECTION,
G_CALLBACK (on_new_connection),
data);
data->new_con_id = id;
@@ -1235,7 +1211,6 @@ wireless_device_state_changed (NMDevice *device,
NMDeviceStateReason reason,
NMApplet *applet)
{
- NMSettingsConnectionInterface *connection;
NMAccessPoint *new = NULL;
char *msg;
char *esc_ssid = NULL;
@@ -1248,18 +1223,6 @@ wireless_device_state_changed (NMDevice *device,
if (new_state != NM_DEVICE_STATE_ACTIVATED)
return;
- if (new) {
- const GByteArray *ssid = nm_access_point_get_ssid (new);
-
- if (ssid)
- esc_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
-
- /* Save this BSSID to seen-bssids list */
- connection = applet_get_exported_connection_for_device (device, applet);
- if (connection)
- add_seen_bssid (connection, new);
- }
-
msg = g_strdup_printf (_("You are now connected to the wireless network '%s'."),
esc_ssid ? esc_ssid : _("(none)"));
applet_do_notify_with_pref (applet, _("Connection Established"),
@@ -1346,14 +1309,6 @@ wireless_get_icon (NMDevice *device,
return pixbuf;
}
-static void
-activate_device_cb (gpointer user_data, const char *path, GError *error)
-{
- if (error)
- nm_warning ("Device Activation failed: %s", error->message);
- applet_schedule_update_icon (NM_APPLET (user_data));
-}
-
static gboolean
wireless_dialog_close (gpointer user_data)
{
@@ -1384,15 +1339,28 @@ nag_dialog_response_cb (GtkDialog *nag_dialog,
}
}
+
static void
-update_cb (NMSettingsConnectionInterface *connection,
- GError *error,
- gpointer user_data)
+activate_existing_cb (NMClient *client,
+ const char *active_path,
+ GError *error,
+ gpointer user_data)
{
- if (error) {
- g_warning ("%s: failed to update connection: (%d) %s",
- __func__, error->code, error->message);
- }
+ if (error)
+ g_warning ("Failed to activate connection: (%d) %s", error->code, error->message);
+ applet_schedule_update_icon (NM_APPLET (user_data));
+}
+
+static void
+activate_new_cb (NMClient *client,
+ const char *connection_path,
+ const char *active_path,
+ GError *error,
+ gpointer user_data)
+{
+ if (error)
+ g_warning ("Failed to add new connection: (%d) %s", error->code, error->message);
+ applet_schedule_update_icon (NM_APPLET (user_data));
}
static void
@@ -1405,7 +1373,7 @@ wireless_dialog_response_cb (GtkDialog *foo,
NMConnection *connection = NULL, *fuzzy_match = NULL;
NMDevice *device = NULL;
NMAccessPoint *ap = NULL;
- const char *service = NM_DBUS_SERVICE_USER_SETTINGS;
+ GSList *all, *iter;
if (response != GTK_RESPONSE_OK)
goto done;
@@ -1433,110 +1401,57 @@ wireless_dialog_response_cb (GtkDialog *foo,
g_assert (connection);
g_assert (device);
- /* If it's a system connection we just need to tell NM to activate it */
- if (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) {
- service = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
- goto activate;
+ /* Find a similar connection and use that instead */
+ all = applet_get_all_connections (applet);
+ for (iter = all; iter; iter = g_slist_next (iter)) {
+ if (nm_connection_compare (connection,
+ NM_CONNECTION (iter->data),
+ (NM_SETTING_COMPARE_FLAG_FUZZY | NM_SETTING_COMPARE_FLAG_IGNORE_ID))) {
+ fuzzy_match = NM_CONNECTION (iter->data);
+ break;
+ }
}
+ g_slist_free (all);
- if (NMA_IS_GCONF_CONNECTION (connection)) {
- /* Not a new or system connection, save the updated settings to GConf */
- nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (connection),
- update_cb,
- NULL);
+ if (fuzzy_match) {
+ nm_client_activate_connection (applet->nm_client,
+ nm_connection_get_path (fuzzy_match),
+ device,
+ ap ? nm_object_get_path (NM_OBJECT (ap)) : NULL,
+ activate_existing_cb,
+ applet);
} else {
- GSList *all, *iter;
-
- /* Find a similar connection and use that instead */
- all = applet_get_all_connections (applet);
- for (iter = all; iter; iter = g_slist_next (iter)) {
- if (nm_connection_compare (connection,
- NM_CONNECTION (iter->data),
- (NM_SETTING_COMPARE_FLAG_FUZZY | NM_SETTING_COMPARE_FLAG_IGNORE_ID))) {
- fuzzy_match = g_object_ref (NM_CONNECTION (iter->data));
- break;
+ NMSetting *s_con;
+ NMSettingWireless *s_wifi = NULL;
+ const char *mode = NULL;
+
+ /* Entirely new connection */
+
+ /* Don't autoconnect adhoc networks by default for now */
+ s_wifi = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
+ if (s_wifi)
+ mode = nm_setting_wireless_get_mode (s_wifi);
+ if (g_strcmp0 (mode, "adhoc") == 0) {
+ s_con = nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+ if (!s_con) {
+ s_con = nm_setting_connection_new ();
+ nm_connection_add_setting (connection, s_con);
}
+ g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NULL);
}
- g_slist_free (all);
-
- if (fuzzy_match) {
- if (nm_connection_get_scope (fuzzy_match) == NM_CONNECTION_SCOPE_SYSTEM) {
- // FIXME: do something other than just use the system connection?
- } else {
- NMSettingWirelessSecurity *s_wireless_sec;
-
- /* Copy secrets & wireless security */
- s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
- if (s_wireless_sec) {
- GHashTable *hash;
- NMSetting *dup_setting;
-
- hash = nm_setting_to_hash (NM_SETTING (s_wireless_sec));
- dup_setting = nm_setting_new_from_hash (NM_TYPE_SETTING_WIRELESS_SECURITY, hash);
- g_hash_table_destroy (hash);
- nm_connection_add_setting (fuzzy_match, dup_setting);
- }
- }
-
- /* Balance nma_wireless_dialog_get_connection() */
- g_object_unref (connection);
- connection = g_object_ref (fuzzy_match);
- } else {
- /* Entirely new connection */
- NMAGConfConnection *new_gconf_connection;
- NMSettingConnection *s_con;
- char *id;
-
- /* Update a new connection's name and autoconnect status */
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- id = (char *) nm_setting_connection_get_id (s_con);
- if (!id) {
- NMSettingWireless *s_wireless;
- const GByteArray *ssid;
- const char *mode;
-
- s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
- ssid = nm_setting_wireless_get_ssid (s_wireless);
-
- id = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
- g_object_set (s_con, NM_SETTING_CONNECTION_ID, id, NULL);
- g_free (id);
-
- // FIXME: don't autoconnect until the connection is successful at least once
- /* Don't autoconnect adhoc networks by default for now */
- mode = nm_setting_wireless_get_mode (s_wireless);
- if (!mode || !strcmp (mode, "infrastructure"))
- g_object_set (s_con, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL);
- }
-
- /* Export it over D-Bus */
- new_gconf_connection = nma_gconf_settings_add_connection (applet->gconf_settings, connection);
- if (!new_gconf_connection) {
- nm_warning ("Couldn't create new network connection.");
- goto done;
- }
-
- /* Balance nma_wireless_dialog_get_connection() */
- g_object_unref (connection);
- connection = g_object_ref (new_gconf_connection);
- }
+ nm_client_add_and_activate_connection (applet->nm_client,
+ connection,
+ device,
+ ap ? nm_object_get_path (NM_OBJECT (ap)) : NULL,
+ activate_new_cb,
+ applet);
}
-activate:
- nm_client_activate_connection (applet->nm_client,
- service,
- nm_connection_get_path (connection),
- device,
- ap ? nm_object_get_path (NM_OBJECT (ap)) : NULL,
- activate_device_cb,
- applet);
-
-done:
/* Balance nma_wireless_dialog_get_connection() */
- if (connection)
- g_object_unref (connection);
+ g_object_unref (connection);
+done:
gtk_widget_hide (GTK_WIDGET (dialog));
gtk_widget_destroy (GTK_WIDGET (dialog));
}
@@ -1579,8 +1494,8 @@ add_one_setting (GHashTable *settings,
g_hash_table_insert (settings, g_strdup (nm_setting_get_name (setting)), secrets);
} else {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): failed to hash setting '%s'.",
__FILE__, __LINE__, __func__, nm_setting_get_name (setting));
}
@@ -1649,8 +1564,8 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
if (response != GTK_RESPONSE_OK) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_USER_CANCELED,
"%s.%d (%s): canceled",
__FILE__, __LINE__, __func__);
goto done;
@@ -1659,8 +1574,8 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
connection = nma_wireless_dialog_get_connection (dialog, &device, NULL);
if (!connection) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): couldn't get connection from wireless dialog.",
__FILE__, __LINE__, __func__);
goto done;
@@ -1670,8 +1585,8 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
if (!s_wireless_sec) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INVALID_CONNECTION,
"%s.%d (%s): requested setting '802-11-wireless-security'"
" didn't exist in the connection.",
__FILE__, __LINE__, __func__);
@@ -1685,8 +1600,8 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
g_free, (GDestroyNotify) g_hash_table_destroy);
if (!settings) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): not enough memory to return secrets.",
__FILE__, __LINE__, __func__);
goto done;
@@ -1708,8 +1623,8 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
if (!s_8021x) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INVALID_CONNECTION,
"%s.%d (%s): requested setting '802-1x' didn't"
" exist in the connection.",
__FILE__, __LINE__, __func__);
@@ -1726,17 +1641,7 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
if (!add_one_setting (settings, connection, NM_SETTING (s_wireless_sec), &error))
goto done;
- info->callback (NM_SETTINGS_CONNECTION_INTERFACE (connection), settings, NULL, info->callback_data);
-
- /* Save the connection back to GConf _after_ hashing it, because
- * saving to GConf might trigger the GConf change notifiers, resulting
- * in the connection being read back in from GConf which clears secrets.
- */
- if (NMA_IS_GCONF_CONNECTION (connection)) {
- nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (connection),
- update_cb,
- NULL);
- }
+ info->callback (NM_REMOTE_CONNECTION (connection), settings, NULL, info->callback_data);
done:
if (settings)
@@ -1744,7 +1649,7 @@ done:
if (error) {
g_warning ("%s", error->message);
- info->callback (NM_SETTINGS_CONNECTION_INTERFACE (connection), NULL, error, info->callback_data);
+ info->callback (NM_REMOTE_CONNECTION (connection), NULL, error, info->callback_data);
g_error_free (error);
}
@@ -1756,7 +1661,7 @@ done:
static gboolean
wireless_get_secrets (NMDevice *device,
- NMSettingsConnectionInterface *connection,
+ NMRemoteConnection *connection,
NMActiveConnection *active_connection,
const char *setting_name,
const char **hints,
@@ -1771,8 +1676,8 @@ wireless_get_secrets (NMDevice *device,
if (!setting_name || !active_connection) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): setting name and active connection object required",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -1781,8 +1686,8 @@ wireless_get_secrets (NMDevice *device,
specific_object = nm_active_connection_get_specific_object (active_connection);
if (!specific_object) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): could not determine AP for specific object",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -1794,8 +1699,8 @@ wireless_get_secrets (NMDevice *device,
info->dialog = nma_wireless_dialog_new (applet, NM_CONNECTION (connection), device, ap);
if (!info->dialog) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SECRET_AGENT_ERROR,
+ NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
"%s.%d (%s): couldn't display secrets UI",
__FILE__, __LINE__, __func__);
g_free (info);
diff --git a/src/applet-device-wired.c b/src/applet-device-wired.c
index c1b0173..31f0c95 100644
--- a/src/applet-device-wired.c
+++ b/src/applet-device-wired.c
@@ -329,7 +329,7 @@ typedef struct {
GtkWidget *ok_button;
NMApplet *applet;
- NMSettingsConnectionInterface *connection;
+ NMRemoteConnection *connection;
NMANewSecretsRequestedFunc callback;
gpointer callback_data;
@@ -403,7 +403,7 @@ pppoe_info_new (GtkBuilder *builder,
NMApplet *applet,
NMANewSecretsRequestedFunc callback,
gpointer callback_data,
- NMSettingsConnectionInterface *connection,
+ NMRemoteConnection *connection,
NMActiveConnection *active_connection)
{
NMPppoeInfo *info;
@@ -450,7 +450,7 @@ destroy_pppoe_dialog (gpointer data, GObject *finalized)
}
static void
-update_cb (NMSettingsConnectionInterface *connection,
+update_cb (NMRemoteConnection *connection,
GError *error,
gpointer user_data)
{
@@ -476,8 +476,8 @@ get_pppoe_secrets_cb (GtkDialog *dialog,
if (response != GTK_RESPONSE_OK) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED,
+ 0,
+ 0,
"%s.%d (%s): canceled",
__FILE__, __LINE__, __func__);
goto done;
@@ -489,8 +489,8 @@ get_pppoe_secrets_cb (GtkDialog *dialog,
secrets = nm_setting_to_hash (setting);
if (!secrets) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ 0,
+ 0,
"%s.%d (%s): failed to hash setting '%s'.",
__FILE__, __LINE__, __func__, nm_setting_get_name (setting));
goto done;
@@ -510,7 +510,7 @@ get_pppoe_secrets_cb (GtkDialog *dialog,
* saving to GConf might trigger the GConf change notifiers, resulting
* in the connection being read back in from GConf which clears secrets.
*/
- nm_settings_connection_interface_update (info->connection, update_cb, NULL);
+ nm_remote_connection_commit_changes (info->connection, update_cb, NULL);
done:
if (error) {
@@ -536,7 +536,7 @@ show_password_toggled (GtkToggleButton *button, gpointer user_data)
static gboolean
pppoe_get_secrets (NMDevice *device,
- NMSettingsConnectionInterface *connection,
+ NMRemoteConnection *connection,
NMActiveConnection *active_connection,
const char *setting_name,
NMANewSecretsRequestedFunc callback,
@@ -554,8 +554,8 @@ pppoe_get_secrets (NMDevice *device,
{
g_warning ("Couldn't load builder file: %s", (*error)->message);
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ 0,
+ 0,
"%s.%d (%s): couldn't display secrets UI",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -623,7 +623,7 @@ get_8021x_secrets_cb (GtkDialog *dialog,
gpointer user_data)
{
NM8021xInfo *info = user_data;
- NMSettingsConnectionInterface *connection = NULL;
+ NMRemoteConnection *connection = NULL;
NMSetting *setting;
GHashTable *settings_hash;
GHashTable *secrets;
@@ -636,8 +636,8 @@ get_8021x_secrets_cb (GtkDialog *dialog,
if (response != GTK_RESPONSE_OK) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED,
+ 0,
+ 0,
"%s.%d (%s): canceled",
__FILE__, __LINE__, __func__);
goto done;
@@ -646,8 +646,8 @@ get_8021x_secrets_cb (GtkDialog *dialog,
connection = nma_wired_dialog_get_connection (info->dialog);
if (!connection) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ 0,
+ 0,
"%s.%d (%s): couldn't get connection from wired dialog.",
__FILE__, __LINE__, __func__);
goto done;
@@ -656,8 +656,8 @@ get_8021x_secrets_cb (GtkDialog *dialog,
setting = nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_802_1X);
if (!setting) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
+ 0,
+ 0,
"%s.%d (%s): requested setting '802-1x' didn't"
" exist in the connection.",
__FILE__, __LINE__, __func__);
@@ -667,8 +667,8 @@ get_8021x_secrets_cb (GtkDialog *dialog,
secrets = nm_setting_to_hash (setting);
if (!secrets) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ 0,
+ 0,
"%s.%d (%s): failed to hash setting '%s'.",
__FILE__, __LINE__, __func__, nm_setting_get_name (setting));
goto done;
@@ -688,7 +688,7 @@ get_8021x_secrets_cb (GtkDialog *dialog,
* saving to GConf might trigger the GConf change notifiers, resulting
* in the connection being read back in from GConf which clears secrets.
*/
- nm_settings_connection_interface_update (connection, update_cb, NULL);
+ nm_remote_connection_commit_changes (connection, update_cb, NULL);
done:
if (error) {
@@ -705,7 +705,7 @@ done:
static gboolean
nm_8021x_get_secrets (NMDevice *device,
- NMSettingsConnectionInterface *connection,
+ NMRemoteConnection *connection,
NMActiveConnection *active_connection,
const char *setting_name,
NMANewSecretsRequestedFunc callback,
@@ -722,8 +722,8 @@ nm_8021x_get_secrets (NMDevice *device,
device);
if (!dialog) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ 0,
+ 0,
"%s.%d (%s): couldn't display secrets UI",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -752,7 +752,7 @@ nm_8021x_get_secrets (NMDevice *device,
static gboolean
wired_get_secrets (NMDevice *device,
- NMSettingsConnectionInterface *connection,
+ NMRemoteConnection *connection,
NMActiveConnection *active_connection,
const char *setting_name,
const char **hints,
@@ -768,8 +768,8 @@ wired_get_secrets (NMDevice *device,
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION));
if (!s_con) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
+ 0,
+ 0,
"%s.%d (%s): Invalid connection",
__FILE__, __LINE__, __func__);
return FALSE;
diff --git a/src/applet-dialogs.c b/src/applet-dialogs.c
index 2d31413..4fe0a89 100644
--- a/src/applet-dialogs.c
+++ b/src/applet-dialogs.c
@@ -144,12 +144,8 @@ get_connection_for_active (NMApplet *applet, NMActiveConnection *active)
{
GSList *list, *iter;
NMConnection *connection = NULL;
- NMConnectionScope scope;
const char *path;
- scope = nm_active_connection_get_scope (active);
- g_return_val_if_fail (scope != NM_CONNECTION_SCOPE_UNKNOWN, NULL);
-
path = nm_active_connection_get_connection (active);
g_return_val_if_fail (path != NULL, NULL);
@@ -157,13 +153,11 @@ get_connection_for_active (NMApplet *applet, NMActiveConnection *active)
for (iter = list; iter; iter = g_slist_next (iter)) {
NMConnection *candidate = NM_CONNECTION (iter->data);
- if ( (nm_connection_get_scope (candidate) == scope)
- && !strcmp (nm_connection_get_path (candidate), path)) {
+ if (!strcmp (nm_connection_get_path (candidate), path)) {
connection = candidate;
break;
}
}
-
g_slist_free (list);
return connection;
diff --git a/src/applet.c b/src/applet.c
index 9247638..eb5ee6f 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright (C) 2004 - 2010 Red Hat, Inc.
+ * Copyright (C) 2004 - 2011 Red Hat, Inc.
* Copyright (C) 2005 - 2008 Novell, Inc.
*
* This applet used the GNOME Wireless Applet as a skeleton to build from.
@@ -39,6 +39,9 @@
#include <unistd.h>
#include <sys/socket.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
#include <NetworkManagerVPN.h>
#include <nm-device-ethernet.h>
#include <nm-device-wifi.h>
@@ -65,7 +68,6 @@
#include "applet-device-bt.h"
#include "applet-dialogs.h"
#include "vpn-password-dialog.h"
-#include "applet-dbus-manager.h"
#include "utils.h"
#include "gconf-helpers.h"
@@ -175,17 +177,16 @@ applet_get_default_active_connection (NMApplet *applet, NMDevice **device)
return default_ac;
}
-NMSettingsInterface *
+NMRemoteSettings *
applet_get_settings (NMApplet *applet)
{
- return NM_SETTINGS_INTERFACE (applet->gconf_settings);
+ return applet->settings;
}
GSList *
applet_get_all_connections (NMApplet *applet)
{
- return g_slist_concat (nm_settings_interface_list_connections (NM_SETTINGS_INTERFACE (applet->system_settings)),
- nm_settings_interface_list_connections (NM_SETTINGS_INTERFACE (applet->gconf_settings)));
+ return nm_remote_settings_list_connections (applet->settings);
}
static NMConnection *
@@ -193,12 +194,8 @@ applet_get_connection_for_active (NMApplet *applet, NMActiveConnection *active)
{
GSList *list, *iter;
NMConnection *connection = NULL;
- NMConnectionScope scope;
const char *path;
- scope = nm_active_connection_get_scope (active);
- g_return_val_if_fail (scope != NM_CONNECTION_SCOPE_UNKNOWN, NULL);
-
path = nm_active_connection_get_connection (active);
g_return_val_if_fail (path != NULL, NULL);
@@ -206,13 +203,11 @@ applet_get_connection_for_active (NMApplet *applet, NMActiveConnection *active)
for (iter = list; iter; iter = g_slist_next (iter)) {
NMConnection *candidate = NM_CONNECTION (iter->data);
- if ( (nm_connection_get_scope (candidate) == scope)
- && !strcmp (nm_connection_get_path (candidate), path)) {
+ if (!strcmp (nm_connection_get_path (candidate), path)) {
connection = candidate;
break;
}
}
-
g_slist_free (list);
return connection;
@@ -224,10 +219,6 @@ applet_get_active_for_connection (NMApplet *applet, NMConnection *connection)
const GPtrArray *active_list;
int i;
const char *cpath;
- NMConnectionScope scope;
-
- scope = nm_connection_get_scope (connection);
- g_return_val_if_fail (scope != NM_CONNECTION_SCOPE_UNKNOWN, NULL);
cpath = nm_connection_get_path (connection);
g_return_val_if_fail (cpath != NULL, NULL);
@@ -237,9 +228,7 @@ applet_get_active_for_connection (NMApplet *applet, NMConnection *connection)
NMActiveConnection *active = NM_ACTIVE_CONNECTION (g_ptr_array_index (active_list, i));
const char *active_cpath = nm_active_connection_get_connection (active);
- if ( (nm_active_connection_get_scope (active) == scope)
- && active_cpath
- && !strcmp (active_cpath, cpath))
+ if (active_cpath && !strcmp (active_cpath, cpath))
return active;
}
return NULL;
@@ -266,26 +255,11 @@ get_device_class (NMDevice *device, NMApplet *applet)
return NULL;
}
-static gboolean
-is_system_connection (NMConnection *connection)
-{
- return (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) ? TRUE : FALSE;
-}
-
-static void
-activate_connection_cb (gpointer user_data, const char *path, GError *error)
-{
- if (error)
- nm_warning ("Connection activation failed: %s", error->message);
-
- applet_schedule_update_icon (NM_APPLET (user_data));
-}
-
typedef struct {
NMApplet *applet;
NMDevice *device;
char *specific_object;
- gpointer dclass_data;
+ NMConnection *connection;
} AppletItemActivateInfo;
static void
@@ -296,19 +270,32 @@ applet_item_activate_info_destroy (AppletItemActivateInfo *info)
if (info->device)
g_object_unref (info->device);
g_free (info->specific_object);
+ if (info->connection)
+ g_object_unref (info->connection);
memset (info, 0, sizeof (AppletItemActivateInfo));
g_free (info);
}
static void
-applet_menu_item_activate_helper_part2 (NMConnection *connection,
- gboolean auto_created,
- gboolean canceled,
- gpointer user_data)
+add_and_activate_cb (NMClient *client,
+ const char *connection_path,
+ const char *active_path,
+ GError *error,
+ gpointer user_data)
+{
+ if (error)
+ nm_warning ("Failed to add/activate connection: (%d) %s", error->code, error->message);
+
+ applet_schedule_update_icon (NM_APPLET (user_data));
+}
+
+static void
+applet_menu_item_activate_helper_new_connection (NMConnection *connection,
+ gboolean auto_created,
+ gboolean canceled,
+ gpointer user_data)
{
AppletItemActivateInfo *info = user_data;
- const char *con_path;
- gboolean is_system = FALSE;
if (canceled) {
applet_item_activate_info_destroy (info);
@@ -317,44 +304,16 @@ applet_menu_item_activate_helper_part2 (NMConnection *connection,
g_return_if_fail (connection != NULL);
- if (!auto_created)
- is_system = is_system_connection (connection);
- else {
- NMAGConfConnection *exported;
-
- exported = nma_gconf_settings_add_connection (info->applet->gconf_settings, connection);
- if (!exported) {
- NMADeviceClass *dclass = get_device_class (info->device, info->applet);
-
- /* If the setting isn't valid, because it needs more authentication
- * or something, ask the user for it.
- */
-
- g_assert (dclass);
- nm_warning ("Invalid connection; asking for more information.");
- if (dclass->get_more_info)
- dclass->get_more_info (info->device, connection, info->applet, info->dclass_data);
- g_object_unref (connection);
+ /* Ask NM to add the new connection and activate it; NM will fill in the
+ * missing details based on the specific object and the device.
+ */
+ nm_client_add_and_activate_connection (info->applet->nm_client,
+ connection,
+ info->device,
+ info->specific_object,
+ add_and_activate_cb,
+ info->applet);
- applet_item_activate_info_destroy (info);
- return;
- }
- g_object_unref (connection);
- connection = NM_CONNECTION (exported);
- }
-
- g_assert (connection);
- con_path = nm_connection_get_path (connection);
- g_assert (con_path);
-
- /* Finally, tell NM to activate the connection */
- nm_client_activate_connection (info->applet->nm_client,
- is_system ? NM_DBUS_SERVICE_SYSTEM_SETTINGS : NM_DBUS_SERVICE_USER_SETTINGS,
- con_path,
- info->device,
- info->specific_object,
- activate_connection_cb,
- info->applet);
applet_item_activate_info_destroy (info);
}
@@ -378,6 +337,17 @@ applet_menu_item_disconnect_helper (NMDevice *device,
nm_device_disconnect (device, disconnect_cb, NULL);
}
+static void
+activate_connection_cb (NMClient *client,
+ const char *path,
+ GError *error,
+ gpointer user_data)
+{
+ if (error)
+ nm_warning ("Connection activation failed: %s", error->message);
+
+ applet_schedule_update_icon (NM_APPLET (user_data));
+}
void
applet_menu_item_activate_helper (NMDevice *device,
@@ -391,26 +361,33 @@ applet_menu_item_activate_helper (NMDevice *device,
g_return_if_fail (NM_IS_DEVICE (device));
- info = g_malloc0 (sizeof (AppletItemActivateInfo));
- info->applet = applet;
- info->specific_object = g_strdup (specific_object);
- info->device = g_object_ref (device);
- info->dclass_data = dclass_data;
-
if (connection) {
- applet_menu_item_activate_helper_part2 (connection, FALSE, FALSE, info);
+ /* If the menu item had an associated connection already, just tell
+ * NM to activate that connection.
+ */
+ nm_client_activate_connection (applet->nm_client,
+ nm_connection_get_path (connection),
+ device,
+ specific_object,
+ activate_connection_cb,
+ applet);
return;
}
- dclass = get_device_class (device, applet);
-
- /* If no connection was passed in, ask the device class to create a new
+ /* If no connection was given, ask the device class to create a new
* default connection for this device type. This could be a wizard,
* and thus take a while.
*/
+
+ info = g_malloc0 (sizeof (AppletItemActivateInfo));
+ info->applet = applet;
+ info->specific_object = g_strdup (specific_object);
+ info->device = g_object_ref (device);
+
+ dclass = get_device_class (device, applet);
g_assert (dclass);
if (!dclass->new_auto_connection (device, dclass_data,
- applet_menu_item_activate_helper_part2,
+ applet_menu_item_activate_helper_new_connection,
info)) {
nm_warning ("Couldn't create default connection.");
applet_item_activate_info_destroy (info);
@@ -761,30 +738,6 @@ applet_is_any_vpn_activating (NMApplet *applet)
return FALSE;
}
-static void
-update_connection_timestamp (NMActiveConnection *active,
- NMConnection *connection,
- NMApplet *applet)
-{
- NMSettingsConnectionInterface *gconf_connection;
- NMSettingConnection *s_con;
-
- if (nm_active_connection_get_scope (active) != NM_CONNECTION_SCOPE_USER)
- return;
-
- gconf_connection = nm_settings_interface_get_connection_by_path (NM_SETTINGS_INTERFACE (applet->gconf_settings),
- nm_connection_get_path (connection));
- if (!gconf_connection || !NMA_IS_GCONF_CONNECTION (gconf_connection))
- return;
-
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- g_assert (s_con);
-
- g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL), NULL);
- /* Ignore secrets since we're just updating the timestamp */
- nma_gconf_connection_update (NMA_GCONF_CONNECTION (gconf_connection), TRUE);
-}
-
static char *
make_vpn_failure_message (NMVPNConnection *vpn,
NMVPNConnectionStateReason reason,
@@ -865,7 +818,6 @@ vpn_connection_state_changed (NMVPNConnection *vpn,
gpointer user_data)
{
NMApplet *applet = NM_APPLET (user_data);
- NMConnection *connection;
const char *banner;
char *title = NULL, *msg;
gboolean device_activating, vpn_activating;
@@ -894,10 +846,6 @@ vpn_connection_state_changed (NMVPNConnection *vpn,
applet_do_notify (applet, NOTIFY_URGENCY_LOW, title, msg,
"gnome-lockscreen", NULL, NULL, NULL, NULL);
g_free (msg);
-
- connection = applet_get_connection_for_active (applet, NM_ACTIVE_CONNECTION (vpn));
- if (connection)
- update_connection_timestamp (NM_ACTIVE_CONNECTION (vpn), connection, applet);
break;
case NM_VPN_CONNECTION_STATE_FAILED:
title = _("VPN Connection Failed");
@@ -947,7 +895,10 @@ typedef struct {
} VPNActivateInfo;
static void
-activate_vpn_cb (gpointer user_data, const char *path, GError *error)
+activate_vpn_cb (NMClient *client,
+ const char *path,
+ GError *error,
+ gpointer user_data)
{
VPNActivateInfo *info = (VPNActivateInfo *) user_data;
char *title, *msg, *name;
@@ -990,7 +941,6 @@ nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data)
NMSettingConnection *s_con;
NMActiveConnection *active;
NMDevice *device = NULL;
- gboolean is_system;
active = applet_get_default_active_connection (applet, &device);
if (!active || !device) {
@@ -1014,9 +964,7 @@ nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data)
info->vpn_name = g_strdup (nm_setting_connection_get_id (s_con));
/* Connection inactive, activate */
- is_system = is_system_connection (connection);
nm_client_activate_connection (applet->nm_client,
- is_system ? NM_DBUS_SERVICE_SYSTEM_SETTINGS : NM_DBUS_SERVICE_USER_SETTINGS,
nm_connection_get_path (connection),
device,
nm_object_get_path (NM_OBJECT (active)),
@@ -1222,32 +1170,22 @@ applet_find_active_connection_for_device (NMDevice *device,
active_connections = nm_client_get_active_connections (applet->nm_client);
for (i = 0; active_connections && (i < active_connections->len); i++) {
- NMSettingsConnectionInterface *tmp;
- NMSettingsInterface *settings = NULL;
+ NMRemoteConnection *tmp;
NMActiveConnection *active;
- const char *service_name;
const char *connection_path;
const GPtrArray *devices;
active = NM_ACTIVE_CONNECTION (g_ptr_array_index (active_connections, i));
devices = nm_active_connection_get_devices (active);
- service_name = nm_active_connection_get_service_name (active);
connection_path = nm_active_connection_get_connection (active);
- if (!devices || !service_name || !connection_path)
+ if (!devices || !connection_path)
continue;
if (!nm_g_ptr_array_contains (devices, device))
continue;
- if (!strcmp (service_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS))
- settings = NM_SETTINGS_INTERFACE (applet->system_settings);
- else if (!strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS))
- settings = NM_SETTINGS_INTERFACE (applet->gconf_settings);
- else
- g_assert_not_reached ();
-
- tmp = nm_settings_interface_get_connection_by_path (settings, connection_path);
+ tmp = nm_remote_settings_get_connection_by_path (applet->settings, connection_path);
if (tmp) {
connection = NM_CONNECTION (tmp);
if (out_active)
@@ -1996,7 +1934,7 @@ foo_set_icon (NMApplet *applet, GdkPixbuf *pixbuf, guint32 layer)
}
-NMSettingsConnectionInterface *
+NMRemoteConnection *
applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet)
{
const GPtrArray *active_connections;
@@ -2005,8 +1943,7 @@ applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet)
active_connections = nm_client_get_active_connections (applet->nm_client);
for (i = 0; active_connections && (i < active_connections->len); i++) {
NMActiveConnection *active;
- NMSettingsConnectionInterface *connection;
- const char *service_name;
+ NMRemoteConnection *connection;
const char *connection_path;
const GPtrArray *devices;
@@ -2015,18 +1952,14 @@ applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet)
continue;
devices = nm_active_connection_get_devices (active);
- service_name = nm_active_connection_get_service_name (active);
connection_path = nm_active_connection_get_connection (active);
- if (!devices || !service_name || !connection_path)
- continue;
-
- if (strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS) != 0)
+ if (!devices || !connection_path)
continue;
if (!nm_g_ptr_array_contains (devices, device))
continue;
- connection = nm_settings_interface_get_connection_by_path (NM_SETTINGS_INTERFACE (applet->gconf_settings), connection_path);
+ connection = nm_remote_settings_get_connection_by_path (applet->settings, connection_path);
if (connection)
return connection;
}
@@ -2041,8 +1974,6 @@ applet_common_device_state_changed (NMDevice *device,
NMApplet *applet)
{
gboolean device_activating = FALSE, vpn_activating = FALSE;
- NMConnection *connection;
- NMActiveConnection *active = NULL;
device_activating = applet_is_any_device_activating (applet);
vpn_activating = applet_is_any_vpn_activating (applet);
@@ -2058,13 +1989,6 @@ applet_common_device_state_changed (NMDevice *device,
device_activating = TRUE;
break;
case NM_DEVICE_STATE_ACTIVATED:
- /* If the device activation was successful, update the corresponding
- * connection object with a current timestamp.
- */
- connection = applet_find_active_connection_for_device (device, applet, &active);
- if (connection && (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_USER))
- update_connection_timestamp (active, connection, applet);
- break;
default:
break;
}
@@ -2242,7 +2166,6 @@ foo_client_setup (NMApplet *applet)
applet->permissions[NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK] = nm_client_get_permission_result (applet->nm_client, NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK);
applet->permissions[NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI] = nm_client_get_permission_result (applet->nm_client, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI);
applet->permissions[NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN] = nm_client_get_permission_result (applet->nm_client, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN);
- applet->permissions[NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS] = nm_client_get_permission_result (applet->nm_client, NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS);
if (nm_client_get_manager_running (applet->nm_client))
g_idle_add (foo_set_initial_state, applet);
@@ -2370,12 +2293,10 @@ out:
static char *
get_tip_for_vpn (NMActiveConnection *active, NMVPNConnectionState state, NMApplet *applet)
{
- NMConnectionScope scope;
char *tip = NULL;
const char *path, *id = NULL;
GSList *iter, *list;
- scope = nm_active_connection_get_scope (active);
path = nm_active_connection_get_connection (active);
g_return_val_if_fail (path != NULL, NULL);
@@ -2384,8 +2305,7 @@ get_tip_for_vpn (NMActiveConnection *active, NMVPNConnectionState state, NMApple
NMConnection *candidate = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
- if ( (nm_connection_get_scope (candidate) == scope)
- && !strcmp (nm_connection_get_path (candidate), path)) {
+ if (!strcmp (nm_connection_get_path (candidate), path)) {
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION));
id = nm_setting_connection_get_id (s_con);
break;
@@ -2528,8 +2448,9 @@ applet_schedule_update_icon (NMApplet *applet)
applet->update_icon_id = g_idle_add (applet_update_icon, applet);
}
+#if 0
static NMDevice *
-find_active_device (NMAGConfConnection *connection,
+find_active_device (NMRemoteConnection *connection,
NMApplet *applet,
NMActiveConnection **out_active_connection)
{
@@ -2547,20 +2468,10 @@ find_active_device (NMAGConfConnection *connection,
active_connections = nm_client_get_active_connections (applet->nm_client);
for (i = 0; active_connections && (i < active_connections->len); i++) {
NMActiveConnection *active;
- const char *service_name;
const char *connection_path;
const GPtrArray *devices;
active = NM_ACTIVE_CONNECTION (g_ptr_array_index (active_connections, i));
- service_name = nm_active_connection_get_service_name (active);
- if (!service_name) {
- /* Shouldn't happen; but we shouldn't crash either */
- g_warning ("%s: couldn't get service name for active connection!", __func__);
- continue;
- }
-
- if (strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS))
- continue;
connection_path = nm_active_connection_get_connection (active);
if (!connection_path) {
@@ -2581,8 +2492,8 @@ find_active_device (NMAGConfConnection *connection,
}
static void
-applet_settings_new_secrets_requested_cb (NMAGConfSettings *settings,
- NMAGConfConnection *connection,
+applet_settings_new_secrets_requested_cb (NMRemoteSettings *settings,
+ NMRemoteConnection *connection,
const char *setting_name,
const char **hints,
gboolean ask_user,
@@ -2602,7 +2513,7 @@ applet_settings_new_secrets_requested_cb (NMAGConfSettings *settings,
/* VPN secrets get handled a bit differently */
if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) {
- nma_vpn_request_password (NM_SETTINGS_CONNECTION_INTERFACE (connection), ask_user, callback, callback_data);
+ nma_vpn_request_password (connection, ask_user, callback, callback_data);
return;
}
@@ -2610,8 +2521,8 @@ applet_settings_new_secrets_requested_cb (NMAGConfSettings *settings,
device = find_active_device (connection, applet, &active_connection);
if (!device || !active_connection) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ 0,
+ 0,
"%s.%d (%s): couldn't find details for connection",
__FILE__, __LINE__, __func__);
goto error;
@@ -2620,8 +2531,8 @@ applet_settings_new_secrets_requested_cb (NMAGConfSettings *settings,
dclass = get_device_class (device, applet);
if (!dclass) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ 0,
+ 0,
"%s.%d (%s): device type unknown",
__FILE__, __LINE__, __func__);
goto error;
@@ -2629,8 +2540,8 @@ applet_settings_new_secrets_requested_cb (NMAGConfSettings *settings,
if (!dclass->get_secrets) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE,
+ 0,
+ 0,
"%s.%d (%s): no secrets found",
__FILE__, __LINE__, __func__);
goto error;
@@ -2640,69 +2551,17 @@ applet_settings_new_secrets_requested_cb (NMAGConfSettings *settings,
// before asking user for other secrets
/* Let the device class handle secrets */
- if (dclass->get_secrets (device, NM_SETTINGS_CONNECTION_INTERFACE (connection),
+ if (dclass->get_secrets (device, connection,
active_connection, setting_name, hints, callback,
callback_data, applet, &error))
return; /* success */
error:
g_warning ("%s", error->message);
- callback (NM_SETTINGS_CONNECTION_INTERFACE (connection), NULL, error, callback_data);
+ callback (connection, NULL, error, callback_data);
g_error_free (error);
}
-
-static gboolean
-periodic_update_active_connection_timestamps (gpointer user_data)
-{
- NMApplet *applet = NM_APPLET (user_data);
- const GPtrArray *connections;
- int i;
-
- if (!applet->nm_client || !nm_client_get_manager_running (applet->nm_client))
- return TRUE;
-
- connections = nm_client_get_active_connections (applet->nm_client);
- for (i = 0; connections && (i < connections->len); i++) {
- NMActiveConnection *active = NM_ACTIVE_CONNECTION (g_ptr_array_index (connections, i));
- const char *path;
- NMSettingsConnectionInterface *connection;
- const GPtrArray *devices;
- int k;
-
- if (nm_active_connection_get_scope (active) == NM_CONNECTION_SCOPE_SYSTEM)
- continue;
-
- path = nm_active_connection_get_connection (active);
- connection = nm_settings_interface_get_connection_by_path (NM_SETTINGS_INTERFACE (applet->gconf_settings), path);
- if (!connection || !NMA_IS_GCONF_CONNECTION (connection))
- continue;
-
- devices = nm_active_connection_get_devices (active);
- if (!devices || !devices->len)
- continue;
-
- /* Check if a device owned by the active connection is completely
- * activated before updating timestamp.
- */
- for (k = 0; devices && (k < devices->len); k++) {
- NMDevice *device = NM_DEVICE (g_ptr_array_index (devices, k));
-
- if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
- NMSettingConnection *s_con;
-
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION));
- g_assert (s_con);
-
- g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL), NULL);
- /* Ignore secrets since we're just updating the timestamp */
- nma_gconf_connection_update (NMA_GCONF_CONNECTION (connection), TRUE);
- break;
- }
- }
- }
-
- return TRUE;
-}
+#endif
/*****************************************************************************/
@@ -2993,14 +2852,6 @@ applet_pre_keyring_callback (gpointer user_data)
}
static void
-exit_cb (GObject *ignored, gpointer user_data)
-{
- NMApplet *applet = user_data;
-
- g_main_loop_quit (applet->loop);
-}
-
-static void
applet_embedded_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
{
gboolean embedded = gtk_status_icon_is_embedded (GTK_STATUS_ICON (object));
@@ -3015,8 +2866,8 @@ constructor (GType type,
GObjectConstructParam *construct_props)
{
NMApplet *applet;
- AppletDBusManager *dbus_mgr;
GError* error = NULL;
+ DBusConnection *connection;
applet = NM_APPLET (G_OBJECT_CLASS (nma_parent_class)->constructor (type, n_props, construct_props));
@@ -3058,28 +2909,19 @@ constructor (GType type,
if (!notify_is_initted ())
notify_init ("NetworkManager");
- dbus_mgr = applet_dbus_manager_get ();
- if (dbus_mgr == NULL) {
- nm_warning ("Couldn't initialize the D-Bus manager.");
- g_object_unref (applet);
- return NULL;
+ applet->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (!applet->bus) {
+ g_warning ("Could not get the system bus. Make sure the message "
+ "bus daemon is running! Message: %s",
+ error->message);
+ g_error_free (error);
+ goto error;
}
- g_signal_connect (G_OBJECT (dbus_mgr), "exit-now", G_CALLBACK (exit_cb), applet);
- applet->system_settings = nm_remote_settings_system_new (applet_dbus_manager_get_connection (dbus_mgr));
+ connection = dbus_g_connection_get_connection (applet->bus);
+ dbus_connection_set_exit_on_disconnect (connection, FALSE);
- applet->gconf_settings = nma_gconf_settings_new (applet_dbus_manager_get_connection (dbus_mgr));
- g_signal_connect (applet->gconf_settings, "new-secrets-requested",
- G_CALLBACK (applet_settings_new_secrets_requested_cb),
- applet);
-
- nm_settings_service_export (NM_SETTINGS_SERVICE (applet->gconf_settings));
-
- /* Start our DBus service */
- if (!applet_dbus_manager_start_service (dbus_mgr)) {
- g_object_unref (applet);
- return NULL;
- }
+ applet->settings = nm_remote_settings_new (applet->bus);
/* Initialize device classes */
applet->wired_class = applet_device_wired_get_class (applet);
@@ -3099,10 +2941,6 @@ constructor (GType type,
foo_client_setup (applet);
- /* timeout to update connection timestamps every 5 minutes */
- applet->update_timestamps_id = g_timeout_add_seconds (300,
- (GSourceFunc) periodic_update_active_connection_timestamps, applet);
-
nm_gconf_set_pre_keyring_callback (applet_pre_keyring_callback, applet);
/* Track embedding to help debug issues where user has removed the
@@ -3127,9 +2965,6 @@ static void finalize (GObject *object)
nm_gconf_set_pre_keyring_callback (NULL, NULL);
- if (applet->update_timestamps_id)
- g_source_remove (applet->update_timestamps_id);
-
g_slice_free (NMADeviceClass, applet->wired_class);
g_slice_free (NMADeviceClass, applet->wifi_class);
g_slice_free (NMADeviceClass, applet->gsm_class);
@@ -3167,13 +3002,14 @@ static void finalize (GObject *object)
if (applet->fallback_icon)
g_object_unref (applet->fallback_icon);
- if (applet->gconf_settings) {
- g_object_unref (applet->gconf_settings);
- applet->gconf_settings = NULL;
+ if (applet->settings) {
+ g_object_unref (applet->settings);
+ applet->settings = NULL;
}
- if (applet->system_settings) {
- g_object_unref (applet->system_settings);
- applet->system_settings = NULL;
+
+ if (applet->bus) {
+ dbus_g_connection_unref (applet->bus);
+ applet->bus = NULL;
}
G_OBJECT_CLASS (nma_parent_class)->finalize (object);
diff --git a/src/applet.h b/src/applet.h
index f300650..3da04ca 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright (C) 2004 - 2010 Red Hat, Inc.
+ * Copyright (C) 2004 - 2011 Red Hat, Inc.
* Copyright (C) 2005 - 2008 Novell, Inc.
*/
@@ -44,10 +44,8 @@
#include <nm-device.h>
#include <NetworkManager.h>
#include <nm-active-connection.h>
-#include <nm-remote-settings-system.h>
-
-#include "applet-dbus-manager.h"
-#include "nma-gconf-settings.h"
+#include <nm-remote-settings.h>
+#include <nm-secret-agent.h>
#define NM_TYPE_APPLET (nma_get_type())
#define NM_APPLET(object) (G_TYPE_CHECK_INSTANCE_CAST((object), NM_TYPE_APPLET, NMApplet))
@@ -82,16 +80,15 @@ typedef struct
GObject parent_instance;
GMainLoop *loop;
- NMClient *nm_client;
+ DBusGConnection *bus;
- NMRemoteSettingsSystem *system_settings;
- NMAGConfSettings *gconf_settings;
+ NMClient *nm_client;
+ NMRemoteSettings *settings;
+ NMSecretAgent *agent;
GConfClient * gconf_client;
char * ui_file;
- guint update_timestamps_id;
-
/* Permissions */
NMClientPermissionResult permissions[NM_CLIENT_PERMISSION_LAST + 1];
@@ -173,6 +170,11 @@ typedef void (*AppletNewAutoConnectionCallback) (NMConnection *connection,
gboolean canceled,
gpointer user_data);
+typedef void (*NMANewSecretsRequestedFunc) (NMRemoteConnection *connection,
+ GHashTable *settings,
+ GError *error,
+ gpointer user_data);
+
struct NMADeviceClass {
gboolean (*new_auto_connection) (NMDevice *device,
gpointer user_data,
@@ -205,7 +207,7 @@ struct NMADeviceClass {
gpointer user_data);
gboolean (*get_secrets) (NMDevice *device,
- NMSettingsConnectionInterface *connection,
+ NMRemoteConnection *connection,
NMActiveConnection *active_connection,
const char *setting_name,
const char **hints,
@@ -221,7 +223,7 @@ NMApplet *nm_applet_new (GMainLoop *loop);
void applet_schedule_update_icon (NMApplet *applet);
-NMSettingsInterface *applet_get_settings (NMApplet *applet);
+NMRemoteSettings *applet_get_settings (NMApplet *applet);
GSList *applet_get_all_connections (NMApplet *applet);
@@ -250,7 +252,7 @@ applet_menu_item_create_device_item_helper (NMDevice *device,
NMApplet *applet,
const gchar *text);
-NMSettingsConnectionInterface *applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet);
+NMRemoteConnection *applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet);
void applet_do_notify (NMApplet *applet,
NotifyUrgency urgency,
diff --git a/src/vpn-password-dialog.c b/src/vpn-password-dialog.c
index ce5214d..cd77870 100644
--- a/src/vpn-password-dialog.c
+++ b/src/vpn-password-dialog.c
@@ -36,7 +36,6 @@
#include <nm-connection.h>
#include <nm-setting-connection.h>
#include <nm-setting-vpn.h>
-#include <nm-settings-interface.h>
typedef struct {
@@ -165,7 +164,7 @@ destroy_gvalue (gpointer data)
}
gboolean
-nma_vpn_request_password (NMSettingsConnectionInterface *connection_iface,
+nma_vpn_request_password (NMRemoteConnection *remote,
gboolean retry,
NMANewSecretsRequestedFunc callback,
gpointer callback_data)
@@ -185,7 +184,7 @@ nma_vpn_request_password (NMSettingsConnectionInterface *connection_iface,
guint child_stdout_channel_eventid;
char *auth_dialog_binary = NULL;
IOUserData io_user_data;
- NMConnection *connection = NM_CONNECTION (connection_iface);
+ NMConnection *connection = NM_CONNECTION (remote);
NMSettingConnection *s_con;
NMSettingVPN *s_vpn;
gboolean success = FALSE;
@@ -194,8 +193,6 @@ nma_vpn_request_password (NMSettingsConnectionInterface *connection_iface,
const char *connection_type;
const char *service_type;
- g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
-
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
g_return_val_if_fail (s_con != NULL, FALSE);
@@ -216,8 +213,8 @@ nma_vpn_request_password (NMSettingsConnectionInterface *connection_iface,
auth_dialog_binary = find_auth_dialog_binary (service_type, id);
if (!auth_dialog_binary) {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ 0,
+ 0,
"%s.%d (%s): couldn't find VPN auth dialog helper program '%s'.",
__FILE__, __LINE__, __func__, service_type);
goto out;
@@ -259,8 +256,8 @@ nma_vpn_request_password (NMSettingsConnectionInterface *connection_iface,
gtk_window_present (GTK_WINDOW (dialog));
g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ 0,
+ 0,
"%s.%d (%s): couldn't run VPN auth dialog.",
__FILE__, __LINE__, __func__);
goto out;
@@ -312,13 +309,13 @@ nma_vpn_request_password (NMSettingsConnectionInterface *connection_iface,
iter = iter->next;
}
g_hash_table_insert (settings, g_strdup (NM_SETTING_VPN_SETTING_NAME), secrets);
- callback (connection_iface, settings, NULL, callback_data);
+ callback (remote, settings, NULL, callback_data);
g_hash_table_destroy (settings);
success = TRUE;
} else {
g_set_error (&error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED,
+ 0,
+ 0,
"%s.%d (%s): canceled", __FILE__, __LINE__, __func__);
}
@@ -329,7 +326,7 @@ nma_vpn_request_password (NMSettingsConnectionInterface *connection_iface,
g_free (auth_dialog_binary);
if (error) {
- callback (NM_SETTINGS_CONNECTION_INTERFACE (connection), NULL, error, callback_data);
+ callback (remote, NULL, error, callback_data);
g_error_free (error);
}
diff --git a/src/vpn-password-dialog.h b/src/vpn-password-dialog.h
index 325f7bf..69ca7e5 100644
--- a/src/vpn-password-dialog.h
+++ b/src/vpn-password-dialog.h
@@ -23,9 +23,11 @@
#define VPN_PASSWORD_DIALOG_H
#include <glib.h>
-#include <nma-gconf-connection.h>
-gboolean nma_vpn_request_password (NMSettingsConnectionInterface *connection,
+#include <nm-remote-connection.h>
+#include "applet.h"
+
+gboolean nma_vpn_request_password (NMRemoteConnection *remote,
gboolean retry,
NMANewSecretsRequestedFunc callback,
gpointer callback_data);
diff --git a/src/wired-dialog.c b/src/wired-dialog.c
index 3209eb3..9a8efae 100644
--- a/src/wired-dialog.c
+++ b/src/wired-dialog.c
@@ -116,7 +116,7 @@ dialog_init (GtkWidget *dialog,
GtkWidget *
nma_wired_dialog_new (const char *ui_file,
NMClient *nm_client,
- NMSettingsConnectionInterface *connection,
+ NMRemoteConnection *connection,
NMDevice *device)
{
GtkBuilder *builder;
@@ -161,10 +161,10 @@ nma_wired_dialog_new (const char *ui_file,
return dialog;
}
-NMSettingsConnectionInterface *
+NMRemoteConnection *
nma_wired_dialog_get_connection (GtkWidget *dialog)
{
- NMSettingsConnectionInterface *connection;
+ NMRemoteConnection *connection;
WirelessSecurity *security;
NMConnection *tmp_connection;
NMSetting *s_8021x, *s_con;
diff --git a/src/wired-dialog.h b/src/wired-dialog.h
index f89b540..954b11a 100644
--- a/src/wired-dialog.h
+++ b/src/wired-dialog.h
@@ -28,13 +28,13 @@
#include <nm-client.h>
#include <nm-connection.h>
#include <nm-device.h>
-#include <nm-settings-connection-interface.h>
+#include <nm-remote-connection.h>
GtkWidget *nma_wired_dialog_new (const char *ui_file,
NMClient *nm_client,
- NMSettingsConnectionInterface *connection,
+ NMRemoteConnection *connection,
NMDevice *device);
-NMSettingsConnectionInterface *nma_wired_dialog_get_connection (GtkWidget *dialog);
+NMRemoteConnection *nma_wired_dialog_get_connection (GtkWidget *dialog);
#endif /* WIRED_DIALOG_H */
diff --git a/src/wireless-dialog.c b/src/wireless-dialog.c
index ee9cb0a..06583e2 100644
--- a/src/wireless-dialog.c
+++ b/src/wireless-dialog.c
@@ -241,14 +241,6 @@ security_combo_changed_manually (GtkWidget *combo,
security_combo_changed (combo, user_data);
}
-static gboolean
-is_system_connection (NMAWirelessDialog *self)
-{
- NMAWirelessDialogPrivate *priv = NMA_WIRELESS_DIALOG_GET_PRIVATE (self);
-
- return priv->connection && (nm_connection_get_scope (priv->connection) == NM_CONNECTION_SCOPE_SYSTEM);
-}
-
static GByteArray *
validate_dialog_ssid (NMAWirelessDialog *self)
{
@@ -297,10 +289,6 @@ stuff_changed_cb (WirelessSecurity *sec, gpointer user_data)
g_byte_array_free (ssid, TRUE);
}
- /* Assume system connections are valid so that we don't have to get secrets for them */
- if (is_system_connection (self))
- valid = TRUE;
-
/* But if there's an in-progress secrets call (which might require authorization)
* then we don't want to enable the OK button because we don't have all the
* connection details yet.
@@ -343,10 +331,6 @@ ssid_entry_changed (GtkWidget *entry, gpointer user_data)
}
out:
- /* Assume system connections are valid so that we don't have to get secrets for them */
- if (is_system_connection (self))
- valid = TRUE;
-
/* But if there's an in-progress secrets call (which might require authorization)
* then we don't want to enable the OK button because we don't have all the
* connection details yet.
@@ -410,13 +394,6 @@ connection_combo_changed (GtkWidget *combo,
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->builder, "security_vbox")), is_new);
}
-static GSList *
-get_all_connections (NMApplet *applet)
-{
- return g_slist_concat (nm_settings_interface_list_connections (NM_SETTINGS_INTERFACE (applet->system_settings)),
- nm_settings_interface_list_connections (NM_SETTINGS_INTERFACE (applet->gconf_settings)));
-}
-
static gboolean
connection_combo_separator_cb (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
@@ -481,7 +458,7 @@ connection_combo_init (NMAWirelessDialog *self, NMConnection *connection)
gtk_list_store_append (store, &tree_iter);
gtk_list_store_set (store, &tree_iter, C_SEP_COLUMN, TRUE, -1);
- connections = get_all_connections (priv->applet);
+ connections = applet_get_all_connections (priv->applet);
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *candidate = NM_CONNECTION (iter->data);
NMSettingWireless *s_wireless;
@@ -771,7 +748,7 @@ add_security_item (NMAWirelessDialog *self,
}
static void
-get_secrets_cb (NMSettingsConnectionInterface *connection,
+get_secrets_cb (NMRemoteConnection *connection,
GHashTable *secrets,
GError *error,
gpointer user_data)
@@ -869,6 +846,7 @@ security_combo_init (NMAWirelessDialog *self, gboolean auth_only)
int item = 0;
NMSettingWireless *s_wireless = NULL;
gboolean is_adhoc;
+ const char *setting_name;
g_return_val_if_fail (self != NULL, FALSE);
@@ -1019,31 +997,28 @@ security_combo_init (NMAWirelessDialog *self, gboolean auth_only)
g_object_unref (G_OBJECT (sec_model));
/* Request secrets for the connection if it needs any */
- if (NM_IS_SETTINGS_CONNECTION_INTERFACE (priv->connection)) {
- const char *setting_name;
-
- setting_name = nm_connection_need_secrets (priv->connection, NULL);
- if (setting_name) {
- GetSecretsInfo *info;
-
- /* Desensitize the dialog's buttons while we wait for the secrets
- * operation to complete.
- */
- gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, FALSE);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_CANCEL, FALSE);
-
- info = g_malloc0 (sizeof (GetSecretsInfo));
- info->self = self;
- info->connection = g_object_ref (priv->connection);
- priv->secrets_info = info;
-
- nm_settings_connection_interface_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (priv->connection),
- setting_name,
- NULL,
- FALSE,
- get_secrets_cb,
- info);
- }
+
+ setting_name = nm_connection_need_secrets (priv->connection, NULL);
+ if (setting_name) {
+ GetSecretsInfo *info;
+
+ /* Desensitize the dialog's buttons while we wait for the secrets
+ * operation to complete.
+ */
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, FALSE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_CANCEL, FALSE);
+
+ info = g_malloc0 (sizeof (GetSecretsInfo));
+ info->self = self;
+ info->connection = g_object_ref (priv->connection);
+ priv->secrets_info = info;
+
+ nm_remote_connection_get_secrets (NM_REMOTE_CONNECTION (priv->connection),
+ setting_name,
+ NULL,
+ FALSE,
+ get_secrets_cb,
+ info);
}
return TRUE;
@@ -1136,11 +1111,7 @@ internal_init (NMAWirelessDialog *self,
priv->network_name_focus = TRUE;
}
- /* Assume system connections are valid so that we don't have to get secrets for them */
- if (is_system_connection (self))
- gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, TRUE);
- else
- gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, FALSE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, FALSE);
if (!device_combo_init (self, specific_device)) {
g_warning ("No wireless devices available.");
@@ -1262,24 +1233,19 @@ nma_wireless_dialog_get_connection (NMAWirelessDialog *self,
} else
connection = g_object_ref (priv->connection);
- /* Only update security information for user connections, as for system
- * connections the applet just needs to tell NM to activate it.
- */
- if (!is_system_connection (self)) {
- /* Fill security */
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->sec_combo));
- if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->sec_combo), &iter))
- gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &sec, -1);
- if (sec) {
- wireless_security_fill_connection (sec, connection);
- wireless_security_unref (sec);
- } else {
- /* Unencrypted */
- s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
- g_assert (s_wireless);
-
- g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NULL, NULL);
- }
+ /* Fill security */
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->sec_combo));
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->sec_combo), &iter))
+ gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &sec, -1);
+ if (sec) {
+ wireless_security_fill_connection (sec, connection);
+ wireless_security_unref (sec);
+ } else {
+ /* Unencrypted */
+ s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+ g_assert (s_wireless);
+
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NULL, NULL);
}
/* Fill device */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]