Exemple #1
0
gboolean
command_runnable (cli_infos_t *infos, command_action_t *action)
{
	gint n = 0;

	/* Require connection, abort on failure */
	if (COMMAND_REQ_CHECK(action, COMMAND_REQ_CONNECTION) && !infos->conn) {
		gboolean autostart;
		autostart = !COMMAND_REQ_CHECK(action, COMMAND_REQ_NO_AUTOSTART);
		if (!cli_infos_connect (infos, autostart) && autostart) {
			return FALSE;
		}
	}

	/* Get the cache ready if needed */
	if (COMMAND_REQ_CHECK(action, COMMAND_REQ_CACHE)) {
		/* If executing an alias have to refresh manually */
		if (infos->status == CLI_ACTION_STATUS_ALIAS) {
			cli_cache_refresh (infos);
		}
		while (!cli_cache_is_fresh (infos->cache)) {
			/* Obviously, there is a problem with updating the cache, abort */
			if (n == MAX_CACHE_REFRESH_LOOP) {
				g_printf (_("Failed to update the cache!"));
				return FALSE;
			}
			loop_select (infos);
			n++;
		}
	}

	return TRUE;
}
gboolean
cli_context_cache_refreshing (cli_context_t *ctx)
{
	return !cli_cache_is_fresh (ctx->cache);
}