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