diff options
author | UbitUmarov | 2019-08-07 21:06:20 +0100 |
---|---|---|
committer | UbitUmarov | 2019-08-07 21:06:20 +0100 |
commit | c043008e04c3cb25b9fc4db62ed064775216d066 (patch) | |
tree | b485825903552d522384fb49c39499226c0399a2 /OpenSim/Region/ClientStack/Linden/Caps/EstateChangeInfo.cs | |
parent | Remove debug output i left in (diff) | |
download | opensim-SC-c043008e04c3cb25b9fc4db62ed064775216d066.zip opensim-SC-c043008e04c3cb25b9fc4db62ed064775216d066.tar.gz opensim-SC-c043008e04c3cb25b9fc4db62ed064775216d066.tar.bz2 opensim-SC-c043008e04c3cb25b9fc4db62ed064775216d066.tar.xz |
add cap EstateChangeInfo
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EstateChangeInfo.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/EstateChangeInfo.cs | 228 |
1 files changed, 228 insertions, 0 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using System.Reflection; | ||
33 | |||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using Mono.Addins; | ||
39 | |||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | ||
42 | using OpenSim.Region.Framework.Interfaces; | ||
43 | using OpenSim.Region.Framework.Scenes; | ||
44 | using Caps=OpenSim.Framework.Capabilities.Caps; | ||
45 | |||
46 | namespace 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 | } | ||