summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-08-13 17:43:10 -0400
committerDan Winship <danw@gnome.org>2014-08-16 10:17:53 -0400
commit5ed054aca9d30c13a7c47bd51cb475d857443b44 (patch)
tree77d4897c7faf78eef7805ce79a4603734abb911f
parent4870786a2f37884f1c904e8c4077ed6037dd7e81 (diff)
downloadNetworkManager-5ed054aca9d30c13a7c47bd51cb475d857443b44.tar.gz
libnm: get rid of redundant NMRemoteConnection properties
NMRemoteConnection had two DBusGConnection properties (NMRemoteConnection:bus and NMRemoteConnection:dbus-connection) and two D-Bus path properties (NMConnection:path and NMRemoteConnection:dbus-path). The former of each pair were the traditional names, and the latter were added for compatibility with NMObject. In libnm, we can just drop NMRemoteConnection:bus, and use the NMObject-compatible :dbus-connection name instead. For the path properties, we need to rename either NMConnection:path or NMObject:dbus-path. Since NMObject already has "nm_object_get_path()" rather than "nm_object_get_dbus_path()", and it already mistakenly referred to the property as "NMObject:path" in the gtk-docs, it seemed to make sense to rename that one rather than the NMConnection one. (And then, for consistency, rename "nm_object_get_connection()" to "nm_object_get_dbus_connection()" to also match its property.)
-rw-r--r--libnm/libnm.ver2
-rw-r--r--libnm/nm-client.c2
-rw-r--r--libnm/nm-object.c20
-rw-r--r--libnm/nm-object.h6
-rw-r--r--libnm/nm-remote-connection.c75
-rw-r--r--libnm/nm-remote-connection.h2
-rw-r--r--libnm/nm-remote-settings.c2
-rw-r--r--libnm/tests/test-nm-client.c2
8 files changed, 20 insertions, 91 deletions
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index 40f5081ff6..778ae0c48c 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -341,7 +341,7 @@ global:
nm_object_array_get_type;
nm_object_error_get_type;
nm_object_error_quark;
- nm_object_get_connection;
+ nm_object_get_dbus_connection;
nm_object_get_path;
nm_object_get_type;
nm_remote_connection_commit_changes;
diff --git a/libnm/nm-client.c b/libnm/nm-client.c
index 1ba44f7842..c6133d6c22 100644
--- a/libnm/nm-client.c
+++ b/libnm/nm-client.c
@@ -1660,7 +1660,7 @@ constructor (GType type,
const char *dbus_path;
for (i = 0; i < n_construct_params; i++) {
- if (strcmp (construct_params[i].pspec->name, NM_OBJECT_DBUS_PATH) == 0) {
+ if (strcmp (construct_params[i].pspec->name, NM_OBJECT_PATH) == 0) {
dbus_path = g_value_get_string (construct_params[i].value);
if (dbus_path == NULL) {
g_value_set_static_string (construct_params[i].value, NM_DBUS_PATH);
diff --git a/libnm/nm-object.c b/libnm/nm-object.c
index d0e88994b2..5afca64413 100644
--- a/libnm/nm-object.c
+++ b/libnm/nm-object.c
@@ -83,7 +83,7 @@ typedef struct {
enum {
PROP_0,
PROP_DBUS_CONNECTION,
- PROP_DBUS_PATH,
+ PROP_PATH,
PROP_NM_RUNNING,
LAST_PROP
@@ -357,7 +357,7 @@ set_property (GObject *object, guint prop_id,
/* Construct only */
priv->connection = g_value_dup_boxed (value);
break;
- case PROP_DBUS_PATH:
+ case PROP_PATH:
/* Construct only */
priv->path = g_value_dup_string (value);
break;
@@ -377,7 +377,7 @@ get_property (GObject *object, guint prop_id,
case PROP_DBUS_CONNECTION:
g_value_set_boxed (value, priv->connection);
break;
- case PROP_DBUS_PATH:
+ case PROP_PATH:
g_value_set_string (value, priv->path);
break;
case PROP_NM_RUNNING:
@@ -422,11 +422,11 @@ nm_object_class_init (NMObjectClass *nm_object_class)
/**
* NMObject:path:
*
- * The DBus object path.
+ * The D-Bus object path.
**/
g_object_class_install_property
- (object_class, PROP_DBUS_PATH,
- g_param_spec_string (NM_OBJECT_DBUS_PATH, "", "",
+ (object_class, PROP_PATH,
+ g_param_spec_string (NM_OBJECT_PATH, "", "",
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
@@ -481,7 +481,7 @@ nm_object_async_initable_iface_init (GAsyncInitableIface *iface)
}
/**
- * nm_object_get_connection:
+ * nm_object_get_dbus_connection:
* @object: a #NMObject
*
* Gets the #NMObject's DBusGConnection.
@@ -489,7 +489,7 @@ nm_object_async_initable_iface_init (GAsyncInitableIface *iface)
* Returns: (transfer none): the connection
**/
DBusGConnection *
-nm_object_get_connection (NMObject *object)
+nm_object_get_dbus_connection (NMObject *object)
{
g_return_val_if_fail (NM_IS_OBJECT (object), NULL);
@@ -596,7 +596,7 @@ _nm_object_create (GType type, DBusGConnection *connection, const char *path)
object = g_object_new (type,
NM_OBJECT_DBUS_CONNECTION, connection,
- NM_OBJECT_DBUS_PATH, path,
+ NM_OBJECT_PATH, path,
NULL);
if (NM_IS_OBJECT (object))
_nm_object_cache_add (NM_OBJECT (object));
@@ -678,7 +678,7 @@ async_got_type (GType type, gpointer user_data)
object = g_object_new (type,
NM_OBJECT_DBUS_CONNECTION, async_data->connection,
- NM_OBJECT_DBUS_PATH, async_data->path,
+ NM_OBJECT_PATH, async_data->path,
NULL);
if (NM_IS_OBJECT (object))
_nm_object_cache_add (NM_OBJECT (object));
diff --git a/libnm/nm-object.h b/libnm/nm-object.h
index 6e263d488f..1d93e2a6a0 100644
--- a/libnm/nm-object.h
+++ b/libnm/nm-object.h
@@ -58,7 +58,7 @@ typedef enum {
GQuark nm_object_error_quark (void);
#define NM_OBJECT_DBUS_CONNECTION "dbus-connection"
-#define NM_OBJECT_DBUS_PATH "dbus-path"
+#define NM_OBJECT_PATH "path"
typedef struct {
GObject parent;
@@ -85,8 +85,8 @@ typedef struct {
GType nm_object_get_type (void);
-DBusGConnection *nm_object_get_connection (NMObject *object);
-const char *nm_object_get_path (NMObject *object);
+DBusGConnection *nm_object_get_dbus_connection (NMObject *object);
+const char *nm_object_get_path (NMObject *object);
G_END_DECLS
diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c
index 71dd8c62d0..d188ed6d0a 100644
--- a/libnm/nm-remote-connection.c
+++ b/libnm/nm-remote-connection.c
@@ -33,9 +33,6 @@
#include "nm-glib-compat.h"
#include "nm-dbus-helpers-private.h"
-#define NM_REMOTE_CONNECTION_DBUS_CONNECTION "dbus-connection"
-#define NM_REMOTE_CONNECTION_DBUS_PATH "dbus-path"
-
static void nm_remote_connection_initable_iface_init (GInitableIface *iface);
static void nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface);
@@ -46,9 +43,7 @@ G_DEFINE_TYPE_WITH_CODE (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNE
enum {
PROP_0,
- PROP_BUS,
PROP_DBUS_CONNECTION,
- PROP_DBUS_PATH,
PROP_UNSAVED,
PROP_VISIBLE,
@@ -689,43 +684,6 @@ nm_remote_connection_init (NMRemoteConnection *self)
{
}
-static GObject *
-constructor (GType type, guint n_construct_properties,
- GObjectConstructParam *construct_properties)
-{
- static GParamSpec *nm_connection_path = NULL;
- static GParamSpec *nm_remote_connection_dbus_path = NULL;
- int i, path_index = -1, dbus_path_index = -1;
-
- if (!nm_connection_path) {
- nm_connection_path =
- g_object_class_find_property (g_type_class_peek (NM_TYPE_CONNECTION),
- NM_CONNECTION_PATH);
- nm_remote_connection_dbus_path =
- g_object_class_find_property (g_type_class_peek (NM_TYPE_REMOTE_CONNECTION),
- NM_REMOTE_CONNECTION_DBUS_PATH);
- }
-
- /* Find the two properties */
- for (i = 0; i < n_construct_properties; i++) {
- if (construct_properties[i].pspec == nm_connection_path)
- path_index = i;
- else if (construct_properties[i].pspec == nm_remote_connection_dbus_path)
- dbus_path_index = i;
- }
- g_assert (path_index != -1 && dbus_path_index != -1);
-
- /* If NMRemoteConnection:dbus-path is set, and NMConnection:path
- * is not, then copy the value of the former to the latter.
- */
- if (g_value_get_string (construct_properties[dbus_path_index].value) &&
- !g_value_get_string (construct_properties[path_index].value))
- construct_properties[path_index].value = construct_properties[dbus_path_index].value;
-
- return G_OBJECT_CLASS (nm_remote_connection_parent_class)->
- constructor (type, n_construct_properties, construct_properties);
-}
-
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
@@ -750,21 +708,9 @@ set_property (GObject *object, guint prop_id,
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (object);
switch (prop_id) {
- case PROP_BUS:
case PROP_DBUS_CONNECTION:
/* Construct only */
- /* priv->bus is set from either of two properties so that it (a) remains
- * backwards compatible with the previous "bus" property, and that (b)
- * it can be created just like an NMObject using the "dbus-connection",
- * even though it's not a subclass of NMObject. So don't overwrite the
- * a valid value that the other property set with NULL, if one of the
- * properties isn't specified at construction time.
- */
- if (!priv->bus)
- priv->bus = g_value_dup_boxed (value);
- break;
- case PROP_DBUS_PATH:
- /* Don't need to do anything; see constructor(). */
+ priv->bus = g_value_dup_boxed (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -802,40 +748,23 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class)
g_type_class_add_private (object_class, sizeof (NMRemoteConnectionPrivate));
/* virtual methods */
- object_class->constructor = constructor;
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->dispose = dispose;
/* Properties */
/**
- * NMRemoteConnection:bus:
+ * NMRemoteConnection:dbus-connection:
*
* The #DBusGConnection that the #NMRemoteConnection is connected to.
*/
g_object_class_install_property
- (object_class, PROP_BUS,
- g_param_spec_boxed (NM_REMOTE_CONNECTION_BUS, "", "",
- DBUS_TYPE_G_CONNECTION,
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- /* These are needed so _nm_object_create() can create NMRemoteConnections */
- g_object_class_install_property
(object_class, PROP_DBUS_CONNECTION,
g_param_spec_boxed (NM_REMOTE_CONNECTION_DBUS_CONNECTION, "", "",
DBUS_TYPE_G_CONNECTION,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
- g_object_class_install_property
- (object_class, PROP_DBUS_PATH,
- g_param_spec_string (NM_REMOTE_CONNECTION_DBUS_PATH, "", "",
- NULL,
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
/**
* NMRemoteConnection:unsaved:
diff --git a/libnm/nm-remote-connection.h b/libnm/nm-remote-connection.h
index 58ffe03bc4..65c154605e 100644
--- a/libnm/nm-remote-connection.h
+++ b/libnm/nm-remote-connection.h
@@ -55,7 +55,7 @@ typedef enum {
GQuark nm_remote_connection_error_quark (void);
/* Properties */
-#define NM_REMOTE_CONNECTION_BUS "bus"
+#define NM_REMOTE_CONNECTION_DBUS_CONNECTION "dbus-connection"
#define NM_REMOTE_CONNECTION_UNSAVED "unsaved"
#define NM_REMOTE_CONNECTION_VISIBLE "visible"
diff --git a/libnm/nm-remote-settings.c b/libnm/nm-remote-settings.c
index be512c665d..def901b658 100644
--- a/libnm/nm-remote-settings.c
+++ b/libnm/nm-remote-settings.c
@@ -887,7 +887,7 @@ constructor (GType type,
/* Fill in the right D-Bus path if none was specified */
for (i = 0; i < n_construct_params; i++) {
- if (strcmp (construct_params[i].pspec->name, NM_OBJECT_DBUS_PATH) == 0) {
+ if (strcmp (construct_params[i].pspec->name, NM_OBJECT_PATH) == 0) {
dbus_path = g_value_get_string (construct_params[i].value);
if (dbus_path == NULL) {
g_value_set_static_string (construct_params[i].value, NM_DBUS_PATH_SETTINGS);
diff --git a/libnm/tests/test-nm-client.c b/libnm/tests/test-nm-client.c
index 3f1e95496c..2a0d6bf1df 100644
--- a/libnm/tests/test-nm-client.c
+++ b/libnm/tests/test-nm-client.c
@@ -52,7 +52,7 @@ test_client_new (void)
client = g_object_new (NM_TYPE_CLIENT,
NM_OBJECT_DBUS_CONNECTION, bus,
- NM_OBJECT_DBUS_PATH, NM_DBUS_PATH,
+ NM_OBJECT_PATH, NM_DBUS_PATH,
NULL);
g_assert (client != NULL);