nm-dispatcher: Added new 'connectivity-state' parameter to private D-Bus API

In order to pass the connectivity state to the relevant hooks along with
the event itself, we need to add this parameter for the 'Action' method
of then internal 'org.freedesktop.nm_dispatcher' interface, which will
be sent by the network manager main process to the dispatcher.

https://bugzilla.gnome.org/show_bug.cgi?id=768969
This commit is contained in:
Mario Sanchez Prada 2016-07-20 16:21:12 +01:00 committed by Beniamino Galvani
parent 283562ef18
commit dfd9d85beb
5 changed files with 28 additions and 13 deletions

View file

@ -80,6 +80,7 @@ handle_action (NMDBusDispatcher *dbus_dispatcher,
GVariant *device_ip6_props,
GVariant *device_dhcp4_props,
GVariant *device_dhcp6_props,
const char *connectivity_state,
const char *vpn_ip_iface,
GVariant *vpn_ip4_props,
GVariant *vpn_ip6_props,
@ -668,6 +669,7 @@ handle_action (NMDBusDispatcher *dbus_dispatcher,
GVariant *device_ip6_props,
GVariant *device_dhcp4_props,
GVariant *device_dhcp6_props,
const char *connectivity_state,
const char *vpn_ip_iface,
GVariant *vpn_ip4_props,
GVariant *vpn_ip6_props,

View file

@ -13,6 +13,7 @@
@device_ip6_config: Properties of the device's IPv6 configuration.
@device_dhcp4_config: Properties of the device's DHCPv4 configuration.
@device_dhcp6_config: Properties of the device's DHCPv6 configuration.
@connectivity_state: Current connectivity state: unknown, none, limited, portal or full.
@vpn_ip_iface: VPN interface name.
@vpn_ip4_config: Properties of the VPN's IPv4 configuration.
@vpn_ip6_config: Properties of the VPN's IPv6 configuration.
@ -30,6 +31,7 @@
<arg name="device_ip6_config" type="a{sv}" direction="in"/>
<arg name="device_dhcp4_config" type="a{sv}" direction="in"/>
<arg name="device_dhcp6_config" type="a{sv}" direction="in"/>
<arg name="connectivity_state" type="s" direction="in"/>
<arg name="vpn_ip_iface" type="s" direction="in"/>
<arg name="vpn_ip4_config" type="a{sv}" direction="in"/>
<arg name="vpn_ip6_config" type="a{sv}" direction="in"/>

View file

@ -99,7 +99,7 @@ update_state (NMConnectivity *self, NMConnectivityState state)
g_object_notify (G_OBJECT (self), NM_CONNECTIVITY_STATE);
/* Notify dispatcher scripts of a connectivity state change */
nm_dispatcher_call_connectivity (DISPATCHER_ACTION_CONNECTIVITY_CHANGE);
nm_dispatcher_call_connectivity (DISPATCHER_ACTION_CONNECTIVITY_CHANGE, state);
}
}

View file

