summaryrefslogtreecommitdiff
path: root/src/settings
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings')
-rw-r--r--src/settings/nm-agent-manager.c187
-rw-r--r--src/settings/nm-agent-manager.h4
-rw-r--r--src/settings/nm-secret-agent.c168
-rw-r--r--src/settings/nm-secret-agent.h7
-rw-r--r--src/settings/nm-settings-connection.c410
-rw-r--r--src/settings/nm-settings-connection.h7
-rw-r--r--src/settings/nm-settings.c304
-rw-r--r--src/settings/nm-settings.h9
-rw-r--r--src/settings/plugins/example/Makefile.am1
-rw-r--r--src/settings/plugins/example/nm-example-connection.c1
-rw-r--r--src/settings/plugins/ifcfg-rh/Makefile.am1
-rw-r--r--src/settings/plugins/ifcfg-rh/plugin.c45
-rw-r--r--src/settings/plugins/keyfile/Makefile.am1
-rw-r--r--src/settings/plugins/keyfile/nm-keyfile-connection.c1
-rw-r--r--src/settings/plugins/keyfile/reader.c1
-rw-r--r--src/settings/plugins/keyfile/tests/Makefile.am2
-rw-r--r--src/settings/plugins/keyfile/writer.c21
17 files changed, 597 insertions, 573 deletions
diff --git a/src/settings/nm-agent-manager.c b/src/settings/nm-agent-manager.c
index 333cbb261e..73b4861da3 100644
--- a/src/settings/nm-agent-manager.c
+++ b/src/settings/nm-agent-manager.c
@@ -22,16 +22,13 @@
#include <string.h>
#include <pwd.h>
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
#include "nm-dbus-interface.h"
#include "nm-logging.h"
#include "nm-agent-manager.h"
#include "nm-secret-agent.h"
#include "nm-manager-auth.h"
-#include "nm-dbus-glib-types.h"
#include "nm-manager-auth.h"
#include "nm-setting-vpn.h"
#include "nm-setting-connection.h"
@@ -40,7 +37,9 @@
#include "nm-dbus-manager.h"
#include "nm-session-monitor.h"
#include "nm-simple-connection.h"
-#include "NetworkManagerUtils.h"
+#include "nm-dbus-utils.h"
+
+#include "nmdbus-agent-manager.h"
G_DEFINE_TYPE (NMAgentManager, nm_agent_manager, G_TYPE_OBJECT)
@@ -49,6 +48,8 @@ G_DEFINE_TYPE (NMAgentManager, nm_agent_manager, G_TYPE_OBJECT)
NMAgentManagerPrivate))
typedef struct {
+ NMDBusAgentManager *dbus_agent_manager;
+
gboolean disposed;
NMDBusManager *dbus_mgr;
@@ -80,20 +81,6 @@ static void request_remove_agent (Request *req, NMSecretAgent *agent, GSList **p
static void request_next_agent (Request *req);
-static void impl_agent_manager_register (NMAgentManager *self,
- const char *identifier,
- DBusGMethodInvocation *context);
-
-static void impl_agent_manager_register_with_capabilities (NMAgentManager *self,
- const char *identifier,
- NMSecretAgentCapabilities capabilities,
- DBusGMethodInvocation *context);
-
-static void impl_agent_manager_unregister (NMAgentManager *self,
- DBusGMethodInvocation *context);
-
-#include "nm-agent-manager-glue.h"
-
/********************************************************************/
#define NM_AGENT_MANAGER_ERROR (nm_agent_manager_error_quark ())
@@ -206,7 +193,7 @@ validate_identifier (const char *identifier, GError **error)
static void
agent_register_permissions_done (NMAuthChain *chain,
GError *error,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
gpointer user_data)
{
NMAgentManager *self = NM_AGENT_MANAGER (user_data);
@@ -227,8 +214,7 @@ agent_register_permissions_done (NMAuthChain *chain,
NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED,
"Failed to request agent permissions: (%d) %s",
error->code, error->message);
- dbus_g_method_return_error (context, local);
- g_error_free (local);
+ g_dbus_method_invocation_take_error (context, local);
} else {
agent = nm_auth_chain_steal_data (chain, "agent");
g_assert (agent);
@@ -245,7 +231,7 @@ agent_register_permissions_done (NMAuthChain *chain,
g_hash_table_insert (priv->agents, g_strdup (sender), agent);
nm_log_dbg (LOGD_AGENTS, "(%s) agent registered",
nm_secret_agent_get_description (agent));
- dbus_g_method_return (context);
+ g_dbus_method_invocation_return_value (context, NULL);
/* Signal an agent was registered */
g_signal_emit (self, signals[AGENT_REGISTERED], 0, agent);
@@ -277,12 +263,17 @@ find_agent_by_identifier_and_uid (NMAgentManager *self,
return NULL;
}
-static void
-impl_agent_manager_register_with_capabilities (NMAgentManager *self,
- const char *identifier,
- NMSecretAgentCapabilities capabilities,
- DBusGMethodInvocation *context)
+
+
+
+static gboolean
+impl_agent_manager_register_with_capabilities (NMDBusAgentManager *object,
+ GDBusMethodInvocation *context,
+ const gchar *identifier,
+ guint capabilities,
+ gpointer user_data)
{
+ NMAgentManager *self = NM_AGENT_MANAGER (user_data);
NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self);
NMAuthSubject *subject;
gulong sender_uid = G_MAXULONG;
@@ -350,24 +341,29 @@ impl_agent_manager_register_with_capabilities (NMAgentManager *self,
done:
if (error)
- dbus_g_method_return_error (context, error);
- g_clear_error (&error);
+ g_dbus_method_invocation_take_error (context, error);
g_clear_error (&local);
g_clear_object (&subject);
+
+ return TRUE;
}
-static void
-impl_agent_manager_register (NMAgentManager *self,
- const char *identifier,
- DBusGMethodInvocation *context)
+static gboolean
+impl_agent_manager_register (NMDBusAgentManager *object,
+ GDBusMethodInvocation *context,
+ const gchar *identifier,
+ gpointer user_data)
{
- impl_agent_manager_register_with_capabilities (self, identifier, 0, context);
+ impl_agent_manager_register_with_capabilities (object, context, identifier, 0, user_data);
+ return TRUE;
}
-static void
-impl_agent_manager_unregister (NMAgentManager *self,
- DBusGMethodInvocation *context)
+static gboolean
+impl_agent_manager_unregister (NMDBusAgentManager *object,
+ GDBusMethodInvocation *context,
+ gpointer user_data)
{
+ NMAgentManager *self = NM_AGENT_MANAGER (user_data);
NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self);
GError *error = NULL;
char *sender = NULL;
@@ -391,19 +387,20 @@ impl_agent_manager_unregister (NMAgentManager *self,
goto done;
}
- dbus_g_method_return (context);
+ g_dbus_method_invocation_return_value (context, NULL);
done:
if (error)
- dbus_g_method_return_error (context, error);
- g_clear_error (&error);
+ g_dbus_method_invocation_take_error (context, error);
g_free (sender);
+
+ return TRUE;
}
/*************************************************************/
typedef void (*RequestCompleteFunc) (Request *req,
- GHashTable *secrets,
+ GVariant *secrets,
const char *agent_dbus_owner,
const char *agent_username,
GError *error,
@@ -499,7 +496,7 @@ request_free (Request *req)
static void
req_complete_success (Request *req,
- GHashTable *secrets,
+ GVariant *secrets,
const char *agent_dbus_owner,
const char *agent_uname)
{
@@ -680,7 +677,7 @@ typedef struct {
char *setting_name;
char **hints;
- GHashTable *existing_secrets;
+ GVariant *existing_secrets;
NMAgentSecretsResultFunc callback;
gpointer callback_data;
@@ -704,7 +701,7 @@ connection_request_free (gpointer data)
g_free (req->setting_name);
g_strfreev (req->hints);
if (req->existing_secrets)
- g_hash_table_unref (req->existing_secrets);
+ g_variant_unref (req->existing_secrets);
if (req->chain)
nm_auth_chain_unref (req->chain);
}
@@ -732,7 +729,7 @@ connection_request_add_agent (Request *parent, NMSecretAgent *agent)
static ConnectionRequest *
connection_request_new_get (NMConnection *connection,
NMAuthSubject *subject,
- GHashTable *existing_secrets,
+ GVariant *existing_secrets,
const char *setting_name,
const char *verb,
NMSecretAgentGetSecretsFlags flags,
@@ -762,7 +759,7 @@ connection_request_new_get (NMConnection *connection,
req->connection = g_object_ref (connection);
if (existing_secrets)
- req->existing_secrets = g_hash_table_ref (existing_secrets);
+ req->existing_secrets = g_variant_ref (existing_secrets);
req->setting_name = g_strdup (setting_name);
req->hints = g_strdupv ((char **) hints);
req->flags = flags;
@@ -801,13 +798,13 @@ connection_request_new_other (NMConnection *connection,
static void
get_done_cb (NMSecretAgent *agent,
gconstpointer call_id,
- GHashTable *secrets,
+ GVariant *secrets,
GError *error,
gpointer user_data)
{
Request *parent = user_data;
ConnectionRequest *req = user_data;
- GHashTable *setting_secrets;
+ GVariant *setting_secrets;
const char *agent_dbus_owner;
struct passwd *pw;
char *agent_uname = NULL;
@@ -815,13 +812,16 @@ get_done_cb (NMSecretAgent *agent,
g_return_if_fail (call_id == parent->current_call_id);
if (error) {
+ char *dbus_error;
+
nm_log_dbg (LOGD_AGENTS, "(%s) agent failed secrets request %p/%s/%s: (%d) %s",
nm_secret_agent_get_description (agent),
req, parent->detail, req->setting_name,
error ? error->code : -1,
(error && error->message) ? error->message : "(unknown)");
- if (dbus_g_error_has_name (error, NM_DBUS_INTERFACE_SECRET_AGENT ".UserCanceled")) {
+ dbus_error = g_dbus_error_get_remote_error (error);
+ if (!g_strcmp0 (dbus_error, NM_DBUS_INTERFACE_SECRET_AGENT ".UserCanceled")) {
error = g_error_new_literal (NM_AGENT_MANAGER_ERROR,
NM_AGENT_MANAGER_ERROR_USER_CANCELED,
"User canceled the secrets request.");
@@ -831,12 +831,13 @@ get_done_cb (NMSecretAgent *agent,
/* Try the next agent */
request_next_agent (parent);
}
+ g_free (dbus_error);
return;
}
/* Ensure the setting we wanted secrets for got returned and has something in it */
- setting_secrets = g_hash_table_lookup (secrets, req->setting_name);
- if (!setting_secrets || !g_hash_table_size (setting_secrets)) {
+ setting_secrets = g_variant_lookup_value (secrets, req->setting_name, NM_VARIANT_TYPE_SETTING);
+ if (!setting_secrets || !g_variant_n_children (setting_secrets)) {
nm_log_dbg (LOGD_AGENTS, "(%s) agent returned no secrets for request %p/%s/%s",
nm_secret_agent_get_description (agent),
req, parent->detail, req->setting_name);
@@ -863,40 +864,40 @@ get_done_cb (NMSecretAgent *agent,
}
static void
-set_secrets_not_required (NMConnection *connection, GHashTable *hash)
+set_secrets_not_required (NMConnection *connection, GVariant *dict)
{
- GHashTableIter iter, setting_iter;
+ GVariantIter iter, setting_iter;
const char *setting_name = NULL;
- GHashTable *setting_hash = NULL;
+ GVariant *setting_dict = NULL;
- /* Iterate through the settings hashes */
- g_hash_table_iter_init (&iter, hash);
- while (g_hash_table_iter_next (&iter,
- (gpointer *) &setting_name,
- (gpointer *) &setting_hash)) {
+ /* Iterate through the settings dicts */
+ g_variant_iter_init (&iter, dict);
+ while (g_variant_iter_next (&iter, "{&s@a{sv}}", &setting_name, &setting_dict)) {
const char *key_name = NULL;
NMSetting *setting;
- GValue *val;
+ GVariant *val;
setting = nm_connection_get_setting_by_name (connection, setting_name);
if (setting) {
/* Now through each secret in the setting and mark it as not required */
- g_hash_table_iter_init (&setting_iter, setting_hash);
- while (g_hash_table_iter_next (&setting_iter, (gpointer *) &key_name, (gpointer *) &val)) {
+ g_variant_iter_init (&setting_iter, setting_dict);
+ while (g_variant_iter_next (&setting_iter, "{&sv}", &key_name, &val)) {
/* For each secret, set the flag that it's not required; VPN
* secrets need slightly different treatment here since the
- * "secrets" property is actually a hash table of secrets.
+ * "secrets" property is actually a dictionary of secrets.
*/
if ( strcmp (setting_name, NM_SETTING_VPN_SETTING_NAME) == 0
- && strcmp (key_name, NM_SETTING_VPN_SECRETS) == 0) {
- GHashTableIter vpn_secret_iter;
- const char *secret_name;
+ && strcmp (key_name, NM_SETTING_VPN_SECRETS) == 0
+ && g_variant_is_of_type (val, G_VARIANT_TYPE ("a{ss}"))) {
+ GVariantIter vpn_secret_iter;
+ const char *secret_name, *secret;
- g_hash_table_iter_init (&vpn_secret_iter, g_value_get_boxed (val));
- while (g_hash_table_iter_next (&vpn_secret_iter, (gpointer *) &secret_name, NULL))
+ g_variant_iter_init (&vpn_secret_iter, val);
+ while (g_variant_iter_next (&vpn_secret_iter, "{&s&s}", &secret_name, &secret))
nm_setting_set_secret_flags (setting, secret_name, NM_SETTING_SECRET_FLAG_NOT_REQUIRED, NULL);
} else
nm_setting_set_secret_flags (setting, key_name, NM_SETTING_SECRET_FLAG_NOT_REQUIRED, NULL);
+ g_variant_unref (val);
}
}
}
@@ -946,7 +947,7 @@ get_agent_request_secrets (ConnectionRequest *req, gboolean include_system_secre
static void
get_agent_modify_auth_cb (NMAuthChain *chain,
GError *error,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
gpointer user_data)
{
Request *parent = user_data;
@@ -1079,15 +1080,15 @@ get_start (gpointer user_data)
{
Request *parent = user_data;
ConnectionRequest *req = user_data;
- GHashTable *setting_secrets = NULL;
+ GVariant *setting_secrets = NULL;
parent->idle_id = 0;
/* Check if there are any existing secrets */
if (req->existing_secrets)
- setting_secrets = g_hash_table_lookup (req->existing_secrets, req->setting_name);
+ setting_secrets = g_variant_lookup_value (req->existing_secrets, req->setting_name, NM_VARIANT_TYPE_SETTING);
- if (setting_secrets && g_hash_table_size (setting_secrets)) {
+ if (setting_secrets && g_variant_n_children (setting_secrets)) {
NMConnection *tmp;
GError *error = NULL;
gboolean new_secrets = (req->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW);
@@ -1132,12 +1133,15 @@ get_start (gpointer user_data)
request_next_agent (parent);
}
+ if (setting_secrets)
+ g_variant_unref (setting_secrets);
+
return FALSE;
}
static void
get_complete_cb (Request *parent,
- GHashTable *secrets,
+ GVariant *secrets,
const char *agent_dbus_owner,
const char *agent_username,
GError *error,
@@ -1178,7 +1182,7 @@ guint32
nm_agent_manager_get_secrets (NMAgentManager *self,
NMConnection *connection,
NMAuthSubject *subject,
- GHashTable *existing_secrets,
+ GVariant *existing_secrets,
const char *setting_name,
NMSecretAgentGetSecretsFlags flags,
const char **hints,
@@ -1248,7 +1252,7 @@ nm_agent_manager_cancel_secrets (NMAgentManager *self,
static void
save_done_cb (NMSecretAgent *agent,
gconstpointer call_id,
- GHashTable *secrets,
+ GVariant *secrets,
GError *error,
gpointer user_data)
{
@@ -1295,7 +1299,7 @@ save_next_cb (Request *parent)
static void
save_complete_cb (Request *req,
- GHashTable *secrets,
+ GVariant *secrets,
const char *agent_dbus_owner,
const char *agent_username,
GError *error,
@@ -1342,7 +1346,7 @@ nm_agent_manager_save_secrets (NMAgentManager *self,
static void
delete_done_cb (NMSecretAgent *agent,
gconstpointer call_id,
- GHashTable *secrets,
+ GVariant *secrets,
GError *error,
gpointer user_data)
{
@@ -1382,7 +1386,7 @@ delete_next_cb (Request *parent)
static void
delete_complete_cb (Request *req,
- GHashTable *secrets,
+ GVariant *secrets,
const char *agent_dbus_owner,
const char *agent_username,
GError *error,
@@ -1486,7 +1490,7 @@ name_owner_changed_cb (NMDBusManager *dbus_mgr,
static void
agent_permissions_changed_done (NMAuthChain *chain,
GError *error,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
gpointer user_data)
{
NMAgentManager *self = NM_AGENT_MANAGER (user_data);
@@ -1587,6 +1591,14 @@ nm_agent_manager_init (NMAgentManager *self)
g_direct_equal,
NULL,
(GDestroyNotify) request_free);
+
+ priv->dbus_agent_manager = nmdbus_agent_manager_skeleton_new ();
+ g_signal_connect (priv->dbus_agent_manager, "handle-register-with-capabilities",
+ G_CALLBACK (impl_agent_manager_register_with_capabilities), self);
+ g_signal_connect (priv->dbus_agent_manager, "handle-register",
+ G_CALLBACK (impl_agent_manager_register), self);
+ g_signal_connect (priv->dbus_agent_manager, "handle-unregister",
+ G_CALLBACK (impl_agent_manager_unregister), self);
}
static void
@@ -1605,6 +1617,12 @@ dispose (GObject *object)
g_hash_table_destroy (priv->requests);
priv->dbus_mgr = NULL;
+
+ g_signal_handlers_disconnect_matched (priv->dbus_agent_manager,
+ G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, object);
+ g_clear_object (&priv->dbus_agent_manager);
+
}
G_OBJECT_CLASS (nm_agent_manager_parent_class)->dispose (object);
@@ -1631,10 +1649,7 @@ nm_agent_manager_class_init (NMAgentManagerClass *agent_manager_class)
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
- dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (agent_manager_class),
- &dbus_glib_nm_agent_manager_object_info);
-
- dbus_g_error_domain_register (NM_AGENT_MANAGER_ERROR,
- NM_DBUS_INTERFACE_AGENT_MANAGER,
- NM_TYPE_AGENT_MANAGER_ERROR);
+ _nm_dbus_register_error_domain (NM_AGENT_MANAGER_ERROR,
+ NM_DBUS_INTERFACE_AGENT_MANAGER,
+ NM_TYPE_AGENT_MANAGER_ERROR);
}
diff --git a/src/settings/nm-agent-manager.h b/src/settings/nm-agent-manager.h
index 1aac2d2ae0..beb9244fdd 100644
--- a/src/settings/nm-agent-manager.h
+++ b/src/settings/nm-agent-manager.h
@@ -68,7 +68,7 @@ typedef void (*NMAgentSecretsResultFunc) (NMAgentManager *manager,
gboolean agent_has_modify,
const char *setting_name,
NMSecretAgentGetSecretsFlags flags,
- GHashTable *secrets,
+ GVariant *secrets,
GError *error,
gpointer user_data,
gpointer other_data2,
@@ -77,7 +77,7 @@ typedef void (*NMAgentSecretsResultFunc) (NMAgentManager *manager,
guint32 nm_agent_manager_get_secrets (NMAgentManager *manager,
NMConnection *connection,
NMAuthSubject *subject,
- GHashTable *existing_secrets,
+ GVariant *existing_secrets,
const char *setting_name,
NMSecretAgentGetSecretsFlags flags,
const char **hints,
diff --git a/src/settings/nm-secret-agent.c b/src/settings/nm-secret-agent.c
index a1c6954ee2..9e9822c8c3 100644
--- a/src/settings/nm-secret-agent.c
+++ b/src/settings/nm-secret-agent.c
@@ -24,13 +24,10 @@
#include <pwd.h>
#include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include "nm-dbus-interface.h"
#include "nm-secret-agent.h"
#include "nm-dbus-manager.h"
-#include "nm-dbus-glib-types.h"
#include "nm-glib-compat.h"
#include "nm-logging.h"
#include "nm-auth-subject.h"
@@ -53,7 +50,7 @@ typedef struct {
GSList *permissions;
- DBusGProxy *proxy;
+ GDBusProxy *proxy;
guint proxy_destroy_id;
GHashTable *requests;
@@ -63,7 +60,7 @@ typedef struct {
typedef struct {
NMSecretAgent *agent;
- DBusGProxyCall *call;
+ GCancellable *cancellable;
char *path;
char *setting_name;
NMSecretAgentCallback callback;
@@ -85,6 +82,7 @@ request_new (NMSecretAgent *agent,
r->setting_name = g_strdup (setting_name);
r->callback = callback;
r->callback_data = callback_data;
+ r->cancellable = g_cancellable_new ();
return r;
}
@@ -93,6 +91,7 @@ request_free (Request *r)
{
g_free (r->path);
g_free (r->setting_name);
+ g_object_unref (r->cancellable);
g_slice_free (Request, r);
}
@@ -253,25 +252,26 @@ nm_secret_agent_has_permission (NMSecretAgent *agent, const char *permission)
/*************************************************************/
static void
-get_callback (DBusGProxy *proxy,
- DBusGProxyCall *call,
- void *user_data)
+get_callback (GObject *proxy,
+ GAsyncResult *result,
+ gpointer user_data)
{
Request *r = user_data;
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (r->agent);
GError *error = NULL;
- GHashTable *secrets = NULL;
-
- g_return_if_fail (call == r->call);
-
- dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &secrets,
- G_TYPE_INVALID);
- r->callback (r->agent, r->call, secrets, error, r->callback_data);
- if (secrets)
- g_hash_table_unref (secrets);
- g_clear_error (&error);
- g_hash_table_remove (priv->requests, call);
+ GVariant *ret, *secrets = NULL;
+
+ if (!g_cancellable_is_cancelled (r->cancellable)) {
+ ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), result, &error);
+ if (ret && g_variant_is_of_type (ret, G_VARIANT_TYPE ("(a{sa{sv}})")))
+ g_variant_get (ret, "(@a{sa{sv}})", &secrets);
+ r->callback (r->agent, r, secrets, error, r->callback_data);
+ if (secrets)
+ g_variant_unref (secrets);
+ g_clear_error (&error);
+ }
+
+ g_hash_table_remove (priv->requests, r);
}
gconstpointer
@@ -285,7 +285,6 @@ nm_secret_agent_get_secrets (NMSecretAgent *self,
{
NMSecretAgentPrivate *priv;
GVariant *dict;
- GHashTable *hash;
Request *r;
g_return_val_if_fail (self != NULL, NULL);
@@ -296,88 +295,87 @@ nm_secret_agent_get_secrets (NMSecretAgent *self,
g_return_val_if_fail (priv->proxy != NULL, NULL);
dict = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
- hash = nm_utils_connection_dict_to_hash (dict);
- g_variant_unref (dict);
/* Mask off the private ONLY_SYSTEM flag if present */
flags &= ~NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM;
r = request_new (self, nm_connection_get_path (connection), setting_name, callback, callback_data);
- r->call = dbus_g_proxy_begin_call_with_timeout (priv->proxy,
- "GetSecrets",
- get_callback,
- r,
- NULL,
- 120000, /* 120 seconds */
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
- DBUS_TYPE_G_OBJECT_PATH, nm_connection_get_path (connection),
- G_TYPE_STRING, setting_name,
- G_TYPE_STRV, hints,
- G_TYPE_UINT, flags,
- G_TYPE_INVALID);
- g_hash_table_insert (priv->requests, r->call, r);
-
- g_hash_table_destroy (hash);
- return r->call;
+ g_dbus_proxy_call (priv->proxy,
+ "GetSecrets",
+ g_variant_new ("(@a{sa{sv}}os^asu)",
+ dict,
+ nm_connection_get_path (connection),
+ setting_name,
+ hints,
+ flags),
+ G_DBUS_CALL_FLAGS_NONE, 120000, /* 120 seconds */
+ r->cancellable,
+ get_callback, r);
+ g_hash_table_insert (priv->requests, r, r);
+
+ return r;
}
static void
-cancel_done (DBusGProxy *proxy, DBusGProxyCall *call_id, void *user_data)
+cancel_done (GObject *proxy, GAsyncResult *result, gpointer user_data)
{
+ char *description = user_data;
+ GVariant *ret;
GError *error = NULL;
- if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
+ ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), result, &error);
+ if (!ret) {
nm_log_dbg (LOGD_AGENTS, "(%s): agent failed to cancel secrets: (%d) %s",
- (const char *) user_data,
- error ? error->code : -1,
- error && error->message ? error->message : "(unknown)");
+ description, error->code, error->message);
g_clear_error (&error);
- }
+ } else
+ g_variant_unref (ret);
+
+ g_free (description);
}
void
nm_secret_agent_cancel_secrets (NMSecretAgent *self, gconstpointer call)
{
NMSecretAgentPrivate *priv;
- Request *r;
+ Request *r = (gpointer) call;
g_return_if_fail (self != NULL);
priv = NM_SECRET_AGENT_GET_PRIVATE (self);
g_return_if_fail (priv->proxy != NULL);
-
- r = g_hash_table_lookup (priv->requests, call);
g_return_if_fail (r != NULL);
- dbus_g_proxy_cancel_call (priv->proxy, (gpointer) call);
-
- dbus_g_proxy_begin_call (priv->proxy,
- "CancelGetSecrets",
- cancel_done,
- g_strdup (nm_secret_agent_get_description (self)),
- g_free,
- DBUS_TYPE_G_OBJECT_PATH, r->path,
- G_TYPE_STRING, r->setting_name,
- G_TYPE_INVALID);
- g_hash_table_remove (priv->requests, call);
+ g_cancellable_cancel (r->cancellable);
+
+ g_dbus_proxy_call (priv->proxy,
+ "CancelGetSecrets",
+ g_variant_new ("(os)", r->path, r->setting_name),
+ G_DBUS_CALL_FLAGS_NONE, 0,
+ NULL,
+ cancel_done, g_strdup (nm_secret_agent_get_description (self)));
}
/*************************************************************/
static void
-agent_save_delete_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- void *user_data)
+agent_save_delete_cb (GObject *proxy,
+ GAsyncResult *result,
+ gpointer user_data)
{
Request *r = user_data;
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (r->agent);
+ GVariant *ret;
GError *error = NULL;
- g_return_if_fail (call == r->call);
+ if (!g_cancellable_is_cancelled (r->cancellable)) {
+ ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), result, &error);
+ if (ret)
+ g_variant_unref (ret);
+ r->callback (r->agent, r, NULL, error, r->callback_data);
+ g_clear_error (&error);
+ }
- dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
- r->callback (r->agent, r->call, NULL, error, r->callback_data);
- g_clear_error (&error);
- g_hash_table_remove (priv->requests, call);
+ g_hash_table_remove (priv->requests, r);
}
static gpointer
@@ -390,28 +388,21 @@ agent_new_save_delete (NMSecretAgent *self,
{
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
GVariant *dict;
- GHashTable *hash;
Request *r;
const char *cpath = nm_connection_get_path (connection);
dict = nm_connection_to_dbus (connection, flags);
- hash = nm_utils_connection_dict_to_hash (dict);
- g_variant_unref (dict);
r = request_new (self, cpath, NULL, callback, callback_data);
- r->call = dbus_g_proxy_begin_call_with_timeout (priv->proxy,
- method,
- agent_save_delete_cb,
- r,
- NULL,
- 10000, /* 10 seconds */
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
- DBUS_TYPE_G_OBJECT_PATH, cpath,
- G_TYPE_INVALID);
- g_hash_table_insert (priv->requests, r->call, r);
-
- g_hash_table_destroy (hash);
- return r->call;
+ g_dbus_proxy_call (priv->proxy,
+ method,
+ g_variant_new ("(@a{sa{sv}}o)", dict, cpath),
+ G_DBUS_CALL_FLAGS_NONE, 10000, /* 10 seconds */
+ NULL,
+ agent_save_delete_cb, r);
+ g_hash_table_insert (priv->requests, r, r);
+
+ return r;
}
gconstpointer
@@ -450,6 +441,7 @@ nm_secret_agent_delete_secrets (NMSecretAgent *self,
callback_data);
}
+#ifdef FIXME
static void
proxy_cleanup (NMSecretAgent *self)
{
@@ -461,11 +453,12 @@ proxy_cleanup (NMSecretAgent *self)
g_clear_object (&priv->proxy);
}
}
+#endif
/*************************************************************/
NMSecretAgent *
-nm_secret_agent_new (DBusGMethodInvocation *context,
+nm_secret_agent_new (GDBusMethodInvocation *context,
NMAuthSubject *subject,
const char *identifier,
NMSecretAgentCapabilities capabilities)
@@ -502,9 +495,10 @@ nm_secret_agent_new (DBusGMethodInvocation *context,
NM_DBUS_PATH_SECRET_AGENT,
NM_DBUS_INTERFACE_SECRET_AGENT);
g_assert (priv->proxy);
+#ifdef FIXME
priv->proxy_destroy_id = g_signal_connect_swapped (priv->proxy, "destroy",
G_CALLBACK (proxy_cleanup), self);
-
+#endif
g_free (username);
return self;
}
@@ -523,7 +517,11 @@ dispose (GObject *object)
{
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (object);
+#ifdef FIXME
proxy_cleanup (NM_SECRET_AGENT (object));
+#else
+ g_clear_object (&priv->proxy);
+#endif
g_clear_object (&priv->subject);
G_OBJECT_CLASS (nm_secret_agent_parent_class)->dispose (object);
diff --git a/src/settings/nm-secret-agent.h b/src/settings/nm-secret-agent.h
index f3f4ff89c5..0b985d9722 100644
--- a/src/settings/nm-secret-agent.h
+++ b/src/settings/nm-secret-agent.h
@@ -21,8 +21,7 @@
#ifndef __NETWORKMANAGER_SECRET_AGENT_H__
#define __NETWORKMANAGER_SECRET_AGENT_H__
-#include <glib.h>
-#include <glib-object.h>
+#include <gio/gio.h>
#include <nm-connection.h>
#include "nm-types.h"
@@ -44,7 +43,7 @@ typedef struct {
GType nm_secret_agent_get_type (void);
-NMSecretAgent *nm_secret_agent_new (DBusGMethodInvocation *context,
+NMSecretAgent *nm_secret_agent_new (GDBusMethodInvocation *invocation,
NMAuthSubject *subject,
const char *identifier,
NMSecretAgentCapabilities capabilities);
@@ -76,7 +75,7 @@ gboolean nm_secret_agent_has_permission (NMSecretAgent *agent,
typedef void (*NMSecretAgentCallback) (NMSecretAgent *agent,
gconstpointer call,
- GHashTable *new_secrets, /* NULL for save & delete */
+ GVariant *new_secrets, /* NULL for save & delete */
GError *error,
gpointer user_data);
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
index db382adb82..d0ad47aed3 100644
--- a/src/settings/nm-settings-connection.c
+++ b/src/settings/nm-settings-connection.c
@@ -24,7 +24,6 @@
#include <string.h>
#include <nm-dbus-interface.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include <nm-setting-connection.h>
#include <nm-setting-vpn.h>
#include <nm-setting-wireless.h>
@@ -34,7 +33,6 @@
#include "nm-session-monitor.h"
#include "nm-dbus-manager.h"
#include "nm-settings-error.h"
-#include "nm-dbus-glib-types.h"
#include "nm-logging.h"
#include "nm-manager-auth.h"
#include "nm-auth-subject.h"
@@ -42,34 +40,11 @@
#include "NetworkManagerUtils.h"
#include "nm-properties-changed-signal.h"
+#include "nmdbus-settings-connection.h"
+
#define SETTINGS_TIMESTAMPS_FILE NMSTATEDIR "/timestamps"
#define SETTINGS_SEEN_BSSIDS_FILE NMSTATEDIR "/seen-bssids"
-static void impl_settings_connection_get_settings (NMSettingsConnection *connection,
- DBusGMethodInvocation *context);
-
-static void impl_settings_connection_update (NMSettingsConnection *connection,
- GHashTable *new_settings,
- DBusGMethodInvocation *context);
-
-static void impl_settings_connection_update_unsaved (NMSettingsConnection *connection,
- GHashTable *new_settings,
- DBusGMethodInvocation *context);
-
-static void impl_settings_connection_save (NMSettingsConnection *connection,
- DBusGMethodInvocation *context);
-
-static void impl_settings_connection_delete (NMSettingsConnection *connection,
- DBusGMethodInvocation *context);
-
-static void impl_settings_connection_get_secrets (NMSettingsConnection *connection,
- const gchar *setting_name,
- DBusGMethodInvocation *context);
-
-#include "nm-settings-connection-glue.h"
-
-static void nm_settings_connection_connection_interface_init (NMConnectionInterface *iface);
-
G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_settings_connection_connection_interface_init)
)
@@ -93,6 +68,8 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
typedef struct {
+ NMDBusSettingsConnection *dbus_settings_connection;
+
NMAgentManager *agent_mgr;
NMSessionMonitor *session_monitor;
guint session_changed_id;
@@ -141,80 +118,160 @@ typedef struct {
/**************************************************************/
/* Return TRUE to continue, FALSE to stop */
-typedef gboolean (*ForEachSecretFunc) (GHashTableIter *iter,
- NMSettingSecretFlags flags,
+typedef gboolean (*ForEachSecretFunc) (NMSettingSecretFlags flags,
gpointer user_data);
+/* These functions, given a dict of dicts representing new secrets of an
+ * NMConnection, walk through each toplevel dict (which represents a NMSetting),
+ * and for each setting, walks through that setting's properties. For each
+ * property that's a secret, they will check that secret's flags in the backing
+ * NMConnection object, and call a supplied callback.
+ *
+ * The one complexity is that the VPN setting's 'secrets' property is *also* a
+ * dict (since the key/value pairs are arbitrary and known only to the VPN
+ * plugin itself). That means we have three levels of dicts that we potentially
+ * have to traverse here. When we hit the VPN setting's 'secrets' property, we
+ * special-case that and iterate over each item in that 'secrets' dict, calling
+ * the supplied callback each time.
+ */
+
static void
-for_each_secret (NMConnection *connection,
- GHashTable *secrets,
- ForEachSecretFunc callback,
- gpointer callback_data)
+find_secret (NMConnection *connection,
+ GVariant *secrets,
+ ForEachSecretFunc callback,
+ gpointer callback_data)
{
- GHashTableIter iter;
+ GVariantIter secrets_iter;
const char *setting_name;
- GHashTable *setting_hash;
-
- /* This function, given a hash of hashes representing new secrets of
- * an NMConnection, walks through each toplevel hash (which represents a
- * NMSetting), and for each setting, walks through that setting hash's
- * properties. For each property that's a secret, it will check that
- * secret's flags in the backing NMConnection object, and call a supplied
- * callback.
- *
- * The one complexity is that the VPN setting's 'secrets' property is
- * *also* a hash table (since the key/value pairs are arbitrary and known
- * only to the VPN plugin itself). That means we have three levels of
- * GHashTables that we potentially have to traverse here. When we hit the
- * VPN setting's 'secrets' property, we special-case that and iterate over
- * each item in that 'secrets' hash table, calling the supplied callback
- * each time.
- */
+ GVariantIter *setting_iter;
- /* Walk through the list of setting hashes */
- g_hash_table_iter_init (&iter, secrets);
- while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, (gpointer) &setting_hash)) {
+ g_variant_iter_init (&secrets_iter, secrets);
+ while (g_variant_iter_next (&secrets_iter, "{&sa{sv}}", &setting_name, &setting_iter)) {
NMSetting *setting;
- GHashTableIter secret_iter;
const char *secret_name;
- GValue *val;
+ GVariant *val;
/* Get the actual NMSetting from the connection so we can get secret flags
* from the connection data, since flags aren't secrets. What we're
* iterating here is just the secrets, not a whole connection.
*/
setting = nm_connection_get_setting_by_name (connection, setting_name);
- if (setting == NULL)
+ if (setting == NULL) {
+ g_variant_iter_free (setting_iter);
continue;
+ }
- /* Walk through the list of keys in each setting hash */
- g_hash_table_iter_init (&secret_iter, setting_hash);
- while (g_hash_table_iter_next (&secret_iter, (gpointer) &secret_name, (gpointer) &val)) {
+ /* Walk through the list of keys in each setting dict */
+ while (g_variant_iter_next (setting_iter, "{sv}", &secret_name, &val)) {
NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
/* VPN secrets need slightly different treatment here since the
* "secrets" property is actually a hash table of secrets.
*/
- if (NM_IS_SETTING_VPN (setting) && (g_strcmp0 (secret_name, NM_SETTING_VPN_SECRETS) == 0)) {
- GHashTableIter vpn_secrets_iter;
+ if ( NM_IS_SETTING_VPN (setting)
+ && !g_strcmp0 (secret_name, NM_SETTING_VPN_SECRETS)) {
+ GVariantIter vpn_secrets_iter;
/* Iterate through each secret from the VPN hash in the overall secrets hash */
- g_hash_table_iter_init (&vpn_secrets_iter, g_value_get_boxed (val));
- while (g_hash_table_iter_next (&vpn_secrets_iter, (gpointer) &secret_name, NULL)) {
+ g_variant_iter_init (&vpn_secrets_iter, val);
+ while (g_variant_iter_next (&vpn_secrets_iter, "{&s&s}", &secret_name, NULL)) {
secret_flags = NM_SETTING_SECRET_FLAG_NONE;
nm_setting_get_secret_flags (setting, secret_name, &secret_flags, NULL);
- if (callback (&vpn_secrets_iter, secret_flags, callback_data) == FALSE)
+ if (!callback (secret_flags, callback_data)) {
+ g_variant_iter_free (setting_iter);
+ g_variant_unref (val);
return;
+ }
}
} else {
nm_setting_get_secret_flags (setting, secret_name, &secret_flags, NULL);
- if (callback (&secret_iter, secret_flags, callback_data) == FALSE)
+ if (!callback (secret_flags, callback_data)) {
+ g_variant_iter_free (setting_iter);
+ g_variant_unref (val);
return;
+ }
}
+
+ g_variant_unref (val);
}
+
+ g_variant_iter_free (setting_iter);
}
}
+static GVariant *
+filter_vpn_secrets (NMSetting *setting,
+ GVariant *vpn_secrets,
+ ForEachSecretFunc callback,
+ gpointer callback_data)
+{
+ GVariantIter iter;
+ GVariantBuilder builder;
+ const char *secret_name, *secret;
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));
+ g_variant_iter_init (&iter, vpn_secrets);
+ while (g_variant_iter_next (&iter, "{&s&s}", &secret_name, &secret)) {
+ NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
+
+ nm_setting_get_secret_flags (setting, secret_name, &secret_flags, NULL);
+ if (callback (secret_flags, callback_data))
+ g_variant_builder_add (&builder, "{ss}", secret_name, secret);
+ }
+
+ return g_variant_builder_end (&builder);
+}
+
+static GVariant *
+filter_secrets (NMConnection *connection,
+ GVariant *secrets,
+ ForEachSecretFunc callback,
+ gpointer callback_data)
+{
+ GVariantBuilder secrets_builder, setting_builder;
+ GVariantIter secrets_iter, *setting_iter;
+ const char *setting_name;
+
+ /* Walk through the list of setting hashes */
+ g_variant_iter_init (&secrets_iter, secrets);
+ g_variant_builder_init (&secrets_builder, NM_VARIANT_TYPE_CONNECTION);
+ while (g_variant_iter_next (&secrets_iter, "{&sa{sv}}", &setting_name, &setting_iter)) {
+ NMSetting *setting;
+ const char *secret_name;
+ GVariant *val;
+
+ setting = nm_connection_get_setting_by_name (connection, setting_name);
+ if (setting == NULL) {
+ g_variant_iter_free (setting_iter);
+ continue;
+ }
+
+ g_variant_builder_init (&setting_builder, NM_VARIANT_TYPE_SETTING);
+ while (g_variant_iter_next (setting_iter, "{sv}", &secret_name, &val)) {
+ NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
+
+ if ( NM_IS_SETTING_VPN (setting)
+ && !g_strcmp0 (secret_name, NM_SETTING_VPN_SECRETS)) {
+ GVariant *vpn_secrets;
+
+ vpn_secrets = filter_vpn_secrets (setting, val, callback, callback_data);
+ g_variant_builder_add (&setting_builder, "{sv}", secret_name, vpn_secrets);
+ } else {
+ nm_setting_get_secret_flags (setting, secret_name, &secret_flags, NULL);
+ if (callback (secret_flags, callback_data))
+ g_variant_builder_add (&setting_builder, "{sv}", &secret_name, val);
+ }
+ g_variant_unref (val);
+ }
+
+ g_variant_iter_free (setting_iter);
+ g_variant_builder_add (&secrets_builder, "sa{sv}", setting_name, &setting_builder);
+ }
+
+ g_variant_unref (secrets);
+ return g_variant_builder_end (&secrets_builder);
+}
+
/**************************************************************/
static void
@@ -439,6 +496,7 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self,
GError **error)
{
NMSettingsConnectionPrivate *priv;
+ GVariant *dict = NULL;
gboolean success = FALSE;
g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), FALSE);
@@ -662,28 +720,21 @@ supports_secrets (NMSettingsConnection *connection, const char *setting_name)
}
static gboolean
-clear_nonagent_secrets (GHashTableIter *iter,
- NMSettingSecretFlags flags,
+clear_nonagent_secrets (NMSettingSecretFlags flags,
gpointer user_data)
{
- if (flags != NM_SETTING_SECRET_FLAG_AGENT_OWNED)
- g_hash_table_iter_remove (iter);
- return TRUE;
+ return !!(flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED);
}
static gboolean
-clear_unsaved_secrets (GHashTableIter *iter,
- NMSettingSecretFlags flags,
+clear_unsaved_secrets (NMSettingSecretFlags flags,
gpointer user_data)
{
- if (flags & (NM_SETTING_SECRET_FLAG_NOT_SAVED | NM_SETTING_SECRET_FLAG_NOT_REQUIRED))
- g_hash_table_iter_remove (iter);
- return TRUE;
+ return !(flags & (NM_SETTING_SECRET_FLAG_NOT_SAVED | NM_SETTING_SECRET_FLAG_NOT_REQUIRED));
}
static gboolean
-has_system_owned_secrets (GHashTableIter *iter,
- NMSettingSecretFlags flags,
+has_system_owned_secrets (NMSettingSecretFlags flags,
gpointer user_data)
{
gboolean *has_system_owned = user_data;
@@ -714,7 +765,7 @@ agent_secrets_done_cb (NMAgentManager *manager,
gboolean agent_has_modify,
const char *setting_name,
NMSecretAgentGetSecretsFlags flags,
- GHashTable *secrets,
+ GVariant *secrets,
GError *error,
gpointer user_data,
gpointer other_data2,
@@ -763,7 +814,7 @@ agent_secrets_done_cb (NMAgentManager *manager,
* save those system-owned secrets. If not, discard them and use the
* existing secrets, or fail the connection.
*/
- for_each_secret (NM_CONNECTION (self), secrets, has_system_owned_secrets, &agent_had_system);
+ find_secret (NM_CONNECTION (self), secrets, has_system_owned_secrets, &agent_had_system);
if (agent_had_system) {
if (flags == NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE) {
/* No user interaction was allowed when requesting secrets; the
@@ -775,7 +826,7 @@ agent_secrets_done_cb (NMAgentManager *manager,
call_id,
agent_dbus_owner);
- for_each_secret (NM_CONNECTION (self), secrets, clear_nonagent_secrets, NULL);
+ secrets = filter_secrets (NM_CONNECTION (self), secrets, clear_nonagent_secrets, NULL);
} else if (agent_has_modify == FALSE) {
/* Agent didn't successfully authenticate; clear system-owned secrets
* from the secrets the agent returned.
@@ -785,7 +836,7 @@ agent_secrets_done_cb (NMAgentManager *manager,
setting_name,
call_id);
- for_each_secret (NM_CONNECTION (self), secrets, clear_nonagent_secrets, NULL);
+ secrets = filter_secrets (NM_CONNECTION (self), secrets, clear_nonagent_secrets, NULL);
}
}
} else {
@@ -804,7 +855,7 @@ agent_secrets_done_cb (NMAgentManager *manager,
* came back. Unsaved secrets by definition require user interaction.
*/
if (flags == NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE)
- for_each_secret (NM_CONNECTION (self), secrets, clear_unsaved_secrets, NULL);
+ secrets = filter_secrets (NM_CONNECTION (self), secrets, clear_unsaved_secrets, NULL);
/* Update the connection with our existing secrets from backing storage */
nm_connection_clear_secrets (NM_CONNECTION (self));
@@ -895,7 +946,6 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
{
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
GVariant *existing_secrets;
- GHashTable *existing_secrets_hash;
guint32 call_id = 0;
char *joined_hints = NULL;
@@ -967,7 +1017,7 @@ nm_settings_connection_cancel_secrets (NMSettingsConnection *self,
/**** User authorization **************************************/
typedef void (*AuthCallback) (NMSettingsConnection *connection,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
NMAuthSubject *subject,
GError *error,
gpointer data);
@@ -975,7 +1025,7 @@ typedef void (*AuthCallback) (NMSettingsConnection *connection,
static void
pk_auth_cb (NMAuthChain *chain,
GError *chain_error,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
gpointer user_data)
{
NMSettingsConnection *self = NM_SETTINGS_CONNECTION (user_data);
@@ -1024,7 +1074,7 @@ pk_auth_cb (NMAuthChain *chain,
* Returns: the #NMAuthSubject on success, or %NULL on failure and sets @error
*/
static NMAuthSubject *
-_new_auth_subject (DBusGMethodInvocation *context, GError **error)
+_new_auth_subject (GDBusMethodInvocation *context, GError **error)
{
NMAuthSubject *subject;
@@ -1041,7 +1091,7 @@ _new_auth_subject (DBusGMethodInvocation *context, GError **error)
static void
auth_start (NMSettingsConnection *self,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
NMAuthSubject *subject,
const char *check_permission,
AuthCallback callback,
@@ -1130,16 +1180,15 @@ check_writable (NMConnection *connection, GError **error)
static void
get_settings_auth_cb (NMSettingsConnection *self,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
NMAuthSubject *subject,
GError *error,
gpointer data)
{
if (error)
- dbus_g_method_return_error (context, error);
+ g_dbus_method_invocation_return_gerror (context, error);
else {
GVariant *settings;
- GHashTable *settings_hash;
NMConnection *dupl_con;
NMSettingConnection *s_con;
NMSettingWireless *s_wifi;
@@ -1177,17 +1226,15 @@ get_settings_auth_cb (NMSettingsConnection *self,
*/
settings = nm_connection_to_dbus (NM_CONNECTION (dupl_con), NM_CONNECTION_SERIALIZE_NO_SECRETS);
g_assert (settings);
- settings_hash = nm_utils_connection_dict_to_hash (settings);
- dbus_g_method_return (context, settings_hash);
- g_hash_table_destroy (settings_hash);
- g_variant_unref (settings);
+ g_dbus_method_invocation_return_value (context,
+ g_variant_new ("(@a{sa{sv}})", settings));
g_object_unref (dupl_con);
}
}
-static void
+static gboolean
impl_settings_connection_get_settings (NMSettingsConnection *self,
- DBusGMethodInvocation *context)
+ GDBusMethodInvocation *context)
{
NMAuthSubject *subject;
GError *error = NULL;
@@ -1197,13 +1244,15 @@ impl_settings_connection_get_settings (NMSettingsConnection *self,
auth_start (self, context, subject, NULL, get_settings_auth_cb, NULL);
g_object_unref (subject);
} else {
- dbus_g_method_return_error (context, error);
+ g_dbus_method_invocation_return_gerror (context, error);
g_error_free (error);
}
+
+ return TRUE;
}
typedef struct {
- DBusGMethodInvocation *context;
+ GDBusMethodInvocation *context;
NMAgentManager *agent_mgr;
NMAuthSubject *subject;
NMConnection *new_settings;
@@ -1216,9 +1265,9 @@ update_complete (NMSettingsConnection *self,
GError *error)
{
if (error)
- dbus_g_method_return_error (info->context, error);
+ g_dbus_method_invocation_return_gerror (info->context, error);
else
- dbus_g_method_return (info->context);
+ g_dbus_method_invocation_return_value (info->context, NULL);
g_clear_object (&info->subject);
g_clear_object (&info->agent_mgr);
@@ -1253,7 +1302,7 @@ con_update_cb (NMSettingsConnection *self,
static void
update_auth_cb (NMSettingsConnection *self,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
NMAuthSubject *subject,
GError *error,
gpointer data)
@@ -1316,8 +1365,8 @@ get_update_modify_permission (NMConnection *old, NMConnection *new)
static void
impl_settings_connection_update_helper (NMSettingsConnection *self,
- GHashTable *new_settings,
- DBusGMethodInvocation *context,
+ GVariant *new_settings,
+ GDBusMethodInvocation *context,
gboolean save_to_disk)
{
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
@@ -1384,37 +1433,43 @@ error:
g_clear_object (&tmp);
g_clear_object (&subject);
- dbus_g_method_return_error (context, error);
+ g_dbus_method_invocation_return_gerror (context, error);
g_clear_error (&error);
}
-static void
+static gboolean
impl_settings_connection_update (NMSettingsConnection *self,
- GHashTable *new_settings,
- DBusGMethodInvocation *context)
+ GVariant *new_settings,
+ GDBusMethodInvocation *context)
{
g_assert (new_settings);
impl_settings_connection_update_helper (self, new_settings, context, TRUE);
+
+ return TRUE;
}
-static void
+static gboolean
impl_settings_connection_update_unsaved (NMSettingsConnection *self,
- GHashTable *new_settings,
- DBusGMethodInvocation *context)
+ GVariant *new_settings,
+ GDBusMethodInvocation *context)
{
g_assert (new_settings);
impl_settings_connection_update_helper (self, new_settings, context, FALSE);
+
+ return TRUE;
}
-static void
+static gboolean
impl_settings_connection_save (NMSettingsConnection *self,
- DBusGMethodInvocation *context)
+ GDBusMethodInvocation *context)
{
/* Do nothing if the connection is already synced with disk */
if (NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->unsaved == TRUE)
impl_settings_connection_update_helper (self, NULL, context, TRUE);
else
- dbus_g_method_return (context);
+ g_dbus_method_invocation_return_value (context, NULL);
+
+ return TRUE;
}
static void
@@ -1422,23 +1477,23 @@ con_delete_cb (NMSettingsConnection *connection,
GError *error,
gpointer user_data)
{
- DBusGMethodInvocation *context = user_data;
+ GDBusMethodInvocation *context = user_data;
if (error)
- dbus_g_method_return_error (context, error);
+ g_dbus_method_invocation_return_gerror (context, error);
else
- dbus_g_method_return (context);
+ g_dbus_method_invocation_return_value (context, NULL);
}
static void
delete_auth_cb (NMSettingsConnection *self,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
NMAuthSubject *subject,
GError *error,
gpointer data)
{
if (error) {
- dbus_g_method_return_error (context, error);
+ g_dbus_method_invocation_return_gerror (context, error);
return;
}
@@ -1462,27 +1517,26 @@ get_modify_permission_basic (NMSettingsConnection *connection)
return NM_AUTH_PERMISSION_SETTINGS_MODIFY_SYSTEM;
}
-static void
+static gboolean
impl_settings_connection_delete (NMSettingsConnection *self,
- DBusGMethodInvocation *context)
+ GDBusMethodInvocation *context)
{
NMAuthSubject *subject;
GError *error = NULL;
if (!check_writable (NM_CONNECTION (self), &error)) {
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- return;
+ g_dbus_method_invocation_take_error (context, error);
+ return TRUE;
}
subject = _new_auth_subject (context, &error);
if (subject) {
auth_start (self, context, subject, get_modify_permission_basic (self), delete_auth_cb, NULL);
g_object_unref (subject);
- } else {
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- }
+ } else
+ g_dbus_method_invocation_take_error (context, error);
+
+ return TRUE;
}
/**************************************************************/
@@ -1496,14 +1550,13 @@ dbus_get_agent_secrets_cb (NMSettingsConnection *self,
gpointer user_data)
{
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
- DBusGMethodInvocation *context = user_data;
+ GDBusMethodInvocation *context = user_data;
GVariant *dict;
- GHashTable *hash;
priv->reqs = g_slist_remove (priv->reqs, GUINT_TO_POINTER (call_id));
if (error)
- dbus_g_method_return_error (context, error);
+ g_dbus_method_invocation_return_gerror (context, error);
else {
/* Return secrets from agent and backing storage to the D-Bus caller;
* nm_settings_connection_get_secrets() will have updated itself with
@@ -1511,20 +1564,14 @@ dbus_get_agent_secrets_cb (NMSettingsConnection *self,
* by the time we get here.
*/
dict = nm_connection_to_dbus (NM_CONNECTION (self), NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
- if (dict)
- hash = nm_utils_connection_dict_to_hash (dict);
- else
- hash = g_hash_table_new (NULL, NULL);
- dbus_g_method_return (context, hash);
- g_hash_table_destroy (hash);
- if (dict)
- g_variant_unref (dict);
+ g_dbus_method_invocation_return_value (context,
+ g_variant_new ("(@a{sa{sv}})", dict));
}
}
static void
dbus_secrets_auth_cb (NMSettingsConnection *self,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
NMAuthSubject *subject,
GError *error,
gpointer user_data)
@@ -1550,17 +1597,17 @@ dbus_secrets_auth_cb (NMSettingsConnection *self,
}
if (error || local) {
- dbus_g_method_return_error (context, error ? error : local);
+ g_dbus_method_invocation_return_gerror (context, error ? error : local);
g_clear_error (&local);
}
g_free (setting_name);
}
-static void
+static gboolean
impl_settings_connection_get_secrets (NMSettingsConnection *self,
const gchar *setting_name,
- DBusGMethodInvocation *context)
+ GDBusMethodInvocation *context)
{
NMAuthSubject *subject;
GError *error = NULL;
@@ -1574,10 +1621,10 @@ impl_settings_connection_get_secrets (NMSettingsConnection *self,
dbus_secrets_auth_cb,
g_strdup (setting_name));
g_object_unref (subject);
- } else {
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- }
+ } else
+ g_dbus_method_invocation_take_error (context, error);
+
+ return TRUE;
}
/**************************************************************/
@@ -1990,6 +2037,35 @@ nm_settings_connection_set_nm_generated (NMSettingsConnection *connection)
/**************************************************************/
+void
+nm_settings_connection_export (NMSettingsConnection *self,
+ const char *path)
+{
+ NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
+
+ nm_connection_set_path (NM_CONNECTION (self), path);
+ nm_dbus_manager_register_object (nm_dbus_manager_get (), path,
+ priv->dbus_settings_connection);
+}
+
+/**************************************************************/
+
+static void
+updated (NMSettingsConnection *self)
+{
+ NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
+
+ nmdbus_settings_connection_emit_updated (priv->dbus_settings_connection);
+}
+
+static void
+removed (NMSettingsConnection *self)
+{
+ NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
+
+ nmdbus_settings_connection_emit_removed (priv->dbus_settings_connection);
+}
+
static void
nm_settings_connection_init (NMSettingsConnection *self)
{
@@ -2015,6 +2091,34 @@ nm_settings_connection_init (NMSettingsConnection *self)
}
static void
+constructed (GObject *object)
+{
+ NMSettingsConnection *self = NM_SETTINGS_CONNECTION (object);
+ NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
+
+ priv->dbus_settings_connection = nmdbus_settings_connection_skeleton_new ();
+
+ g_object_bind_property (self, NM_SETTINGS_CONNECTION_UNSAVED,
+ priv->dbus_settings_connection, "unsaved",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
+ g_signal_connect_swapped (priv->dbus_settings_connection, "handle-delete",
+ G_CALLBACK (impl_settings_connection_delete), self);
+ g_signal_connect_swapped (priv->dbus_settings_connection, "handle-get-secrets",
+ G_CALLBACK (impl_settings_connection_get_secrets), self);
+ g_signal_connect_swapped (priv->dbus_settings_connection, "handle-get-settings",
+ G_CALLBACK (impl_settings_connection_get_settings), self);
+ g_signal_connect_swapped (priv->dbus_settings_connection, "handle-save",
+ G_CALLBACK (impl_settings_connection_save), self);
+ g_signal_connect_swapped (priv->dbus_settings_connection, "handle-update",
+ G_CALLBACK (impl_settings_connection_update), self);
+ g_signal_connect_swapped (priv->dbus_settings_connection, "handle-update-unsaved",
+ G_CALLBACK (impl_settings_connection_update_unsaved), self);
+
+ G_OBJECT_CLASS (nm_settings_connection_parent_class)->constructed (object);
+}
+
+static void
dispose (GObject *object)
{
NMSettingsConnection *self = NM_SETTINGS_CONNECTION (object);
@@ -2094,10 +2198,14 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class)
g_type_class_add_private (class, sizeof (NMSettingsConnectionPrivate));
/* Virtual methods */
+ object_class->constructed = constructed;
object_class->dispose = dispose;
object_class->get_property = get_property;
object_class->set_property = set_property;
+ class->updated = updated;
+ class->removed = removed;
+
class->commit_changes = commit_changes;
class->delete = do_delete;
class->supports_secrets = supports_secrets;
@@ -2124,7 +2232,7 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class)
g_signal_new (NM_SETTINGS_CONNECTION_UPDATED,
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_FIRST,
- 0,
+ G_STRUCT_OFFSET (NMSettingsConnectionClass, updated),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@@ -2142,14 +2250,10 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class)
g_signal_new (NM_SETTINGS_CONNECTION_REMOVED,
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_FIRST,
- 0,
+ G_STRUCT_OFFSET (NMSettingsConnectionClass, removed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
-
- nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
- G_TYPE_FROM_CLASS (class),
- &dbus_glib_nm_settings_connection_object_info);
}
static void
diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h
index 3ee62465fd..459ee7d2fb 100644
--- a/src/settings/nm-settings-connection.h
+++ b/src/settings/nm-settings-connection.h
@@ -66,6 +66,10 @@ struct _NMSettingsConnection {
struct _NMSettingsConnectionClass {
GObjectClass parent;
+ /* signals */
+ void (*updated) (NMSettingsConnection *connection);
+ void (*removed) (NMSettingsConnection *connection);
+
/* virtual methods */
void (*commit_changes) (NMSettingsConnection *connection,
NMSettingsConnectionCommitFunc callback,
@@ -81,6 +85,9 @@ struct _NMSettingsConnectionClass {
GType nm_settings_connection_get_type (void);
+void nm_settings_connection_export (NMSettingsConnection *connection,
+ const char *path);
+
void nm_settings_connection_commit_changes (NMSettingsConnection *connection,
NMSettingsConnectionCommitFunc callback,
gpointer user_data);
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index a4339ed492..42a5675392 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -29,8 +29,6 @@
#include <string.h>
#include <gmodule.h>
#include <pwd.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include <nm-dbus-interface.h>
#include <nm-connection.h>
@@ -55,7 +53,6 @@
#include "nm-core-internal.h"
#include "nm-device-ethernet.h"
-#include "nm-dbus-glib-types.h"
#include "nm-settings.h"
#include "nm-settings-connection.h"
#include "nm-settings-error.h"
@@ -71,6 +68,9 @@
#include "nm-config.h"
#include "NetworkManagerUtils.h"
+#include "nm-object.h"
+#include "nmdbus-settings.h"
+
/* LINKER CRACKROCK */
#define EXPORT(sym) void * __export_##sym = &sym;
@@ -89,35 +89,6 @@ static void claim_connection (NMSettings *self,
NMSettingsConnection *connection,
gboolean do_export);
-static gboolean impl_settings_list_connections (NMSettings *self,
- GPtrArray **connections,
- GError **error);
-
-static void impl_settings_get_connection_by_uuid (NMSettings *self,
- const char *uuid,
- DBusGMethodInvocation *context);
-
-static void impl_settings_add_connection (NMSettings *self,
- GHashTable *settings,
- DBusGMethodInvocation *context);
-
-static void impl_settings_add_connection_unsaved (NMSettings *self,
- GHashTable *settings,
- DBusGMethodInvocation *context);
-
-static void impl_settings_load_connections (NMSettings *self,
- char **filenames,
- DBusGMethodInvocation *context);
-
-static void impl_settings_reload_connections (NMSettings *self,
- DBusGMethodInvocation *context);
-
-static void impl_settings_save_hostname (NMSettings *self,
- const char *hostname,
- DBusGMethodInvocation *context);
-
-#include "nm-settings-glue.h"
-
static void unmanaged_specs_changed (NMSystemConfigInterface *config, gpointer user_data);
static void unrecognized_specs_changed (NMSystemConfigInterface *config, gpointer user_data);
@@ -128,8 +99,6 @@ G_DEFINE_TYPE_EXTENDED (NMSettings, nm_settings, G_TYPE_OBJECT, 0,
typedef struct {
- NMDBusManager *dbus_mgr;
-
NMAgentManager *agent_mgr;
NMConfig *config;
@@ -155,7 +124,6 @@ enum {
CONNECTION_VISIBILITY_CHANGED,
AGENT_REGISTERED,
- NEW_CONNECTION, /* exported, not used internally */
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -235,17 +203,23 @@ nm_settings_for_each_connection (NMSettings *self,
static gboolean
impl_settings_list_connections (NMSettings *self,
- GPtrArray **connections,
- GError **error)
+ GDBusMethodInvocation *context)
{
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
+ GPtrArray *connections;
GHashTableIter iter;
gpointer key;
- *connections = g_ptr_array_sized_new (g_hash_table_size (priv->connections) + 1);
+ connections = g_ptr_array_sized_new (g_hash_table_size (priv->connections) + 1);
g_hash_table_iter_init (&iter, priv->connections);
while (g_hash_table_iter_next (&iter, &key, NULL))
- g_ptr_array_add (*connections, g_strdup ((const char *) key));
+ g_ptr_array_add (connections, g_strdup ((const char *) key));
+ g_ptr_array_add (connections, NULL);
+
+ g_dbus_method_invocation_return_value (context,
+ g_variant_new ("(as)", (char **) connections->pdata));
+ g_ptr_array_free (connections, TRUE);
+
return TRUE;
}
@@ -270,10 +244,10 @@ nm_settings_get_connection_by_uuid (NMSettings *self, const char *uuid)
return NULL;
}
-static void
+static gboolean
impl_settings_get_connection_by_uuid (NMSettings *self,
const char *uuid,
- DBusGMethodInvocation *context)
+ GDBusMethodInvocation *context)
{
NMSettingsConnection *connection = NULL;
NMAuthSubject *subject = NULL;
@@ -308,14 +282,16 @@ impl_settings_get_connection_by_uuid (NMSettings *self,
}
g_clear_object (&subject);
- dbus_g_method_return (context, nm_connection_get_path (NM_CONNECTION (connection)));
- return;
+ g_dbus_method_invocation_return_value (context,
+ g_variant_new ("(s)", nm_connection_get_path (NM_CONNECTION (connection))));
+ return TRUE;
error:
g_assert (error);
- dbus_g_method_return_error (context, error);
- g_error_free (error);
+ g_dbus_method_invocation_take_error (context, error);
g_clear_object (&subject);
+
+ return TRUE;
}
static int
@@ -380,51 +356,6 @@ nm_settings_get_connection_by_path (NMSettings *self, const char *path)
return (NMSettingsConnection *) g_hash_table_lookup (priv->connections, path);
}
-static char*
-uscore_to_wincaps (const char *uscore)
-{
- const char *p;
- GString *str;
- gboolean last_was_uscore;
-
- last_was_uscore = TRUE;
-
- str = g_string_new (NULL);
- p = uscore;
- while (p && *p) {
- if (*p == '-' || *p == '_')
- last_was_uscore = TRUE;
- else {
- if (last_was_uscore) {
- g_string_append_c (str, g_ascii_toupper (*p));
- last_was_uscore = FALSE;
- } else
- g_string_append_c (str, *p);
- }
- ++p;
- }
-
- return g_string_free (str, FALSE);
-}
-
-static void
-notify (GObject *object, GParamSpec *pspec)
-{
- GValue *value;
- GHashTable *hash;
-
- value = g_slice_new0 (GValue);
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
-
- g_value_init (value, pspec->value_type);
- g_object_get_property (object, pspec->name, value);
- g_hash_table_insert (hash, uscore_to_wincaps (pspec->name), value);
- g_signal_emit (object, signals[PROPERTIES_CHANGED], 0, hash);
- g_hash_table_destroy (hash);
- g_value_unset (value);
- g_slice_free (GValue, value);
-}
-
const GSList *
nm_settings_get_unmanaged_specs (NMSettings *self)
{
@@ -750,6 +681,9 @@ connection_removed (NMSettingsConnection *connection, gpointer user_data)
(gpointer) nm_connection_get_path (NM_CONNECTION (connection)));
/* Notify D-Bus */
+ nm_object_emit_dbus_signal (NM_OBJECT (self),
+ "ConnectionRemoved",
+ nm_connection_get_path (NM_CONNECTION (connection)));
g_signal_emit (self, signals[CONNECTION_REMOVED], 0, connection);
/* Re-emit for listeners like NMPolicy */
@@ -866,9 +800,7 @@ claim_connection (NMSettings *self,
/* Export the connection over D-Bus */
g_warn_if_fail (nm_connection_get_path (NM_CONNECTION (connection)) == NULL);
path = g_strdup_printf ("%s/%u", NM_DBUS_PATH_SETTINGS, ec_counter++);
- nm_connection_set_path (NM_CONNECTION (connection), path);
- nm_dbus_manager_register_object (priv->dbus_mgr, path, G_OBJECT (connection));
- g_free (path);
+ nm_settings_connection_export (connection, path);
g_hash_table_insert (priv->connections,
(gpointer) nm_connection_get_path (NM_CONNECTION (connection)),
@@ -883,9 +815,10 @@ claim_connection (NMSettings *self,
g_signal_emit_by_name (self, NM_CP_SIGNAL_CONNECTION_ADDED, connection);
g_object_notify (G_OBJECT (self), NM_SETTINGS_CONNECTIONS);
- /* Exported D-Bus signal */
- g_signal_emit (self, signals[NEW_CONNECTION], 0, connection);
+ nm_object_emit_dbus_signal (NM_OBJECT (self), "NewConnection", path);
}
+
+ g_free (path);
}
/**
@@ -1008,7 +941,7 @@ send_agent_owned_secrets (NMSettings *self,
static void
pk_add_cb (NMAuthChain *chain,
GError *chain_error,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
gpointer user_data)
{
NMSettings *self = NM_SETTINGS (user_data);
@@ -1096,11 +1029,11 @@ is_adhoc_wpa (NMConnection *connection)
void
nm_settings_add_connection_dbus (NMSettings *self,
- NMConnection *connection,
- gboolean save_to_disk,
- DBusGMethodInvocation *context,
- NMSettingsAddCallback callback,
- gpointer user_data)
+ NMConnection *connection,
+ gboolean save_to_disk,
+ GDBusMethodInvocation *context,
+ NMSettingsAddCallback callback,
+ gpointer user_data)
{
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
NMSettingConnection *s_con;
@@ -1205,20 +1138,20 @@ static void
impl_settings_add_connection_add_cb (NMSettings *self,
NMSettingsConnection *connection,
GError *error,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
gpointer user_data)
{
if (error)
- dbus_g_method_return_error (context, error);
+ g_dbus_method_invocation_return_gerror (context, error);
else
- dbus_g_method_return (context, nm_connection_get_path (NM_CONNECTION (connection)));
+ g_dbus_method_invocation_return_value (context, g_variant_new ("(s)", nm_connection_get_path (NM_CONNECTION (connection))));
}
static void
impl_settings_add_connection_helper (NMSettings *self,
- GHashTable *settings,
+ GVariant *settings,
gboolean save_to_disk,
- DBusGMethodInvocation *context)
+ GDBusMethodInvocation *context)
{
NMConnection *connection;
GVariant *dict;
@@ -1237,30 +1170,31 @@ impl_settings_add_connection_helper (NMSettings *self,
g_object_unref (connection);
} else {
g_assert (error);
- dbus_g_method_return_error (context, error);
- g_error_free (error);
+ g_dbus_method_invocation_take_error (context, error);
}
}
-static void
+static gboolean
impl_settings_add_connection (NMSettings *self,
- GHashTable *settings,
- DBusGMethodInvocation *context)
+ GVariant *settings,
+ GDBusMethodInvocation *context)
{
impl_settings_add_connection_helper (self, settings, TRUE, context);
+ return TRUE;
}
-static void
+static gboolean
impl_settings_add_connection_unsaved (NMSettings *self,
- GHashTable *settings,
- DBusGMethodInvocation *context)
+ GVariant *settings,
+ GDBusMethodInvocation *context)
{
impl_settings_add_connection_helper (self, settings, FALSE, context);
+ return TRUE;
}
static gboolean
ensure_root (NMDBusManager *dbus_mgr,
- DBusGMethodInvocation *context)
+ GDBusMethodInvocation *context)
{
gulong caller_uid;
GError *error = NULL;
@@ -1269,34 +1203,32 @@ ensure_root (NMDBusManager *dbus_mgr,
error = g_error_new_literal (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED,
"Unable to determine request UID.");
- dbus_g_method_return_error (context, error);
- g_error_free (error);
+ g_dbus_method_invocation_take_error (context, error);
return FALSE;
}
if (caller_uid != 0) {
error = g_error_new_literal (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED,
"Permission denied");
- dbus_g_method_return_error (context, error);
- g_error_free (error);
+ g_dbus_method_invocation_take_error (context, error);
return FALSE;
}
return TRUE;
}
-static void
+static gboolean
impl_settings_load_connections (NMSettings *self,
char **filenames,
- DBusGMethodInvocation *context)
+ GDBusMethodInvocation *context)
{
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
GPtrArray *failures;
GSList *iter;
int i;
- if (!ensure_root (priv->dbus_mgr, context))
- return;
+ if (!ensure_root (nm_dbus_manager_get (), context))
+ return TRUE;
failures = g_ptr_array_new ();
@@ -1316,19 +1248,24 @@ impl_settings_load_connections (NMSettings *self,
}
g_ptr_array_add (failures, NULL);
- dbus_g_method_return (context, failures->len == 1, failures->pdata);
+ g_dbus_method_invocation_return_value (context,
+ g_variant_new ("(bas)",
+ failures->len == 1,
+ (char **) failures->pdata));
g_ptr_array_unref (failures);
+
+ return TRUE;
}
-static void
+static gboolean
impl_settings_reload_connections (NMSettings *self,
- DBusGMethodInvocation *context)
+ GDBusMethodInvocation *context)
{
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
GSList *iter;
- if (!ensure_root (priv->dbus_mgr, context))
- return;
+ if (!ensure_root (nm_dbus_manager_get (), context))
+ return TRUE;
for (iter = priv->plugins; iter; iter = g_slist_next (iter)) {
NMSystemConfigInterface *plugin = NM_SYSTEM_CONFIG_INTERFACE (iter->data);
@@ -1336,13 +1273,14 @@ impl_settings_reload_connections (NMSettings *self,
nm_system_config_interface_reload_connections (plugin);
}
- dbus_g_method_return (context, TRUE);
+ g_dbus_method_invocation_return_value (context, g_variant_new ("(b)", TRUE));
+ return TRUE;
}
static void
pk_hostname_cb (NMAuthChain *chain,
GError *chain_error,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
gpointer user_data)
{
NMSettings *self = NM_SETTINGS (user_data);
@@ -1388,11 +1326,10 @@ pk_hostname_cb (NMAuthChain *chain,
}
if (error)
- dbus_g_method_return_error (context, error);
+ g_dbus_method_invocation_take_error (context, error);
else
- dbus_g_method_return (context);
+ g_dbus_method_invocation_return_value (context, NULL);
- g_clear_error (&error);
nm_auth_chain_unref (chain);
}
@@ -1423,10 +1360,10 @@ validate_hostname (const char *hostname)
return (p - hostname <= HOST_NAME_MAX);
}
-static void
+static gboolean
impl_settings_save_hostname (NMSettings *self,
const char *hostname,
- DBusGMethodInvocation *context)
+ GDBusMethodInvocation *context)
{
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
NMAuthChain *chain;
@@ -1462,8 +1399,9 @@ impl_settings_save_hostname (NMSettings *self,
done:
if (error)
- dbus_g_method_return_error (context, error);
- g_clear_error (&error);
+ g_dbus_method_invocation_take_error (context, error);
+
+ return TRUE;
}
static gboolean
@@ -1761,7 +1699,6 @@ nm_settings_new (GError **error)
priv = NM_SETTINGS_GET_PRIVATE (self);
priv->config = nm_config_get ();
- priv->dbus_mgr = nm_dbus_manager_get ();
/* Load the plugins; fail if a plugin is not found. */
if (!load_plugins (self, nm_config_get_plugins (priv->config), error)) {
@@ -1771,7 +1708,7 @@ nm_settings_new (GError **error)
load_connections (self);
- nm_dbus_manager_register_object (priv->dbus_mgr, NM_DBUS_PATH_SETTINGS, self);
+ nm_object_export (NM_OBJECT (self), NM_DBUS_PATH_SETTINGS);
return self;
}
@@ -1810,8 +1747,6 @@ dispose (GObject *object)
g_slist_free_full (priv->auths, (GDestroyNotify) nm_auth_chain_unref);
priv->auths = NULL;
- priv->dbus_mgr = NULL;
-
g_object_unref (priv->agent_mgr);
G_OBJECT_CLASS (nm_settings_parent_class)->dispose (object);
@@ -1841,17 +1776,18 @@ get_property (GObject *object, guint prop_id,
NMSettings *self = NM_SETTINGS (object);
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
const GSList *specs, *iter;
- GSList *copy = NULL;
GHashTableIter citer;
GPtrArray *array;
const char *path;
switch (prop_id) {
case PROP_UNMANAGED_SPECS:
+ array = g_ptr_array_new ();
specs = nm_settings_get_unmanaged_specs (self);
for (iter = specs; iter; iter = g_slist_next (iter))
- copy = g_slist_append (copy, g_strdup (iter->data));
- g_value_take_boxed (value, copy);
+ g_ptr_array_add (array, g_strdup (iter->data));
+ g_ptr_array_add (array, NULL);
+ g_value_take_boxed (value, (char **) g_ptr_array_free (array, FALSE));
break;
case PROP_HOSTNAME:
g_value_take_string (value, nm_settings_get_hostname (self));
@@ -1864,11 +1800,12 @@ get_property (GObject *object, guint prop_id,
g_value_set_boolean (value, !!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS));
break;
case PROP_CONNECTIONS:
- array = g_ptr_array_sized_new (g_hash_table_size (priv->connections));
+ array = g_ptr_array_sized_new (g_hash_table_size (priv->connections) + 1);
g_hash_table_iter_init (&citer, priv->connections);
while (g_hash_table_iter_next (&citer, (gpointer) &path, NULL))
g_ptr_array_add (array, g_strdup (path));
- g_value_take_boxed (value, array);
+ g_ptr_array_add (array, NULL);
+ g_value_take_boxed (value, (char **) g_ptr_array_free (array, FALSE));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1884,7 +1821,6 @@ nm_settings_class_init (NMSettingsClass *class)
g_type_class_add_private (class, sizeof (NMSettingsPrivate));
/* virtual methods */
- object_class->notify = notify;
object_class->get_property = get_property;
object_class->dispose = dispose;
object_class->finalize = finalize;
@@ -1894,7 +1830,7 @@ nm_settings_class_init (NMSettingsClass *class)
g_object_class_install_property
(object_class, PROP_UNMANAGED_SPECS,
g_param_spec_boxed (NM_SETTINGS_UNMANAGED_SPECS, "", "",
- DBUS_TYPE_G_LIST_OF_STRING,
+ G_TYPE_STRV,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
@@ -1915,19 +1851,11 @@ nm_settings_class_init (NMSettingsClass *class)
g_object_class_install_property
(object_class, PROP_CONNECTIONS,
g_param_spec_boxed (NM_SETTINGS_CONNECTIONS, "", "",
- DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
+ G_TYPE_STRV,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/* signals */
- signals[PROPERTIES_CHANGED] =
- g_signal_new ("properties-changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMSettingsClass, properties_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_VARIANT);
signals[CONNECTION_ADDED] =
g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_ADDED,
G_OBJECT_CLASS_TYPE (object_class),
@@ -1983,38 +1911,40 @@ nm_settings_class_init (NMSettingsClass *class)
G_TYPE_NONE, 1, G_TYPE_OBJECT);
- signals[NEW_CONNECTION] =
- g_signal_new ("new-connection",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
+ nm_object_class_add_interface (NM_OBJECT_CLASS (class),
+ NMDBUS_TYPE_SETTINGS,
+ "AddConnection", impl_settings_add_connection,
+ "AddConnectionUnsaved", impl_settings_add_connection_unsaved,
+ "GetConnectionByUuid", impl_settings_get_connection_by_uuid,
+ "ListConnections", impl_settings_list_connections,
+ "LoadConnections", impl_settings_load_connections,
+ "ReloadConnections", impl_settings_reload_connections,
+ "SaveHostname", impl_settings_save_hostname,
+ NULL);
- dbus_g_error_domain_register (NM_SETTINGS_ERROR,
- NM_DBUS_INTERFACE_SETTINGS,
- NM_TYPE_SETTINGS_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTINGS_ERROR,
+ NM_DBUS_INTERFACE_SETTINGS,
+ NM_TYPE_SETTINGS_ERROR);
/* And register all the settings errors with D-Bus */
- dbus_g_error_domain_register (NM_CONNECTION_ERROR, NULL, NM_TYPE_CONNECTION_ERROR);
- dbus_g_error_domain_register (NM_SETTING_802_1X_ERROR, NULL, NM_TYPE_SETTING_802_1X_ERROR);
- dbus_g_error_domain_register (NM_SETTING_BLUETOOTH_ERROR, NULL, NM_TYPE_SETTING_BLUETOOTH_ERROR);
- dbus_g_error_domain_register (NM_SETTING_CDMA_ERROR, NULL, NM_TYPE_SETTING_CDMA_ERROR);
- dbus_g_error_domain_register (NM_SETTING_CONNECTION_ERROR, NULL, NM_TYPE_SETTING_CONNECTION_ERROR);
- dbus_g_error_domain_register (NM_SETTING_GSM_ERROR, NULL, NM_TYPE_SETTING_GSM_ERROR);
- dbus_g_error_domain_register (NM_SETTING_IP4_CONFIG_ERROR, NULL, NM_TYPE_SETTING_IP4_CONFIG_ERROR);
- dbus_g_error_domain_register (NM_SETTING_IP6_CONFIG_ERROR, NULL, NM_TYPE_SETTING_IP6_CONFIG_ERROR);
- dbus_g_error_domain_register (NM_SETTING_OLPC_MESH_ERROR, NULL, NM_TYPE_SETTING_OLPC_MESH_ERROR);
- dbus_g_error_domain_register (NM_SETTING_PPP_ERROR, NULL, NM_TYPE_SETTING_PPP_ERROR);
- dbus_g_error_domain_register (NM_SETTING_PPPOE_ERROR, NULL, NM_TYPE_SETTING_PPPOE_ERROR);
- dbus_g_error_domain_register (NM_SETTING_SERIAL_ERROR, NULL, NM_TYPE_SETTING_SERIAL_ERROR);
- dbus_g_error_domain_register (NM_SETTING_ADSL_ERROR, NULL, NM_TYPE_SETTING_ADSL_ERROR);
- dbus_g_error_domain_register (NM_SETTING_VPN_ERROR, NULL, NM_TYPE_SETTING_VPN_ERROR);
- dbus_g_error_domain_register (NM_SETTING_WIRED_ERROR, NULL, NM_TYPE_SETTING_WIRED_ERROR);
- dbus_g_error_domain_register (NM_SETTING_WIRELESS_SECURITY_ERROR, NULL, NM_TYPE_SETTING_WIRELESS_SECURITY_ERROR);
- dbus_g_error_domain_register (NM_SETTING_WIRELESS_ERROR, NULL, NM_TYPE_SETTING_WIRELESS_ERROR);
- dbus_g_error_domain_register (NM_SETTING_ERROR, NULL, NM_TYPE_SETTING_ERROR);
-
- dbus_g_object_type_install_info (NM_TYPE_SETTINGS, &dbus_glib_nm_settings_object_info);
-
+ // FIXME
+ _nm_dbus_register_error_domain (NM_CONNECTION_ERROR, NULL, NM_TYPE_CONNECTION_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_802_1X_ERROR, NULL, NM_TYPE_SETTING_802_1X_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_BLUETOOTH_ERROR, NULL, NM_TYPE_SETTING_BLUETOOTH_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_CDMA_ERROR, NULL, NM_TYPE_SETTING_CDMA_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_CONNECTION_ERROR, NULL, NM_TYPE_SETTING_CONNECTION_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_GSM_ERROR, NULL, NM_TYPE_SETTING_GSM_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_IP4_CONFIG_ERROR, NULL, NM_TYPE_SETTING_IP4_CONFIG_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_IP6_CONFIG_ERROR, NULL, NM_TYPE_SETTING_IP6_CONFIG_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_OLPC_MESH_ERROR, NULL, NM_TYPE_SETTING_OLPC_MESH_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_PPP_ERROR, NULL, NM_TYPE_SETTING_PPP_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_PPPOE_ERROR, NULL, NM_TYPE_SETTING_PPPOE_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_SERIAL_ERROR, NULL, NM_TYPE_SETTING_SERIAL_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_ADSL_ERROR, NULL, NM_TYPE_SETTING_ADSL_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_VPN_ERROR, NULL, NM_TYPE_SETTING_VPN_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_WIRED_ERROR, NULL, NM_TYPE_SETTING_WIRED_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_WIRELESS_SECURITY_ERROR, NULL, NM_TYPE_SETTING_WIRELESS_SECURITY_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_WIRELESS_ERROR, NULL, NM_TYPE_SETTING_WIRELESS_ERROR);
+ _nm_dbus_register_error_domain (NM_SETTING_ERROR, NULL, NM_TYPE_SETTING_ERROR);
}
diff --git a/src/settings/nm-settings.h b/src/settings/nm-settings.h
index 520c4ec34c..9e444fb539 100644
--- a/src/settings/nm-settings.h
+++ b/src/settings/nm-settings.h
@@ -29,6 +29,7 @@
#include <nm-connection.h>
#include "nm-types.h"
+#include "nm-object.h"
#define NM_TYPE_SETTINGS (nm_settings_get_type ())
#define NM_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS, NMSettings))
@@ -50,11 +51,11 @@
#define NM_SETTINGS_SIGNAL_AGENT_REGISTERED "agent-registered"
struct _NMSettings {
- GObject parent_instance;
+ NMObject parent_instance;
};
typedef struct {
- GObjectClass parent_class;
+ NMObjectClass parent_class;
/* Signals */
void (*properties_changed) (NMSettings *self, GHashTable *properties);
@@ -85,13 +86,13 @@ void nm_settings_for_each_connection (NMSettings *settings,
typedef void (*NMSettingsAddCallback) (NMSettings *settings,
NMSettingsConnection *connection,
GError *error,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
gpointer user_data);
void nm_settings_add_connection_dbus (NMSettings *self,
NMConnection *connection,
gboolean save_to_disk,
- DBusGMethodInvocation *context,
+ GDBusMethodInvocation *context,
NMSettingsAddCallback callback,
gpointer user_data);
diff --git a/src/settings/plugins/example/Makefile.am b/src/settings/plugins/example/Makefile.am
index 8fc4aa92b1..4b2048e0de 100644
--- a/src/settings/plugins/example/Makefile.am
+++ b/src/settings/plugins/example/Makefile.am
@@ -8,7 +8,6 @@ AM_CPPFLAGS = \
-DNETWORKMANAGER_COMPILATION \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
$(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
-DNMCONFDIR=\"$(nmconfdir)\"
# 'noinst' here because this is an example plugin we don't want to install
diff --git a/src/settings/plugins/example/nm-example-connection.c b/src/settings/plugins/example/nm-example-connection.c
index c634388e9f..f70e309baf 100644
--- a/src/settings/plugins/example/nm-example-connection.c
+++ b/src/settings/plugins/example/nm-example-connection.c
@@ -25,7 +25,6 @@
#include <nm-utils.h>
#include "nm-system-config-interface.h"
-#include "nm-dbus-glib-types.h"
#include "nm-example-connection.h"
#include "common.h"
diff --git a/src/settings/plugins/ifcfg-rh/Makefile.am b/src/settings/plugins/ifcfg-rh/Makefile.am
index 10064812d0..644fb88d14 100644
--- a/src/settings/plugins/ifcfg-rh/Makefile.am
+++ b/src/settings/plugins/ifcfg-rh/Makefile.am
@@ -34,7 +34,6 @@ AM_CPPFLAGS = \
-DNETWORKMANAGER_COMPILATION \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
$(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
$(NSS_CFLAGS) \
-DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c
index f4a25effce..9bae58b50c 100644
--- a/src/settings/plugins/ifcfg-rh/plugin.c
+++ b/src/settings/plugins/ifcfg-rh/plugin.c
@@ -33,10 +33,6 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
#if HAVE_SELINUX
#include <selinux/selinux.h>
#endif
@@ -44,13 +40,13 @@
#include <nm-setting-connection.h>
#include "common.h"
-#include "nm-dbus-glib-types.h"
#include "plugin.h"
#include "nm-system-config-interface.h"
#include "nm-settings-error.h"
#include "nm-config.h"
#include "nm-logging.h"
#include "NetworkManagerUtils.h"
+#include "nm-dbus-utils.h"
#include "nm-ifcfg-connection.h"
#include "nm-inotify-helper.h"
@@ -68,7 +64,6 @@ static gboolean impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
const char **out_path,
GError **error);
-#include "nm-ifcfg-rh-glue.h"
static void connection_new_or_changed (SCPluginIfcfg *plugin,
const char *path,
@@ -97,7 +92,7 @@ typedef struct {
GFileMonitor *ifcfg_monitor;
guint ifcfg_monitor_id;
- DBusGConnection *bus;
+ GDBusConnection *bus;
} SCPluginIfcfgPrivate;
@@ -857,29 +852,18 @@ sc_plugin_ifcfg_init (SCPluginIfcfg *plugin)
priv->hostname = plugin_get_hostname (plugin);
- priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ priv->bus = g_bus_bus_get_sync (G_BUS_SYSTEM, NULL, &error);
if (!priv->bus) {
nm_log_warn (LOGD_SETTINGS, "Couldn't connect to D-Bus: %s", error->message);
g_clear_error (&error);
} else {
- DBusConnection *tmp;
- DBusGProxy *proxy;
int result;
- tmp = dbus_g_connection_get_connection (priv->bus);
- dbus_connection_set_exit_on_disconnect (tmp, FALSE);
-
- proxy = dbus_g_proxy_new_for_name (priv->bus,
- "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus");
-
- if (!dbus_g_proxy_call (proxy, "RequestName", &error,
- G_TYPE_STRING, DBUS_SERVICE_NAME,
- G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE,
- G_TYPE_INVALID,
- G_TYPE_UINT, &result,
- G_TYPE_INVALID)) {
+ result = nm_dbus_request_name (priv->bus,
+ DBUS_SERVICE_NAME,
+ DBUS_NAME_FLAG_DO_NOT_QUEUE,
+ NULL, &error);
+ if (!result) {
nm_log_warn (LOGD_SETTINGS, "Couldn't acquire D-Bus service: %s", error->message);
g_clear_error (&error);
} else if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
@@ -888,12 +872,8 @@ sc_plugin_ifcfg_init (SCPluginIfcfg *plugin)
success = TRUE;
}
- if (!success) {
- if (priv->bus) {
- dbus_g_connection_unref (priv->bus);
- priv->bus = NULL;
- }
- }
+ if (!success)
+ g_clear_object (&priv->bus);
}
static void
@@ -903,10 +883,7 @@ dispose (GObject *object)
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
NMInotifyHelper *ih;
- if (priv->bus) {
- dbus_g_connection_unref (priv->bus);
- priv->bus = NULL;
- }
+ g_clear_object (&priv->bus);
if (priv->ih_event_id) {
ih = nm_inotify_helper_get ();
diff --git a/src/settings/plugins/keyfile/Makefile.am b/src/settings/plugins/keyfile/Makefile.am
index bf89b06796..248f221639 100644
--- a/src/settings/plugins/keyfile/Makefile.am
+++ b/src/settings/plugins/keyfile/Makefile.am
@@ -12,7 +12,6 @@ AM_CPPFLAGS = \
-DNETWORKMANAGER_COMPILATION \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
$(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
-DNMCONFDIR=\"$(nmconfdir)\"
noinst_LTLIBRARIES = \
diff --git a/src/settings/plugins/keyfile/nm-keyfile-connection.c b/src/settings/plugins/keyfile/nm-keyfile-connection.c
index c078b6de09..cd474c239e 100644
--- a/src/settings/plugins/keyfile/nm-keyfile-connection.c
+++ b/src/settings/plugins/keyfile/nm-keyfile-connection.c
@@ -26,7 +26,6 @@
#include <nm-utils.h>
#include "nm-system-config-interface.h"
-#include "nm-dbus-glib-types.h"
#include "nm-keyfile-connection.h"
#include "reader.h"
#include "writer.h"
diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c
index 15410bbf6d..a0c966db9d 100644
--- a/src/settings/plugins/keyfile/reader.c
+++ b/src/settings/plugins/keyfile/reader.c
@@ -37,7 +37,6 @@
#include <arpa/inet.h>
#include <string.h>
-#include "nm-dbus-glib-types.h"
#include "nm-glib-compat.h"
#include "nm-system-config-interface.h"
#include "nm-logging.h"
diff --git a/src/settings/plugins/keyfile/tests/Makefile.am b/src/settings/plugins/keyfile/tests/Makefile.am
index 1cd6ab91cd..2612a1d3cc 100644
--- a/src/settings/plugins/keyfile/tests/Makefile.am
+++ b/src/settings/plugins/keyfile/tests/Makefile.am
@@ -12,7 +12,6 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/settings \
-I$(srcdir)/../ \
$(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
-DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \
-DNETWORKMANAGER_COMPILATION \
@@ -32,7 +31,6 @@ test_keyfile_SOURCES = \
test_keyfile_LDADD = \
$(top_builddir)/src/libNetworkManager.la \
- $(DBUS_LIBS) \
$(CODE_COVERAGE_LDFLAGS)
TESTS = test-keyfile
diff --git a/src/settings/plugins/keyfile/writer.c b/src/settings/plugins/keyfile/writer.c
index ae8f0a912b..d4765a7431 100644
--- a/src/settings/plugins/keyfile/writer.c
+++ b/src/settings/plugins/keyfile/writer.c
@@ -26,7 +26,6 @@
#include <stdio.h>
#include <errno.h>
-#include <dbus/dbus-glib.h>
#include <nm-setting.h>
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
@@ -41,7 +40,6 @@
#include <string.h>
#include <arpa/inet.h>
-#include "nm-dbus-glib-types.h"
#include "nm-glib-compat.h"
#include "nm-logging.h"
#include "writer.h"
@@ -456,19 +454,22 @@ password_raw_writer (GKeyFile *file,
const GValue *value)
{
const char *setting_name = nm_setting_get_name (setting);
- GByteArray *array;
+ GBytes *bytes;
+ const guint8 *data;
+ gsize length;
int i, *tmp_array;
- g_return_if_fail (G_VALUE_HOLDS (value, DBUS_TYPE_G_UCHAR_ARRAY));
+ g_return_if_fail (G_VALUE_HOLDS (value, G_TYPE_BYTES));
- array = (GByteArray *) g_value_get_boxed (value);
- if (!array || !array->len)
+ bytes = g_value_get_boxed (value);
+ if (!bytes || !g_bytes_get_size (bytes))
return;
- tmp_array = g_new (gint, array->len);
- for (i = 0; i < array->len; i++)
- tmp_array[i] = (int) array->data[i];
- nm_keyfile_plugin_kf_set_integer_list (file, setting_name, key, tmp_array, array->len);
+ data = g_bytes_get_data (bytes, &length);
+ tmp_array = g_new (gint, length);
+ for (i = 0; i < length; i++)
+ tmp_array[i] = (int) data[i];
+ nm_keyfile_plugin_kf_set_integer_list (file, setting_name, key, tmp_array, length);
g_free (tmp_array);
}