PageRenderTime 69ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llui/llurlaction.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 98 lines | 31 code | 18 blank | 49 comment | 0 complexity | 7325a66b0948cdede5804195f0611a3c MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llurlaction.h
  3. * @author Martin Reddy
  4. * @brief A set of actions that can performed on Urls
  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. #ifndef LL_LLURLACTION_H
  28. #define LL_LLURLACTION_H
  29. #include <string>
  30. #include <boost/function.hpp>
  31. ///
  32. /// The LLUrlAction class provides a number of static functions that
  33. /// let you open Urls in web browsers, execute SLURLs, and copy Urls
  34. /// to the clipboard. Many of these functions are not available at
  35. /// the llui level, and must be supplied via a set of callbacks.
  36. ///
  37. /// N.B. The action functions specifically do not use const ref
  38. /// strings so that a url parameter can be used into a boost::bind()
  39. /// call under situations when that input string is deallocated before
  40. /// the callback is executed.
  41. ///
  42. class LLUrlAction
  43. {
  44. public:
  45. LLUrlAction();
  46. /// load a Url in the user's preferred web browser
  47. static void openURL(std::string url);
  48. /// load a Url in the internal Second Life web browser
  49. static void openURLInternal(std::string url);
  50. /// load a Url in the operating system's default web browser
  51. static void openURLExternal(std::string url);
  52. /// execute the given secondlife: SLURL
  53. static void executeSLURL(std::string url);
  54. /// if the Url specifies an SL location, teleport there
  55. static void teleportToLocation(std::string url);
  56. /// if the Url specifies an SL location, show it on a map
  57. static void showLocationOnMap(std::string url);
  58. /// perform the appropriate action for left-clicking on a Url
  59. static void clickAction(std::string url);
  60. /// copy the label for a Url to the clipboard
  61. static void copyLabelToClipboard(std::string url);
  62. /// copy a Url to the clipboard
  63. static void copyURLToClipboard(std::string url);
  64. /// if the Url specifies an SL command in the form like 'app/{cmd}/{id}/*', show its profile
  65. static void showProfile(std::string url);
  66. /// specify the callbacks to enable this class's functionality
  67. typedef boost::function<void (const std::string&)> url_callback_t;
  68. typedef boost::function<bool(const std::string& url)> execute_url_callback_t;
  69. static void setOpenURLCallback(url_callback_t cb);
  70. static void setOpenURLInternalCallback(url_callback_t cb);
  71. static void setOpenURLExternalCallback(url_callback_t cb);
  72. static void setExecuteSLURLCallback(execute_url_callback_t cb);
  73. private:
  74. // callbacks for operations we can perform on Urls
  75. static url_callback_t sOpenURLCallback;
  76. static url_callback_t sOpenURLInternalCallback;
  77. static url_callback_t sOpenURLExternalCallback;
  78. static execute_url_callback_t sExecuteSLURLCallback;
  79. };
  80. #endif