Skip to content

Commit 2b528ed

Browse files
zhangxianwei8raveit65
authored andcommitted
rfkill: Add RFKill support plugin on Linux systems
from GNOME/gnome-settings-daemon@444af32 Signed-off-by: Zhang Xianwei <zhang.xianwei8@zte.com.cn>
1 parent 765208e commit 2b528ed

18 files changed

+1894
-0
lines changed

configure.ac

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,21 @@ AM_CONDITIONAL(HAVE_POLKIT, test "x$HAVE_POLKIT" = "xyes")
355355
AC_SUBST(POLKIT_CFLAGS)
356356
AC_SUBST(POLKIT_LIBS)
357357

358+
# ---------------------------------------------------------------------------
359+
# Rfkill
360+
# ---------------------------------------------------------------------------
361+
362+
AC_ARG_ENABLE(rfkill,
363+
AS_HELP_STRING([--disable-rfkill], [disable rfkill support (default: enabled)]),,
364+
enable_rfkill=yes, enabled_rfkill=no)
365+
366+
if test x"$enable_rfkill" != x"no" ; then
367+
AC_CHECK_HEADERS([linux/rfkill.h],,
368+
AC_MSG_ERROR([RFKill headers not found but rfkill support requested]))
369+
fi
370+
371+
AM_CONDITIONAL(BUILD_RFKILL, [test x"$enable_rfkill" = x"yes"])
372+
358373
# ---------------------------------------------------------------------------
359374
# Enable Profiling
360375
# ---------------------------------------------------------------------------
@@ -454,6 +469,7 @@ plugins/keyboard/Makefile
454469
plugins/media-keys/Makefile
455470
plugins/mpris/Makefile
456471
plugins/mouse/Makefile
472+
plugins/rfkill/Makefile
457473
plugins/smartcard/Makefile
458474
plugins/sound/Makefile
459475
plugins/typing-break/Makefile
@@ -480,6 +496,7 @@ data/org.mate.SettingsDaemon.plugins.keyboard.gschema.xml
480496
data/org.mate.SettingsDaemon.plugins.media-keys.gschema.xml
481497
data/org.mate.SettingsDaemon.plugins.mpris.gschema.xml
482498
data/org.mate.SettingsDaemon.plugins.mouse.gschema.xml
499+
data/org.mate.SettingsDaemon.plugins.rfkill.gschema.xml
483500
data/org.mate.SettingsDaemon.plugins.smartcard.gschema.xml
484501
data/org.mate.SettingsDaemon.plugins.sound.gschema.xml
485502
data/org.mate.SettingsDaemon.plugins.typing-break.gschema.xml
@@ -521,6 +538,7 @@ echo "
521538
Libcanberra support: ${have_libcanberra}
522539
Libmatemixer support: ${have_libmatemixer}
523540
Smartcard support: ${have_smartcard_support}
541+
RFKill support: ${enable_rfkill}
524542
${NSS_DATABASE:+\
525543
System nssdb: ${NSS_DATABASE}
526544
}\

data/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ msd_gschemas_in = \
1616
org.mate.SettingsDaemon.plugins.media-keys.gschema.xml.in \
1717
org.mate.SettingsDaemon.plugins.mpris.gschema.xml.in \
1818
org.mate.SettingsDaemon.plugins.mouse.gschema.xml.in \
19+
org.mate.SettingsDaemon.plugins.rfkill.gschema.xml.in \
1920
org.mate.SettingsDaemon.plugins.smartcard.gschema.xml.in \
2021
org.mate.SettingsDaemon.plugins.sound.gschema.xml.in \
2122
org.mate.SettingsDaemon.plugins.typing-break.gschema.xml.in \
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<schemalist>
2+
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.mate.SettingsDaemon.plugins.rfkill" path="/org/mate/settings-daemon/plugins/rfkill/">
3+
<key name="active" type="b">
4+
<default>true</default>
5+
<summary>Activation of this plugin</summary>
6+
<description>Whether this plugin would be activated by mate-settings-daemon or not</description>
7+
</key>
8+
<key name="priority" type="i">
9+
<default>0</default>
10+
<summary>Priority to use for this plugin</summary>
11+
<description>Priority to use for this plugin in mate-settings-daemon startup queue</description>
12+
</key>
13+
</schema>
14+
</schemalist>
15+

mate-settings-daemon/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ api_DATA = \
5959

