예제 #1
0
파일: radiostates.c 프로젝트: Vesuri/mce
/**
 * Restore the radio states from persistant storage
 *
 * @param[out] online_states A pointer to the restored online radio states
 * @param[out] offline_states A pointer to the restored offline radio states
 * @return TRUE on success, FALSE on failure
 */
static gboolean restore_radio_states(gulong *online_states,
				     gulong *offline_states)
{
	if (mce_are_settings_locked() == TRUE) {
		mce_log(LL_INFO, "Removing stale settings lockfile");

		if (mce_unlock_settings() == FALSE) {
			mce_log(LL_ERR, "Failed to remove settings lockfile; %m");
		}
	}

	return read_radio_states(MCE_ONLINE_RADIO_STATES_PATH, online_states, MCE_OFFLINE_RADIO_STATES_PATH, offline_states);
}
예제 #2
0
파일: radiostates.c 프로젝트: spiiroin/mce
/** Restore the radio states from persistant storage
 */
static void
mrs_restore_radio_states(void)
{
	static const char online_file[]  = MCE_ONLINE_RADIO_STATES_PATH;
	static const char offline_file[] = MCE_OFFLINE_RADIO_STATES_PATH;

	/* Apply configured defaults */
	active_radio_states = saved_radio_states = mrs_get_default_radio_states();

	/* FIXME: old maemo backup/restore handling - can be removed? */
	if( mce_are_settings_locked() ) {
		if( mce_unlock_settings() )
			mce_log(LL_INFO, "Removed stale settings lockfile");
		else
			mce_log(LL_ERR, "Failed to remove settings lockfile; %m");
	}

	/* The files get generated by mce on 1st bootup. Skip the
	 * read attempt and associated diagnostic logging if the
	 * files do not exist */
	if( access(online_file, F_OK) == -1 && errno == ENOENT )
		goto EXIT;

	gulong online_states  = 0;
	gulong offline_states = 0;

	if( mce_read_number_string_from_file(online_file, &online_states,
					     NULL, TRUE, TRUE) )
		active_radio_states = (guint)online_states;

	if( mce_read_number_string_from_file(offline_file, &offline_states,
					     NULL, TRUE, TRUE) )
		saved_radio_states  = (guint)offline_states;

EXIT:
	mce_log(LL_DEBUG, "active_radio_states: %s",
		radio_states_repr(active_radio_states));
	mce_log(LL_DEBUG, "saved_radio_states: %s",
		radio_states_repr(saved_radio_states));
	return;
}