[network-manager-applet/polkit1: 2/2] Port to new libnm-glib settings interface
- From: Dan Williams <dcbw src gnome org>
- To: svn-commits-list gnome org
- Subject: [network-manager-applet/polkit1: 2/2] Port to new libnm-glib settings interface
- Date: Thu, 23 Jul 2009 13:42:30 +0000 (UTC)
commit 78e2b98689229f1fc99008a172fe2ebe1edaad61
Author: Dan Williams <dcbw redhat com>
Date: Thu Jul 23 09:18:16 2009 -0400
Port to new libnm-glib settings interface
Not runtime tested at all yet.
configure.ac | 64 +-
src/Makefile.am | 2 +-
src/applet-device-cdma.c | 74 +-
src/applet-device-gsm.c | 72 +-
src/applet-device-wifi.c | 134 ++-
src/applet-device-wired.c | 154 ++-
src/applet.c | 166 +--
src/applet.h | 13 +-
src/connection-editor/Makefile.am | 18 +-
src/connection-editor/ce-page.c | 44 +-
src/connection-editor/nm-connection-editor.c | 28 +-
src/connection-editor/nm-connection-editor.h | 8 +-
src/connection-editor/nm-connection-list.c | 850 +++++-------
src/connection-editor/nm-connection-list.h | 13 +-
src/connection-editor/polkit-helpers.c | 86 --
src/connection-editor/polkit-helpers.h | 41 -
src/gconf-helpers/gconf-helpers.c | 18 +-
src/gconf-helpers/nma-gconf-connection.c | 619 +++++---
src/gconf-helpers/nma-gconf-connection.h | 21 +-
src/gconf-helpers/nma-gconf-settings.c | 168 +--
src/gconf-helpers/nma-gconf-settings.h | 32 +-
src/gnome-bluetooth/network-manager-applet.c | 63 +-
src/marshallers/nma-marshal.list | 4 +-
src/polkit-helpers/Makefile.am | 25 -
src/polkit-helpers/README | 24 -
src/polkit-helpers/polkit-gnome-action.c | 2093 --------------------------
src/polkit-helpers/polkit-gnome-action.h | 92 --
src/polkit-helpers/polkit-gnome-auth.c | 165 --
src/polkit-helpers/polkit-gnome-auth.h | 51 -
src/polkit-helpers/polkit-gnome-context.c | 289 ----
src/polkit-helpers/polkit-gnome-context.h | 108 --
src/polkit-helpers/polkit-gnome.h | 36 -
src/utils/utils.c | 31 +-
src/vpn-password-dialog.c | 31 +-
src/vpn-password-dialog.h | 8 +-
src/wired-dialog.c | 10 +-
src/wired-dialog.h | 5 +-
src/wireless-dialog.c | 22 +-
38 files changed, 1310 insertions(+), 4372 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8fb6b51..a7afa97 100644
--- a/configure.ac
+++ b/configure.ac
@@ -118,67 +118,8 @@ AC_SUBST(DBUS_CFLAGS)
PKG_CHECK_MODULES(DBUS_126, [dbus-1 >= 1.2.6], [have_dbus_126=yes],[have_dbus_126=no])
AM_CONDITIONAL(HAVE_DBUS_126, test x"$have_dbus_126" = "xyes")
-#### PolicyKit checks; need at least 0.6 or later
-PKG_CHECK_EXISTS(polkit-gnome,[have_polkit_gnome=yes],[have_polkit_gnome=no])
-if test x"$have_polkit_gnome" = "xyes"; then
- PKG_CHECK_MODULES(POLKIT, polkit-gnome)
-else
- PKG_CHECK_MODULES(POLKIT, [polkit >= 0.6])
- PKG_CHECK_MODULES(POLKIT_DBUS, [polkit-dbus >= 0.6])
- AC_DEFINE([NO_POLKIT_GNOME],[1],[Define if you don't have PolicyKit-gnome 0.7 or later])
-fi
-AM_CONDITIONAL(NO_POLKIT_GNOME, test x"$have_polkit_gnome" = "xno")
-
-##### Find out the version of PolicyKit we're using
-polkit_version=`pkg-config --modversion polkit`
-POLKIT_VERSION_MAJOR=`echo $polkit_version | awk -F. '{print $1}'`
-POLKIT_VERSION_MINOR=`echo $polkit_version | awk -F. '{print $2}'`
-POLKIT_VERSION_MICRO=`echo $polkit_version | awk -F. '{print $3}'`
-if test "z$POLKIT_VERSION_MAJOR" = "z"; then
- POLKIT_VERSION_MAJOR="0"
-fi
-if test "z$POLKIT_VERSION_MINOR" = "z"; then
- POLKIT_VERSION_MINOR="0"
-fi
-if test "z$POLKIT_VERSION_MICRO" = "z"; then
- POLKIT_VERSION_MICRO="0"
-fi
-
-if test "z$POLKIT_VERSION_MAJOR" = "z0" -a "z$POLKIT_VERSION_MINOR" = "z0" -a "z$POLKIT_VERSION_MICRO" = "z0"; then
- echo "Error: Couldn't determine the version of your PolicyKit package."
- echo " This is probably an error in this script, please report it"
- echo " along with the following information:"
- echo " Base PolicyKit version ='$polkit_version'"
- echo " POLKIT_VERSION_MAJOR='$POLKIT_VERSION_MAJOR'"
- echo " POLKIT_VERSION_MINOR='$POLKIT_VERSION_MINOR'"
- echo " POLKIT_VERSION_MICRO='$POLKIT_VERSION_MICRO'"
- exit 1
-else
- echo "Your PolicyKit version is $POLKIT_VERSION_MAJOR,$POLKIT_VERSION_MINOR,$POLKIT_VERSION_MICRO."
- POLKIT_CFLAGS="$POLKIT_CFLAGS -DPOLKIT_VERSION_MAJOR=$POLKIT_VERSION_MAJOR"
- POLKIT_CFLAGS="$POLKIT_CFLAGS -DPOLKIT_VERSION_MINOR=$POLKIT_VERSION_MINOR"
- POLKIT_CFLAGS="$POLKIT_CFLAGS -DPOLKIT_VERSION_MICRO=$POLKIT_VERSION_MICRO"
-fi
-AC_SUBST(POLKIT_CFLAGS)
-
-AC_MSG_CHECKING([Linux Wireless Extensions >= 18])
-AC_TRY_COMPILE([#ifndef __user
- #define __user
- #endif
- #include <sys/types.h>
- #include <linux/types.h>
- #include <sys/socket.h>
- #include <net/if.h>
- #include <wireless.h>],
- [#ifndef IWEVGENIE
- #error "not found"
- #endif],
- [ac_have_iwevgenie=yes],
- [ac_have_iwevgenie=no])
-AC_MSG_RESULT($ac_have_iwevgenie)
-if test "$ac_have_iwevgenie" = no; then
- AC_MSG_ERROR(wireless-tools >= 28pre9 not installed or not functional)
-fi
+#### PolicyKit checks; need at least 0.92 or later
+PKG_CHECK_MODULES(POLKIT, [polkit-gobject-1 >= 0.92])
AC_ARG_WITH(dbus-sys, AS_HELP_STRING([--with-dbus-sys=DIR], [where D-BUS system.d directory is]))
@@ -210,7 +151,6 @@ src/marshallers/Makefile
src/utils/Makefile
src/gconf-helpers/Makefile
src/wireless-security/Makefile
-src/polkit-helpers/Makefile
src/connection-editor/Makefile
src/gnome-bluetooth/Makefile
icons/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index 14ad753..6bd7b04 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = marshallers utils gconf-helpers wireless-security polkit-helpers connection-editor gnome-bluetooth
+SUBDIRS = marshallers utils gconf-helpers wireless-security connection-editor gnome-bluetooth
bin_PROGRAMS = nm-applet
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index 9e19f34..73feb10 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -403,9 +403,10 @@ cdma_get_icon (NMDevice *device,
}
typedef struct {
- DBusGMethodInvocation *context;
+ NMANewSecretsRequestedFunc callback;
+ gpointer callback_data;
NMApplet *applet;
- NMConnection *connection;
+ NMSettingsConnectionInterface *connection;
NMActiveConnection *active_connection;
GtkWidget *dialog;
GtkEntry *secret_entry;
@@ -426,12 +427,22 @@ 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;
- NMAGConfConnection *gconf_connection;
NMSettingCdma *setting;
GHashTable *settings_hash;
GHashTable *secrets;
@@ -443,13 +454,15 @@ 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_ERROR, NM_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED,
+ g_set_error (&err,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): canceled",
__FILE__, __LINE__, __func__);
goto done;
}
- setting = NM_SETTING_CDMA (nm_connection_get_setting (info->connection, NM_TYPE_SETTING_CDMA));
+ setting = NM_SETTING_CDMA (nm_connection_get_setting (NM_CONNECTION (info->connection), NM_TYPE_SETTING_CDMA));
if (!strcmp (info->secret_name, NM_SETTING_CDMA_PASSWORD)) {
g_object_set (setting,
@@ -459,9 +472,11 @@ get_cdma_secrets_cb (GtkDialog *dialog,
secrets = nm_setting_to_hash (NM_SETTING (setting));
if (!secrets) {
- g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
- "%s.%d (%s): failed to hash setting '%s'.",
- __FILE__, __LINE__, __func__, nm_setting_get_name (NM_SETTING (setting)));
+ g_set_error (&err,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ "%s.%d (%s): failed to hash setting '%s'.",
+ __FILE__, __LINE__, __func__, nm_setting_get_name (NM_SETTING (setting)));
goto done;
}
@@ -472,25 +487,24 @@ get_cdma_secrets_cb (GtkDialog *dialog,
g_free, (GDestroyNotify) g_hash_table_destroy);
g_hash_table_insert (settings_hash, g_strdup (nm_setting_get_name (NM_SETTING (setting))), secrets);
- dbus_g_method_return (info->context, settings_hash);
+ 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.
*/
- gconf_connection = nma_gconf_settings_get_by_connection (info->applet->gconf_settings, info->connection);
- if (gconf_connection)
- nma_gconf_connection_save (gconf_connection);
+ 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);
- dbus_g_method_return_error (info->context, err);
+ info->callback (info->connection, NULL, err, info->callback_data);
g_error_free (err);
}
- nm_connection_clear_secrets (info->connection);
+ nm_connection_clear_secrets (NM_CONNECTION (info->connection));
destroy_cdma_dialog (info, NULL);
}
@@ -549,43 +563,51 @@ ask_for_password (NMDevice *device,
static gboolean
cdma_get_secrets (NMDevice *device,
- NMConnection *connection,
- NMActiveConnection *active_connection,
- const char *setting_name,
- const char **hints,
- DBusGMethodInvocation *context,
- NMApplet *applet,
- GError **error)
+ NMSettingsConnectionInterface *connection,
+ NMActiveConnection *active_connection,
+ const char *setting_name,
+ const char **hints,
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data,
+ NMApplet *applet,
+ GError **error)
{
NMCdmaInfo *info;
GtkWidget *widget;
GtkEntry *secret_entry = NULL;
if (!hints || !g_strv_length ((char **) hints)) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): missing secrets hints.",
__FILE__, __LINE__, __func__);
return FALSE;
}
if (!strcmp (hints[0], NM_SETTING_CDMA_PASSWORD))
- widget = ask_for_password (device, connection, &secret_entry);
+ widget = ask_for_password (device, NM_CONNECTION (connection), &secret_entry);
else {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): unknown secrets hint '%s'.",
__FILE__, __LINE__, __func__, hints[0]);
return FALSE;
}
if (!widget || !secret_entry) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): error asking for CDMA secrets.",
__FILE__, __LINE__, __func__);
return FALSE;
}
info = g_new (NMCdmaInfo, 1);
- info->context = context;
+ info->callback = callback;
+ info->callback_data = callback_data;
info->applet = applet;
info->active_connection = active_connection;
info->connection = g_object_ref (connection);
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index 6f0d3d7..e69385c 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -405,11 +405,12 @@ gsm_get_icon (NMDevice *device,
}
typedef struct {
- DBusGMethodInvocation *context;
+ NMANewSecretsRequestedFunc callback;
+ gpointer callback_data;
NMApplet *applet;
NMActiveConnection *active_connection;
GtkWidget *dialog;
- NMConnection *connection;
+ NMSettingsConnectionInterface *connection;
GtkEntry *secret_entry;
char *secret_name;
} NMGsmInfo;
@@ -451,12 +452,22 @@ destroy_gsm_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_gsm_secrets_cb (GtkDialog *dialog,
- gint response,
- gpointer user_data)
+ gint response,
+ gpointer user_data)
{
NMGsmInfo *info = (NMGsmInfo *) user_data;
- NMAGConfConnection *gconf_connection;
NMSettingGsm *setting;
GHashTable *settings_hash;
GHashTable *secrets;
@@ -468,13 +479,15 @@ get_gsm_secrets_cb (GtkDialog *dialog,
g_object_weak_unref (G_OBJECT (info->active_connection), destroy_gsm_dialog, info);
if (response != GTK_RESPONSE_OK) {
- g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED,
+ g_set_error (&err,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): canceled",
__FILE__, __LINE__, __func__);
goto done;
}
- setting = NM_SETTING_GSM (nm_connection_get_setting (info->connection, NM_TYPE_SETTING_GSM));
+ setting = NM_SETTING_GSM (nm_connection_get_setting (NM_CONNECTION (info->connection), NM_TYPE_SETTING_GSM));
if (!strcmp (info->secret_name, NM_SETTING_GSM_PIN) ||
!strcmp (info->secret_name, NM_SETTING_GSM_PUK) ||
@@ -483,9 +496,11 @@ get_gsm_secrets_cb (GtkDialog *dialog,
secrets = nm_setting_to_hash (NM_SETTING (setting));
if (!secrets) {
- g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
- "%s.%d (%s): failed to hash setting '%s'.",
- __FILE__, __LINE__, __func__, nm_setting_get_name (NM_SETTING (setting)));
+ g_set_error (&err,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ "%s.%d (%s): failed to hash setting '%s'.",
+ __FILE__, __LINE__, __func__, nm_setting_get_name (NM_SETTING (setting)));
goto done;
}
@@ -496,25 +511,24 @@ get_gsm_secrets_cb (GtkDialog *dialog,
g_free, (GDestroyNotify) g_hash_table_destroy);
g_hash_table_insert (settings_hash, g_strdup (nm_setting_get_name (NM_SETTING (setting))), secrets);
- dbus_g_method_return (info->context, settings_hash);
+ 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.
*/
- gconf_connection = nma_gconf_settings_get_by_connection (info->applet->gconf_settings, info->connection);
- if (gconf_connection)
- nma_gconf_connection_save (gconf_connection);
+ 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);
- dbus_g_method_return_error (info->context, err);
+ info->callback (info->connection, NULL, err, info->callback_data);
g_error_free (err);
}
- nm_connection_clear_secrets (info->connection);
+ nm_connection_clear_secrets (NM_CONNECTION (info->connection));
destroy_gsm_dialog (info, NULL);
}
@@ -633,11 +647,12 @@ ask_for_password (NMDevice *device,
static gboolean
gsm_get_secrets (NMDevice *device,
- NMConnection *connection,
+ NMSettingsConnectionInterface *connection,
NMActiveConnection *active_connection,
const char *setting_name,
const char **hints,
- DBusGMethodInvocation *context,
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data,
NMApplet *applet,
GError **error)
{
@@ -646,7 +661,9 @@ gsm_get_secrets (NMDevice *device,
GtkEntry *secret_entry = NULL;
if (!hints || !g_strv_length ((char **) hints)) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): missing secrets hints.",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -654,25 +671,30 @@ gsm_get_secrets (NMDevice *device,
if ( !strcmp (hints[0], NM_SETTING_GSM_PIN)
|| !strcmp (hints[0], NM_SETTING_GSM_PUK))
- widget = ask_for_pin_puk (device, connection, hints[0], &secret_entry);
+ widget = ask_for_pin_puk (device, NM_CONNECTION (connection), hints[0], &secret_entry);
else if (!strcmp (hints[0], NM_SETTING_GSM_PASSWORD))
- widget = ask_for_password (device, connection, &secret_entry);
+ widget = ask_for_password (device, NM_CONNECTION (connection), &secret_entry);
else {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): unknown secrets hint '%s'.",
__FILE__, __LINE__, __func__, hints[0]);
return FALSE;
}
if (!widget || !secret_entry) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): error asking for GSM secrets.",
__FILE__, __LINE__, __func__);
return FALSE;
}
- info = g_new (NMGsmInfo, 1);
- info->context = context;
+ info = g_malloc0 (sizeof (NMGsmInfo));
+ info->callback = callback;
+ info->callback_data = callback_data;
info->applet = applet;
info->active_connection = active_connection;
info->connection = g_object_ref (connection);
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index bc00a76..41cff73 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -736,16 +736,12 @@ out:
}
static gboolean
-add_seen_bssid (NMAGConfConnection *gconf_connection, NMAccessPoint *ap)
+add_seen_bssid (NMSettingsConnectionInterface *connection, NMAccessPoint *ap)
{
- NMConnection *connection;
NMSettingWireless *s_wireless;
const char *bssid;
- connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (gconf_connection));
- g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
-
- s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+ s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_WIRELESS));
if (!s_wireless)
return FALSE;
@@ -757,12 +753,22 @@ add_seen_bssid (NMAGConfConnection *gconf_connection, NMAccessPoint *ap)
}
static void
+bssid_update_cb (NMSettingsConnectionInterface *connection,
+ GError *error,
+ gpointer user_data)
+{
+ if (error) {
+ g_warning ("%s: failed to update connection seen BSSIDs: (%d) %s",
+ __func__, error->code, error->message);
+ }
+}
+
+static void
notify_active_ap_changed_cb (NMDeviceWifi *device,
GParamSpec *pspec,
NMApplet *applet)
{
- NMAGConfConnection *gconf_connection;
- NMConnection *connection;
+ NMSettingsConnectionInterface *connection;
NMSettingWireless *s_wireless;
NMAccessPoint *new;
const GByteArray *ssid;
@@ -774,14 +780,11 @@ notify_active_ap_changed_cb (NMDeviceWifi *device,
if (!new || (state != NM_DEVICE_STATE_ACTIVATED))
return;
- gconf_connection = applet_get_exported_connection_for_device (NM_DEVICE (device), applet);
- if (!gconf_connection)
+ connection = applet_get_exported_connection_for_device (NM_DEVICE (device), applet);
+ if (!connection)
return;
- connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (gconf_connection));
- g_return_if_fail (NM_IS_CONNECTION (connection));
-
- s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+ s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_WIRELESS));
if (!s_wireless)
return;
@@ -789,8 +792,8 @@ notify_active_ap_changed_cb (NMDeviceWifi *device,
if (!ssid || !nm_utils_same_ssid (nm_setting_wireless_get_ssid (s_wireless), ssid, TRUE))
return;
- if (add_seen_bssid (gconf_connection, new))
- nma_gconf_connection_save (gconf_connection);
+ if (add_seen_bssid (connection, new))
+ nm_settings_connection_interface_update (connection, bssid_update_cb, NULL);
applet_schedule_update_icon (applet);
}
@@ -1038,7 +1041,9 @@ access_point_removed_cb (NMDeviceWifi *device,
}
static void
-on_new_connection (NMSettings *settings, NMExportedConnection *connection, gpointer datap)
+on_new_connection (NMSettingsInterface *settings,
+ NMSettingsConnectionInterface *connection,
+ gpointer datap)
{
struct ap_notification_data *data = datap;
queue_avail_access_point_notification (NM_DEVICE (data->device));
@@ -1048,7 +1053,7 @@ static void
free_ap_notification_data (gpointer user_data)
{
struct ap_notification_data *data = user_data;
- NMSettings *settings = applet_get_settings (data->applet);
+ NMSettingsInterface *settings = applet_get_settings (data->applet);
if (data->id)
g_source_remove (data->id);
@@ -1156,7 +1161,7 @@ wireless_device_state_changed (NMDevice *device,
NMDeviceStateReason reason,
NMApplet *applet)
{
- NMAGConfConnection *gconf_connection;
+ NMSettingsConnectionInterface *connection;
NMAccessPoint *new = NULL;
char *msg;
char *esc_ssid = NULL;
@@ -1176,9 +1181,9 @@ wireless_device_state_changed (NMDevice *device,
esc_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
/* Save this BSSID to seen-bssids list */
- gconf_connection = applet_get_exported_connection_for_device (device, applet);
- if (gconf_connection && add_seen_bssid (gconf_connection, new))
- nma_gconf_connection_save (gconf_connection);
+ connection = applet_get_exported_connection_for_device (device, applet);
+ if (connection && add_seen_bssid (connection, new))
+ nm_settings_connection_interface_update (connection, bssid_update_cb, NULL);
}
msg = g_strdup_printf (_("You are now connected to the wireless network '%s'."),
@@ -1298,6 +1303,17 @@ nag_dialog_response_cb (GtkDialog *nag_dialog,
}
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
wireless_dialog_response_cb (GtkDialog *foo,
gint response,
gpointer user_data)
@@ -1307,7 +1323,6 @@ wireless_dialog_response_cb (GtkDialog *foo,
NMConnection *connection = NULL, *fuzzy_match = NULL;
NMDevice *device = NULL;
NMAccessPoint *ap = NULL;
- NMAGConfConnection *gconf_connection;
if (response != GTK_RESPONSE_OK)
goto done;
@@ -1332,10 +1347,11 @@ wireless_dialog_response_cb (GtkDialog *foo,
g_assert (connection);
g_assert (device);
- gconf_connection = nma_gconf_settings_get_by_connection (applet->gconf_settings, connection);
- if (gconf_connection) {
+ if (NMA_IS_GCONF_CONNECTION (connection)) {
/* Not a new or system connection, save the updated settings to GConf */
- nma_gconf_connection_save (gconf_connection);
+ nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (connection),
+ update_cb,
+ NULL);
} else {
GSList *all, *iter;
@@ -1403,8 +1419,8 @@ wireless_dialog_response_cb (GtkDialog *foo,
}
/* Export it over D-Bus */
- gconf_connection = nma_gconf_settings_add_connection (applet->gconf_settings, connection);
- if (!gconf_connection) {
+ connection = NM_CONNECTION (nma_gconf_settings_add_connection (applet->gconf_settings, connection));
+ if (!connection) {
nm_warning ("Couldn't create other network connection.");
goto done;
}
@@ -1468,7 +1484,9 @@ add_one_setting (GHashTable *settings,
if (secrets) {
g_hash_table_insert (settings, g_strdup (nm_setting_get_name (setting)), secrets);
} else {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): failed to hash setting '%s'.",
__FILE__, __LINE__, __func__, nm_setting_get_name (setting));
}
@@ -1481,7 +1499,8 @@ typedef struct {
NMActiveConnection *active_connection;
GtkWidget *dialog;
GtkWidget *nag_dialog;
- DBusGMethodInvocation *context;
+ NMANewSecretsRequestedFunc callback;
+ gpointer callback_data;
char *setting_name;
} NMWifiInfo;
@@ -1503,7 +1522,6 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
{
NMWifiInfo *info = user_data;
NMAWirelessDialog *dialog = NMA_WIRELESS_DIALOG (info->dialog);
- NMAGConfConnection *gconf_connection;
NMConnection *connection = NULL;
NMSettingWirelessSecurity *s_wireless_sec;
NMDevice *device = NULL;
@@ -1536,7 +1554,9 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
g_object_weak_unref (G_OBJECT (info->active_connection), destroy_wifi_dialog, info);
if (response != GTK_RESPONSE_OK) {
- g_set_error (&error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED,
"%s.%d (%s): canceled",
__FILE__, __LINE__, __func__);
goto done;
@@ -1544,7 +1564,9 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
connection = nma_wireless_dialog_get_connection (dialog, &device, NULL);
if (!connection) {
- g_set_error (&error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): couldn't get connection from wireless dialog.",
__FILE__, __LINE__, __func__);
goto done;
@@ -1553,7 +1575,9 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
/* Second-guess which setting NM wants secrets for. */
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_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
"%s.%d (%s): requested setting '802-11-wireless-security'"
" didn't exist in the connection.",
__FILE__, __LINE__, __func__);
@@ -1566,7 +1590,9 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
settings = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify) g_hash_table_destroy);
if (!settings) {
- g_set_error (&error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): not enough memory to return secrets.",
__FILE__, __LINE__, __func__);
goto done;
@@ -1587,7 +1613,9 @@ 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_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
"%s.%d (%s): requested setting '802-1x' didn't"
" exist in the connection.",
__FILE__, __LINE__, __func__);
@@ -1604,15 +1632,17 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
if (!add_one_setting (settings, connection, NM_SETTING (s_wireless_sec), &error))
goto done;
- dbus_g_method_return (info->context, settings);
+ 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.
*/
- gconf_connection = nma_gconf_settings_get_by_connection (info->applet->gconf_settings, connection);
- if (gconf_connection)
- nma_gconf_connection_save (gconf_connection);
+ if (NMA_IS_GCONF_CONNECTION (connection)) {
+ nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (connection),
+ update_cb,
+ NULL);
+ }
done:
if (settings)
@@ -1620,7 +1650,7 @@ done:
if (error) {
g_warning ("%s", error->message);
- dbus_g_method_return_error (info->context, error);
+ info->callback (NM_SETTINGS_CONNECTION_INTERFACE (connection), NULL, error, info->callback_data);
g_error_free (error);
}
@@ -1632,11 +1662,12 @@ done:
static gboolean
wireless_get_secrets (NMDevice *device,
- NMConnection *connection,
+ NMSettingsConnectionInterface *connection,
NMActiveConnection *active_connection,
const char *setting_name,
const char **hints,
- DBusGMethodInvocation *context,
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data,
NMApplet *applet,
GError **error)
{
@@ -1645,7 +1676,9 @@ wireless_get_secrets (NMDevice *device,
const char *specific_object;
if (!setting_name || !active_connection) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): setting name and active connection object required",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -1653,7 +1686,9 @@ wireless_get_secrets (NMDevice *device,
specific_object = nm_active_connection_get_specific_object (active_connection);
if (!specific_object) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): could not determine AP for specific object",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -1662,9 +1697,11 @@ wireless_get_secrets (NMDevice *device,
info = g_malloc0 (sizeof (NMWifiInfo));
ap = nm_device_wifi_get_access_point_by_path (NM_DEVICE_WIFI (device), specific_object);
- info->dialog = nma_wireless_dialog_new (applet, connection, device, ap);
+ info->dialog = nma_wireless_dialog_new (applet, NM_CONNECTION (connection), device, ap);
if (!info->dialog) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): couldn't display secrets UI",
__FILE__, __LINE__, __func__);
g_free (info);
@@ -1673,7 +1710,8 @@ wireless_get_secrets (NMDevice *device,
info->applet = applet;
info->active_connection = active_connection;
- info->context = context;
+ info->callback = callback;
+ info->callback_data = callback_data;
info->setting_name = g_strdup (setting_name);
g_signal_connect (info->dialog, "response",
diff --git a/src/applet-device-wired.c b/src/applet-device-wired.c
index d116326..2da4601 100644
--- a/src/applet-device-wired.c
+++ b/src/applet-device-wired.c
@@ -322,8 +322,9 @@ typedef struct {
GtkWidget *ok_button;
NMApplet *applet;
- NMConnection *connection;
- DBusGMethodInvocation *context;
+ NMSettingsConnectionInterface *connection;
+ NMANewSecretsRequestedFunc callback;
+ gpointer callback_data;
GtkWidget *dialog;
NMActiveConnection *active_connection;
@@ -411,8 +412,9 @@ pppoe_update_ui (NMConnection *connection, NMPppoeInfo *info)
static NMPppoeInfo *
pppoe_info_new (GladeXML *xml,
NMApplet *applet,
- DBusGMethodInvocation *context,
- NMConnection *connection,
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data,
+ NMSettingsConnectionInterface *connection,
NMActiveConnection *active_connection)
{
NMPppoeInfo *info;
@@ -428,7 +430,8 @@ pppoe_info_new (GladeXML *xml,
g_signal_connect (info->password_entry, "changed", G_CALLBACK (pppoe_verify), info);
info->applet = applet;
- info->context = context;
+ info->callback = callback;
+ info->callback_data = callback_data;
info->connection = g_object_ref (connection);
info->active_connection = active_connection;
@@ -458,16 +461,24 @@ destroy_pppoe_dialog (gpointer data, GObject *finalized)
}
static void
+update_cb (NMSettingsConnectionInterface *connection,
+ GError *error,
+ gpointer user_data)
+{
+ if (error)
+ g_warning ("Error saving connection secrets: (%d) %s", error->code, error->message);
+}
+
+static void
get_pppoe_secrets_cb (GtkDialog *dialog,
gint response,
gpointer user_data)
{
NMPppoeInfo *info = (NMPppoeInfo *) user_data;
- NMAGConfConnection *gconf_connection;
NMSetting *setting;
GHashTable *settings_hash;
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.
@@ -475,18 +486,22 @@ get_pppoe_secrets_cb (GtkDialog *dialog,
g_object_weak_unref (G_OBJECT (info->active_connection), destroy_pppoe_dialog, info);
if (response != GTK_RESPONSE_OK) {
- g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED,
"%s.%d (%s): canceled",
__FILE__, __LINE__, __func__);
goto done;
}
- setting = nm_connection_get_setting (info->connection, NM_TYPE_SETTING_PPPOE);
+ setting = nm_connection_get_setting (NM_CONNECTION (info->connection), NM_TYPE_SETTING_PPPOE);
pppoe_update_setting (NM_SETTING_PPPOE (setting), info);
secrets = nm_setting_to_hash (setting);
if (!secrets) {
- g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): failed to hash setting '%s'.",
__FILE__, __LINE__, __func__, nm_setting_get_name (setting));
goto done;
@@ -499,25 +514,23 @@ get_pppoe_secrets_cb (GtkDialog *dialog,
g_free, (GDestroyNotify) g_hash_table_destroy);
g_hash_table_insert (settings_hash, g_strdup (nm_setting_get_name (setting)), secrets);
- dbus_g_method_return (info->context, settings_hash);
+ 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.
*/
- gconf_connection = nma_gconf_settings_get_by_connection (info->applet->gconf_settings, info->connection);
- if (gconf_connection)
- nma_gconf_connection_save (gconf_connection);
+ nm_settings_connection_interface_update (info->connection, update_cb, NULL);
done:
- if (err) {
- g_warning ("%s", err->message);
- dbus_g_method_return_error (info->context, err);
- g_error_free (err);
+ if (error) {
+ g_warning ("%s", error->message);
+ info->callback (info->connection, NULL, error, info->callback_data);
+ g_error_free (error);
}
- nm_connection_clear_secrets (info->connection);
+ nm_connection_clear_secrets (NM_CONNECTION (info->connection));
destroy_pppoe_dialog (info, NULL);
}
@@ -534,10 +547,11 @@ show_password_toggled (GtkToggleButton *button, gpointer user_data)
static gboolean
pppoe_get_secrets (NMDevice *device,
- NMConnection *connection,
+ NMSettingsConnectionInterface *connection,
NMActiveConnection *active_connection,
const char *setting_name,
- DBusGMethodInvocation *context,
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data,
NMApplet *applet,
GError **error)
{
@@ -547,13 +561,15 @@ pppoe_get_secrets (NMDevice *device,
xml = glade_xml_new (GLADEDIR "/ce-page-dsl.glade", "DslPage", NULL);
if (!xml) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): couldn't display secrets UI",
__FILE__, __LINE__, __func__);
return FALSE;
}
- info = pppoe_info_new (xml, applet, context, connection, active_connection);
+ info = pppoe_info_new (xml, applet, callback, callback_data, connection, active_connection);
/* Create the dialog */
info->dialog = gtk_dialog_new ();
@@ -568,7 +584,7 @@ pppoe_get_secrets (NMDevice *device,
glade_xml_get_widget (xml, "DslPage"),
TRUE, TRUE, 0);
- pppoe_update_ui (connection, info);
+ pppoe_update_ui (NM_CONNECTION (connection), info);
w = glade_xml_get_widget (xml, "dsl_show_password");
g_signal_connect (G_OBJECT (w), "toggled", G_CALLBACK (show_password_toggled), info);
@@ -595,7 +611,8 @@ typedef struct {
NMApplet *applet;
NMActiveConnection *active_connection;
GtkWidget *dialog;
- DBusGMethodInvocation *context;
+ NMANewSecretsRequestedFunc callback;
+ gpointer callback_data;
} NM8021xInfo;
static void
@@ -614,12 +631,11 @@ get_8021x_secrets_cb (GtkDialog *dialog,
gpointer user_data)
{
NM8021xInfo *info = user_data;
- NMAGConfConnection *gconf_connection;
- NMConnection *connection = NULL;
+ NMSettingsConnectionInterface *connection = NULL;
NMSetting *setting;
GHashTable *settings_hash;
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.
@@ -627,7 +643,9 @@ get_8021x_secrets_cb (GtkDialog *dialog,
g_object_weak_unref (G_OBJECT (info->active_connection), destroy_8021x_dialog, info);
if (response != GTK_RESPONSE_OK) {
- g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED,
"%s.%d (%s): canceled",
__FILE__, __LINE__, __func__);
goto done;
@@ -635,15 +653,19 @@ get_8021x_secrets_cb (GtkDialog *dialog,
connection = nma_wired_dialog_get_connection (info->dialog);
if (!connection) {
- g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): couldn't get connection from wired dialog.",
__FILE__, __LINE__, __func__);
goto done;
}
- setting = nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
+ setting = nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_802_1X);
if (!setting) {
- g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
"%s.%d (%s): requested setting '802-1x' didn't"
" exist in the connection.",
__FILE__, __LINE__, __func__);
@@ -652,14 +674,16 @@ get_8021x_secrets_cb (GtkDialog *dialog,
secrets = nm_setting_to_hash (setting);
if (!secrets) {
- g_set_error (&err, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): failed to hash setting '%s'.",
__FILE__, __LINE__, __func__, nm_setting_get_name (setting));
goto done;
}
- utils_fill_connection_certs (connection);
- utils_clear_filled_connection_certs (connection);
+ utils_fill_connection_certs (NM_CONNECTION (connection));
+ utils_clear_filled_connection_certs (NM_CONNECTION (connection));
/* Returned secrets are a{sa{sv}}; this is the outer a{s...} hash that
* will contain all the individual settings hashes.
@@ -668,36 +692,35 @@ get_8021x_secrets_cb (GtkDialog *dialog,
g_free, (GDestroyNotify) g_hash_table_destroy);
g_hash_table_insert (settings_hash, g_strdup (nm_setting_get_name (setting)), secrets);
- dbus_g_method_return (info->context, settings_hash);
+ info->callback (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.
*/
- gconf_connection = nma_gconf_settings_get_by_connection (info->applet->gconf_settings, connection);
- if (gconf_connection)
- nma_gconf_connection_save (gconf_connection);
+ nm_settings_connection_interface_update (connection, update_cb, NULL);
done:
- if (err) {
- g_warning ("%s", err->message);
- dbus_g_method_return_error (info->context, err);
- g_error_free (err);
+ if (error) {
+ g_warning ("%s", error->message);
+ info->callback (connection, NULL, error, info->callback_data);
+ g_error_free (error);
}
if (connection)
- nm_connection_clear_secrets (connection);
+ nm_connection_clear_secrets (NM_CONNECTION (connection));
destroy_8021x_dialog (info, NULL);
}
static gboolean
nm_8021x_get_secrets (NMDevice *device,
- NMConnection *connection,
+ NMSettingsConnectionInterface *connection,
NMActiveConnection *active_connection,
const char *setting_name,
- DBusGMethodInvocation *context,
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data,
NMApplet *applet,
GError **error)
{
@@ -709,17 +732,20 @@ nm_8021x_get_secrets (NMDevice *device,
g_object_ref (connection),
device);
if (!dialog) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): couldn't display secrets UI",
__FILE__, __LINE__, __func__);
return FALSE;
}
info = g_malloc0 (sizeof (NM8021xInfo));
- info->context = context;
info->applet = applet;
info->active_connection = active_connection;
info->dialog = dialog;
+ info->callback = callback;
+ info->callback_data = callback_data;
g_signal_connect (dialog, "response", G_CALLBACK (get_8021x_secrets_cb), info);
@@ -737,11 +763,12 @@ nm_8021x_get_secrets (NMDevice *device,
static gboolean
wired_get_secrets (NMDevice *device,
- NMConnection *connection,
+ NMSettingsConnectionInterface *connection,
NMActiveConnection *active_connection,
const char *setting_name,
const char **hints,
- DBusGMethodInvocation *context,
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data,
NMApplet *applet,
GError **error)
{
@@ -749,9 +776,11 @@ wired_get_secrets (NMDevice *device,
const char *connection_type;
gboolean success = FALSE;
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+ 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_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
"%s.%d (%s): Invalid connection",
__FILE__, __LINE__, __func__);
return FALSE;
@@ -759,9 +788,24 @@ wired_get_secrets (NMDevice *device,
connection_type = nm_setting_connection_get_connection_type (s_con);
if (!strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)) {
- success = nm_8021x_get_secrets (device, connection, active_connection, setting_name, context, applet, error);
- } else if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME))
- success = pppoe_get_secrets (device, connection, active_connection, setting_name, context, applet, error);
+ success = nm_8021x_get_secrets (device,
+ connection,
+ active_connection,
+ setting_name,
+ callback,
+ callback_data,
+ applet,
+ error);
+ } else if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME)) {
+ success = pppoe_get_secrets (device,
+ connection,
+ active_connection,
+ setting_name,
+ callback,
+ callback_data,
+ applet,
+ error);
+ }
return success;
}
diff --git a/src/applet.c b/src/applet.c
index 9cf9735..e59946f 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -52,7 +52,6 @@
#include <nm-setting-connection.h>
#include <nm-setting-vpn.h>
#include <nm-active-connection.h>
-#include <nm-dbus-settings-system.h>
#include <nm-setting-wireless.h>
#include <glade/glade.h>
@@ -178,35 +177,17 @@ applet_get_default_active_connection (NMApplet *applet, NMDevice **device)
return default_ac;
}
-static void
-exported_connection_to_connection (gpointer data, gpointer user_data)
-{
- GSList **list = (GSList **) user_data;
-
- *list = g_slist_prepend (*list, nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (data)));
-}
-
-NMSettings *
+NMSettingsInterface *
applet_get_settings (NMApplet *applet)
{
- return (NMSettings *) applet->gconf_settings;
+ return NM_SETTINGS_INTERFACE (applet->gconf_settings);
}
GSList *
applet_get_all_connections (NMApplet *applet)
{
- GSList *list;
- GSList *connections = NULL;
-
- list = nm_settings_list_connections (NM_SETTINGS (applet->dbus_settings));
- g_slist_foreach (list, exported_connection_to_connection, &connections);
- g_slist_free (list);
-
- list = nm_settings_list_connections (NM_SETTINGS (applet->gconf_settings));
- g_slist_foreach (list, exported_connection_to_connection, &connections);
- g_slist_free (list);
-
- return connections;
+ 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 NMConnection *
@@ -528,19 +509,31 @@ clear_animation_timeout (NMApplet *applet)
}
static void
+save_timestamp_cb (NMSettingsConnectionInterface *connection,
+ GError *error,
+ gpointer user_data)
+{
+ if (error) {
+ g_warning ("Error saving connection %s timestamp: (%d) %s",
+ nm_connection_get_path (NM_CONNECTION (connection)),
+ error->code,
+ error->message);
+ }
+}
+
+static void
update_connection_timestamp (NMActiveConnection *active,
NMConnection *connection,
NMApplet *applet)
{
- NMAGConfConnection *gconf_connection;
- const char *path;
+ NMSettingsConnectionInterface *gconf_connection;
NMSettingConnection *s_con;
if (nm_active_connection_get_scope (active) != NM_CONNECTION_SCOPE_USER)
return;
- path = nm_connection_get_path (connection);
- gconf_connection = nma_gconf_settings_get_by_dbus_path (applet->gconf_settings, path);
+ gconf_connection = nm_settings_interface_get_connection_by_path (NM_SETTINGS_INTERFACE (applet->gconf_settings),
+ nm_connection_get_path (connection));
if (!gconf_connection)
return;
@@ -548,7 +541,7 @@ update_connection_timestamp (NMActiveConnection *active,
g_assert (s_con);
g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL), NULL);
- nma_gconf_connection_save (gconf_connection);
+ nm_settings_connection_interface_update (gconf_connection, save_timestamp_cb, NULL);
}
static char *
@@ -1030,6 +1023,8 @@ 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;
NMActiveConnection *active;
const char *service_name;
const char *connection_path;
@@ -1046,26 +1041,19 @@ applet_find_active_connection_for_device (NMDevice *device,
if (!nm_g_ptr_array_contains (devices, device))
continue;
- if (!strcmp (service_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS)) {
- NMDBusConnection *tmp;
+ 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_dbus_settings_get_connection_by_path (applet->dbus_settings, connection_path);
- if (tmp) {
- connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (tmp));
- if (out_active)
- *out_active = active;
- break;
- }
- } else if (!strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS)) {
- NMAGConfConnection *tmp;
-
- tmp = nma_gconf_settings_get_by_dbus_path (applet->gconf_settings, connection_path);
- if (tmp) {
- connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (tmp));
- if (out_active)
- *out_active = active;
- break;
- }
+ tmp = nm_settings_interface_get_connection_by_path (settings, connection_path);
+ if (tmp) {
+ connection = NM_CONNECTION (tmp);
+ if (out_active)
+ *out_active = active;
+ break;
}
}
@@ -1636,7 +1624,7 @@ foo_set_icon (NMApplet *applet, GdkPixbuf *pixbuf, guint32 layer)
}
-NMAGConfConnection *
+NMSettingsConnectionInterface *
applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet)
{
const GPtrArray *active_connections;
@@ -1645,7 +1633,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;
- NMAGConfConnection *gconf_connection;
+ NMSettingsConnectionInterface *connection;
const char *service_name;
const char *connection_path;
const GPtrArray *devices;
@@ -1661,11 +1649,9 @@ applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet)
if (!nm_g_ptr_array_contains (devices, device))
continue;
- gconf_connection = nma_gconf_settings_get_by_dbus_path (applet->gconf_settings, connection_path);
- if (!gconf_connection || !nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (gconf_connection)))
- continue;
-
- return gconf_connection;
+ connection = nm_settings_interface_get_connection_by_path (NM_SETTINGS_INTERFACE (applet->gconf_settings), connection_path);
+ if (connection)
+ return connection;
}
return NULL;
}
@@ -2109,14 +2095,14 @@ applet_schedule_update_icon (NMApplet *applet)
}
static NMDevice *
-find_active_device (NMAGConfConnection *exported,
+find_active_device (NMAGConfConnection *connection,
NMApplet *applet,
NMActiveConnection **out_active_connection)
{
const GPtrArray *active_connections;
int i;
- g_return_val_if_fail (exported != NULL, NULL);
+ g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (applet != NULL, NULL);
g_return_val_if_fail (out_active_connection != NULL, NULL);
g_return_val_if_fail (*out_active_connection == NULL, NULL);
@@ -2127,7 +2113,6 @@ find_active_device (NMAGConfConnection *exported,
active_connections = nm_client_get_active_connections (applet->nm_client);
for (i = 0; active_connections && (i < active_connections->len); i++) {
NMActiveConnection *active;
- NMConnection *connection;
const char *service_name;
const char *connection_path;
const GPtrArray *devices;
@@ -2139,8 +2124,7 @@ find_active_device (NMAGConfConnection *exported,
connection_path = nm_active_connection_get_connection (active);
- connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
- if (!strcmp (connection_path, nm_connection_get_path (connection))) {
+ if (!strcmp (connection_path, nm_connection_get_path (NM_CONNECTION (connection)))) {
devices = nm_active_connection_get_devices (active);
if (devices)
*out_active_connection = active;
@@ -2153,37 +2137,36 @@ find_active_device (NMAGConfConnection *exported,
static void
applet_settings_new_secrets_requested_cb (NMAGConfSettings *settings,
- NMAGConfConnection *exported,
+ NMAGConfConnection *connection,
const char *setting_name,
const char **hints,
gboolean ask_user,
- DBusGMethodInvocation *context,
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data,
gpointer user_data)
{
NMApplet *applet = NM_APPLET (user_data);
NMActiveConnection *active_connection = NULL;
- NMConnection *connection;
NMSettingConnection *s_con;
NMDevice *device;
NMADeviceClass *dclass;
GError *error = NULL;
- 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 (connection, NM_TYPE_SETTING_CONNECTION));
+ s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION);
g_return_if_fail (s_con != NULL);
/* 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_EXPORTED_CONNECTION (exported), ask_user, context);
+ nma_vpn_request_password (NM_SETTINGS_CONNECTION_INTERFACE (connection), ask_user, callback, callback_data);
return;
}
/* Find the active device for this connection */
- device = find_active_device (exported, applet, &active_connection);
+ device = find_active_device (connection, applet, &active_connection);
if (!device || !active_connection) {
- g_set_error (&error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): couldn't find details for connection",
__FILE__, __LINE__, __func__);
goto error;
@@ -2191,29 +2174,32 @@ applet_settings_new_secrets_requested_cb (NMAGConfSettings *settings,
dclass = get_device_class (device, applet);
if (!dclass) {
- g_set_error (&error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): device type unknown",
__FILE__, __LINE__, __func__);
goto error;
}
if (!dclass->get_secrets) {
- g_set_error (&error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_UNAVAILABLE,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE,
"%s.%d (%s): no secrets found",
__FILE__, __LINE__, __func__);
goto error;
}
/* Let the device class handle secrets */
- if (!dclass->get_secrets (device, connection, active_connection, setting_name,
- hints, context, applet, &error))
- goto error;
-
- return;
+ if (dclass->get_secrets (device, NM_SETTINGS_CONNECTION_INTERFACE (connection),
+ active_connection, setting_name, hints, callback,
+ callback_data, applet, &error))
+ return; /* success */
error:
g_warning ("%s", error->message);
- dbus_g_method_return_error (context, error);
+ callback (NM_SETTINGS_CONNECTION_INTERFACE (connection), NULL, error, callback_data);
g_error_free (error);
}
@@ -2231,8 +2217,7 @@ periodic_update_active_connection_timestamps (gpointer user_data)
for (i = 0; connections && (i < connections->len); i++) {
NMActiveConnection *active = NM_ACTIVE_CONNECTION (g_ptr_array_index (connections, i));
const char *path;
- NMAGConfConnection *gconf_connection;
- NMConnection *connection;
+ NMSettingsConnectionInterface *connection;
const GPtrArray *devices;
int k;
@@ -2240,8 +2225,8 @@ periodic_update_active_connection_timestamps (gpointer user_data)
continue;
path = nm_active_connection_get_connection (active);
- gconf_connection = nma_gconf_settings_get_by_dbus_path (applet->gconf_settings, path);
- if (!gconf_connection)
+ connection = nm_settings_interface_get_connection_by_path (NM_SETTINGS_INTERFACE (applet->gconf_settings), path);
+ if (!connection)
continue;
devices = nm_active_connection_get_devices (active);
@@ -2257,12 +2242,11 @@ periodic_update_active_connection_timestamps (gpointer user_data)
if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
NMSettingConnection *s_con;
- connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (gconf_connection));
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+ 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);
- nma_gconf_connection_save (gconf_connection);
+ nm_settings_connection_interface_update (connection, save_timestamp_cb, NULL);
break;
}
}
@@ -2612,16 +2596,14 @@ constructor (GType type,
}
g_signal_connect (G_OBJECT (dbus_mgr), "exit-now", G_CALLBACK (exit_cb), applet);
- applet->dbus_settings = (NMDBusSettings *) nm_dbus_settings_system_new (applet_dbus_manager_get_connection (dbus_mgr));
+ applet->system_settings = nm_remote_settings_system_new (applet_dbus_manager_get_connection (dbus_mgr));
- applet->gconf_settings = nma_gconf_settings_new ();
+ 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);
- dbus_g_connection_register_g_object (applet_dbus_manager_get_connection (dbus_mgr),
- NM_DBUS_PATH_SETTINGS,
- G_OBJECT (applet->gconf_settings));
+ nm_settings_service_export (NM_SETTINGS_SERVICE (applet->gconf_settings));
/* Start our DBus service */
if (!applet_dbus_manager_start_service (dbus_mgr)) {
@@ -2706,9 +2688,9 @@ static void finalize (GObject *object)
g_object_unref (applet->gconf_settings);
applet->gconf_settings = NULL;
}
- if (applet->dbus_settings) {
- g_object_unref (applet->dbus_settings);
- applet->dbus_settings = NULL;
+ if (applet->system_settings) {
+ g_object_unref (applet->system_settings);
+ applet->system_settings = NULL;
}
G_OBJECT_CLASS (nma_parent_class)->finalize (object);
diff --git a/src/applet.h b/src/applet.h
index db0102c..de4ddfc 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -45,7 +45,7 @@
#include <nm-device.h>
#include <NetworkManager.h>
#include <nm-active-connection.h>
-#include <nm-dbus-settings.h>
+#include <nm-remote-settings-system.h>
#include "applet-dbus-manager.h"
#include "nma-gconf-settings.h"
@@ -83,7 +83,7 @@ typedef struct
GMainLoop *loop;
NMClient *nm_client;
- NMDBusSettings *dbus_settings;
+ NMRemoteSettingsSystem *system_settings;
NMAGConfSettings *gconf_settings;
GConfClient * gconf_client;
@@ -184,11 +184,12 @@ struct NMADeviceClass {
gpointer user_data);
gboolean (*get_secrets) (NMDevice *device,
- NMConnection *connection,
+ NMSettingsConnectionInterface *connection,
NMActiveConnection *active_connection,
const char *setting_name,
const char **hints,
- DBusGMethodInvocation *context,
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data,
NMApplet *applet,
GError **error);
};
@@ -199,7 +200,7 @@ NMApplet *nm_applet_new (GMainLoop *loop);
void applet_schedule_update_icon (NMApplet *applet);
-NMSettings *applet_get_settings (NMApplet *applet);
+NMSettingsInterface *applet_get_settings (NMApplet *applet);
GSList *applet_get_all_connections (NMApplet *applet);
@@ -212,7 +213,7 @@ void applet_menu_item_activate_helper (NMDevice *device,
NMApplet *applet,
gpointer dclass_data);
-NMAGConfConnection *applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet);
+NMSettingsConnectionInterface *applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet);
void applet_do_notify (NMApplet *applet,
NotifyUrgency urgency,
diff --git a/src/connection-editor/Makefile.am b/src/connection-editor/Makefile.am
index 0f59066..465d748 100644
--- a/src/connection-editor/Makefile.am
+++ b/src/connection-editor/Makefile.am
@@ -10,18 +10,12 @@ nm_connection_editor_CPPFLAGS = \
-DDATADIR=\""$(datadir)"\" \
-DNMALOCALEDIR=\"$(datadir)/locale\" \
$(DBUS_CFLAGS) \
- $(POLKIT_CFLAGS) \
$(DISABLE_DEPRECATED) \
-I${top_srcdir}/src/gconf-helpers \
-I${top_srcdir}/src/utils \
-I${top_srcdir}/src/wireless-security \
-I${top_builddir}/src/marshallers
-if NO_POLKIT_GNOME
-nm_connection_editor_CPPFLAGS += \
- -I${top_srcdir}/src/polkit-helpers
-endif
-
nm_connection_editor_SOURCES = \
nm-connection-editor.c \
nm-connection-editor.h \
@@ -53,9 +47,7 @@ nm_connection_editor_SOURCES = \
ip4-routes-dialog.h \
ip4-routes-dialog.c \
ppp-auth-methods-dialog.c \
- ppp-auth-methods-dialog.h \
- polkit-helpers.c \
- polkit-helpers.h
+ ppp-auth-methods-dialog.h
nm-connection-editor-service-glue.h: $(top_srcdir)/src/connection-editor/nm-connection-editor-service.xml
dbus-binding-tool --prefix=nm_connection_editor_service --mode=glib-server --output=$@ $<
@@ -65,13 +57,7 @@ nm_connection_editor_LDADD = \
${top_builddir}/src/wireless-security/libwireless-security.la \
${top_builddir}/src/utils/libutils.la \
${top_builddir}/src/marshallers/libmarshallers.la \
- $(NMA_LIBS) \
- $(POLKIT_LIBS)
-
-if NO_POLKIT_GNOME
-nm_connection_editor_LDADD += \
- ${top_builddir}/src/polkit-helpers/libpolkit-helpers.la
-endif
+ $(NMA_LIBS)
gladedir = $(datadir)/nm-applet
glade_DATA = \
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index 0160367..0292adf 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -35,7 +35,6 @@
#include "ce-page.h"
#include "nma-marshal.h"
#include "utils.h"
-#include "polkit-helpers.h"
#define DBUS_TYPE_G_ARRAY_OF_STRING (dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING))
#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
@@ -182,53 +181,16 @@ emit_initialized (CEPage *self, GError *error)
}
static void
-try_secrets_again (PolKitAction *action,
- gboolean gained_privilege,
- GError *error,
- gpointer user_data)
-{
- CEPage *self = user_data;
- GError *real_error = NULL;
-
- if (error) {
- emit_initialized (self, error);
- return;
- }
-
- if (gained_privilege) {
- /* Yay! Got privilege, try again */
- internal_request_secrets (self, &real_error);
- } else if (!error) {
- /* Sometimes PK screws up and won't return an error even if
- * the operation failed.
- */
- g_set_error (&real_error, 0, 0, "%s",
- _("Insufficient privileges or unknown error retrieving system connection secrets."));
- }
-
- if (real_error)
- emit_initialized (self, real_error);
- g_clear_error (&real_error);
-}
-
-static void
get_secrets_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
{
CEPage *self = user_data;
- GError *pk_error = NULL;
GError *error = NULL;
GHashTable *settings = NULL, *setting_hash;
gboolean do_signal = TRUE;
- if (!dbus_g_proxy_end_call (proxy, call, &pk_error,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings,
- G_TYPE_INVALID)) {
- if (pk_helper_is_permission_denied_error (pk_error)) {
- /* If permission was denied, try to authenticate */
- if (pk_helper_obtain_auth (pk_error, self->parent_window, try_secrets_again, self, &error))
- do_signal = FALSE; /* 'secrets' signal will happen after auth result */
- }
- } else {
+ if (dbus_g_proxy_end_call (proxy, call, &error,
+ DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings,
+ G_TYPE_INVALID)) {
/* Update the connection with the new secrets */
setting_hash = g_hash_table_lookup (settings, self->setting_name);
if (setting_hash) {
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index c695c03..e30bc2b 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -40,12 +40,6 @@
#include <gdk/gdkx.h>
#include <glib/gi18n.h>
-#ifdef NO_POLKIT_GNOME
-#include "polkit-gnome.h"
-#else
-#include <polkit-gnome/polkit-gnome.h>
-#endif
-
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
#include <nm-setting-wired.h>
@@ -73,7 +67,6 @@
#include "page-mobile.h"
#include "page-ppp.h"
#include "page-vpn.h"
-#include "polkit-helpers.h"
G_DEFINE_TYPE (NMConnectionEditor, nm_connection_editor, G_TYPE_OBJECT)
@@ -169,7 +162,10 @@ connection_editor_validate (NMConnectionEditor *editor)
valid = TRUE;
done:
+ gtk_widget_set_sensitive (editor->system_checkbutton, valid);
+#if 0
g_object_set (editor->system_gnome_action, "master-sensitive", valid, NULL);
+#endif
}
static void
@@ -190,10 +186,12 @@ system_checkbutton_toggled_cb (GtkWidget *widget, NMConnectionEditor *editor)
} else
req_privs = TRUE;
+#if 0
if (req_privs)
g_object_set (editor->system_gnome_action, "polkit-action", editor->system_action, NULL);
else
g_object_set (editor->system_gnome_action, "polkit-action", NULL, NULL);
+#endif
/* Can't ever modify read-only connections */
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
@@ -234,6 +232,9 @@ set_editor_sensitivity (NMConnectionEditor *editor, gboolean sensitive)
}
}
+typedef guint32 PolKitResult;
+#define POLKIT_RESULT_UNKNOWN 0
+
static void
update_sensitivity (NMConnectionEditor *editor, PolKitResult pk_result)
{
@@ -247,11 +248,13 @@ update_sensitivity (NMConnectionEditor *editor, PolKitResult pk_result)
return;
}
+#if 0
if (pk_result == POLKIT_RESULT_UNKNOWN)
pk_result = polkit_gnome_action_get_polkit_result (editor->system_gnome_action);
if (pk_result == POLKIT_RESULT_NO || pk_result == POLKIT_RESULT_UNKNOWN)
denied = TRUE;
+#endif
switch (editor->orig_scope) {
case NM_CONNECTION_SCOPE_SYSTEM:
@@ -271,6 +274,7 @@ update_sensitivity (NMConnectionEditor *editor, PolKitResult pk_result)
}
}
+#if 0
static void
system_pk_result_changed_cb (PolKitGnomeAction *gnome_action,
PolKitResult result,
@@ -278,13 +282,16 @@ system_pk_result_changed_cb (PolKitGnomeAction *gnome_action,
{
update_sensitivity (editor, result);
}
+#endif
static void
nm_connection_editor_init (NMConnectionEditor *editor)
{
GtkWidget *dialog, *hbox;
+#if 0
const char *auth_label, *auth_tooltip;
const char *label, *tooltip;
+#endif
/* Yes, we mean applet.glade, not nm-connection-editor.glade. The wireless security bits
are taken from applet.glade. */
@@ -317,6 +324,7 @@ nm_connection_editor_init (NMConnectionEditor *editor)
editor->cancel_button = glade_xml_get_widget (editor->xml, "cancel_button");
editor->system_checkbutton = glade_xml_get_widget (editor->xml, "system_checkbutton");
+#if 0
editor->system_action = polkit_action_new ();
polkit_action_set_action_id (editor->system_action, "org.freedesktop.network-manager-settings.system.modify");
@@ -363,8 +371,10 @@ nm_connection_editor_init (NMConnectionEditor *editor)
g_signal_connect (editor->system_gnome_action, "polkit-result-changed",
G_CALLBACK (system_pk_result_changed_cb), editor);
-
editor->ok_button = polkit_gnome_action_create_button (editor->system_gnome_action);
+#endif
+
+ editor->ok_button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
hbox = glade_xml_get_widget (editor->xml, "action_area_hbox");
gtk_box_pack_end (GTK_BOX (hbox), editor->ok_button, TRUE, TRUE, 0);
}
@@ -391,6 +401,7 @@ dispose (GObject *object)
editor->xml = NULL;
}
+#if 0
if (editor->system_action) {
polkit_action_unref (editor->system_action);
editor->system_action = NULL;
@@ -399,6 +410,7 @@ dispose (GObject *object)
g_object_unref (editor->system_gnome_action);
editor->system_gnome_action = NULL;
}
+#endif
G_OBJECT_CLASS (nm_connection_editor_parent_class)->dispose (object);
}
diff --git a/src/connection-editor/nm-connection-editor.h b/src/connection-editor/nm-connection-editor.h
index 2e6c122..9bab69d 100644
--- a/src/connection-editor/nm-connection-editor.h
+++ b/src/connection-editor/nm-connection-editor.h
@@ -27,12 +27,6 @@
#include <glib-object.h>
#include <glade/glade-xml.h>
-#include <nm-settings.h>
-#ifdef NO_POLKIT_GNOME
-#include "polkit-gnome.h"
-#else
-#include <polkit-gnome/polkit-gnome.h>
-#endif
#define NM_TYPE_CONNECTION_EDITOR (nm_connection_editor_get_type ())
#define NM_IS_CONNECTION_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION_EDITOR))
@@ -46,8 +40,10 @@ typedef struct {
gboolean initialized;
NMConnectionScope orig_scope;
+#if 0
PolKitAction *system_action;
PolKitGnomeAction *system_gnome_action;
+#endif
GtkWidget *system_checkbutton;
gboolean system_settings_can_modify;
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index 0bace76..fcb772c 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -31,12 +31,6 @@
#include <gdk/gdkx.h>
#include <glib/gi18n.h>
-#ifdef NO_POLKIT_GNOME
-#include "polkit-gnome.h"
-#else
-#include <polkit-gnome/polkit-gnome.h>
-#endif
-
#include <nm-setting-connection.h>
#include <nm-connection.h>
#include <nm-setting.h>
@@ -50,6 +44,7 @@
#include <nm-setting-serial.h>
#include <nm-vpn-plugin-ui-interface.h>
#include <nm-utils.h>
+#include <nm-settings-system-interface.h>
#include "ce-page.h"
#include "page-wired.h"
@@ -62,7 +57,6 @@
#include "gconf-helpers.h"
#include "utils.h"
#include "vpn-helpers.h"
-#include "polkit-helpers.h"
G_DEFINE_TYPE (NMConnectionList, nm_connection_list, G_TYPE_OBJECT)
@@ -83,8 +77,6 @@ typedef struct {
GtkTreeView *treeview;
GtkWindow *list_window;
GtkWidget *button;
- PolKitAction *action;
- PolKitGnomeAction *gnome_action;
PageNewConnectionFunc new_func;
} ActionInfo;
@@ -114,14 +106,14 @@ error_dialog (GtkWindow *parent, const char *heading, const char *format, ...)
gtk_widget_destroy (dialog);
}
-static NMExportedConnection *
+static NMSettingsConnectionInterface *
get_active_connection (GtkTreeView *treeview)
{
GtkTreeSelection *selection;
GList *selected_rows;
GtkTreeModel *model = NULL;
GtkTreeIter iter;
- NMExportedConnection *exported = NULL;
+ NMSettingsConnectionInterface *connection = NULL;
selection = gtk_tree_view_get_selection (treeview);
selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
@@ -129,13 +121,13 @@ get_active_connection (GtkTreeView *treeview)
return NULL;
if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) selected_rows->data))
- gtk_tree_model_get (model, &iter, COL_CONNECTION, &exported, -1);
+ gtk_tree_model_get (model, &iter, COL_CONNECTION, &connection, -1);
/* free memory */
g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
g_list_free (selected_rows);
- return exported;
+ return connection;
}
#define TV_TYPE_TAG "ctype"
@@ -158,17 +150,16 @@ get_treeview_for_type (NMConnectionList *list, GType ctype)
}
static GtkListStore *
-get_model_for_connection (NMConnectionList *list, NMExportedConnection *exported)
+get_model_for_connection (NMConnectionList *list, NMSettingsConnectionInterface *connection)
{
- NMConnection *connection;
NMSettingConnection *s_con;
GtkTreeView *treeview;
GtkTreeModel *model;
const char *str_type;
- connection = nm_exported_connection_get_connection (exported);
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- str_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
+ s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION);
+ g_assert (s_con);
+ str_type = nm_setting_connection_get_connection_type (s_con);
if (!str_type) {
g_warning ("Ignoring incomplete connection");
@@ -193,8 +184,8 @@ get_model_for_connection (NMConnectionList *list, NMExportedConnection *exported
static gboolean
get_iter_for_connection (GtkTreeModel *model,
- NMExportedConnection *exported,
- GtkTreeIter *iter)
+ NMSettingsConnectionInterface *connection,
+ GtkTreeIter *iter)
{
GtkTreeIter temp_iter;
gboolean found = FALSE;
@@ -203,10 +194,10 @@ get_iter_for_connection (GtkTreeModel *model,
return FALSE;
do {
- NMExportedConnection *candidate = NULL;
+ NMSettingsConnectionInterface *candidate = NULL;
gtk_tree_model_get (model, &temp_iter, COL_CONNECTION, &candidate, -1);
- if (candidate && (candidate == exported)) {
+ if (candidate && (candidate == connection)) {
*iter = temp_iter;
found = TRUE;
break;
@@ -290,499 +281,322 @@ out:
static void
update_connection_row (GtkListStore *store,
- GtkTreeIter *iter,
- NMExportedConnection *exported)
+ GtkTreeIter *iter,
+ NMSettingsConnectionInterface *connection)
{
- NMConnection *connection;
NMSettingConnection *s_con;
char *last_used;
- connection = nm_exported_connection_get_connection (exported);
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
last_used = format_last_used (nm_setting_connection_get_timestamp (s_con));
gtk_list_store_set (store, iter,
- COL_ID, nm_setting_connection_get_id (s_con),
- COL_LAST_USED, last_used,
- COL_TIMESTAMP, nm_setting_connection_get_timestamp (s_con),
- COL_CONNECTION, exported,
- -1);
+ COL_ID, nm_setting_connection_get_id (s_con),
+ COL_LAST_USED, last_used,
+ COL_TIMESTAMP, nm_setting_connection_get_timestamp (s_con),
+ COL_CONNECTION, connection,
+ -1);
g_free (last_used);
}
/**********************************************/
-/* Connection removing */
+/* Connection deleting */
-typedef void (*ConnectionRemovedFn) (NMExportedConnection *exported,
- gboolean success,
- gpointer user_data);
+typedef void (*DeleteResultFunc) (NMConnectionList *list,
+ GError *error,
+ gpointer user_data);
typedef struct {
- NMExportedConnection *exported;
- GtkWindow *parent;
- ConnectionRemovedFn callback;
- gpointer user_data;
-} ConnectionRemoveInfo;
-
-static void remove_connection (NMExportedConnection *exported,
- GtkWindow *parent,
- ConnectionRemovedFn callback,
- gpointer user_data);
-
-static void
-remove_connection_cb (PolKitAction *action,
- gboolean gained_privilege,
- GError *error,
- gpointer user_data)
-{
- ConnectionRemoveInfo *info = (ConnectionRemoveInfo *) user_data;
- gboolean done = TRUE;
-
- if (gained_privilege) {
- remove_connection (info->exported, info->parent, info->callback, info->user_data);
- done = FALSE;
- } else if (error) {
- error_dialog (info->parent,
- _("Could not obtain required privileges"),
- "%s", error->message);
- g_error_free (error);
- } else {
- error_dialog (info->parent,
- _("Could not delete connection"),
- "%s", _("The connection could not be deleted due to an unknown error."));
- }
-
- if (done && info->callback)
- info->callback (info->exported, FALSE, info->user_data);
-
- g_object_unref (info->exported);
- g_slice_free (ConnectionRemoveInfo, info);
-}
+ NMConnectionList *list;
+ NMSettingsConnectionInterface *original;
+ DeleteResultFunc callback;
+ gpointer callback_data;
+} DeleteInfo;
static void
-remove_connection (NMExportedConnection *exported,
- GtkWindow *parent,
- ConnectionRemovedFn callback,
- gpointer user_data)
+delete_cb (NMSettingsConnectionInterface *connection_iface,
+ GError *error,
+ gpointer user_data)
{
- GError *error = NULL;
- gboolean success;
-
- success = nm_exported_connection_delete (exported, &error);
- if (!success) {
- gboolean auth_pending = FALSE;
-
- if (pk_helper_is_permission_denied_error (error)) {
- ConnectionRemoveInfo *info;
- GError *auth_error = NULL;
-
- info = g_slice_new (ConnectionRemoveInfo);
- info->exported = g_object_ref (exported);
- info->parent = parent;
- info->callback = callback;
- info->user_data = user_data;
-
- auth_pending = pk_helper_obtain_auth (error, parent, remove_connection_cb, info, &auth_error);
- if (auth_error) {
- error_dialog (parent,
- _("Could not move connection"),
- "%s", auth_error->message);
- g_error_free (auth_error);
- }
-
- if (!auth_pending) {
- g_object_unref (info->exported);
- g_slice_free (ConnectionRemoveInfo, info);
- }
- } else {
- error_dialog (parent,
- _("Could not move connection"),
- "%s", error->message);
- }
-
- g_error_free (error);
+ DeleteInfo *info = user_data;
+ NMConnection *connection = NM_CONNECTION (connection_iface);
+ NMConnectionScope scope;
- if (auth_pending)
- return;
- } else {
- NMConnection *connection;
+ scope = nm_connection_get_scope (connection);
+ if (!error && (scope == NM_CONNECTION_SCOPE_USER)) {
NMSettingConnection *s_con;
NMSettingVPN *s_vpn;
NMVpnPluginUiInterface *plugin;
+ GError *vpn_error = NULL;
+
+ /* Clean up keyring keys */
+ nm_gconf_clear_keyring_items (connection);
- connection = nm_exported_connection_get_connection (exported);
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
g_assert (s_con);
- if (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_USER) {
- /* Clean up keyring keys */
- nm_gconf_clear_keyring_items (connection);
- }
-
/* Clean up VPN secrets and any plugin-specific data */
- if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) {
- s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
- if (s_vpn) {
- plugin = vpn_get_plugin_by_service (nm_setting_vpn_get_service_type (s_vpn));
- if (plugin)
- if (!nm_vpn_plugin_ui_interface_delete_connection (plugin, connection, &error)) {
- g_warning ("%s: couldn't clean up VPN connection on delete: (%d) %s",
- __func__, error ? error->code : -1, error ? error->message : "unknown");
- if (error)
- g_error_free (error);
- }
- }
+ if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME))
+ goto done;
+
+ s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+ if (!s_vpn)
+ goto done;
+
+ plugin = vpn_get_plugin_by_service (nm_setting_vpn_get_service_type (s_vpn));
+ if (!plugin)
+ goto done;
+
+ if (!nm_vpn_plugin_ui_interface_delete_connection (plugin, connection, &vpn_error)) {
+ g_warning ("%s: couldn't clean up VPN connection on delete: (%d) %s",
+ __func__,
+ vpn_error ? vpn_error->code : -1,
+ (vpn_error && vpn_error->message) ? vpn_error->message : "unknown");
+ g_clear_error (&vpn_error);
}
}
- if (callback)
- callback (exported, success, user_data);
+done:
+ info->callback (info->list, error, info->callback_data);
+ g_free (info);
+}
+
+static void
+delete_connection (NMConnectionList *list,
+ NMSettingsConnectionInterface *connection,
+ DeleteResultFunc callback,
+ gpointer user_data)
+{
+ DeleteInfo *info;
+
+ info = g_malloc0 (sizeof (DeleteInfo));
+ info->list = list;
+ info->callback = callback;
+ info->callback_data = user_data;
+
+ nm_settings_connection_interface_delete (connection, delete_cb, info);
}
/**********************************************/
/* Connection adding */
-typedef void (*ConnectionAddedFn) (NMExportedConnection *exported,
- gboolean success,
- gpointer user_data);
+typedef void (*AddResultFunc) (NMConnectionList *list,
+ GError *error,
+ gpointer user_data);
typedef struct {
NMConnectionList *list;
NMConnectionEditor *editor;
- NMConnection *connection;
- ConnectionAddedFn callback;
- gpointer user_data;
-} ConnectionAddInfo;
-
-static void add_connection (NMConnectionList *self,
- NMConnectionEditor *editor,
- NMConnection *connection,
- ConnectionAddedFn callback,
- gpointer user_data);
+ AddResultFunc callback;
+ gpointer callback_data;
+} AddInfo;
static void
-add_connection_cb (PolKitAction *action,
- gboolean gained_privilege,
- GError *error,
- gpointer user_data)
+add_cb (NMSettingsInterface *settings,
+ GError *error,
+ gpointer user_data)
{
- ConnectionAddInfo *info = (ConnectionAddInfo *) user_data;
- GtkWindow *parent = nm_connection_editor_get_window (info->editor);
- gboolean done = TRUE;
-
- if (gained_privilege) {
- add_connection (info->list, info->editor, info->connection, info->callback, info->user_data);
- done = FALSE;
- } else if (error) {
- error_dialog (parent,
- _("Could not obtain required privileges"),
- "%s", error->message);
- g_error_free (error);
- } else {
- error_dialog (parent,
- _("Could not add connection"),
- "%s", _("The connection could not be added due to an unknown error."));
- }
+ AddInfo *info = user_data;
+ NMConnection *connection;
- if (done && info->callback)
- info->callback (NULL, FALSE, info->user_data);
+ if (!error) {
+ /* Let the VPN plugin save its secrets */
+ connection = nm_connection_editor_get_connection (info->editor);
+ if (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_USER)
+ nm_connection_editor_save_vpn_secrets (info->editor);
+ }
- g_object_unref (info->connection);
- g_slice_free (ConnectionAddInfo, info);
+ info->callback (info->list, error, info->callback_data);
+ g_free (info);
}
static void
add_connection (NMConnectionList *self,
NMConnectionEditor *editor,
- NMConnection *connection,
- ConnectionAddedFn callback,
- gpointer user_data)
+ AddResultFunc callback,
+ gpointer callback_data)
{
- NMExportedConnection *exported = NULL;
+ NMSettingsInterface *settings = NULL;
+ NMSettingsConnectionInterface *connection;
NMConnectionScope scope;
- gboolean success = FALSE;
+ AddInfo *info;
- scope = nm_connection_get_scope (connection);
- if (scope == NM_CONNECTION_SCOPE_SYSTEM) {
- GError *error = NULL;
-
- utils_fill_connection_certs (connection);
- success = nm_dbus_settings_system_add_connection (self->system_settings, connection, &error);
- utils_clear_filled_connection_certs (connection);
-
- if (!success) {
- gboolean pending_auth = FALSE;
- GtkWindow *parent;
-
- parent = nm_connection_editor_get_window (editor);
- if (pk_helper_is_permission_denied_error (error)) {
- ConnectionAddInfo *info;
- GError *auth_error = NULL;
-
- info = g_slice_new (ConnectionAddInfo);
- info->list = self;
- info->editor = editor;
- info->connection = g_object_ref (connection);
- info->callback = callback;
- info->user_data = user_data;
-
- pending_auth = pk_helper_obtain_auth (error, parent, add_connection_cb, info, &auth_error);
- if (auth_error) {
- error_dialog (parent,
- _("Could not add connection"),
- "%s", auth_error->message);
- g_error_free (auth_error);
- }
-
- if (!pending_auth) {
- g_object_unref (info->connection);
- g_slice_free (ConnectionAddInfo, info);
- }
- } else {
- error_dialog (parent,
- _("Could not add connection"),
- "%s", error->message);
- }
-
- g_error_free (error);
-
- if (pending_auth)
- return;
- }
- } else if (scope == NM_CONNECTION_SCOPE_USER) {
- exported = (NMExportedConnection *) nma_gconf_settings_add_connection (self->gconf_settings, connection);
- success = exported != NULL;
- if (success && editor)
- nm_connection_editor_save_vpn_secrets (editor);
- } else
- g_warning ("%s: unhandled connection scope %d!", __func__, scope);
-
- if (callback)
- callback (exported, success, user_data);
-
- if (exported)
- g_object_unref (exported);
+ info = g_malloc0 (sizeof (AddInfo));
+ info->list = self;
+ info->editor = editor;
+ info->callback = callback;
+ info->callback_data = callback_data;
+
+ connection = NM_SETTINGS_CONNECTION_INTERFACE (nm_connection_editor_get_connection (editor));
+ g_assert (connection);
+ scope = nm_connection_get_scope (NM_CONNECTION (connection));
+ if (scope == NM_CONNECTION_SCOPE_SYSTEM)
+ settings = NM_SETTINGS_INTERFACE (self->system_settings);
+ else if (scope == NM_CONNECTION_SCOPE_USER)
+ settings = NM_SETTINGS_INTERFACE (self->gconf_settings);
+ else
+ g_assert_not_reached ();
+
+ utils_fill_connection_certs (NM_CONNECTION (connection));
+ nm_settings_interface_add_connection (settings, connection, add_cb, info);
+ utils_clear_filled_connection_certs (NM_CONNECTION (connection));
}
/**********************************************/
/* Connection updating */
-typedef void (*ConnectionUpdatedFn) (NMConnectionList *list,
- gboolean success,
- gpointer user_data);
+typedef void (*UpdateResultFunc) (NMConnectionList *list,
+ GError *error,
+ gpointer user_data);
typedef struct {
NMConnectionList *list;
NMConnectionEditor *editor;
- NMExportedConnection *original;
+ NMSettingsConnectionInterface *original;
NMConnection *modified;
- ConnectionUpdatedFn callback;
- gpointer user_data;
-
- NMExportedConnection *added_connection;
-} ConnectionUpdateInfo;
-
-static void update_connection (NMConnectionList *list,
- NMConnectionEditor *editor,
- NMExportedConnection *original,
- NMConnection *modified,
- ConnectionUpdatedFn callback,
- gpointer user_data);
-
+ UpdateResultFunc callback;
+ gpointer callback_data;
+} UpdateInfo;
static void
-connection_update_done (ConnectionUpdateInfo *info, gboolean success)
+update_complete (UpdateInfo *info, GError *error)
{
- if (info->callback)
- info->callback (info->list, success, info->user_data);
-
+ info->callback (info->list, error, info->callback_data);
g_object_unref (info->original);
g_object_unref (info->modified);
- if (info->added_connection)
- g_object_unref (info->added_connection);
-
- g_slice_free (ConnectionUpdateInfo, info);
+ g_free (info);
}
static void
-connection_update_remove_done (NMExportedConnection *exported,
- gboolean success,
- gpointer user_data)
+update_remove_result_cb (NMConnectionList *list,
+ GError *error,
+ gpointer user_data)
{
- ConnectionUpdateInfo *info = (ConnectionUpdateInfo *) user_data;
-
- if (success)
- connection_update_done (info, success);
- else if (info->added_connection) {
- GtkWindow *parent;
+ UpdateInfo *info = user_data;
- /* Revert the scope of the original connection and remove the connection we just successfully added */
- /* FIXME: loops forever on error */
- parent = nm_connection_editor_get_window (info->editor);
- remove_connection (info->added_connection, parent, connection_update_remove_done, info);
- }
+ update_complete (info, error);
}
static void
-connection_update_add_done (NMExportedConnection *exported,
- gboolean success,
- gpointer user_data)
+update_add_result_cb (NMConnectionList *list, GError *error, gpointer user_data)
{
- ConnectionUpdateInfo *info = (ConnectionUpdateInfo *) user_data;
-
- if (success) {
- /* Adding the connection with different scope succeeded, now try to remove the original */
- info->added_connection = exported ? g_object_ref (exported) : NULL;
- remove_connection (info->original, GTK_WINDOW (info->editor), connection_update_remove_done, info);
- } else
- connection_update_done (info, success);
+ UpdateInfo *info = user_data;
+
+ if (error) {
+ update_complete (info, error);
+ return;
+ }
+
+ /* Now try to remove the original connection */
+ delete_connection (list, info->original, update_remove_result_cb, info);
}
static void
-update_connection_cb (PolKitAction *action,
- gboolean gained_privilege,
- GError *error,
- gpointer user_data)
+update_cb (NMSettingsConnectionInterface *connection,
+ GError *error,
+ gpointer user_data)
{
- ConnectionUpdateInfo *info = (ConnectionUpdateInfo *) user_data;
- gboolean done = TRUE;
- GtkWindow *parent;
+ UpdateInfo *info = user_data;
- parent = nm_connection_editor_get_window (info->editor);
- if (gained_privilege) {
- update_connection (info->list, info->editor, info->original, info->modified, info->callback, info->user_data);
- done = FALSE;
- } else if (error) {
- error_dialog (parent,
- _("Could not update connection"),
- "%s", error->message);
- g_error_free (error);
- } else {
- error_dialog (parent,
- _("Could not update connection"),
- "%s", _("The connection could not be updated due to an unknown error."));
+ if (!error) {
+ /* Save user-connection vpn secrets */
+ if (nm_connection_get_scope (NM_CONNECTION (connection)) == NM_CONNECTION_SCOPE_USER)
+ nm_connection_editor_save_vpn_secrets (info->editor);
}
- if (done)
- connection_update_done (info, FALSE);
- else {
- g_object_unref (info->original);
- g_object_unref (info->modified);
- g_slice_free (ConnectionUpdateInfo, info);
- }
+ update_complete (info, error);
}
static void
update_connection (NMConnectionList *list,
NMConnectionEditor *editor,
- NMExportedConnection *original,
- NMConnection *modified,
- ConnectionUpdatedFn callback,
+ NMSettingsConnectionInterface *original,
+ UpdateResultFunc callback,
gpointer user_data)
{
+ NMConnection *modified = nm_connection_editor_get_connection (editor);
NMConnectionScope original_scope;
- ConnectionUpdateInfo *info;
+ UpdateInfo *info;
- info = g_slice_new0 (ConnectionUpdateInfo);
+ info = g_malloc0 (sizeof (UpdateInfo));
info->list = list;
info->editor = editor;
info->original = g_object_ref (original);
info->modified = g_object_ref (modified);
info->callback = callback;
- info->user_data = user_data;
+ info->callback_data = user_data;
- original_scope = nm_connection_get_scope (nm_exported_connection_get_connection (original));
+ original_scope = nm_connection_get_scope (NM_CONNECTION (original));
if (nm_connection_get_scope (modified) == original_scope) {
/* The easy part: Connection is updated */
GHashTable *new_settings;
GError *error = NULL;
- gboolean success;
- gboolean pending_auth = FALSE;
- GtkWindow *parent;
utils_fill_connection_certs (modified);
new_settings = nm_connection_to_hash (modified);
-
- /* Hack; make sure that gconf private values are copied */
- nm_gconf_copy_private_connection_values (nm_exported_connection_get_connection (original),
- modified);
-
- success = nm_exported_connection_update (original, new_settings, &error);
- g_hash_table_destroy (new_settings);
utils_clear_filled_connection_certs (modified);
- parent = nm_connection_editor_get_window (editor);
- if (!success) {
- if (pk_helper_is_permission_denied_error (error)) {
- GError *auth_error = NULL;
-
- pending_auth = pk_helper_obtain_auth (error, parent, update_connection_cb, info, &auth_error);
- if (auth_error) {
- error_dialog (parent,
- _("Could not update connection"),
- "%s", auth_error->message);
- g_error_free (auth_error);
- }
- } else {
- error_dialog (parent,
- _("Could not update connection"),
- "%s", error->message);
- }
-
+ if (!nm_connection_replace_settings (NM_CONNECTION (original),
+ new_settings,
+ &error)) {
+ callback (list, error, user_data);
g_error_free (error);
} else {
- /* Save user-connection vpn secrets */
- if (editor && (original_scope == NM_CONNECTION_SCOPE_USER))
- nm_connection_editor_save_vpn_secrets (editor);
+ /* Hack; make sure that gconf private values are copied */
+ nm_gconf_copy_private_connection_values (NM_CONNECTION (original), modified);
+ nm_settings_connection_interface_update (original, update_cb, info);
}
-
- if (!pending_auth)
- connection_update_done (info, success);
} else {
/* The hard part: Connection scope changed:
- Add the exported connection,
- if it succeeds, remove the old one. */
- add_connection (list, editor, modified, connection_update_add_done, info);
+ * Add the modified connection to the new settings service, then delete
+ * the original connection from the old settings service.
+ */
+ add_connection (list, editor, update_add_result_cb, info);
}
}
+/**********************************************/
+/* dialog/UI handling stuff */
+
static void
-add_done_cb (NMConnectionEditor *editor, gint response, GError *error, gpointer user_data)
+add_finished_cb (NMConnectionList *list, GError *error, gpointer user_data)
+{
+ NMConnectionEditor *editor = NM_CONNECTION_EDITOR (user_data);
+ GtkWindow *parent;
+
+ if (error) {
+ parent = nm_connection_editor_get_window (editor);
+ error_dialog (parent, _("Connection add failed"), "%s", error->message);
+ }
+
+ g_hash_table_remove (list->editors, nm_connection_editor_get_connection (editor));
+}
+
+
+static void
+add_response_cb (NMConnectionEditor *editor, gint response, GError *error, gpointer user_data)
{
ActionInfo *info = (ActionInfo *) user_data;
NMConnection *connection;
const char *message = _("An unknown error ocurred.");
- connection = nm_connection_editor_get_connection (editor);
-
- switch (response) {
- case GTK_RESPONSE_NONE:
+ if (response == GTK_RESPONSE_OK) {
+ add_connection (info->list, editor, add_finished_cb, editor);
+ return;
+ } else if (response == GTK_RESPONSE_NONE) {
if (error && error->message)
message = error->message;
error_dialog (GTK_WINDOW (editor->window),
_("Error initializing editor"),
"%s", message);
- break;
- case GTK_RESPONSE_OK:
- add_connection (info->list, editor, connection, NULL, NULL);
- break;
- case GTK_RESPONSE_CANCEL:
- break;
- default:
- g_assert_not_reached ();
- break;
}
+ connection = nm_connection_editor_get_connection (editor);
g_hash_table_remove (info->list->editors, connection);
}
-typedef struct {
- NMConnection *new;
- NMConnectionList *list;
-} AddConnectionInfo;
-
static void
really_add_connection (NMConnection *connection,
gboolean canceled,
@@ -793,7 +607,7 @@ really_add_connection (NMConnection *connection,
NMConnectionEditor *editor;
GError *editor_error = NULL;
const char *message = _("The connection editor dialog could not be initialized due to an unknown error.");
- gboolean can_modify;
+ gboolean can_modify = FALSE;
g_return_if_fail (info != NULL);
@@ -808,7 +622,11 @@ really_add_connection (NMConnection *connection,
return;
}
- can_modify = nm_dbus_settings_system_get_can_modify (info->list->system_settings);
+ g_object_get (G_OBJECT (info->list->system_settings),
+ NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY,
+ &can_modify,
+ NULL);
+
editor = nm_connection_editor_new (connection, can_modify, &error);
if (!editor) {
error_dialog (info->list_window,
@@ -819,7 +637,7 @@ really_add_connection (NMConnection *connection,
return;
}
- g_signal_connect (G_OBJECT (editor), "done", G_CALLBACK (add_done_cb), info);
+ g_signal_connect (G_OBJECT (editor), "done", G_CALLBACK (add_response_cb), info);
g_hash_table_insert (info->list->editors, connection, editor);
nm_connection_editor_run (editor);
@@ -830,12 +648,12 @@ page_get_connections (gpointer user_data)
{
ActionInfo *info = (ActionInfo *) user_data;
- return g_slist_concat (nm_settings_list_connections (NM_SETTINGS (info->list->system_settings)),
- nm_settings_list_connections (NM_SETTINGS (info->list->gconf_settings)));
+ return g_slist_concat (nm_settings_interface_list_connections (NM_SETTINGS_INTERFACE (info->list->system_settings)),
+ nm_settings_interface_list_connections (NM_SETTINGS_INTERFACE (info->list->gconf_settings)));
}
static void
-add_connection_clicked (GtkButton *button, gpointer user_data)
+add_clicked (GtkButton *button, gpointer user_data)
{
ActionInfo *info = (ActionInfo *) user_data;
NMConnectionList *list = info->list;
@@ -856,17 +674,18 @@ add_connection_clicked (GtkButton *button, gpointer user_data)
typedef struct {
NMConnectionList *list;
- NMExportedConnection *original_connection;
-} EditConnectionInfo;
+ NMConnectionEditor *editor;
+ NMSettingsConnectionInterface *original_connection;
+} EditInfo;
static void
connection_updated_cb (NMConnectionList *list,
- gboolean success,
- gpointer user_data)
+ GError *error,
+ gpointer user_data)
{
- EditConnectionInfo *info = (EditConnectionInfo *) user_data;
+ EditInfo *info = user_data;
- if (success) {
+ if (!error) {
GtkListStore *store;
GtkTreeIter iter;
@@ -883,7 +702,7 @@ connection_updated_cb (NMConnectionList *list,
static void
edit_done_cb (NMConnectionEditor *editor, gint response, GError *error, gpointer user_data)
{
- EditConnectionInfo *info = (EditConnectionInfo *) user_data;
+ EditInfo *info = user_data;
const char *message = _("An unknown error ocurred.");
g_hash_table_remove (info->list->editors, info->original_connection);
@@ -892,7 +711,11 @@ edit_done_cb (NMConnectionEditor *editor, gint response, GError *error, gpointer
if (error && error->message)
message = error->message;
error_dialog (GTK_WINDOW (editor->window), _("Error initializing editor"), "%s", message);
- } else if (response == GTK_RESPONSE_OK) {
+ g_free (info);
+ return;
+ }
+
+ if (response == GTK_RESPONSE_OK) {
NMConnection *connection;
GError *edit_error = NULL;
gboolean success;
@@ -905,15 +728,15 @@ edit_done_cb (NMConnectionEditor *editor, gint response, GError *error, gpointer
if (success) {
update_connection (info->list, editor, info->original_connection,
- connection, connection_updated_cb, info);
+ connection_updated_cb, info);
} else {
g_warning ("%s: invalid connection after update: bug in the "
"'%s' / '%s' invalid: %d",
__func__,
g_type_name (nm_connection_lookup_setting_type_by_quark (edit_error->domain)),
edit_error->message, edit_error->code);
+ connection_updated_cb (info->list, edit_error, info);
g_error_free (edit_error);
- connection_updated_cb (info->list, FALSE, user_data);
}
}
}
@@ -921,28 +744,31 @@ edit_done_cb (NMConnectionEditor *editor, gint response, GError *error, gpointer
static void
do_edit (ActionInfo *info)
{
- NMExportedConnection *exported;
- NMConnection *connection;
+ NMSettingsConnectionInterface *connection;
+ NMConnection *duplicated;
NMConnectionEditor *editor;
- EditConnectionInfo *edit_info;
+ EditInfo *edit_info;
GError *error = NULL;
const char *message = _("The connection editor dialog could not be initialized due to an unknown error.");
+ gboolean can_modify = FALSE;
- exported = get_active_connection (info->treeview);
- g_return_if_fail (exported != NULL);
+ connection = get_active_connection (info->treeview);
+ g_return_if_fail (connection != NULL);
/* Don't allow two editors for the same connection */
- editor = NM_CONNECTION_EDITOR (g_hash_table_lookup (info->list->editors, exported));
+ editor = (NMConnectionEditor *) g_hash_table_lookup (info->list->editors, connection);
if (editor) {
nm_connection_editor_present (editor);
return;
}
- connection = nm_gconf_connection_duplicate (nm_exported_connection_get_connection (exported));
- editor = nm_connection_editor_new (connection,
- nm_dbus_settings_system_get_can_modify (info->list->system_settings),
- &error);
- g_object_unref (connection);
+ g_object_get (G_OBJECT (info->list->system_settings),
+ NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY, &can_modify,
+ NULL);
+
+ duplicated = nm_gconf_connection_duplicate (NM_CONNECTION (connection));
+ editor = nm_connection_editor_new (duplicated, can_modify, &error);
+ g_object_unref (duplicated);
if (!editor) {
error_dialog (info->list_window,
@@ -952,12 +778,13 @@ do_edit (ActionInfo *info)
return;
}
- edit_info = g_new (EditConnectionInfo, 1);
+ edit_info = g_malloc0 (sizeof (EditInfo));
edit_info->list = info->list;
- edit_info->original_connection = g_object_ref (exported);
+ edit_info->editor = editor;
+ edit_info->original_connection = g_object_ref (connection);
g_signal_connect (editor, "done", G_CALLBACK (edit_done_cb), edit_info);
- g_hash_table_insert (info->list->editors, exported, editor);
+ g_hash_table_insert (info->list->editors, connection, editor);
nm_connection_editor_run (editor);
}
@@ -969,37 +796,32 @@ edit_connection_cb (GtkButton *button, gpointer user_data)
}
static void
-connection_remove_done (NMExportedConnection *exported,
- gboolean success,
- gpointer user_data)
+delete_result_cb (NMConnectionList *list,
+ GError *error,
+ gpointer user_data)
{
- if (success) {
- NMConnectionList *list = (NMConnectionList *) user_data;
+ GtkWindow *parent = GTK_WINDOW (user_data);
- /* Close any open editor windows for this connection */
- g_hash_table_remove (list->editors, exported);
- }
+ if (error)
+ error_dialog (parent, _("Connection delete failed"), "%s", error->message);
}
static void
-delete_connection_cb (GtkButton *button, gpointer user_data)
+delete_clicked (GtkButton *button, gpointer user_data)
{
ActionInfo *info = (ActionInfo *) user_data;
- NMExportedConnection *exported = NULL;
- NMConnection *connection;
+ NMSettingsConnectionInterface *connection;
NMSettingConnection *s_con;
GtkWidget *dialog;
const char *id;
guint result;
- exported = get_active_connection (info->treeview);
- g_return_if_fail (exported != NULL);
- connection = nm_exported_connection_get_connection (exported);
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
+ connection = get_active_connection (info->treeview);
+ g_return_if_fail (connection != NULL);
- if (!id)
- return;
+ s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION);
+ g_assert (s_con);
+ id = nm_setting_connection_get_id (s_con);
dialog = gtk_message_dialog_new (GTK_WINDOW (info->list->dialog),
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -1017,34 +839,37 @@ delete_connection_cb (GtkButton *button, gpointer user_data)
gtk_widget_destroy (dialog);
if (result == GTK_RESPONSE_YES)
- remove_connection (exported, GTK_WINDOW (info->list->dialog), connection_remove_done, info->list);
+ delete_connection (info->list, connection, delete_result_cb, GTK_WINDOW (info->list->dialog));
}
+typedef guint32 PolKitResult;
+#define POLKIT_RESULT_UNKNOWN 0
+
static gboolean
check_sensitivity (ActionInfo *info, PolKitResult pk_result)
{
gboolean sensitive = TRUE;
- NMExportedConnection *exported = NULL;
- NMConnection *connection = NULL;
+ NMSettingsConnectionInterface *connection = NULL;
- exported = get_active_connection (info->treeview);
- if (exported)
- connection = nm_exported_connection_get_connection (exported);
+ connection = get_active_connection (info->treeview);
if (!connection)
return FALSE;
- if (nm_connection_get_scope (connection) != NM_CONNECTION_SCOPE_SYSTEM)
+ if (nm_connection_get_scope (NM_CONNECTION (connection)) != NM_CONNECTION_SCOPE_SYSTEM)
return TRUE;
+#if 0
if (pk_result == POLKIT_RESULT_UNKNOWN)
pk_result = polkit_gnome_action_get_polkit_result (info->gnome_action);
if (pk_result == POLKIT_RESULT_NO || pk_result == POLKIT_RESULT_UNKNOWN)
sensitive = FALSE;
+#endif
return sensitive;
}
+#if 0
static void
system_pk_result_changed_cb (PolKitGnomeAction *gnome_action,
PolKitResult result,
@@ -1052,6 +877,7 @@ system_pk_result_changed_cb (PolKitGnomeAction *gnome_action,
{
gtk_widget_set_sensitive (info->button, check_sensitivity (info, result));
}
+#endif
static void
pk_button_selection_changed_cb (GtkTreeSelection *selection, gpointer user_data)
@@ -1059,8 +885,7 @@ pk_button_selection_changed_cb (GtkTreeSelection *selection, gpointer user_data)
ActionInfo *info = (ActionInfo *) user_data;
GtkTreeIter iter;
GtkTreeModel *model;
- NMExportedConnection *exported;
- NMConnection *connection = NULL;
+ NMSettingsConnectionInterface *connection;
NMSettingConnection *s_con;
gboolean can_do_action = FALSE;
gboolean req_privs = FALSE;
@@ -1068,16 +893,15 @@ pk_button_selection_changed_cb (GtkTreeSelection *selection, gpointer user_data)
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
goto done;
- exported = get_active_connection (info->treeview);
- if (exported)
- connection = nm_exported_connection_get_connection (exported);
+ connection = get_active_connection (info->treeview);
if (!connection)
goto done;
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+ s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection),
+ NM_TYPE_SETTING_CONNECTION);
g_assert (s_con);
- if (nm_connection_get_scope (connection) != NM_CONNECTION_SCOPE_SYSTEM)
+ if (nm_connection_get_scope (NM_CONNECTION (connection)) != NM_CONNECTION_SCOPE_SYSTEM)
can_do_action = !nm_setting_connection_get_read_only (s_con);
else {
if (!nm_setting_connection_get_read_only (s_con))
@@ -1086,8 +910,11 @@ pk_button_selection_changed_cb (GtkTreeSelection *selection, gpointer user_data)
}
done:
+ gtk_widget_set_sensitive (info->button, can_do_action);
+#if 0
g_object_set (info->gnome_action, "polkit-action", req_privs ? info->action : NULL, NULL);
g_object_set (info->gnome_action, "master-sensitive", can_do_action, NULL);
+#endif
}
static void
@@ -1095,8 +922,7 @@ vpn_list_selection_changed_cb (GtkTreeSelection *selection, gpointer user_data)
{
ActionInfo *info = (ActionInfo *) user_data;
NMVpnPluginUiInterface *plugin;
- NMExportedConnection *exported;
- NMConnection *connection = NULL;
+ NMSettingsConnectionInterface *connection;
NMSettingVPN *s_vpn;
const char *service_type;
GtkTreeIter iter;
@@ -1107,13 +933,11 @@ vpn_list_selection_changed_cb (GtkTreeSelection *selection, gpointer user_data)
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
goto done;
- exported = get_active_connection (info->treeview);
- if (exported)
- connection = nm_exported_connection_get_connection (exported);
+ connection = get_active_connection (info->treeview);
if (!connection)
goto done;
- s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
+ s_vpn = NM_SETTING_VPN (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_VPN));
service_type = s_vpn ? nm_setting_vpn_get_service_type (s_vpn) : NULL;
if (!service_type)
@@ -1142,6 +966,7 @@ import_success_cb (NMConnection *connection, gpointer user_data)
char *s;
GError *error = NULL;
const char *message = _("The connection editor dialog could not be initialized due to an unknown error.");
+ gboolean can_modify = FALSE;
/* Basic sanity checks of the connection */
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
@@ -1154,9 +979,9 @@ import_success_cb (NMConnection *connection, gpointer user_data)
if (!s) {
GSList *connections;
- connections = nm_settings_list_connections (NM_SETTINGS (info->list->system_settings));
+ connections = nm_settings_interface_list_connections (NM_SETTINGS_INTERFACE (info->list->system_settings));
connections = g_slist_concat (connections,
- nm_settings_list_connections (NM_SETTINGS (info->list->gconf_settings)));
+ nm_settings_interface_list_connections (NM_SETTINGS_INTERFACE (info->list->gconf_settings)));
s = utils_next_available_name (connections, _("VPN connection %d"));
g_object_set (s_con, NM_SETTING_CONNECTION_ID, s, NULL);
@@ -1197,9 +1022,12 @@ import_success_cb (NMConnection *connection, gpointer user_data)
return;
}
- editor = nm_connection_editor_new (connection,
- nm_dbus_settings_system_get_can_modify (info->list->system_settings),
- &error);
+ g_object_get (G_OBJECT (info->list->system_settings),
+ NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY,
+ &can_modify,
+ NULL);
+
+ editor = nm_connection_editor_new (connection, can_modify, &error);
if (!editor) {
error_dialog (info->list_window,
_("Could not edit imported connection"),
@@ -1208,7 +1036,7 @@ import_success_cb (NMConnection *connection, gpointer user_data)
return;
}
- g_signal_connect (G_OBJECT (editor), "done", G_CALLBACK (add_done_cb), info);
+ g_signal_connect (G_OBJECT (editor), "done", G_CALLBACK (add_response_cb), info);
g_hash_table_insert (info->list->editors, connection, editor);
nm_connection_editor_run (editor);
@@ -1224,16 +1052,11 @@ static void
export_vpn_cb (GtkButton *button, gpointer user_data)
{
ActionInfo *info = (ActionInfo *) user_data;
- NMExportedConnection *exported;
- NMConnection *connection = NULL;
-
- exported = get_active_connection (info->treeview);
- if (exported)
- connection = nm_exported_connection_get_connection (exported);
- if (!connection)
- return;
+ NMSettingsConnectionInterface *connection;
- vpn_export (connection);
+ connection = get_active_connection (info->treeview);
+ if (connection)
+ vpn_export (NM_CONNECTION (connection));
}
static void
@@ -1257,8 +1080,10 @@ dialog_response_cb (GtkDialog *dialog, guint response, gpointer user_data)
static void
nm_connection_list_init (NMConnectionList *list)
{
+#if 0
list->system_action = polkit_action_new ();
polkit_action_set_action_id (list->system_action, "org.freedesktop.network-manager-settings.system.modify");
+#endif
}
static void
@@ -1283,7 +1108,9 @@ dispose (GObject *object)
if (list->unknown_icon)
g_object_unref (list->unknown_icon);
+#if 0
polkit_action_unref (list->system_action);
+#endif
if (list->dialog)
gtk_widget_destroy (list->dialog);
@@ -1375,8 +1202,10 @@ action_info_free (ActionInfo *info)
{
g_return_if_fail (info != NULL);
+#if 0
/* gnome_action should have been destroyed when the dialog got destroyed */
polkit_action_unref (info->action);
+#endif
g_free (info);
}
@@ -1384,8 +1213,7 @@ static ActionInfo *
action_info_new (NMConnectionList *list,
GtkTreeView *treeview,
GtkWindow *list_window,
- GtkWidget *button,
- PolKitAction *action)
+ GtkWidget *button)
{
ActionInfo *info;
@@ -1396,21 +1224,21 @@ action_info_new (NMConnectionList *list,
info->treeview = treeview;
info->list_window = list_window;
info->button = button;
- info->action = polkit_action_ref (action);
return info;
}
static void
action_info_set_button (ActionInfo *info,
- GtkWidget *button,
- PolKitGnomeAction *gnome_action)
+ GtkWidget *button)
{
g_return_if_fail (info != NULL);
info->button = button;
+#if 0
if (info->gnome_action)
g_object_unref (info->gnome_action);
info->gnome_action = gnome_action;
+#endif
}
static void
@@ -1443,13 +1271,15 @@ create_system_action_button (const char *name,
const char *tooltip,
const char *stock_icon,
const char *auth_icon,
+#if 0
GCallback result_callback,
+#endif
GtkWidget *hbox,
- PolKitGnomeAction **out_action,
gpointer user_data)
{
- PolKitGnomeAction *action;
GtkWidget *button;
+#if 0
+ PolKitGnomeAction *action;
action = polkit_gnome_action_new (name);
@@ -1491,9 +1321,13 @@ create_system_action_button (const char *name,
G_CALLBACK (result_callback), user_data);
button = polkit_gnome_action_create_button (action);
+#endif
+ button = gtk_button_new_from_stock (stock_icon);
gtk_box_pack_end (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+#if 0
*out_action = action;
+#endif
return button;
}
@@ -1508,7 +1342,9 @@ add_connection_buttons (NMConnectionList *self,
GtkWidget *button, *hbox;
ActionInfo *info;
GtkTreeSelection *selection;
+#if 0
PolKitGnomeAction *action = NULL;
+#endif
selection = gtk_tree_view_get_selection (treeview);
@@ -1516,8 +1352,8 @@ add_connection_buttons (NMConnectionList *self,
name = g_strdup_printf ("%s_add", prefix);
button = glade_xml_get_widget (self->gui, name);
g_free (name);
- info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), NULL, self->system_action);
- g_signal_connect (button, "clicked", G_CALLBACK (add_connection_clicked), info);
+ info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), NULL);
+ g_signal_connect (button, "clicked", G_CALLBACK (add_clicked), info);
if (ctype == NM_TYPE_SETTING_VPN) {
GHashTable *plugins;
@@ -1533,8 +1369,7 @@ add_connection_buttons (NMConnectionList *self,
g_free (name);
/* Edit */
- info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), NULL, self->system_action);
- action = NULL;
+ info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), NULL);
button = create_system_action_button ("system-edit",
_("Edit..."),
_("Authenticate to edit the selected connection."),
@@ -1542,19 +1377,19 @@ add_connection_buttons (NMConnectionList *self,
_("Edit the selected connection."),
GTK_STOCK_EDIT,
GTK_STOCK_DIALOG_AUTHENTICATION,
+#if 0
G_CALLBACK (system_pk_result_changed_cb),
+#endif
hbox,
- &action,
info);
- action_info_set_button (info, button, action);
+ action_info_set_button (info, button);
g_signal_connect (button, "clicked", G_CALLBACK (edit_connection_cb), info);
g_signal_connect (treeview, "row-activated", G_CALLBACK (connection_double_clicked_cb), info);
g_signal_connect (selection, "changed", G_CALLBACK (pk_button_selection_changed_cb), info);
pk_button_selection_changed_cb (selection, info);
/* Delete */
- info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), NULL, self->system_action);
- action = NULL;
+ info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), NULL);
button = create_system_action_button ("system-delete",
_("Delete..."),
_("Authenticate to delete the selected connection."),
@@ -1562,12 +1397,13 @@ add_connection_buttons (NMConnectionList *self,
_("Delete the selected connection."),
GTK_STOCK_DELETE,
GTK_STOCK_DIALOG_AUTHENTICATION,
+#if 0
G_CALLBACK (system_pk_result_changed_cb),
+#endif
hbox,
- &action,
info);
- action_info_set_button (info, button, action);
- g_signal_connect (button, "clicked", G_CALLBACK (delete_connection_cb), info);
+ action_info_set_button (info, button);
+ g_signal_connect (button, "clicked", G_CALLBACK (delete_clicked), info);
g_signal_connect (selection, "changed", G_CALLBACK (pk_button_selection_changed_cb), info);
pk_button_selection_changed_cb (selection, info);
@@ -1578,7 +1414,7 @@ add_connection_buttons (NMConnectionList *self,
if (button) {
gboolean import_supported = FALSE;
- info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), button, self->system_action);
+ info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), button);
g_signal_connect (button, "clicked", G_CALLBACK (import_vpn_cb), info);
g_hash_table_foreach (vpn_get_plugins (NULL), check_vpn_import_supported, &import_supported);
@@ -1590,7 +1426,7 @@ add_connection_buttons (NMConnectionList *self,
button = glade_xml_get_widget (self->gui, name);
g_free (name);
if (button) {
- info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), button, self->system_action);
+ info = action_info_new (self, treeview, GTK_WINDOW (self->dialog), button);
g_signal_connect (button, "clicked", G_CALLBACK (export_vpn_cb), info);
g_signal_connect (selection, "changed", G_CALLBACK (vpn_list_selection_changed_cb), info);
gtk_widget_set_sensitive (button, FALSE);
@@ -1666,45 +1502,43 @@ add_connection_tabs (NMConnectionList *self, GType def_type)
}
static void
-connection_removed (NMExportedConnection *exported, gpointer user_data)
+connection_removed (NMSettingsConnectionInterface *connection, gpointer user_data)
{
GtkListStore *store = GTK_LIST_STORE (user_data);
GtkTreeIter iter;
- if (get_iter_for_connection (GTK_TREE_MODEL (store), exported, &iter))
+ if (get_iter_for_connection (GTK_TREE_MODEL (store), connection, &iter))
gtk_list_store_remove (store, &iter);
}
static void
-connection_updated (NMExportedConnection *exported,
- GHashTable *settings,
- gpointer user_data)
+connection_updated (NMSettingsConnectionInterface *connection,
+ GHashTable *settings,
+ gpointer user_data)
{
GtkListStore *store = GTK_LIST_STORE (user_data);
GtkTreeIter iter;
- if (get_iter_for_connection (GTK_TREE_MODEL (store), exported, &iter))
- update_connection_row (store, &iter, exported);
+ if (get_iter_for_connection (GTK_TREE_MODEL (store), connection, &iter))
+ update_connection_row (store, &iter, connection);
}
static void
-connection_added (NMSettings *settings,
- NMExportedConnection *exported,
- gpointer user_data)
+connection_added (NMSettingsInterface *settings,
+ NMSettingsConnectionInterface *connection,
+ gpointer user_data)
{
NMConnectionList *self = NM_CONNECTION_LIST (user_data);
GtkListStore *store;
GtkTreeIter iter;
- NMConnection *connection;
NMSettingConnection *s_con;
char *last_used;
- store = get_model_for_connection (self, exported);
+ store = get_model_for_connection (self, connection);
if (!store)
return;
- connection = nm_exported_connection_get_connection (exported);
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION));
last_used = format_last_used (nm_setting_connection_get_timestamp (s_con));
@@ -1713,13 +1547,13 @@ connection_added (NMSettings *settings,
COL_ID, nm_setting_connection_get_id (s_con),
COL_LAST_USED, last_used,
COL_TIMESTAMP, nm_setting_connection_get_timestamp (s_con),
- COL_CONNECTION, exported,
+ COL_CONNECTION, connection,
-1);
g_free (last_used);
- g_signal_connect (exported, "removed", G_CALLBACK (connection_removed), store);
- g_signal_connect (exported, "updated", G_CALLBACK (connection_updated), store);
+ g_signal_connect (connection, "removed", G_CALLBACK (connection_removed), store);
+ g_signal_connect (connection, "updated", G_CALLBACK (connection_updated), store);
}
#define ICON_LOAD(x, y) \
@@ -1736,7 +1570,7 @@ NMConnectionList *
nm_connection_list_new (GType def_type)
{
NMConnectionList *list;
- DBusGConnection *dbus_connection;
+ DBusGConnection *bus;
GError *error = NULL;
list = g_object_new (NM_TYPE_CONNECTION_LIST, NULL);
@@ -1765,20 +1599,20 @@ nm_connection_list_new (GType def_type)
if (!list->client)
goto error;
- dbus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (error) {
g_warning ("Could not connect to the system bus: %s", error->message);
g_error_free (error);
goto error;
}
- list->system_settings = nm_dbus_settings_system_new (dbus_connection);
- dbus_g_connection_unref (dbus_connection);
+ list->system_settings = nm_remote_settings_system_new (bus);
+ dbus_g_connection_unref (bus);
g_signal_connect (list->system_settings, "new-connection",
G_CALLBACK (connection_added),
list);
- list->gconf_settings = nma_gconf_settings_new ();
+ list->gconf_settings = nma_gconf_settings_new (NULL);
g_signal_connect (list->gconf_settings, "new-connection",
G_CALLBACK (connection_added),
list);
diff --git a/src/connection-editor/nm-connection-list.h b/src/connection-editor/nm-connection-list.h
index 8038207..218087d 100644
--- a/src/connection-editor/nm-connection-list.h
+++ b/src/connection-editor/nm-connection-list.h
@@ -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 2004-2005 Red Hat, Inc.
+ * (C) Copyright 2004-2009 Red Hat, Inc.
*/
#ifndef NM_CONNECTION_LIST_H
@@ -28,12 +28,7 @@
#include <gconf/gconf-client.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
-#include <nm-dbus-settings-system.h>
-#ifdef NO_POLKIT_GNOME
-#include "polkit-gnome.h"
-#else
-#include <polkit-gnome/polkit-gnome.h>
-#endif
+#include <nm-remote-settings-system.h>
#include "nma-gconf-settings.h"
#define NM_TYPE_CONNECTION_LIST (nm_connection_list_get_type ())
@@ -49,12 +44,14 @@ typedef struct {
GConfClient *client;
NMAGConfSettings *gconf_settings;
- NMDBusSettingsSystem *system_settings;
+ NMRemoteSettingsSystem *system_settings;
GladeXML *gui;
GtkWidget *dialog;
+#if 0
PolKitAction *system_action;
+#endif
GdkPixbuf *wired_icon;
GdkPixbuf *wireless_icon;
diff --git a/src/gconf-helpers/gconf-helpers.c b/src/gconf-helpers/gconf-helpers.c
index 4c766aa..ceb19bd 100644
--- a/src/gconf-helpers/gconf-helpers.c
+++ b/src/gconf-helpers/gconf-helpers.c
@@ -39,7 +39,7 @@
#include <nm-setting-vpn.h>
#include <nm-setting-ip4-config.h>
#include <nm-utils.h>
-#include <nm-settings.h>
+#include <nm-settings-interface.h>
#include "gconf-helpers.h"
#include "gconf-upgrade.h"
@@ -1785,7 +1785,9 @@ get_one_private_key (NMConnection *connection,
secret_name = NM_SETTING_802_1X_PHASE2_PRIVATE_KEY;
real_password_secret_name = NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD;
} else {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_UNAVAILABLE,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE,
"%s.%d - %s/%s Unknown private key password type '%s'.",
__FILE__, __LINE__, nm_setting_connection_get_id (s_con), setting_name, tag);
return FALSE;
@@ -1816,7 +1818,9 @@ get_one_private_key (NMConnection *connection,
if (*error) {
goto out;
} else if (!array || !array->len) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_UNAVAILABLE,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE,
"%s.%d - %s/%s couldn't read private key.",
__FILE__, __LINE__, nm_setting_connection_get_id (s_con), setting_name);
goto out;
@@ -1895,7 +1899,9 @@ nm_gconf_get_keyring_items (NMConnection *connection,
}
if (key_name == NULL) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_UNAVAILABLE,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE,
"%s.%d - Internal error; keyring item '%s/%s' didn't "
"have a 'setting-key' attribute.",
__FILE__, __LINE__, connection_name, setting_name);
@@ -1911,7 +1917,9 @@ nm_gconf_get_keyring_items (NMConnection *connection,
if (!get_one_private_key (connection, setting_name, key_name,
found->secret, include_private_passwords, secrets, error)) {
if (!*error) {
- g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_UNAVAILABLE,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE,
"%s.%d - %s/%s unknown error from get_one_private_key().",
__FILE__, __LINE__, connection_name, setting_name);
}
diff --git a/src/gconf-helpers/nma-gconf-connection.c b/src/gconf-helpers/nma-gconf-connection.c
index 504595f..e74e248 100644
--- a/src/gconf-helpers/nma-gconf-connection.c
+++ b/src/gconf-helpers/nma-gconf-connection.c
@@ -16,7 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2008 Novell, Inc.
- * (C) Copyright 2008 Red Hat, Inc.
+ * (C) Copyright 2008 - 2009 Red Hat, Inc.
*/
#include <string.h>
@@ -32,8 +32,15 @@
#include "nm-utils.h"
#include "utils.h"
#include "nma-marshal.h"
+#include "nm-settings-interface.h"
-G_DEFINE_TYPE (NMAGConfConnection, nma_gconf_connection, NM_TYPE_EXPORTED_CONNECTION)
+static NMSettingsConnectionInterface *parent_settings_connection_iface;
+
+static void settings_connection_interface_init (NMSettingsConnectionInterface *class);
+
+G_DEFINE_TYPE_EXTENDED (NMAGConfConnection, nma_gconf_connection, NM_TYPE_EXPORTED_CONNECTION, 0,
+ G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
+ settings_connection_interface_init))
#define NMA_GCONF_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMA_TYPE_GCONF_CONNECTION, NMAGConfConnectionPrivate))
@@ -60,6 +67,22 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
+static void
+fill_vpn_user_name (NMConnection *connection)
+{
+ const char *user_name;
+ NMSettingVPN *s_vpn;
+
+ s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
+ if (!s_vpn)
+ return;
+
+ user_name = g_get_user_name ();
+ g_assert (g_utf8_validate (user_name, -1, NULL));
+ g_object_set (s_vpn, NM_SETTING_VPN_USER_NAME, user_name, NULL);
+}
+
+
NMAGConfConnection *
nma_gconf_connection_new (GConfClient *client, const char *conf_dir)
{
@@ -84,106 +107,126 @@ nma_gconf_connection_new (GConfClient *client, const char *conf_dir)
NMAGConfConnection *
nma_gconf_connection_new_from_connection (GConfClient *client,
- const char *conf_dir,
- NMConnection *connection)
+ const char *conf_dir,
+ NMConnection *connection)
{
+ GObject *object;
+ NMAGConfConnection *self;
+ static guint32 ec_counter = 0;
+ DBusGConnection *bus;
+ GError *error = NULL;
+ gboolean success;
+ GHashTable *settings;
+ char *path;
+
g_return_val_if_fail (GCONF_IS_CLIENT (client), NULL);
g_return_val_if_fail (conf_dir != NULL, NULL);
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
- return (NMAGConfConnection *) g_object_new (NMA_TYPE_GCONF_CONNECTION,
- NMA_GCONF_CONNECTION_CLIENT, client,
- NMA_GCONF_CONNECTION_DIR, conf_dir,
- NM_EXPORTED_CONNECTION_CONNECTION, connection,
- NULL);
-}
+ /* Ensure the connection is valid first */
+ utils_fill_connection_certs (connection);
+ success = nm_connection_verify (connection, &error);
+ utils_clear_filled_connection_certs (connection);
+ if (!success) {
+ g_warning ("Invalid connection: '%s' / '%s' invalid: %d",
+ g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
+ (error && error->message) ? error->message : "(unknown)",
+ error ? error->code : -1);
+ g_clear_error (&error);
+ return NULL;
+ }
-const char *
-nma_gconf_connection_get_path (NMAGConfConnection *self)
-{
- g_return_val_if_fail (NMA_IS_GCONF_CONNECTION (self), NULL);
+ object = g_object_new (NMA_TYPE_GCONF_CONNECTION,
+ NMA_GCONF_CONNECTION_CLIENT, client,
+ NMA_GCONF_CONNECTION_DIR, conf_dir,
+ NM_CONNECTION_SCOPE, NM_CONNECTION_SCOPE_USER,
+ NULL);
+ if (!object)
+ return NULL;
- return NMA_GCONF_CONNECTION_GET_PRIVATE (self)->dir;
-}
+ self = NMA_GCONF_CONNECTION (object);
-/* FIXME: Remove and replace the callers with nm_exported_connection_update() */
-void
-nma_gconf_connection_save (NMAGConfConnection *self)
-{
- NMAGConfConnectionPrivate *priv;
- NMConnection *connection;
+ // FIXME: fill certs before hashing? or copy private values?
+ settings = nm_connection_to_hash (connection);
+ success = nm_connection_replace_settings (NM_CONNECTION (self), settings, NULL);
+ g_hash_table_destroy (settings);
- g_return_if_fail (NMA_IS_GCONF_CONNECTION (self));
+ /* Already verified the settings above, they had better be OK */
+ g_assert (success);
- priv = NMA_GCONF_CONNECTION_GET_PRIVATE (self);
+ fill_vpn_user_name (NM_CONNECTION (self));
- connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (self));
- nm_gconf_write_connection (connection,
- priv->client,
- priv->dir);
- gconf_client_notify (priv->client, priv->dir);
- gconf_client_suggest_sync (priv->client, NULL);
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (!bus) {
+ nm_warning ("Could not get the system bus: (%d) %s",
+ error ? error->code : -1,
+ (error && error->message) ? error->message : "(unknown)");
+ g_error_free (error);
+ g_object_unref (object);
+ return NULL;
+ }
+
+ /* Export the object over D-Bus */
+ path = g_strdup_printf ("%s/%u", NM_DBUS_PATH_SETTINGS, ec_counter++);
+ nm_connection_set_path (NM_CONNECTION (self), path);
+ dbus_g_connection_register_g_object (bus, path, G_OBJECT (self));
+ g_free (path);
+ dbus_g_connection_unref (bus);
+
+ return self;
}
-static void
-fill_vpn_user_name (NMConnection *connection)
+const char *
+nma_gconf_connection_get_gconf_path (NMAGConfConnection *self)
{
- const char *user_name;
- NMSettingVPN *s_vpn;
-
- s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
- if (!s_vpn)
- return;
+ g_return_val_if_fail (NMA_IS_GCONF_CONNECTION (self), NULL);
- user_name = g_get_user_name ();
- g_assert (g_utf8_validate (user_name, -1, NULL));
- g_object_set (s_vpn, NM_SETTING_VPN_USER_NAME, user_name, NULL);
+ return NMA_GCONF_CONNECTION_GET_PRIVATE (self)->dir;
}
gboolean
-nma_gconf_connection_changed (NMAGConfConnection *self)
+nma_gconf_connection_gconf_changed (NMAGConfConnection *self)
{
- NMAGConfConnectionPrivate *priv;
- GHashTable *settings;
- NMConnection *wrapped_connection;
- NMConnection *gconf_connection;
+ NMAGConfConnectionPrivate *priv = NMA_GCONF_CONNECTION_GET_PRIVATE (self);
+ NMConnection *new;
GHashTable *new_settings;
GError *error = NULL;
+ gboolean success;
- g_return_val_if_fail (NMA_IS_GCONF_CONNECTION (self), FALSE);
-
- priv = NMA_GCONF_CONNECTION_GET_PRIVATE (self);
- wrapped_connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (self));
-
- gconf_connection = nm_gconf_read_connection (priv->client, priv->dir);
- if (!gconf_connection) {
+ new = nm_gconf_read_connection (priv->client, priv->dir);
+ if (!new) {
g_warning ("No connection read from GConf at %s.", priv->dir);
goto invalid;
}
- utils_fill_connection_certs (gconf_connection);
- if (!nm_connection_verify (gconf_connection, &error)) {
- utils_clear_filled_connection_certs (gconf_connection);
+ utils_fill_connection_certs (new);
+ success = nm_connection_verify (new, &error);
+ utils_clear_filled_connection_certs (new);
+ if (!success) {
g_warning ("%s: Invalid connection %s: '%s' / '%s' invalid: %d",
__func__, priv->dir,
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
+ g_object_unref (new);
goto invalid;
}
- utils_clear_filled_connection_certs (gconf_connection);
/* Ignore the GConf update if nothing changed */
- if (nm_connection_compare (wrapped_connection, gconf_connection, NM_SETTING_COMPARE_FLAG_EXACT))
+ if (nm_connection_compare (NM_CONNECTION (self), new, NM_SETTING_COMPARE_FLAG_EXACT)) {
+ g_object_unref (new);
return TRUE;
+ }
- utils_fill_connection_certs (gconf_connection);
- new_settings = nm_connection_to_hash (gconf_connection);
- utils_clear_filled_connection_certs (gconf_connection);
+ utils_fill_connection_certs (new);
+ new_settings = nm_connection_to_hash (new);
+ utils_clear_filled_connection_certs (new);
+ g_object_unref (new);
- if (!nm_connection_replace_settings (wrapped_connection, new_settings, &error)) {
- utils_clear_filled_connection_certs (wrapped_connection);
- g_hash_table_destroy (new_settings);
+ success = nm_connection_replace_settings (NM_CONNECTION (self), new_settings, &error);
+ utils_clear_filled_connection_certs (NM_CONNECTION (self));
+ g_hash_table_destroy (new_settings);
+ if (!success) {
g_warning ("%s: '%s' / '%s' invalid: %d",
__func__,
error ? g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)) : "(none)",
@@ -191,74 +234,66 @@ nma_gconf_connection_changed (NMAGConfConnection *self)
error ? error->code : -1);
goto invalid;
}
- g_object_unref (gconf_connection);
- g_hash_table_destroy (new_settings);
-
- fill_vpn_user_name (wrapped_connection);
- settings = nm_connection_to_hash (wrapped_connection);
- utils_clear_filled_connection_certs (wrapped_connection);
+ fill_vpn_user_name (NM_CONNECTION (self));
- nm_exported_connection_signal_updated (NM_EXPORTED_CONNECTION (self), settings);
- g_hash_table_destroy (settings);
+ // FIXME: signal update
return TRUE;
invalid:
g_clear_error (&error);
- nm_exported_connection_signal_removed (NM_EXPORTED_CONNECTION (self));
+ g_signal_emit_by_name (self, "removed");
return FALSE;
}
+/******************************************************/
-static GHashTable *
-get_settings (NMExportedConnection *exported)
+static gboolean
+update (NMSettingsConnectionInterface *connection,
+ NMSettingsConnectionInterfaceUpdateFunc callback,
+ gpointer user_data)
{
- NMConnection *connection;
- GHashTable *settings;
-
- connection = nm_exported_connection_get_connection (exported);
+ NMAGConfConnectionPrivate *priv = NMA_GCONF_CONNECTION_GET_PRIVATE (connection);
- utils_fill_connection_certs (connection);
- settings = nm_connection_to_hash (connection);
- utils_clear_filled_connection_certs (connection);
-
- return settings;
-}
+ nm_gconf_write_connection (NM_CONNECTION (connection),
+ priv->client,
+ priv->dir);
+ gconf_client_notify (priv->client, priv->dir);
+ gconf_client_suggest_sync (priv->client, NULL);
-static void
-secrets_return_error (DBusGMethodInvocation *context, GError *error)
-{
- nm_warning ("Error getting secrets: %s", error->message);
- dbus_g_method_return_error (context, error);
- g_error_free (error);
+ return parent_settings_connection_iface->update (connection, callback, user_data);
}
-typedef struct {
- gboolean found;
- const char **hints;
-} FindHintsInfo;
-
-static void
-find_hints_in_secrets (gpointer key, gpointer data, gpointer user_data)
+static gboolean
+do_delete (NMSettingsConnectionInterface *connection,
+ NMSettingsConnectionInterfaceDeleteFunc callback,
+ gpointer user_data)
{
- FindHintsInfo *info = (FindHintsInfo *) user_data;
- const char **iter;
+ NMAGConfConnectionPrivate *priv = NMA_GCONF_CONNECTION_GET_PRIVATE (connection);
+ gboolean success;
+ GError *error = NULL;
- for (iter = info->hints; !info->found && *iter; iter++) {
- if (!strcmp (*iter, (const char *) key) && data && G_IS_VALUE (data))
- info->found = TRUE;
+ success = gconf_client_recursive_unset (priv->client, priv->dir, 0, &error);
+ if (!success) {
+ callback (connection, error, user_data);
+ g_error_free (error);
+ return FALSE;
}
+ gconf_client_suggest_sync (priv->client, NULL);
+
+ return parent_settings_connection_iface->delete (connection, callback, user_data);
}
-static void
-service_get_secrets (NMExportedConnection *exported,
- const gchar *setting_name,
- const gchar **hints,
- gboolean request_new,
- DBusGMethodInvocation *context)
+static gboolean
+internal_get_secrets (NMSettingsConnectionInterface *connection,
+ const char *setting_name,
+ const char **hints,
+ gboolean request_new,
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data,
+ GError **error)
{
- NMConnection *connection;
- GError *error = NULL;
+ NMAGConfConnection *self = NMA_GCONF_CONNECTION (connection);
GHashTable *settings = NULL;
GHashTable *secrets = NULL;
NMSettingConnection *s_con;
@@ -266,29 +301,30 @@ service_get_secrets (NMExportedConnection *exported,
const char *connection_id;
const char *connection_type;
- connection = nm_exported_connection_get_connection (exported);
-
- setting = nm_connection_get_setting_by_name (connection, setting_name);
+ setting = nm_connection_get_setting_by_name (NM_CONNECTION (self), setting_name);
if (!setting) {
- g_set_error (&error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
"%s.%d - Connection didn't have requested setting '%s'.",
__FILE__, __LINE__, setting_name);
- secrets_return_error (context, error);
- return;
+ return FALSE;
}
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- connection_id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
- connection_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
+ s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (self), NM_TYPE_SETTING_CONNECTION);
+ g_assert (s_con);
+ connection_id = nm_setting_connection_get_id (s_con);
+ connection_type = nm_setting_connection_get_connection_type (s_con);
if (!s_con || !connection_id || !strlen (connection_id) || !connection_type) {
- g_set_error (&error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ g_set_error (error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
"%s.%d - Connection didn't have required '"
NM_SETTING_CONNECTION_SETTING_NAME
"' setting , or the connection name was invalid.",
__FILE__, __LINE__);
- secrets_return_error (context, error);
- return;
+ return FALSE;
}
/* VPN passwords are handled by the VPN plugin's auth dialog */
@@ -298,16 +334,15 @@ service_get_secrets (NMExportedConnection *exported,
if (request_new) {
nm_info ("New secrets for %s/%s requested; ask the user",
connection_id, setting_name);
- nm_connection_clear_secrets (connection);
+ nm_connection_clear_secrets (NM_CONNECTION (self));
goto get_secrets;
}
- secrets = nm_gconf_get_keyring_items (connection, setting_name, FALSE, &error);
+ secrets = nm_gconf_get_keyring_items (NM_CONNECTION (self), setting_name, FALSE, error);
if (!secrets) {
- if (error) {
- secrets_return_error (context, error);
- return;
- }
+ if (error)
+ return FALSE;
+
nm_info ("No keyring secrets found for %s/%s; asking user.",
connection_id, setting_name);
goto get_secrets;
@@ -324,10 +359,24 @@ service_get_secrets (NMExportedConnection *exported,
* get some new secrets.
*/
if (hints && g_strv_length ((char **) hints)) {
- FindHintsInfo info = { .found = FALSE, .hints = hints };
+ GHashTableIter iter;
+ gpointer key, value;
+ gboolean found = FALSE;
+
+ g_hash_table_iter_init (&iter, secrets);
+ while (g_hash_table_iter_next (&iter, &key, &value) && !found) {
+ const char **hint = hints;
+
+ while (!found && *hint) {
+ if (!strcmp (*hint, (const char *) key) && value && G_IS_VALUE (value)) {
+ found = TRUE;
+ break;
+ }
+ hint++;
+ }
+ }
- g_hash_table_foreach (secrets, find_hints_in_secrets, &info);
- if (info.found == FALSE) {
+ if (!found) {
g_hash_table_destroy (secrets);
goto get_secrets;
}
@@ -340,22 +389,75 @@ service_get_secrets (NMExportedConnection *exported,
g_free,
(GDestroyNotify) g_hash_table_destroy);
g_hash_table_insert (settings, g_strdup (setting_name), secrets);
- dbus_g_method_return (context, settings);
+ callback (NM_SETTINGS_CONNECTION_INTERFACE (self), settings, NULL, callback_data);
g_hash_table_destroy (settings);
- return;
+ return TRUE;
get_secrets:
- g_signal_emit (exported,
+ g_signal_emit (self,
signals[NEW_SECRETS_REQUESTED],
0,
setting_name,
hints,
request_new,
- context);
+ callback,
+ callback_data);
+ return TRUE;
+}
+
+typedef struct {
+ NMSettingsConnectionInterfaceGetSecretsFunc callback;
+ gpointer callback_data;
+} GetSecretsInfo;
+
+static void
+get_secrets_cb (NMSettingsConnectionInterface *connection,
+ GHashTable *settings,
+ GError *error,
+ gpointer user_data)
+{
+ GetSecretsInfo *info = user_data;
+
+ info->callback (NM_SETTINGS_CONNECTION_INTERFACE (connection), settings, error, info->callback_data);
+ g_free (info);
}
static gboolean
-is_user_request_authorized (DBusGMethodInvocation *context,
+get_secrets (NMSettingsConnectionInterface *connection,
+ const char *setting_name,
+ const char **hints,
+ gboolean request_new,
+ NMSettingsConnectionInterfaceGetSecretsFunc callback,
+ gpointer user_data)
+{
+ GetSecretsInfo *info;
+ GError *error = NULL;
+
+ info = g_malloc0 (sizeof (GetSecretsInfo));
+ info->callback = callback;
+ info->callback_data = user_data;
+
+ if (!internal_get_secrets (connection,
+ setting_name,
+ hints,
+ request_new,
+ get_secrets_cb,
+ info,
+ &error)) {
+ callback (NM_SETTINGS_CONNECTION_INTERFACE (connection), NULL, error, user_data);
+ g_error_free (error);
+ g_free (info);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/******************************************************/
+
+static gboolean
+is_dbus_request_authorized (DBusGMethodInvocation *context,
+ gboolean allow_user,
GError **error)
{
DBusGConnection *bus = NULL;
@@ -367,44 +469,44 @@ is_user_request_authorized (DBusGMethodInvocation *context,
sender = dbus_g_method_get_sender (context);
if (!sender) {
- g_set_error (error, NM_SETTINGS_ERROR,
- NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error, NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s", "Could not determine D-Bus requestor");
goto out;
}
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
if (!bus) {
- g_set_error (error, NM_SETTINGS_ERROR,
- NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error, NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s", "Could not get the system bus");
goto out;
}
connection = dbus_g_connection_get_connection (bus);
if (!connection) {
- g_set_error (error, NM_SETTINGS_ERROR,
- NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (error, NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s", "Could not get the D-Bus system bus");
goto out;
}
dbus_error_init (&dbus_error);
- /* FIXME: do this async */
sender_uid = dbus_bus_get_unix_user (connection, sender, &dbus_error);
if (dbus_error_is_set (&dbus_error)) {
dbus_error_free (&dbus_error);
- g_set_error (error, NM_SETTINGS_ERROR,
- NM_SETTINGS_ERROR_PERMISSION_DENIED,
+ g_set_error (error, NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED,
"%s", "Could not determine the Unix user ID of the requestor");
goto out;
}
/* And finally, the actual UID check */
- if ((sender_uid == geteuid()) || (sender_uid == 0))
+ if ( (allow_user && (sender_uid == geteuid()))
+ || (sender_uid == 0))
success = TRUE;
else {
- g_set_error (error, NM_SETTINGS_ERROR,
- NM_SETTINGS_ERROR_PERMISSION_DENIED,
+ g_set_error (error, NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED,
"%s", "Requestor UID does not match the UID of the user settings service");
}
@@ -415,67 +517,138 @@ out:
return success;
}
+static void
+con_update_cb (NMSettingsConnectionInterface *connection,
+ GError *error,
+ gpointer user_data)
+{
+ DBusGMethodInvocation *context = user_data;
-static gboolean
-update (NMExportedConnection *exported, GHashTable *new_settings, GError **error)
+ if (error)
+ dbus_g_method_return_error (context, error);
+ else
+ dbus_g_method_return (context);
+}
+
+static void
+dbus_update (NMExportedConnection *exported,
+ GHashTable *new_settings,
+ DBusGMethodInvocation *context)
{
- NMAGConfConnectionPrivate *priv = NMA_GCONF_CONNECTION_GET_PRIVATE (exported);
- NMConnection *tmp;
+ NMAGConfConnection *self = NMA_GCONF_CONNECTION (exported);
+ NMConnection *new;
gboolean success = FALSE;
- DBusGMethodInvocation *context;
-
- context = g_object_get_data (G_OBJECT (exported), NM_EXPORTED_CONNECTION_DBUS_METHOD_INVOCATION);
+ GError *error = NULL;
/* Restrict Update to execution by the current user and root for DBus invocation */
- if (context && !is_user_request_authorized (context, error)) {
- nm_warning ("%s.%d - Connection update permission denied: (%d) %s",
- __FILE__, __LINE__, (*error)->code, (*error)->message);
- return FALSE;
+ if (!is_dbus_request_authorized (context, TRUE, &error)) {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
}
- tmp = nm_connection_new_from_hash (new_settings, error);
- if (!tmp) {
- nm_warning ("%s: Invalid connection: '%s' / '%s' invalid: %d",
- __func__,
- g_type_name (nm_connection_lookup_setting_type_by_quark ((*error)->domain)),
- (*error)->message, (*error)->code);
- } else {
- /* Copy private values to the connection that actually gets saved */
- nm_gconf_copy_private_connection_values (tmp, nm_exported_connection_get_connection (exported));
+ new = nm_connection_new_from_hash (new_settings, &error);
+ if (!new) {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+ g_object_unref (new);
+
+ success = nm_connection_replace_settings (NM_CONNECTION (self), new_settings, NULL);
+ /* Settings better be valid; we verified them above */
+ g_assert (success);
- nm_gconf_write_connection (tmp, priv->client, priv->dir);
- g_object_unref (tmp);
+ nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (self),
+ con_update_cb,
+ context);
+}
- gconf_client_notify (priv->client, priv->dir);
- gconf_client_suggest_sync (priv->client, NULL);
- success = TRUE;
+static void
+con_delete_cb (NMSettingsConnectionInterface *connection,
+ GError *error,
+ gpointer user_data)
+{
+ DBusGMethodInvocation *context = user_data;
+
+ if (error)
+ dbus_g_method_return_error (context, error);
+ else
+ dbus_g_method_return (context);
+}
+
+static void
+dbus_delete (NMExportedConnection *exported,
+ DBusGMethodInvocation *context)
+{
+ NMAGConfConnection *self = NMA_GCONF_CONNECTION (exported);
+ GError *error = NULL;
+
+ /* Restrict Update to execution by the current user and root for DBus invocation */
+ if (!is_dbus_request_authorized (context, TRUE, &error)) {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
}
- return success;
+ nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (self),
+ con_delete_cb,
+ context);
}
-static gboolean
-do_delete (NMExportedConnection *exported, GError **error)
+static void
+dbus_get_secrets_cb (NMSettingsConnectionInterface *connection,
+ GHashTable *settings,
+ GError *error,
+ gpointer user_data)
{
- NMAGConfConnectionPrivate *priv = NMA_GCONF_CONNECTION_GET_PRIVATE (exported);
- gboolean success;
- DBusGMethodInvocation *context;
+ DBusGMethodInvocation *context = user_data;
- context = g_object_get_data (G_OBJECT (exported), NM_EXPORTED_CONNECTION_DBUS_METHOD_INVOCATION);
+ if (error)
+ dbus_g_method_return_error (context, error);
+ else
+ dbus_g_method_return (context, settings);
+}
- /* Restrict Delete to execution by the current user and root for DBus invocation */
- if (context && !is_user_request_authorized (context, error)) {
- nm_warning ("%s.%d - Connection delete permission denied: (%d) %s",
- __FILE__, __LINE__, (*error)->code, (*error)->message);
- return FALSE;
+static void
+dbus_get_secrets (NMExportedConnection *connection,
+ const gchar *setting_name,
+ const gchar **hints,
+ gboolean request_new,
+ DBusGMethodInvocation *context)
+{
+ GError *error = NULL;
+
+ /* Restrict GetSecrets to execution by root for DBus invocation */
+ if (!is_dbus_request_authorized (context, FALSE, &error)) {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
}
- success = gconf_client_recursive_unset (priv->client, priv->dir, 0, error);
- gconf_client_suggest_sync (priv->client, NULL);
- return success;
+ if (!internal_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (connection),
+ setting_name,
+ hints,
+ request_new,
+ dbus_get_secrets_cb,
+ context,
+ &error)) {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ }
}
-/* GObject */
+/************************************************************/
+
+static void
+settings_connection_interface_init (NMSettingsConnectionInterface *iface)
+{
+ parent_settings_connection_iface = g_type_interface_peek_parent (iface);
+
+ iface->update = update;
+ iface->delete = do_delete;
+ iface->get_secrets = get_secrets;
+}
static void
nma_gconf_connection_init (NMAGConfConnection *connection)
@@ -484,14 +657,11 @@ nma_gconf_connection_init (NMAGConfConnection *connection)
static GObject *
constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
{
GObject *object;
NMAGConfConnectionPrivate *priv;
- NMConnection *connection;
- DBusGConnection *bus;
- GError *error = NULL;
object = G_OBJECT_CLASS (nma_gconf_connection_parent_class)->constructor (type, n_construct_params, construct_params);
@@ -502,47 +672,17 @@ constructor (GType type,
if (!priv->client) {
nm_warning ("GConfClient not provided.");
- goto err;
+ g_object_unref (object);
+ return NULL;
}
if (!priv->dir) {
nm_warning ("GConf directory not provided.");
- goto err;
- }
-
- connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (object));
-
- utils_fill_connection_certs (connection);
- if (!nm_connection_verify (connection, &error)) {
- utils_clear_filled_connection_certs (connection);
- g_warning ("Invalid connection: '%s' / '%s' invalid: %d",
- g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
- error->message, error->code);
- g_error_free (error);
- goto err;
- }
- utils_clear_filled_connection_certs (connection);
-
- fill_vpn_user_name (connection);
-
- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (!bus) {
- nm_warning ("Could not get the system bus: %s", error->message);
- g_error_free (error);
- goto err;
+ g_object_unref (object);
+ return NULL;
}
- nm_exported_connection_register_object (NM_EXPORTED_CONNECTION (object),
- NM_CONNECTION_SCOPE_USER,
- bus);
- dbus_g_connection_unref (bus);
-
return object;
-
- err:
- g_object_unref (object);
-
- return NULL;
}
static void
@@ -610,12 +750,12 @@ get_property (GObject *object, guint prop_id,
}
static void
-nma_gconf_connection_class_init (NMAGConfConnectionClass *gconf_connection_class)
+nma_gconf_connection_class_init (NMAGConfConnectionClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (gconf_connection_class);
- NMExportedConnectionClass *connection_class = NM_EXPORTED_CONNECTION_CLASS (gconf_connection_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ NMExportedConnectionClass *ec_class = NM_EXPORTED_CONNECTION_CLASS (class);
- g_type_class_add_private (gconf_connection_class, sizeof (NMAGConfConnectionPrivate));
+ g_type_class_add_private (class, sizeof (NMAGConfConnectionPrivate));
/* Virtual methods */
object_class->constructor = constructor;
@@ -624,10 +764,9 @@ nma_gconf_connection_class_init (NMAGConfConnectionClass *gconf_connection_class
object_class->dispose = dispose;
object_class->finalize = finalize;
- connection_class->get_settings = get_settings;
- connection_class->service_get_secrets = service_get_secrets;
- connection_class->update = update;
- connection_class->do_delete = do_delete;
+ ec_class->update = dbus_update;
+ ec_class->delete = dbus_delete;
+ ec_class->get_secrets = dbus_get_secrets;
/* Properties */
g_object_class_install_property
@@ -653,7 +792,7 @@ nma_gconf_connection_class_init (NMAGConfConnectionClass *gconf_connection_class
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMAGConfConnectionClass, new_secrets_requested),
NULL, NULL,
- nma_marshal_VOID__STRING_POINTER_BOOLEAN_POINTER,
- G_TYPE_NONE, 4,
- G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN, G_TYPE_POINTER);
+ nma_marshal_VOID__STRING_POINTER_BOOLEAN_POINTER_POINTER,
+ G_TYPE_NONE, 5,
+ G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN, G_TYPE_POINTER, G_TYPE_POINTER);
}
diff --git a/src/gconf-helpers/nma-gconf-connection.h b/src/gconf-helpers/nma-gconf-connection.h
index 32a7c63..296ca58 100644
--- a/src/gconf-helpers/nma-gconf-connection.h
+++ b/src/gconf-helpers/nma-gconf-connection.h
@@ -24,7 +24,9 @@
#include <gconf/gconf-client.h>
#include <dbus/dbus-glib.h>
-#include <nm-settings.h>
+#include <nm-connection.h>
+#include <nm-exported-connection.h>
+#include <nm-settings-connection-interface.h>
G_BEGIN_DECLS
@@ -42,6 +44,11 @@ typedef struct {
NMExportedConnection parent;
} NMAGConfConnection;
+typedef void (*NMANewSecretsRequestedFunc) (NMSettingsConnectionInterface *connection,
+ GHashTable *settings,
+ GError *error,
+ gpointer user_data);
+
typedef struct {
NMExportedConnectionClass parent;
@@ -56,17 +63,15 @@ typedef struct {
GType nma_gconf_connection_get_type (void);
NMAGConfConnection *nma_gconf_connection_new (GConfClient *client,
- const char *conf_dir);
+ const char *conf_dir);
NMAGConfConnection *nma_gconf_connection_new_from_connection (GConfClient *client,
- const char *conf_dir,
- NMConnection *connection);
-
-const char *nma_gconf_connection_get_path (NMAGConfConnection *self);
+ const char *conf_dir,
+ NMConnection *connection);
-void nma_gconf_connection_save (NMAGConfConnection *self);
+gboolean nma_gconf_connection_gconf_changed (NMAGConfConnection *self);
-gboolean nma_gconf_connection_changed (NMAGConfConnection *self);
+const char *nma_gconf_connection_get_gconf_path (NMAGConfConnection *self);
G_END_DECLS
diff --git a/src/gconf-helpers/nma-gconf-settings.c b/src/gconf-helpers/nma-gconf-settings.c
index 895cf59..d213dd5 100644
--- a/src/gconf-helpers/nma-gconf-settings.c
+++ b/src/gconf-helpers/nma-gconf-settings.c
@@ -20,12 +20,13 @@
#include <string.h>
#include <stdio.h>
+
#include "nma-gconf-settings.h"
#include "gconf-helpers.h"
#include "nma-marshal.h"
#include "nm-utils.h"
-G_DEFINE_TYPE (NMAGConfSettings, nma_gconf_settings, NM_TYPE_SETTINGS)
+G_DEFINE_TYPE (NMAGConfSettings, nma_gconf_settings, NM_TYPE_SETTINGS_SERVICE)
#define NMA_GCONF_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMA_TYPE_GCONF_SETTINGS, NMAGConfSettingsPrivate))
@@ -49,9 +50,16 @@ static guint signals[LAST_SIGNAL] = { 0 };
NMAGConfSettings *
-nma_gconf_settings_new (void)
+nma_gconf_settings_new (DBusGConnection *bus)
{
- return (NMAGConfSettings *) g_object_new (NMA_TYPE_GCONF_SETTINGS, NULL);
+ NMAGConfSettings *self;
+
+ self = (NMAGConfSettings *) g_object_new (NMA_TYPE_GCONF_SETTINGS,
+ NM_SETTINGS_SERVICE_SCOPE, NM_CONNECTION_SCOPE_USER,
+ NULL);
+ if (self && bus)
+ g_object_set (G_OBJECT (self), NM_SETTINGS_SERVICE_BUS, bus, NULL);
+ return self;
}
static void
@@ -59,7 +67,8 @@ connection_new_secrets_requested_cb (NMAGConfConnection *connection,
const char *setting_name,
const char **hints,
gboolean ask_user,
- DBusGMethodInvocation *context,
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data,
gpointer user_data)
{
NMAGConfSettings *self = NMA_GCONF_SETTINGS (user_data);
@@ -74,7 +83,8 @@ connection_new_secrets_requested_cb (NMAGConfConnection *connection,
setting_name,
hints,
ask_user,
- context);
+ callback,
+ callback_data);
}
static void
@@ -87,19 +97,32 @@ connection_removed (NMExportedConnection *connection, gpointer user_data)
}
static void
-add_connection_real (NMAGConfSettings *self, NMAGConfConnection *connection)
+internal_add_connection (NMAGConfSettings *self, NMAGConfConnection *connection)
{
NMAGConfSettingsPrivate *priv = NMA_GCONF_SETTINGS_GET_PRIVATE (self);
- if (connection) {
- priv->connections = g_slist_prepend (priv->connections, connection);
- g_signal_connect (connection, "new-secrets-requested",
- G_CALLBACK (connection_new_secrets_requested_cb),
- self);
+ g_return_if_fail (connection != NULL);
+
+ priv->connections = g_slist_prepend (priv->connections, connection);
+ g_signal_connect (connection, "new-secrets-requested",
+ G_CALLBACK (connection_new_secrets_requested_cb),
+ self);
+
+ g_signal_connect (connection, "removed", G_CALLBACK (connection_removed), self);
+ g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_NEW_CONNECTION, NM_CONNECTION (connection));
+}
- g_signal_connect (connection, "removed", G_CALLBACK (connection_removed), self);
- nm_settings_signal_new_connection (NM_SETTINGS (self),
- NM_EXPORTED_CONNECTION (connection));
+static void
+update_cb (NMSettingsConnectionInterface *connection,
+ GError *error,
+ gpointer user_data)
+{
+ if (error) {
+ g_warning ("%s: %s:%d error updating connection %s: (%d) %s",
+ __func__, __FILE__, __LINE__,
+ nma_gconf_connection_get_gconf_path (NMA_GCONF_CONNECTION (connection)),
+ error ? error->code : -1,
+ (error && error->message) ? error->message : "(unknown)");
}
}
@@ -134,21 +157,20 @@ nma_gconf_settings_add_connection (NMAGConfSettings *self, NMConnection *connect
exported = nma_gconf_connection_new_from_connection (priv->client, path, connection);
g_free (path);
- if (!exported)
- return NULL;
-
- add_connection_real (self, exported);
+ if (exported) {
+ internal_add_connection (self, exported);
- /* Must save connection to GConf _after_ adding it to the connections
- * list to avoid races with GConf notifications.
- */
- nma_gconf_connection_save (exported);
+ /* Must save connection to GConf _after_ adding it to the connections
+ * list to avoid races with GConf notifications.
+ */
+ nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (exported), update_cb, NULL);
+ }
return exported;
}
-NMAGConfConnection *
-nma_gconf_settings_get_by_path (NMAGConfSettings *self, const char *path)
+static NMAGConfConnection *
+get_connection_by_gconf_path (NMAGConfSettings *self, const char *path)
{
NMAGConfSettingsPrivate *priv;
GSList *iter;
@@ -161,7 +183,7 @@ nma_gconf_settings_get_by_path (NMAGConfSettings *self, const char *path)
NMAGConfConnection *connection = NMA_GCONF_CONNECTION (iter->data);
const char *gconf_path;
- gconf_path = nma_gconf_connection_get_path (connection);
+ gconf_path = nma_gconf_connection_get_gconf_path (connection);
if (gconf_path && !strcmp (gconf_path, path))
return connection;
}
@@ -169,52 +191,18 @@ nma_gconf_settings_get_by_path (NMAGConfSettings *self, const char *path)
return NULL;
}
-NMAGConfConnection *
-nma_gconf_settings_get_by_dbus_path (NMAGConfSettings *self,
- const char *path)
+static NMExportedConnection *
+get_connection_by_path (NMSettingsService *settings, const char *path)
{
- NMAGConfSettingsPrivate *priv;
- GSList *iter;
-
- g_return_val_if_fail (NMA_IS_GCONF_SETTINGS (self), NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- priv = NMA_GCONF_SETTINGS_GET_PRIVATE (self);
- for (iter = priv->connections; iter; iter = iter->next) {
- NMAGConfConnection *connection = NMA_GCONF_CONNECTION (iter->data);
- NMConnection *wrapped;
- const char *sc_path;
-
- wrapped = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (connection));
- sc_path = nm_connection_get_path (wrapped);
-
- if (sc_path && !strcmp (sc_path, path))
- return connection;
- }
-
- return NULL;
-}
-
-NMAGConfConnection *
-nma_gconf_settings_get_by_connection (NMAGConfSettings *self,
- NMConnection *connection)
-{
- NMAGConfSettingsPrivate *priv;
+ NMAGConfSettingsPrivate *priv = NMA_GCONF_SETTINGS_GET_PRIVATE (settings);
GSList *iter;
- g_return_val_if_fail (NMA_IS_GCONF_SETTINGS (self), NULL);
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
- priv = NMA_GCONF_SETTINGS_GET_PRIVATE (self);
-
for (iter = priv->connections; iter; iter = iter->next) {
- NMConnection *wrapped;
+ NMConnection *connection = NM_CONNECTION (iter->data);
- wrapped = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (iter->data));
- if (connection == wrapped)
- return NMA_GCONF_CONNECTION (iter->data);
+ if (!strcmp (nm_connection_get_path (connection), path))
+ return NM_EXPORTED_CONNECTION (connection);
}
-
return NULL;
}
@@ -232,7 +220,7 @@ read_connections (NMAGConfSettings *settings)
for (iter = dir_list; iter; iter = iter->next) {
char *dir = (char *) iter->data;
- add_connection_real (settings, nma_gconf_connection_new (priv->client, dir));
+ internal_add_connection (settings, nma_gconf_connection_new (priv->client, dir));
g_free (dir);
}
@@ -250,7 +238,7 @@ read_connections_cb (gpointer data)
}
static GSList *
-list_connections (NMSettings *settings)
+list_connections (NMSettingsService *settings)
{
NMAGConfSettingsPrivate *priv = NMA_GCONF_SETTINGS_GET_PRIVATE (settings);
@@ -285,15 +273,15 @@ connection_changes_done (gpointer data)
NMAGConfSettingsPrivate *priv = NMA_GCONF_SETTINGS_GET_PRIVATE (info->settings);
NMAGConfConnection *connection;
- connection = nma_gconf_settings_get_by_path (info->settings, info->path);
+ connection = get_connection_by_gconf_path (info->settings, info->path);
if (!connection) {
/* New connection */
connection = nma_gconf_connection_new (priv->client, info->path);
- add_connection_real (info->settings, connection);
+ internal_add_connection (info->settings, connection);
} else {
if (gconf_client_dir_exists (priv->client, info->path, NULL)) {
/* Updated connection */
- if (!nma_gconf_connection_changed (connection))
+ if (!nma_gconf_connection_gconf_changed (connection))
priv->connections = g_slist_remove (priv->connections, connection);
}
}
@@ -353,12 +341,12 @@ remove_pending_change (gpointer data)
g_source_remove (GPOINTER_TO_UINT (data));
}
-/* GObject */
+/************************************************************/
static void
-nma_gconf_settings_init (NMAGConfSettings *settings)
+nma_gconf_settings_init (NMAGConfSettings *self)
{
- NMAGConfSettingsPrivate *priv = NMA_GCONF_SETTINGS_GET_PRIVATE (settings);
+ NMAGConfSettingsPrivate *priv = NMA_GCONF_SETTINGS_GET_PRIVATE (self);
priv->client = gconf_client_get_default ();
priv->pending_changes = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, remove_pending_change);
@@ -369,10 +357,10 @@ nma_gconf_settings_init (NMAGConfSettings *settings)
NULL);
priv->conf_notify_id = gconf_client_notify_add (priv->client,
- GCONF_PATH_CONNECTIONS,
- (GConfClientNotifyFunc) connections_changed_cb,
- settings,
- NULL, NULL);
+ GCONF_PATH_CONNECTIONS,
+ (GConfClientNotifyFunc) connections_changed_cb,
+ self,
+ NULL, NULL);
}
static GObject *
@@ -381,17 +369,10 @@ constructor (GType type,
GObjectConstructParam *construct_params)
{
GObject *object;
- NMAGConfSettingsPrivate *priv;
object = G_OBJECT_CLASS (nma_gconf_settings_parent_class)->constructor (type, n_construct_params, construct_params);
-
- if (!object)
- return NULL;
-
- priv = NMA_GCONF_SETTINGS_GET_PRIVATE (object);
-
- priv->read_connections_id = g_idle_add (read_connections_cb, object);
-
+ if (object)
+ NMA_GCONF_SETTINGS_GET_PRIVATE (object)->read_connections_id = g_idle_add (read_connections_cb, object);
return object;
}
@@ -424,18 +405,19 @@ dispose (GObject *object)
}
static void
-nma_gconf_settings_class_init (NMAGConfSettingsClass *gconf_settings_class)
+nma_gconf_settings_class_init (NMAGConfSettingsClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (gconf_settings_class);
- NMSettingsClass *settings_class = NM_SETTINGS_CLASS (gconf_settings_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ NMSettingsServiceClass *settings_class = NM_SETTINGS_SERVICE_CLASS (class);
- g_type_class_add_private (gconf_settings_class, sizeof (NMAGConfSettingsPrivate));
+ g_type_class_add_private (class, sizeof (NMAGConfSettingsPrivate));
/* Virtual methods */
object_class->constructor = constructor;
object_class->dispose = dispose;
settings_class->list_connections = list_connections;
+ settings_class->get_connection_by_path = get_connection_by_path;
/* Signals */
signals[NEW_SECRETS_REQUESTED] =
@@ -444,7 +426,7 @@ nma_gconf_settings_class_init (NMAGConfSettingsClass *gconf_settings_class)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMAGConfSettingsClass, new_secrets_requested),
NULL, NULL,
- nma_marshal_VOID__OBJECT_STRING_POINTER_BOOLEAN_POINTER,
- G_TYPE_NONE, 5,
- G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN, G_TYPE_POINTER);
+ nma_marshal_VOID__OBJECT_STRING_POINTER_BOOLEAN_POINTER_POINTER,
+ G_TYPE_NONE, 6,
+ G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN, G_TYPE_POINTER, G_TYPE_POINTER);
}
diff --git a/src/gconf-helpers/nma-gconf-settings.h b/src/gconf-helpers/nma-gconf-settings.h
index 38c4f70..d197a35 100644
--- a/src/gconf-helpers/nma-gconf-settings.h
+++ b/src/gconf-helpers/nma-gconf-settings.h
@@ -21,9 +21,9 @@
#ifndef NMA_GCONF_SETTINGS_H
#define NMA_GCONF_SETTINGS_H
-#include <dbus/dbus-glib.h>
#include <nm-connection.h>
-#include <nm-settings.h>
+#include <nm-settings-service.h>
+
#include "nma-gconf-connection.h"
G_BEGIN_DECLS
@@ -36,36 +36,28 @@ G_BEGIN_DECLS
#define NMA_GCONF_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_GCONF_SETTINGS, NMAGConfSettingsClass))
typedef struct {
- NMSettings parent;
+ NMSettingsService parent;
} NMAGConfSettings;
typedef struct {
- NMSettingsClass parent;
+ NMSettingsServiceClass parent;
/* Signals */
void (*new_secrets_requested) (NMAGConfSettings *self,
- NMAGConfConnection *exported,
- const char *setting_name,
- const char **hints,
- gboolean ask_user,
- DBusGMethodInvocation *context);
+ NMAGConfConnection *exported,
+ const char *setting_name,
+ const char **hints,
+ gboolean ask_user,
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data);
} NMAGConfSettingsClass;
GType nma_gconf_settings_get_type (void);
-NMAGConfSettings *nma_gconf_settings_new (void);
+NMAGConfSettings *nma_gconf_settings_new (DBusGConnection *bus);
NMAGConfConnection *nma_gconf_settings_add_connection (NMAGConfSettings *self,
- NMConnection *connection);
-
-NMAGConfConnection *nma_gconf_settings_get_by_path (NMAGConfSettings *self,
- const char *path);
-
-NMAGConfConnection *nma_gconf_settings_get_by_dbus_path (NMAGConfSettings *self,
- const char *path);
-
-NMAGConfConnection *nma_gconf_settings_get_by_connection (NMAGConfSettings *self,
- NMConnection *connection);
+ NMConnection *connection);
G_END_DECLS
diff --git a/src/gnome-bluetooth/network-manager-applet.c b/src/gnome-bluetooth/network-manager-applet.c
index 3cdd5b5..67453f9 100644
--- a/src/gnome-bluetooth/network-manager-applet.c
+++ b/src/gnome-bluetooth/network-manager-applet.c
@@ -67,7 +67,7 @@ get_array_from_bdaddr (const char *str)
return NULL;
}
-static NMExportedConnection *
+static NMSettingsConnectionInterface *
add_setup (const char *bdaddr)
{
NMConnection *connection;
@@ -114,38 +114,48 @@ add_setup (const char *bdaddr)
NULL);
nm_connection_add_setting (connection, ip_setting);
- gconf_settings = nma_gconf_settings_new ();
+ gconf_settings = nma_gconf_settings_new (NULL);
exported = nma_gconf_settings_add_connection (gconf_settings, connection);
if (exported != NULL)
- return NM_EXPORTED_CONNECTION (exported);
+ return NM_SETTINGS_CONNECTION_INTERFACE (exported);
return NULL;
}
static void
+delete_cb (NMSettingsConnectionInterface *connection,
+ GError *error,
+ gpointer user_data)
+{
+ if (error)
+ g_warning ("Error deleting connection: (%d) %s", error->code, error->message);
+ if (user_data)
+ g_object_set_data (G_OBJECT (user_data), "conn", NULL);
+}
+
+static void
button_toggled (GtkToggleButton *button, gpointer user_data)
{
- NMExportedConnection *exported;
+ NMSettingsConnectionInterface *connection;
const char *bdaddr;
bdaddr = g_object_get_data (G_OBJECT (button), "bdaddr");
g_assert (bdaddr);
if (gtk_toggle_button_get_active (button) == FALSE) {
- exported = g_object_get_data (G_OBJECT (button), "conn");
- nm_exported_connection_delete (exported, NULL);
- g_object_set_data (G_OBJECT (button), "conn", NULL);
+ connection = g_object_get_data (G_OBJECT (button), "conn");
+ nm_settings_connection_interface_delete (connection, delete_cb, button);
} else {
- exported = add_setup (bdaddr);
- g_object_set_data (G_OBJECT (button), "conn", exported);
+ connection = add_setup (bdaddr);
+ g_object_set_data (G_OBJECT (button), "conn", connection);
}
}
-static NMExportedConnection *
+static NMSettingsConnectionInterface *
get_connection_for_bdaddr (const char *bdaddr)
{
- NMExportedConnection *result = NULL;
- NMSettings *settings;
+ NMSettingsConnectionInterface *found = NULL;
+ NMSettingsInterface *settings;
GSList *list, *l;
GByteArray *array;
@@ -153,16 +163,15 @@ get_connection_for_bdaddr (const char *bdaddr)
if (array == NULL)
return NULL;
- settings = NM_SETTINGS (nma_gconf_settings_new ());
- list = nm_settings_list_connections (settings);
+ settings = NM_SETTINGS_INTERFACE (nma_gconf_settings_new (NULL));
+ list = nm_settings_interface_list_connections (settings);
for (l = list; l != NULL; l = l->next) {
- NMExportedConnection *exported = l->data;
- NMConnection *conn = nm_exported_connection_get_connection (exported);
+ NMSettingsConnectionInterface *candidate = l->data;
NMSetting *setting;
const char *type;
const GByteArray *addr;
- setting = nm_connection_get_setting_by_name (conn, NM_SETTING_BLUETOOTH_SETTING_NAME);
+ setting = nm_connection_get_setting_by_name (NM_CONNECTION (candidate), NM_SETTING_BLUETOOTH_SETTING_NAME);
if (setting == NULL)
continue;
type = nm_setting_bluetooth_get_connection_type (NM_SETTING_BLUETOOTH (setting));
@@ -171,27 +180,27 @@ get_connection_for_bdaddr (const char *bdaddr)
addr = nm_setting_bluetooth_get_bdaddr (NM_SETTING_BLUETOOTH (setting));
if (addr == NULL || memcmp (addr->data, array->data, addr->len) != 0)
continue;
- result = exported;
+ found = candidate;
break;
}
g_slist_free (list);
- return result;
+ return found;
}
static GtkWidget *
get_config_widgets (const char *bdaddr, const char **uuids)
{
GtkWidget *button;
- NMExportedConnection *conn;
+ NMSettingsConnectionInterface *connection;
button = gtk_check_button_new_with_label (_("Access the Internet using your mobile phone"));
g_object_set_data_full (G_OBJECT (button),
"bdaddr", g_strdup (bdaddr),
(GDestroyNotify) g_free);
- conn = get_connection_for_bdaddr (bdaddr);
- if (conn != NULL) {
- g_object_set_data (G_OBJECT (button), "conn", conn);
+ connection = get_connection_for_bdaddr (bdaddr);
+ if (connection != NULL) {
+ g_object_set_data (G_OBJECT (button), "conn", connection);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
}
g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (button_toggled), NULL);
@@ -202,15 +211,15 @@ get_config_widgets (const char *bdaddr, const char **uuids)
static void
device_removed (const char *bdaddr)
{
- NMExportedConnection *exported;
+ NMSettingsConnectionInterface *connection;
g_message ("Device '%s' got removed", bdaddr);
// FIXME: don't just delete any random PAN conenction for this
// bdaddr, actually delete the one this plugin created
- exported = get_connection_for_bdaddr (bdaddr);
- if (exported)
- nm_exported_connection_delete (exported, NULL);
+ connection = get_connection_for_bdaddr (bdaddr);
+ if (connection)
+ nm_settings_connection_interface_delete (connection, delete_cb, NULL);
}
static GbtPluginInfo plugin_info = {
diff --git a/src/marshallers/nma-marshal.list b/src/marshallers/nma-marshal.list
index 4b7c3c1..4cf3524 100644
--- a/src/marshallers/nma-marshal.list
+++ b/src/marshallers/nma-marshal.list
@@ -1,7 +1,7 @@
VOID:POINTER
VOID:STRING,STRING,STRING
-VOID:STRING,POINTER,BOOLEAN,POINTER
-VOID:OBJECT,STRING,POINTER,BOOLEAN,POINTER
+VOID:STRING,POINTER,BOOLEAN,POINTER,POINTER
+VOID:OBJECT,STRING,POINTER,BOOLEAN,POINTER,POINTER
VOID:POINTER,POINTER
VOID:INT,POINTER
diff --git a/src/utils/utils.c b/src/utils/utils.c
index 0e2234b..61f1a7a 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -30,7 +30,6 @@
#include <nm-gsm-device.h>
#include <nm-cdma-device.h>
#include <nm-access-point.h>
-#include <nm-settings.h>
#include <nm-setting-connection.h>
#include <nm-setting-wired.h>
@@ -893,22 +892,6 @@ utils_ether_ntop (const struct ether_addr *mac)
}
-static void
-add_one_name (gpointer data, gpointer user_data)
-{
- NMExportedConnection *exported = NM_EXPORTED_CONNECTION (data);
- NMConnection *connection;
- NMSettingConnection *s_con;
- const char *id;
- GSList **list = (GSList **) user_data;
-
- connection = nm_exported_connection_get_connection (exported);
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- id = nm_setting_connection_get_id (s_con);
- g_assert (id);
- *list = g_slist_append (*list, (gpointer) id);
-}
-
char *
utils_next_available_name (GSList *connections, const char *format)
{
@@ -916,10 +899,16 @@ utils_next_available_name (GSList *connections, const char *format)
char *cname = NULL;
int i = 0;
- g_slist_foreach (connections, add_one_name, &names);
-
- if (g_slist_length (names) == 0)
- return g_strdup_printf (format, 1);
+ for (iter = connections; iter; iter = g_slist_next (iter)) {
+ NMConnection *candidate = NM_CONNECTION (iter->data);
+ NMSettingConnection *s_con;
+ const char *id;
+
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION));
+ id = nm_setting_connection_get_id (s_con);
+ g_assert (id);
+ names = g_slist_append (names, (gpointer) id);
+ }
/* Find the next available unique connection name */
while (!cname && (i++ < 10000)) {
diff --git a/src/vpn-password-dialog.c b/src/vpn-password-dialog.c
index c1d2307..b1eae10 100644
--- a/src/vpn-password-dialog.c
+++ b/src/vpn-password-dialog.c
@@ -37,7 +37,7 @@
#include <nm-connection.h>
#include <nm-setting-connection.h>
#include <nm-setting-vpn.h>
-#include <nm-settings.h>
+#include <nm-settings-interface.h>
typedef struct {
@@ -166,9 +166,10 @@ destroy_gvalue (gpointer data)
}
gboolean
-nma_vpn_request_password (NMExportedConnection *exported,
+nma_vpn_request_password (NMSettingsConnectionInterface *connection_iface,
gboolean retry,
- DBusGMethodInvocation *context)
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data)
{
const char *argv[] = { NULL /*"/usr/libexec/nm-vpnc-auth-dialog"*/,
"-u", NULL /*"2a5d52b5-95b4-4431-b96e-3dd46128f9a7"*/,
@@ -185,19 +186,18 @@ nma_vpn_request_password (NMExportedConnection *exported,
guint child_stdout_channel_eventid;
char *auth_dialog_binary = NULL;
IOUserData io_user_data;
+ NMConnection *connection = NM_CONNECTION (connection_iface);
NMSettingConnection *s_con;
NMSettingVPN *s_vpn;
gboolean success = FALSE;
GError *error = NULL;
- NMConnection *connection;
const char *id;
const char *connection_type;
const char *service_type;
- g_return_val_if_fail (NM_IS_EXPORTED_CONNECTION (exported), FALSE);
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
- connection = nm_exported_connection_get_connection (exported);
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+ s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
g_return_val_if_fail (s_con != NULL, FALSE);
id = nm_setting_connection_get_id (s_con);
@@ -216,7 +216,9 @@ nma_vpn_request_password (NMExportedConnection *exported,
/* find the auth-dialog binary */
auth_dialog_binary = find_auth_dialog_binary (service_type, id);
if (!auth_dialog_binary) {
- g_set_error (&error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): couldn't find VPN auth dialog helper program '%s'.",
__FILE__, __LINE__, __func__, service_type);
goto out;
@@ -257,7 +259,9 @@ nma_vpn_request_password (NMExportedConnection *exported,
service_type);
gtk_window_present (GTK_WINDOW (dialog));
g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
- g_set_error (&error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
"%s.%d (%s): couldn't run VPN auth dialog.",
__FILE__, __LINE__, __func__);
goto out;
@@ -309,12 +313,13 @@ nma_vpn_request_password (NMExportedConnection *exported,
iter = iter->next;
}
g_hash_table_insert (settings, g_strdup (NM_SETTING_VPN_SETTING_NAME), secrets);
-
- dbus_g_method_return (context, settings);
+ callback (connection_iface, settings, NULL, callback_data);
g_hash_table_destroy (settings);
success = TRUE;
} else {
- g_set_error (&error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED,
+ g_set_error (&error,
+ NM_SETTINGS_INTERFACE_ERROR,
+ NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED,
"%s.%d (%s): canceled", __FILE__, __LINE__, __func__);
}
@@ -325,7 +330,7 @@ nma_vpn_request_password (NMExportedConnection *exported,
g_free (auth_dialog_binary);
if (error) {
- dbus_g_method_return_error (context, error);
+ callback (NM_SETTINGS_CONNECTION_INTERFACE (connection), NULL, error, callback_data);
g_error_free (error);
}
diff --git a/src/vpn-password-dialog.h b/src/vpn-password-dialog.h
index 19cbe2c..325f7bf 100644
--- a/src/vpn-password-dialog.h
+++ b/src/vpn-password-dialog.h
@@ -23,11 +23,11 @@
#define VPN_PASSWORD_DIALOG_H
#include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <nm-settings.h>
+#include <nma-gconf-connection.h>
-gboolean nma_vpn_request_password (NMExportedConnection *exported,
+gboolean nma_vpn_request_password (NMSettingsConnectionInterface *connection,
gboolean retry,
- DBusGMethodInvocation *context);
+ NMANewSecretsRequestedFunc callback,
+ gpointer callback_data);
#endif
diff --git a/src/wired-dialog.c b/src/wired-dialog.c
index 7b0e1a7..b2b48d0 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 *glade_file,
NMClient *nm_client,
- NMConnection *connection,
+ NMSettingsConnectionInterface *connection,
NMDevice *device)
{
GladeXML *xml;
@@ -136,7 +136,7 @@ nma_wired_dialog_new (const char *glade_file,
return NULL;
}
- success = dialog_init (dialog, xml, nm_client, glade_file, connection);
+ success = dialog_init (dialog, xml, nm_client, glade_file, NM_CONNECTION (connection));
if (!success) {
nm_warning ("Couldn't create wired security dialog.");
gtk_widget_destroy (dialog);
@@ -150,10 +150,10 @@ nma_wired_dialog_new (const char *glade_file,
return dialog;
}
-NMConnection *
+NMSettingsConnectionInterface *
nma_wired_dialog_get_connection (GtkWidget *dialog)
{
- NMConnection *connection;
+ NMSettingsConnectionInterface *connection;
WirelessSecurity *security;
NMConnection *tmp_connection;
NMSetting *s_8021x;
@@ -169,7 +169,7 @@ nma_wired_dialog_get_connection (GtkWidget *dialog)
ws_802_1x_fill_connection (security, "wpa_eap_auth_combo", tmp_connection);
s_8021x = nm_connection_get_setting (tmp_connection, NM_TYPE_SETTING_802_1X);
- nm_connection_add_setting (connection, NM_SETTING (g_object_ref (s_8021x)));
+ nm_connection_add_setting (NM_CONNECTION (connection), NM_SETTING (g_object_ref (s_8021x)));
g_object_unref (tmp_connection);
diff --git a/src/wired-dialog.h b/src/wired-dialog.h
index 6dfcb5f..75c6433 100644
--- a/src/wired-dialog.h
+++ b/src/wired-dialog.h
@@ -28,12 +28,13 @@
#include <nm-client.h>
#include <nm-connection.h>
#include <nm-device.h>
+#include <nm-settings-connection-interface.h>
GtkWidget *nma_wired_dialog_new (const char *glade_file,
NMClient *nm_client,
- NMConnection *connection,
+ NMSettingsConnectionInterface *connection,
NMDevice *device);
-NMConnection *nma_wired_dialog_get_connection (GtkWidget *dialog);
+NMSettingsConnectionInterface *nma_wired_dialog_get_connection (GtkWidget *dialog);
#endif /* WIRED_DIALOG_H */
diff --git a/src/wireless-dialog.c b/src/wireless-dialog.c
index 664791f..b513741 100644
--- a/src/wireless-dialog.c
+++ b/src/wireless-dialog.c
@@ -328,29 +328,11 @@ connection_combo_changed (GtkWidget *combo,
gtk_widget_set_sensitive (glade_xml_get_widget (priv->xml, "security_vbox"), is_new);
}
-static void
-exported_connection_to_connection (gpointer data, gpointer user_data)
-{
- GSList **list = (GSList **) user_data;
-
- *list = g_slist_prepend (*list, nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (data)));
-}
-
static GSList *
get_all_connections (NMApplet *applet)
{
- GSList *list;
- GSList *connections = NULL;
-
- list = nm_settings_list_connections (NM_SETTINGS (applet->dbus_settings));
- g_slist_foreach (list, exported_connection_to_connection, &connections);
- g_slist_free (list);
-
- list = nm_settings_list_connections (NM_SETTINGS (applet->gconf_settings));
- g_slist_foreach (list, exported_connection_to_connection, &connections);
- g_slist_free (list);
-
- return connections;
+ 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]