PageRenderTime 96ms CodeModel.GetById 24ms app.highlight 11ms RepoModel.GetById 24ms app.codeStats 13ms

/indra/newview/llviewerhome.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 77 lines | 29 code | 9 blank | 39 comment | 2 complexity | 0878093f3f8881b2cc6851775ba50663 MD5 | raw file
 1/** 
 2 * @file llviewerhome.cpp
 3 * @brief Model (non-View) component for the web-based Home side panel
 4 * @author Martin Reddy
 5 *
 6 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
 7 * Second Life Viewer Source Code
 8 * Copyright (C) 2010, Linden Research, Inc.
 9 * 
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation;
13 * version 2.1 of the License only.
14 * 
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * Lesser General Public License for more details.
19 * 
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23 * 
24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
25 * $/LicenseInfo$
26 */
27
28#include "llviewerprecompiledheaders.h"
29#include "llviewerhome.h"
30
31#include "lllogininstance.h"
32#include "llsd.h"
33#include "llui.h"
34#include "lluri.h"
35#include "llviewercontrol.h"
36#include "llweb.h"
37
38//static
39std::string LLViewerHome::getHomeURL()
40{	
41	// Return the URL to display in the Home side tray. We read
42	// this value from settings.xml and support various substitutions
43
44	LLSD substitution;
45	substitution["AUTH_TOKEN"] = LLURI::escape(getAuthKey());
46
47	// get the home URL from the settings.xml file
48	std::string homeURL = gSavedSettings.getString("HomeSidePanelURL");
49
50	// support a grid-level override of the URL from login.cgi
51	LLSD grid_url = LLLoginInstance::getInstance()->getResponse("home_sidetray_url");
52	if (! grid_url.asString().empty())
53	{
54		homeURL = grid_url.asString();
55	}	
56
57	// expand all substitution strings in the URL and return it
58	// (also adds things like [LANGUAGE], [VERSION], [OS], etc.)
59	return LLWeb::expandURLSubstitutions(homeURL, substitution);
60}
61
62//static
63std::string LLViewerHome::getAuthKey()
64{
65	// return the value of the (optional) auth token returned by login.cgi
66	// this lets the server provide an authentication token that we can
67	// blindly pass to the Home web page for it to perform authentication.
68	// We use "home_sidetray_token", and fallback to "auth_token" if not
69	// present.
70	LLSD auth_token = LLLoginInstance::getInstance()->getResponse("home_sidetray_token");
71	if (auth_token.asString().empty())
72	{
73		auth_token = LLLoginInstance::getInstance()->getResponse("auth_token");
74	}
75	return auth_token.asString();
76}
77