diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
7 files changed, 833 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/World/Estate/XEstateConnector.cs b/OpenSim/Region/CoreModules/World/Estate/XEstateConnector.cs new file mode 100644 index 0000000..73e706c --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Estate/XEstateConnector.cs | |||
@@ -0,0 +1,218 @@ | |||
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.Generic; | ||
30 | using System.Reflection; | ||
31 | |||
32 | using OpenSim.Services.Interfaces; | ||
33 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
34 | using OpenSim.Server.Base; | ||
35 | using OpenSim.Framework.Servers.HttpServer; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | using log4net; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.World.Estate | ||
43 | { | ||
44 | public class EstateConnector | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | protected XEstateModule m_EstateModule; | ||
49 | |||
50 | public EstateConnector(XEstateModule module) | ||
51 | { | ||
52 | m_EstateModule = module; | ||
53 | } | ||
54 | |||
55 | public void SendTeleportHomeOneUser(uint EstateID, UUID PreyID) | ||
56 | { | ||
57 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
58 | sendData["METHOD"] = "teleport_home_one_user"; | ||
59 | |||
60 | sendData["EstateID"] = EstateID.ToString(); | ||
61 | sendData["PreyID"] = PreyID.ToString(); | ||
62 | |||
63 | SendToEstate(EstateID, sendData); | ||
64 | } | ||
65 | |||
66 | public void SendTeleportHomeAllUsers(uint EstateID) | ||
67 | { | ||
68 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
69 | sendData["METHOD"] = "teleport_home_all_users"; | ||
70 | |||
71 | sendData["EstateID"] = EstateID.ToString(); | ||
72 | |||
73 | SendToEstate(EstateID, sendData); | ||
74 | } | ||
75 | |||
76 | public bool SendUpdateCovenant(uint EstateID, UUID CovenantID) | ||
77 | { | ||
78 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
79 | sendData["METHOD"] = "update_covenant"; | ||
80 | |||
81 | sendData["CovenantID"] = CovenantID.ToString(); | ||
82 | sendData["EstateID"] = EstateID.ToString(); | ||
83 | |||
84 | // Handle local regions locally | ||
85 | // | ||
86 | foreach (Scene s in m_EstateModule.Scenes) | ||
87 | { | ||
88 | if (s.RegionInfo.EstateSettings.EstateID == EstateID) | ||
89 | s.RegionInfo.RegionSettings.Covenant = CovenantID; | ||
90 | // s.ReloadEstateData(); | ||
91 | } | ||
92 | |||
93 | SendToEstate(EstateID, sendData); | ||
94 | |||
95 | return true; | ||
96 | } | ||
97 | |||
98 | public bool SendUpdateEstate(uint EstateID) | ||
99 | { | ||
100 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
101 | sendData["METHOD"] = "update_estate"; | ||
102 | |||
103 | sendData["EstateID"] = EstateID.ToString(); | ||
104 | |||
105 | // Handle local regions locally | ||
106 | // | ||
107 | foreach (Scene s in m_EstateModule.Scenes) | ||
108 | { | ||
109 | if (s.RegionInfo.EstateSettings.EstateID == EstateID) | ||
110 | s.ReloadEstateData(); | ||
111 | } | ||
112 | |||
113 | SendToEstate(EstateID, sendData); | ||
114 | |||
115 | return true; | ||
116 | } | ||
117 | |||
118 | public void SendEstateMessage(uint EstateID, UUID FromID, string FromName, string Message) | ||
119 | { | ||
120 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
121 | sendData["METHOD"] = "estate_message"; | ||
122 | |||
123 | sendData["EstateID"] = EstateID.ToString(); | ||
124 | sendData["FromID"] = FromID.ToString(); | ||
125 | sendData["FromName"] = FromName; | ||
126 | sendData["Message"] = Message; | ||
127 | |||
128 | SendToEstate(EstateID, sendData); | ||
129 | } | ||
130 | |||
131 | private void SendToEstate(uint EstateID, Dictionary<string, object> sendData) | ||
132 | { | ||
133 | List<UUID> regions = m_EstateModule.Scenes[0].GetEstateRegions((int)EstateID); | ||
134 | |||
135 | UUID ScopeID = UUID.Zero; | ||
136 | |||
137 | // Handle local regions locally | ||
138 | // | ||
139 | lock (m_EstateModule.Scenes) | ||
140 | { | ||
141 | foreach (Scene s in m_EstateModule.Scenes) | ||
142 | { | ||
143 | if (regions.Contains(s.RegionInfo.RegionID)) | ||
144 | { | ||
145 | // All regions in one estate are in the same scope. | ||
146 | // Use that scope. | ||
147 | // | ||
148 | ScopeID = s.RegionInfo.ScopeID; | ||
149 | regions.Remove(s.RegionInfo.RegionID); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | |||
154 | // Our own region should always be in the above list. | ||
155 | // In a standalone this would not be true. But then, | ||
156 | // Scope ID is not relevat there. Use first scope. | ||
157 | // | ||
158 | if (ScopeID == UUID.Zero) | ||
159 | ScopeID = m_EstateModule.Scenes[0].RegionInfo.ScopeID; | ||
160 | |||
161 | // Don't send to the same instance twice | ||
162 | // | ||
163 | List<string> done = new List<string>(); | ||
164 | |||
165 | // Send to remote regions | ||
166 | // | ||
167 | foreach (UUID regionID in regions) | ||
168 | { | ||
169 | GridRegion region = m_EstateModule.Scenes[0].GridService.GetRegionByUUID(ScopeID, regionID); | ||
170 | if (region != null) | ||
171 | { | ||
172 | string url = "http://" + region.ExternalHostName + ":" + region.HttpPort; | ||
173 | if (done.Contains(url)) | ||
174 | continue; | ||
175 | |||
176 | Call(region, sendData); | ||
177 | done.Add(url); | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | |||
182 | private bool Call(GridRegion region, Dictionary<string, object> sendData) | ||
183 | { | ||
184 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
185 | // m_log.DebugFormat("[XESTATE CONNECTOR]: queryString = {0}", reqString); | ||
186 | try | ||
187 | { | ||
188 | string url = "http://" + region.ExternalHostName + ":" + region.HttpPort; | ||
189 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
190 | url + "/estate", | ||
191 | reqString); | ||
192 | if (reply != string.Empty) | ||
193 | { | ||
194 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
195 | |||
196 | if (replyData.ContainsKey("RESULT")) | ||
197 | { | ||
198 | if (replyData["RESULT"].ToString().ToLower() == "true") | ||
199 | return true; | ||
200 | else | ||
201 | return false; | ||
202 | } | ||
203 | else | ||
204 | m_log.DebugFormat("[XESTATE CONNECTOR]: reply data does not contain result field"); | ||
205 | |||
206 | } | ||
207 | else | ||
208 | m_log.DebugFormat("[XESTATE CONNECTOR]: received empty reply"); | ||
209 | } | ||
210 | catch (Exception e) | ||
211 | { | ||
212 | m_log.DebugFormat("[XESTATE CONNECTOR]: Exception when contacting remote sim: {0}", e.Message); | ||
213 | } | ||
214 | |||
215 | return false; | ||
216 | } | ||
217 | } | ||
218 | } | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/XEstateModule.cs b/OpenSim/Region/CoreModules/World/Estate/XEstateModule.cs new file mode 100644 index 0000000..f54ab2c --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Estate/XEstateModule.cs | |||
@@ -0,0 +1,256 @@ | |||
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.Reflection; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenSim.Server.Base; | ||
42 | using OpenSim.Framework.Servers; | ||
43 | using OpenSim.Framework.Servers.HttpServer; | ||
44 | using Mono.Addins; | ||
45 | |||
46 | namespace OpenSim.Region.CoreModules.World.Estate | ||
47 | { | ||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XEstate")] | ||
49 | public class XEstateModule : ISharedRegionModule | ||
50 | { | ||
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | protected List<Scene> m_Scenes = new List<Scene>(); | ||
54 | protected bool m_InInfoUpdate = false; | ||
55 | |||
56 | public bool InInfoUpdate | ||
57 | { | ||
58 | get { return m_InInfoUpdate; } | ||
59 | set { m_InInfoUpdate = value; } | ||
60 | } | ||
61 | |||
62 | public List<Scene> Scenes | ||
63 | { | ||
64 | get { return m_Scenes; } | ||
65 | } | ||
66 | |||
67 | protected EstateConnector m_EstateConnector; | ||
68 | |||
69 | public void Initialise(IConfigSource config) | ||
70 | { | ||
71 | int port = 0; | ||
72 | |||
73 | IConfig estateConfig = config.Configs["Estate"]; | ||
74 | if (estateConfig != null) | ||
75 | { | ||
76 | port = estateConfig.GetInt("Port", 0); | ||
77 | } | ||
78 | |||
79 | m_EstateConnector = new EstateConnector(this); | ||
80 | |||
81 | // Instantiate the request handler | ||
82 | IHttpServer server = MainServer.GetHttpServer((uint)port); | ||
83 | server.AddStreamHandler(new EstateRequestHandler(this)); | ||
84 | } | ||
85 | |||
86 | public void PostInitialise() | ||
87 | { | ||
88 | } | ||
89 | |||
90 | public void Close() | ||
91 | { | ||
92 | } | ||
93 | |||
94 | public void AddRegion(Scene scene) | ||
95 | { | ||
96 | lock (m_Scenes) | ||
97 | m_Scenes.Add(scene); | ||
98 | |||
99 | scene.EventManager.OnNewClient += OnNewClient; | ||
100 | } | ||
101 | |||
102 | public void RegionLoaded(Scene scene) | ||
103 | { | ||
104 | IEstateModule em = scene.RequestModuleInterface<IEstateModule>(); | ||
105 | |||
106 | em.OnRegionInfoChange += OnRegionInfoChange; | ||
107 | em.OnEstateInfoChange += OnEstateInfoChange; | ||
108 | em.OnEstateMessage += OnEstateMessage; | ||
109 | } | ||
110 | |||
111 | public void RemoveRegion(Scene scene) | ||
112 | { | ||
113 | scene.EventManager.OnNewClient -= OnNewClient; | ||
114 | |||
115 | lock (m_Scenes) | ||
116 | m_Scenes.Remove(scene); | ||
117 | } | ||
118 | |||
119 | public string Name | ||
120 | { | ||
121 | get { return "EstateModule"; } | ||
122 | } | ||
123 | |||
124 | public Type ReplaceableInterface | ||
125 | { | ||
126 | get { return null; } | ||
127 | } | ||
128 | |||
129 | private Scene FindScene(UUID RegionID) | ||
130 | { | ||
131 | foreach (Scene s in Scenes) | ||
132 | { | ||
133 | if (s.RegionInfo.RegionID == RegionID) | ||
134 | return s; | ||
135 | } | ||
136 | |||
137 | return null; | ||
138 | } | ||
139 | |||
140 | private void OnRegionInfoChange(UUID RegionID) | ||
141 | { | ||
142 | Scene s = FindScene(RegionID); | ||
143 | if (s == null) | ||
144 | return; | ||
145 | |||
146 | if (!m_InInfoUpdate) | ||
147 | m_EstateConnector.SendUpdateCovenant(s.RegionInfo.EstateSettings.EstateID, s.RegionInfo.RegionSettings.Covenant); | ||
148 | } | ||
149 | |||
150 | private void OnEstateInfoChange(UUID RegionID) | ||
151 | { | ||
152 | Scene s = FindScene(RegionID); | ||
153 | if (s == null) | ||
154 | return; | ||
155 | |||
156 | if (!m_InInfoUpdate) | ||
157 | m_EstateConnector.SendUpdateEstate(s.RegionInfo.EstateSettings.EstateID); | ||
158 | } | ||
159 | |||
160 | private void OnEstateMessage(UUID RegionID, UUID FromID, string FromName, string Message) | ||
161 | { | ||
162 | Scene senderScenes = FindScene(RegionID); | ||
163 | if (senderScenes == null) | ||
164 | return; | ||
165 | |||
166 | uint estateID = senderScenes.RegionInfo.EstateSettings.EstateID; | ||
167 | |||
168 | foreach (Scene s in Scenes) | ||
169 | { | ||
170 | if (s.RegionInfo.EstateSettings.EstateID == estateID) | ||
171 | { | ||
172 | IDialogModule dm = s.RequestModuleInterface<IDialogModule>(); | ||
173 | |||
174 | if (dm != null) | ||
175 | { | ||
176 | dm.SendNotificationToUsersInRegion(FromID, FromName, | ||
177 | Message); | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | if (!m_InInfoUpdate) | ||
182 | m_EstateConnector.SendEstateMessage(estateID, FromID, FromName, Message); | ||
183 | } | ||
184 | |||
185 | private void OnNewClient(IClientAPI client) | ||
186 | { | ||
187 | client.OnEstateTeleportOneUserHomeRequest += OnEstateTeleportOneUserHomeRequest; | ||
188 | client.OnEstateTeleportAllUsersHomeRequest += OnEstateTeleportAllUsersHomeRequest; | ||
189 | |||
190 | } | ||
191 | |||
192 | private void OnEstateTeleportOneUserHomeRequest(IClientAPI client, UUID invoice, UUID senderID, UUID prey) | ||
193 | { | ||
194 | if (prey == UUID.Zero) | ||
195 | return; | ||
196 | |||
197 | if (!(client.Scene is Scene)) | ||
198 | return; | ||
199 | |||
200 | Scene scene = (Scene)client.Scene; | ||
201 | |||
202 | uint estateID = scene.RegionInfo.EstateSettings.EstateID; | ||
203 | |||
204 | if (!scene.Permissions.CanIssueEstateCommand(client.AgentId, false)) | ||
205 | return; | ||
206 | |||
207 | foreach (Scene s in Scenes) | ||
208 | { | ||
209 | if (s == scene) | ||
210 | continue; // Already handles by estate module | ||
211 | if (s.RegionInfo.EstateSettings.EstateID != estateID) | ||
212 | continue; | ||
213 | |||
214 | ScenePresence p = scene.GetScenePresence(prey); | ||
215 | if (p != null && !p.IsChildAgent) | ||
216 | { | ||
217 | p.ControllingClient.SendTeleportStart(16); | ||
218 | scene.TeleportClientHome(prey, p.ControllingClient); | ||
219 | } | ||
220 | } | ||
221 | |||
222 | m_EstateConnector.SendTeleportHomeOneUser(estateID, prey); | ||
223 | } | ||
224 | |||
225 | private void OnEstateTeleportAllUsersHomeRequest(IClientAPI client, UUID invoice, UUID senderID) | ||
226 | { | ||
227 | if (!(client.Scene is Scene)) | ||
228 | return; | ||
229 | |||
230 | Scene scene = (Scene)client.Scene; | ||
231 | |||
232 | uint estateID = scene.RegionInfo.EstateSettings.EstateID; | ||
233 | |||
234 | if (!scene.Permissions.CanIssueEstateCommand(client.AgentId, false)) | ||
235 | return; | ||
236 | |||
237 | foreach (Scene s in Scenes) | ||
238 | { | ||
239 | if (s == scene) | ||
240 | continue; // Already handles by estate module | ||
241 | if (s.RegionInfo.EstateSettings.EstateID != estateID) | ||
242 | continue; | ||
243 | |||
244 | scene.ForEachScenePresence(delegate(ScenePresence p) { | ||
245 | if (p != null && !p.IsChildAgent) | ||
246 | { | ||
247 | p.ControllingClient.SendTeleportStart(16); | ||
248 | scene.TeleportClientHome(p.ControllingClient.AgentId, p.ControllingClient); | ||
249 | } | ||
250 | }); | ||
251 | } | ||
252 | |||
253 | m_EstateConnector.SendTeleportHomeAllUsers(estateID); | ||
254 | } | ||
255 | } | ||
256 | } | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs b/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs new file mode 100644 index 0000000..eb74cda --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs | |||
@@ -0,0 +1,298 @@ | |||
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.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Xml; | ||
33 | |||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | |||
40 | using OpenMetaverse; | ||
41 | using log4net; | ||
42 | |||
43 | namespace OpenSim.Region.CoreModules.World.Estate | ||
44 | { | ||
45 | public class EstateRequestHandler : BaseStreamHandler | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | protected XEstateModule m_EstateModule; | ||
50 | protected Object m_RequestLock = new Object(); | ||
51 | |||
52 | public EstateRequestHandler(XEstateModule fmodule) | ||
53 | : base("POST", "/estate") | ||
54 | { | ||
55 | m_EstateModule = fmodule; | ||
56 | } | ||
57 | |||
58 | public override byte[] Handle(string path, Stream requestData, | ||
59 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
60 | { | ||
61 | StreamReader sr = new StreamReader(requestData); | ||
62 | string body = sr.ReadToEnd(); | ||
63 | sr.Close(); | ||
64 | body = body.Trim(); | ||
65 | |||
66 | m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body); | ||
67 | |||
68 | try | ||
69 | { | ||
70 | lock (m_RequestLock) | ||
71 | { | ||
72 | Dictionary<string, object> request = | ||
73 | ServerUtils.ParseQueryString(body); | ||
74 | |||
75 | if (!request.ContainsKey("METHOD")) | ||
76 | return FailureResult(); | ||
77 | |||
78 | string method = request["METHOD"].ToString(); | ||
79 | request.Remove("METHOD"); | ||
80 | |||
81 | try | ||
82 | { | ||
83 | m_EstateModule.InInfoUpdate = false; | ||
84 | |||
85 | switch (method) | ||
86 | { | ||
87 | case "update_covenant": | ||
88 | return UpdateCovenant(request); | ||
89 | case "update_estate": | ||
90 | return UpdateEstate(request); | ||
91 | case "estate_message": | ||
92 | return EstateMessage(request); | ||
93 | case "teleport_home_one_user": | ||
94 | return TeleportHomeOneUser(request); | ||
95 | case "teleport_home_all_users": | ||
96 | return TeleportHomeAllUsers(request); | ||
97 | } | ||
98 | } | ||
99 | finally | ||
100 | { | ||
101 | m_EstateModule.InInfoUpdate = false; | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | catch (Exception e) | ||
106 | { | ||
107 | m_log.Debug("[XESTATE]: Exception {0}" + e.ToString()); | ||
108 | } | ||
109 | |||
110 | return FailureResult(); | ||
111 | } | ||
112 | |||
113 | byte[] TeleportHomeAllUsers(Dictionary<string, object> request) | ||
114 | { | ||
115 | UUID PreyID = UUID.Zero; | ||
116 | int EstateID = 0; | ||
117 | |||
118 | if (!request.ContainsKey("EstateID")) | ||
119 | return FailureResult(); | ||
120 | |||
121 | if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID)) | ||
122 | return FailureResult(); | ||
123 | |||
124 | foreach (Scene s in m_EstateModule.Scenes) | ||
125 | { | ||
126 | if (s.RegionInfo.EstateSettings.EstateID == EstateID) | ||
127 | { | ||
128 | s.ForEachScenePresence(delegate(ScenePresence p) { | ||
129 | if (p != null && !p.IsChildAgent) | ||
130 | { | ||
131 | p.ControllingClient.SendTeleportStart(16); | ||
132 | s.TeleportClientHome(p.ControllingClient.AgentId, p.ControllingClient); | ||
133 | } | ||
134 | }); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | return SuccessResult(); | ||
139 | } | ||
140 | |||
141 | byte[] TeleportHomeOneUser(Dictionary<string, object> request) | ||
142 | { | ||
143 | UUID PreyID = UUID.Zero; | ||
144 | int EstateID = 0; | ||
145 | |||
146 | if (!request.ContainsKey("PreyID") || | ||
147 | !request.ContainsKey("EstateID")) | ||
148 | { | ||
149 | return FailureResult(); | ||
150 | } | ||
151 | |||
152 | if (!UUID.TryParse(request["PreyID"].ToString(), out PreyID)) | ||
153 | return FailureResult(); | ||
154 | |||
155 | if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID)) | ||
156 | return FailureResult(); | ||
157 | |||
158 | foreach (Scene s in m_EstateModule.Scenes) | ||
159 | { | ||
160 | if (s.RegionInfo.EstateSettings.EstateID == EstateID) | ||
161 | { | ||
162 | ScenePresence p = s.GetScenePresence(PreyID); | ||
163 | if (p != null && !p.IsChildAgent) | ||
164 | { | ||
165 | p.ControllingClient.SendTeleportStart(16); | ||
166 | s.TeleportClientHome(PreyID, p.ControllingClient); | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | |||
171 | return SuccessResult(); | ||
172 | } | ||
173 | |||
174 | byte[] EstateMessage(Dictionary<string, object> request) | ||
175 | { | ||
176 | UUID FromID = UUID.Zero; | ||
177 | string FromName = String.Empty; | ||
178 | string Message = String.Empty; | ||
179 | int EstateID = 0; | ||
180 | |||
181 | if (!request.ContainsKey("FromID") || | ||
182 | !request.ContainsKey("FromName") || | ||
183 | !request.ContainsKey("Message") || | ||
184 | !request.ContainsKey("EstateID")) | ||
185 | { | ||
186 | return FailureResult(); | ||
187 | } | ||
188 | |||
189 | if (!UUID.TryParse(request["FromID"].ToString(), out FromID)) | ||
190 | return FailureResult(); | ||
191 | |||
192 | if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID)) | ||
193 | return FailureResult(); | ||
194 | |||
195 | FromName = request["FromName"].ToString(); | ||
196 | Message = request["Message"].ToString(); | ||
197 | |||
198 | foreach (Scene s in m_EstateModule.Scenes) | ||
199 | { | ||
200 | if (s.RegionInfo.EstateSettings.EstateID == EstateID) | ||
201 | { | ||
202 | IDialogModule dm = s.RequestModuleInterface<IDialogModule>(); | ||
203 | |||
204 | if (dm != null) | ||
205 | { | ||
206 | dm.SendNotificationToUsersInRegion(FromID, FromName, | ||
207 | Message); | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | |||
212 | return SuccessResult(); | ||
213 | } | ||
214 | |||
215 | byte[] UpdateCovenant(Dictionary<string, object> request) | ||
216 | { | ||
217 | UUID CovenantID = UUID.Zero; | ||
218 | int EstateID = 0; | ||
219 | |||
220 | if (!request.ContainsKey("CovenantID") || !request.ContainsKey("EstateID")) | ||
221 | return FailureResult(); | ||
222 | |||
223 | if (!UUID.TryParse(request["CovenantID"].ToString(), out CovenantID)) | ||
224 | return FailureResult(); | ||
225 | |||
226 | if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID)) | ||
227 | return FailureResult(); | ||
228 | |||
229 | foreach (Scene s in m_EstateModule.Scenes) | ||
230 | { | ||
231 | if (s.RegionInfo.EstateSettings.EstateID == (uint)EstateID) | ||
232 | s.RegionInfo.RegionSettings.Covenant = CovenantID; | ||
233 | } | ||
234 | |||
235 | return SuccessResult(); | ||
236 | } | ||
237 | |||
238 | byte[] UpdateEstate(Dictionary<string, object> request) | ||
239 | { | ||
240 | int EstateID = 0; | ||
241 | |||
242 | if (!request.ContainsKey("EstateID")) | ||
243 | return FailureResult(); | ||
244 | if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID)) | ||
245 | return FailureResult(); | ||
246 | |||
247 | foreach (Scene s in m_EstateModule.Scenes) | ||
248 | { | ||
249 | if (s.RegionInfo.EstateSettings.EstateID == (uint)EstateID) | ||
250 | s.ReloadEstateData(); | ||
251 | } | ||
252 | return SuccessResult(); | ||
253 | } | ||
254 | |||
255 | private byte[] FailureResult() | ||
256 | { | ||
257 | return BoolResult(false); | ||
258 | } | ||
259 | |||
260 | private byte[] SuccessResult() | ||
261 | { | ||
262 | return BoolResult(true); | ||
263 | } | ||
264 | |||
265 | private byte[] BoolResult(bool value) | ||
266 | { | ||
267 | XmlDocument doc = new XmlDocument(); | ||
268 | |||
269 | XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, | ||
270 | "", ""); | ||
271 | |||
272 | doc.AppendChild(xmlnode); | ||
273 | |||
274 | XmlElement rootElement = doc.CreateElement("", "ServerResponse", | ||
275 | ""); | ||
276 | |||
277 | doc.AppendChild(rootElement); | ||
278 | |||
279 | XmlElement result = doc.CreateElement("", "RESULT", ""); | ||
280 | result.AppendChild(doc.CreateTextNode(value.ToString())); | ||
281 | |||
282 | rootElement.AppendChild(result); | ||
283 | |||
284 | return DocToBytes(doc); | ||
285 | } | ||
286 | |||
287 | private byte[] DocToBytes(XmlDocument doc) | ||
288 | { | ||
289 | MemoryStream ms = new MemoryStream(); | ||
290 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
291 | xw.Formatting = Formatting.Indented; | ||
292 | doc.WriteTo(xw); | ||
293 | xw.Flush(); | ||
294 | |||
295 | return ms.ToArray(); | ||
296 | } | ||
297 | } | ||
298 | } | ||
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index c307998..dbc9296 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -74,6 +74,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
74 | 74 | ||
75 | protected IUserManagement m_userManager; | 75 | protected IUserManagement m_userManager; |
76 | protected IPrimCountModule m_primCountModule; | 76 | protected IPrimCountModule m_primCountModule; |
77 | protected IDialogModule m_Dialog; | ||
77 | 78 | ||
78 | // Minimum for parcels to work is 64m even if we don't actually use them. | 79 | // Minimum for parcels to work is 64m even if we don't actually use them. |
79 | #pragma warning disable 0429 | 80 | #pragma warning disable 0429 |
@@ -161,6 +162,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
161 | { | 162 | { |
162 | m_userManager = m_scene.RequestModuleInterface<IUserManagement>(); | 163 | m_userManager = m_scene.RequestModuleInterface<IUserManagement>(); |
163 | m_primCountModule = m_scene.RequestModuleInterface<IPrimCountModule>(); | 164 | m_primCountModule = m_scene.RequestModuleInterface<IPrimCountModule>(); |
165 | m_Dialog = m_scene.RequestModuleInterface<IDialogModule>(); | ||
164 | } | 166 | } |
165 | 167 | ||
166 | public void RemoveRegion(Scene scene) | 168 | public void RemoveRegion(Scene scene) |
@@ -213,6 +215,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
213 | client.OnPreAgentUpdate += ClientOnPreAgentUpdate; | 215 | client.OnPreAgentUpdate += ClientOnPreAgentUpdate; |
214 | client.OnParcelEjectUser += ClientOnParcelEjectUser; | 216 | client.OnParcelEjectUser += ClientOnParcelEjectUser; |
215 | client.OnParcelFreezeUser += ClientOnParcelFreezeUser; | 217 | client.OnParcelFreezeUser += ClientOnParcelFreezeUser; |
218 | client.OnSetStartLocationRequest += ClientOnSetHome; | ||
216 | 219 | ||
217 | EntityBase presenceEntity; | 220 | EntityBase presenceEntity; |
218 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) | 221 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) |
@@ -1896,7 +1899,53 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1896 | land.LandData.ParcelAccessList.Add(entry); | 1899 | land.LandData.ParcelAccessList.Add(entry); |
1897 | } | 1900 | } |
1898 | } | 1901 | } |
1899 | 1902 | ||
1903 | /// <summary> | ||
1904 | /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in | ||
1905 | /// </summary> | ||
1906 | /// <param name="remoteClient"></param> | ||
1907 | /// <param name="regionHandle"></param> | ||
1908 | /// <param name="position"></param> | ||
1909 | /// <param name="lookAt"></param> | ||
1910 | /// <param name="flags"></param> | ||
1911 | public virtual void ClientOnSetHome(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | ||
1912 | { | ||
1913 | // Let's find the parcel in question | ||
1914 | ILandObject land = landChannel.GetLandObject(position); | ||
1915 | if (land == null || m_scene.GridUserService == null) | ||
1916 | { | ||
1917 | m_Dialog.SendAlertToUser(remoteClient, "Set Home request failed."); | ||
1918 | return; | ||
1919 | } | ||
1920 | |||
1921 | // Gather some data | ||
1922 | ulong gpowers = remoteClient.GetGroupPowers(land.LandData.GroupID); | ||
1923 | SceneObjectGroup telehub = null; | ||
1924 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero) | ||
1925 | // Does the telehub exist in the scene? | ||
1926 | telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject); | ||
1927 | |||
1928 | // Can the user set home here? | ||
1929 | if (// (a) gods and land managers can set home | ||
1930 | m_scene.Permissions.IsAdministrator(remoteClient.AgentId) || | ||
1931 | m_scene.Permissions.IsGod(remoteClient.AgentId) || | ||
1932 | // (b) land owners can set home | ||
1933 | remoteClient.AgentId == land.LandData.OwnerID || | ||
1934 | // (c) members of the land-associated group in roles that can set home | ||
1935 | ((gpowers & (ulong)GroupPowers.AllowSetHome) == (ulong)GroupPowers.AllowSetHome) || | ||
1936 | // (d) parcels with telehubs can be the home of anyone | ||
1937 | (telehub != null && land.ContainsPoint((int)telehub.AbsolutePosition.X, (int)telehub.AbsolutePosition.Y))) | ||
1938 | { | ||
1939 | if (m_scene.GridUserService.SetHome(remoteClient.AgentId.ToString(), land.RegionUUID, position, lookAt)) | ||
1940 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | ||
1941 | m_Dialog.SendAlertToUser(remoteClient, "Home position set."); | ||
1942 | else | ||
1943 | m_Dialog.SendAlertToUser(remoteClient, "Set Home request failed."); | ||
1944 | } | ||
1945 | else | ||
1946 | m_Dialog.SendAlertToUser(remoteClient, "You are not allowed to set your home location in this parcel."); | ||
1947 | } | ||
1948 | |||
1900 | protected void InstallInterfaces() | 1949 | protected void InstallInterfaces() |
1901 | { | 1950 | { |
1902 | Command clearCommand | 1951 | Command clearCommand |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 07d00c0..31f8a3f 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -249,13 +249,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
249 | if (estateModule != null) | 249 | if (estateModule != null) |
250 | regionFlags = estateModule.GetRegionFlags(); | 250 | regionFlags = estateModule.GetRegionFlags(); |
251 | 251 | ||
252 | // In a perfect world, this would have worked. | ||
253 | // | ||
254 | // if ((landData.Flags & (uint)ParcelFlags.AllowLandmark) != 0) | ||
255 | // regionFlags |= (uint)RegionFlags.AllowLandmark; | ||
256 | // if (landData.OwnerID == remote_client.AgentId) | ||
257 | // regionFlags |= (uint)RegionFlags.AllowSetHome; | ||
258 | |||
259 | int seq_id; | 252 | int seq_id; |
260 | if (snap_selection && (sequence_id == 0)) | 253 | if (snap_selection && (sequence_id == 0)) |
261 | { | 254 | { |
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 79dd4a0..f8e93e1 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -1453,6 +1453,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1453 | 1453 | ||
1454 | bool permission = false; | 1454 | bool permission = false; |
1455 | 1455 | ||
1456 | // m_log.DebugFormat("[PERMISSIONS MODULE]: Checking rez object at {0} in {1}", objectPosition, m_scene.Name); | ||
1457 | |||
1456 | ILandObject land = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); | 1458 | ILandObject land = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); |
1457 | if (land == null) return false; | 1459 | if (land == null) return false; |
1458 | 1460 | ||
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index 883045a..d093224 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | |||
@@ -369,6 +369,15 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
369 | }); | 369 | }); |
370 | } | 370 | } |
371 | 371 | ||
372 | public void SetSoundQueueing(UUID objectID, bool shouldQueue) | ||
373 | { | ||
374 | SceneObjectPart part; | ||
375 | if (!m_scene.TryGetSceneObjectPart(objectID, out part)) | ||
376 | return; | ||
377 | |||
378 | part.SoundQueueing = shouldQueue; | ||
379 | } | ||
380 | |||
372 | #endregion | 381 | #endregion |
373 | } | 382 | } |
374 | } | 383 | } |