PageRenderTime 20ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 1ms 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
 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
28#ifndef LL_LLURLACTION_H
29#define LL_LLURLACTION_H
30
31#include <string>
32#include <boost/function.hpp>
33
34///
35/// The LLUrlAction class provides a number of static functions that
36/// let you open Urls in web browsers, execute SLURLs, and copy Urls
37/// to the clipboard. Many of these functions are not available at
38/// the llui level, and must be supplied via a set of callbacks.
39///
40/// N.B. The action functions specifically do not use const ref
41/// strings so that a url parameter can be used into a boost::bind()
42/// call under situations when that input string is deallocated before
43/// the callback is executed.
44///
45class LLUrlAction
46{
47public:
48	LLUrlAction();
49
50	/// load a Url in the user's preferred web browser
51	static void openURL(std::string url);
52
53	/// load a Url in the internal Second Life web browser
54	static void openURLInternal(std::string url);
55
56	/// load a Url in the operating system's default web browser
57	static void openURLExternal(std::string url);
58
59	/// execute the given secondlife: SLURL
60	static void executeSLURL(std::string url);
61
62	/// if the Url specifies an SL location, teleport there
63	static void teleportToLocation(std::string url);
64
65	/// if the Url specifies an SL location, show it on a map
66	static void showLocationOnMap(std::string url);
67
68	/// perform the appropriate action for left-clicking on a Url
69	static void clickAction(std::string url);
70
71	/// copy the label for a Url to the clipboard
72	static void copyLabelToClipboard(std::string url);
73
74	/// copy a Url to the clipboard
75	static void copyURLToClipboard(std::string url);
76
77	/// if the Url specifies an SL command in the form like 'app/{cmd}/{id}/*', show its profile
78	static void showProfile(std::string url);
79
80	/// specify the callbacks to enable this class's functionality
81	typedef boost::function<void (const std::string&)> url_callback_t;
82	typedef boost::function<bool(const std::string& url)> execute_url_callback_t;
83
84	static void	setOpenURLCallback(url_callback_t cb);
85	static void	setOpenURLInternalCallback(url_callback_t cb);
86	static void	setOpenURLExternalCallback(url_callback_t cb);
87	static void	setExecuteSLURLCallback(execute_url_callback_t cb);
88
89private:
90	// callbacks for operations we can perform on Urls
91	static url_callback_t sOpenURLCallback;
92	static url_callback_t sOpenURLInternalCallback;
93	static url_callback_t sOpenURLExternalCallback;
94
95	static execute_url_callback_t sExecuteSLURLCallback;
96};
97
98#endif