aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llsdmessagesystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmessage/llsdmessagesystem.cpp')
-rw-r--r--linden/indra/llmessage/llsdmessagesystem.cpp176
1 files changed, 0 insertions, 176 deletions
diff --git a/linden/indra/llmessage/llsdmessagesystem.cpp b/linden/indra/llmessage/llsdmessagesystem.cpp
deleted file mode 100644
index 66382ea..0000000
--- a/linden/indra/llmessage/llsdmessagesystem.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
1/**
2 * @file llsdmessagesystem.cpp
3 * @brief LLSDMessageSystem class implementation
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "linden_common.h"
29#include "llsdmessagesystem.h"
30
31#include "llhttpnode.h"
32#include "llsdutil.h"
33
34LLSDMessageSystem::LLSDMessageSystem() : mMsg(* new LLMessageSystem())
35{
36}
37
38LLSDMessageSystem::LLSDMessageSystem(LLMessageSystem& delegateSystem) : mMsg(delegateSystem)
39{
40}
41
42LLSDMessageSystem::~LLSDMessageSystem()
43{
44}
45
46bool LLSDMessageSystem::handleMessage(std::string name, const LLSD& message)
47{
48 setInput(message);
49 return mMsg.callHandler(name.c_str(), false, this);
50}
51
52void LLSDMessageSystem::setInput(const LLSD& input)
53{
54 mInput = input;
55}
56
57LLSD getLLSD(const LLSD& input, const char* block, const char* var, S32 blocknum)
58{
59 if(input[block].isArray())
60 {
61 return input[block][blocknum][var];
62 }
63 return input[block][var];
64}
65
66//virtual
67void LLSDMessageSystem::getU32Fast(const char *block, const char *var, U32 &data, S32 blocknum)
68{
69 data = ll_U32_from_sd(getLLSD(mInput, block, var, blocknum));
70}
71
72//virtual
73void LLSDMessageSystem::getUUIDFast(const char *block, const char *var, LLUUID &uuid, S32 blocknum)
74{
75 uuid = getLLSD(mInput, block, var, blocknum).asUUID();
76}
77
78//virtual
79void LLSDMessageSystem::getIPAddrFast(const char *block, const char *var, U32 &ip, S32 blocknum)
80{
81 ip = ll_ipaddr_from_sd(getLLSD(mInput, block, var, blocknum));
82}
83
84//virtual
85void LLSDMessageSystem::getIPPortFast(const char *block, const char *var, U16 &port, S32 blocknum)
86{
87 port = getLLSD(mInput, block, var, blocknum).asInteger();
88}
89
90//virtual
91void LLSDMessageSystem::getU64Fast(const char *block, const char *var, U64 &data, S32 blocknum)
92{
93 data = ll_U64_from_sd(getLLSD(mInput, block, var, blocknum));
94}
95
96//virtual
97void LLSDMessageSystem::getStringFast(const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum)
98{
99 std::string data = getLLSD(mInput, block, var, blocknum).asString();
100 S32 length = data.length();
101 memset(buffer, 0, buffer_size);
102 strncpy(buffer, data.c_str(), llmin(length, buffer_size)); /* Flawfinder: ignore */
103}
104
105//virtual
106void LLSDMessageSystem::newMessageFast(const char *name)
107{
108 mMsg.newMessageFast(name);
109}
110
111//virtual
112void LLSDMessageSystem::nextBlockFast(const char *blockname)
113{
114 mMsg.nextBlockFast(blockname);
115}
116
117//virtual
118void LLSDMessageSystem::addU32Fast(const char *varname, U32 u)
119{
120 mMsg.addU32Fast(varname, u);
121}
122
123//virtual
124void LLSDMessageSystem::addUUIDFast( const char *varname, const LLUUID& uuid)
125{
126 mMsg.addUUIDFast(varname, uuid);
127}
128
129//virtual
130S32 LLSDMessageSystem::sendReliable(const LLHost &host)
131{
132 return mMsg.sendReliable(host);
133}
134
135//virtual
136U32 LLSDMessageSystem::getOurCircuitCode()
137{
138 return mMsg.getOurCircuitCode();
139}
140
141void LLSDMessageSystem::useServices()
142{
143 /*
144 Having this function body here, causes the classes and globals in this
145 file to be linked into any program that uses the llmessage library.
146 */
147}
148
149class LLMessageService : public LLHTTPNode
150{
151 virtual bool validate(const std::string& name, LLSD& context) const
152 { return true; }
153
154 virtual void post(LLHTTPNode::ResponsePtr response, const LLSD& context, const LLSD& input) const;
155};
156
157//virtual
158void LLMessageService::post(LLHTTPNode::ResponsePtr response, const LLSD& context, const LLSD& input) const
159{
160 static LLSDMessageSystem msg(*gMessageSystem);
161
162 std::string name = context["request"]["wildcard"]["message-name"];
163
164 if (msg.handleMessage(name, input))
165 {
166 response->result(LLSD());
167 }
168 else
169 {
170 response->notFound();
171 }
172}
173
174
175LLHTTPRegistration<LLMessageService>
176 gHTTPRegistrationMessageService("/message/<message-name>");