aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EstateChangeInfo.cs228
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs46
2 files changed, 250 insertions, 24 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EstateChangeInfo.cs b/OpenSim/Region/ClientStack/Linden/Caps/EstateChangeInfo.cs
new file mode 100644
index 0000000..4e2b660
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EstateChangeInfo.cs
@@ -0,0 +1,228 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using System.Reflection;
33
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using OpenMetaverse.StructuredData;
38using Mono.Addins;
39
40using OpenSim.Framework;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes;
44using Caps=OpenSim.Framework.Capabilities.Caps;
45
46namespace OpenSim.Region.ClientStack.Linden
47{
48 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EstateChangeInfoCapModule")]
49 public class EstateChangeInfoCapModule : INonSharedRegionModule
50 {
51 private static readonly ILog m_log =
52 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53
54 private Scene m_scene;
55 private bool m_Enabled = false;
56 private string m_capUrl;
57 IEstateModule m_EstateModule;
58
59 #region INonSharedRegionModule Members
60
61 public void Initialise(IConfigSource pSource)
62 {
63 IConfig config = pSource.Configs["ClientStack.LindenCaps"];
64 if (config == null)
65 return;
66
67 m_capUrl = config.GetString("Cap_EstateChangeInfo", string.Empty);
68 if (!String.IsNullOrEmpty(m_capUrl) && m_capUrl.Equals("localhost"))
69 m_Enabled = true;
70 }
71
72 public void AddRegion(Scene scene)
73 {
74 if (!m_Enabled)
75 return;
76
77 m_scene = scene;
78 }
79
80 public void RemoveRegion(Scene scene)
81 {
82 if (!m_Enabled)
83 return;
84
85 if (m_scene == scene)
86 {
87 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
88 m_scene = null;
89 }
90 }
91
92 public void RegionLoaded(Scene scene)
93 {
94 if (!m_Enabled)
95 return;
96
97 if (scene.RegionInfo == null || scene.RegionInfo.EstateSettings == null)
98 {
99 m_Enabled = false;
100 return;
101 }
102
103 m_EstateModule = scene.RequestModuleInterface<IEstateModule>();
104 if(m_EstateModule == null)
105 {
106 m_Enabled = false;
107 return;
108 }
109
110 scene.EventManager.OnRegisterCaps += RegisterCaps;
111 }
112
113 public void Close()
114 {
115 }
116
117 public string Name
118 {
119 get { return "EstateChangeInfoCapModule"; }
120 }
121
122 public Type ReplaceableInterface
123 {
124 get { return null; }
125 }
126
127 #endregion
128
129 public void RegisterCaps(UUID agentID, Caps caps)
130 {
131 string capUrl = "/CAPS/" + UUID.Random() + "/";
132
133 caps.RegisterHandler(
134 "EstateChangeInfo",
135 new RestHTTPHandler(
136 "POST",
137 capUrl,
138 httpMethod => ProcessRequest(httpMethod, agentID, caps),
139 "EstateChangeInfo",
140 agentID.ToString())); ;
141 }
142
143 public Hashtable ProcessRequest(Hashtable request, UUID AgentId, Caps cap)
144 {
145 Hashtable responsedata = new Hashtable();
146
147 ScenePresence avatar;
148 if (!m_scene.TryGetScenePresence(AgentId, out avatar) || !m_scene.Permissions.CanIssueEstateCommand(AgentId, false))
149 {
150 responsedata["int_response_code"] = 401;
151 responsedata["str_response_string"] = LLSDxmlEncode.LLSDEmpty;
152 responsedata["keepalive"] = false;
153 return responsedata;
154 }
155
156 if (m_scene.RegionInfo == null
157 || m_scene.RegionInfo.EstateSettings == null)
158 {
159 responsedata["int_response_code"] = 501;
160 responsedata["str_response_string"] = LLSDxmlEncode.LLSDEmpty;
161 responsedata["keepalive"] = false;
162 return responsedata;
163 }
164
165 OSDMap r;
166
167 try
168 {
169 r = (OSDMap)OSDParser.Deserialize((string)request["requestbody"]);
170 }
171 catch (Exception ex)
172 {
173 m_log.Error("[UPLOAD OBJECT ASSET MODULE]: Error deserializing message " + ex.ToString());
174 r = null;
175 }
176
177 if (r == null)
178 {
179 responsedata["int_response_code"] = 400; //501; //410; //404;
180 responsedata["content_type"] = "text/plain";
181 responsedata["keepalive"] = false;
182 responsedata["str_response_string"] = LLSDxmlEncode.LLSDEmpty;
183 return responsedata;
184 }
185
186 bool ok = true;
187 try
188 {
189 string estateName = r["estate_name"].AsString();
190 UUID invoice = r["invoice"].AsUUID();
191 int sunHour = r["sun_hour"].AsInteger();
192 bool sunFixed = r["is_sun_fixed"].AsBoolean();
193 bool externallyVisible = r["is_externally_visible"].AsBoolean();
194 bool allowDirectTeleport = r["allow_direct_teleport"].AsBoolean();
195 bool denyAnonymous = r["deny_anonymous"].AsBoolean();
196 bool denyAgeUnverified = r["deny_age_unverified"].AsBoolean();
197 bool alloVoiceChat = r["allow_voice_chat"].AsBoolean();
198 // taxfree is now AllowAccessOverride
199 bool overridePublicAccess = m_scene.RegionInfo.EstateSettings.TaxFree;
200 if (r.ContainsKey("override_public_access"))
201 overridePublicAccess = r["override_public_access"].AsBoolean();
202
203 ok = m_EstateModule.handleEstateChangeInfoCap(estateName, invoice, sunHour, sunFixed,
204 externallyVisible, allowDirectTeleport, denyAnonymous, denyAgeUnverified,
205 alloVoiceChat, overridePublicAccess);
206 }
207 catch
208 {
209 ok = false;
210 }
211
212 if(ok)
213 {
214 responsedata["int_response_code"] = 200;
215 responsedata["content_type"] = "text/plain";
216 responsedata["str_response_string"] = LLSDxmlEncode.LLSDEmpty;
217 }
218 else
219 {
220 responsedata["int_response_code"] = 400; //501; //410; //404;
221 responsedata["content_type"] = "text/plain";
222 responsedata["keepalive"] = false;
223 responsedata["str_response_string"] = LLSDxmlEncode.LLSDEmpty;
224 }
225 return responsedata;
226 }
227 }
228}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs
index adb49bd..a33607f 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs
@@ -161,34 +161,34 @@ namespace OpenSim.Region.ClientStack.Linden
161 int lastattach = 0; 161 int lastattach = 0;
162 162
163 OSDMap rm = (OSDMap)r; 163 OSDMap rm = (OSDMap)r;
164 164 OSD tmpOSD;
165 if (rm.ContainsKey("ObjectData")) //v2 165 if (rm.TryGetValue("ObjectData", out tmpOSD)) //v2
166 { 166 {
167 if (rm["ObjectData"].Type != OSDType.Map) 167 if (tmpOSD.Type != OSDType.Map)
168 { 168 {
169 responsedata["str_response_string"] = "Has ObjectData key, but data not in expected format"; 169 responsedata["str_response_string"] = "Has ObjectData key, but data not in expected format";
170 return responsedata; 170 return responsedata;
171 } 171 }
172 172
173 OSDMap ObjMap = (OSDMap)rm["ObjectData"]; 173 OSDMap ObjMap = (OSDMap)tmpOSD;
174 174
175 bypass_raycast = ObjMap["BypassRaycast"].AsBoolean(); 175 bypass_raycast = ObjMap["BypassRaycast"].AsBoolean();
176 everyone_mask = readuintval(ObjMap["EveryoneMask"]); 176 everyone_mask = ReadUIntVal(ObjMap["EveryoneMask"]);
177 flags = readuintval(ObjMap["Flags"]); 177 flags = ReadUIntVal(ObjMap["Flags"]);
178 group_mask = readuintval(ObjMap["GroupMask"]); 178 group_mask = ReadUIntVal(ObjMap["GroupMask"]);
179 material = ObjMap["Material"].AsInteger(); 179 material = ObjMap["Material"].AsInteger();
180 next_owner_mask = readuintval(ObjMap["NextOwnerMask"]); 180 next_owner_mask = ReadUIntVal(ObjMap["NextOwnerMask"]);
181 p_code = ObjMap["PCode"].AsInteger(); 181 p_code = ObjMap["PCode"].AsInteger();
182 182
183 if (ObjMap.ContainsKey("Path")) 183 if (ObjMap.TryGetValue("Path", out tmpOSD))
184 { 184 {
185 if (ObjMap["Path"].Type != OSDType.Map) 185 if (tmpOSD.Type != OSDType.Map)
186 { 186 {
187 responsedata["str_response_string"] = "Has Path key, but data not in expected format"; 187 responsedata["str_response_string"] = "Has Path key, but data not in expected format";
188 return responsedata; 188 return responsedata;
189 } 189 }
190 190
191 OSDMap PathMap = (OSDMap)ObjMap["Path"]; 191 OSDMap PathMap = (OSDMap)tmpOSD;
192 path_begin = PathMap["Begin"].AsInteger(); 192 path_begin = PathMap["Begin"].AsInteger();
193 path_curve = PathMap["Curve"].AsInteger(); 193 path_curve = PathMap["Curve"].AsInteger();
194 path_end = PathMap["End"].AsInteger(); 194 path_end = PathMap["End"].AsInteger();
@@ -203,18 +203,17 @@ namespace OpenSim.Region.ClientStack.Linden
203 path_taper_y = PathMap["TaperY"].AsInteger(); 203 path_taper_y = PathMap["TaperY"].AsInteger();
204 path_twist = PathMap["Twist"].AsInteger(); 204 path_twist = PathMap["Twist"].AsInteger();
205 path_twist_begin = PathMap["TwistBegin"].AsInteger(); 205 path_twist_begin = PathMap["TwistBegin"].AsInteger();
206
207 } 206 }
208 207
209 if (ObjMap.ContainsKey("Profile")) 208 if (ObjMap.TryGetValue("Profile", out tmpOSD))
210 { 209 {
211 if (ObjMap["Profile"].Type != OSDType.Map) 210 if (tmpOSD.Type != OSDType.Map)
212 { 211 {
213 responsedata["str_response_string"] = "Has Profile key, but data not in expected format"; 212 responsedata["str_response_string"] = "Has Profile key, but data not in expected format";
214 return responsedata; 213 return responsedata;
215 } 214 }
216 215
217 OSDMap ProfileMap = (OSDMap)ObjMap["Profile"]; 216 OSDMap ProfileMap = (OSDMap)tmpOSD;
218 217
219 profile_begin = ProfileMap["Begin"].AsInteger(); 218 profile_begin = ProfileMap["Begin"].AsInteger();
220 profile_curve = ProfileMap["Curve"].AsInteger(); 219 profile_curve = ProfileMap["Curve"].AsInteger();
@@ -239,15 +238,15 @@ namespace OpenSim.Region.ClientStack.Linden
239 return responsedata; 238 return responsedata;
240 } 239 }
241 240
242 if (rm.ContainsKey("AgentData")) 241 if (rm.TryGetValue("AgentData", out tmpOSD))
243 { 242 {
244 if (rm["AgentData"].Type != OSDType.Map) 243 if (tmpOSD.Type != OSDType.Map)
245 { 244 {
246 responsedata["str_response_string"] = "Has AgentData key, but data not in expected format"; 245 responsedata["str_response_string"] = "Has AgentData key, but data not in expected format";
247 return responsedata; 246 return responsedata;
248 } 247 }
249 248
250 OSDMap AgentDataMap = (OSDMap)rm["AgentData"]; 249 OSDMap AgentDataMap = (OSDMap)tmpOSD;
251 250
252 //session_id = AgentDataMap["SessionId"].AsUUID(); 251 //session_id = AgentDataMap["SessionId"].AsUUID();
253 group_id = AgentDataMap["GroupId"].AsUUID(); 252 group_id = AgentDataMap["GroupId"].AsUUID();
@@ -258,13 +257,13 @@ namespace OpenSim.Region.ClientStack.Linden
258 { //v1 257 { //v1
259 bypass_raycast = rm["bypass_raycast"].AsBoolean(); 258 bypass_raycast = rm["bypass_raycast"].AsBoolean();
260 259
261 everyone_mask = readuintval(rm["everyone_mask"]); 260 everyone_mask = ReadUIntVal(rm["everyone_mask"]);
262 flags = readuintval(rm["flags"]); 261 flags = ReadUIntVal(rm["flags"]);
263 group_id = rm["group_id"].AsUUID(); 262 group_id = rm["group_id"].AsUUID();
264 group_mask = readuintval(rm["group_mask"]); 263 group_mask = ReadUIntVal(rm["group_mask"]);
265 hollow = rm["hollow"].AsInteger(); 264 hollow = rm["hollow"].AsInteger();
266 material = rm["material"].AsInteger(); 265 material = rm["material"].AsInteger();
267 next_owner_mask = readuintval(rm["next_owner_mask"]); 266 next_owner_mask = ReadUIntVal(rm["next_owner_mask"]);
268 hollow = rm["hollow"].AsInteger(); 267 hollow = rm["hollow"].AsInteger();
269 p_code = rm["p_code"].AsInteger(); 268 p_code = rm["p_code"].AsInteger();
270 path_begin = rm["path_begin"].AsInteger(); 269 path_begin = rm["path_begin"].AsInteger();
@@ -344,7 +343,6 @@ namespace OpenSim.Region.ClientStack.Linden
344 obj = m_scene.AddNewPrim(avatar.UUID, group_id, pos, rotation, pbs); 343 obj = m_scene.AddNewPrim(avatar.UUID, group_id, pos, rotation, pbs);
345 } 344 }
346 345
347
348 if (obj == null) 346 if (obj == null)
349 return responsedata; 347 return responsedata;
350 348
@@ -369,7 +367,7 @@ namespace OpenSim.Region.ClientStack.Linden
369 return responsedata; 367 return responsedata;
370 } 368 }
371 369
372 private uint readuintval(OSD obj) 370 private uint ReadUIntVal(OSD obj)
373 { 371 {
374 byte[] tmp = obj.AsBinary(); 372 byte[] tmp = obj.AsBinary();
375 if (BitConverter.IsLittleEndian) 373 if (BitConverter.IsLittleEndian)