Skip to content
Permalink
Browse files

rfkill: Add RFKill support plugin on Linux systems

from GNOME/gnome-settings-daemon@444af32

Signed-off-by: Zhang Xianwei <zhang.xianwei8@zte.com.cn>
  • Loading branch information...
zhangxianwei8 authored and raveit65 committed Oct 18, 2018
1 parent 765208e commit 2b528edce044642edcd388b851f52012b7e09e38
@@ -355,6 +355,21 @@ AM_CONDITIONAL(HAVE_POLKIT, test "x$HAVE_POLKIT" = "xyes")
AC_SUBST(POLKIT_CFLAGS)
AC_SUBST(POLKIT_LIBS)

# ---------------------------------------------------------------------------
# Rfkill
# ---------------------------------------------------------------------------

AC_ARG_ENABLE(rfkill,
AS_HELP_STRING([--disable-rfkill], [disable rfkill support (default: enabled)]),,
enable_rfkill=yes, enabled_rfkill=no)

if test x"$enable_rfkill" != x"no" ; then
AC_CHECK_HEADERS([linux/rfkill.h],,
AC_MSG_ERROR([RFKill headers not found but rfkill support requested]))
fi

AM_CONDITIONAL(BUILD_RFKILL, [test x"$enable_rfkill" = x"yes"])

# ---------------------------------------------------------------------------
# Enable Profiling
# ---------------------------------------------------------------------------
@@ -454,6 +469,7 @@ plugins/keyboard/Makefile
plugins/media-keys/Makefile
plugins/mpris/Makefile
plugins/mouse/Makefile
plugins/rfkill/Makefile
plugins/smartcard/Makefile
plugins/sound/Makefile
plugins/typing-break/Makefile
@@ -480,6 +496,7 @@ data/org.mate.SettingsDaemon.plugins.keyboard.gschema.xml
data/org.mate.SettingsDaemon.plugins.media-keys.gschema.xml
data/org.mate.SettingsDaemon.plugins.mpris.gschema.xml
data/org.mate.SettingsDaemon.plugins.mouse.gschema.xml
data/org.mate.SettingsDaemon.plugins.rfkill.gschema.xml
data/org.mate.SettingsDaemon.plugins.smartcard.gschema.xml
data/org.mate.SettingsDaemon.plugins.sound.gschema.xml
data/org.mate.SettingsDaemon.plugins.typing-break.gschema.xml
@@ -521,6 +538,7 @@ echo "
Libcanberra support: ${have_libcanberra}
Libmatemixer support: ${have_libmatemixer}
Smartcard support: ${have_smartcard_support}
RFKill support: ${enable_rfkill}
${NSS_DATABASE:+\
System nssdb: ${NSS_DATABASE}
}\
@@ -16,6 +16,7 @@ msd_gschemas_in = \
org.mate.SettingsDaemon.plugins.media-keys.gschema.xml.in \
org.mate.SettingsDaemon.plugins.mpris.gschema.xml.in \
org.mate.SettingsDaemon.plugins.mouse.gschema.xml.in \
org.mate.SettingsDaemon.plugins.rfkill.gschema.xml.in \
org.mate.SettingsDaemon.plugins.smartcard.gschema.xml.in \
org.mate.SettingsDaemon.plugins.sound.gschema.xml.in \
org.mate.SettingsDaemon.plugins.typing-break.gschema.xml.in \
@@ -0,0 +1,15 @@
<schemalist>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.mate.SettingsDaemon.plugins.rfkill" path="/org/mate/settings-daemon/plugins/rfkill/">
<key name="active" type="b">
<default>true</default>
<summary>Activation of this plugin</summary>
<description>Whether this plugin would be activated by mate-settings-daemon or not</description>
</key>
<key name="priority" type="i">
<default>0</default>
<summary>Priority to use for this plugin</summary>
<description>Priority to use for this plugin in mate-settings-daemon startup queue</description>
</key>
</schema>
</schemalist>

@@ -59,6 +59,8 @@ api_DATA = \

