From 3525195bc9b5fdfd9799411edd452981ef1f4ebd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 11 Jun 2010 21:52:43 +0100 Subject: Allow IInventoryService.GetFolder(folderId, userId) as well as GetFolder(InventoryFolderBase folder) This involves no wire changes since the methods often just construct an InventoryFolderBase under the hood. This is in line with other methods that alraedy allow requests via uuid --- .../Inventory/QuickAndDirtyInventoryServiceConnector.cs | 5 +++++ .../Connectors/Inventory/XInventoryConnector.cs | 5 +++++ .../SimianGrid/SimianInventoryServiceConnector.cs | 7 ++++++- OpenSim/Services/Interfaces/IInventoryService.cs | 8 ++++++++ OpenSim/Services/InventoryService/InventoryService.cs | 17 +++++++++++------ OpenSim/Services/InventoryService/XInventoryService.cs | 5 +++++ 6 files changed, 40 insertions(+), 7 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs index a7aa138..5a23687 100644 --- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs @@ -171,6 +171,11 @@ namespace OpenSim.Services.Connectors { return null; } + + public InventoryFolderBase GetFolder(UUID folderId, UUID userId) + { + return null; + } public InventoryFolderBase GetFolder(InventoryFolderBase folder) { diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs index e25e7eb..e7acb59 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs @@ -431,6 +431,11 @@ namespace OpenSim.Services.Connectors return null; } + public InventoryFolderBase GetFolder(UUID folderId, UUID userId) + { + return GetFolder(new InventoryFolderBase(folderId, userId)); + } + public InventoryFolderBase GetFolder(InventoryFolderBase folder) { try diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs index dc68259..6bf43d5 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -314,6 +314,11 @@ namespace OpenSim.Services.Connectors.SimianGrid m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Item " + item.ID + " owned by " + item.Owner + " not found"); return null; } + + public InventoryFolderBase GetFolder(UUID folderId, UUID userId) + { + return GetFolder(new InventoryFolderBase(folderId, userId)); + } /// /// Get a folder, given by its UUID diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs index 1b78fb3..b0ffd8f 100644 --- a/OpenSim/Services/Interfaces/IInventoryService.cs +++ b/OpenSim/Services/Interfaces/IInventoryService.cs @@ -170,6 +170,14 @@ namespace OpenSim.Services.Interfaces InventoryItemBase GetItem(InventoryItemBase item); /// + /// Get a folder. + /// + /// + /// + /// + InventoryFolderBase GetFolder(UUID folderId, UUID userId); + + /// /// Get a folder, given by its UUID /// /// diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs index fbcd663..9f1c4a4 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs @@ -439,15 +439,20 @@ namespace OpenSim.Services.InventoryService m_log.DebugFormat("[INVENTORY SERVICE]: GetItem failed to find item {0}", item.ID); return null; } - - public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder) - { - InventoryFolderBase result = m_Database.getInventoryFolder(folder.ID); + + public virtual InventoryFolderBase GetFolder(UUID folderId, UUID userId) + { + InventoryFolderBase result = m_Database.getInventoryFolder(folderId); if (result != null) return result; - m_log.DebugFormat("[INVENTORY SERVICE]: GetFolder failed to find folder {0}", folder.ID); - return null; + m_log.DebugFormat("[INVENTORY SERVICE]: GetFolder failed to find folder {0}", folderId); + return null; + } + + public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder) + { + return GetFolder(folder.ID, folder.Owner); } public virtual bool DeleteFolders(UUID ownerID, List folderIDs) diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index af831fd..00aadc5 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -368,6 +368,11 @@ namespace OpenSim.Services.InventoryService return ConvertToOpenSim(items[0]); } + + public virtual InventoryFolderBase GetFolder(UUID folderId, UUID userId) + { + return GetFolder(new InventoryFolderBase(folderId, userId)); + } public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder) { -- cgit v1.1 From d1a324888be2a0db247999928dff12d0bb62cddd Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 11 Jun 2010 15:37:25 -0700 Subject: * Added a new method to IMapImageGenerator for getting the map tile before it is JPEG2000 compressed * Aesthetically improved map tile water * SimianGrid connector now uploads a PNG tile to the AddMapTile API --- .../SimianGrid/SimianGridServiceConnector.cs | 84 +++++++++++++++++++++- 1 file changed, 81 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs index 3a61226..cc8080f 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs @@ -28,17 +28,18 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; using System.Net; using System.Reflection; using log4net; using Mono.Addins; using Nini.Config; using OpenSim.Framework; -using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; -using OpenSim.Server.Base; using OpenMetaverse; using OpenMetaverse.StructuredData; @@ -62,7 +63,7 @@ namespace OpenSim.Services.Connectors.SimianGrid #region ISharedRegionModule public Type ReplaceableInterface { get { return null; } } - public void RegionLoaded(Scene scene) { } + public void RegionLoaded(Scene scene) { UploadMapTile(scene); } public void PostInitialise() { } public void Close() { } @@ -356,6 +357,83 @@ namespace OpenSim.Services.Connectors.SimianGrid #endregion IGridService + private void UploadMapTile(IScene scene) + { + string errorMessage = null; + + // Create a PNG map tile and upload it to the AddMapTile API + byte[] pngData = Utils.EmptyBytes; + IMapImageGenerator tileGenerator = scene.RequestModuleInterface(); + if (tileGenerator == null) + { + m_log.Warn("[SIMIAN GRID CONNECTOR]: Cannot upload PNG map tile without an IMapImageGenerator"); + return; + } + + using (Image mapTile = tileGenerator.CreateMapTile("defaultstripe.png")) + { + using (MemoryStream stream = new MemoryStream()) + { + mapTile.Save(stream, ImageFormat.Png); + pngData = stream.ToArray(); + } + } + + List postParameters = new List() + { + new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()), + new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()), + new MultipartForm.File("Tile", "tile.png", "image/png", pngData) + }; + + // Make the remote storage request + try + { + HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl); + + HttpWebResponse response = MultipartForm.Post(request, postParameters); + using (Stream responseStream = response.GetResponseStream()) + { + string responseStr = null; + + try + { + responseStr = responseStream.GetStreamString(); + OSD responseOSD = OSDParser.Deserialize(responseStr); + if (responseOSD.Type == OSDType.Map) + { + OSDMap responseMap = (OSDMap)responseOSD; + if (responseMap["Success"].AsBoolean()) + m_log.Info("[SIMIAN GRID CONNECTOR]: Uploaded " + pngData.Length + " byte PNG map tile to AddMapTile"); + else + errorMessage = "Upload failed: " + responseMap["Message"].AsString(); + } + else + { + errorMessage = "Response format was invalid:\n" + responseStr; + } + } + catch (Exception ex) + { + if (!String.IsNullOrEmpty(responseStr)) + errorMessage = "Failed to parse the response:\n" + responseStr; + else + errorMessage = "Failed to retrieve the response: " + ex.Message; + } + } + } + catch (WebException ex) + { + errorMessage = ex.Message; + } + + if (!String.IsNullOrEmpty(errorMessage)) + { + m_log.WarnFormat("[SIMIAN GRID CONNECTOR]: Failed to store {0} byte PNG map tile for {1}: {2}", + pngData.Length, scene.RegionInfo.RegionName, errorMessage); + } + } + private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled) { NameValueCollection requestArgs = new NameValueCollection -- cgit v1.1 From ed38b4a140d8a7d184ede1b53b97180505928270 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 12 Jun 2010 00:32:54 +0100 Subject: Some people don't use Simian. Make the connector respect that it's disabled and not try to send a map tile in that case. --- OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs index cc8080f..db9027a 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs @@ -63,7 +63,7 @@ namespace OpenSim.Services.Connectors.SimianGrid #region ISharedRegionModule public Type ReplaceableInterface { get { return null; } } - public void RegionLoaded(Scene scene) { UploadMapTile(scene); } + public void RegionLoaded(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { UploadMapTile(scene); } } public void PostInitialise() { } public void Close() { } -- cgit v1.1