diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Communications/IGridServices.cs | 1 | ||||
-rw-r--r-- | OpenSim/Framework/Data.DB4o/DB4oGridData.cs | 5 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs | 43 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLGridData.cs | 41 | ||||
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteGridData.cs | 32 | ||||
-rw-r--r-- | OpenSim/Framework/Data/GridData.cs | 7 | ||||
-rw-r--r-- | OpenSim/Framework/Data/RegionProfileData.cs | 42 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 48 |
8 files changed, 219 insertions, 0 deletions
diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 14baf3f..3e2a5da 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs | |||
@@ -36,6 +36,7 @@ namespace OpenSim.Framework.Communications | |||
36 | bool DeregisterRegion(RegionInfo regionInfo); | 36 | bool DeregisterRegion(RegionInfo regionInfo); |
37 | List<SimpleRegionInfo> RequestNeighbours(uint x, uint y); | 37 | List<SimpleRegionInfo> RequestNeighbours(uint x, uint y); |
38 | RegionInfo RequestNeighbourInfo(ulong regionHandle); | 38 | RegionInfo RequestNeighbourInfo(ulong regionHandle); |
39 | RegionInfo RequestClosestRegion(string regionName); | ||
39 | Dictionary<string, string> GetGridSettings(); | 40 | Dictionary<string, string> GetGridSettings(); |
40 | List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); | 41 | List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); |
41 | } | 42 | } |
diff --git a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs index b11af82..999d4f8 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs | |||
@@ -98,6 +98,11 @@ namespace OpenSim.Framework.Data.DB4o | |||
98 | "). Total Registered Regions: " + manager.simProfiles.Count); | 98 | "). Total Registered Regions: " + manager.simProfiles.Count); |
99 | } | 99 | } |
100 | 100 | ||
101 | public RegionProfileData GetProfileByString(string regionName) | ||
102 | { | ||
103 | throw new Exception("GetProfileByString Not supported in DB4oGridData"); | ||
104 | //return null; | ||
105 | } | ||
101 | /// <summary> | 106 | /// <summary> |
102 | /// Adds a new specified region to the database | 107 | /// Adds a new specified region to the database |
103 | /// </summary> | 108 | /// </summary> |
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs index 2b91cf9..38a1d08 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs | |||
@@ -180,6 +180,49 @@ namespace OpenSim.Framework.Data.MSSQL | |||
180 | return row; | 180 | return row; |
181 | } | 181 | } |
182 | 182 | ||
183 | |||
184 | /// <summary> | ||
185 | /// Returns a sim profile from it's Region name string | ||
186 | /// </summary> | ||
187 | /// <param name="uuid">The region name search query</param> | ||
188 | /// <returns>The sim profile</returns> | ||
189 | public RegionProfileData GetProfileByString(string regionName) | ||
190 | { | ||
191 | if (regionName.Length > 2) | ||
192 | { | ||
193 | try | ||
194 | { | ||
195 | lock (database) | ||
196 | { | ||
197 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
198 | // Add % because this is a like query. | ||
199 | param["?regionName"] = regionName + "%"; | ||
200 | // Order by statement will return shorter matches first. Only returns one record or no record. | ||
201 | IDbCommand result = database.Query("SELECT top 1 * FROM " + m_regionsTableName + " WHERE regionName like ?regionName order by regionName", param); | ||
202 | IDataReader reader = result.ExecuteReader(); | ||
203 | |||
204 | RegionProfileData row = database.getRegionRow(reader); | ||
205 | reader.Close(); | ||
206 | result.Dispose(); | ||
207 | |||
208 | return row; | ||
209 | } | ||
210 | } | ||
211 | catch (Exception e) | ||
212 | { | ||
213 | database.Reconnect(); | ||
214 | m_log.Error(e.ToString()); | ||
215 | return null; | ||
216 | } | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters"); | ||
221 | return null; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | |||
183 | /// <summary> | 226 | /// <summary> |
184 | /// Adds a new specified region to the database | 227 | /// Adds a new specified region to the database |
185 | /// </summary> | 228 | /// </summary> |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs index 584d49c..3855d99 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs | |||
@@ -249,6 +249,47 @@ namespace OpenSim.Framework.Data.MySQL | |||
249 | } | 249 | } |
250 | 250 | ||
251 | /// <summary> | 251 | /// <summary> |
252 | /// Returns a sim profile from it's Region name string | ||
253 | /// </summary> | ||
254 | /// <param name="uuid">The region name search query</param> | ||
255 | /// <returns>The sim profile</returns> | ||
256 | public RegionProfileData GetProfileByString(string regionName) | ||
257 | { | ||
258 | if (regionName.Length > 2) | ||
259 | { | ||
260 | try | ||
261 | { | ||
262 | lock (database) | ||
263 | { | ||
264 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
265 | // Add % because this is a like query. | ||
266 | param["?regionName"] = regionName + "%"; | ||
267 | // Order by statement will return shorter matches first. Only returns one record or no record. | ||
268 | IDbCommand result = database.Query("SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", param); | ||
269 | IDataReader reader = result.ExecuteReader(); | ||
270 | |||
271 | RegionProfileData row = database.readSimRow(reader); | ||
272 | reader.Close(); | ||
273 | result.Dispose(); | ||
274 | |||
275 | return row; | ||
276 | } | ||
277 | } | ||
278 | catch (Exception e) | ||
279 | { | ||
280 | database.Reconnect(); | ||
281 | m_log.Error(e.ToString()); | ||
282 | return null; | ||
283 | } | ||
284 | } | ||
285 | else | ||
286 | { | ||
287 | m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters"); | ||
288 | return null; | ||
289 | } | ||
290 | } | ||
291 | |||
292 | /// <summary> | ||
252 | /// Adds a new profile to the database | 293 | /// Adds a new profile to the database |
253 | /// </summary> | 294 | /// </summary> |
254 | /// <param name="profile">The profile to add</param> | 295 | /// <param name="profile">The profile to add</param> |
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs index 6487ba7..4d42f19 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs | |||
@@ -112,6 +112,38 @@ namespace OpenSim.Framework.Data.SQLite | |||
112 | } | 112 | } |
113 | 113 | ||
114 | /// <summary> | 114 | /// <summary> |
115 | /// Returns a sim profile from it's Region name string | ||
116 | /// </summary> | ||
117 | /// <param name="uuid">The region name search query</param> | ||
118 | /// <returns>The sim profile</returns> | ||
119 | public RegionProfileData GetProfileByString(string regionName) | ||
120 | { | ||
121 | if (regionName.Length > 2) | ||
122 | { | ||
123 | |||
124 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
125 | // Add % because this is a like query. | ||
126 | param["?regionName"] = regionName + "%"; | ||
127 | // Only returns one record or no record. | ||
128 | IDbCommand result = database.Query("SELECT * FROM regions WHERE regionName like ?regionName LIMIT 1", param); | ||
129 | IDataReader reader = result.ExecuteReader(); | ||
130 | |||
131 | RegionProfileData row = database.getRow(reader); | ||
132 | reader.Close(); | ||
133 | result.Dispose(); | ||
134 | |||
135 | return row; | ||
136 | |||
137 | } | ||
138 | else | ||
139 | { | ||
140 | //m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters"); | ||
141 | return null; | ||
142 | } | ||
143 | } | ||
144 | |||
145 | |||
146 | /// <summary> | ||
115 | /// Returns a sim profile from it's UUID | 147 | /// Returns a sim profile from it's UUID |
116 | /// </summary> | 148 | /// </summary> |
117 | /// <param name="uuid">The region UUID</param> | 149 | /// <param name="uuid">The region UUID</param> |
diff --git a/OpenSim/Framework/Data/GridData.cs b/OpenSim/Framework/Data/GridData.cs index 95a568a..5eaa2c4 100644 --- a/OpenSim/Framework/Data/GridData.cs +++ b/OpenSim/Framework/Data/GridData.cs | |||
@@ -69,6 +69,13 @@ namespace OpenSim.Framework.Data | |||
69 | RegionProfileData GetProfileByLLUUID(LLUUID UUID); | 69 | RegionProfileData GetProfileByLLUUID(LLUUID UUID); |
70 | 70 | ||
71 | /// <summary> | 71 | /// <summary> |
72 | /// Returns a sim profile from a string match | ||
73 | /// </summary> | ||
74 | /// <param name="regionName">A string for a partial region name match</param> | ||
75 | /// <returns>A sim profile</returns> | ||
76 | RegionProfileData GetProfileByString(string regionName); | ||
77 | |||
78 | /// <summary> | ||
72 | /// Returns all profiles within the specified range | 79 | /// Returns all profiles within the specified range |
73 | /// </summary> | 80 | /// </summary> |
74 | /// <param name="Xmin">Minimum sim coordinate (X)</param> | 81 | /// <param name="Xmin">Minimum sim coordinate (X)</param> |
diff --git a/OpenSim/Framework/Data/RegionProfileData.cs b/OpenSim/Framework/Data/RegionProfileData.cs index b541116..f736571 100644 --- a/OpenSim/Framework/Data/RegionProfileData.cs +++ b/OpenSim/Framework/Data/RegionProfileData.cs | |||
@@ -216,5 +216,47 @@ namespace OpenSim.Framework.Data | |||
216 | 216 | ||
217 | return simData; | 217 | return simData; |
218 | } | 218 | } |
219 | |||
220 | /// <summary> | ||
221 | /// Request sim profile information from a grid server | ||
222 | /// </summary> | ||
223 | /// <param name="region_handle"></param> | ||
224 | /// <param name="gridserver_url"></param> | ||
225 | /// <param name="gridserver_sendkey"></param> | ||
226 | /// <param name="gridserver_recvkey"></param> | ||
227 | /// <returns>The sim profile. Null if there was a request failure</returns> | ||
228 | public static RegionProfileData RequestSimProfileData(string regionName, string gridserver_url, | ||
229 | string gridserver_sendkey, string gridserver_recvkey) | ||
230 | { | ||
231 | Hashtable requestData = new Hashtable(); | ||
232 | requestData["region_name_search"] = regionName; | ||
233 | requestData["authkey"] = gridserver_sendkey; | ||
234 | ArrayList SendParams = new ArrayList(); | ||
235 | SendParams.Add(requestData); | ||
236 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | ||
237 | XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); | ||
238 | |||
239 | Hashtable responseData = (Hashtable)GridResp.Value; | ||
240 | |||
241 | if (responseData.ContainsKey("error")) | ||
242 | { | ||
243 | return null; | ||
244 | } | ||
245 | |||
246 | RegionProfileData simData = new RegionProfileData(); | ||
247 | simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]); | ||
248 | simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]); | ||
249 | simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); | ||
250 | simData.serverIP = (string)responseData["sim_ip"]; | ||
251 | simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]); | ||
252 | simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]); | ||
253 | simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); | ||
254 | simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; | ||
255 | simData.serverURI = (string)responseData["server_uri"]; | ||
256 | simData.UUID = new LLUUID((string)responseData["region_UUID"]); | ||
257 | simData.regionName = (string)responseData["region_name"]; | ||
258 | |||
259 | return simData; | ||
260 | } | ||
219 | } | 261 | } |
220 | } | 262 | } |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 0f1f0d9..37ddb3e 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -597,5 +597,53 @@ namespace OpenSim.Framework | |||
597 | 597 | ||
598 | return ret; | 598 | return ret; |
599 | } | 599 | } |
600 | public static string[] ParseStartLocationRequest(string startLocationRequest) | ||
601 | { | ||
602 | string[] returnstring = new string[4]; | ||
603 | // format uri:RegionName&X&Y&Z | ||
604 | returnstring[0] = "last"; | ||
605 | returnstring[1] = "127"; | ||
606 | returnstring[2] = "127"; | ||
607 | returnstring[3] = "0"; | ||
608 | // This is the crappy way of doing it. | ||
609 | |||
610 | if (startLocationRequest.Contains(":") && startLocationRequest.Contains("&")) | ||
611 | { | ||
612 | //System.Console.WriteLine("StartLocationRequest Contains proper elements"); | ||
613 | |||
614 | string[] splitstr = startLocationRequest.Split(':');//,2,StringSplitOptions.RemoveEmptyEntries); | ||
615 | |||
616 | //System.Console.WriteLine("Found " + splitstr.GetLength(0) + " elements in 1st split result"); | ||
617 | |||
618 | if (splitstr.GetLength(0) == 2) | ||
619 | { | ||
620 | |||
621 | string[] splitstr2 = splitstr[1].Split('&');//, 4, StringSplitOptions.RemoveEmptyEntries); | ||
622 | |||
623 | //System.Console.WriteLine("Found " + splitstr2.GetLength(0) + " elements in 2nd split result"); | ||
624 | |||
625 | if (splitstr2.GetLength(0) >= 1) | ||
626 | { | ||
627 | returnstring[0] = splitstr2[0]; | ||
628 | } | ||
629 | if (splitstr2.GetLength(0) >= 2) | ||
630 | { | ||
631 | returnstring[1] = splitstr2[1]; | ||
632 | } | ||
633 | if (splitstr2.GetLength(0) >= 3) | ||
634 | { | ||
635 | returnstring[2] = splitstr2[2]; | ||
636 | } | ||
637 | if (splitstr2.GetLength(0) >= 4) | ||
638 | { | ||
639 | returnstring[3] = splitstr2[3]; | ||
640 | } | ||
641 | } | ||
642 | |||
643 | } | ||
644 | return returnstring; | ||
645 | |||
646 | |||
647 | } | ||
600 | } | 648 | } |
601 | } | 649 | } |