コード例 #1
0
void HippoPanelGridsImpl::retrieveGridInfo()
{
	std::string loginuri = childGetValue("loginuri");
	if ((loginuri == "") || (loginuri == "<required>")) {
		LLNotificationsUtil::add("GridInfoNoLoginUri");
		return;
	}
	
	HippoGridInfo *grid = 0;
	bool cleanupGrid = false;
	if (mState == NORMAL) {
		grid = gHippoGridManager->getGrid(mCurGrid);
	} else if ((mState == ADD_NEW) || (mState == ADD_COPY)) {
		grid = new HippoGridInfo("");
		cleanupGrid = true;
	} else {
		llerrs << "Illegal state " << mState << '.' << llendl;
		return;
	}
	if (!grid) {
		llerrs << "Internal error retrieving grid info." << llendl;
		return;
	}
	
	grid->setLoginUri(loginuri);
	try
	{
		grid->getGridInfo();

		if (grid->getPlatform() != HippoGridInfo::PLATFORM_OTHER)
			getChild<LLComboBox>("platform")->setCurrentByIndex(grid->getPlatform());
		if (grid->getGridName() != "") childSetText("gridname", grid->getGridName());
		if (grid->getLoginUri() != "") childSetText("loginuri", grid->getLoginUri());
		if (grid->getLoginPage() != "") childSetText("loginpage", grid->getLoginPage());
		if (grid->getHelperUri() != "") childSetText("helperuri", grid->getHelperUri());
		if (grid->getWebSite() != "") childSetText("website", grid->getWebSite());
		if (grid->getSupportUrl() != "") childSetText("support", grid->getSupportUrl());
		if (grid->getRegisterUrl() != "") childSetText("register", grid->getRegisterUrl());
		if (grid->getPasswordUrl() != "") childSetText("password", grid->getPasswordUrl());
		if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl());
		if (grid->getGridMessage() != "") childSetText("gridmessage", grid->getGridMessage());
	}
	catch(AIAlert::ErrorCode const& error)
	{
		if (error.getCode() == HTTP_METHOD_NOT_ALLOWED || error.getCode() == HTTP_OK)
		{
			AIAlert::add("GridInfoError", error);
		}
		else
		{
			// Append GridInfoErrorInstruction to error message.
			AIAlert::add("GridInfoError", AIAlert::Error(AIAlert::Prefix(), AIAlert::not_modal, error, "GridInfoErrorInstruction"));
		}
	}

	if (cleanupGrid) delete grid;
}
コード例 #2
0
// returns false, if adding new grid failed
bool HippoPanelGridsImpl::saveCurGrid()
{
	HippoGridInfo *gridInfo = 0;
	
	gridInfo = gHippoGridManager->getGrid(mCurGrid);
	//gridInfo->getGridInfo();
	refresh();
	
	std::string gridname = childGetValue("gridname");
	if (gridname == "<required>") gridname = "";
	std::string loginuri = childGetValue("loginuri");
	if (loginuri == "<required>") loginuri = "";
	
	if (gridname.empty() && !loginuri.empty())
		this->retrieveGridInfo();
	
	if ((mState == ADD_NEW) || (mState == ADD_COPY)) {
		
		// check nickname
		std::string gridname = childGetValue("gridname");
		childSetValue("gridname", (gridname != "")? gridname: "<required>");
		if (gridname == "") {
			LLNotificationsUtil::add("GridsNoNick");
			return false;
		}
		if (gHippoGridManager->getGrid(gridname)) {
			LLSD args;
			args["NAME"] = gridname;
			LLNotificationsUtil::add("GridExists", args);
			return false;
		}
		
		// check login URI
		if (loginuri == "") {
			LLSD args;
			args["NAME"] = gridname;
			LLNotificationsUtil::add("GridsNoLoginUri", args);
			return false;
		}
		
		mState = NORMAL;
		mCurGrid = gridname;
		gridInfo = new HippoGridInfo(gridname);
		gHippoGridManager->addGrid(gridInfo);
		try
		{
			gridInfo->getGridInfo();
		}
		catch (AIAlert::ErrorCode const& error)
		{
			if (error.getCode() == HTTP_NOT_FOUND || error.getCode() == HTTP_METHOD_NOT_ALLOWED)
			{
				// Ignore this error; it might be a user entered entry for a grid that has no get_grid_info support.
				llwarns << AIAlert::text(error) << llendl;
			}
			else if (error.getCode() == HTTP_OK)
			{
				// XML parse error.
				AIAlert::add("GridInfoError", error);
			}
			else
			{
				// Append GridInfoErrorInstruction to error message.
				AIAlert::add("GridInfoError", AIAlert::Error(AIAlert::Prefix(), AIAlert::not_modal, error, "GridInfoErrorInstruction"));
			}
		}
	}

	if (!gridInfo) {
		llwarns << "Grid not found, ignoring changes." << llendl;
		return true;
	}

	gridInfo->setPlatform(childGetValue("platform"));
	gridInfo->setGridName(childGetValue("gridname"));
	gridInfo->setLoginUri(childGetValue("loginuri"));
	gridInfo->setLoginPage(childGetValue("loginpage"));
	gridInfo->setHelperUri(childGetValue("helperuri"));
	gridInfo->setWebSite(childGetValue("website"));
	gridInfo->setSupportUrl(childGetValue("support"));
	gridInfo->setRegisterUrl(childGetValue("register"));
	gridInfo->setPasswordUrl(childGetValue("password"));
	gridInfo->setSearchUrl(childGetValue("search"));
	gridInfo->setRenderCompat(childGetValue("render_compat"));
	
	refresh();
	return true;
}