aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llsdappservices.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmessage/llsdappservices.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llmessage/llsdappservices.cpp')
-rw-r--r--linden/indra/llmessage/llsdappservices.cpp278
1 files changed, 278 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llsdappservices.cpp b/linden/indra/llmessage/llsdappservices.cpp
new file mode 100644
index 0000000..d923b22
--- /dev/null
+++ b/linden/indra/llmessage/llsdappservices.cpp
@@ -0,0 +1,278 @@
1/**
2 * @file llsdappservices.cpp
3 * @author Phoenix
4 * @date 2006-09-12
5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 *
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#include "linden_common.h"
30#include "llsdappservices.h"
31
32#include "llapp.h"
33#include "llhttpnode.h"
34#include "llsdserialize.h"
35
36void LLSDAppServices::useServices()
37{
38 /*
39 Having this function body here, causes the classes and globals in this
40 file to be linked into any program that uses the llmessage library.
41 */
42}
43
44class LLHTTPConfigService : public LLHTTPNode
45{
46public:
47 virtual void describe(Description& desc) const
48 {
49 desc.shortInfo("GET an array of all the options in priority order.");
50 desc.getAPI();
51 desc.source(__FILE__, __LINE__);
52 }
53
54 virtual LLSD get() const
55 {
56 LLSD result;
57 LLApp* app = LLApp::instance();
58 for(int ii = 0; ii < LLApp::PRIORITY_COUNT; ++ii)
59 {
60 result.append(app->getOptionData((LLApp::OptionPriority)ii));
61 }
62 return result;
63 }
64};
65
66LLHTTPRegistration<LLHTTPConfigService>
67 gHTTPRegistratiAppConfig("/app/config");
68
69class LLHTTPConfigRuntimeService : public LLHTTPNode
70{
71public:
72 virtual void describe(Description& desc) const
73 {
74 desc.shortInfo("Manipulate a map of runtime-override options.");
75 desc.getAPI();
76 desc.postAPI();
77 desc.source(__FILE__, __LINE__);
78 }
79
80 virtual LLSD get() const
81 {
82 return LLApp::instance()->getOptionData(
83 LLApp::PRIORITY_RUNTIME_OVERRIDE);
84 }
85
86 virtual void post(
87 LLHTTPNode::ResponsePtr response,
88 const LLSD& context,
89 const LLSD& input) const
90 {
91 LLSD result = LLApp::instance()->getOptionData(
92 LLApp::PRIORITY_RUNTIME_OVERRIDE);
93 LLSD::map_const_iterator iter = input.beginMap();
94 LLSD::map_const_iterator end = input.endMap();
95 for(; iter != end; ++iter)
96 {
97 result[(*iter).first] = (*iter).second;
98 }
99 LLApp::instance()->setOptionData(
100 LLApp::PRIORITY_RUNTIME_OVERRIDE,
101 result);
102 response->result(result);
103 }
104};
105
106LLHTTPRegistration<LLHTTPConfigRuntimeService>
107 gHTTPRegistrationRuntimeConfig("/app/config/runtime-override");
108
109class LLHTTPConfigRuntimeSingleService : public LLHTTPNode
110{
111public:
112 virtual void describe(Description& desc) const
113 {
114 desc.shortInfo("Manipulate a single runtime-override option.");
115 desc.getAPI();
116 desc.putAPI();
117 desc.delAPI();
118 desc.source(__FILE__, __LINE__);
119 }
120
121 virtual bool validate(const std::string& name, LLSD& context) const
122 {
123 //llinfos << "validate: " << name << ", "
124 // << LLSDOStreamer<LLSDNotationFormatter>(context) << llendl;
125 if((std::string("PUT") == context["request"]["verb"].asString()) && !name.empty())
126 {
127 return true;
128 }
129 else
130 {
131 // This is for GET and DELETE
132 LLSD options = LLApp::instance()->getOptionData(
133 LLApp::PRIORITY_RUNTIME_OVERRIDE);
134 if(options.has(name)) return true;
135 else return false;
136 }
137 }
138
139 virtual void get(
140 LLHTTPNode::ResponsePtr response,
141 const LLSD& context) const
142 {
143 std::string name = context["request"]["wildcard"]["option-name"];
144 LLSD options = LLApp::instance()->getOptionData(
145 LLApp::PRIORITY_RUNTIME_OVERRIDE);
146 response->result(options[name]);
147 }
148
149 virtual void put(
150 LLHTTPNode::ResponsePtr response,
151 const LLSD& context,
152 const LLSD& input) const
153 {
154 std::string name = context["request"]["wildcard"]["option-name"];
155 LLSD options = LLApp::instance()->getOptionData(
156 LLApp::PRIORITY_RUNTIME_OVERRIDE);
157 options[name] = input;
158 LLApp::instance()->setOptionData(
159 LLApp::PRIORITY_RUNTIME_OVERRIDE,
160 options);
161 response->result(input);
162 }
163
164 virtual void del(
165 LLHTTPNode::ResponsePtr response,
166 const LLSD& context) const
167 {
168 std::string name = context["request"]["wildcard"]["option-name"];
169 LLSD options = LLApp::instance()->getOptionData(
170 LLApp::PRIORITY_RUNTIME_OVERRIDE);
171 options.erase(name);
172 LLApp::instance()->setOptionData(
173 LLApp::PRIORITY_RUNTIME_OVERRIDE,
174 options);
175 response->result(LLSD());
176 }
177};
178
179LLHTTPRegistration<LLHTTPConfigRuntimeSingleService>
180 gHTTPRegistrationRuntimeSingleConfig(
181 "/app/config/runtime-override/<option-name>");
182
183template<int PRIORITY>
184class LLHTTPConfigPriorityService : public LLHTTPNode
185{
186public:
187 virtual void describe(Description& desc) const
188 {
189 desc.shortInfo("Get a map of the options at this priority.");
190 desc.getAPI();
191 desc.source(__FILE__, __LINE__);
192 }
193
194 virtual void get(
195 LLHTTPNode::ResponsePtr response,
196 const LLSD& context) const
197 {
198 response->result(LLApp::instance()->getOptionData(
199 (LLApp::OptionPriority)PRIORITY));
200 }
201};
202
203LLHTTPRegistration< LLHTTPConfigPriorityService<LLApp::PRIORITY_COMMAND_LINE> >
204 gHTTPRegistrationCommandLineConfig("/app/config/command-line");
205LLHTTPRegistration<
206 LLHTTPConfigPriorityService<LLApp::PRIORITY_SPECIFIC_CONFIGURATION> >
207 gHTTPRegistrationSpecificConfig("/app/config/specific");
208LLHTTPRegistration<
209 LLHTTPConfigPriorityService<LLApp::PRIORITY_GENERAL_CONFIGURATION> >
210 gHTTPRegistrationGeneralConfig("/app/config/general");
211LLHTTPRegistration< LLHTTPConfigPriorityService<LLApp::PRIORITY_DEFAULT> >
212 gHTTPRegistrationDefaultConfig("/app/config/default");
213
214class LLHTTPLiveConfigService : public LLHTTPNode
215{
216public:
217 virtual void describe(Description& desc) const
218 {
219 desc.shortInfo("Get a map of the currently live options.");
220 desc.getAPI();
221 desc.source(__FILE__, __LINE__);
222 }
223
224 virtual void get(
225 LLHTTPNode::ResponsePtr response,
226 const LLSD& context) const
227 {
228 LLSD result;
229 LLApp* app = LLApp::instance();
230 LLSD::map_const_iterator iter;
231 LLSD::map_const_iterator end;
232 for(int ii = LLApp::PRIORITY_COUNT - 1; ii >= 0; --ii)
233 {
234 LLSD options = app->getOptionData((LLApp::OptionPriority)ii);
235 iter = options.beginMap();
236 end = options.endMap();
237 for(; iter != end; ++iter)
238 {
239 result[(*iter).first] = (*iter).second;
240 }
241 }
242 response->result(result);
243 }
244};
245
246LLHTTPRegistration<LLHTTPLiveConfigService>
247 gHTTPRegistrationLiveConfig("/app/config/live");
248
249class LLHTTPLiveConfigSingleService : public LLHTTPNode
250{
251public:
252 virtual void describe(Description& desc) const
253 {
254 desc.shortInfo("Get the named live option.");
255 desc.getAPI();
256 desc.source(__FILE__, __LINE__);
257 }
258
259 virtual bool validate(const std::string& name, LLSD& context) const
260 {
261 llinfos << "LLHTTPLiveConfigSingleService::validate(" << name
262 << ")" << llendl;
263 LLSD option = LLApp::instance()->getOption(name);
264 if(option) return true;
265 else return false;
266 }
267
268 virtual void get(
269 LLHTTPNode::ResponsePtr response,
270 const LLSD& context) const
271 {
272 std::string name = context["request"]["wildcard"]["option-name"];
273 response->result(LLApp::instance()->getOption(name));
274 }
275};
276
277LLHTTPRegistration<LLHTTPLiveConfigSingleService>
278 gHTTPRegistrationLiveSingleConfig("/app/config/live/<option-name>");