vpn: fix VPN active connection D-Bus API handling (bgo #569294)
Due to limitations in dbus-glib, where one GObject cannot have more than one introspection XML object attached to it, we used to include more than one <interface> in the VPNConnection object introspection XML. This was suboptimal for two reasons: 1) it duplicated the Connection.Active introspection XML which made it harder for clients to use the introspection data in a dynamic fashion, besides looking ugly in the docs 2) not many other programs use this feature of dbus-glib, which means it didn't get a lot of testing, and broke, which sucks for NM. To fix this issue, create a base class for NMVpnConnection that handles the Connection.Active API, and make NMVpnConnection itself handle just the VPN pieces that it layers on top. This makes dbus-glib happy because we aren't using two <interface> blocks in the same introspection XML, and it makes the NM code more robust because we can re-use the existing Connection.Active introspection XML in the NMVpnConnectionBase class.
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
#include <glib.h>
|
||||
#include "nm-active-connection.h"
|
||||
#include "NetworkManager.h"
|
||||
#include "nm-active-connection-glue.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
||||
char *
|
||||
nm_active_connection_get_next_object_path (void)
|
||||
@@ -32,13 +32,6 @@ nm_active_connection_get_next_object_path (void)
|
||||
return g_strdup_printf (NM_DBUS_PATH "/ActiveConnection/%d", counter++);
|
||||
}
|
||||
|
||||
void
|
||||
nm_active_connection_install_type_info (GObjectClass *klass)
|
||||
{
|
||||
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
|
||||
&dbus_glib_nm_active_connection_object_info);
|
||||
}
|
||||
|
||||
void
|
||||
nm_active_connection_scope_to_value (NMConnection *connection, GValue *value)
|
||||
{
|
||||
@@ -60,4 +53,73 @@ nm_active_connection_scope_to_value (NMConnection *connection, GValue *value)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nm_active_connection_install_properties (GObjectClass *object_class,
|
||||
guint prop_service_name,
|
||||
guint prop_connection,
|
||||
guint prop_specific_object,
|
||||
guint prop_devices,
|
||||
guint prop_state,
|
||||
guint prop_default,
|
||||
guint prop_default6,
|
||||
guint prop_vpn)
|
||||
{
|
||||
g_object_class_install_property (object_class, prop_service_name,
|
||||
g_param_spec_string (NM_ACTIVE_CONNECTION_SERVICE_NAME,
|
||||
"Service name",
|
||||
"Service name",
|
||||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class, prop_connection,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_CONNECTION,
|
||||
"Connection",
|
||||
"Connection",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class, prop_specific_object,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT,
|
||||
"Specific object",
|
||||
"Specific object",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class, prop_devices,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DEVICES,
|
||||
"Devices",
|
||||
"Devices",
|
||||
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class, prop_state,
|
||||
g_param_spec_uint (NM_ACTIVE_CONNECTION_STATE,
|
||||
"State",
|
||||
"State",
|
||||
NM_ACTIVE_CONNECTION_STATE_UNKNOWN,
|
||||
NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
|
||||
NM_ACTIVE_CONNECTION_STATE_UNKNOWN,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class, prop_default,
|
||||
g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT,
|
||||
"Default",
|
||||
"Is the default IPv4 active connection",
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class, prop_default6,
|
||||
g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT6,
|
||||
"Default6",
|
||||
"Is the default IPv6 active connection",
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class, prop_vpn,
|
||||
g_param_spec_boolean (NM_ACTIVE_CONNECTION_VPN,
|
||||
"VPN",
|
||||
"Is a VPN connection",
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user