Skip to content
Permalink
Browse files

Merge pull request #4 from cyphermox/flight-mode-fixes

Flight mode fixes
  • Loading branch information...
cyphermox committed Jul 3, 2014
2 parents 03f4503 + 1e30561 commit 740b08d03c5b693c89bca03ac369f06ce771d48a
Showing with 24 additions and 27 deletions.
  1. +3 −10 src/urf-arbitrator.c
  2. +19 −17 src/urf-config.c
  3. +2 −0 src/urf-daemon.c
@@ -165,8 +165,6 @@ urf_arbitrator_set_flight_mode (UrfArbitrator *arbitrator,

g_message("set_flight_mode: %d:", (int) block);

urf_config_set_persist_state (priv->config, RFKILL_TYPE_ALL, block);

for (i = RFKILL_TYPE_ALL + 1; i < NUM_RFKILL_TYPES; i++) {
state = urf_killswitch_get_state (priv->killswitch[i]);

@@ -191,6 +189,9 @@ urf_arbitrator_set_flight_mode (UrfArbitrator *arbitrator,

ret = urf_arbitrator_set_block (arbitrator, i, want_state);
}

if (!ret)
break;
}

return ret;
@@ -646,14 +647,6 @@ urf_arbitrator_dispose (GObject *object)
KillswitchState state;
int i;

if (priv->persist) {
for (i = RFKILL_TYPE_ALL + 1; i < NUM_RFKILL_TYPES; i++) {
state = urf_killswitch_get_state (priv->killswitch[i]);
g_debug("dispose arbitrator: state for %d is %d", i, state);
urf_config_set_persist_state (priv->config, i, state);
}
}

for (i = 0; i < NUM_RFKILL_TYPES; i++) {
if (priv->killswitch[i]) {
g_object_unref (priv->killswitch[i]);
@@ -785,23 +785,6 @@ urf_config_get_persist_state (UrfConfig *config,
return state;
}

/**
* urf_persist_set_persist_state:
**/
void
urf_config_set_persist_state (UrfConfig *config,
const gint type,
const KillswitchState state)
{
UrfConfigPrivate *priv = URF_CONFIG_GET_PRIVATE (config);

g_return_if_fail (type >= 0);

g_debug ("setting state for device %s: %s", type_to_string(type), state > 0 ? "blocked" : "unblocked");

g_key_file_set_boolean (priv->persistence_file, type_to_string (type), "soft", state > 0);
}

static void
urf_config_save_persistence_file (UrfConfig *config)
{
@@ -829,6 +812,25 @@ urf_config_save_persistence_file (UrfConfig *config)
}
}

/**
* urf_persist_set_persist_state:
**/
void
urf_config_set_persist_state (UrfConfig *config,
const gint type,
const KillswitchState state)
{
UrfConfigPrivate *priv = URF_CONFIG_GET_PRIVATE (config);

g_return_if_fail (type >= 0);

g_debug ("setting state for device %s: %s", type_to_string(type), state > 0 ? "blocked" : "unblocked");

g_key_file_set_boolean (priv->persistence_file, type_to_string (type), "soft", state > 0);

urf_config_save_persistence_file (config);
}

static void
urf_config_get_persistence_file (UrfConfig *config)
{
@@ -386,6 +386,8 @@ urf_daemon_flight_mode (UrfDaemon *daemon,
g_warning ("Failed to emit UrfkeyPressed: %s", error->message);
g_error_free (error);
}
} else {
g_warning ("Failed to set device flight mode to %s", block ? "blocked" : "unblocked");
}

g_dbus_method_invocation_return_value (invocation,

0 comments on commit 740b08d

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