Example #1
0
int HTMIME_location_custom (HTRequest * request, HTResponse * response, char * token, char * value)
{
	char * location = HTStrip(value);

	std::string finalLocation;

	//nlinfo("redirect to '%s' '%s'", value, location);

	// If not absolute URI (Error) then find the base
	if (!HTURL_isAbsolute(location))
	{
		char * base = HTAnchor_address((HTAnchor *) HTRequest_anchor(request));
		location = HTParse(location, base, PARSE_ALL);
		//redirection = HTAnchor_findAddress(location);
		finalLocation = location;
		HT_FREE(base);
		HT_FREE(location);
	}
	else
	{
		finalLocation = location;
	}
	//nlinfo("final location '%s'", finalLocation.c_str());

	CGroupHTML *gh = (CGroupHTML *) HTRequest_context(request);

	gh->setURL(finalLocation);

	return HT_OK;
}
Example #2
0
// ***************************************************************************
int requestTerminater (HTRequest * request, HTResponse * /* response */,
				void * param, int /* status */)
{
	/*
		Yoyo and Boris: we had to make the request terminate by UID and not by pointer (param is an uid).
		Because this method was called at mainLoop time, but for GroupHTML created/deleted at login time !!!
		=> Memory Crash.
	*/

	// TestYoyo
	//nlinfo("** requestTerminater(): uid%d", (uint32)param);

	// the parameter is actually an uint32
	if (param != 0)
	{
		CGroupHTML::TGroupHtmlByUIDMap::iterator	it= CGroupHTML::_GroupHtmlByUID.find((uint32)(size_t)param);
		if(it!=CGroupHTML::_GroupHtmlByUID.end())
		{
			// get the pointer. NB: the refptr should not be NULL
			// since object removed from map when deleted
			CGroupHTML *gh = it->second;
			nlassert(gh);

			// callback the browser
			gh->requestTerminated(request);
		}
	}
    return HT_OK;
}
	virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
	{
		string webapp, window = Params;
		vector<string> res;
		explode(Params, string("|"), res);
		if(res[0]=="webig" || res[0]=="mailbox" || res[0]=="guild_forum" || res[0]=="profile")
		{
			window = "webig";
			if(res[0]=="mailbox")
				webapp = "mail";
			else if(res[0]=="guild_forum")
				webapp = "forum";
			else if(res[0]=="profile")
				webapp = "profile&pname="+urlencode(getParam(Params,"pname"))+"&ptype="+getParam(Params,"ptype");
			else
				webapp = "web";
		}

		CInterfaceManager *pIM = CInterfaceManager::getInstance();
		CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(pIM->getElementFromId("ui:interface", window));
		if (pGC == NULL)
		{
			nlwarning("%s is not a container", window.c_str());
			return;
		}
		if (!isContainerAuthorized(pGC)) return;

		if(window == "webig")
		{
			if(pGC->getActive() && currentWebApp == webapp)
			{
				pGC->setActive(false);
				currentWebApp.clear();
			}
			else
			{
				pGC->setActive(true);
				currentWebApp = webapp;
			}
			if(!webapp.empty() && pGC->getActive())
			{
				CGroupHTML *pGH = dynamic_cast<CGroupHTML*>(pIM->getElementFromId("ui:interface:webig:content:html"));
				if (pGH == NULL)
				{
					nlwarning("%s is not a group html", window.c_str());
					return;
				}
				pGH->setURL("http://atys.ryzom.com/start/index.php?app="+webapp);
			}
		}
		else
		{
			// normal open/close swap
			pGC->setActive(!pGC->getActive());
		}
	}
	void execute (CCtrlBase *pCaller, const std::string &sParams)
	{
		CInterfaceManager	*pIM= CInterfaceManager::getInstance();
		string container = getParam (sParams, "name");
		CGroupHTML *groupHtml = dynamic_cast<CGroupHTML*>(pIM->getElementFromId(container));
		if (groupHtml)
		{
			groupHtml->browse(groupHtml->Home.c_str());
		}
	};
