[gnome-settings-daemon] rfkill: Simplify get_*_airplane_mode()
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] rfkill: Simplify get_*_airplane_mode()
- Date: Tue, 26 Nov 2013 16:50:27 +0000 (UTC)
commit 3fa7ed73475e35c0c756fde89213df1c856310c8
Author: Bastien Nocera <hadess hadess net>
Date: Tue Nov 26 17:49:11 2013 +0100
rfkill: Simplify get_*_airplane_mode()
plugins/rfkill/gsd-rfkill-manager.c | 38 +++++++++++-----------------------
1 files changed, 12 insertions(+), 26 deletions(-)
---
diff --git a/plugins/rfkill/gsd-rfkill-manager.c b/plugins/rfkill/gsd-rfkill-manager.c
index 26ade21..c2bcdce 100644
--- a/plugins/rfkill/gsd-rfkill-manager.c
+++ b/plugins/rfkill/gsd-rfkill-manager.c
@@ -99,15 +99,15 @@ gsd_rfkill_manager_init (GsdRfkillManager *manager)
}
static gboolean
-engine_get_bluetooth_airplane_mode (GsdRfkillManager *manager)
+engine_get_airplane_mode_helper (GHashTable *killswitches)
{
GHashTableIter iter;
gpointer key, value;
- if (g_hash_table_size (manager->priv->bt_killswitches) == 0)
+ if (g_hash_table_size (killswitches) == 0)
return FALSE;
- g_hash_table_iter_init (&iter, manager->priv->bt_killswitches);
+ g_hash_table_iter_init (&iter, killswitches);
while (g_hash_table_iter_next (&iter, &key, &value)) {
int state;
@@ -122,6 +122,12 @@ engine_get_bluetooth_airplane_mode (GsdRfkillManager *manager)
}
static gboolean
+engine_get_bluetooth_airplane_mode (GsdRfkillManager *manager)
+{
+ return engine_get_airplane_mode_helper (manager->priv->bt_killswitches);
+}
+
+static gboolean
engine_get_bluetooth_hardware_airplane_mode (GsdRfkillManager *manager)
{
GHashTableIter iter;
@@ -155,31 +161,11 @@ engine_get_has_bluetooth_airplane_mode (GsdRfkillManager *manager)
static gboolean
engine_get_airplane_mode (GsdRfkillManager *manager)
{
- GHashTableIter iter;
- gpointer key, value;
-
- /* If we have no killswitches, airplane mode only depends on NM's wwan state. */
- if (g_hash_table_size (manager->priv->killswitches) == 0) {
- return manager->priv->wwan_interesting && !manager->priv->wwan_enabled;
- }
-
- g_hash_table_iter_init (&iter, manager->priv->killswitches);
- while (g_hash_table_iter_next (&iter, &key, &value)) {
- int state;
-
- state = GPOINTER_TO_INT (value);
-
- /* A single rfkill switch that's unblocked? Airplane mode is off */
- if (state == RFKILL_STATE_UNBLOCKED)
- return FALSE;
- }
-
+ if (!manager->priv->wwan_interesting)
+ return engine_get_airplane_mode_helper (manager->priv->killswitches);
/* wwan enabled? then airplane mode is off (because an USB modem
could be on in this state) */
- if (manager->priv->wwan_interesting && manager->priv->wwan_enabled)
- return FALSE;
-
- return TRUE;
+ return engine_get_airplane_mode_helper (manager->priv->killswitches) && !manager->priv->wwan_enabled;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]