diff options
author | Jacek Antonelli | 2008-08-15 23:45:27 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:27 -0500 |
commit | a8a62201ba762e98dff92cf49033e577fc34d8d4 (patch) | |
tree | 11f8513c5cdc222f2fac0c93eb724c089803c200 /linden/indra/newview/llcommandhandler.cpp | |
parent | Second Life viewer sources 1.18.6.4-RC (diff) | |
download | meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.zip meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.gz meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.bz2 meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.xz |
Second Life viewer sources 1.19.0.0
Diffstat (limited to 'linden/indra/newview/llcommandhandler.cpp')
-rw-r--r-- | linden/indra/newview/llcommandhandler.cpp | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/linden/indra/newview/llcommandhandler.cpp b/linden/indra/newview/llcommandhandler.cpp index 5c44937..6e7014c 100644 --- a/linden/indra/newview/llcommandhandler.cpp +++ b/linden/indra/newview/llcommandhandler.cpp | |||
@@ -14,12 +14,12 @@ | |||
14 | * ("GPL"), unless you have obtained a separate licensing agreement | 14 | * ("GPL"), unless you have obtained a separate licensing agreement |
15 | * ("Other License"), formally executed by you and Linden Lab. Terms of | 15 | * ("Other License"), formally executed by you and Linden Lab. Terms of |
16 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | 16 | * the GPL can be found in doc/GPL-license.txt in this distribution, or |
17 | * online at http://secondlife.com/developers/opensource/gplv2 | 17 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 |
18 | * | 18 | * |
19 | * There are special exceptions to the terms and conditions of the GPL as | 19 | * There are special exceptions to the terms and conditions of the GPL as |
20 | * it is applied to this Source Code. View the full text of the exception | 20 | * it is applied to this Source Code. View the full text of the exception |
21 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 21 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
22 | * online at http://secondlife.com/developers/opensource/flossexception | 22 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception |
23 | * | 23 | * |
24 | * By copying, modifying or distributing this software, you acknowledge | 24 | * By copying, modifying or distributing this software, you acknowledge |
25 | * that you have read and understood your obligations described above, | 25 | * that you have read and understood your obligations described above, |
@@ -40,16 +40,21 @@ | |||
40 | //--------------------------------------------------------------------------- | 40 | //--------------------------------------------------------------------------- |
41 | // Underlying registry for command handlers, not directly accessible. | 41 | // Underlying registry for command handlers, not directly accessible. |
42 | //--------------------------------------------------------------------------- | 42 | //--------------------------------------------------------------------------- |
43 | struct LLCommandHandlerInfo | ||
44 | { | ||
45 | bool mAllowFromExternalBrowser; | ||
46 | LLCommandHandler* mHandler; // safe, all of these are static objects | ||
47 | }; | ||
43 | 48 | ||
44 | class LLCommandHandlerRegistry | 49 | class LLCommandHandlerRegistry |
45 | { | 50 | { |
46 | public: | 51 | public: |
47 | static LLCommandHandlerRegistry& instance(); | 52 | static LLCommandHandlerRegistry& instance(); |
48 | void add(const char* cmd, LLCommandHandler* handler); | 53 | void add(const char* cmd, bool allow_from_external_browser, LLCommandHandler* handler); |
49 | bool dispatch(const std::string& cmd, const LLSD& params, const LLSD& queryMap); | 54 | bool dispatch(const std::string& cmd, bool from_external_browser, const LLSD& params, const LLSD& queryMap); |
50 | 55 | ||
51 | private: | 56 | private: |
52 | std::map<std::string, LLCommandHandler*> mMap; | 57 | std::map<std::string, LLCommandHandlerInfo> mMap; |
53 | }; | 58 | }; |
54 | 59 | ||
55 | // static | 60 | // static |
@@ -62,29 +67,40 @@ LLCommandHandlerRegistry& LLCommandHandlerRegistry::instance() | |||
62 | return instance; | 67 | return instance; |
63 | } | 68 | } |
64 | 69 | ||
65 | void LLCommandHandlerRegistry::add(const char* cmd, LLCommandHandler* handler) | 70 | void LLCommandHandlerRegistry::add(const char* cmd, bool allow_from_external_browser, LLCommandHandler* handler) |
66 | { | 71 | { |
67 | mMap[cmd] = handler; | 72 | LLCommandHandlerInfo info; |
73 | info.mAllowFromExternalBrowser = allow_from_external_browser; | ||
74 | info.mHandler = handler; | ||
75 | |||
76 | mMap[cmd] = info; | ||
68 | } | 77 | } |
69 | 78 | ||
70 | bool LLCommandHandlerRegistry::dispatch(const std::string& cmd, | 79 | bool LLCommandHandlerRegistry::dispatch(const std::string& cmd, |
80 | bool from_external_browser, | ||
71 | const LLSD& params, | 81 | const LLSD& params, |
72 | const LLSD& queryMap) | 82 | const LLSD& queryMap) |
73 | { | 83 | { |
74 | std::map<std::string, LLCommandHandler*>::iterator it = mMap.find(cmd); | 84 | std::map<std::string, LLCommandHandlerInfo>::iterator it = mMap.find(cmd); |
75 | if (it == mMap.end()) return false; | 85 | if (it == mMap.end()) return false; |
76 | LLCommandHandler* handler = it->second; | 86 | const LLCommandHandlerInfo& info = it->second; |
77 | if (!handler) return false; | 87 | if (from_external_browser && !info.mAllowFromExternalBrowser) |
78 | return handler->handle(params, queryMap); | 88 | { |
89 | // block request from external browser, but report as | ||
90 | // "handled" because it was well formatted. | ||
91 | return true; | ||
92 | } | ||
93 | if (!info.mHandler) return false; | ||
94 | return info.mHandler->handle(params, queryMap); | ||
79 | } | 95 | } |
80 | 96 | ||
81 | //--------------------------------------------------------------------------- | 97 | //--------------------------------------------------------------------------- |
82 | // Automatic registration of commands, runs before main() | 98 | // Automatic registration of commands, runs before main() |
83 | //--------------------------------------------------------------------------- | 99 | //--------------------------------------------------------------------------- |
84 | 100 | ||
85 | LLCommandHandler::LLCommandHandler(const char* cmd) | 101 | LLCommandHandler::LLCommandHandler(const char* cmd, bool allow_from_external_browser) |
86 | { | 102 | { |
87 | LLCommandHandlerRegistry::instance().add(cmd, this); | 103 | LLCommandHandlerRegistry::instance().add(cmd, allow_from_external_browser, this); |
88 | } | 104 | } |
89 | 105 | ||
90 | LLCommandHandler::~LLCommandHandler() | 106 | LLCommandHandler::~LLCommandHandler() |
@@ -98,7 +114,10 @@ LLCommandHandler::~LLCommandHandler() | |||
98 | //--------------------------------------------------------------------------- | 114 | //--------------------------------------------------------------------------- |
99 | 115 | ||
100 | // static | 116 | // static |
101 | bool LLCommandDispatcher::dispatch(const std::string& cmd, const LLSD& params, const LLSD& queryMap) | 117 | bool LLCommandDispatcher::dispatch(const std::string& cmd, |
118 | bool from_external_browser, | ||
119 | const LLSD& params, const LLSD& queryMap) | ||
102 | { | 120 | { |
103 | return LLCommandHandlerRegistry::instance().dispatch(cmd, params, queryMap); | 121 | return LLCommandHandlerRegistry::instance().dispatch( |
122 | cmd, from_external_browser, params, queryMap); | ||
104 | } | 123 | } |