示例#1
0
void LLFloaterSearch::search(const SearchQuery &p)
{
	if (! mWebBrowser || !p.validateBlock())
	{
		return;
	}

	// reset the god level warning as we're sending the latest state
	getChildView("refresh_search")->setVisible(FALSE);
	mSearchGodLevel = gAgent.getGodLevel();

	// work out the subdir to use based on the requested category
	LLSD subs;
	if (mCategoryPaths.has(p.category))
	{
		subs["CATEGORY"] = mCategoryPaths[p.category].asString();
	}
	else
	{
		subs["CATEGORY"] = mCategoryPaths["all"].asString();
	}

	// add the search query string
	subs["QUERY"] = LLURI::escape(p.query);

	// add the permissions token that login.cgi gave us
	// We use "search_token", and fallback to "auth_token" if not present.
	LLSD search_token = LLLoginInstance::getInstance()->getResponse("search_token");
	if (search_token.asString().empty())
	{
		search_token = LLLoginInstance::getInstance()->getResponse("auth_token");
	}
	subs["AUTH_TOKEN"] = search_token.asString();

	// add the user's preferred maturity (can be changed via prefs)
	std::string maturity;
	if (gAgent.prefersAdult())
	{
		maturity = "42";  // PG,Mature,Adult
	}
	else if (gAgent.prefersMature())
	{
		maturity = "21";  // PG,Mature
	}
	else
	{
		maturity = "13";  // PG
	}
	subs["MATURITY"] = maturity;

	// add the user's god status
	subs["GODLIKE"] = gAgent.isGodlike() ? "1" : "0";

	// get the search URL and expand all of the substitutions
	// (also adds things like [LANGUAGE], [VERSION], [OS], etc.)
// <FS:AW  opensim search support>
//	std::string url = gSavedSettings.getString("SearchURL");
	std::string url;

#ifdef HAS_OPENSIM_SUPPORT // <FS:AW optional opensim support>
	std::string debug_url = gSavedSettings.getString("SearchURLDebug");
	if (gSavedSettings.getBOOL("DebugSearch") && !debug_url.empty())
	{
		url = debug_url;
	}
	else if(LLGridManager::getInstance()->isInOpenSim())
	{
		url = LLLoginInstance::getInstance()->hasResponse("search")
			? LLLoginInstance::getInstance()->getResponse("search").asString()
			: gSavedSettings.getString("SearchURLOpenSim");
	}
	else // we are in SL or SL beta
#endif // HAS_OPENSIM_SUPPORT // <FS:AW optional opensim support>
	{
		url = gSavedSettings.getString("SearchURL");
	}
// </FS:AW  opensim search support>

	url = LLWeb::expandURLSubstitutions(url, subs);

	// and load the URL in the web view
	mWebBrowser->navigateTo(url, "text/html");
}
// static
void LLFloaterSearch::search(const SearchQuery &p, LLMediaCtrl* mWebBrowser)
{
	if (! mWebBrowser || !p.validateBlock())
	{
		return;
	}

	// work out the subdir to use based on the requested category
	LLSD subs;
	// declare a map that transforms a category name into
	// the URL suffix that is used to search that category
	static LLSD mCategoryPaths = LLSD::emptyMap();
	if (mCategoryPaths.size() == 0)
	{
		mCategoryPaths["all"]          = "search";
		mCategoryPaths["people"]       = "search/people";
		mCategoryPaths["places"]       = "search/places";
		mCategoryPaths["events"]       = "search/events";
		mCategoryPaths["groups"]       = "search/groups";
		mCategoryPaths["wiki"]         = "search/wiki";
		mCategoryPaths["destinations"] = "destinations";
		mCategoryPaths["classifieds"]  = "classifieds";
	}
	if (mCategoryPaths.has(p.category))
	{
		subs["CATEGORY"] = mCategoryPaths[p.category].asString();
	}
	else
	{
		subs["CATEGORY"] = mCategoryPaths["all"].asString();
	}

	// add the search query string
	subs["QUERY"] = LLURI::escape(p.query);

	// add the permissions token that login.cgi gave us
	// We use "search_token", and fallback to "auth_token" if not present.
	LLSD search_token = LLUserAuth::getInstance()->getResponse("search_token");
	if (search_token.asString().empty())
	{
		search_token = LLUserAuth::getInstance()->getResponse("auth_token");
	}
	subs["AUTH_TOKEN"] = search_token.asString();

	// add the user's preferred maturity (can be changed via prefs)
	std::string maturity;
	if (gAgent.prefersAdult())
	{
		maturity = "42";  // PG,Mature,Adult
	}
	else if (gAgent.prefersMature())
	{
		maturity = "21";  // PG,Mature
	}
	else
	{
		maturity = "13";  // PG
	}
	subs["MATURITY"] = maturity;

	// add the user's god status
	subs["GODLIKE"] = gAgent.isGodlike() ? "1" : "0";

	// get the search URL and expand all of the substitutions
	// (also adds things like [LANGUAGE], [VERSION], [OS], etc.)
	std::string url = gSavedSettings.getString("SearchURL");
	url = LLWeb::expandURLSubstitutions(url, subs);

	// and load the URL in the web view
	mWebBrowser->navigateTo(url, "text/html");
}