aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorMarck2010-12-13 21:19:33 +0100
committerMarck2010-12-13 21:20:48 +0100
commit9a24c0b41c786f49766c212c656f8162e4c263ef (patch)
treed10e0ee6fa7398d79a937426218c7a6ee80e6aa7 /OpenSim/Services
parentIt turns out that the 1/2 sec burst for prims download is not a bug, but a fe... (diff)
downloadopensim-SC_OLD-9a24c0b41c786f49766c212c656f8162e4c263ef.zip
opensim-SC_OLD-9a24c0b41c786f49766c212c656f8162e4c263ef.tar.gz
opensim-SC_OLD-9a24c0b41c786f49766c212c656f8162e4c263ef.tar.bz2
opensim-SC_OLD-9a24c0b41c786f49766c212c656f8162e4c263ef.tar.xz
Show map tile for hyperlinks. Perform Check4096 before adding a hyperlink.
Configuration option AssetService in section [GridService] must be set to enable this functionality. Map tiles do currently not show for hyperlinks set in simulators that are connected to grids, see Mantis #5270.
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs29
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs76
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs29
3 files changed, 70 insertions, 64 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index 85c1380..d4fd1b8 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Drawing; 31using System.Drawing;
32using System.IO;
32using System.Net; 33using System.Net;
33using System.Reflection; 34using System.Reflection;
34using OpenSim.Framework; 35using OpenSim.Framework;
@@ -48,7 +49,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
48 { 49 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 51
51// private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); 52 private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013");
52 53
53 private IAssetService m_AssetService; 54 private IAssetService m_AssetService;
54 55
@@ -143,24 +144,25 @@ namespace OpenSim.Services.Connectors.Hypergrid
143 return true; 144 return true;
144 } 145 }
145 146
146 UUID m_MissingTexture = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); 147 public UUID GetMapImage(UUID regionID, string imageURL, string storagePath)
147
148 public UUID GetMapImage(UUID regionID, string imageURL)
149 { 148 {
150 if (m_AssetService == null) 149 if (m_AssetService == null)
151 return m_MissingTexture; 150 return m_HGMapImage;
152 151
152 UUID mapTile = m_HGMapImage;
153 string filename = string.Empty;
154 Bitmap bitmap = null;
153 try 155 try
154 { 156 {
155
156 WebClient c = new WebClient(); 157 WebClient c = new WebClient();
157 //m_log.Debug("JPEG: " + imageURL); 158 //m_log.Debug("JPEG: " + imageURL);
158 string filename = regionID.ToString(); 159 string name = regionID.ToString();
159 c.DownloadFile(imageURL, filename + ".jpg"); 160 filename = Path.Combine(storagePath, name + ".jpg");
160 Bitmap m = new Bitmap(filename + ".jpg"); 161 c.DownloadFile(imageURL, filename);
162 bitmap = new Bitmap(filename);
161 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); 163 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
162 byte[] imageData = OpenJPEG.EncodeFromImage(m, true); 164 byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true);
163 AssetBase ass = new AssetBase(UUID.Random(), "region " + filename, (sbyte)AssetType.Texture, regionID.ToString()); 165 AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString());
164 166
165 // !!! for now 167 // !!! for now
166 //info.RegionSettings.TerrainImageID = ass.FullID; 168 //info.RegionSettings.TerrainImageID = ass.FullID;
@@ -172,14 +174,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
172 m_AssetService.Store(ass); 174 m_AssetService.Store(ass);
173 175
174 // finally 176 // finally
175 return ass.FullID; 177 mapTile = ass.FullID;
176
177 } 178 }
178 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke 179 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
179 { 180 {
180 m_log.Warn("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); 181 m_log.Warn("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache");
181 } 182 }
182 return UUID.Zero; 183 return mapTile;
183 } 184 }
184 185
185 public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) 186 public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID)
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index 9863ba0..643d0fc 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO;
31using System.Linq; 32using System.Linq;
32using System.Net; 33using System.Net;
33using System.Reflection; 34using System.Reflection;
@@ -52,8 +53,6 @@ namespace OpenSim.Services.GridService
52 LogManager.GetLogger( 53 LogManager.GetLogger(
53 MethodBase.GetCurrentMethod().DeclaringType); 54 MethodBase.GetCurrentMethod().DeclaringType);
54 55
55 private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013");
56
57 private static uint m_autoMappingX = 0; 56 private static uint m_autoMappingX = 0;
58 private static uint m_autoMappingY = 0; 57 private static uint m_autoMappingY = 0;
59 private static bool m_enableAutoMapping = false; 58 private static bool m_enableAutoMapping = false;
@@ -65,6 +64,7 @@ namespace OpenSim.Services.GridService
65 64
66 protected UUID m_ScopeID = UUID.Zero; 65 protected UUID m_ScopeID = UUID.Zero;
67 protected bool m_Check4096 = true; 66 protected bool m_Check4096 = true;
67 protected string m_MapTileDirectory = string.Empty;
68 68
69 // Hyperlink regions are hyperlinks on the map 69 // Hyperlink regions are hyperlinks on the map
70 public readonly Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>(); 70 public readonly Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
@@ -121,9 +121,24 @@ namespace OpenSim.Services.GridService
121 121
122 m_Check4096 = gridConfig.GetBoolean("Check4096", true); 122 m_Check4096 = gridConfig.GetBoolean("Check4096", true);
123 123
124 m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", string.Empty);
125
124 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); 126 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);
125 127
126 m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services..."); 128 m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");
129 }
130
131 if (!string.IsNullOrEmpty(m_MapTileDirectory))
132 {
133 try
134 {
135 Directory.CreateDirectory(m_MapTileDirectory);
136 }
137 catch (Exception e)
138 {
139 m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e);
140 m_MapTileDirectory = string.Empty;
141 }
127 } 142 }
128 143
129 if (MainConsole.Instance != null) 144 if (MainConsole.Instance != null)
@@ -271,42 +286,22 @@ namespace OpenSim.Services.GridService
271 if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason)) 286 if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason))
272 return false; 287 return false;
273 288
274 if (regionID != UUID.Zero) 289 if (regionID == UUID.Zero)
275 {
276 region = m_GridService.GetRegionByUUID(scopeID, regionID);
277 if (region != null)
278 {
279 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}",
280 region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize);
281 regInfo = region;
282 return true;
283 }
284
285 regInfo.RegionID = regionID;
286
287 if ( externalName == string.Empty )
288 regInfo.RegionName = regInfo.ServerURI;
289 else
290 regInfo.RegionName = externalName;
291
292 m_log.Debug("[HYPERGRID LINKER]: naming linked region " + regInfo.RegionName);
293
294 // Try get the map image
295 //regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL);
296 // I need a texture that works for this... the one I tried doesn't seem to be working
297 regInfo.TerrainImage = m_HGMapImage;
298
299 AddHyperlinkRegion(regInfo, handle);
300 m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID);
301
302 }
303 else
304 { 290 {
305 m_log.Warn("[HYPERGRID LINKER]: Unable to link region"); 291 m_log.Warn("[HYPERGRID LINKER]: Unable to link region");
306 reason = "Remote region could not be found"; 292 reason = "Remote region could not be found";
307 return false; 293 return false;
308 } 294 }
309 295
296 region = m_GridService.GetRegionByUUID(scopeID, regionID);
297 if (region != null)
298 {
299 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}",
300 region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize);
301 regInfo = region;
302 return true;
303 }
304
310 uint x, y; 305 uint x, y;
311 if (m_Check4096 && !Check4096(handle, out x, out y)) 306 if (m_Check4096 && !Check4096(handle, out x, out y))
312 { 307 {
@@ -316,7 +311,20 @@ namespace OpenSim.Services.GridService
316 return false; 311 return false;
317 } 312 }
318 313
319 m_log.Debug("[HYPERGRID LINKER]: link region succeeded"); 314 regInfo.RegionID = regionID;
315
316 if ( externalName == string.Empty )
317 regInfo.RegionName = regInfo.ServerURI;
318 else
319 regInfo.RegionName = externalName;
320
321 m_log.Debug("[HYPERGRID LINKER]: naming linked region " + regInfo.RegionName);
322
323 // Get the map image
324 regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL, m_MapTileDirectory);
325
326 AddHyperlinkRegion(regInfo, handle);
327 m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID);
320 return true; 328 return true;
321 } 329 }
322 330
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 05be7b8..4419201 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -123,42 +123,39 @@ namespace OpenSim.Services.HypergridService
123 externalName = m_ExternalName + ((regionName != string.Empty) ? " " + regionName : ""); 123 externalName = m_ExternalName + ((regionName != string.Empty) ? " " + regionName : "");
124 imageURL = string.Empty; 124 imageURL = string.Empty;
125 reason = string.Empty; 125 reason = string.Empty;
126 126 GridRegion region = null;
127 127
128 m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to link to {0}", (regionName == string.Empty)? "default region" : regionName); 128 m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to link to {0}", (regionName == string.Empty)? "default region" : regionName);
129 if (!m_AllowTeleportsToAnyRegion || regionName == string.Empty) 129 if (!m_AllowTeleportsToAnyRegion || regionName == string.Empty)
130 { 130 {
131 List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID); 131 List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID);
132 if (defs != null && defs.Count > 0) 132 if (defs != null && defs.Count > 0)
133 m_DefaultGatewayRegion = defs[0];
134
135 try
136 { 133 {
137 regionID = m_DefaultGatewayRegion.RegionID; 134 region = defs[0];
138 regionHandle = m_DefaultGatewayRegion.RegionHandle; 135 m_DefaultGatewayRegion = region;
139 } 136 }
140 catch 137 else
141 { 138 {
142 reason = "Grid setup problem. Try specifying a particular region here."; 139 reason = "Grid setup problem. Try specifying a particular region here.";
143 m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to send information. Please specify a default region for this grid!"); 140 m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to send information. Please specify a default region for this grid!");
144 return false; 141 return false;
145 } 142 }
146
147 return true;
148 } 143 }
149 144 else
150 GridRegion region = m_GridService.GetRegionByName(m_ScopeID, regionName);
151 if (region == null)
152 { 145 {
153 reason = "Region not found"; 146 region = m_GridService.GetRegionByName(m_ScopeID, regionName);
154 return false; 147 if (region == null)
148 {
149 reason = "Region not found";
150 return false;
151 }
155 } 152 }
156 153
157 regionID = region.RegionID; 154 regionID = region.RegionID;
158 regionHandle = region.RegionHandle; 155 regionHandle = region.RegionHandle;
159 string regionimage = "regionImage" + region.RegionID.ToString();
160 regionimage = regionimage.Replace("-", "");
161 156
157 string regionimage = "regionImage" + regionID.ToString();
158 regionimage = regionimage.Replace("-", "");
162 imageURL = region.ServerURI + "index.php?method=" + regionimage; 159 imageURL = region.ServerURI + "index.php?method=" + regionimage;
163 160
164 return true; 161 return true;