PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llviewerhelputil.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 67 lines | 26 code | 7 blank | 34 comment | 0 complexity | 54c1b373955840856da3ba36fca1cf44 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llviewerhelp.cpp
  3. * @brief Utility functions for the Help system
  4. * @author Soft Linden
  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 "llviewerhelputil.h"
  29. #include "llagent.h"
  30. #include "llsd.h"
  31. #include "llstring.h"
  32. #include "lluri.h"
  33. #include "llweb.h"
  34. #include "llviewercontrol.h"
  35. //////////////////////////////////////////////
  36. // Build a help URL from a topic and formatter
  37. //static
  38. std::string LLViewerHelpUtil::helpURLEncode( const std::string &component )
  39. {
  40. // Every character rfc3986 allows as unreserved in 2.3, minus the tilde
  41. // which we may grant special meaning. Yay.
  42. const char* allowed =
  43. "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  44. "abcdefghijklmnopqrstuvwxyz"
  45. "0123456789"
  46. "-._";
  47. std::string escaped = LLURI::escape(component, allowed);
  48. return escaped;
  49. }
  50. //static
  51. std::string LLViewerHelpUtil::buildHelpURL( const std::string &topic)
  52. {
  53. LLSD substitution;
  54. substitution["TOPIC"] = helpURLEncode(topic);
  55. substitution["DEBUG_MODE"] = gAgent.isGodlike() ? "/debug" : "";
  56. // get the help URL and expand all of the substitutions
  57. // (also adds things like [LANGUAGE], [VERSION], [OS], etc.)
  58. std::string helpURL = gSavedSettings.getString("HelpURLFormat");
  59. return LLWeb::expandURLSubstitutions(helpURL, substitution);
  60. }