6060
mate_settings_daemon_SOURCES = \
6161
main.c \
62+
mate-settings-bus.c \
63+
mate-settings-bus.h \
6264
mate-settings-manager.c \
6365
mate-settings-manager.h \
6466
mate-settings-plugin.c \
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2+
*
3+
* Copyright (C) 2006-2011 Richard Hughes <richard@hughsie.com>
4+
*
5+
* Licensed under the GNU General Public License Version 2
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*/
21+
22+
#include "config.h"
23+
24+
#include <string.h>
25+
#include <unistd.h>
26+
#include <stdio.h>
27+
#include <glib.h>
28+
#include <gio/gio.h>
29+
30+
#include "mate-settings-bus.h"
31+
32+
char *
33+
mate_settings_get_chassis_type (void)
34+
{
35+
char *ret = NULL;
36+
GError *error = NULL;
37+
GVariant *inner;
38+
GVariant *variant = NULL;
39+
GDBusConnection *connection;
40+
41+
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM,
42+
NULL,
43+
&error);
44+
if (connection == NULL) {
45+
g_warning ("system bus not available: %s", error->message);
46+
g_error_free (error);
47+
goto out;
48+
}
49+
50+
variant = g_dbus_connection_call_sync (connection,
51+
"org.freedesktop.hostname1",
52+
"/org/freedesktop/hostname1",
53+
"org.freedesktop.DBus.Properties",
54+
"Get",
55+
g_variant_new ("(ss)",
56+
"org.freedesktop.hostname1",
57+
"Chassis"),
58+
NULL,
59+
G_DBUS_CALL_FLAGS_NONE,
60+
-1,
61+
NULL,
62+
&error);
63+
if (variant == NULL) {
64+
g_debug ("Failed to get property '%s': %s", "Chassis", error->message);
65+
g_error_free (error);
66+
goto out;
67+
}
68+
69+
g_variant_get (variant, "(v)", &inner);
70+
ret = g_variant_dup_string (inner, NULL);
71+
g_debug ("Get property '%s': %s", "Chassis", ret);
72+
g_variant_unref (inner);
73+
out:
74+
g_clear_object (&connection);
75+
g_clear_pointer (&variant, g_variant_unref);
76+
return ret;
77+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2+
*
3+
* Copyright (C) 2010-2011 Richard Hughes <richard@hughsie.com>
4+
*
5+
* Licensed under the GNU General Public License Version 2
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*/
21+
22+
#ifndef __MATE_SETTINGS_BUS_H
23+
#define __MATE_SETTINGS_BUS_H
24+
25+
#include <glib-object.h>
26+
27+
G_BEGIN_DECLS
28+
29+
char * mate_settings_get_chassis_type (void);
30+
31+
G_END_DECLS
32+
33+
#endif /* __MATE_SETTINGS_BUS_H */

plugins/Makefile.am

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,11 @@ else
2828
disabled_plugins += smartcard
2929
endif
3030

31+
if BUILD_RFKILL
32+
enabled_plugins += rfkill
33+
else
34+
disabled_plugins += rfkill
35+
endif
36+
3137
SUBDIRS = common $(enabled_plugins)
3238
DIST_SUBDIRS = $(SUBDIRS) $(disabled_plugins)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Get access to /dev/rfkill for users
2+
# See https://bugzilla.redhat.com/show_bug.cgi?id=514798
3+
#
4+
# Simplified by Kay Sievers
5+
# https://bugzilla.redhat.com/show_bug.cgi?id=733326
6+
# See also https://bugzilla.gnome.org/show_bug.cgi?id=711373
7+
8+
KERNEL=="rfkill", SUBSYSTEM=="misc", TAG+="uaccess"

plugins/rfkill/Makefile.am

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
plugin_LTLIBRARIES = librfkill.la
2+
3+
librfkill_la_SOURCES = \
4+
msd-rfkill-plugin.c \
5+
msd-rfkill-manager.h \
6+
msd-rfkill-manager.c \
7+
rfkill-glib.c \
8+
rfkill-glib.h \
9+
rfkill.h
10+
11+
librfkill_la_CPPFLAGS = \
12+
-I$(top_srcdir)/mate-settings-daemon \
13+
-I$(top_srcdir)/data/ \
14+
-DMATE_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
15+
-DLIBEXECDIR=\""$(libexecdir)"\" \
16+
$(AM_CPPFLAGS)
17+
18+
librfkill_la_CFLAGS = \
19+
$(PLUGIN_CFLAGS) \
20+
$(RFKILL_CFLAGS) \
21+
$(SETTINGS_PLUGIN_CFLAGS) \
22+
$(AM_CFLAGS)
23+
24+
librfkill_la_LDFLAGS = \
25+
$(MSD_PLUGIN_LDFLAGS)
26+
27+
librfkill_la_LIBADD = \
28+
$(RFKILL_LIBS) \
29+
$(SETTINGS_PLUGIN_LIBS)
30+
31+
plugin_in_files = rfkill.mate-settings-plugin.in
32+
33+
plugin_DATA = $(plugin_in_files:.mate-settings-plugin.in=.mate-settings-plugin)
34+
35+
udevrulesdir = $(prefix)/lib/udev/rules.d
36+
udevrules_DATA = 61-mate-settings-daemon-rfkill.rules
37+
38+
EXTRA_DIST = $(plugin_in_files) $(udevrules_DATA)
39+
CLEANFILES = $(plugin_DATA)
40+
DISTCLEANFILES = $(plugin_DATA)
41+
42+
@MSD_INTLTOOL_PLUGIN_RULE@

0 commit comments

Comments
 (0)