Example #5
0
// --------------------------------------------------------------------------------------------------------------------
bool CViewPointer::drawBrowse (CCtrlBase* pCB, CRGBA col)
{
	CGroupHTML *pCGH = dynamic_cast<CGroupHTML *>(pCB);
	if (pCGH != NULL)
	{
		if (pCGH->isBrowsing())
		{
			static uint8 rot =0;
			drawCursor(_TxIdRotate, col, rot>>3);
			rot = (rot+1) & 0x1f;
			return true;
		}
	}
	return false;
}
Example #6
0
// ***************************************************************************
void CGuildManager::update()
{
	CInterfaceManager *pIM = CInterfaceManager::getInstance();
	STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();

	// *** Need to rebuild the guild data?
	if (_NeedRebuild)
	{
		_NeedUpdate = true;
		_NeedRebuild = false;

		// Rebuild transfert the database to the local structure

		// Guild stuff
		uint32 oldName = _Guild.NameID;
		_Guild.NameID = pIM->getDbProp("SERVER:GUILD:NAME")->getValue32();
		_Guild.Name = "";
		_InGuild = (_Guild.NameID != 0);
		if (!_InGuild)
			closeAllInterfaces();
		_Guild.Icon = pIM->getDbProp("SERVER:GUILD:ICON")->getValue64();
		_Guild.QuitGuildAvailable = true;

		// Guild Members
		if(_NeedRebuildMembers)
		{
			_NeedUpdateMembers = true;
			_NeedRebuildMembers = false;

			_GuildMembers.clear();
			for (uint32 i = 0; i < MAX_GUILD_MEMBER; ++i)
			{
				sint32 name = pIM->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":NAME")->getValue32();
				if (name != 0)
				{
					SGuildMember gm;
					gm.NameID = name;
					gm.Index = i;
					gm.Grade = (EGSPD::CGuildGrade::TGuildGrade)(pIM->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":GRADE")->getValue32());
					gm.Online = (TCharConnectionState)(pIM->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":ONLINE")->getValue32());
					gm.EnterDate = pIM->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":ENTER_DATE")->getValue32();
					_GuildMembers.push_back(gm);
				}
			}
		}

		// Does the player are newcomer ?
		// Boris 01/09/2006 : removed : now the guild interface is open if
		// is was active before OR if the EGS ask it to the client

		bool playerNewToTheGuild = _NewToTheGuild &&(oldName != _Guild.NameID) && _InGuild;
		if (playerNewToTheGuild)
		{
			// reset the flag
			_NewToTheGuild = false;
			// Don't pop the guild window in ring mode.
			// NB nico : this test should not be necessary, as the guild infos should be filled during the init of the db
			// However, there are situation where this db info is filled after init (should only happen at guild creation time ...)
			// Maybe an EGS  bug ?
			if (R2::getEditor().getMode() == R2::CEditor::NotInitialized)
			{
				CInterfaceElement *pElt;
				// Open the guild info if we are not in the init phase
				if (!IngameDbMngr.initInProgress())
				{
					pElt = pIM->getElementFromId(WIN_GUILD);
					if (pElt != NULL)
						pElt->setActive(true);
				}
				// Browse the forum
				pElt = pIM->getElementFromId(WIN_GUILD_FORUM":content:html");
				if (pElt != NULL)
				{
					CGroupHTML *html = dynamic_cast<CGroupHTML*>(pElt);
					if (html)
						html->browse("home");
				}
			}
		}
	}

	// *** Need to update Names?
	if (_NeedUpdate)
	{
		bool bAllValid = true;
		// Update wait until all the name of members, name of the guild and description are valid

		if (!pSMC->getString (_Guild.NameID, _Guild.Name)) bAllValid = false;

		for (uint i = 0; i < _GuildMembers.size(); ++i)
		{
			if (!pSMC->getString (_GuildMembers[i].NameID, _GuildMembers[i].Name)) bAllValid = false;
			else _GuildMembers[i].Name = CEntityCL::removeTitleAndShardFromName(_GuildMembers[i].Name);
		}

		// If all is valid no more need update and if guild is opened update the interface
		if (bAllValid)
		{
			// Search for UserEntity to find our own grade
			if ((UserEntity != NULL) && (_GuildMembers.size() > 0))
			{
				uint i;
				_Grade = EGSPD::CGuildGrade::Member;
				string sUserName = strlwr(UserEntity->getEntityName().toString());
				for (i = 0; i < _GuildMembers.size(); ++i)
				{
					if (strlwr(_GuildMembers[i].Name.toString()) == sUserName)
					{
						_Grade = _GuildMembers[i].Grade;
						break;
					}
				}
			}

			// set this value in the database
			pIM->getDbProp("UI:VARIABLES:USER:GUILD_GRADE")->setValue32(_Grade);

			// update the guild display
			CGroupContainer *pGuild = dynamic_cast<CGroupContainer*>(pIM->getElementFromId(WIN_GUILD));
			if (pGuild != NULL)
			{
				// if the guild window is visible
				if (pGuild->isOpen() && pGuild->getActive())
				{
					// Close the modal window if the member list will change
					if(pIM->getModalWindow()!=NULL && _NeedUpdateMembers)
					{
						if (pIM->getModalWindow()->getId() == MENU_GUILD_MEMBER )
							pIM->disableModalWindow();
					}

					// Rebuild interface. Rebuild members only if needed
					pIM->runActionHandler("guild_sheet_open", NULL, toString("update_members=%d", (uint)_NeedUpdateMembers) );
				}
			}

			// guild updated
			_NeedUpdate = false;
			_NeedUpdateMembers= false;
		}
	}

	// *** Join proposal handling
	if (_JoinPropUpdate)
	{
		bool bAllValid = true;
		if (!pSMC->getDynString (_JoinPropPhraseID, _JoinPropPhrase)) bAllValid = false;
		// If all is valid no more need update and update the interface
		if (bAllValid)
		{
			_JoinPropUpdate = false;
			CGroupContainer *pJoinProp = dynamic_cast<CGroupContainer*>(pIM->getElementFromId(WIN_JOIN_PROPOSAL));
			if (pJoinProp != NULL)
			{
				CViewText *pJoinPropPhraseView = dynamic_cast<CViewText*>(pIM->getElementFromId(VIEW_JOIN_PROPOSAL_PHRASE));
				if (pJoinPropPhraseView != NULL)
					pJoinPropPhraseView->setText(_JoinPropPhrase);

				pJoinProp->setActive(true);
				pIM->setTopWindow(pJoinProp);
				pJoinProp->updateCoords();
				pJoinProp->center();
				pJoinProp->enableBlink(2);
			}
		}
	}
}