diff options
author | Diva Canto | 2010-01-24 14:30:48 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-24 14:30:48 -0800 |
commit | 48b03c2c61a422c3ac9843892a2ae93b29a9f7b8 (patch) | |
tree | ce3aae8c5bb0ee0c1748e4355cd616ea84b5b344 /OpenSim/Services | |
parent | Change a member of the friendslist module to better reflect the client side (diff) | |
download | opensim-SC-48b03c2c61a422c3ac9843892a2ae93b29a9f7b8.zip opensim-SC-48b03c2c61a422c3ac9843892a2ae93b29a9f7b8.tar.gz opensim-SC-48b03c2c61a422c3ac9843892a2ae93b29a9f7b8.tar.bz2 opensim-SC-48b03c2c61a422c3ac9843892a2ae93b29a9f7b8.tar.xz |
Integrated the hyperlinking with the GridService.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | 215 | ||||
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs | 354 | ||||
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 7 | ||||
-rw-r--r-- | OpenSim/Services/GridService/HypergridLinker.cs | 614 | ||||
-rw-r--r-- | OpenSim/Services/HypergridService/HGCommands.cs | 318 | ||||
-rw-r--r-- | OpenSim/Services/HypergridService/HypergridService.cs | 417 | ||||
-rw-r--r-- | OpenSim/Services/HypergridService/HypergridServiceBase.cs | 84 | ||||
-rw-r--r-- | OpenSim/Services/Interfaces/IHypergridService.cs | 49 |
8 files changed, 834 insertions, 1224 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index a8d9292..ae0a0b6 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | |||
@@ -1,13 +1,18 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections; | 2 | using System.Collections; |
3 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
4 | using System.Drawing; | ||
4 | using System.Net; | 5 | using System.Net; |
6 | using System.Reflection; | ||
5 | 7 | ||
8 | using OpenSim.Framework; | ||
6 | using OpenSim.Services.Interfaces; | 9 | using OpenSim.Services.Interfaces; |
7 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 10 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
8 | 11 | ||
9 | using OpenMetaverse; | 12 | using OpenMetaverse; |
13 | using OpenMetaverse.Imaging; | ||
10 | using Nwc.XmlRpc; | 14 | using Nwc.XmlRpc; |
15 | using log4net; | ||
11 | 16 | ||
12 | using OpenSim.Services.Connectors.Simulation; | 17 | using OpenSim.Services.Connectors.Simulation; |
13 | 18 | ||
@@ -15,6 +20,21 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
15 | { | 20 | { |
16 | public class GatekeeperServiceConnector : SimulationServiceConnector | 21 | public class GatekeeperServiceConnector : SimulationServiceConnector |
17 | { | 22 | { |
23 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
24 | |||
25 | private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); | ||
26 | |||
27 | private IAssetService m_AssetService; | ||
28 | |||
29 | public GatekeeperServiceConnector() : base() | ||
30 | { | ||
31 | } | ||
32 | |||
33 | public GatekeeperServiceConnector(IAssetService assService) | ||
34 | { | ||
35 | m_AssetService = assService; | ||
36 | } | ||
37 | |||
18 | protected override string AgentPath() | 38 | protected override string AgentPath() |
19 | { | 39 | { |
20 | return "/foreignagent/"; | 40 | return "/foreignagent/"; |
@@ -25,6 +45,201 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
25 | return "/foreignobject/"; | 45 | return "/foreignobject/"; |
26 | } | 46 | } |
27 | 47 | ||
48 | public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string imageURL, out string reason) | ||
49 | { | ||
50 | regionID = UUID.Zero; | ||
51 | imageURL = string.Empty; | ||
52 | realHandle = 0; | ||
53 | reason = string.Empty; | ||
54 | |||
55 | Hashtable hash = new Hashtable(); | ||
56 | hash["region_name"] = info.RegionName; | ||
57 | |||
58 | IList paramList = new ArrayList(); | ||
59 | paramList.Add(hash); | ||
60 | |||
61 | XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); | ||
62 | string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; | ||
63 | //m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Linking to " + uri); | ||
64 | XmlRpcResponse response = null; | ||
65 | try | ||
66 | { | ||
67 | response = request.Send(uri, 10000); | ||
68 | } | ||
69 | catch (Exception e) | ||
70 | { | ||
71 | m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); | ||
72 | reason = "Error contacting remote server"; | ||
73 | return false; | ||
74 | } | ||
75 | |||
76 | if (response.IsFault) | ||
77 | { | ||
78 | reason = response.FaultString; | ||
79 | m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); | ||
80 | return false; | ||
81 | } | ||
82 | |||
83 | hash = (Hashtable)response.Value; | ||
84 | //foreach (Object o in hash) | ||
85 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
86 | try | ||
87 | { | ||
88 | bool success = false; | ||
89 | Boolean.TryParse((string)hash["result"], out success); | ||
90 | if (success) | ||
91 | { | ||
92 | UUID.TryParse((string)hash["uuid"], out regionID); | ||
93 | //m_log.Debug(">> HERE, uuid: " + uuid); | ||
94 | if ((string)hash["handle"] != null) | ||
95 | { | ||
96 | realHandle = Convert.ToUInt64((string)hash["handle"]); | ||
97 | //m_log.Debug(">> HERE, realHandle: " + realHandle); | ||
98 | } | ||
99 | if (hash["region_image"] != null) | ||
100 | { | ||
101 | imageURL = (string)hash["region_image"]; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | } | ||
106 | catch (Exception e) | ||
107 | { | ||
108 | reason = "Error parsing return arguments"; | ||
109 | m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
110 | return false; | ||
111 | } | ||
112 | |||
113 | return true; | ||
114 | } | ||
115 | |||
116 | UUID m_MissingTexture = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); | ||
117 | |||
118 | public UUID GetMapImage(UUID regionID, string imageURL) | ||
119 | { | ||
120 | if (m_AssetService == null) | ||
121 | return m_MissingTexture; | ||
122 | |||
123 | try | ||
124 | { | ||
125 | |||
126 | WebClient c = new WebClient(); | ||
127 | //m_log.Debug("JPEG: " + imageURL); | ||
128 | string filename = regionID.ToString(); | ||
129 | c.DownloadFile(imageURL, filename + ".jpg"); | ||
130 | Bitmap m = new Bitmap(filename + ".jpg"); | ||
131 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | ||
132 | byte[] imageData = OpenJPEG.EncodeFromImage(m, true); | ||
133 | AssetBase ass = new AssetBase(UUID.Random(), "region " + filename, (sbyte)AssetType.Texture); | ||
134 | |||
135 | // !!! for now | ||
136 | //info.RegionSettings.TerrainImageID = ass.FullID; | ||
137 | |||
138 | ass.Temporary = true; | ||
139 | ass.Local = true; | ||
140 | ass.Data = imageData; | ||
141 | |||
142 | m_AssetService.Store(ass); | ||
143 | |||
144 | // finally | ||
145 | return ass.FullID; | ||
146 | |||
147 | } | ||
148 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke | ||
149 | { | ||
150 | m_log.Warn("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); | ||
151 | } | ||
152 | return UUID.Zero; | ||
153 | } | ||
154 | |||
155 | public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) | ||
156 | { | ||
157 | Hashtable hash = new Hashtable(); | ||
158 | hash["region_uuid"] = regionID.ToString(); | ||
159 | |||
160 | IList paramList = new ArrayList(); | ||
161 | paramList.Add(hash); | ||
162 | |||
163 | XmlRpcRequest request = new XmlRpcRequest("get_region", paramList); | ||
164 | string uri = "http://" + gatekeeper.ExternalEndPoint.Address + ":" + gatekeeper.HttpPort + "/"; | ||
165 | m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: contacting " + uri); | ||
166 | XmlRpcResponse response = null; | ||
167 | try | ||
168 | { | ||
169 | response = request.Send(uri, 10000); | ||
170 | } | ||
171 | catch (Exception e) | ||
172 | { | ||
173 | m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); | ||
174 | return null; | ||
175 | } | ||
176 | |||
177 | if (response.IsFault) | ||
178 | { | ||
179 | m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); | ||
180 | return null; | ||
181 | } | ||
182 | |||
183 | hash = (Hashtable)response.Value; | ||
184 | //foreach (Object o in hash) | ||
185 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
186 | try | ||
187 | { | ||
188 | bool success = false; | ||
189 | Boolean.TryParse((string)hash["result"], out success); | ||
190 | if (success) | ||
191 | { | ||
192 | GridRegion region = new GridRegion(); | ||
193 | |||
194 | UUID.TryParse((string)hash["uuid"], out region.RegionID); | ||
195 | //m_log.Debug(">> HERE, uuid: " + region.RegionID); | ||
196 | int n = 0; | ||
197 | if (hash["x"] != null) | ||
198 | { | ||
199 | Int32.TryParse((string)hash["x"], out n); | ||
200 | region.RegionLocX = n; | ||
201 | //m_log.Debug(">> HERE, x: " + region.RegionLocX); | ||
202 | } | ||
203 | if (hash["y"] != null) | ||
204 | { | ||
205 | Int32.TryParse((string)hash["y"], out n); | ||
206 | region.RegionLocY = n; | ||
207 | //m_log.Debug(">> HERE, y: " + region.RegionLocY); | ||
208 | } | ||
209 | if (hash["region_name"] != null) | ||
210 | { | ||
211 | region.RegionName = (string)hash["region_name"]; | ||
212 | //m_log.Debug(">> HERE, name: " + region.RegionName); | ||
213 | } | ||
214 | if (hash["hostname"] != null) | ||
215 | region.ExternalHostName = (string)hash["hostname"]; | ||
216 | if (hash["http_port"] != null) | ||
217 | { | ||
218 | uint p = 0; | ||
219 | UInt32.TryParse((string)hash["http_port"], out p); | ||
220 | region.HttpPort = p; | ||
221 | } | ||
222 | if (hash["internal_port"] != null) | ||
223 | { | ||
224 | int p = 0; | ||
225 | Int32.TryParse((string)hash["internal_port"], out p); | ||
226 | region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); | ||
227 | } | ||
228 | |||
229 | // Successful return | ||
230 | return region; | ||
231 | } | ||
232 | |||
233 | } | ||
234 | catch (Exception e) | ||
235 | { | ||
236 | m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
237 | return null; | ||
238 | } | ||
239 | |||
240 | return null; | ||
241 | } | ||
242 | |||
28 | public GridRegion GetHomeRegion(GridRegion gatekeeper, UUID userID, out Vector3 position, out Vector3 lookAt) | 243 | public GridRegion GetHomeRegion(GridRegion gatekeeper, UUID userID, out Vector3 position, out Vector3 lookAt) |
29 | { | 244 | { |
30 | position = Vector3.UnitY; lookAt = Vector3.UnitY; | 245 | position = Vector3.UnitY; lookAt = Vector3.UnitY; |
diff --git a/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs deleted file mode 100644 index 1786d38..0000000 --- a/OpenSim/Services/Connectors/Hypergrid/HypergridServiceConnector.cs +++ /dev/null | |||
@@ -1,354 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using System.Drawing; | ||
33 | using System.Net; | ||
34 | using System.Reflection; | ||
35 | using OpenSim.Services.Interfaces; | ||
36 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
37 | |||
38 | using OpenSim.Framework; | ||
39 | |||
40 | using OpenMetaverse; | ||
41 | using OpenMetaverse.Imaging; | ||
42 | using log4net; | ||
43 | using Nwc.XmlRpc; | ||
44 | using Nini.Config; | ||
45 | |||
46 | namespace OpenSim.Services.Connectors.Hypergrid | ||
47 | { | ||
48 | public class HypergridServiceConnector : IHypergridService | ||
49 | { | ||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private IAssetService m_AssetService; | ||
53 | private string m_ServerURL; | ||
54 | |||
55 | public HypergridServiceConnector() { } | ||
56 | |||
57 | public HypergridServiceConnector(IAssetService assService) | ||
58 | { | ||
59 | m_AssetService = assService; | ||
60 | } | ||
61 | |||
62 | public HypergridServiceConnector(IConfigSource source) | ||
63 | { | ||
64 | Initialise(source); | ||
65 | } | ||
66 | |||
67 | public virtual void Initialise(IConfigSource source) | ||
68 | { | ||
69 | IConfig hgConfig = source.Configs["HypergridService"]; | ||
70 | if (hgConfig == null) | ||
71 | { | ||
72 | m_log.Error("[HYPERGRID CONNECTOR]: HypergridService missing from OpenSim.ini"); | ||
73 | throw new Exception("Hypergrid connector init error"); | ||
74 | } | ||
75 | |||
76 | string serviceURI = hgConfig.GetString("HypergridServerURI", | ||
77 | String.Empty); | ||
78 | |||
79 | if (serviceURI == String.Empty) | ||
80 | { | ||
81 | m_log.Error("[HYPERGRID CONNECTOR]: No Server URI named in section HypergridService"); | ||
82 | throw new Exception("Hypergrid connector init error"); | ||
83 | } | ||
84 | m_ServerURL = serviceURI; | ||
85 | } | ||
86 | |||
87 | public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string imageURL, out string reason) | ||
88 | { | ||
89 | regionID = UUID.Zero; | ||
90 | imageURL = string.Empty; | ||
91 | realHandle = 0; | ||
92 | reason = string.Empty; | ||
93 | |||
94 | Hashtable hash = new Hashtable(); | ||
95 | hash["region_name"] = info.RegionName; | ||
96 | |||
97 | IList paramList = new ArrayList(); | ||
98 | paramList.Add(hash); | ||
99 | |||
100 | XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); | ||
101 | string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; | ||
102 | //m_log.Debug("[HGrid]: Linking to " + uri); | ||
103 | XmlRpcResponse response = null; | ||
104 | try | ||
105 | { | ||
106 | response = request.Send(uri, 10000); | ||
107 | } | ||
108 | catch (Exception e) | ||
109 | { | ||
110 | m_log.Debug("[HGrid]: Exception " + e.Message); | ||
111 | reason = "Error contacting remote server"; | ||
112 | return false; | ||
113 | } | ||
114 | |||
115 | if (response.IsFault) | ||
116 | { | ||
117 | reason = response.FaultString; | ||
118 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
119 | return false; | ||
120 | } | ||
121 | |||
122 | hash = (Hashtable)response.Value; | ||
123 | //foreach (Object o in hash) | ||
124 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
125 | try | ||
126 | { | ||
127 | bool success = false; | ||
128 | Boolean.TryParse((string)hash["result"], out success); | ||
129 | if (success) | ||
130 | { | ||
131 | UUID.TryParse((string)hash["uuid"], out regionID); | ||
132 | //m_log.Debug(">> HERE, uuid: " + uuid); | ||
133 | if ((string)hash["handle"] != null) | ||
134 | { | ||
135 | realHandle = Convert.ToUInt64((string)hash["handle"]); | ||
136 | //m_log.Debug(">> HERE, realHandle: " + realHandle); | ||
137 | } | ||
138 | if (hash["region_image"] != null) | ||
139 | { | ||
140 | imageURL = (string)hash["region_image"]; | ||
141 | } | ||
142 | } | ||
143 | |||
144 | } | ||
145 | catch (Exception e) | ||
146 | { | ||
147 | reason = "Error parsing return arguments"; | ||
148 | m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
149 | return false; | ||
150 | } | ||
151 | |||
152 | return true; | ||
153 | } | ||
154 | |||
155 | public UUID GetMapImage(UUID regionID, string imageURL) | ||
156 | { | ||
157 | try | ||
158 | { | ||
159 | |||
160 | WebClient c = new WebClient(); | ||
161 | //m_log.Debug("JPEG: " + uri); | ||
162 | string filename = regionID.ToString(); | ||
163 | c.DownloadFile(imageURL, filename + ".jpg"); | ||
164 | Bitmap m = new Bitmap(filename + ".jpg"); | ||
165 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | ||
166 | byte[] imageData = OpenJPEG.EncodeFromImage(m, true); | ||
167 | AssetBase ass = new AssetBase(UUID.Random(), "region " + filename, (sbyte)AssetType.Texture); | ||
168 | |||
169 | // !!! for now | ||
170 | //info.RegionSettings.TerrainImageID = ass.FullID; | ||
171 | |||
172 | ass.Temporary = true; | ||
173 | ass.Local = true; | ||
174 | ass.Data = imageData; | ||
175 | |||
176 | m_AssetService.Store(ass); | ||
177 | |||
178 | // finally | ||
179 | return ass.FullID; | ||
180 | |||
181 | } | ||
182 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke | ||
183 | { | ||
184 | m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache"); | ||
185 | } | ||
186 | return UUID.Zero; | ||
187 | } | ||
188 | |||
189 | public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) | ||
190 | { | ||
191 | Hashtable hash = new Hashtable(); | ||
192 | hash["region_uuid"] = regionID.ToString(); | ||
193 | |||
194 | IList paramList = new ArrayList(); | ||
195 | paramList.Add(hash); | ||
196 | |||
197 | XmlRpcRequest request = new XmlRpcRequest("get_region", paramList); | ||
198 | string uri = "http://" + gatekeeper.ExternalEndPoint.Address + ":" + gatekeeper.HttpPort + "/"; | ||
199 | m_log.Debug("[HGrid]: contacting " + uri); | ||
200 | XmlRpcResponse response = null; | ||
201 | try | ||
202 | { | ||
203 | response = request.Send(uri, 10000); | ||
204 | } | ||
205 | catch (Exception e) | ||
206 | { | ||
207 | m_log.Debug("[HGrid]: Exception " + e.Message); | ||
208 | return null; | ||
209 | } | ||
210 | |||
211 | if (response.IsFault) | ||
212 | { | ||
213 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
214 | return null; | ||
215 | } | ||
216 | |||
217 | hash = (Hashtable)response.Value; | ||
218 | //foreach (Object o in hash) | ||
219 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
220 | try | ||
221 | { | ||
222 | bool success = false; | ||
223 | Boolean.TryParse((string)hash["result"], out success); | ||
224 | if (success) | ||
225 | { | ||
226 | GridRegion region = new GridRegion(); | ||
227 | |||
228 | UUID.TryParse((string)hash["uuid"], out region.RegionID); | ||
229 | //m_log.Debug(">> HERE, uuid: " + region.RegionID); | ||
230 | int n = 0; | ||
231 | if (hash["x"] != null) | ||
232 | { | ||
233 | Int32.TryParse((string)hash["x"], out n); | ||
234 | region.RegionLocX = n; | ||
235 | //m_log.Debug(">> HERE, x: " + region.RegionLocX); | ||
236 | } | ||
237 | if (hash["y"] != null) | ||
238 | { | ||
239 | Int32.TryParse((string)hash["y"], out n); | ||
240 | region.RegionLocY = n; | ||
241 | //m_log.Debug(">> HERE, y: " + region.RegionLocY); | ||
242 | } | ||
243 | if (hash["region_name"] != null) | ||
244 | { | ||
245 | region.RegionName = (string)hash["region_name"]; | ||
246 | //m_log.Debug(">> HERE, name: " + region.RegionName); | ||
247 | } | ||
248 | if (hash["hostname"] != null) | ||
249 | region.ExternalHostName = (string)hash["hostname"]; | ||
250 | if (hash["http_port"] != null) | ||
251 | { | ||
252 | uint p = 0; | ||
253 | UInt32.TryParse((string)hash["http_port"], out p); | ||
254 | region.HttpPort = p; | ||
255 | } | ||
256 | if (hash["internal_port"] != null) | ||
257 | { | ||
258 | int p = 0; | ||
259 | Int32.TryParse((string)hash["internal_port"], out p); | ||
260 | region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); | ||
261 | } | ||
262 | |||
263 | // Successful return | ||
264 | return region; | ||
265 | } | ||
266 | |||
267 | } | ||
268 | catch (Exception e) | ||
269 | { | ||
270 | m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
271 | return null; | ||
272 | } | ||
273 | |||
274 | return null; | ||
275 | } | ||
276 | |||
277 | #region From local regions to grid-wide hypergrid service | ||
278 | |||
279 | public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong realHandle, out string imageURL, out string reason) | ||
280 | { | ||
281 | regionID = UUID.Zero; | ||
282 | imageURL = string.Empty; | ||
283 | realHandle = 0; | ||
284 | reason = string.Empty; | ||
285 | |||
286 | Hashtable hash = new Hashtable(); | ||
287 | hash["region_desc"] = regionDescriptor; | ||
288 | |||
289 | IList paramList = new ArrayList(); | ||
290 | paramList.Add(hash); | ||
291 | |||
292 | XmlRpcRequest request = new XmlRpcRequest("link_region_by_desc", paramList); | ||
293 | XmlRpcResponse response = null; | ||
294 | try | ||
295 | { | ||
296 | response = request.Send(m_ServerURL, 10000); | ||
297 | } | ||
298 | catch (Exception e) | ||
299 | { | ||
300 | m_log.Debug("[HGrid]: Exception " + e.Message); | ||
301 | reason = "Error contacting remote server"; | ||
302 | return false; | ||
303 | } | ||
304 | |||
305 | if (response.IsFault) | ||
306 | { | ||
307 | reason = response.FaultString; | ||
308 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
309 | return false; | ||
310 | } | ||
311 | |||
312 | hash = (Hashtable)response.Value; | ||
313 | //foreach (Object o in hash) | ||
314 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
315 | try | ||
316 | { | ||
317 | bool success = false; | ||
318 | Boolean.TryParse((string)hash["result"], out success); | ||
319 | if (success) | ||
320 | { | ||
321 | UUID.TryParse((string)hash["uuid"], out regionID); | ||
322 | //m_log.Debug(">> HERE, uuid: " + uuid); | ||
323 | if ((string)hash["handle"] != null) | ||
324 | { | ||
325 | realHandle = Convert.ToUInt64((string)hash["handle"]); | ||
326 | //m_log.Debug(">> HERE, realHandle: " + realHandle); | ||
327 | } | ||
328 | if (hash["region_image"] != null) | ||
329 | { | ||
330 | imageURL = (string)hash["region_image"]; | ||
331 | } | ||
332 | } | ||
333 | |||
334 | } | ||
335 | catch (Exception e) | ||
336 | { | ||
337 | reason = "Error parsing return arguments"; | ||
338 | m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
339 | return false; | ||
340 | } | ||
341 | |||
342 | return true; | ||
343 | } | ||
344 | |||
345 | // TODO !!! | ||
346 | public GridRegion GetRegionByUUID(UUID regionID) { return null; } | ||
347 | public GridRegion GetRegionByPosition(int x, int y) { return null; } | ||
348 | public GridRegion GetRegionByName(string name) { return null; } | ||
349 | public List<GridRegion> GetRegionsByName(string name) { return null; } | ||
350 | public List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax) { return null; } | ||
351 | |||
352 | #endregion | ||
353 | } | ||
354 | } | ||
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 9e0790c..ae29a74 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -50,6 +50,7 @@ namespace OpenSim.Services.GridService | |||
50 | private bool m_DeleteOnUnregister = true; | 50 | private bool m_DeleteOnUnregister = true; |
51 | private static GridService m_RootInstance = null; | 51 | private static GridService m_RootInstance = null; |
52 | protected IConfigSource m_config; | 52 | protected IConfigSource m_config; |
53 | protected HypergridLinker m_HypergridLinker; | ||
53 | 54 | ||
54 | protected IAuthenticationService m_AuthenticationService = null; | 55 | protected IAuthenticationService m_AuthenticationService = null; |
55 | protected bool m_AllowDuplicateNames = false; | 56 | protected bool m_AllowDuplicateNames = false; |
@@ -92,6 +93,8 @@ namespace OpenSim.Services.GridService | |||
92 | "Set database flags for region", | 93 | "Set database flags for region", |
93 | String.Empty, | 94 | String.Empty, |
94 | HandleSetFlags); | 95 | HandleSetFlags); |
96 | |||
97 | m_HypergridLinker = new HypergridLinker(m_config, this, m_Database); | ||
95 | } | 98 | } |
96 | } | 99 | } |
97 | 100 | ||
@@ -346,7 +349,7 @@ namespace OpenSim.Services.GridService | |||
346 | 349 | ||
347 | #region Data structure conversions | 350 | #region Data structure conversions |
348 | 351 | ||
349 | protected RegionData RegionInfo2RegionData(GridRegion rinfo) | 352 | public RegionData RegionInfo2RegionData(GridRegion rinfo) |
350 | { | 353 | { |
351 | RegionData rdata = new RegionData(); | 354 | RegionData rdata = new RegionData(); |
352 | rdata.posX = (int)rinfo.RegionLocX; | 355 | rdata.posX = (int)rinfo.RegionLocX; |
@@ -359,7 +362,7 @@ namespace OpenSim.Services.GridService | |||
359 | return rdata; | 362 | return rdata; |
360 | } | 363 | } |
361 | 364 | ||
362 | protected GridRegion RegionData2RegionInfo(RegionData rdata) | 365 | public GridRegion RegionData2RegionInfo(RegionData rdata) |
363 | { | 366 | { |
364 | GridRegion rinfo = new GridRegion(rdata.Data); | 367 | GridRegion rinfo = new GridRegion(rdata.Data); |
365 | rinfo.RegionLocX = rdata.posX; | 368 | rinfo.RegionLocX = rdata.posX; |
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs new file mode 100644 index 0000000..b0cf723 --- /dev/null +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -0,0 +1,614 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using System.Xml; | ||
33 | |||
34 | using Nini.Config; | ||
35 | using log4net; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Data; | ||
39 | using OpenSim.Server.Base; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenSim.Services.Connectors.Hypergrid; | ||
42 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
43 | using OpenMetaverse; | ||
44 | |||
45 | namespace OpenSim.Services.GridService | ||
46 | { | ||
47 | public class HypergridLinker | ||
48 | { | ||
49 | private static readonly ILog m_log = | ||
50 | LogManager.GetLogger( | ||
51 | MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); | ||
54 | |||
55 | private static uint m_autoMappingX = 0; | ||
56 | private static uint m_autoMappingY = 0; | ||
57 | private static bool m_enableAutoMapping = false; | ||
58 | |||
59 | protected IRegionData m_Database; | ||
60 | protected GridService m_GridService; | ||
61 | protected IAssetService m_AssetService; | ||
62 | protected GatekeeperServiceConnector m_GatekeeperConnector; | ||
63 | |||
64 | protected UUID m_ScopeID = UUID.Zero; | ||
65 | |||
66 | // Hyperlink regions are hyperlinks on the map | ||
67 | public readonly Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>(); | ||
68 | protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>(); | ||
69 | |||
70 | protected GridRegion m_DefaultRegion; | ||
71 | protected GridRegion DefaultRegion | ||
72 | { | ||
73 | get | ||
74 | { | ||
75 | if (m_DefaultRegion == null) | ||
76 | { | ||
77 | List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID); | ||
78 | if (defs != null && defs.Count > 0) | ||
79 | m_DefaultRegion = defs[0]; | ||
80 | else | ||
81 | { | ||
82 | // Best guess, may be totally off | ||
83 | m_DefaultRegion = new GridRegion(1000, 1000); | ||
84 | m_log.WarnFormat("[HYPERGRID LINKER]: This grid does not have a default region. Assuming default coordinates at 1000, 1000."); | ||
85 | } | ||
86 | } | ||
87 | return m_DefaultRegion; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db) | ||
92 | { | ||
93 | m_log.DebugFormat("[HYPERGRID LINKER]: Starting..."); | ||
94 | |||
95 | m_Database = db; | ||
96 | m_GridService = gridService; | ||
97 | |||
98 | IConfig gridConfig = config.Configs["GridService"]; | ||
99 | if (gridConfig != null) | ||
100 | { | ||
101 | string assetService = gridConfig.GetString("AssetService", string.Empty); | ||
102 | |||
103 | Object[] args = new Object[] { config }; | ||
104 | |||
105 | if (assetService != string.Empty) | ||
106 | m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args); | ||
107 | |||
108 | string scope = gridConfig.GetString("ScopeID", string.Empty); | ||
109 | if (scope != string.Empty) | ||
110 | UUID.TryParse(scope, out m_ScopeID); | ||
111 | |||
112 | m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); | ||
113 | |||
114 | m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services..."); | ||
115 | } | ||
116 | |||
117 | |||
118 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", | ||
119 | "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", | ||
120 | "Link a hypergrid region", RunCommand); | ||
121 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", | ||
122 | "unlink-region <local name> or <HostName>:<HttpPort> <cr>", | ||
123 | "Unlink a hypergrid region", RunCommand); | ||
124 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>", | ||
125 | "Set local coordinate to map HG regions to", RunCommand); | ||
126 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks <cr>", | ||
127 | "List the HG regions", HandleShow); | ||
128 | } | ||
129 | |||
130 | |||
131 | #region Link Region | ||
132 | |||
133 | public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason) | ||
134 | { | ||
135 | regionID = UUID.Zero; | ||
136 | imageURL = string.Empty; | ||
137 | regionHandle = 0; | ||
138 | reason = string.Empty; | ||
139 | int xloc = random.Next(0, Int16.MaxValue) * (int)Constants.RegionSize; | ||
140 | GridRegion region = TryLinkRegionToCoords(regionDescriptor, xloc, 0, out reason); | ||
141 | if (region == null) | ||
142 | return false; | ||
143 | |||
144 | regionID = region.RegionID; | ||
145 | regionHandle = region.RegionHandle; | ||
146 | return true; | ||
147 | } | ||
148 | |||
149 | private static Random random = new Random(); | ||
150 | |||
151 | // From the command line link-region | ||
152 | public GridRegion TryLinkRegionToCoords(string mapName, int xloc, int yloc, out string reason) | ||
153 | { | ||
154 | reason = string.Empty; | ||
155 | string host = "127.0.0.1"; | ||
156 | string portstr; | ||
157 | string regionName = ""; | ||
158 | uint port = 9000; | ||
159 | string[] parts = mapName.Split(new char[] { ':' }); | ||
160 | if (parts.Length >= 1) | ||
161 | { | ||
162 | host = parts[0]; | ||
163 | } | ||
164 | if (parts.Length >= 2) | ||
165 | { | ||
166 | portstr = parts[1]; | ||
167 | //m_log.Debug("-- port = " + portstr); | ||
168 | if (!UInt32.TryParse(portstr, out port)) | ||
169 | regionName = parts[1]; | ||
170 | } | ||
171 | // always take the last one | ||
172 | if (parts.Length >= 3) | ||
173 | { | ||
174 | regionName = parts[2]; | ||
175 | } | ||
176 | |||
177 | // Sanity check. Don't ever link to this sim. | ||
178 | IPAddress ipaddr = null; | ||
179 | try | ||
180 | { | ||
181 | ipaddr = Util.GetHostFromDNS(host); | ||
182 | } | ||
183 | catch { } | ||
184 | |||
185 | GridRegion regInfo; | ||
186 | bool success = TryCreateLink(xloc, yloc, regionName, port, host, out regInfo, out reason); | ||
187 | if (success) | ||
188 | { | ||
189 | regInfo.RegionName = mapName; | ||
190 | return regInfo; | ||
191 | } | ||
192 | |||
193 | return null; | ||
194 | } | ||
195 | |||
196 | |||
197 | // From the command line and the 2 above | ||
198 | public bool TryCreateLink(int xloc, int yloc, | ||
199 | string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo, out string reason) | ||
200 | { | ||
201 | m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); | ||
202 | |||
203 | reason = string.Empty; | ||
204 | regInfo = new GridRegion(); | ||
205 | regInfo.RegionName = externalRegionName; | ||
206 | regInfo.HttpPort = externalPort; | ||
207 | regInfo.ExternalHostName = externalHostName; | ||
208 | regInfo.RegionLocX = xloc; | ||
209 | regInfo.RegionLocY = yloc; | ||
210 | |||
211 | try | ||
212 | { | ||
213 | regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); | ||
214 | } | ||
215 | catch (Exception e) | ||
216 | { | ||
217 | m_log.Warn("[HYPERGRID LINKER]: Wrong format for link-region: " + e.Message); | ||
218 | reason = "Internal error"; | ||
219 | return false; | ||
220 | } | ||
221 | |||
222 | // Finally, link it | ||
223 | ulong handle = 0; | ||
224 | UUID regionID = UUID.Zero; | ||
225 | string imageURL = string.Empty; | ||
226 | if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out imageURL, out reason)) | ||
227 | return false; | ||
228 | |||
229 | if (regionID != UUID.Zero) | ||
230 | { | ||
231 | regInfo.RegionID = regionID; | ||
232 | // Try get the map image | ||
233 | regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL); | ||
234 | // I need a texture that works for this... the one I tried doesn't seem to be working | ||
235 | //regInfo.TerrainImage = m_HGMapImage; | ||
236 | |||
237 | AddHyperlinkRegion(regInfo, handle); | ||
238 | m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID); | ||
239 | |||
240 | } | ||
241 | else | ||
242 | { | ||
243 | m_log.Warn("[HYPERGRID LINKER]: Unable to link region"); | ||
244 | reason = "Remote region could not be found"; | ||
245 | return false; | ||
246 | } | ||
247 | |||
248 | uint x, y; | ||
249 | if (!Check4096(handle, out x, out y)) | ||
250 | { | ||
251 | RemoveHyperlinkRegion(regInfo.RegionID); | ||
252 | reason = "Region is too far (" + x + ", " + y + ")"; | ||
253 | m_log.Info("[HYPERGRID LINKER]: Unable to link, region is too far (" + x + ", " + y + ")"); | ||
254 | return false; | ||
255 | } | ||
256 | |||
257 | m_log.Debug("[HYPERGRID LINKER]: link region succeeded"); | ||
258 | return true; | ||
259 | } | ||
260 | |||
261 | public bool TryUnlinkRegion(string mapName) | ||
262 | { | ||
263 | GridRegion regInfo = null; | ||
264 | if (mapName.Contains(":")) | ||
265 | { | ||
266 | string host = "127.0.0.1"; | ||
267 | //string portstr; | ||
268 | //string regionName = ""; | ||
269 | uint port = 9000; | ||
270 | string[] parts = mapName.Split(new char[] { ':' }); | ||
271 | if (parts.Length >= 1) | ||
272 | { | ||
273 | host = parts[0]; | ||
274 | } | ||
275 | |||
276 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
277 | if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) | ||
278 | regInfo = r; | ||
279 | } | ||
280 | else | ||
281 | { | ||
282 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
283 | if (r.RegionName.Equals(mapName)) | ||
284 | regInfo = r; | ||
285 | } | ||
286 | if (regInfo != null) | ||
287 | { | ||
288 | RemoveHyperlinkRegion(regInfo.RegionID); | ||
289 | return true; | ||
290 | } | ||
291 | else | ||
292 | { | ||
293 | m_log.InfoFormat("[HYPERGRID LINKER]: Region {0} not found", mapName); | ||
294 | return false; | ||
295 | } | ||
296 | } | ||
297 | |||
298 | /// <summary> | ||
299 | /// Cope with this viewer limitation. | ||
300 | /// </summary> | ||
301 | /// <param name="regInfo"></param> | ||
302 | /// <returns></returns> | ||
303 | public bool Check4096(ulong realHandle, out uint x, out uint y) | ||
304 | { | ||
305 | GridRegion defRegion = DefaultRegion; | ||
306 | |||
307 | uint ux = 0, uy = 0; | ||
308 | Utils.LongToUInts(realHandle, out ux, out uy); | ||
309 | x = ux / Constants.RegionSize; | ||
310 | y = uy / Constants.RegionSize; | ||
311 | |||
312 | if ((Math.Abs((int)defRegion.RegionLocX - ux) >= 4096 * Constants.RegionSize) || | ||
313 | (Math.Abs((int)defRegion.RegionLocY - uy) >= 4096 * Constants.RegionSize)) | ||
314 | { | ||
315 | return false; | ||
316 | } | ||
317 | return true; | ||
318 | } | ||
319 | |||
320 | private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) | ||
321 | { | ||
322 | //m_HyperlinkRegions[regionInfo.RegionID] = regionInfo; | ||
323 | //m_HyperlinkHandles[regionInfo.RegionID] = regionHandle; | ||
324 | |||
325 | RegionData rdata = m_GridService.RegionInfo2RegionData(regionInfo); | ||
326 | int flags = (int)OpenSim.Data.RegionFlags.Hyperlink + (int)OpenSim.Data.RegionFlags.NoDirectLogin + (int)OpenSim.Data.RegionFlags.RegionOnline; | ||
327 | rdata.Data["flags"] = flags.ToString(); | ||
328 | |||
329 | m_Database.Store(rdata); | ||
330 | |||
331 | } | ||
332 | |||
333 | private void RemoveHyperlinkRegion(UUID regionID) | ||
334 | { | ||
335 | //// Try the hyperlink collection | ||
336 | //if (m_HyperlinkRegions.ContainsKey(regionID)) | ||
337 | //{ | ||
338 | // m_HyperlinkRegions.Remove(regionID); | ||
339 | // m_HyperlinkHandles.Remove(regionID); | ||
340 | //} | ||
341 | m_Database.Delete(regionID); | ||
342 | } | ||
343 | |||
344 | #endregion | ||
345 | |||
346 | |||
347 | #region Console Commands | ||
348 | |||
349 | public void HandleShow(string module, string[] cmd) | ||
350 | { | ||
351 | MainConsole.Instance.Output("Not Implemented Yet"); | ||
352 | //if (cmd.Length != 2) | ||
353 | //{ | ||
354 | // MainConsole.Instance.Output("Syntax: show hyperlinks"); | ||
355 | // return; | ||
356 | //} | ||
357 | //List<GridRegion> regions = new List<GridRegion>(m_HypergridService.m_HyperlinkRegions.Values); | ||
358 | //if (regions == null || regions.Count < 1) | ||
359 | //{ | ||
360 | // MainConsole.Instance.Output("No hyperlinks"); | ||
361 | // return; | ||
362 | //} | ||
363 | |||
364 | //MainConsole.Instance.Output("Region Name Region UUID"); | ||
365 | //MainConsole.Instance.Output("Location URI"); | ||
366 | //MainConsole.Instance.Output("Owner ID "); | ||
367 | //MainConsole.Instance.Output("-------------------------------------------------------------------------------"); | ||
368 | //foreach (GridRegion r in regions) | ||
369 | //{ | ||
370 | // MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} \n\n", | ||
371 | // r.RegionName, r.RegionID, | ||
372 | // String.Format("{0},{1}", r.RegionLocX, r.RegionLocY), "http://" + r.ExternalHostName + ":" + r.HttpPort.ToString(), | ||
373 | // r.EstateOwner.ToString())); | ||
374 | //} | ||
375 | //return; | ||
376 | } | ||
377 | public void RunCommand(string module, string[] cmdparams) | ||
378 | { | ||
379 | List<string> args = new List<string>(cmdparams); | ||
380 | if (args.Count < 1) | ||
381 | return; | ||
382 | |||
383 | string command = args[0]; | ||
384 | args.RemoveAt(0); | ||
385 | |||
386 | cmdparams = args.ToArray(); | ||
387 | |||
388 | RunHGCommand(command, cmdparams); | ||
389 | |||
390 | } | ||
391 | |||
392 | private void RunHGCommand(string command, string[] cmdparams) | ||
393 | { | ||
394 | if (command.Equals("link-mapping")) | ||
395 | { | ||
396 | if (cmdparams.Length == 2) | ||
397 | { | ||
398 | try | ||
399 | { | ||
400 | m_autoMappingX = Convert.ToUInt32(cmdparams[0]); | ||
401 | m_autoMappingY = Convert.ToUInt32(cmdparams[1]); | ||
402 | m_enableAutoMapping = true; | ||
403 | } | ||
404 | catch (Exception) | ||
405 | { | ||
406 | m_autoMappingX = 0; | ||
407 | m_autoMappingY = 0; | ||
408 | m_enableAutoMapping = false; | ||
409 | } | ||
410 | } | ||
411 | } | ||
412 | else if (command.Equals("link-region")) | ||
413 | { | ||
414 | if (cmdparams.Length < 3) | ||
415 | { | ||
416 | if ((cmdparams.Length == 1) || (cmdparams.Length == 2)) | ||
417 | { | ||
418 | LoadXmlLinkFile(cmdparams); | ||
419 | } | ||
420 | else | ||
421 | { | ||
422 | LinkRegionCmdUsage(); | ||
423 | } | ||
424 | return; | ||
425 | } | ||
426 | |||
427 | if (cmdparams[2].Contains(":")) | ||
428 | { | ||
429 | // New format | ||
430 | int xloc, yloc; | ||
431 | string mapName; | ||
432 | try | ||
433 | { | ||
434 | xloc = Convert.ToInt32(cmdparams[0]); | ||
435 | yloc = Convert.ToInt32(cmdparams[1]); | ||
436 | mapName = cmdparams[2]; | ||
437 | if (cmdparams.Length > 3) | ||
438 | for (int i = 3; i < cmdparams.Length; i++) | ||
439 | mapName += " " + cmdparams[i]; | ||
440 | |||
441 | //m_log.Info(">> MapName: " + mapName); | ||
442 | } | ||
443 | catch (Exception e) | ||
444 | { | ||
445 | MainConsole.Instance.Output("[HGrid] Wrong format for link-region command: " + e.Message); | ||
446 | LinkRegionCmdUsage(); | ||
447 | return; | ||
448 | } | ||
449 | |||
450 | // Convert cell coordinates given by the user to meters | ||
451 | xloc = xloc * (int)Constants.RegionSize; | ||
452 | yloc = yloc * (int)Constants.RegionSize; | ||
453 | string reason = string.Empty; | ||
454 | if (TryLinkRegionToCoords(mapName, xloc, yloc, out reason) == null) | ||
455 | MainConsole.Instance.Output("Failed to link region: " + reason); | ||
456 | MainConsole.Instance.Output("Hyperlink estalished"); | ||
457 | } | ||
458 | else | ||
459 | { | ||
460 | // old format | ||
461 | GridRegion regInfo; | ||
462 | int xloc, yloc; | ||
463 | uint externalPort; | ||
464 | string externalHostName; | ||
465 | try | ||
466 | { | ||
467 | xloc = Convert.ToInt32(cmdparams[0]); | ||
468 | yloc = Convert.ToInt32(cmdparams[1]); | ||
469 | externalPort = Convert.ToUInt32(cmdparams[3]); | ||
470 | externalHostName = cmdparams[2]; | ||
471 | //internalPort = Convert.ToUInt32(cmdparams[4]); | ||
472 | //remotingPort = Convert.ToUInt32(cmdparams[5]); | ||
473 | } | ||
474 | catch (Exception e) | ||
475 | { | ||
476 | MainConsole.Instance.Output("[HGrid] Wrong format for link-region command: " + e.Message); | ||
477 | LinkRegionCmdUsage(); | ||
478 | return; | ||
479 | } | ||
480 | |||
481 | // Convert cell coordinates given by the user to meters | ||
482 | xloc = xloc * (int)Constants.RegionSize; | ||
483 | yloc = yloc * (int)Constants.RegionSize; | ||
484 | string reason = string.Empty; | ||
485 | if (TryCreateLink(xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason)) | ||
486 | { | ||
487 | if (cmdparams.Length >= 5) | ||
488 | { | ||
489 | regInfo.RegionName = ""; | ||
490 | for (int i = 4; i < cmdparams.Length; i++) | ||
491 | regInfo.RegionName += cmdparams[i] + " "; | ||
492 | } | ||
493 | } | ||
494 | } | ||
495 | return; | ||
496 | } | ||
497 | else if (command.Equals("unlink-region")) | ||
498 | { | ||
499 | if (cmdparams.Length < 1) | ||
500 | { | ||
501 | UnlinkRegionCmdUsage(); | ||
502 | return; | ||
503 | } | ||
504 | if (TryUnlinkRegion(cmdparams[0])) | ||
505 | MainConsole.Instance.Output("Successfully unlinked " + cmdparams[0]); | ||
506 | else | ||
507 | MainConsole.Instance.Output("Unable to unlink " + cmdparams[0] + ", region not found."); | ||
508 | } | ||
509 | } | ||
510 | |||
511 | private void LoadXmlLinkFile(string[] cmdparams) | ||
512 | { | ||
513 | //use http://www.hgurl.com/hypergrid.xml for test | ||
514 | try | ||
515 | { | ||
516 | XmlReader r = XmlReader.Create(cmdparams[0]); | ||
517 | XmlConfigSource cs = new XmlConfigSource(r); | ||
518 | string[] excludeSections = null; | ||
519 | |||
520 | if (cmdparams.Length == 2) | ||
521 | { | ||
522 | if (cmdparams[1].ToLower().StartsWith("excludelist:")) | ||
523 | { | ||
524 | string excludeString = cmdparams[1].ToLower(); | ||
525 | excludeString = excludeString.Remove(0, 12); | ||
526 | char[] splitter = { ';' }; | ||
527 | |||
528 | excludeSections = excludeString.Split(splitter); | ||
529 | } | ||
530 | } | ||
531 | |||
532 | for (int i = 0; i < cs.Configs.Count; i++) | ||
533 | { | ||
534 | bool skip = false; | ||
535 | if ((excludeSections != null) && (excludeSections.Length > 0)) | ||
536 | { | ||
537 | for (int n = 0; n < excludeSections.Length; n++) | ||
538 | { | ||
539 | if (excludeSections[n] == cs.Configs[i].Name.ToLower()) | ||
540 | { | ||
541 | skip = true; | ||
542 | break; | ||
543 | } | ||
544 | } | ||
545 | } | ||
546 | if (!skip) | ||
547 | { | ||
548 | ReadLinkFromConfig(cs.Configs[i]); | ||
549 | } | ||
550 | } | ||
551 | } | ||
552 | catch (Exception e) | ||
553 | { | ||
554 | m_log.Error(e.ToString()); | ||
555 | } | ||
556 | } | ||
557 | |||
558 | |||
559 | private void ReadLinkFromConfig(IConfig config) | ||
560 | { | ||
561 | GridRegion regInfo; | ||
562 | int xloc, yloc; | ||
563 | uint externalPort; | ||
564 | string externalHostName; | ||
565 | uint realXLoc, realYLoc; | ||
566 | |||
567 | xloc = Convert.ToInt32(config.GetString("xloc", "0")); | ||
568 | yloc = Convert.ToInt32(config.GetString("yloc", "0")); | ||
569 | externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); | ||
570 | externalHostName = config.GetString("externalHostName", ""); | ||
571 | realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); | ||
572 | realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0")); | ||
573 | |||
574 | if (m_enableAutoMapping) | ||
575 | { | ||
576 | xloc = (int)((xloc % 100) + m_autoMappingX); | ||
577 | yloc = (int)((yloc % 100) + m_autoMappingY); | ||
578 | } | ||
579 | |||
580 | if (((realXLoc == 0) && (realYLoc == 0)) || | ||
581 | (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && | ||
582 | ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) | ||
583 | { | ||
584 | xloc = xloc * (int)Constants.RegionSize; | ||
585 | yloc = yloc * (int)Constants.RegionSize; | ||
586 | string reason = string.Empty; | ||
587 | if (TryCreateLink(xloc, yloc, "", externalPort, | ||
588 | externalHostName, out regInfo, out reason)) | ||
589 | { | ||
590 | regInfo.RegionName = config.GetString("localName", ""); | ||
591 | } | ||
592 | else | ||
593 | MainConsole.Instance.Output("Unable to link " + externalHostName + ": " + reason); | ||
594 | } | ||
595 | } | ||
596 | |||
597 | |||
598 | private void LinkRegionCmdUsage() | ||
599 | { | ||
600 | MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]"); | ||
601 | MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]"); | ||
602 | MainConsole.Instance.Output("Usage: link-region <URI_of_xml> [<exclude>]"); | ||
603 | } | ||
604 | |||
605 | private void UnlinkRegionCmdUsage() | ||
606 | { | ||
607 | MainConsole.Instance.Output("Usage: unlink-region <HostName>:<HttpPort>"); | ||
608 | MainConsole.Instance.Output("Usage: unlink-region <LocalName>"); | ||
609 | } | ||
610 | |||
611 | #endregion | ||
612 | |||
613 | } | ||
614 | } | ||
diff --git a/OpenSim/Services/HypergridService/HGCommands.cs b/OpenSim/Services/HypergridService/HGCommands.cs deleted file mode 100644 index 78ba46d..0000000 --- a/OpenSim/Services/HypergridService/HGCommands.cs +++ /dev/null | |||
@@ -1,318 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Xml; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | //using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Framework.Console; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | |||
40 | namespace OpenSim.Services.HypergridService | ||
41 | { | ||
42 | public class HGCommands | ||
43 | { | ||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | private HypergridService m_HypergridService; | ||
46 | |||
47 | private static uint m_autoMappingX = 0; | ||
48 | private static uint m_autoMappingY = 0; | ||
49 | private static bool m_enableAutoMapping = false; | ||
50 | |||
51 | public HGCommands(HypergridService service) | ||
52 | { | ||
53 | m_HypergridService = service; | ||
54 | } | ||
55 | |||
56 | public void HandleShow(string module, string[] cmd) | ||
57 | { | ||
58 | if (cmd.Length != 2) | ||
59 | { | ||
60 | MainConsole.Instance.Output("Syntax: show hyperlinks"); | ||
61 | return; | ||
62 | } | ||
63 | List<GridRegion> regions = new List<GridRegion>(m_HypergridService.m_HyperlinkRegions.Values); | ||
64 | if (regions == null || regions.Count < 1) | ||
65 | { | ||
66 | MainConsole.Instance.Output("No hyperlinks"); | ||
67 | return; | ||
68 | } | ||
69 | |||
70 | MainConsole.Instance.Output("Region Name Region UUID"); | ||
71 | MainConsole.Instance.Output("Location URI"); | ||
72 | MainConsole.Instance.Output("Owner ID "); | ||
73 | MainConsole.Instance.Output("-------------------------------------------------------------------------------"); | ||
74 | foreach (GridRegion r in regions) | ||
75 | { | ||
76 | MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} \n\n", | ||
77 | r.RegionName, r.RegionID, | ||
78 | String.Format("{0},{1}", r.RegionLocX, r.RegionLocY), "http://" + r.ExternalHostName + ":" + r.HttpPort.ToString(), | ||
79 | r.EstateOwner.ToString())); | ||
80 | } | ||
81 | return; | ||
82 | } | ||
83 | public void RunCommand(string module, string[] cmdparams) | ||
84 | { | ||
85 | List<string> args = new List<string>(cmdparams); | ||
86 | if (args.Count < 1) | ||
87 | return; | ||
88 | |||
89 | string command = args[0]; | ||
90 | args.RemoveAt(0); | ||
91 | |||
92 | cmdparams = args.ToArray(); | ||
93 | |||
94 | RunHGCommand(command, cmdparams); | ||
95 | |||
96 | } | ||
97 | |||
98 | private void RunHGCommand(string command, string[] cmdparams) | ||
99 | { | ||
100 | if (command.Equals("link-mapping")) | ||
101 | { | ||
102 | if (cmdparams.Length == 2) | ||
103 | { | ||
104 | try | ||
105 | { | ||
106 | m_autoMappingX = Convert.ToUInt32(cmdparams[0]); | ||
107 | m_autoMappingY = Convert.ToUInt32(cmdparams[1]); | ||
108 | m_enableAutoMapping = true; | ||
109 | } | ||
110 | catch (Exception) | ||
111 | { | ||
112 | m_autoMappingX = 0; | ||
113 | m_autoMappingY = 0; | ||
114 | m_enableAutoMapping = false; | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | else if (command.Equals("link-region")) | ||
119 | { | ||
120 | if (cmdparams.Length < 3) | ||
121 | { | ||
122 | if ((cmdparams.Length == 1) || (cmdparams.Length == 2)) | ||
123 | { | ||
124 | LoadXmlLinkFile(cmdparams); | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | LinkRegionCmdUsage(); | ||
129 | } | ||
130 | return; | ||
131 | } | ||
132 | |||
133 | if (cmdparams[2].Contains(":")) | ||
134 | { | ||
135 | // New format | ||
136 | int xloc, yloc; | ||
137 | string mapName; | ||
138 | try | ||
139 | { | ||
140 | xloc = Convert.ToInt32(cmdparams[0]); | ||
141 | yloc = Convert.ToInt32(cmdparams[1]); | ||
142 | mapName = cmdparams[2]; | ||
143 | if (cmdparams.Length > 3) | ||
144 | for (int i = 3; i < cmdparams.Length; i++) | ||
145 | mapName += " " + cmdparams[i]; | ||
146 | |||
147 | //m_log.Info(">> MapName: " + mapName); | ||
148 | } | ||
149 | catch (Exception e) | ||
150 | { | ||
151 | MainConsole.Instance.Output("[HGrid] Wrong format for link-region command: " + e.Message); | ||
152 | LinkRegionCmdUsage(); | ||
153 | return; | ||
154 | } | ||
155 | |||
156 | // Convert cell coordinates given by the user to meters | ||
157 | xloc = xloc * (int)Constants.RegionSize; | ||
158 | yloc = yloc * (int)Constants.RegionSize; | ||
159 | string reason = string.Empty; | ||
160 | if (m_HypergridService.TryLinkRegionToCoords(mapName, xloc, yloc, out reason) == null) | ||
161 | MainConsole.Instance.Output("Failed to link region: " + reason); | ||
162 | MainConsole.Instance.Output("Hyperlink estalished"); | ||
163 | } | ||
164 | else | ||
165 | { | ||
166 | // old format | ||
167 | GridRegion regInfo; | ||
168 | int xloc, yloc; | ||
169 | uint externalPort; | ||
170 | string externalHostName; | ||
171 | try | ||
172 | { | ||
173 | xloc = Convert.ToInt32(cmdparams[0]); | ||
174 | yloc = Convert.ToInt32(cmdparams[1]); | ||
175 | externalPort = Convert.ToUInt32(cmdparams[3]); | ||
176 | externalHostName = cmdparams[2]; | ||
177 | //internalPort = Convert.ToUInt32(cmdparams[4]); | ||
178 | //remotingPort = Convert.ToUInt32(cmdparams[5]); | ||
179 | } | ||
180 | catch (Exception e) | ||
181 | { | ||
182 | MainConsole.Instance.Output("[HGrid] Wrong format for link-region command: " + e.Message); | ||
183 | LinkRegionCmdUsage(); | ||
184 | return; | ||
185 | } | ||
186 | |||
187 | // Convert cell coordinates given by the user to meters | ||
188 | xloc = xloc * (int)Constants.RegionSize; | ||
189 | yloc = yloc * (int)Constants.RegionSize; | ||
190 | string reason = string.Empty; | ||
191 | if (m_HypergridService.TryCreateLink(xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason)) | ||
192 | { | ||
193 | if (cmdparams.Length >= 5) | ||
194 | { | ||
195 | regInfo.RegionName = ""; | ||
196 | for (int i = 4; i < cmdparams.Length; i++) | ||
197 | regInfo.RegionName += cmdparams[i] + " "; | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | return; | ||
202 | } | ||
203 | else if (command.Equals("unlink-region")) | ||
204 | { | ||
205 | if (cmdparams.Length < 1) | ||
206 | { | ||
207 | UnlinkRegionCmdUsage(); | ||
208 | return; | ||
209 | } | ||
210 | if (m_HypergridService.TryUnlinkRegion(cmdparams[0])) | ||
211 | MainConsole.Instance.Output("Successfully unlinked " + cmdparams[0]); | ||
212 | else | ||
213 | MainConsole.Instance.Output("Unable to unlink " + cmdparams[0] + ", region not found."); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | private void LoadXmlLinkFile(string[] cmdparams) | ||
218 | { | ||
219 | //use http://www.hgurl.com/hypergrid.xml for test | ||
220 | try | ||
221 | { | ||
222 | XmlReader r = XmlReader.Create(cmdparams[0]); | ||
223 | XmlConfigSource cs = new XmlConfigSource(r); | ||
224 | string[] excludeSections = null; | ||
225 | |||
226 | if (cmdparams.Length == 2) | ||
227 | { | ||
228 | if (cmdparams[1].ToLower().StartsWith("excludelist:")) | ||
229 | { | ||
230 | string excludeString = cmdparams[1].ToLower(); | ||
231 | excludeString = excludeString.Remove(0, 12); | ||
232 | char[] splitter = { ';' }; | ||
233 | |||
234 | excludeSections = excludeString.Split(splitter); | ||
235 | } | ||
236 | } | ||
237 | |||
238 | for (int i = 0; i < cs.Configs.Count; i++) | ||
239 | { | ||
240 | bool skip = false; | ||
241 | if ((excludeSections != null) && (excludeSections.Length > 0)) | ||
242 | { | ||
243 | for (int n = 0; n < excludeSections.Length; n++) | ||
244 | { | ||
245 | if (excludeSections[n] == cs.Configs[i].Name.ToLower()) | ||
246 | { | ||
247 | skip = true; | ||
248 | break; | ||
249 | } | ||
250 | } | ||
251 | } | ||
252 | if (!skip) | ||
253 | { | ||
254 | ReadLinkFromConfig(cs.Configs[i]); | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | catch (Exception e) | ||
259 | { | ||
260 | m_log.Error(e.ToString()); | ||
261 | } | ||
262 | } | ||
263 | |||
264 | |||
265 | private void ReadLinkFromConfig(IConfig config) | ||
266 | { | ||
267 | GridRegion regInfo; | ||
268 | int xloc, yloc; | ||
269 | uint externalPort; | ||
270 | string externalHostName; | ||
271 | uint realXLoc, realYLoc; | ||
272 | |||
273 | xloc = Convert.ToInt32(config.GetString("xloc", "0")); | ||
274 | yloc = Convert.ToInt32(config.GetString("yloc", "0")); | ||
275 | externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); | ||
276 | externalHostName = config.GetString("externalHostName", ""); | ||
277 | realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); | ||
278 | realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0")); | ||
279 | |||
280 | if (m_enableAutoMapping) | ||
281 | { | ||
282 | xloc = (int)((xloc % 100) + m_autoMappingX); | ||
283 | yloc = (int)((yloc % 100) + m_autoMappingY); | ||
284 | } | ||
285 | |||
286 | if (((realXLoc == 0) && (realYLoc == 0)) || | ||
287 | (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && | ||
288 | ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) | ||
289 | { | ||
290 | xloc = xloc * (int)Constants.RegionSize; | ||
291 | yloc = yloc * (int)Constants.RegionSize; | ||
292 | string reason = string.Empty; | ||
293 | if (m_HypergridService.TryCreateLink(xloc, yloc, "", externalPort, | ||
294 | externalHostName, out regInfo, out reason)) | ||
295 | { | ||
296 | regInfo.RegionName = config.GetString("localName", ""); | ||
297 | } | ||
298 | else | ||
299 | MainConsole.Instance.Output("Unable to link " + externalHostName + ": " + reason); | ||
300 | } | ||
301 | } | ||
302 | |||
303 | |||
304 | private void LinkRegionCmdUsage() | ||
305 | { | ||
306 | MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]"); | ||
307 | MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]"); | ||
308 | MainConsole.Instance.Output("Usage: link-region <URI_of_xml> [<exclude>]"); | ||
309 | } | ||
310 | |||
311 | private void UnlinkRegionCmdUsage() | ||
312 | { | ||
313 | MainConsole.Instance.Output("Usage: unlink-region <HostName>:<HttpPort>"); | ||
314 | MainConsole.Instance.Output("Usage: unlink-region <LocalName>"); | ||
315 | } | ||
316 | |||
317 | } | ||
318 | } | ||
diff --git a/OpenSim/Services/HypergridService/HypergridService.cs b/OpenSim/Services/HypergridService/HypergridService.cs deleted file mode 100644 index ac0f5ac..0000000 --- a/OpenSim/Services/HypergridService/HypergridService.cs +++ /dev/null | |||
@@ -1,417 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using Nini.Config; | ||
33 | using log4net; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Console; | ||
36 | using OpenSim.Data; | ||
37 | using OpenSim.Server.Base; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using OpenSim.Services.Connectors.Hypergrid; | ||
40 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
41 | using OpenMetaverse; | ||
42 | |||
43 | namespace OpenSim.Services.HypergridService | ||
44 | { | ||
45 | public class HypergridService : HypergridServiceBase, IHypergridService | ||
46 | { | ||
47 | private static readonly ILog m_log = | ||
48 | LogManager.GetLogger( | ||
49 | MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private static HypergridService m_RootInstance = null; | ||
52 | protected IConfigSource m_config; | ||
53 | |||
54 | protected IPresenceService m_PresenceService = null; | ||
55 | protected IGridService m_GridService; | ||
56 | protected IAssetService m_AssetService; | ||
57 | protected HypergridServiceConnector m_HypergridConnector; | ||
58 | |||
59 | protected bool m_AllowDuplicateNames = false; | ||
60 | protected UUID m_ScopeID = UUID.Zero; | ||
61 | |||
62 | // Hyperlink regions are hyperlinks on the map | ||
63 | public readonly Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>(); | ||
64 | protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>(); | ||
65 | |||
66 | protected GridRegion m_DefaultRegion; | ||
67 | protected GridRegion DefaultRegion | ||
68 | { | ||
69 | get | ||
70 | { | ||
71 | if (m_DefaultRegion == null) | ||
72 | { | ||
73 | List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID); | ||
74 | if (defs != null && defs.Count > 0) | ||
75 | m_DefaultRegion = defs[0]; | ||
76 | else | ||
77 | { | ||
78 | // Best guess, may be totally off | ||
79 | m_DefaultRegion = new GridRegion(1000, 1000); | ||
80 | m_log.WarnFormat("[HYPERGRID SERVICE]: This grid does not have a default region. Assuming default coordinates at 1000, 1000."); | ||
81 | } | ||
82 | } | ||
83 | return m_DefaultRegion; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | public HypergridService(IConfigSource config) | ||
88 | : base(config) | ||
89 | { | ||
90 | m_log.DebugFormat("[HYPERGRID SERVICE]: Starting..."); | ||
91 | |||
92 | m_config = config; | ||
93 | IConfig gridConfig = config.Configs["HypergridService"]; | ||
94 | if (gridConfig != null) | ||
95 | { | ||
96 | string gridService = gridConfig.GetString("GridService", string.Empty); | ||
97 | string presenceService = gridConfig.GetString("PresenceService", String.Empty); | ||
98 | string assetService = gridConfig.GetString("AssetService", string.Empty); | ||
99 | |||
100 | Object[] args = new Object[] { config }; | ||
101 | if (gridService != string.Empty) | ||
102 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); | ||
103 | |||
104 | if (m_GridService == null) | ||
105 | throw new Exception("HypergridService cannot function without a GridService"); | ||
106 | |||
107 | if (presenceService != String.Empty) | ||
108 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); | ||
109 | |||
110 | if (assetService != string.Empty) | ||
111 | m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args); | ||
112 | |||
113 | m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); | ||
114 | |||
115 | string scope = gridConfig.GetString("ScopeID", string.Empty); | ||
116 | if (scope != string.Empty) | ||
117 | UUID.TryParse(scope, out m_ScopeID); | ||
118 | |||
119 | m_HypergridConnector = new HypergridServiceConnector(m_AssetService); | ||
120 | |||
121 | m_log.DebugFormat("[HYPERGRID SERVICE]: Loaded all services..."); | ||
122 | } | ||
123 | |||
124 | if (m_RootInstance == null) | ||
125 | { | ||
126 | m_RootInstance = this; | ||
127 | |||
128 | HGCommands hgCommands = new HGCommands(this); | ||
129 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", | ||
130 | "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>", | ||
131 | "Link a hypergrid region", hgCommands.RunCommand); | ||
132 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", | ||
133 | "unlink-region <local name> or <HostName>:<HttpPort> <cr>", | ||
134 | "Unlink a hypergrid region", hgCommands.RunCommand); | ||
135 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>", | ||
136 | "Set local coordinate to map HG regions to", hgCommands.RunCommand); | ||
137 | MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks <cr>", | ||
138 | "List the HG regions", hgCommands.HandleShow); | ||
139 | } | ||
140 | } | ||
141 | |||
142 | #region Link Region | ||
143 | |||
144 | public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason) | ||
145 | { | ||
146 | regionID = UUID.Zero; | ||
147 | imageURL = string.Empty; | ||
148 | regionHandle = 0; | ||
149 | reason = string.Empty; | ||
150 | int xloc = random.Next(0, Int16.MaxValue) * (int)Constants.RegionSize; | ||
151 | GridRegion region = TryLinkRegionToCoords(regionDescriptor, xloc, 0, out reason); | ||
152 | if (region == null) | ||
153 | return false; | ||
154 | |||
155 | regionID = region.RegionID; | ||
156 | regionHandle = region.RegionHandle; | ||
157 | return true; | ||
158 | } | ||
159 | |||
160 | private static Random random = new Random(); | ||
161 | |||
162 | // From the command line link-region | ||
163 | public GridRegion TryLinkRegionToCoords(string mapName, int xloc, int yloc, out string reason) | ||
164 | { | ||
165 | reason = string.Empty; | ||
166 | string host = "127.0.0.1"; | ||
167 | string portstr; | ||
168 | string regionName = ""; | ||
169 | uint port = 9000; | ||
170 | string[] parts = mapName.Split(new char[] { ':' }); | ||
171 | if (parts.Length >= 1) | ||
172 | { | ||
173 | host = parts[0]; | ||
174 | } | ||
175 | if (parts.Length >= 2) | ||
176 | { | ||
177 | portstr = parts[1]; | ||
178 | //m_log.Debug("-- port = " + portstr); | ||
179 | if (!UInt32.TryParse(portstr, out port)) | ||
180 | regionName = parts[1]; | ||
181 | } | ||
182 | // always take the last one | ||
183 | if (parts.Length >= 3) | ||
184 | { | ||
185 | regionName = parts[2]; | ||
186 | } | ||
187 | |||
188 | // Sanity check. Don't ever link to this sim. | ||
189 | IPAddress ipaddr = null; | ||
190 | try | ||
191 | { | ||
192 | ipaddr = Util.GetHostFromDNS(host); | ||
193 | } | ||
194 | catch { } | ||
195 | |||
196 | GridRegion regInfo; | ||
197 | bool success = TryCreateLink(xloc, yloc, regionName, port, host, out regInfo, out reason); | ||
198 | if (success) | ||
199 | { | ||
200 | regInfo.RegionName = mapName; | ||
201 | return regInfo; | ||
202 | } | ||
203 | |||
204 | return null; | ||
205 | } | ||
206 | |||
207 | |||
208 | // From the command line and the 2 above | ||
209 | public bool TryCreateLink(int xloc, int yloc, | ||
210 | string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo, out string reason) | ||
211 | { | ||
212 | m_log.DebugFormat("[HYPERGRID SERVICE]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); | ||
213 | |||
214 | reason = string.Empty; | ||
215 | regInfo = new GridRegion(); | ||
216 | regInfo.RegionName = externalRegionName; | ||
217 | regInfo.HttpPort = externalPort; | ||
218 | regInfo.ExternalHostName = externalHostName; | ||
219 | regInfo.RegionLocX = xloc; | ||
220 | regInfo.RegionLocY = yloc; | ||
221 | |||
222 | try | ||
223 | { | ||
224 | regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); | ||
225 | } | ||
226 | catch (Exception e) | ||
227 | { | ||
228 | m_log.Warn("[HYPERGRID SERVICE]: Wrong format for link-region: " + e.Message); | ||
229 | reason = "Internal error"; | ||
230 | return false; | ||
231 | } | ||
232 | |||
233 | // Finally, link it | ||
234 | ulong handle = 0; | ||
235 | UUID regionID = UUID.Zero; | ||
236 | string imageURL = string.Empty; | ||
237 | if (!m_HypergridConnector.LinkRegion(regInfo, out regionID, out handle, out imageURL, out reason)) | ||
238 | return false; | ||
239 | |||
240 | if (regionID != UUID.Zero) | ||
241 | { | ||
242 | regInfo.RegionID = regionID; | ||
243 | |||
244 | AddHyperlinkRegion(regInfo, handle); | ||
245 | m_log.Info("[HYPERGRID SERVICE]: Successfully linked to region_uuid " + regInfo.RegionID); | ||
246 | |||
247 | // Try get the map image | ||
248 | regInfo.TerrainImage = m_HypergridConnector.GetMapImage(regionID, imageURL); | ||
249 | } | ||
250 | else | ||
251 | { | ||
252 | m_log.Warn("[HYPERGRID SERVICE]: Unable to link region"); | ||
253 | reason = "Remote region could not be found"; | ||
254 | return false; | ||
255 | } | ||
256 | |||
257 | uint x, y; | ||
258 | if (!Check4096(regInfo, out x, out y)) | ||
259 | { | ||
260 | RemoveHyperlinkRegion(regInfo.RegionID); | ||
261 | reason = "Region is too far (" + x + ", " + y + ")"; | ||
262 | m_log.Info("[HYPERGRID SERVICE]: Unable to link, region is too far (" + x + ", " + y + ")"); | ||
263 | return false; | ||
264 | } | ||
265 | |||
266 | m_log.Debug("[HYPERGRID SERVICE]: link region succeeded"); | ||
267 | return true; | ||
268 | } | ||
269 | |||
270 | public bool TryUnlinkRegion(string mapName) | ||
271 | { | ||
272 | GridRegion regInfo = null; | ||
273 | if (mapName.Contains(":")) | ||
274 | { | ||
275 | string host = "127.0.0.1"; | ||
276 | //string portstr; | ||
277 | //string regionName = ""; | ||
278 | uint port = 9000; | ||
279 | string[] parts = mapName.Split(new char[] { ':' }); | ||
280 | if (parts.Length >= 1) | ||
281 | { | ||
282 | host = parts[0]; | ||
283 | } | ||
284 | |||
285 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
286 | if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) | ||
287 | regInfo = r; | ||
288 | } | ||
289 | else | ||
290 | { | ||
291 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
292 | if (r.RegionName.Equals(mapName)) | ||
293 | regInfo = r; | ||
294 | } | ||
295 | if (regInfo != null) | ||
296 | { | ||
297 | RemoveHyperlinkRegion(regInfo.RegionID); | ||
298 | return true; | ||
299 | } | ||
300 | else | ||
301 | { | ||
302 | m_log.InfoFormat("[HYPERGRID SERVICE]: Region {0} not found", mapName); | ||
303 | return false; | ||
304 | } | ||
305 | } | ||
306 | |||
307 | /// <summary> | ||
308 | /// Cope with this viewer limitation. | ||
309 | /// </summary> | ||
310 | /// <param name="regInfo"></param> | ||
311 | /// <returns></returns> | ||
312 | public bool Check4096(GridRegion regInfo, out uint x, out uint y) | ||
313 | { | ||
314 | GridRegion defRegion = DefaultRegion; | ||
315 | |||
316 | ulong realHandle = m_HyperlinkHandles[regInfo.RegionID]; | ||
317 | uint ux = 0, uy = 0; | ||
318 | Utils.LongToUInts(realHandle, out ux, out uy); | ||
319 | x = ux / Constants.RegionSize; | ||
320 | y = uy / Constants.RegionSize; | ||
321 | |||
322 | if ((Math.Abs((int)defRegion.RegionLocX - ux) >= 4096 * Constants.RegionSize) || | ||
323 | (Math.Abs((int)defRegion.RegionLocY - uy) >= 4096 * Constants.RegionSize)) | ||
324 | { | ||
325 | return false; | ||
326 | } | ||
327 | return true; | ||
328 | } | ||
329 | |||
330 | private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) | ||
331 | { | ||
332 | m_HyperlinkRegions[regionInfo.RegionID] = regionInfo; | ||
333 | m_HyperlinkHandles[regionInfo.RegionID] = regionHandle; | ||
334 | } | ||
335 | |||
336 | private void RemoveHyperlinkRegion(UUID regionID) | ||
337 | { | ||
338 | // Try the hyperlink collection | ||
339 | if (m_HyperlinkRegions.ContainsKey(regionID)) | ||
340 | { | ||
341 | m_HyperlinkRegions.Remove(regionID); | ||
342 | m_HyperlinkHandles.Remove(regionID); | ||
343 | } | ||
344 | } | ||
345 | |||
346 | #endregion | ||
347 | |||
348 | #region Get Hyperlinks | ||
349 | |||
350 | public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) | ||
351 | { | ||
352 | if (m_HyperlinkRegions.ContainsKey(regionID)) | ||
353 | return m_HypergridConnector.GetHyperlinkRegion(gatekeeper, regionID); | ||
354 | else | ||
355 | return gatekeeper; | ||
356 | } | ||
357 | |||
358 | #endregion | ||
359 | |||
360 | #region GetRegionBy X | ||
361 | |||
362 | public GridRegion GetRegionByUUID(UUID regionID) | ||
363 | { | ||
364 | if (m_HyperlinkRegions.ContainsKey(regionID)) | ||
365 | return m_HyperlinkRegions[regionID]; | ||
366 | |||
367 | return null; | ||
368 | } | ||
369 | |||
370 | public GridRegion GetRegionByPosition(int x, int y) | ||
371 | { | ||
372 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
373 | if (r.RegionLocX == x && r.RegionLocY == y) | ||
374 | return r; | ||
375 | |||
376 | return null; | ||
377 | } | ||
378 | |||
379 | public GridRegion GetRegionByName(string name) | ||
380 | { | ||
381 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
382 | if (r.RegionName.ToLower() == name.ToLower()) | ||
383 | return r; | ||
384 | |||
385 | return null; | ||
386 | } | ||
387 | |||
388 | public List<GridRegion> GetRegionsByName(string name) | ||
389 | { | ||
390 | List<GridRegion> regions = new List<GridRegion>(); | ||
391 | |||
392 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
393 | if ((r.RegionName != null) && r.RegionName.ToLower().StartsWith(name.ToLower())) | ||
394 | regions.Add(r); | ||
395 | |||
396 | return regions; | ||
397 | |||
398 | } | ||
399 | |||
400 | public List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax) | ||
401 | { | ||
402 | List<GridRegion> regions = new List<GridRegion>(); | ||
403 | |||
404 | foreach (GridRegion r in m_HyperlinkRegions.Values) | ||
405 | if ((r.RegionLocX > xmin) && (r.RegionLocX < xmax) && | ||
406 | (r.RegionLocY > ymin) && (r.RegionLocY < ymax)) | ||
407 | regions.Add(r); | ||
408 | |||
409 | return regions; | ||
410 | } | ||
411 | |||
412 | #endregion | ||
413 | |||
414 | |||
415 | |||
416 | } | ||
417 | } | ||
diff --git a/OpenSim/Services/HypergridService/HypergridServiceBase.cs b/OpenSim/Services/HypergridService/HypergridServiceBase.cs deleted file mode 100644 index 4f91f64..0000000 --- a/OpenSim/Services/HypergridService/HypergridServiceBase.cs +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | using OpenSim.Services.Base; | ||
35 | |||
36 | namespace OpenSim.Services.HypergridService | ||
37 | { | ||
38 | public class HypergridServiceBase : ServiceBase | ||
39 | { | ||
40 | protected IRegionData m_Database = null; | ||
41 | |||
42 | public HypergridServiceBase(IConfigSource config) | ||
43 | : base(config) | ||
44 | { | ||
45 | string dllName = String.Empty; | ||
46 | string connString = String.Empty; | ||
47 | string realm = "TBD"; | ||
48 | |||
49 | // | ||
50 | // Try reading the [DatabaseService] section, if it exists | ||
51 | // | ||
52 | IConfig dbConfig = config.Configs["DatabaseService"]; | ||
53 | if (dbConfig != null) | ||
54 | { | ||
55 | if (dllName == String.Empty) | ||
56 | dllName = dbConfig.GetString("StorageProvider", String.Empty); | ||
57 | if (connString == String.Empty) | ||
58 | connString = dbConfig.GetString("ConnectionString", String.Empty); | ||
59 | } | ||
60 | |||
61 | // | ||
62 | // [HypergridService] section overrides [DatabaseService], if it exists | ||
63 | // | ||
64 | IConfig gridConfig = config.Configs["HypergridService"]; | ||
65 | if (gridConfig != null) | ||
66 | { | ||
67 | dllName = gridConfig.GetString("StorageProvider", dllName); | ||
68 | connString = gridConfig.GetString("ConnectionString", connString); | ||
69 | realm = gridConfig.GetString("Realm", realm); | ||
70 | } | ||
71 | |||
72 | //// | ||
73 | //// We tried, but this doesn't exist. We can't proceed. | ||
74 | //// | ||
75 | //if (dllName.Equals(String.Empty)) | ||
76 | // throw new Exception("No StorageProvider configured"); | ||
77 | |||
78 | //m_Database = LoadPlugin<IRegionData>(dllName, new Object[] { connString, realm }); | ||
79 | //if (m_Database == null) | ||
80 | // throw new Exception("Could not find a storage interface in the given module"); | ||
81 | |||
82 | } | ||
83 | } | ||
84 | } | ||
diff --git a/OpenSim/Services/Interfaces/IHypergridService.cs b/OpenSim/Services/Interfaces/IHypergridService.cs deleted file mode 100644 index 86ef1b4..0000000 --- a/OpenSim/Services/Interfaces/IHypergridService.cs +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections.Generic; | ||
29 | using OpenSim.Framework; | ||
30 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
31 | |||
32 | using OpenMetaverse; | ||
33 | |||
34 | namespace OpenSim.Services.Interfaces | ||
35 | { | ||
36 | public interface IHypergridService | ||
37 | { | ||
38 | bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason); | ||
39 | GridRegion GetHyperlinkRegion(GridRegion gateway, UUID regionID); | ||
40 | |||
41 | GridRegion GetRegionByUUID(UUID regionID); | ||
42 | GridRegion GetRegionByPosition(int x, int y); | ||
43 | GridRegion GetRegionByName(string name); | ||
44 | List<GridRegion> GetRegionsByName(string name); | ||
45 | List<GridRegion> GetRegionRange(int xmin, int xmax, int ymin, int ymax); | ||
46 | |||
47 | } | ||
48 | |||
49 | } | ||