PageRenderTime 102ms CodeModel.GetById 7ms RepoModel.GetById 1ms app.codeStats 0ms

/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
Possible License(s): LGPL-2.1
  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. #include "llviewerprecompiledheaders.h"
  28. #include "llviewerhome.h"
  29. #include "lllogininstance.h"
  30. #include "llsd.h"
  31. #include "llui.h"
  32. #include "lluri.h"
  33. #include "llviewercontrol.h"
  34. #include "llweb.h"
  35. //static
  36. std::string LLViewerHome::getHomeURL()
  37. {
  38. // Return the URL to display in the Home side tray. We read
  39. // this value from settings.xml and support various substitutions
  40. LLSD substitution;
  41. substitution["AUTH_TOKEN"] = LLURI::escape(getAuthKey());
  42. // get the home URL from the settings.xml file
  43. std::string homeURL = gSavedSettings.getString("HomeSidePanelURL");
  44. // support a grid-level override of the URL from login.cgi
  45. LLSD grid_url = LLLoginInstance::getInstance()->getResponse("home_sidetray_url");
  46. if (! grid_url.asString().empty())
  47. {
  48. homeURL = grid_url.asString();
  49. }
  50. // expand all substitution strings in the URL and return it
  51. // (also adds things like [LANGUAGE], [VERSION], [OS], etc.)
  52. return LLWeb::expandURLSubstitutions(homeURL, substitution);
  53. }
  54. //static
  55. std::string LLViewerHome::getAuthKey()
  56. {
  57. // return the value of the (optional) auth token returned by login.cgi
  58. // this lets the server provide an authentication token that we can
  59. // blindly pass to the Home web page for it to perform authentication.
  60. // We use "home_sidetray_token", and fallback to "auth_token" if not
  61. // present.
  62. LLSD auth_token = LLLoginInstance::getInstance()->getResponse("home_sidetray_token");
  63. if (auth_token.asString().empty())
  64. {
  65. auth_token = LLLoginInstance::getInstance()->getResponse("auth_token");
  66. }
  67. return auth_token.asString();
  68. }