aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMW2009-02-24 15:57:25 +0000
committerMW2009-02-24 15:57:25 +0000
commit021225675f0d1f28daf6c21fe54b4172c7084036 (patch)
tree0c2cd006e07c82ff11ea9277c397067857767c5d /OpenSim
parentFirst step in separating out the Userserver console command handling to a "mo... (diff)
downloadopensim-SC_OLD-021225675f0d1f28daf6c21fe54b4172c7084036.zip
opensim-SC_OLD-021225675f0d1f28daf6c21fe54b4172c7084036.tar.gz
opensim-SC_OLD-021225675f0d1f28daf6c21fe54b4172c7084036.tar.bz2
opensim-SC_OLD-021225675f0d1f28daf6c21fe54b4172c7084036.tar.xz
Added OpenSim.Grid.GridServer.Modules, for the GridServer modules/components.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Grid/GridServer.Modules/GridDBService.cs (renamed from OpenSim/Grid/GridServer/GridDBService.cs)568
-rw-r--r--OpenSim/Grid/GridServer.Modules/GridMessagingModule.cs (renamed from OpenSim/Grid/GridServer/GridMessagingModule.cs)322
-rw-r--r--OpenSim/Grid/GridServer.Modules/GridRestModule.cs (renamed from OpenSim/Grid/GridServer/GridRestModule.cs)564
-rw-r--r--OpenSim/Grid/GridServer.Modules/GridXmlRpcModule.cs (renamed from OpenSim/Grid/GridServer/GridXmlRpcModule.cs)1770
-rw-r--r--OpenSim/Grid/GridServer/GridServerBase.cs1
5 files changed, 1613 insertions, 1612 deletions
diff --git a/OpenSim/Grid/GridServer/GridDBService.cs b/OpenSim/Grid/GridServer.Modules/GridDBService.cs
index f58f42b..b728f1f 100644
--- a/OpenSim/Grid/GridServer/GridDBService.cs
+++ b/OpenSim/Grid/GridServer.Modules/GridDBService.cs
@@ -1,284 +1,284 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Reflection; 32using System.Reflection;
33using System.Xml; 33using System.Xml;
34using log4net; 34using log4net;
35using Nwc.XmlRpc; 35using Nwc.XmlRpc;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenSim.Data; 37using OpenSim.Data;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Servers; 40using OpenSim.Framework.Servers;
41 41
42 42
43namespace OpenSim.Grid.GridServer 43namespace OpenSim.Grid.GridServer.Modules
44{ 44{
45 public class GridDBService 45 public class GridDBService
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private List<IGridDataPlugin> _plugins = new List<IGridDataPlugin>(); 49 private List<IGridDataPlugin> _plugins = new List<IGridDataPlugin>();
50 private List<ILogDataPlugin> _logplugins = new List<ILogDataPlugin>(); 50 private List<ILogDataPlugin> _logplugins = new List<ILogDataPlugin>();
51 51
52 /// <summary> 52 /// <summary>
53 /// Adds a list of grid and log data plugins, as described by 53 /// Adds a list of grid and log data plugins, as described by
54 /// `provider' and `connect', to `_plugins' and `_logplugins', 54 /// `provider' and `connect', to `_plugins' and `_logplugins',
55 /// respectively. 55 /// respectively.
56 /// </summary> 56 /// </summary>
57 /// <param name="provider"> 57 /// <param name="provider">
58 /// The filename of the inventory server plugin DLL. 58 /// The filename of the inventory server plugin DLL.
59 /// </param> 59 /// </param>
60 /// <param name="connect"> 60 /// <param name="connect">
61 /// The connection string for the storage backend. 61 /// The connection string for the storage backend.
62 /// </param> 62 /// </param>
63 public void AddPlugin(string provider, string connect) 63 public void AddPlugin(string provider, string connect)
64 { 64 {
65 _plugins = DataPluginFactory.LoadDataPlugins<IGridDataPlugin>(provider, connect); 65 _plugins = DataPluginFactory.LoadDataPlugins<IGridDataPlugin>(provider, connect);
66 _logplugins = DataPluginFactory.LoadDataPlugins<ILogDataPlugin>(provider, connect); 66 _logplugins = DataPluginFactory.LoadDataPlugins<ILogDataPlugin>(provider, connect);
67 } 67 }
68 68
69 public int GetNumberOfPlugins() 69 public int GetNumberOfPlugins()
70 { 70 {
71 return _plugins.Count; 71 return _plugins.Count;
72 } 72 }
73 73
74 /// <summary> 74 /// <summary>
75 /// Logs a piece of information to the database 75 /// Logs a piece of information to the database
76 /// </summary> 76 /// </summary>
77 /// <param name="target">What you were operating on (in grid server, this will likely be the region UUIDs)</param> 77 /// <param name="target">What you were operating on (in grid server, this will likely be the region UUIDs)</param>
78 /// <param name="method">Which method is being called?</param> 78 /// <param name="method">Which method is being called?</param>
79 /// <param name="args">What arguments are being passed?</param> 79 /// <param name="args">What arguments are being passed?</param>
80 /// <param name="priority">How high priority is this? 1 = Max, 6 = Verbose</param> 80 /// <param name="priority">How high priority is this? 1 = Max, 6 = Verbose</param>
81 /// <param name="message">The message to log</param> 81 /// <param name="message">The message to log</param>
82 private void logToDB(string target, string method, string args, int priority, string message) 82 private void logToDB(string target, string method, string args, int priority, string message)
83 { 83 {
84 foreach (ILogDataPlugin plugin in _logplugins) 84 foreach (ILogDataPlugin plugin in _logplugins)
85 { 85 {
86 try 86 try
87 { 87 {
88 plugin.saveLog("Gridserver", target, method, args, priority, message); 88 plugin.saveLog("Gridserver", target, method, args, priority, message);
89 } 89 }
90 catch (Exception) 90 catch (Exception)
91 { 91 {
92 m_log.Warn("[storage]: Unable to write log via " + plugin.Name); 92 m_log.Warn("[storage]: Unable to write log via " + plugin.Name);
93 } 93 }
94 } 94 }
95 } 95 }
96 96
97 /// <summary> 97 /// <summary>
98 /// Returns a region by argument 98 /// Returns a region by argument
99 /// </summary> 99 /// </summary>
100 /// <param name="uuid">A UUID key of the region to return</param> 100 /// <param name="uuid">A UUID key of the region to return</param>
101 /// <returns>A SimProfileData for the region</returns> 101 /// <returns>A SimProfileData for the region</returns>
102 public RegionProfileData GetRegion(UUID uuid) 102 public RegionProfileData GetRegion(UUID uuid)
103 { 103 {
104 foreach (IGridDataPlugin plugin in _plugins) 104 foreach (IGridDataPlugin plugin in _plugins)
105 { 105 {
106 try 106 try
107 { 107 {
108 return plugin.GetProfileByUUID(uuid); 108 return plugin.GetProfileByUUID(uuid);
109 } 109 }
110 catch (Exception e) 110 catch (Exception e)
111 { 111 {
112 m_log.Warn("[storage]: GetRegion - " + e.Message); 112 m_log.Warn("[storage]: GetRegion - " + e.Message);
113 } 113 }
114 } 114 }
115 return null; 115 return null;
116 } 116 }
117 117
118 /// <summary> 118 /// <summary>
119 /// Returns a region by argument 119 /// Returns a region by argument
120 /// </summary> 120 /// </summary>
121 /// <param name="uuid">A regionHandle of the region to return</param> 121 /// <param name="uuid">A regionHandle of the region to return</param>
122 /// <returns>A SimProfileData for the region</returns> 122 /// <returns>A SimProfileData for the region</returns>
123 public RegionProfileData GetRegion(ulong handle) 123 public RegionProfileData GetRegion(ulong handle)
124 { 124 {
125 foreach (IGridDataPlugin plugin in _plugins) 125 foreach (IGridDataPlugin plugin in _plugins)
126 { 126 {
127 try 127 try
128 { 128 {
129 return plugin.GetProfileByHandle(handle); 129 return plugin.GetProfileByHandle(handle);
130 } 130 }
131 catch (Exception ex) 131 catch (Exception ex)
132 { 132 {
133 m_log.Debug("[storage]: " + ex.Message); 133 m_log.Debug("[storage]: " + ex.Message);
134 m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + plugin.Name); 134 m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + plugin.Name);
135 } 135 }
136 } 136 }
137 return null; 137 return null;
138 } 138 }
139 139
140 /// <summary> 140 /// <summary>
141 /// Returns a region by argument 141 /// Returns a region by argument
142 /// </summary> 142 /// </summary>
143 /// <param name="regionName">A partial regionName of the region to return</param> 143 /// <param name="regionName">A partial regionName of the region to return</param>
144 /// <returns>A SimProfileData for the region</returns> 144 /// <returns>A SimProfileData for the region</returns>
145 public RegionProfileData GetRegion(string regionName) 145 public RegionProfileData GetRegion(string regionName)
146 { 146 {
147 foreach (IGridDataPlugin plugin in _plugins) 147 foreach (IGridDataPlugin plugin in _plugins)
148 { 148 {
149 try 149 try
150 { 150 {
151 return plugin.GetProfileByString(regionName); 151 return plugin.GetProfileByString(regionName);
152 } 152 }
153 catch 153 catch
154 { 154 {
155 m_log.Warn("[storage]: Unable to find region " + regionName + " via " + plugin.Name); 155 m_log.Warn("[storage]: Unable to find region " + regionName + " via " + plugin.Name);
156 } 156 }
157 } 157 }
158 return null; 158 return null;
159 } 159 }
160 160
161 public List<RegionProfileData> GetRegions(uint xmin, uint ymin, uint xmax, uint ymax) 161 public List<RegionProfileData> GetRegions(uint xmin, uint ymin, uint xmax, uint ymax)
162 { 162 {
163 List<RegionProfileData> regions = new List<RegionProfileData>(); 163 List<RegionProfileData> regions = new List<RegionProfileData>();
164 164
165 foreach (IGridDataPlugin plugin in _plugins) 165 foreach (IGridDataPlugin plugin in _plugins)
166 { 166 {
167 try 167 try
168 { 168 {
169 regions.AddRange(plugin.GetProfilesInRange(xmin, ymin, xmax, ymax)); 169 regions.AddRange(plugin.GetProfilesInRange(xmin, ymin, xmax, ymax));
170 } 170 }
171 catch 171 catch
172 { 172 {
173 m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name); 173 m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name);
174 } 174 }
175 } 175 }
176 176
177 return regions; 177 return regions;
178 } 178 }
179 179
180 public List<RegionProfileData> GetRegions(string name, int maxNum) 180 public List<RegionProfileData> GetRegions(string name, int maxNum)
181 { 181 {
182 List<RegionProfileData> regions = new List<RegionProfileData>(); 182 List<RegionProfileData> regions = new List<RegionProfileData>();
183 foreach (IGridDataPlugin plugin in _plugins) 183 foreach (IGridDataPlugin plugin in _plugins)
184 { 184 {
185 try 185 try
186 { 186 {
187 int num = maxNum - regions.Count; 187 int num = maxNum - regions.Count;
188 List<RegionProfileData> profiles = plugin.GetRegionsByName(name, (uint)num); 188 List<RegionProfileData> profiles = plugin.GetRegionsByName(name, (uint)num);
189 if (profiles != null) regions.AddRange(profiles); 189 if (profiles != null) regions.AddRange(profiles);
190 } 190 }
191 catch 191 catch
192 { 192 {
193 m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name); 193 m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name);
194 } 194 }
195 } 195 }
196 196
197 return regions; 197 return regions;
198 } 198 }
199 199
200 public DataResponse AddUpdateRegion(RegionProfileData sim, RegionProfileData existingSim) 200 public DataResponse AddUpdateRegion(RegionProfileData sim, RegionProfileData existingSim)
201 { 201 {
202 DataResponse insertResponse = DataResponse.RESPONSE_ERROR; 202 DataResponse insertResponse = DataResponse.RESPONSE_ERROR;
203 foreach (IGridDataPlugin plugin in _plugins) 203 foreach (IGridDataPlugin plugin in _plugins)
204 { 204 {
205 try 205 try
206 { 206 {
207 if (existingSim == null) 207 if (existingSim == null)
208 { 208 {
209 insertResponse = plugin.AddProfile(sim); 209 insertResponse = plugin.AddProfile(sim);
210 } 210 }
211 else 211 else
212 { 212 {
213 insertResponse = plugin.UpdateProfile(sim); 213 insertResponse = plugin.UpdateProfile(sim);
214 } 214 }
215 } 215 }
216 catch (Exception e) 216 catch (Exception e)
217 { 217 {
218 m_log.Warn("[LOGIN END]: " + 218 m_log.Warn("[LOGIN END]: " +
219 "Unable to login region " + sim.ToString() + " via " + plugin.Name); 219 "Unable to login region " + sim.ToString() + " via " + plugin.Name);
220 m_log.Warn("[LOGIN END]: " + e.ToString()); 220 m_log.Warn("[LOGIN END]: " + e.ToString());
221 } 221 }
222 } 222 }
223 return insertResponse; 223 return insertResponse;
224 } 224 }
225 225
226 public DataResponse DeleteRegion(string uuid) 226 public DataResponse DeleteRegion(string uuid)
227 { 227 {
228 DataResponse insertResponse = DataResponse.RESPONSE_ERROR; 228 DataResponse insertResponse = DataResponse.RESPONSE_ERROR;
229 foreach (IGridDataPlugin plugin in _plugins) 229 foreach (IGridDataPlugin plugin in _plugins)
230 { 230 {
231 //OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData(); 231 //OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData();
232 try 232 try
233 { 233 {
234 //Nice are we not using multiple databases? 234 //Nice are we not using multiple databases?
235 //MySQLGridData mysqldata = (MySQLGridData)(plugin); 235 //MySQLGridData mysqldata = (MySQLGridData)(plugin);
236 236
237 //DataResponse insertResponse = mysqldata.DeleteProfile(TheSim); 237 //DataResponse insertResponse = mysqldata.DeleteProfile(TheSim);
238 insertResponse = plugin.DeleteProfile(uuid); 238 insertResponse = plugin.DeleteProfile(uuid);
239 } 239 }
240 catch (Exception) 240 catch (Exception)
241 { 241 {
242 m_log.Error("storage Unable to delete region " + uuid + " via " + plugin.Name); 242 m_log.Error("storage Unable to delete region " + uuid + " via " + plugin.Name);
243 //MainLog.Instance.Warn("storage", e.ToString()); 243 //MainLog.Instance.Warn("storage", e.ToString());
244 insertResponse = DataResponse.RESPONSE_ERROR; 244 insertResponse = DataResponse.RESPONSE_ERROR;
245 } 245 }
246 } 246 }
247 return insertResponse; 247 return insertResponse;
248 } 248 }
249 249
250 public string CheckReservations(RegionProfileData theSim, XmlNode authkeynode) 250 public string CheckReservations(RegionProfileData theSim, XmlNode authkeynode)
251 { 251 {
252 foreach (IGridDataPlugin plugin in _plugins) 252 foreach (IGridDataPlugin plugin in _plugins)
253 { 253 {
254 try 254 try
255 { 255 {
256 //Check reservations 256 //Check reservations
257 ReservationData reserveData = 257 ReservationData reserveData =
258 plugin.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY); 258 plugin.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY);
259 if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) || 259 if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) ||
260 (reserveData == null && authkeynode.InnerText != theSim.regionRecvKey)) 260 (reserveData == null && authkeynode.InnerText != theSim.regionRecvKey))
261 { 261 {
262 plugin.AddProfile(theSim); 262 plugin.AddProfile(theSim);
263 m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")"); 263 m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")");
264 logToDB(theSim.ToString(), "RestSetSimMethod", String.Empty, 5, 264 logToDB(theSim.ToString(), "RestSetSimMethod", String.Empty, 5,
265 "Region successfully updated and connected to grid."); 265 "Region successfully updated and connected to grid.");
266 } 266 }
267 else 267 else
268 { 268 {
269 m_log.Warn("[grid]: " + 269 m_log.Warn("[grid]: " +
270 "Unable to update region (RestSetSimMethod): Incorrect reservation auth key."); 270 "Unable to update region (RestSetSimMethod): Incorrect reservation auth key.");
271 // Wanted: " + reserveData.gridRecvKey + ", Got: " + theSim.regionRecvKey + "."); 271 // Wanted: " + reserveData.gridRecvKey + ", Got: " + theSim.regionRecvKey + ".");
272 return "Unable to update region (RestSetSimMethod): Incorrect auth key."; 272 return "Unable to update region (RestSetSimMethod): Incorrect auth key.";
273 } 273 }
274 } 274 }
275 catch (Exception e) 275 catch (Exception e)
276 { 276 {
277 m_log.Warn("[GRID]: GetRegionPlugin Handle " + plugin.Name + " unable to add new sim: " + 277 m_log.Warn("[GRID]: GetRegionPlugin Handle " + plugin.Name + " unable to add new sim: " +
278 e.ToString()); 278 e.ToString());
279 } 279 }
280 } 280 }
281 return "OK"; 281 return "OK";
282 } 282 }
283 } 283 }
284} 284}
diff --git a/OpenSim/Grid/GridServer/GridMessagingModule.cs b/OpenSim/Grid/GridServer.Modules/GridMessagingModule.cs
index 7194ba4..9c2b5ca 100644
--- a/OpenSim/Grid/GridServer/GridMessagingModule.cs
+++ b/OpenSim/Grid/GridServer.Modules/GridMessagingModule.cs
@@ -1,161 +1,161 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using System.Text; 32using System.Text;
33using Nwc.XmlRpc; 33using Nwc.XmlRpc;
34using log4net; 34using log4net;
35using OpenSim.Framework.Servers; 35using OpenSim.Framework.Servers;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Grid.Framework; 37using OpenSim.Grid.Framework;
38 38
39namespace OpenSim.Grid.GridServer 39namespace OpenSim.Grid.GridServer.Modules
40{ 40{
41 public class GridMessagingModule : IGridMessagingMapper 41 public class GridMessagingModule : IGridMessagingMapper
42 { 42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 protected GridDBService m_gridDBService; 45 protected GridDBService m_gridDBService;
46 protected IUGAIMCore m_gridCore; 46 protected IUGAIMCore m_gridCore;
47 47
48 protected GridConfig m_config; 48 protected GridConfig m_config;
49 49
50 /// <value> 50 /// <value>
51 /// Used to notify old regions as to which OpenSim version to upgrade to 51 /// Used to notify old regions as to which OpenSim version to upgrade to
52 /// </value> 52 /// </value>
53 private string m_opensimVersion; 53 private string m_opensimVersion;
54 54
55 protected BaseHttpServer m_httpServer; 55 protected BaseHttpServer m_httpServer;
56 56
57 // This is here so that the grid server can hand out MessageServer settings to regions on registration 57 // This is here so that the grid server can hand out MessageServer settings to regions on registration
58 private List<MessageServerInfo> m_messageServers = new List<MessageServerInfo>(); 58 private List<MessageServerInfo> m_messageServers = new List<MessageServerInfo>();
59 59
60 public GridMessagingModule() 60 public GridMessagingModule()
61 { 61 {
62 } 62 }
63 63
64 public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config) 64 public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config)
65 { 65 {
66 m_opensimVersion = opensimVersion; 66 m_opensimVersion = opensimVersion;
67 m_gridDBService = gridDBService; 67 m_gridDBService = gridDBService;
68 m_gridCore = gridCore; 68 m_gridCore = gridCore;
69 m_config = config; 69 m_config = config;
70 70
71 m_gridCore.RegisterInterface<IGridMessagingMapper>(this); 71 m_gridCore.RegisterInterface<IGridMessagingMapper>(this);
72 72
73 RegisterHandlers(); 73 RegisterHandlers();
74 } 74 }
75 75
76 public void PostInitialise() 76 public void PostInitialise()
77 { 77 {
78 78
79 } 79 }
80 80
81 public void RegisterHandlers() 81 public void RegisterHandlers()
82 { 82 {
83 //have these in separate method as some servers restart the http server and reregister all the handlers. 83 //have these in separate method as some servers restart the http server and reregister all the handlers.
84 m_httpServer = m_gridCore.GetHttpServer(); 84 m_httpServer = m_gridCore.GetHttpServer();
85 85
86 // Message Server ---> Grid Server 86 // Message Server ---> Grid Server
87 m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer); 87 m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer);
88 m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer); 88 m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer);
89 } 89 }
90 90
91 public List<MessageServerInfo> GetMessageServersList() 91 public List<MessageServerInfo> GetMessageServersList()
92 { 92 {
93 lock (m_messageServers) 93 lock (m_messageServers)
94 { 94 {
95 return new List<MessageServerInfo>(m_messageServers); 95 return new List<MessageServerInfo>(m_messageServers);
96 } 96 }
97 } 97 }
98 98
99 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request) 99 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request)
100 { 100 {
101 XmlRpcResponse response = new XmlRpcResponse(); 101 XmlRpcResponse response = new XmlRpcResponse();
102 Hashtable requestData = (Hashtable)request.Params[0]; 102 Hashtable requestData = (Hashtable)request.Params[0];
103 Hashtable responseData = new Hashtable(); 103 Hashtable responseData = new Hashtable();
104 104
105 if (requestData.Contains("uri")) 105 if (requestData.Contains("uri"))
106 { 106 {
107 string URI = (string)requestData["URI"]; 107 string URI = (string)requestData["URI"];
108 string sendkey = (string)requestData["sendkey"]; 108 string sendkey = (string)requestData["sendkey"];
109 string recvkey = (string)requestData["recvkey"]; 109 string recvkey = (string)requestData["recvkey"];
110 MessageServerInfo m = new MessageServerInfo(); 110 MessageServerInfo m = new MessageServerInfo();
111 m.URI = URI; 111 m.URI = URI;
112 m.sendkey = sendkey; 112 m.sendkey = sendkey;
113 m.recvkey = recvkey; 113 m.recvkey = recvkey;
114 RegisterMessageServer(m); 114 RegisterMessageServer(m);
115 responseData["responsestring"] = "TRUE"; 115 responseData["responsestring"] = "TRUE";
116 response.Value = responseData; 116 response.Value = responseData;
117 } 117 }
118 return response; 118 return response;
119 } 119 }
120 120
121 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request) 121 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request)
122 { 122 {
123 XmlRpcResponse response = new XmlRpcResponse(); 123 XmlRpcResponse response = new XmlRpcResponse();
124 Hashtable requestData = (Hashtable)request.Params[0]; 124 Hashtable requestData = (Hashtable)request.Params[0];
125 Hashtable responseData = new Hashtable(); 125 Hashtable responseData = new Hashtable();
126 126
127 if (requestData.Contains("uri")) 127 if (requestData.Contains("uri"))
128 { 128 {
129 string URI = (string)requestData["uri"]; 129 string URI = (string)requestData["uri"];
130 string sendkey = (string)requestData["sendkey"]; 130 string sendkey = (string)requestData["sendkey"];
131 string recvkey = (string)requestData["recvkey"]; 131 string recvkey = (string)requestData["recvkey"];
132 MessageServerInfo m = new MessageServerInfo(); 132 MessageServerInfo m = new MessageServerInfo();
133 m.URI = URI; 133 m.URI = URI;
134 m.sendkey = sendkey; 134 m.sendkey = sendkey;
135 m.recvkey = recvkey; 135 m.recvkey = recvkey;
136 DeRegisterMessageServer(m); 136 DeRegisterMessageServer(m);
137 responseData["responsestring"] = "TRUE"; 137 responseData["responsestring"] = "TRUE";
138 response.Value = responseData; 138 response.Value = responseData;
139 } 139 }
140 return response; 140 return response;
141 } 141 }
142 142
143 public void RegisterMessageServer(MessageServerInfo m) 143 public void RegisterMessageServer(MessageServerInfo m)
144 { 144 {
145 lock (m_messageServers) 145 lock (m_messageServers)
146 { 146 {
147 if (!m_messageServers.Contains(m)) 147 if (!m_messageServers.Contains(m))
148 m_messageServers.Add(m); 148 m_messageServers.Add(m);
149 } 149 }
150 } 150 }
151 151
152 public void DeRegisterMessageServer(MessageServerInfo m) 152 public void DeRegisterMessageServer(MessageServerInfo m)
153 { 153 {
154 lock (m_messageServers) 154 lock (m_messageServers)
155 { 155 {
156 if (m_messageServers.Contains(m)) 156 if (m_messageServers.Contains(m))
157 m_messageServers.Remove(m); 157 m_messageServers.Remove(m);
158 } 158 }
159 } 159 }
160 } 160 }
161} 161}
diff --git a/OpenSim/Grid/GridServer/GridRestModule.cs b/OpenSim/Grid/GridServer.Modules/GridRestModule.cs
index 2ec7cdb..cd6d4d5 100644
--- a/OpenSim/Grid/GridServer/GridRestModule.cs
+++ b/OpenSim/Grid/GridServer.Modules/GridRestModule.cs
@@ -1,282 +1,282 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Reflection; 32using System.Reflection;
33using System.Xml; 33using System.Xml;
34using log4net; 34using log4net;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Data; 36using OpenSim.Data;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Servers; 39using OpenSim.Framework.Servers;
40using OpenSim.Grid.Framework; 40using OpenSim.Grid.Framework;
41 41
42namespace OpenSim.Grid.GridServer 42namespace OpenSim.Grid.GridServer.Modules
43{ 43{
44 public class GridRestModule 44 public class GridRestModule
45 { 45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 private GridDBService m_gridDBService; 48 private GridDBService m_gridDBService;
49 private IUGAIMCore m_gridCore; 49 private IUGAIMCore m_gridCore;
50 50
51 protected GridConfig m_config; 51 protected GridConfig m_config;
52 52
53 /// <value> 53 /// <value>
54 /// Used to notify old regions as to which OpenSim version to upgrade to 54 /// Used to notify old regions as to which OpenSim version to upgrade to
55 /// </value> 55 /// </value>
56 private string m_opensimVersion; 56 private string m_opensimVersion;
57 57
58 protected BaseHttpServer m_httpServer; 58 protected BaseHttpServer m_httpServer;
59 59
60 /// <summary> 60 /// <summary>
61 /// Constructor 61 /// Constructor
62 /// </summary> 62 /// </summary>
63 /// <param name="opensimVersion"> 63 /// <param name="opensimVersion">
64 /// Used to notify old regions as to which OpenSim version to upgrade to 64 /// Used to notify old regions as to which OpenSim version to upgrade to
65 /// </param> 65 /// </param>
66 public GridRestModule() 66 public GridRestModule()
67 { 67 {
68 } 68 }
69 69
70 public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config) 70 public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config)
71 { 71 {
72 m_opensimVersion = opensimVersion; 72 m_opensimVersion = opensimVersion;
73 m_gridDBService = gridDBService; 73 m_gridDBService = gridDBService;
74 m_gridCore = gridCore; 74 m_gridCore = gridCore;
75 m_config = config; 75 m_config = config;
76 RegisterHandlers(); 76 RegisterHandlers();
77 } 77 }
78 78
79 public void PostInitialise() 79 public void PostInitialise()
80 { 80 {
81 81
82 } 82 }
83 83
84 public void RegisterHandlers() 84 public void RegisterHandlers()
85 { 85 {
86 //have these in separate method as some servers restart the http server and reregister all the handlers. 86 //have these in separate method as some servers restart the http server and reregister all the handlers.
87 m_httpServer = m_gridCore.GetHttpServer(); 87 m_httpServer = m_gridCore.GetHttpServer();
88 88
89 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", RestGetSimMethod)); 89 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", RestGetSimMethod));
90 m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", RestSetSimMethod)); 90 m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", RestSetSimMethod));
91 91
92 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/regions/", RestGetRegionMethod)); 92 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/regions/", RestGetRegionMethod));
93 m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/regions/", RestSetRegionMethod)); 93 m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/regions/", RestSetRegionMethod));
94 } 94 }
95 95
96 /// <summary> 96 /// <summary>
97 /// Performs a REST Get Operation 97 /// Performs a REST Get Operation
98 /// </summary> 98 /// </summary>
99 /// <param name="request"></param> 99 /// <param name="request"></param>
100 /// <param name="path"></param> 100 /// <param name="path"></param>
101 /// <param name="param"></param> 101 /// <param name="param"></param>
102 /// <param name="httpRequest">HTTP request header object</param> 102 /// <param name="httpRequest">HTTP request header object</param>
103 /// <param name="httpResponse">HTTP response header object</param> 103 /// <param name="httpResponse">HTTP response header object</param>
104 /// <returns></returns> 104 /// <returns></returns>
105 public string RestGetRegionMethod(string request, string path, string param, 105 public string RestGetRegionMethod(string request, string path, string param,
106 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 106 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
107 { 107 {
108 return RestGetSimMethod(String.Empty, "/sims/", param, httpRequest, httpResponse); 108 return RestGetSimMethod(String.Empty, "/sims/", param, httpRequest, httpResponse);
109 } 109 }
110 110
111 /// <summary> 111 /// <summary>
112 /// Performs a REST Set Operation 112 /// Performs a REST Set Operation
113 /// </summary> 113 /// </summary>
114 /// <param name="request"></param> 114 /// <param name="request"></param>
115 /// <param name="path"></param> 115 /// <param name="path"></param>
116 /// <param name="param"></param> 116 /// <param name="param"></param>
117 /// <param name="httpRequest">HTTP request header object</param> 117 /// <param name="httpRequest">HTTP request header object</param>
118 /// <param name="httpResponse">HTTP response header object</param> 118 /// <param name="httpResponse">HTTP response header object</param>
119 /// <returns></returns> 119 /// <returns></returns>
120 public string RestSetRegionMethod(string request, string path, string param, 120 public string RestSetRegionMethod(string request, string path, string param,
121 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 121 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
122 { 122 {
123 return RestSetSimMethod(String.Empty, "/sims/", param, httpRequest, httpResponse); 123 return RestSetSimMethod(String.Empty, "/sims/", param, httpRequest, httpResponse);
124 } 124 }
125 125
126 /// <summary> 126 /// <summary>
127 /// Returns information about a sim via a REST Request 127 /// Returns information about a sim via a REST Request
128 /// </summary> 128 /// </summary>
129 /// <param name="request"></param> 129 /// <param name="request"></param>
130 /// <param name="path"></param> 130 /// <param name="path"></param>
131 /// <param name="param">A string representing the sim's UUID</param> 131 /// <param name="param">A string representing the sim's UUID</param>
132 /// <param name="httpRequest">HTTP request header object</param> 132 /// <param name="httpRequest">HTTP request header object</param>
133 /// <param name="httpResponse">HTTP response header object</param> 133 /// <param name="httpResponse">HTTP response header object</param>
134 /// <returns>Information about the sim in XML</returns> 134 /// <returns>Information about the sim in XML</returns>
135 public string RestGetSimMethod(string request, string path, string param, 135 public string RestGetSimMethod(string request, string path, string param,
136 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 136 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
137 { 137 {
138 string respstring = String.Empty; 138 string respstring = String.Empty;
139 139
140 RegionProfileData TheSim; 140 RegionProfileData TheSim;
141 141
142 UUID UUID; 142 UUID UUID;
143 if (UUID.TryParse(param, out UUID)) 143 if (UUID.TryParse(param, out UUID))
144 { 144 {
145 TheSim = m_gridDBService.GetRegion(UUID); 145 TheSim = m_gridDBService.GetRegion(UUID);
146 146
147 if (!(TheSim == null)) 147 if (!(TheSim == null))
148 { 148 {
149 respstring = "<Root>"; 149 respstring = "<Root>";
150 respstring += "<authkey>" + TheSim.regionSendKey + "</authkey>"; 150 respstring += "<authkey>" + TheSim.regionSendKey + "</authkey>";
151 respstring += "<sim>"; 151 respstring += "<sim>";
152 respstring += "<uuid>" + TheSim.UUID.ToString() + "</uuid>"; 152 respstring += "<uuid>" + TheSim.UUID.ToString() + "</uuid>";
153 respstring += "<regionname>" + TheSim.regionName + "</regionname>"; 153 respstring += "<regionname>" + TheSim.regionName + "</regionname>";
154 respstring += "<sim_ip>" + TheSim.serverIP + "</sim_ip>"; 154 respstring += "<sim_ip>" + TheSim.serverIP + "</sim_ip>";
155 respstring += "<sim_port>" + TheSim.serverPort.ToString() + "</sim_port>"; 155 respstring += "<sim_port>" + TheSim.serverPort.ToString() + "</sim_port>";
156 respstring += "<region_locx>" + TheSim.regionLocX.ToString() + "</region_locx>"; 156 respstring += "<region_locx>" + TheSim.regionLocX.ToString() + "</region_locx>";
157 respstring += "<region_locy>" + TheSim.regionLocY.ToString() + "</region_locy>"; 157 respstring += "<region_locy>" + TheSim.regionLocY.ToString() + "</region_locy>";
158 respstring += "<estate_id>1</estate_id>"; 158 respstring += "<estate_id>1</estate_id>";
159 respstring += "</sim>"; 159 respstring += "</sim>";
160 respstring += "</Root>"; 160 respstring += "</Root>";
161 } 161 }
162 } 162 }
163 else 163 else
164 { 164 {
165 respstring = "<Root>"; 165 respstring = "<Root>";
166 respstring += "<error>Param must be a UUID</error>"; 166 respstring += "<error>Param must be a UUID</error>";
167 respstring += "</Root>"; 167 respstring += "</Root>";
168 } 168 }
169 169
170 return respstring; 170 return respstring;
171 } 171 }
172 172
173 /// <summary> 173 /// <summary>
174 /// Creates or updates a sim via a REST Method Request 174 /// Creates or updates a sim via a REST Method Request
175 /// BROKEN with SQL Update 175 /// BROKEN with SQL Update
176 /// </summary> 176 /// </summary>
177 /// <param name="request"></param> 177 /// <param name="request"></param>
178 /// <param name="path"></param> 178 /// <param name="path"></param>
179 /// <param name="param"></param> 179 /// <param name="param"></param>
180 /// <param name="httpRequest">HTTP request header object</param> 180 /// <param name="httpRequest">HTTP request header object</param>
181 /// <param name="httpResponse">HTTP response header object</param> 181 /// <param name="httpResponse">HTTP response header object</param>
182 /// <returns>"OK" or an error</returns> 182 /// <returns>"OK" or an error</returns>
183 public string RestSetSimMethod(string request, string path, string param, 183 public string RestSetSimMethod(string request, string path, string param,
184 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 184 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
185 { 185 {
186 m_log.Info("Processing region update via REST method"); 186 m_log.Info("Processing region update via REST method");
187 RegionProfileData theSim; 187 RegionProfileData theSim;
188 theSim = m_gridDBService.GetRegion(new UUID(param)); 188 theSim = m_gridDBService.GetRegion(new UUID(param));
189 if (theSim == null) 189 if (theSim == null)
190 { 190 {
191 theSim = new RegionProfileData(); 191 theSim = new RegionProfileData();
192 UUID UUID = new UUID(param); 192 UUID UUID = new UUID(param);
193 theSim.UUID = UUID; 193 theSim.UUID = UUID;
194 theSim.regionRecvKey = m_config.SimRecvKey; 194 theSim.regionRecvKey = m_config.SimRecvKey;
195 } 195 }
196 196
197 XmlDocument doc = new XmlDocument(); 197 XmlDocument doc = new XmlDocument();
198 doc.LoadXml(request); 198 doc.LoadXml(request);
199 XmlNode rootnode = doc.FirstChild; 199 XmlNode rootnode = doc.FirstChild;
200 XmlNode authkeynode = rootnode.ChildNodes[0]; 200 XmlNode authkeynode = rootnode.ChildNodes[0];
201 if (authkeynode.Name != "authkey") 201 if (authkeynode.Name != "authkey")
202 { 202 {
203 return "ERROR! bad XML - expected authkey tag"; 203 return "ERROR! bad XML - expected authkey tag";
204 } 204 }
205 205
206 XmlNode simnode = rootnode.ChildNodes[1]; 206 XmlNode simnode = rootnode.ChildNodes[1];
207 if (simnode.Name != "sim") 207 if (simnode.Name != "sim")
208 { 208 {
209 return "ERROR! bad XML - expected sim tag"; 209 return "ERROR! bad XML - expected sim tag";
210 } 210 }
211 211
212 //theSim.regionSendKey = Cfg; 212 //theSim.regionSendKey = Cfg;
213 theSim.regionRecvKey = m_config.SimRecvKey; 213 theSim.regionRecvKey = m_config.SimRecvKey;
214 theSim.regionSendKey = m_config.SimSendKey; 214 theSim.regionSendKey = m_config.SimSendKey;
215 theSim.regionSecret = m_config.SimRecvKey; 215 theSim.regionSecret = m_config.SimRecvKey;
216 theSim.regionDataURI = String.Empty; 216 theSim.regionDataURI = String.Empty;
217 theSim.regionAssetURI = m_config.DefaultAssetServer; 217 theSim.regionAssetURI = m_config.DefaultAssetServer;
218 theSim.regionAssetRecvKey = m_config.AssetRecvKey; 218 theSim.regionAssetRecvKey = m_config.AssetRecvKey;
219 theSim.regionAssetSendKey = m_config.AssetSendKey; 219 theSim.regionAssetSendKey = m_config.AssetSendKey;
220 theSim.regionUserURI = m_config.DefaultUserServer; 220 theSim.regionUserURI = m_config.DefaultUserServer;
221 theSim.regionUserSendKey = m_config.UserSendKey; 221 theSim.regionUserSendKey = m_config.UserSendKey;
222 theSim.regionUserRecvKey = m_config.UserRecvKey; 222 theSim.regionUserRecvKey = m_config.UserRecvKey;
223 223
224 for (int i = 0; i < simnode.ChildNodes.Count; i++) 224 for (int i = 0; i < simnode.ChildNodes.Count; i++)
225 { 225 {
226 switch (simnode.ChildNodes[i].Name) 226 switch (simnode.ChildNodes[i].Name)
227 { 227 {
228 case "regionname": 228 case "regionname":
229 theSim.regionName = simnode.ChildNodes[i].InnerText; 229 theSim.regionName = simnode.ChildNodes[i].InnerText;
230 break; 230 break;
231 231
232 case "sim_ip": 232 case "sim_ip":
233 theSim.serverIP = simnode.ChildNodes[i].InnerText; 233 theSim.serverIP = simnode.ChildNodes[i].InnerText;
234 break; 234 break;
235 235
236 case "sim_port": 236 case "sim_port":
237 theSim.serverPort = Convert.ToUInt32(simnode.ChildNodes[i].InnerText); 237 theSim.serverPort = Convert.ToUInt32(simnode.ChildNodes[i].InnerText);
238 break; 238 break;
239 239
240 case "region_locx": 240 case "region_locx":
241 theSim.regionLocX = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); 241 theSim.regionLocX = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
242 theSim.regionHandle = Utils.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize)); 242 theSim.regionHandle = Utils.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize));
243 break; 243 break;
244 244
245 case "region_locy": 245 case "region_locy":
246 theSim.regionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); 246 theSim.regionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText);
247 theSim.regionHandle = Utils.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize)); 247 theSim.regionHandle = Utils.UIntsToLong((theSim.regionLocX * Constants.RegionSize), (theSim.regionLocY * Constants.RegionSize));
248 break; 248 break;
249 } 249 }
250 } 250 }
251 251
252 theSim.serverURI = "http://" + theSim.serverIP + ":" + theSim.serverPort + "/"; 252 theSim.serverURI = "http://" + theSim.serverIP + ":" + theSim.serverPort + "/";
253 bool requirePublic = false; 253 bool requirePublic = false;
254 bool requireValid = true; 254 bool requireValid = true;
255 255
256 if (requirePublic && 256 if (requirePublic &&
257 (theSim.serverIP.StartsWith("172.16") || theSim.serverIP.StartsWith("192.168") || 257 (theSim.serverIP.StartsWith("172.16") || theSim.serverIP.StartsWith("192.168") ||
258 theSim.serverIP.StartsWith("10.") || theSim.serverIP.StartsWith("0.") || 258 theSim.serverIP.StartsWith("10.") || theSim.serverIP.StartsWith("0.") ||
259 theSim.serverIP.StartsWith("255."))) 259 theSim.serverIP.StartsWith("255.")))
260 { 260 {
261 return "ERROR! Servers must register with public addresses."; 261 return "ERROR! Servers must register with public addresses.";
262 } 262 }
263 263
264 if (requireValid && (theSim.serverIP.StartsWith("0.") || theSim.serverIP.StartsWith("255."))) 264 if (requireValid && (theSim.serverIP.StartsWith("0.") || theSim.serverIP.StartsWith("255.")))
265 { 265 {
266 return "ERROR! 0.*.*.* / 255.*.*.* Addresses are invalid, please check your server config and try again"; 266 return "ERROR! 0.*.*.* / 255.*.*.* Addresses are invalid, please check your server config and try again";
267 } 267 }
268 268
269 try 269 try
270 { 270 {
271 m_log.Info("[DATA]: " + 271 m_log.Info("[DATA]: " +
272 "Updating / adding via " + m_gridDBService.GetNumberOfPlugins() + " storage provider(s) registered."); 272 "Updating / adding via " + m_gridDBService.GetNumberOfPlugins() + " storage provider(s) registered.");
273 273
274 return m_gridDBService.CheckReservations(theSim, authkeynode); 274 return m_gridDBService.CheckReservations(theSim, authkeynode);
275 } 275 }
276 catch (Exception e) 276 catch (Exception e)
277 { 277 {
278 return "ERROR! Could not save to database! (" + e.ToString() + ")"; 278 return "ERROR! Could not save to database! (" + e.ToString() + ")";
279 } 279 }
280 } 280 }
281 } 281 }
282} 282}
diff --git a/OpenSim/Grid/GridServer/GridXmlRpcModule.cs b/OpenSim/Grid/GridServer.Modules/GridXmlRpcModule.cs
index d69f079..d5af900 100644
--- a/OpenSim/Grid/GridServer/GridXmlRpcModule.cs
+++ b/OpenSim/Grid/GridServer.Modules/GridXmlRpcModule.cs
@@ -1,885 +1,885 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Reflection; 32using System.Reflection;
33using System.Xml; 33using System.Xml;
34using log4net; 34using log4net;
35using Nwc.XmlRpc; 35using Nwc.XmlRpc;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenSim.Data; 37using OpenSim.Data;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Servers; 40using OpenSim.Framework.Servers;
41using OpenSim.Grid.Framework; 41using OpenSim.Grid.Framework;
42 42
43namespace OpenSim.Grid.GridServer 43namespace OpenSim.Grid.GridServer.Modules
44{ 44{
45 public class GridXmlRpcModule 45 public class GridXmlRpcModule
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private GridDBService m_gridDBService; 49 private GridDBService m_gridDBService;
50 private IUGAIMCore m_gridCore; 50 private IUGAIMCore m_gridCore;
51 51
52 protected GridConfig m_config; 52 protected GridConfig m_config;
53 53
54 protected IGridMessagingMapper m_messagingServerMapper; 54 protected IGridMessagingMapper m_messagingServerMapper;
55 /// <value> 55 /// <value>
56 /// Used to notify old regions as to which OpenSim version to upgrade to 56 /// Used to notify old regions as to which OpenSim version to upgrade to
57 /// </value> 57 /// </value>
58 private string m_opensimVersion; 58 private string m_opensimVersion;
59 59
60 protected BaseHttpServer m_httpServer; 60 protected BaseHttpServer m_httpServer;
61 61
62 /// <summary> 62 /// <summary>
63 /// Constructor 63 /// Constructor
64 /// </summary> 64 /// </summary>
65 /// <param name="opensimVersion"> 65 /// <param name="opensimVersion">
66 /// Used to notify old regions as to which OpenSim version to upgrade to 66 /// Used to notify old regions as to which OpenSim version to upgrade to
67 /// </param> 67 /// </param>
68 public GridXmlRpcModule() 68 public GridXmlRpcModule()
69 { 69 {
70 } 70 }
71 71
72 public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config) 72 public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config)
73 { 73 {
74 m_opensimVersion = opensimVersion; 74 m_opensimVersion = opensimVersion;
75 m_gridDBService = gridDBService; 75 m_gridDBService = gridDBService;
76 m_gridCore = gridCore; 76 m_gridCore = gridCore;
77 m_config = config; 77 m_config = config;
78 RegisterHandlers(); 78 RegisterHandlers();
79 } 79 }
80 80
81 public void PostInitialise() 81 public void PostInitialise()
82 { 82 {
83 IGridMessagingMapper messagingModule; 83 IGridMessagingMapper messagingModule;
84 if (m_gridCore.TryGet<IGridMessagingMapper>(out messagingModule)) 84 if (m_gridCore.TryGet<IGridMessagingMapper>(out messagingModule))
85 { 85 {
86 m_messagingServerMapper = messagingModule; 86 m_messagingServerMapper = messagingModule;
87 } 87 }
88 } 88 }
89 89
90 public void RegisterHandlers() 90 public void RegisterHandlers()
91 { 91 {
92 //have these in separate method as some servers restart the http server and reregister all the handlers. 92 //have these in separate method as some servers restart the http server and reregister all the handlers.
93 m_httpServer = m_gridCore.GetHttpServer(); 93 m_httpServer = m_gridCore.GetHttpServer();
94 94
95 m_httpServer.AddXmlRPCHandler("simulator_login", XmlRpcSimulatorLoginMethod); 95 m_httpServer.AddXmlRPCHandler("simulator_login", XmlRpcSimulatorLoginMethod);
96 m_httpServer.AddXmlRPCHandler("simulator_data_request", XmlRpcSimulatorDataRequestMethod); 96 m_httpServer.AddXmlRPCHandler("simulator_data_request", XmlRpcSimulatorDataRequestMethod);
97 m_httpServer.AddXmlRPCHandler("simulator_after_region_moved", XmlRpcDeleteRegionMethod); 97 m_httpServer.AddXmlRPCHandler("simulator_after_region_moved", XmlRpcDeleteRegionMethod);
98 m_httpServer.AddXmlRPCHandler("map_block", XmlRpcMapBlockMethod); 98 m_httpServer.AddXmlRPCHandler("map_block", XmlRpcMapBlockMethod);
99 m_httpServer.AddXmlRPCHandler("search_for_region_by_name", XmlRpcSearchForRegionMethod); 99 m_httpServer.AddXmlRPCHandler("search_for_region_by_name", XmlRpcSearchForRegionMethod);
100 } 100 }
101 101
102 /// <summary> 102 /// <summary>
103 /// Returns a XML String containing a list of the neighbouring regions 103 /// Returns a XML String containing a list of the neighbouring regions
104 /// </summary> 104 /// </summary>
105 /// <param name="reqhandle">The regionhandle for the center sim</param> 105 /// <param name="reqhandle">The regionhandle for the center sim</param>
106 /// <returns>An XML string containing neighbour entities</returns> 106 /// <returns>An XML string containing neighbour entities</returns>
107 public string GetXMLNeighbours(ulong reqhandle) 107 public string GetXMLNeighbours(ulong reqhandle)
108 { 108 {
109 string response = String.Empty; 109 string response = String.Empty;
110 RegionProfileData central_region = m_gridDBService.GetRegion(reqhandle); 110 RegionProfileData central_region = m_gridDBService.GetRegion(reqhandle);
111 RegionProfileData neighbour; 111 RegionProfileData neighbour;
112 for (int x = -1; x < 2; x++) 112 for (int x = -1; x < 2; x++)
113 { 113 {
114 for (int y = -1; y < 2; y++) 114 for (int y = -1; y < 2; y++)
115 { 115 {
116 if ( 116 if (
117 m_gridDBService.GetRegion( 117 m_gridDBService.GetRegion(
118 Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize), 118 Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize),
119 (uint)(central_region.regionLocY + y) * Constants.RegionSize)) != null) 119 (uint)(central_region.regionLocY + y) * Constants.RegionSize)) != null)
120 { 120 {
121 neighbour = 121 neighbour =
122 m_gridDBService.GetRegion( 122 m_gridDBService.GetRegion(
123 Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize), 123 Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize),
124 (uint)(central_region.regionLocY + y) * Constants.RegionSize)); 124 (uint)(central_region.regionLocY + y) * Constants.RegionSize));
125 125
126 response += "<neighbour>"; 126 response += "<neighbour>";
127 response += "<sim_ip>" + neighbour.serverIP + "</sim_ip>"; 127 response += "<sim_ip>" + neighbour.serverIP + "</sim_ip>";
128 response += "<sim_port>" + neighbour.serverPort.ToString() + "</sim_port>"; 128 response += "<sim_port>" + neighbour.serverPort.ToString() + "</sim_port>";
129 response += "<locx>" + neighbour.regionLocX.ToString() + "</locx>"; 129 response += "<locx>" + neighbour.regionLocX.ToString() + "</locx>";
130 response += "<locy>" + neighbour.regionLocY.ToString() + "</locy>"; 130 response += "<locy>" + neighbour.regionLocY.ToString() + "</locy>";
131 response += "<regionhandle>" + neighbour.regionHandle.ToString() + "</regionhandle>"; 131 response += "<regionhandle>" + neighbour.regionHandle.ToString() + "</regionhandle>";
132 response += "</neighbour>"; 132 response += "</neighbour>";
133 } 133 }
134 } 134 }
135 } 135 }
136 return response; 136 return response;
137 } 137 }
138 138
139 /// <summary> 139 /// <summary>
140 /// Checks that it's valid to replace the existing region data with new data 140 /// Checks that it's valid to replace the existing region data with new data
141 /// 141 ///
142 /// Currently, this means ensure that the keys passed in by the new region 142 /// Currently, this means ensure that the keys passed in by the new region
143 /// match those in the original region. (XXX Is this correct? Shouldn't we simply check 143 /// match those in the original region. (XXX Is this correct? Shouldn't we simply check
144 /// against the keys in the current configuration?) 144 /// against the keys in the current configuration?)
145 /// </summary> 145 /// </summary>
146 /// <param name="sim"></param> 146 /// <param name="sim"></param>
147 /// <returns></returns> 147 /// <returns></returns>
148 protected virtual void ValidateOverwriteKeys(RegionProfileData sim, RegionProfileData existingSim) 148 protected virtual void ValidateOverwriteKeys(RegionProfileData sim, RegionProfileData existingSim)
149 { 149 {
150 if (!(existingSim.regionRecvKey == sim.regionRecvKey && existingSim.regionSendKey == sim.regionSendKey)) 150 if (!(existingSim.regionRecvKey == sim.regionRecvKey && existingSim.regionSendKey == sim.regionSendKey))
151 { 151 {
152 throw new LoginException( 152 throw new LoginException(
153 String.Format( 153 String.Format(
154 "Authentication failed when trying to login existing region {0} at location {1} {2} currently occupied by {3}" 154 "Authentication failed when trying to login existing region {0} at location {1} {2} currently occupied by {3}"
155 + " with the region's send key {4} (expected {5}) and the region's receive key {6} (expected {7})", 155 + " with the region's send key {4} (expected {5}) and the region's receive key {6} (expected {7})",
156 sim.regionName, sim.regionLocX, sim.regionLocY, existingSim.regionName, 156 sim.regionName, sim.regionLocX, sim.regionLocY, existingSim.regionName,
157 sim.regionSendKey, existingSim.regionSendKey, sim.regionRecvKey, existingSim.regionRecvKey), 157 sim.regionSendKey, existingSim.regionSendKey, sim.regionRecvKey, existingSim.regionRecvKey),
158 "The keys required to login your region did not match the grid server keys. Please check your grid send and receive keys."); 158 "The keys required to login your region did not match the grid server keys. Please check your grid send and receive keys.");
159 } 159 }
160 } 160 }
161 161
162 /// <summary> 162 /// <summary>
163 /// Checks that the new region data is valid. 163 /// Checks that the new region data is valid.
164 /// 164 ///
165 /// Currently, this means checking that the keys passed in by the new region 165 /// Currently, this means checking that the keys passed in by the new region
166 /// match those in the grid server's configuration. 166 /// match those in the grid server's configuration.
167 /// </summary> 167 /// </summary>
168 /// 168 ///
169 /// <param name="sim"></param> 169 /// <param name="sim"></param>
170 /// <exception cref="LoginException">Thrown if region login failed</exception> 170 /// <exception cref="LoginException">Thrown if region login failed</exception>
171 protected virtual void ValidateNewRegionKeys(RegionProfileData sim) 171 protected virtual void ValidateNewRegionKeys(RegionProfileData sim)
172 { 172 {
173 if (!(sim.regionRecvKey == m_config.SimSendKey && sim.regionSendKey == m_config.SimRecvKey)) 173 if (!(sim.regionRecvKey == m_config.SimSendKey && sim.regionSendKey == m_config.SimRecvKey))
174 { 174 {
175 throw new LoginException( 175 throw new LoginException(
176 String.Format( 176 String.Format(
177 "Authentication failed when trying to login new region {0} at location {1} {2}" 177 "Authentication failed when trying to login new region {0} at location {1} {2}"
178 + " with the region's send key {3} (expected {4}) and the region's receive key {5} (expected {6})", 178 + " with the region's send key {3} (expected {4}) and the region's receive key {5} (expected {6})",
179 sim.regionName, sim.regionLocX, sim.regionLocY, 179 sim.regionName, sim.regionLocX, sim.regionLocY,
180 sim.regionSendKey, m_config.SimRecvKey, sim.regionRecvKey, m_config.SimSendKey), 180 sim.regionSendKey, m_config.SimRecvKey, sim.regionRecvKey, m_config.SimSendKey),
181 "The keys required to login your region did not match your existing region keys. Please check your grid send and receive keys."); 181 "The keys required to login your region did not match your existing region keys. Please check your grid send and receive keys.");
182 } 182 }
183 } 183 }
184 184
185 /// <summary> 185 /// <summary>
186 /// Check that a region's http uri is externally contactable. 186 /// Check that a region's http uri is externally contactable.
187 /// </summary> 187 /// </summary>
188 /// <param name="sim"></param> 188 /// <param name="sim"></param>
189 /// <exception cref="LoginException">Thrown if the region is not contactable</exception> 189 /// <exception cref="LoginException">Thrown if the region is not contactable</exception>
190 protected virtual void ValidateRegionContactable(RegionProfileData sim) 190 protected virtual void ValidateRegionContactable(RegionProfileData sim)
191 { 191 {
192 string regionStatusUrl = String.Format("{0}{1}", sim.httpServerURI, "simstatus/"); 192 string regionStatusUrl = String.Format("{0}{1}", sim.httpServerURI, "simstatus/");
193 string regionStatusResponse; 193 string regionStatusResponse;
194 194
195 RestClient rc = new RestClient(regionStatusUrl); 195 RestClient rc = new RestClient(regionStatusUrl);
196 rc.RequestMethod = "GET"; 196 rc.RequestMethod = "GET";
197 197
198 m_log.DebugFormat("[LOGIN]: Contacting {0} for status of region {1}", regionStatusUrl, sim.regionName); 198 m_log.DebugFormat("[LOGIN]: Contacting {0} for status of region {1}", regionStatusUrl, sim.regionName);
199 199
200 try 200 try
201 { 201 {
202 Stream rs = rc.Request(); 202 Stream rs = rc.Request();
203 StreamReader sr = new StreamReader(rs); 203 StreamReader sr = new StreamReader(rs);
204 regionStatusResponse = sr.ReadToEnd(); 204 regionStatusResponse = sr.ReadToEnd();
205 sr.Close(); 205 sr.Close();
206 } 206 }
207 catch (Exception e) 207 catch (Exception e)
208 { 208 {
209 throw new LoginException( 209 throw new LoginException(
210 String.Format("Region status request to {0} failed", regionStatusUrl), 210 String.Format("Region status request to {0} failed", regionStatusUrl),
211 String.Format( 211 String.Format(
212 "The grid service could not contact the http url {0} at your region. Please make sure this url is reachable by the grid service", 212 "The grid service could not contact the http url {0} at your region. Please make sure this url is reachable by the grid service",
213 regionStatusUrl), 213 regionStatusUrl),
214 e); 214 e);
215 } 215 }
216 216
217 if (!regionStatusResponse.Equals("OK")) 217 if (!regionStatusResponse.Equals("OK"))
218 { 218 {
219 throw new LoginException( 219 throw new LoginException(
220 String.Format( 220 String.Format(
221 "Region {0} at {1} returned status response {2} rather than {3}", 221 "Region {0} at {1} returned status response {2} rather than {3}",
222 sim.regionName, regionStatusUrl, regionStatusResponse, "OK"), 222 sim.regionName, regionStatusUrl, regionStatusResponse, "OK"),
223 String.Format( 223 String.Format(
224 "When the grid service asked for the status of your region, it received the response {0} rather than {1}. Please check your status", 224 "When the grid service asked for the status of your region, it received the response {0} rather than {1}. Please check your status",
225 regionStatusResponse, "OK")); 225 regionStatusResponse, "OK"));
226 } 226 }
227 } 227 }
228 228
229 /// <summary> 229 /// <summary>
230 /// Construct an XMLRPC error response 230 /// Construct an XMLRPC error response
231 /// </summary> 231 /// </summary>
232 /// <param name="error"></param> 232 /// <param name="error"></param>
233 /// <returns></returns> 233 /// <returns></returns>
234 public static XmlRpcResponse ErrorResponse(string error) 234 public static XmlRpcResponse ErrorResponse(string error)
235 { 235 {
236 XmlRpcResponse errorResponse = new XmlRpcResponse(); 236 XmlRpcResponse errorResponse = new XmlRpcResponse();
237 Hashtable errorResponseData = new Hashtable(); 237 Hashtable errorResponseData = new Hashtable();
238 errorResponse.Value = errorResponseData; 238 errorResponse.Value = errorResponseData;
239 errorResponseData["error"] = error; 239 errorResponseData["error"] = error;
240 return errorResponse; 240 return errorResponse;
241 } 241 }
242 242
243 /// <summary> 243 /// <summary>
244 /// Performed when a region connects to the grid server initially. 244 /// Performed when a region connects to the grid server initially.
245 /// </summary> 245 /// </summary>
246 /// <param name="request">The XML RPC Request</param> 246 /// <param name="request">The XML RPC Request</param>
247 /// <returns>Startup parameters</returns> 247 /// <returns>Startup parameters</returns>
248 public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request) 248 public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request)
249 { 249 {
250 RegionProfileData sim; 250 RegionProfileData sim;
251 RegionProfileData existingSim; 251 RegionProfileData existingSim;
252 252
253 Hashtable requestData = (Hashtable)request.Params[0]; 253 Hashtable requestData = (Hashtable)request.Params[0];
254 UUID uuid; 254 UUID uuid;
255 255
256 if (!requestData.ContainsKey("UUID") || !UUID.TryParse((string)requestData["UUID"], out uuid)) 256 if (!requestData.ContainsKey("UUID") || !UUID.TryParse((string)requestData["UUID"], out uuid))
257 { 257 {
258 m_log.Debug("[LOGIN PRELUDE]: Region connected without a UUID, sending back error response."); 258 m_log.Debug("[LOGIN PRELUDE]: Region connected without a UUID, sending back error response.");
259 return ErrorResponse("No UUID passed to grid server - unable to connect you"); 259 return ErrorResponse("No UUID passed to grid server - unable to connect you");
260 } 260 }
261 261
262 try 262 try
263 { 263 {
264 sim = RegionFromRequest(requestData); 264 sim = RegionFromRequest(requestData);
265 } 265 }
266 catch (FormatException e) 266 catch (FormatException e)
267 { 267 {
268 m_log.Debug("[LOGIN PRELUDE]: Invalid login parameters, sending back error response."); 268 m_log.Debug("[LOGIN PRELUDE]: Invalid login parameters, sending back error response.");
269 return ErrorResponse("Wrong format in login parameters. Please verify parameters." + e.ToString()); 269 return ErrorResponse("Wrong format in login parameters. Please verify parameters." + e.ToString());
270 } 270 }
271 271
272 m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); 272 m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName);
273 273
274 if (!m_config.AllowRegionRegistration) 274 if (!m_config.AllowRegionRegistration)
275 { 275 {
276 m_log.DebugFormat( 276 m_log.DebugFormat(
277 "[LOGIN END]: Disabled region registration blocked login request from simulator: {0}", 277 "[LOGIN END]: Disabled region registration blocked login request from simulator: {0}",
278 sim.regionName); 278 sim.regionName);
279 279
280 return ErrorResponse("This grid is currently not accepting region registrations."); 280 return ErrorResponse("This grid is currently not accepting region registrations.");
281 } 281 }
282 282
283 int majorInterfaceVersion = 0; 283 int majorInterfaceVersion = 0;
284 if (requestData.ContainsKey("major_interface_version")) 284 if (requestData.ContainsKey("major_interface_version"))
285 int.TryParse((string)requestData["major_interface_version"], out majorInterfaceVersion); 285 int.TryParse((string)requestData["major_interface_version"], out majorInterfaceVersion);
286 286
287 if (majorInterfaceVersion != VersionInfo.MajorInterfaceVersion) 287 if (majorInterfaceVersion != VersionInfo.MajorInterfaceVersion)
288 { 288 {
289 return ErrorResponse( 289 return ErrorResponse(
290 String.Format( 290 String.Format(
291 "Your region service implements OGS1 interface version {0}" 291 "Your region service implements OGS1 interface version {0}"
292 + " but this grid requires that the region implement OGS1 interface version {1} to connect." 292 + " but this grid requires that the region implement OGS1 interface version {1} to connect."
293 + " Try changing to OpenSimulator {2}", 293 + " Try changing to OpenSimulator {2}",
294 majorInterfaceVersion, VersionInfo.MajorInterfaceVersion, m_opensimVersion)); 294 majorInterfaceVersion, VersionInfo.MajorInterfaceVersion, m_opensimVersion));
295 } 295 }
296 296
297 existingSim = m_gridDBService.GetRegion(sim.regionHandle); 297 existingSim = m_gridDBService.GetRegion(sim.regionHandle);
298 298
299 if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID) 299 if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID)
300 { 300 {
301 try 301 try
302 { 302 {
303 if (existingSim == null) 303 if (existingSim == null)
304 { 304 {
305 ValidateNewRegionKeys(sim); 305 ValidateNewRegionKeys(sim);
306 } 306 }
307 else 307 else
308 { 308 {
309 ValidateOverwriteKeys(sim, existingSim); 309 ValidateOverwriteKeys(sim, existingSim);
310 } 310 }
311 311
312 ValidateRegionContactable(sim); 312 ValidateRegionContactable(sim);
313 } 313 }
314 catch (LoginException e) 314 catch (LoginException e)
315 { 315 {
316 string logMsg = e.Message; 316 string logMsg = e.Message;
317 if (e.InnerException != null) 317 if (e.InnerException != null)
318 logMsg += ", " + e.InnerException.Message; 318 logMsg += ", " + e.InnerException.Message;
319 319
320 m_log.WarnFormat("[LOGIN END]: {0}", logMsg); 320 m_log.WarnFormat("[LOGIN END]: {0}", logMsg);
321 321
322 return e.XmlRpcErrorResponse; 322 return e.XmlRpcErrorResponse;
323 } 323 }
324 324
325 DataResponse insertResponse = m_gridDBService.AddUpdateRegion(sim, existingSim); 325 DataResponse insertResponse = m_gridDBService.AddUpdateRegion(sim, existingSim);
326 326
327 switch (insertResponse) 327 switch (insertResponse)
328 { 328 {
329 case DataResponse.RESPONSE_OK: 329 case DataResponse.RESPONSE_OK:
330 m_log.Info("[LOGIN END]: " + (existingSim == null ? "New" : "Existing") + " sim login successful: " + sim.regionName); 330 m_log.Info("[LOGIN END]: " + (existingSim == null ? "New" : "Existing") + " sim login successful: " + sim.regionName);
331 break; 331 break;
332 case DataResponse.RESPONSE_ERROR: 332 case DataResponse.RESPONSE_ERROR:
333 m_log.Warn("[LOGIN END]: Sim login failed (Error): " + sim.regionName); 333 m_log.Warn("[LOGIN END]: Sim login failed (Error): " + sim.regionName);
334 break; 334 break;
335 case DataResponse.RESPONSE_INVALIDCREDENTIALS: 335 case DataResponse.RESPONSE_INVALIDCREDENTIALS:
336 m_log.Warn("[LOGIN END]: " + 336 m_log.Warn("[LOGIN END]: " +
337 "Sim login failed (Invalid Credentials): " + sim.regionName); 337 "Sim login failed (Invalid Credentials): " + sim.regionName);
338 break; 338 break;
339 case DataResponse.RESPONSE_AUTHREQUIRED: 339 case DataResponse.RESPONSE_AUTHREQUIRED:
340 m_log.Warn("[LOGIN END]: " + 340 m_log.Warn("[LOGIN END]: " +
341 "Sim login failed (Authentication Required): " + 341 "Sim login failed (Authentication Required): " +
342 sim.regionName); 342 sim.regionName);
343 break; 343 break;
344 } 344 }
345 345
346 XmlRpcResponse response = CreateLoginResponse(sim); 346 XmlRpcResponse response = CreateLoginResponse(sim);
347 347
348 return response; 348 return response;
349 } 349 }
350 else 350 else
351 { 351 {
352 m_log.Warn("[LOGIN END]: Failed to login region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + " currently occupied by " + existingSim.regionName); 352 m_log.Warn("[LOGIN END]: Failed to login region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + " currently occupied by " + existingSim.regionName);
353 return ErrorResponse("Another region already exists at that location. Please try another."); 353 return ErrorResponse("Another region already exists at that location. Please try another.");
354 } 354 }
355 } 355 }
356 356
357 /// <summary> 357 /// <summary>
358 /// Construct a successful response to a simulator's login attempt. 358 /// Construct a successful response to a simulator's login attempt.
359 /// </summary> 359 /// </summary>
360 /// <param name="sim"></param> 360 /// <param name="sim"></param>
361 /// <returns></returns> 361 /// <returns></returns>
362 private XmlRpcResponse CreateLoginResponse(RegionProfileData sim) 362 private XmlRpcResponse CreateLoginResponse(RegionProfileData sim)
363 { 363 {
364 XmlRpcResponse response = new XmlRpcResponse(); 364 XmlRpcResponse response = new XmlRpcResponse();
365 Hashtable responseData = new Hashtable(); 365 Hashtable responseData = new Hashtable();
366 response.Value = responseData; 366 response.Value = responseData;
367 367
368 ArrayList SimNeighboursData = GetSimNeighboursData(sim); 368 ArrayList SimNeighboursData = GetSimNeighboursData(sim);
369 369
370 responseData["UUID"] = sim.UUID.ToString(); 370 responseData["UUID"] = sim.UUID.ToString();
371 responseData["region_locx"] = sim.regionLocX.ToString(); 371 responseData["region_locx"] = sim.regionLocX.ToString();
372 responseData["region_locy"] = sim.regionLocY.ToString(); 372 responseData["region_locy"] = sim.regionLocY.ToString();
373 responseData["regionname"] = sim.regionName; 373 responseData["regionname"] = sim.regionName;
374 responseData["estate_id"] = "1"; 374 responseData["estate_id"] = "1";
375 responseData["neighbours"] = SimNeighboursData; 375 responseData["neighbours"] = SimNeighboursData;
376 376
377 responseData["sim_ip"] = sim.serverIP; 377 responseData["sim_ip"] = sim.serverIP;
378 responseData["sim_port"] = sim.serverPort.ToString(); 378 responseData["sim_port"] = sim.serverPort.ToString();
379 responseData["asset_url"] = sim.regionAssetURI; 379 responseData["asset_url"] = sim.regionAssetURI;
380 responseData["asset_sendkey"] = sim.regionAssetSendKey; 380 responseData["asset_sendkey"] = sim.regionAssetSendKey;
381 responseData["asset_recvkey"] = sim.regionAssetRecvKey; 381 responseData["asset_recvkey"] = sim.regionAssetRecvKey;
382 responseData["user_url"] = sim.regionUserURI; 382 responseData["user_url"] = sim.regionUserURI;
383 responseData["user_sendkey"] = sim.regionUserSendKey; 383 responseData["user_sendkey"] = sim.regionUserSendKey;
384 responseData["user_recvkey"] = sim.regionUserRecvKey; 384 responseData["user_recvkey"] = sim.regionUserRecvKey;
385 responseData["authkey"] = sim.regionSecret; 385 responseData["authkey"] = sim.regionSecret;
386 386
387 // New! If set, use as URL to local sim storage (ie http://remotehost/region.Yap) 387 // New! If set, use as URL to local sim storage (ie http://remotehost/region.Yap)
388 responseData["data_uri"] = sim.regionDataURI; 388 responseData["data_uri"] = sim.regionDataURI;
389 389
390 responseData["allow_forceful_banlines"] = m_config.AllowForcefulBanlines; 390 responseData["allow_forceful_banlines"] = m_config.AllowForcefulBanlines;
391 391
392 // Instead of sending a multitude of message servers to the registering sim 392 // Instead of sending a multitude of message servers to the registering sim
393 // we should probably be sending a single one and parhaps it's backup 393 // we should probably be sending a single one and parhaps it's backup
394 // that has responsibility over routing it's messages. 394 // that has responsibility over routing it's messages.
395 395
396 // The Sim won't be contacting us again about any of the message server stuff during it's time up. 396 // The Sim won't be contacting us again about any of the message server stuff during it's time up.
397 397
398 responseData["messageserver_count"] = 0; 398 responseData["messageserver_count"] = 0;
399 399
400 // IGridMessagingModule messagingModule; 400 // IGridMessagingModule messagingModule;
401 // if (m_gridCore.TryGet<IGridMessagingModule>(out messagingModule)) 401 // if (m_gridCore.TryGet<IGridMessagingModule>(out messagingModule))
402 //{ 402 //{
403 if(m_messagingServerMapper != null) 403 if(m_messagingServerMapper != null)
404 { 404 {
405 List<MessageServerInfo> messageServers = m_messagingServerMapper.GetMessageServersList(); 405 List<MessageServerInfo> messageServers = m_messagingServerMapper.GetMessageServersList();
406 responseData["messageserver_count"] = messageServers.Count; 406 responseData["messageserver_count"] = messageServers.Count;
407 407
408 for (int i = 0; i < messageServers.Count; i++) 408 for (int i = 0; i < messageServers.Count; i++)
409 { 409 {
410 responseData["messageserver_uri" + i] = messageServers[i].URI; 410 responseData["messageserver_uri" + i] = messageServers[i].URI;
411 responseData["messageserver_sendkey" + i] = messageServers[i].sendkey; 411 responseData["messageserver_sendkey" + i] = messageServers[i].sendkey;
412 responseData["messageserver_recvkey" + i] = messageServers[i].recvkey; 412 responseData["messageserver_recvkey" + i] = messageServers[i].recvkey;
413 } 413 }
414 } 414 }
415 return response; 415 return response;
416 } 416 }
417 417
418 private ArrayList GetSimNeighboursData(RegionProfileData sim) 418 private ArrayList GetSimNeighboursData(RegionProfileData sim)
419 { 419 {
420 ArrayList SimNeighboursData = new ArrayList(); 420 ArrayList SimNeighboursData = new ArrayList();
421 421
422 RegionProfileData neighbour; 422 RegionProfileData neighbour;
423 Hashtable NeighbourBlock; 423 Hashtable NeighbourBlock;
424 424
425 //First use the fast method. (not implemented in SQLLite) 425 //First use the fast method. (not implemented in SQLLite)
426 List<RegionProfileData> neighbours = m_gridDBService.GetRegions(sim.regionLocX - 1, sim.regionLocY - 1, sim.regionLocX + 1, sim.regionLocY + 1); 426 List<RegionProfileData> neighbours = m_gridDBService.GetRegions(sim.regionLocX - 1, sim.regionLocY - 1, sim.regionLocX + 1, sim.regionLocY + 1);
427 427
428 if (neighbours.Count > 0) 428 if (neighbours.Count > 0)
429 { 429 {
430 foreach (RegionProfileData aSim in neighbours) 430 foreach (RegionProfileData aSim in neighbours)
431 { 431 {
432 NeighbourBlock = new Hashtable(); 432 NeighbourBlock = new Hashtable();
433 NeighbourBlock["sim_ip"] = aSim.serverIP; 433 NeighbourBlock["sim_ip"] = aSim.serverIP;
434 NeighbourBlock["sim_port"] = aSim.serverPort.ToString(); 434 NeighbourBlock["sim_port"] = aSim.serverPort.ToString();
435 NeighbourBlock["region_locx"] = aSim.regionLocX.ToString(); 435 NeighbourBlock["region_locx"] = aSim.regionLocX.ToString();
436 NeighbourBlock["region_locy"] = aSim.regionLocY.ToString(); 436 NeighbourBlock["region_locy"] = aSim.regionLocY.ToString();
437 NeighbourBlock["UUID"] = aSim.ToString(); 437 NeighbourBlock["UUID"] = aSim.ToString();
438 NeighbourBlock["regionHandle"] = aSim.regionHandle.ToString(); 438 NeighbourBlock["regionHandle"] = aSim.regionHandle.ToString();
439 439
440 if (aSim.UUID != sim.UUID) 440 if (aSim.UUID != sim.UUID)
441 { 441 {
442 SimNeighboursData.Add(NeighbourBlock); 442 SimNeighboursData.Add(NeighbourBlock);
443 } 443 }
444 } 444 }
445 } 445 }
446 else 446 else
447 { 447 {
448 for (int x = -1; x < 2; x++) 448 for (int x = -1; x < 2; x++)
449 { 449 {
450 for (int y = -1; y < 2; y++) 450 for (int y = -1; y < 2; y++)
451 { 451 {
452 if ( 452 if (
453 m_gridDBService.GetRegion( 453 m_gridDBService.GetRegion(
454 Utils.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize), 454 Utils.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize),
455 (uint)(sim.regionLocY + y) * Constants.RegionSize)) != null) 455 (uint)(sim.regionLocY + y) * Constants.RegionSize)) != null)
456 { 456 {
457 neighbour = 457 neighbour =
458 m_gridDBService.GetRegion( 458 m_gridDBService.GetRegion(
459 Utils.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize), 459 Utils.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize),
460 (uint)(sim.regionLocY + y) * Constants.RegionSize)); 460 (uint)(sim.regionLocY + y) * Constants.RegionSize));
461 461
462 NeighbourBlock = new Hashtable(); 462 NeighbourBlock = new Hashtable();
463 NeighbourBlock["sim_ip"] = neighbour.serverIP; 463 NeighbourBlock["sim_ip"] = neighbour.serverIP;
464 NeighbourBlock["sim_port"] = neighbour.serverPort.ToString(); 464 NeighbourBlock["sim_port"] = neighbour.serverPort.ToString();
465 NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString(); 465 NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString();
466 NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString(); 466 NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString();
467 NeighbourBlock["UUID"] = neighbour.UUID.ToString(); 467 NeighbourBlock["UUID"] = neighbour.UUID.ToString();
468 NeighbourBlock["regionHandle"] = neighbour.regionHandle.ToString(); 468 NeighbourBlock["regionHandle"] = neighbour.regionHandle.ToString();
469 469
470 if (neighbour.UUID != sim.UUID) SimNeighboursData.Add(NeighbourBlock); 470 if (neighbour.UUID != sim.UUID) SimNeighboursData.Add(NeighbourBlock);
471 } 471 }
472 } 472 }
473 } 473 }
474 } 474 }
475 return SimNeighboursData; 475 return SimNeighboursData;
476 } 476 }
477 477
478 /// <summary> 478 /// <summary>
479 /// Loads the grid's own RegionProfileData object with data from the XMLRPC simulator_login request from a region 479 /// Loads the grid's own RegionProfileData object with data from the XMLRPC simulator_login request from a region
480 /// </summary> 480 /// </summary>
481 /// <param name="requestData"></param> 481 /// <param name="requestData"></param>
482 /// <returns></returns> 482 /// <returns></returns>
483 private RegionProfileData RegionFromRequest(Hashtable requestData) 483 private RegionProfileData RegionFromRequest(Hashtable requestData)
484 { 484 {
485 RegionProfileData sim; 485 RegionProfileData sim;
486 sim = new RegionProfileData(); 486 sim = new RegionProfileData();
487 487
488 sim.UUID = new UUID((string)requestData["UUID"]); 488 sim.UUID = new UUID((string)requestData["UUID"]);
489 sim.originUUID = new UUID((string)requestData["originUUID"]); 489 sim.originUUID = new UUID((string)requestData["originUUID"]);
490 490
491 sim.regionRecvKey = String.Empty; 491 sim.regionRecvKey = String.Empty;
492 sim.regionSendKey = String.Empty; 492 sim.regionSendKey = String.Empty;
493 493
494 if (requestData.ContainsKey("region_secret")) 494 if (requestData.ContainsKey("region_secret"))
495 { 495 {
496 string regionsecret = (string)requestData["region_secret"]; 496 string regionsecret = (string)requestData["region_secret"];
497 if (regionsecret.Length > 0) 497 if (regionsecret.Length > 0)
498 sim.regionSecret = regionsecret; 498 sim.regionSecret = regionsecret;
499 else 499 else
500 sim.regionSecret = m_config.SimRecvKey; 500 sim.regionSecret = m_config.SimRecvKey;
501 501
502 } 502 }
503 else 503 else
504 { 504 {
505 sim.regionSecret = m_config.SimRecvKey; 505 sim.regionSecret = m_config.SimRecvKey;
506 } 506 }
507 507
508 sim.regionDataURI = String.Empty; 508 sim.regionDataURI = String.Empty;
509 sim.regionAssetURI = m_config.DefaultAssetServer; 509 sim.regionAssetURI = m_config.DefaultAssetServer;
510 sim.regionAssetRecvKey = m_config.AssetRecvKey; 510 sim.regionAssetRecvKey = m_config.AssetRecvKey;
511 sim.regionAssetSendKey = m_config.AssetSendKey; 511 sim.regionAssetSendKey = m_config.AssetSendKey;
512 sim.regionUserURI = m_config.DefaultUserServer; 512 sim.regionUserURI = m_config.DefaultUserServer;
513 sim.regionUserSendKey = m_config.UserSendKey; 513 sim.regionUserSendKey = m_config.UserSendKey;
514 sim.regionUserRecvKey = m_config.UserRecvKey; 514 sim.regionUserRecvKey = m_config.UserRecvKey;
515 515
516 sim.serverIP = (string)requestData["sim_ip"]; 516 sim.serverIP = (string)requestData["sim_ip"];
517 sim.serverPort = Convert.ToUInt32((string)requestData["sim_port"]); 517 sim.serverPort = Convert.ToUInt32((string)requestData["sim_port"]);
518 sim.httpPort = Convert.ToUInt32((string)requestData["http_port"]); 518 sim.httpPort = Convert.ToUInt32((string)requestData["http_port"]);
519 sim.remotingPort = Convert.ToUInt32((string)requestData["remoting_port"]); 519 sim.remotingPort = Convert.ToUInt32((string)requestData["remoting_port"]);
520 sim.regionLocX = Convert.ToUInt32((string)requestData["region_locx"]); 520 sim.regionLocX = Convert.ToUInt32((string)requestData["region_locx"]);
521 sim.regionLocY = Convert.ToUInt32((string)requestData["region_locy"]); 521 sim.regionLocY = Convert.ToUInt32((string)requestData["region_locy"]);
522 sim.regionLocZ = 0; 522 sim.regionLocZ = 0;
523 523
524 UUID textureID; 524 UUID textureID;
525 if (UUID.TryParse((string)requestData["map-image-id"], out textureID)) 525 if (UUID.TryParse((string)requestData["map-image-id"], out textureID))
526 { 526 {
527 sim.regionMapTextureID = textureID; 527 sim.regionMapTextureID = textureID;
528 } 528 }
529 529
530 // part of an initial brutish effort to provide accurate information (as per the xml region spec) 530 // part of an initial brutish effort to provide accurate information (as per the xml region spec)
531 // wrt the ownership of a given region 531 // wrt the ownership of a given region
532 // the (very bad) assumption is that this value is being read and handled inconsistently or 532 // the (very bad) assumption is that this value is being read and handled inconsistently or
533 // not at all. Current strategy is to put the code in place to support the validity of this information 533 // not at all. Current strategy is to put the code in place to support the validity of this information
534 // and to roll forward debugging any issues from that point 534 // and to roll forward debugging any issues from that point
535 // 535 //
536 // this particular section of the mod attempts to receive a value from the region's xml file by way of 536 // this particular section of the mod attempts to receive a value from the region's xml file by way of
537 // OSG1GridServices for the region's owner 537 // OSG1GridServices for the region's owner
538 sim.owner_uuid = (UUID)(string)requestData["master_avatar_uuid"]; 538 sim.owner_uuid = (UUID)(string)requestData["master_avatar_uuid"];
539 539
540 try 540 try
541 { 541 {
542 sim.regionRecvKey = (string)requestData["recvkey"]; 542 sim.regionRecvKey = (string)requestData["recvkey"];
543 sim.regionSendKey = (string)requestData["authkey"]; 543 sim.regionSendKey = (string)requestData["authkey"];
544 } 544 }
545 catch (KeyNotFoundException) { } 545 catch (KeyNotFoundException) { }
546 546
547 sim.regionHandle = Utils.UIntsToLong((sim.regionLocX * Constants.RegionSize), (sim.regionLocY * Constants.RegionSize)); 547 sim.regionHandle = Utils.UIntsToLong((sim.regionLocX * Constants.RegionSize), (sim.regionLocY * Constants.RegionSize));
548 sim.serverURI = (string)requestData["server_uri"]; 548 sim.serverURI = (string)requestData["server_uri"];
549 549
550 sim.httpServerURI = "http://" + sim.serverIP + ":" + sim.httpPort + "/"; 550 sim.httpServerURI = "http://" + sim.serverIP + ":" + sim.httpPort + "/";
551 551
552 sim.regionName = (string)requestData["sim_name"]; 552 sim.regionName = (string)requestData["sim_name"];
553 return sim; 553 return sim;
554 } 554 }
555 555
556 /// <summary> 556 /// <summary>
557 /// Returns an XML RPC response to a simulator profile request 557 /// Returns an XML RPC response to a simulator profile request
558 /// Performed after moving a region. 558 /// Performed after moving a region.
559 /// </summary> 559 /// </summary>
560 /// <param name="request"></param> 560 /// <param name="request"></param>
561 /// <returns></returns> 561 /// <returns></returns>
562 /// <param name="request">The XMLRPC Request</param> 562 /// <param name="request">The XMLRPC Request</param>
563 /// <returns>Processing parameters</returns> 563 /// <returns>Processing parameters</returns>
564 public XmlRpcResponse XmlRpcDeleteRegionMethod(XmlRpcRequest request) 564 public XmlRpcResponse XmlRpcDeleteRegionMethod(XmlRpcRequest request)
565 { 565 {
566 XmlRpcResponse response = new XmlRpcResponse(); 566 XmlRpcResponse response = new XmlRpcResponse();
567 Hashtable responseData = new Hashtable(); 567 Hashtable responseData = new Hashtable();
568 response.Value = responseData; 568 response.Value = responseData;
569 569
570 //RegionProfileData TheSim = null; 570 //RegionProfileData TheSim = null;
571 string uuid; 571 string uuid;
572 Hashtable requestData = (Hashtable)request.Params[0]; 572 Hashtable requestData = (Hashtable)request.Params[0];
573 573
574 if (requestData.ContainsKey("UUID")) 574 if (requestData.ContainsKey("UUID"))
575 { 575 {
576 //TheSim = GetRegion(new UUID((string) requestData["UUID"])); 576 //TheSim = GetRegion(new UUID((string) requestData["UUID"]));
577 uuid = requestData["UUID"].ToString(); 577 uuid = requestData["UUID"].ToString();
578 m_log.InfoFormat("[LOGOUT]: Logging out region: {0}", uuid); 578 m_log.InfoFormat("[LOGOUT]: Logging out region: {0}", uuid);
579 // logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcDeleteRegionMethod","", 5,"Attempting delete with UUID."); 579 // logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcDeleteRegionMethod","", 5,"Attempting delete with UUID.");
580 } 580 }
581 else 581 else
582 { 582 {
583 responseData["error"] = "No UUID or region_handle passed to grid server - unable to delete"; 583 responseData["error"] = "No UUID or region_handle passed to grid server - unable to delete";
584 return response; 584 return response;
585 } 585 }
586 586
587 DataResponse insertResponse = m_gridDBService.DeleteRegion(uuid); 587 DataResponse insertResponse = m_gridDBService.DeleteRegion(uuid);
588 588
589 string insertResp = ""; 589 string insertResp = "";
590 switch (insertResponse) 590 switch (insertResponse)
591 { 591 {
592 case DataResponse.RESPONSE_OK: 592 case DataResponse.RESPONSE_OK:
593 //MainLog.Instance.Verbose("grid", "Deleting region successful: " + uuid); 593 //MainLog.Instance.Verbose("grid", "Deleting region successful: " + uuid);
594 insertResp = "Deleting region successful: " + uuid; 594 insertResp = "Deleting region successful: " + uuid;
595 break; 595 break;
596 case DataResponse.RESPONSE_ERROR: 596 case DataResponse.RESPONSE_ERROR:
597 //MainLog.Instance.Warn("storage", "Deleting region failed (Error): " + uuid); 597 //MainLog.Instance.Warn("storage", "Deleting region failed (Error): " + uuid);
598 insertResp = "Deleting region failed (Error): " + uuid; 598 insertResp = "Deleting region failed (Error): " + uuid;
599 break; 599 break;
600 case DataResponse.RESPONSE_INVALIDCREDENTIALS: 600 case DataResponse.RESPONSE_INVALIDCREDENTIALS:
601 //MainLog.Instance.Warn("storage", "Deleting region failed (Invalid Credentials): " + uuid); 601 //MainLog.Instance.Warn("storage", "Deleting region failed (Invalid Credentials): " + uuid);
602 insertResp = "Deleting region (Invalid Credentials): " + uuid; 602 insertResp = "Deleting region (Invalid Credentials): " + uuid;
603 break; 603 break;
604 case DataResponse.RESPONSE_AUTHREQUIRED: 604 case DataResponse.RESPONSE_AUTHREQUIRED:
605 //MainLog.Instance.Warn("storage", "Deleting region failed (Authentication Required): " + uuid); 605 //MainLog.Instance.Warn("storage", "Deleting region failed (Authentication Required): " + uuid);
606 insertResp = "Deleting region (Authentication Required): " + uuid; 606 insertResp = "Deleting region (Authentication Required): " + uuid;
607 break; 607 break;
608 } 608 }
609 609
610 responseData["status"] = insertResp; 610 responseData["status"] = insertResp;
611 611
612 return response; 612 return response;
613 } 613 }
614 614
615 /// <summary> 615 /// <summary>
616 /// Returns an XML RPC response to a simulator profile request 616 /// Returns an XML RPC response to a simulator profile request
617 /// </summary> 617 /// </summary>
618 /// <param name="request"></param> 618 /// <param name="request"></param>
619 /// <returns></returns> 619 /// <returns></returns>
620 public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request) 620 public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request)
621 { 621 {
622 Hashtable requestData = (Hashtable)request.Params[0]; 622 Hashtable requestData = (Hashtable)request.Params[0];
623 Hashtable responseData = new Hashtable(); 623 Hashtable responseData = new Hashtable();
624 RegionProfileData simData = null; 624 RegionProfileData simData = null;
625 if (requestData.ContainsKey("region_UUID")) 625 if (requestData.ContainsKey("region_UUID"))
626 { 626 {
627 UUID regionID = new UUID((string)requestData["region_UUID"]); 627 UUID regionID = new UUID((string)requestData["region_UUID"]);
628 simData = m_gridDBService.GetRegion(regionID); 628 simData = m_gridDBService.GetRegion(regionID);
629 if (simData == null) 629 if (simData == null)
630 { 630 {
631 m_log.WarnFormat("[DATA] didn't find region for regionID {0} from {1}", 631 m_log.WarnFormat("[DATA] didn't find region for regionID {0} from {1}",
632 regionID, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); 632 regionID, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
633 } 633 }
634 } 634 }
635 else if (requestData.ContainsKey("region_handle")) 635 else if (requestData.ContainsKey("region_handle"))
636 { 636 {
637 //CFK: The if/else below this makes this message redundant. 637 //CFK: The if/else below this makes this message redundant.
638 //CFK: m_log.Info("requesting data for region " + (string) requestData["region_handle"]); 638 //CFK: m_log.Info("requesting data for region " + (string) requestData["region_handle"]);
639 ulong regionHandle = Convert.ToUInt64((string)requestData["region_handle"]); 639 ulong regionHandle = Convert.ToUInt64((string)requestData["region_handle"]);
640 simData = m_gridDBService.GetRegion(regionHandle); 640 simData = m_gridDBService.GetRegion(regionHandle);
641 if (simData == null) 641 if (simData == null)
642 { 642 {
643 m_log.WarnFormat("[DATA] didn't find region for regionHandle {0} from {1}", 643 m_log.WarnFormat("[DATA] didn't find region for regionHandle {0} from {1}",
644 regionHandle, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); 644 regionHandle, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
645 } 645 }
646 } 646 }
647 else if (requestData.ContainsKey("region_name_search")) 647 else if (requestData.ContainsKey("region_name_search"))
648 { 648 {
649 string regionName = (string)requestData["region_name_search"]; 649 string regionName = (string)requestData["region_name_search"];
650 simData = m_gridDBService.GetRegion(regionName); 650 simData = m_gridDBService.GetRegion(regionName);
651 if (simData == null) 651 if (simData == null)
652 { 652 {
653 m_log.WarnFormat("[DATA] didn't find region for regionName {0} from {1}", 653 m_log.WarnFormat("[DATA] didn't find region for regionName {0} from {1}",
654 regionName, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); 654 regionName, request.Params.Count > 1 ? request.Params[1] : "unknwon source");
655 } 655 }
656 } 656 }
657 else m_log.Warn("[DATA] regionlookup without regionID, regionHandle or regionHame"); 657 else m_log.Warn("[DATA] regionlookup without regionID, regionHandle or regionHame");
658 658
659 if (simData == null) 659 if (simData == null)
660 { 660 {
661 //Sim does not exist 661 //Sim does not exist
662 responseData["error"] = "Sim does not exist"; 662 responseData["error"] = "Sim does not exist";
663 } 663 }
664 else 664 else
665 { 665 {
666 m_log.Info("[DATA]: found " + (string)simData.regionName + " regionHandle = " + 666 m_log.Info("[DATA]: found " + (string)simData.regionName + " regionHandle = " +
667 (string)requestData["region_handle"]); 667 (string)requestData["region_handle"]);
668 responseData["sim_ip"] = simData.serverIP; 668 responseData["sim_ip"] = simData.serverIP;
669 responseData["sim_port"] = simData.serverPort.ToString(); 669 responseData["sim_port"] = simData.serverPort.ToString();
670 responseData["server_uri"] = simData.serverURI; 670 responseData["server_uri"] = simData.serverURI;
671 responseData["http_port"] = simData.httpPort.ToString(); 671 responseData["http_port"] = simData.httpPort.ToString();
672 responseData["remoting_port"] = simData.remotingPort.ToString(); 672 responseData["remoting_port"] = simData.remotingPort.ToString();
673 responseData["region_locx"] = simData.regionLocX.ToString(); 673 responseData["region_locx"] = simData.regionLocX.ToString();
674 responseData["region_locy"] = simData.regionLocY.ToString(); 674 responseData["region_locy"] = simData.regionLocY.ToString();
675 responseData["region_UUID"] = simData.UUID.Guid.ToString(); 675 responseData["region_UUID"] = simData.UUID.Guid.ToString();
676 responseData["region_name"] = simData.regionName; 676 responseData["region_name"] = simData.regionName;
677 responseData["regionHandle"] = simData.regionHandle.ToString(); 677 responseData["regionHandle"] = simData.regionHandle.ToString();
678 } 678 }
679 679
680 XmlRpcResponse response = new XmlRpcResponse(); 680 XmlRpcResponse response = new XmlRpcResponse();
681 response.Value = responseData; 681 response.Value = responseData;
682 return response; 682 return response;
683 } 683 }
684 684
685 public XmlRpcResponse XmlRpcMapBlockMethod(XmlRpcRequest request) 685 public XmlRpcResponse XmlRpcMapBlockMethod(XmlRpcRequest request)
686 { 686 {
687 int xmin = 980, ymin = 980, xmax = 1020, ymax = 1020; 687 int xmin = 980, ymin = 980, xmax = 1020, ymax = 1020;
688 688
689 Hashtable requestData = (Hashtable)request.Params[0]; 689 Hashtable requestData = (Hashtable)request.Params[0];
690 if (requestData.ContainsKey("xmin")) 690 if (requestData.ContainsKey("xmin"))
691 { 691 {
692 xmin = (Int32)requestData["xmin"]; 692 xmin = (Int32)requestData["xmin"];
693 } 693 }
694 if (requestData.ContainsKey("ymin")) 694 if (requestData.ContainsKey("ymin"))
695 { 695 {
696 ymin = (Int32)requestData["ymin"]; 696 ymin = (Int32)requestData["ymin"];
697 } 697 }
698 if (requestData.ContainsKey("xmax")) 698 if (requestData.ContainsKey("xmax"))
699 { 699 {
700 xmax = (Int32)requestData["xmax"]; 700 xmax = (Int32)requestData["xmax"];
701 } 701 }
702 if (requestData.ContainsKey("ymax")) 702 if (requestData.ContainsKey("ymax"))
703 { 703 {
704 ymax = (Int32)requestData["ymax"]; 704 ymax = (Int32)requestData["ymax"];
705 } 705 }
706 //CFK: The second log is more meaningful and either standard or fast generally occurs. 706 //CFK: The second log is more meaningful and either standard or fast generally occurs.
707 //CFK: m_log.Info("[MAP]: World map request for range (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); 707 //CFK: m_log.Info("[MAP]: World map request for range (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")");
708 708
709 XmlRpcResponse response = new XmlRpcResponse(); 709 XmlRpcResponse response = new XmlRpcResponse();
710 Hashtable responseData = new Hashtable(); 710 Hashtable responseData = new Hashtable();
711 response.Value = responseData; 711 response.Value = responseData;
712 IList simProfileList = new ArrayList(); 712 IList simProfileList = new ArrayList();
713 713
714 bool fastMode = (m_config.DatabaseProvider == "OpenSim.Data.MySQL.dll" || m_config.DatabaseProvider == "OpenSim.Data.MSSQL.dll"); 714 bool fastMode = (m_config.DatabaseProvider == "OpenSim.Data.MySQL.dll" || m_config.DatabaseProvider == "OpenSim.Data.MSSQL.dll");
715 715
716 if (fastMode) 716 if (fastMode)
717 { 717 {
718 List<RegionProfileData> neighbours = m_gridDBService.GetRegions((uint)xmin, (uint)ymin, (uint)xmax, (uint)ymax); 718 List<RegionProfileData> neighbours = m_gridDBService.GetRegions((uint)xmin, (uint)ymin, (uint)xmax, (uint)ymax);
719 719
720 foreach (RegionProfileData aSim in neighbours) 720 foreach (RegionProfileData aSim in neighbours)
721 { 721 {
722 Hashtable simProfileBlock = new Hashtable(); 722 Hashtable simProfileBlock = new Hashtable();
723 simProfileBlock["x"] = aSim.regionLocX.ToString(); 723 simProfileBlock["x"] = aSim.regionLocX.ToString();
724 simProfileBlock["y"] = aSim.regionLocY.ToString(); 724 simProfileBlock["y"] = aSim.regionLocY.ToString();
725 //m_log.DebugFormat("[MAP]: Sending neighbour info for {0},{1}", aSim.regionLocX, aSim.regionLocY); 725 //m_log.DebugFormat("[MAP]: Sending neighbour info for {0},{1}", aSim.regionLocX, aSim.regionLocY);
726 simProfileBlock["name"] = aSim.regionName; 726 simProfileBlock["name"] = aSim.regionName;
727 simProfileBlock["access"] = 21; 727 simProfileBlock["access"] = 21;
728 simProfileBlock["region-flags"] = 512; 728 simProfileBlock["region-flags"] = 512;
729 simProfileBlock["water-height"] = 0; 729 simProfileBlock["water-height"] = 0;
730 simProfileBlock["agents"] = 1; 730 simProfileBlock["agents"] = 1;
731 simProfileBlock["map-image-id"] = aSim.regionMapTextureID.ToString(); 731 simProfileBlock["map-image-id"] = aSim.regionMapTextureID.ToString();
732 732
733 // For Sugilite compatibility 733 // For Sugilite compatibility
734 simProfileBlock["regionhandle"] = aSim.regionHandle.ToString(); 734 simProfileBlock["regionhandle"] = aSim.regionHandle.ToString();
735 simProfileBlock["sim_ip"] = aSim.serverIP; 735 simProfileBlock["sim_ip"] = aSim.serverIP;
736 simProfileBlock["sim_port"] = aSim.serverPort.ToString(); 736 simProfileBlock["sim_port"] = aSim.serverPort.ToString();
737 simProfileBlock["sim_uri"] = aSim.serverURI.ToString(); 737 simProfileBlock["sim_uri"] = aSim.serverURI.ToString();
738 simProfileBlock["uuid"] = aSim.UUID.ToString(); 738 simProfileBlock["uuid"] = aSim.UUID.ToString();
739 simProfileBlock["remoting_port"] = aSim.remotingPort.ToString(); 739 simProfileBlock["remoting_port"] = aSim.remotingPort.ToString();
740 simProfileBlock["http_port"] = aSim.httpPort.ToString(); 740 simProfileBlock["http_port"] = aSim.httpPort.ToString();
741 741
742 simProfileList.Add(simProfileBlock); 742 simProfileList.Add(simProfileBlock);
743 } 743 }
744 m_log.Info("[MAP]: Fast map " + simProfileList.Count.ToString() + 744 m_log.Info("[MAP]: Fast map " + simProfileList.Count.ToString() +
745 " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); 745 " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")");
746 } 746 }
747 else 747 else
748 { 748 {
749 RegionProfileData simProfile; 749 RegionProfileData simProfile;
750 for (int x = xmin; x < xmax + 1; x++) 750 for (int x = xmin; x < xmax + 1; x++)
751 { 751 {
752 for (int y = ymin; y < ymax + 1; y++) 752 for (int y = ymin; y < ymax + 1; y++)
753 { 753 {
754 ulong regHandle = Utils.UIntsToLong((uint)(x * Constants.RegionSize), (uint)(y * Constants.RegionSize)); 754 ulong regHandle = Utils.UIntsToLong((uint)(x * Constants.RegionSize), (uint)(y * Constants.RegionSize));
755 simProfile = m_gridDBService.GetRegion(regHandle); 755 simProfile = m_gridDBService.GetRegion(regHandle);
756 if (simProfile != null) 756 if (simProfile != null)
757 { 757 {
758 Hashtable simProfileBlock = new Hashtable(); 758 Hashtable simProfileBlock = new Hashtable();
759 simProfileBlock["x"] = x; 759 simProfileBlock["x"] = x;
760 simProfileBlock["y"] = y; 760 simProfileBlock["y"] = y;
761 simProfileBlock["name"] = simProfile.regionName; 761 simProfileBlock["name"] = simProfile.regionName;
762 simProfileBlock["access"] = 0; 762 simProfileBlock["access"] = 0;
763 simProfileBlock["region-flags"] = 0; 763 simProfileBlock["region-flags"] = 0;
764 simProfileBlock["water-height"] = 20; 764 simProfileBlock["water-height"] = 20;
765 simProfileBlock["agents"] = 1; 765 simProfileBlock["agents"] = 1;
766 simProfileBlock["map-image-id"] = simProfile.regionMapTextureID.ToString(); 766 simProfileBlock["map-image-id"] = simProfile.regionMapTextureID.ToString();
767 767
768 // For Sugilite compatibility 768 // For Sugilite compatibility
769 simProfileBlock["regionhandle"] = simProfile.regionHandle.ToString(); 769 simProfileBlock["regionhandle"] = simProfile.regionHandle.ToString();
770 simProfileBlock["sim_ip"] = simProfile.serverIP.ToString(); 770 simProfileBlock["sim_ip"] = simProfile.serverIP.ToString();
771 simProfileBlock["sim_port"] = simProfile.serverPort.ToString(); 771 simProfileBlock["sim_port"] = simProfile.serverPort.ToString();
772 simProfileBlock["sim_uri"] = simProfile.serverURI.ToString(); 772 simProfileBlock["sim_uri"] = simProfile.serverURI.ToString();
773 simProfileBlock["uuid"] = simProfile.UUID.ToString(); 773 simProfileBlock["uuid"] = simProfile.UUID.ToString();
774 simProfileBlock["remoting_port"] = simProfile.remotingPort.ToString(); 774 simProfileBlock["remoting_port"] = simProfile.remotingPort.ToString();
775 simProfileBlock["http_port"] = simProfile.httpPort; 775 simProfileBlock["http_port"] = simProfile.httpPort;
776 776
777 simProfileList.Add(simProfileBlock); 777 simProfileList.Add(simProfileBlock);
778 } 778 }
779 } 779 }
780 } 780 }
781 m_log.Info("[MAP]: Std map " + simProfileList.Count.ToString() + 781 m_log.Info("[MAP]: Std map " + simProfileList.Count.ToString() +
782 " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); 782 " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")");
783 } 783 }
784 784
785 responseData["sim-profiles"] = simProfileList; 785 responseData["sim-profiles"] = simProfileList;
786 786
787 return response; 787 return response;
788 } 788 }
789 789
790 /// <summary> 790 /// <summary>
791 /// Returns up to <code>maxNumber</code> profiles of regions that have a name starting with <code>name</code> 791 /// Returns up to <code>maxNumber</code> profiles of regions that have a name starting with <code>name</code>
792 /// </summary> 792 /// </summary>
793 /// <param name="request"></param> 793 /// <param name="request"></param>
794 /// <returns></returns> 794 /// <returns></returns>
795 public XmlRpcResponse XmlRpcSearchForRegionMethod(XmlRpcRequest request) 795 public XmlRpcResponse XmlRpcSearchForRegionMethod(XmlRpcRequest request)
796 { 796 {
797 Hashtable requestData = (Hashtable)request.Params[0]; 797 Hashtable requestData = (Hashtable)request.Params[0];
798 798
799 if (!requestData.ContainsKey("name") || !requestData.Contains("maxNumber")) 799 if (!requestData.ContainsKey("name") || !requestData.Contains("maxNumber"))
800 { 800 {
801 m_log.Warn("[DATA] Invalid region-search request; missing name or maxNumber"); 801 m_log.Warn("[DATA] Invalid region-search request; missing name or maxNumber");
802 return new XmlRpcResponse(500, "Missing name or maxNumber in region search request"); 802 return new XmlRpcResponse(500, "Missing name or maxNumber in region search request");
803 } 803 }
804 804
805 Hashtable responseData = new Hashtable(); 805 Hashtable responseData = new Hashtable();
806 806
807 string name = (string)requestData["name"]; 807 string name = (string)requestData["name"];
808 int maxNumber = Convert.ToInt32((string)requestData["maxNumber"]); 808 int maxNumber = Convert.ToInt32((string)requestData["maxNumber"]);
809 if (maxNumber == 0 || name.Length < 3) 809 if (maxNumber == 0 || name.Length < 3)
810 { 810 {
811 // either we didn't want any, or we were too unspecific 811 // either we didn't want any, or we were too unspecific
812 responseData["numFound"] = 0; 812 responseData["numFound"] = 0;
813 } 813 }
814 else 814 else
815 { 815 {
816 List<RegionProfileData> sims = m_gridDBService.GetRegions(name, maxNumber); 816 List<RegionProfileData> sims = m_gridDBService.GetRegions(name, maxNumber);
817 817
818 responseData["numFound"] = sims.Count; 818 responseData["numFound"] = sims.Count;
819 for (int i = 0; i < sims.Count; ++i) 819 for (int i = 0; i < sims.Count; ++i)
820 { 820 {
821 RegionProfileData sim = sims[i]; 821 RegionProfileData sim = sims[i];
822 string prefix = "region" + i + "."; 822 string prefix = "region" + i + ".";
823 responseData[prefix + "region_name"] = sim.regionName; 823 responseData[prefix + "region_name"] = sim.regionName;
824 responseData[prefix + "region_UUID"] = sim.UUID.ToString(); 824 responseData[prefix + "region_UUID"] = sim.UUID.ToString();
825 responseData[prefix + "region_locx"] = sim.regionLocX.ToString(); 825 responseData[prefix + "region_locx"] = sim.regionLocX.ToString();
826 responseData[prefix + "region_locy"] = sim.regionLocY.ToString(); 826 responseData[prefix + "region_locy"] = sim.regionLocY.ToString();
827 responseData[prefix + "sim_ip"] = sim.serverIP.ToString(); 827 responseData[prefix + "sim_ip"] = sim.serverIP.ToString();
828 responseData[prefix + "sim_port"] = sim.serverPort.ToString(); 828 responseData[prefix + "sim_port"] = sim.serverPort.ToString();
829 responseData[prefix + "remoting_port"] = sim.remotingPort.ToString(); 829 responseData[prefix + "remoting_port"] = sim.remotingPort.ToString();
830 responseData[prefix + "http_port"] = sim.httpPort.ToString(); 830 responseData[prefix + "http_port"] = sim.httpPort.ToString();
831 responseData[prefix + "map_UUID"] = sim.regionMapTextureID.ToString(); 831 responseData[prefix + "map_UUID"] = sim.regionMapTextureID.ToString();
832 } 832 }
833 } 833 }
834 834
835 XmlRpcResponse response = new XmlRpcResponse(); 835 XmlRpcResponse response = new XmlRpcResponse();
836 response.Value = responseData; 836 response.Value = responseData;
837 return response; 837 return response;
838 } 838 }
839 839
840 /// <summary> 840 /// <summary>
841 /// Construct an XMLRPC registration disabled response 841 /// Construct an XMLRPC registration disabled response
842 /// </summary> 842 /// </summary>
843 /// <param name="error"></param> 843 /// <param name="error"></param>
844 /// <returns></returns> 844 /// <returns></returns>
845 public static XmlRpcResponse XmlRPCRegionRegistrationDisabledResponse(string error) 845 public static XmlRpcResponse XmlRPCRegionRegistrationDisabledResponse(string error)
846 { 846 {
847 XmlRpcResponse errorResponse = new XmlRpcResponse(); 847 XmlRpcResponse errorResponse = new XmlRpcResponse();
848 Hashtable errorResponseData = new Hashtable(); 848 Hashtable errorResponseData = new Hashtable();
849 errorResponse.Value = errorResponseData; 849 errorResponse.Value = errorResponseData;
850 errorResponseData["restricted"] = error; 850 errorResponseData["restricted"] = error;
851 return errorResponse; 851 return errorResponse;
852 } 852 }
853 } 853 }
854 854
855 /// <summary> 855 /// <summary>
856 /// Exception generated when a simulator fails to login to the grid 856 /// Exception generated when a simulator fails to login to the grid
857 /// </summary> 857 /// </summary>
858 public class LoginException : Exception 858 public class LoginException : Exception
859 { 859 {
860 /// <summary> 860 /// <summary>
861 /// Return an XmlRpcResponse version of the exception message suitable for sending to a client 861 /// Return an XmlRpcResponse version of the exception message suitable for sending to a client
862 /// </summary> 862 /// </summary>
863 /// <param name="message"></param> 863 /// <param name="message"></param>
864 /// <param name="xmlRpcMessage"></param> 864 /// <param name="xmlRpcMessage"></param>
865 public XmlRpcResponse XmlRpcErrorResponse 865 public XmlRpcResponse XmlRpcErrorResponse
866 { 866 {
867 get { return m_xmlRpcErrorResponse; } 867 get { return m_xmlRpcErrorResponse; }
868 } 868 }
869 private XmlRpcResponse m_xmlRpcErrorResponse; 869 private XmlRpcResponse m_xmlRpcErrorResponse;
870 870
871 public LoginException(string message, string xmlRpcMessage) 871 public LoginException(string message, string xmlRpcMessage)
872 : base(message) 872 : base(message)
873 { 873 {
874 // FIXME: Might be neater to refactor and put the method inside here 874 // FIXME: Might be neater to refactor and put the method inside here
875 m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage); 875 m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage);
876 } 876 }
877 877
878 public LoginException(string message, string xmlRpcMessage, Exception e) 878 public LoginException(string message, string xmlRpcMessage, Exception e)
879 : base(message, e) 879 : base(message, e)
880 { 880 {
881 // FIXME: Might be neater to refactor and put the method inside here 881 // FIXME: Might be neater to refactor and put the method inside here
882 m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage); 882 m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage);
883 } 883 }
884 } 884 }
885} 885}
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs
index 7b47aab..3313591 100644
--- a/OpenSim/Grid/GridServer/GridServerBase.cs
+++ b/OpenSim/Grid/GridServer/GridServerBase.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
37using OpenSim.Grid.Framework; 37using OpenSim.Grid.Framework;
38using OpenSim.Grid.GridServer.Modules;
38 39
39namespace OpenSim.Grid.GridServer 40namespace OpenSim.Grid.GridServer
40{ 41{