On Wed, 2016-06-08 at 16:20 -0400, Tony Espy wrote:
> From: Mathieu Trudel-Lapierre
>
> ... Also do that rather than resetting the killswitch to the NM saved
> WirelessEnabled state if urfkill support is enabled.
>
> Gbp-Pq: Name Track-killswitch-change-signals-from-urfkill.patch
> ---
> config.h.in | 6 +
> configure.ac | 11 ++
> src/Makefile.am | 6 +
> src/nm-manager.c | 112 +-
> src/nm-urfkill-manager.c | 289
> +++
> src/nm-urfkill-manager.h | 50
> 6 files changed, 472 insertions(+), 2 deletions(-)
> create mode 100644 src/nm-urfkill-manager.c
> create mode 100644 src/nm-urfkill-manager.h
>
> diff --git a/config.h.in b/config.h.in
> index baabb79..356de31 100644
> --- a/config.h.in
> +++ b/config.h.in
> @@ -261,6 +261,9 @@
> /* Define if you have ModemManager1 support */
> #undef WITH_MODEM_MANAGER_1
>
> +/* Define if you have oFono support */
> +#undef WITH_OFONO
> +
> /* whether to compile polkit support */
> #undef WITH_POLKIT
>
> @@ -276,6 +279,9 @@
> /* Define if you have Teamd control support */
> #undef WITH_TEAMDCTL
>
> +/* Define if you want to build with support for the urfkill daemon
> */
> +#undef WITH_URFKILL
> +
> /* Define if you have Wi-Fi support */
> #undef WITH_WIFI
This hunk wouldn't apply upstream since config.h.in gets auto-
generated... so can just be removed from the patch.
> diff --git a/configure.ac b/configure.ac
> index 2ccfa23..6ad177d 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -268,6 +268,17 @@ else
> fi
>
> dnl
> +dnl Default to using WEXT but allow it to be disabled
> +dnl
> +AC_ARG_WITH(urfkill, AS_HELP_STRING([--with-urfkill=yes], [Enable or
> disable support for urfkill]), ac_with_urfkill=$withval,
> ac_with_urfkill="yes")
> +if test x"$ac_with_urfkill" = x"yes"; then
> + AC_DEFINE(WITH_URFKILL, 1, [Define if you want to build with
> support for the urfkill daemon])
> +else
> + AC_DEFINE(WITH_URFKILL, 0, [Define if you want to build with
> support for the urfkill daemon])
> +fi
> +AM_CONDITIONAL(WITH_URFKILL, test x"${ac_with_urfkill}" = x"yes")
> +
> +dnl
> dnl Checks for libm - needed for pow()
> dnl
> LT_LIB_M
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 2495bbc..49028f1 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -445,6 +445,12 @@ libNetworkManager_la_SOURCES = \
> NetworkManagerUtils.c \
> NetworkManagerUtils.h
>
> +if WITH_URFKILL
> +libNetworkManager_la_SOURCES += \
> + nm-urfkill-manager.c \
> + nm-urfkill-manager.h \
> + $(NULL)
> +endif
>
> if SUSPEND_RESUME_UPOWER
> libNetworkManager_la_SOURCES += nm-sleep-monitor-upower.c
> diff --git a/src/nm-manager.c b/src/nm-manager.c
> index 8cf70c7..8f45b0f 100644
> --- a/src/nm-manager.c
> +++ b/src/nm-manager.c
> @@ -34,6 +34,7 @@
> #include "nm-device-generic.h"
> #include "nm-platform.h"
> #include "nm-rfkill-manager.h"
> +#include "nm-urfkill-manager.h"
> #include "nm-dhcp-manager.h"
> #include "nm-settings.h"
> #include "nm-settings-connection.h"
> @@ -121,6 +122,9 @@ typedef struct {
> guintid;
> } prop_filter;
> NMRfkillManager *rfkill_mgr;
> +#if WITH_URFKILL
> + NMUrfkillManager *urfkill_mgr;
> +#endif
>
> NMSettings *settings;
> char *hostname;
> @@ -144,6 +148,7 @@ typedef struct {
> gboolean ifstate_force_online;
>
> guint timestamp_update_id;
> + guint rfkill_initial_id;
>
> gboolean startup;
> gboolean devices_inited;
> @@ -5213,6 +5218,49 @@ dbus_connection_changed_cb (NMBusManager
> *dbus_mgr,
>
> /***
> ***/
>
> +#if WITH_URFKILL
> +static void
> +urfkill_wlan_state_changed_cb (NMUrfkillManager *mgr,
> + gboolean enabled,
> + gpointer user_data)
> +{
> + NMManager *self = NM_MANAGER (user_data);
> + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
> + GError *error = NULL;
> +
> + nm_log_dbg (LOGD_RFKILL, "urfkill wlan state changed to %s",
> + enabled ? "enabled" : "disabled");
> +
> + if (priv->rfkill_initial_id) {
> + g_source_remove (priv->rfkill_initial_id);
> + priv->rfkill_initial_id = 0;
> + }
nm_clear_g_source(>rfkill_initial_id) replaces all 4 of these
lines; but as below I don't think we'd really need them.
> + manager_update_radio_enabled (self,
> +
> >radio_states[RFKILL_TYPE_WLAN],
> + enabled);
> + nm_manager_update_state (self);
> +}
> +
> +static void
> +urfkill_wwan_state_changed_cb (NMUrfkillManager *mgr,
> + gboolean enabled,
> + gpointer user_data)
> +{
> + NMManager *self = NM_MANAGER