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;
}
	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());
		}
	}