mate_settings_daemon_SOURCES = \
main.c \
mate-settings-bus.c \
mate-settings-bus.h \
mate-settings-manager.c \
mate-settings-manager.h \
mate-settings-plugin.c \
@@ -0,0 +1,77 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2006-2011 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "config.h"

#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <glib.h>
#include <gio/gio.h>

#include "mate-settings-bus.h"

char *
mate_settings_get_chassis_type (void)
{
char *ret = NULL;
GError *error = NULL;
GVariant *inner;
GVariant *variant = NULL;
GDBusConnection *connection;

connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM,
NULL,
&error);
if (connection == NULL) {
g_warning ("system bus not available: %s", error->message);
g_error_free (error);
goto out;
}

variant = g_dbus_connection_call_sync (connection,
"org.freedesktop.hostname1",
"/org/freedesktop/hostname1",
"org.freedesktop.DBus.Properties",
"Get",
g_variant_new ("(ss)",
"org.freedesktop.hostname1",
"Chassis"),
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
if (variant == NULL) {
g_debug ("Failed to get property '%s': %s", "Chassis", error->message);
g_error_free (error);
goto out;
}

g_variant_get (variant, "(v)", &inner);
ret = g_variant_dup_string (inner, NULL);
g_debug ("Get property '%s': %s", "Chassis", ret);
g_variant_unref (inner);
out:
g_clear_object (&connection);
g_clear_pointer (&variant, g_variant_unref);
return ret;
}
@@ -0,0 +1,33 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2010-2011 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __MATE_SETTINGS_BUS_H
#define __MATE_SETTINGS_BUS_H

#include <glib-object.h>

G_BEGIN_DECLS

char * mate_settings_get_chassis_type (void);

G_END_DECLS

#endif /* __MATE_SETTINGS_BUS_H */
@@ -28,5 +28,11 @@ else
disabled_plugins += smartcard
endif

if BUILD_RFKILL
enabled_plugins += rfkill
else
disabled_plugins += rfkill
endif

SUBDIRS = common $(enabled_plugins)
DIST_SUBDIRS = $(SUBDIRS) $(disabled_plugins)
@@ -0,0 +1,8 @@
# Get access to /dev/rfkill for users
# See https://bugzilla.redhat.com/show_bug.cgi?id=514798
#
# Simplified by Kay Sievers
# https://bugzilla.redhat.com/show_bug.cgi?id=733326
# See also https://bugzilla.gnome.org/show_bug.cgi?id=711373

KERNEL=="rfkill", SUBSYSTEM=="misc", TAG+="uaccess"
@@ -0,0 +1,42 @@
plugin_LTLIBRARIES = librfkill.la

librfkill_la_SOURCES = \
msd-rfkill-plugin.c \
msd-rfkill-manager.h \
msd-rfkill-manager.c \
rfkill-glib.c \
rfkill-glib.h \
rfkill.h

librfkill_la_CPPFLAGS = \
-I$(top_srcdir)/mate-settings-daemon \
-I$(top_srcdir)/data/ \
-DMATE_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
-DLIBEXECDIR=\""$(libexecdir)"\" \
$(AM_CPPFLAGS)

librfkill_la_CFLAGS = \
$(PLUGIN_CFLAGS) \
$(RFKILL_CFLAGS) \
$(SETTINGS_PLUGIN_CFLAGS) \
$(AM_CFLAGS)

librfkill_la_LDFLAGS = \
$(MSD_PLUGIN_LDFLAGS)

librfkill_la_LIBADD = \
$(RFKILL_LIBS) \
$(SETTINGS_PLUGIN_LIBS)

plugin_in_files = rfkill.mate-settings-plugin.in

plugin_DATA = $(plugin_in_files:.mate-settings-plugin.in=.mate-settings-plugin)

udevrulesdir = $(prefix)/lib/udev/rules.d
udevrules_DATA = 61-mate-settings-daemon-rfkill.rules

EXTRA_DIST = $(plugin_in_files) $(udevrules_DATA)
CLEANFILES = $(plugin_DATA)
DISTCLEANFILES = $(plugin_DATA)

@MSD_INTLTOOL_PLUGIN_RULE@
Oops, something went wrong.

0 comments on commit 2b528ed

Please sign in to comment.
You can’t perform that action at this time.