Beispiel #1
0
/**
 * 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);
}
Beispiel #2
0
/**
 * Save the profile id into conf file
 *
 * @param id The profile id to save
 * @return TRUE on success, FALSE on failure
 */
static gboolean save_color_profile(const gchar *id)
{
	gboolean status = FALSE;

	if (mce_are_settings_locked() == TRUE) {
		mce_log(LL_WARN,
			"Cannot save current color profile id; backup/restore "
			"or device clear/factory reset pending");
		goto EXIT;
	}

	status = mce_gconf_set_string(MCE_GCONF_DISPLAY_COLOR_PROFILE, id);

EXIT:
	return status;
}
Beispiel #3
0
/** 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;
}
Beispiel #4
0
/**
 * Save the radio states to persistant storage
 *
 * @param online_states The online radio states to store
 * @param offline_states The offline radio states to store
 * @return TRUE on success, FALSE on failure
 */
static gboolean save_radio_states(const gulong online_states,
				  const gulong offline_states)
{
	gboolean status = FALSE;

	if (mce_are_settings_locked() == TRUE) {
		mce_log(LL_WARN,
			"Cannot save radio states; backup/restore "
			"or device clear/factory reset pending");
		goto EXIT;
	}

	status = mce_write_number_string_to_file_atomic(MCE_ONLINE_RADIO_STATES_PATH, online_states);

	if (status == FALSE)
		goto EXIT;

	status = mce_write_number_string_to_file_atomic(MCE_OFFLINE_RADIO_STATES_PATH, offline_states);

EXIT:
	return status;
}
Beispiel #5
0
/** Save the radio states to persistant storage
 */
static void
mrs_save_radio_states(void)
{
	const guint online_states  = active_radio_states;
	const guint offline_states = saved_radio_states;

	/* FIXME: old maemo backup/restore handling - can be removed? */
	if (mce_are_settings_locked() == TRUE) {
		mce_log(LL_WARN,
			"Cannot save radio states; backup/restore "
			"or device clear/factory reset pending");
		goto EXIT;
	}

	mce_write_number_string_to_file_atomic(MCE_ONLINE_RADIO_STATES_PATH,
					       online_states);
	mce_write_number_string_to_file_atomic(MCE_OFFLINE_RADIO_STATES_PATH,
					       offline_states);

EXIT:
	return;
}