@ -28,11 +28,13 @@
#include "nm-dispatcher-api.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-connectivity.h"
#include "nm-device.h"
#include "nm-dhcp4-config.h"
#include "nm-dhcp6-config.h"
#include "nm-ip4-config.h"
#include "nm-ip6-config.h"
#include "nm-manager.h"
#include "nm-settings-connection.h"
#include "nm-platform.h"
#include "nm-core-internal.h"
@ -450,6 +452,7 @@ _dispatcher_call (DispatcherAction action,
NMSettingsConnection *settings_connection,
NMConnection *applied_connection,
NMDevice *device,
NMConnectivityState connectivity_state,
const char *vpn_iface,
NMIP4Config *vpn_ip4_config,
NMIP6Config *vpn_ip6_config,
@ -581,7 +584,7 @@ _dispatcher_call (DispatcherAction action,
GVariantIter *results;
ret = _nm_dbus_proxy_call_sync (dispatcher_proxy, "Action",
g_variant_new ("(s@a{sa{sv}}a{sv}a{sv}a{sv}a{sv}@a{sv}@a{sv}sa{sv}a{sv}b)",
g_variant_new ("(s@a{sa{sv}}a{sv}a{sv}a{sv}a{sv}@a{sv}@a{sv}ssa{sv}a{sv}b)",
action_to_string (action),
connection_dict,
&connection_props,
@ -590,6 +593,7 @@ _dispatcher_call (DispatcherAction action,
&device_ip6_props,
device_dhcp4_props,
device_dhcp6_props,
nm_connectivity_state_to_string (connectivity_state),
vpn_iface ? vpn_iface : "",
&vpn_ip4_props,
&vpn_ip6_props,
@ -616,7 +620,7 @@ _dispatcher_call (DispatcherAction action,
info->callback = callback;
info->user_data = user_data;
g_dbus_proxy_call (dispatcher_proxy, "Action",
g_variant_new ("(s@a{sa{sv}}a{sv}a{sv}a{sv}a{sv}@a{sv}@a{sv}sa{sv}a{sv}b)",
g_variant_new ("(s@a{sa{sv}}a{sv}a{sv}a{sv}a{sv}@a{sv}@a{sv}ssa{sv}a{sv}b)",
action_to_string (action),
connection_dict,
&connection_props,
@ -625,6 +629,7 @@ _dispatcher_call (DispatcherAction action,
&device_ip6_props,
device_dhcp4_props,
device_dhcp6_props,
nm_connectivity_state_to_string (connectivity_state),
vpn_iface ? vpn_iface : "",
&vpn_ip4_props,
&vpn_ip6_props,
@ -674,8 +679,9 @@ nm_dispatcher_call (DispatcherAction action,
gpointer user_data,
guint *out_call_id)
{
return _dispatcher_call (action, FALSE, settings_connection, applied_connection, device, NULL, NULL,
NULL, callback, user_data, out_call_id);
return _dispatcher_call (action, FALSE, settings_connection, applied_connection, device,
NM_CONNECTIVITY_UNKNOWN, NULL, NULL, NULL,
callback, user_data, out_call_id);
}
/**
@ -696,8 +702,8 @@ nm_dispatcher_call_sync (DispatcherAction action,
NMConnection *applied_connection,
NMDevice *device)
{
return _dispatcher_call (action, TRUE, settings_connection, applied_connection, device, NULL, NULL,
NULL, NULL, NULL, NULL);
return _dispatcher_call (action, TRUE, settings_connection, applied_connection, device,
NM_CONNECTIVITY_UNKNOWN, NULL, NULL, NULL, NULL, NULL, NULL);
}
/**
@ -731,8 +737,9 @@ nm_dispatcher_call_vpn (DispatcherAction action,
gpointer user_data,
guint *out_call_id)
{
return _dispatcher_call (action, FALSE, settings_connection, applied_connection, parent_device, vpn_iface,
vpn_ip4_config, vpn_ip6_config, callback, user_data, out_call_id);
return _dispatcher_call (action, FALSE, settings_connection, applied_connection,
parent_device, NM_CONNECTIVITY_UNKNOWN, vpn_iface, vpn_ip4_config,
vpn_ip6_config, callback, user_data, out_call_id);
}
/**
@ -759,22 +766,25 @@ nm_dispatcher_call_vpn_sync (DispatcherAction action,
NMIP4Config *vpn_ip4_config,
NMIP6Config *vpn_ip6_config)
{
return _dispatcher_call (action, TRUE, settings_connection, applied_connection, parent_device, vpn_iface,
return _dispatcher_call (action, TRUE, settings_connection, applied_connection,
parent_device, NM_CONNECTIVITY_UNKNOWN, vpn_iface,
vpn_ip4_config, vpn_ip6_config, NULL, NULL, NULL);
}
/**
* nm_dispatcher_call_connectivity():
* @action: the %DispatcherAction
* @connectivity_state: the #NMConnectivityState value
*
* This method does not block the caller.
*
* Returns: %TRUE if the action was dispatched, %FALSE on failure
*/
gboolean
nm_dispatcher_call_connectivity (DispatcherAction action)
nm_dispatcher_call_connectivity (DispatcherAction action,
NMConnectivityState connectivity_state)
{
return _dispatcher_call (action, FALSE, NULL, NULL, NULL,
return _dispatcher_call (action, FALSE, NULL, NULL, NULL, connectivity_state,
NULL, NULL, NULL, NULL, NULL, NULL);
}

View file

@ -76,7 +76,8 @@ gboolean nm_dispatcher_call_vpn_sync (DispatcherAction action,
NMIP4Config *vpn_ip4_config,
NMIP6Config *vpn_ip6_config);
gboolean nm_dispatcher_call_connectivity (DispatcherAction action);
gboolean nm_dispatcher_call_connectivity (DispatcherAction action,
NMConnectivityState state);
void nm_dispatcher_call_cancel (guint call_id);