diff options
author | Dan Winship <danw@gnome.org> | 2014-08-13 14:34:29 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-08-16 10:17:53 -0400 |
commit | e1ba13a426bf6fc34043822d772384559b0831cb (patch) | |
tree | a70fc1d7815f244e9b17388a17711df155ed9bda /libnm | |
parent | 5ed054aca9d30c13a7c47bd51cb475d857443b44 (diff) | |
download | NetworkManager-e1ba13a426bf6fc34043822d772384559b0831cb.tar.gz |
libnm-core, libnm, core: make NMConnection an interface
The fact that NMRemoteConnection has to be an NMConnection and
therefore can't be an NMObject means that it needs to reimplement bits
of NMObject functionality (and likewise NMObject needs some special
magic to deal with it). Likewise, we will need a daemon-side
equivalent of NMObject as part of the gdbus port, and we would want
NMSettingsConnection to be able to inherit from this as well.
Solve this problem by making NMConnection into an interface, and
having NMRemoteConnection and NMSettingsConnection implement it. (We
use some hacks to keep the GHashTable of NMSettings objects inside
nm-connection.c rather than having to be implemented by the
implementations.)
Since NMConnection is no longer an instantiable type, this adds
NMSimpleConnection to replace the various non-D-Bus-based uses of
NMConnection throughout the code. nm_connection_new() becomes
nm_simple_connection_new(), nm_connection_new_from_hash() becomes
nm_simple_connection_new_from_hash(), and nm_connection_duplicate()
becomes nm_simple_connection_new_clone().
Diffstat (limited to 'libnm')
-rw-r--r-- | libnm/NetworkManager.h | 1 | ||||
-rw-r--r-- | libnm/libnm.ver | 7 | ||||
-rw-r--r-- | libnm/nm-remote-connection.c | 30 | ||||
-rw-r--r-- | libnm/nm-remote-connection.h | 5 | ||||
-rw-r--r-- | libnm/nm-remote-settings.c | 2 | ||||
-rw-r--r-- | libnm/nm-secret-agent.c | 3 | ||||
-rw-r--r-- | libnm/nm-vpn-plugin.c | 7 | ||||
-rw-r--r-- | libnm/tests/test-nm-client.c | 6 | ||||
-rw-r--r-- | libnm/tests/test-remote-settings-client.c | 6 |
9 files changed, 45 insertions, 22 deletions
diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h index 08b4f4cc9e..f473fea1cb 100644 --- a/libnm/NetworkManager.h +++ b/libnm/NetworkManager.h @@ -79,6 +79,7 @@ #include <nm-setting-wireless-security.h> #include <nm-setting-wireless.h> #include <nm-setting.h> +#include <nm-simple-connection.h> #include <nm-types.h> #include <nm-utils.h> #include <nm-version.h> diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 778ae0c48c..e994ed974a 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -78,7 +78,6 @@ global: nm_connection_compare; nm_connection_diff; nm_connection_dump; - nm_connection_duplicate; nm_connection_error_get_type; nm_connection_error_quark; nm_connection_for_each_setting_value; @@ -120,8 +119,6 @@ global: nm_connection_get_virtual_iface_name; nm_connection_is_type; nm_connection_need_secrets; - nm_connection_new; - nm_connection_new_from_hash; nm_connection_normalize; nm_connection_remove_setting; nm_connection_replace_settings; @@ -867,6 +864,10 @@ global: nm_setting_wireless_security_remove_proto; nm_setting_wireless_security_remove_proto_by_value; nm_setting_wireless_security_set_wep_key; + nm_simple_connection_get_type; + nm_simple_connection_new; + nm_simple_connection_new_clone; + nm_simple_connection_new_from_hash; nm_ssid_get_type; nm_state_get_type; nm_string_array_get_type; diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c index d188ed6d0a..e7433ad579 100644 --- a/libnm/nm-remote-connection.c +++ b/libnm/nm-remote-connection.c @@ -33,10 +33,12 @@ #include "nm-glib-compat.h" #include "nm-dbus-helpers-private.h" +static void nm_remote_connection_connection_iface_init (NMConnectionInterface *iface); static void nm_remote_connection_initable_iface_init (GInitableIface *iface); static void nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface); -G_DEFINE_TYPE_WITH_CODE (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNECTION, +G_DEFINE_TYPE_WITH_CODE (NMRemoteConnection, nm_remote_connection, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_remote_connection_connection_iface_init); G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_remote_connection_initable_iface_init); G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_remote_connection_async_initable_iface_init); ) @@ -44,6 +46,7 @@ G_DEFINE_TYPE_WITH_CODE (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNE enum { PROP_0, PROP_DBUS_CONNECTION, + PROP_PATH, PROP_UNSAVED, PROP_VISIBLE, @@ -689,6 +692,9 @@ get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { switch (prop_id) { + case PROP_PATH: + g_value_set_string (value, nm_connection_get_path (NM_CONNECTION (object))); + break; case PROP_UNSAVED: g_value_set_boolean (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->unsaved); break; @@ -712,6 +718,10 @@ set_property (GObject *object, guint prop_id, /* Construct only */ priv->bus = g_value_dup_boxed (value); break; + case PROP_PATH: + /* Construct only */ + nm_connection_set_path (NM_CONNECTION (object), g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -767,6 +777,19 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class) G_PARAM_STATIC_STRINGS)); /** + * NMRemoteConnection:path: + * + * The D-Bus path of the connection that the #NMRemoteConnection represents. + */ + g_object_class_install_property + (object_class, PROP_PATH, + g_param_spec_string (NM_REMOTE_CONNECTION_PATH, "", "", + NULL, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + + /** * NMRemoteConnection:unsaved: * * %TRUE if the remote connection contains changes that have not been saved @@ -799,6 +822,11 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class) } static void +nm_remote_connection_connection_iface_init (NMConnectionInterface *iface) +{ +} + +static void nm_remote_connection_initable_iface_init (GInitableIface *iface) { iface->init = init_sync; diff --git a/libnm/nm-remote-connection.h b/libnm/nm-remote-connection.h index 65c154605e..01db85c363 100644 --- a/libnm/nm-remote-connection.h +++ b/libnm/nm-remote-connection.h @@ -56,15 +56,16 @@ GQuark nm_remote_connection_error_quark (void); /* Properties */ #define NM_REMOTE_CONNECTION_DBUS_CONNECTION "dbus-connection" +#define NM_REMOTE_CONNECTION_PATH "path" #define NM_REMOTE_CONNECTION_UNSAVED "unsaved" #define NM_REMOTE_CONNECTION_VISIBLE "visible" typedef struct { - NMConnection parent; + GObject parent; } NMRemoteConnection; typedef struct { - NMConnectionClass parent_class; + GObjectClass parent_class; /*< private >*/ gpointer padding[8]; diff --git a/libnm/nm-remote-settings.c b/libnm/nm-remote-settings.c index def901b658..9fbc13c76d 100644 --- a/libnm/nm-remote-settings.c +++ b/libnm/nm-remote-settings.c @@ -81,7 +81,7 @@ * char *uuid; * gboolean success; * - * connection = nm_connection_new (); + * connection = nm_simple_connection_new (); * * /* Build up the 'connection' setting */ * s_con = (NMSettingConnection *) nm_setting_connection_new (); diff --git a/libnm/nm-secret-agent.c b/libnm/nm-secret-agent.c index 705c780121..384c5e69e6 100644 --- a/libnm/nm-secret-agent.c +++ b/libnm/nm-secret-agent.c @@ -27,6 +27,7 @@ #include "nm-secret-agent.h" #include "nm-enum-types.h" #include "nm-dbus-helpers-private.h" +#include "nm-simple-connection.h" static void impl_secret_agent_get_secrets (NMSecretAgent *self, GHashTable *connection_hash, @@ -329,7 +330,7 @@ verify_request (NMSecretAgent *self, /* Make sure the given connection is valid */ g_assert (out_connection); - connection = nm_connection_new_from_hash (connection_hash, &local); + connection = nm_simple_connection_new_from_hash (connection_hash, &local); if (connection) { nm_connection_set_path (connection, connection_path); *out_connection = connection; diff --git a/libnm/nm-vpn-plugin.c b/libnm/nm-vpn-plugin.c index cff632f9c5..d6b4633c3d 100644 --- a/libnm/nm-vpn-plugin.c +++ b/libnm/nm-vpn-plugin.c @@ -28,7 +28,6 @@ #include "nm-vpn-plugin.h" #include "nm-vpn-enum-types.h" #include "nm-utils.h" -#include "nm-connection.h" #include "nm-dbus-glib-types.h" static gboolean impl_vpn_plugin_connect (NMVpnPlugin *plugin, @@ -452,7 +451,7 @@ _connect_generic (NMVpnPlugin *plugin, return FALSE; } - connection = nm_connection_new_from_hash (properties, &local); + connection = nm_simple_connection_new_from_hash (properties, &local); if (!connection) { g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, "Invalid connection: (%d) %s", @@ -526,7 +525,7 @@ impl_vpn_plugin_need_secrets (NMVpnPlugin *plugin, g_return_val_if_fail (NM_IS_VPN_PLUGIN (plugin), FALSE); g_return_val_if_fail (properties != NULL, FALSE); - connection = nm_connection_new_from_hash (properties, &cnfh_err); + connection = nm_simple_connection_new_from_hash (properties, &cnfh_err); if (!connection) { g_set_error (err, NM_VPN_PLUGIN_ERROR, @@ -581,7 +580,7 @@ impl_vpn_plugin_new_secrets (NMVpnPlugin *plugin, return FALSE; } - connection = nm_connection_new_from_hash (properties, &local); + connection = nm_simple_connection_new_from_hash (properties, &local); if (!connection) { g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, "Invalid connection: (%d) %s", diff --git a/libnm/tests/test-nm-client.c b/libnm/tests/test-nm-client.c index 2a0d6bf1df..5f0bcbffbf 100644 --- a/libnm/tests/test-nm-client.c +++ b/libnm/tests/test-nm-client.c @@ -26,11 +26,7 @@ #include <sys/types.h> #include <signal.h> -#include "nm-dbus-interface.h" -#include "nm-client.h" -#include "nm-device-wifi.h" -#include "nm-device-ethernet.h" -#include "nm-device-wimax.h" +#include <NetworkManager.h> #include "nm-glib-compat.h" #include "common.h" diff --git a/libnm/tests/test-remote-settings-client.c b/libnm/tests/test-remote-settings-client.c index d0ba50428d..52977f8e2f 100644 --- a/libnm/tests/test-remote-settings-client.c +++ b/libnm/tests/test-remote-settings-client.c @@ -26,12 +26,8 @@ #include <sys/types.h> #include <signal.h> -#include <nm-dbus-interface.h> -#include <nm-setting-connection.h> -#include <nm-setting-wired.h> -#include <nm-utils.h> +#include <NetworkManager.h> -#include "nm-remote-settings.h" #include "common.h" #include "nm-test-utils.h" |