From 5a10da3ee89934e366c1d69833b81605dbc35017 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 3 May 2014 17:13:53 -0700 Subject: Added a optional key between the group remote connectors, sim and service. This allows for more secure group services, to be used by collections of mutually-trusting grids. --- .../Groups/Remote/GroupsServiceRemoteConnector.cs | 8 +++-- .../Remote/GroupsServiceRemoteConnectorModule.cs | 3 +- .../Groups/Remote/GroupsServiceRobustConnector.cs | 38 ++++++++++++++++++++-- bin/OpenSim.ini.example | 4 +++ 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs index 67402a2..1425a23 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs @@ -44,15 +44,17 @@ namespace OpenSim.Groups private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string m_ServerURI; + private string m_SecretKey; private object m_Lock = new object(); - public GroupsServiceRemoteConnector(string url) + public GroupsServiceRemoteConnector(string url, string secret) { m_ServerURI = url; if (!m_ServerURI.EndsWith("/")) m_ServerURI += "/"; - m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}", m_ServerURI); + m_SecretKey = secret; + m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, secret key {1}", m_ServerURI, m_SecretKey); } public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, @@ -654,6 +656,8 @@ namespace OpenSim.Groups private Dictionary MakeRequest(string method, Dictionary sendData) { sendData["METHOD"] = method; + if (m_SecretKey != string.Empty) + sendData["KEY"] = m_SecretKey; string reply = string.Empty; lock (m_Lock) diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs index d3de0e8..5fb3c19 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs @@ -77,7 +77,8 @@ namespace OpenSim.Groups if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url)); - m_GroupsService = new GroupsServiceRemoteConnector(url); + string secret = groupsConfig.GetString("SecretKey", string.Empty); + m_GroupsService = new GroupsServiceRemoteConnector(url, secret); m_Scenes = new List(); } diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs index 616afa9..828965f 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs @@ -52,14 +52,24 @@ namespace OpenSim.Groups public GroupsServiceRobustConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) { + string key = string.Empty; if (configName != String.Empty) m_ConfigName = configName; m_log.DebugFormat("[Groups.RobustConnector]: Starting with config name {0}", m_ConfigName); + IConfig groupsConfig = config.Configs[m_ConfigName]; + if (groupsConfig != null) + { + key = groupsConfig.GetString("SecretKey", string.Empty); + m_log.DebugFormat("[Groups.RobustConnector]: Starting with secret key {0}", key); + } + else + m_log.WarnFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName); + m_GroupsService = new GroupsService(config); - server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService)); + server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, key)); } } @@ -68,11 +78,13 @@ namespace OpenSim.Groups private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private GroupsService m_GroupsService; + private string m_SecretKey = String.Empty; - public GroupsServicePostHandler(GroupsService service) : + public GroupsServicePostHandler(GroupsService service, string key) : base("POST", "/groups") { m_GroupsService = service; + m_SecretKey = key; } protected override byte[] ProcessRequest(string path, Stream requestData, @@ -96,6 +108,20 @@ namespace OpenSim.Groups string method = request["METHOD"].ToString(); request.Remove("METHOD"); + if (!String.IsNullOrEmpty(m_SecretKey)) // Verification required + { + // Sender didn't send key + if (!request.ContainsKey("KEY") || (request["KEY"] == null)) + return FailureResult("This service requires a secret key"); + + // Sender sent wrong key + if (!m_SecretKey.Equals(request["KEY"])) + return FailureResult("Provided key does not match existing one"); + + // OK, key matches. Remove it. + request.Remove("KEY"); + } + m_log.DebugFormat("[Groups.Handler]: {0}", method); switch (method) { @@ -784,6 +810,14 @@ namespace OpenSim.Groups string xmlString = ServerUtils.BuildXmlResponse(result); return Util.UTF8NoBomEncoding.GetBytes(xmlString); } + + private byte[] FailureResult(string reason) + { + Dictionary result = new Dictionary(); + NullResult(result, reason); + string xmlString = ServerUtils.BuildXmlResponse(result); + return Util.UTF8NoBomEncoding.GetBytes(xmlString); + } #endregion } } diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 1395d72..8742313 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -996,6 +996,10 @@ ;; Used for V2 in HG only. If standalone, set this to local; if grided sim, set this to remote ; LocalService = local + ;# {SecretKey} {ServicesConnectorModule:Groups Remote Service Connector} {Secret key between sim and remote group service} {} "" + ;; Used for V2 in Remote only. + ; SecretKey = "" + ;# {GroupsServerURI} {Module:GroupsModule (ServicesConnectorModule:Groups Remote Service Connector or (ServicesConnectorModule:Groups HG Service Connector and LocalService:remote))} {Groups Server URI} {} ;; URI for the groups services of this grid ;; e.g. http://yourxmlrpcserver.com/xmlrpc.php for Flotsam XmlRpc -- cgit v1.1 From 7f570636f8056ec24dd7f28207af62b44a8811ba Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 4 May 2014 11:41:52 -0700 Subject: Please note: older simulators (0.7.6) still send the info about gzip in ContentType --- OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 0d7f259..06392f7 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -243,7 +243,7 @@ namespace OpenSim.Server.Handlers.Simulation } Stream inputStream = request; - if ((httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) + if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) inputStream = new GZipStream(inputStream, CompressionMode.Decompress); StreamReader reader = new StreamReader(inputStream, encoding); @@ -454,7 +454,7 @@ namespace OpenSim.Server.Handlers.Simulation keysvals.Add("querystringkeys", querystringkeys); Stream inputStream = request; - if ((httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) + if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) inputStream = new GZipStream(inputStream, CompressionMode.Decompress); Encoding encoding = Encoding.UTF8; -- cgit v1.1 From 7862d1e20dc8c405e594d888722d90178f0cd9f7 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Wed, 30 Apr 2014 08:48:05 +0300 Subject: Added range-checking for the parameters to PRIM_POINT_LIGHT (used in llSetLinkPrimitiveParamsFast() ) --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 4d20e13..0e6b24a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1884,9 +1884,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.Shape.LightColorR = Util.Clip((float)color.x, 0.0f, 1.0f); part.Shape.LightColorG = Util.Clip((float)color.y, 0.0f, 1.0f); part.Shape.LightColorB = Util.Clip((float)color.z, 0.0f, 1.0f); - part.Shape.LightIntensity = intensity; - part.Shape.LightRadius = radius; - part.Shape.LightFalloff = falloff; + part.Shape.LightIntensity = Util.Clip((float)intensity, 0.0f, 1.0f); + part.Shape.LightRadius = Util.Clip((float)radius, 0.1f, 20.0f); + part.Shape.LightFalloff = Util.Clip((float)falloff, 0.01f, 2.0f); } else { -- cgit v1.1 From 0fe08c8799b1a3a2d5a07c206c2f9680d1c0798e Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 4 May 2014 13:36:36 +0300 Subject: - When sending the "My Suitcase" folder to the client, always claim it has Folder Type 8. (Previously we had used Folder Type -1 in one place, and LLClientView didn't even bother changing Folder Type 100 to anything else.) --- OpenSim/Framework/InventoryItemBase.cs | 4 ++++ OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 5 ++++- .../HypergridService/HGSuitcaseInventoryService.cs | 14 +++++++------- OpenSim/Services/InventoryService/XInventoryService.cs | 4 ++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs index 5761200..ce63ee0 100644 --- a/OpenSim/Framework/InventoryItemBase.cs +++ b/OpenSim/Framework/InventoryItemBase.cs @@ -35,6 +35,10 @@ namespace OpenSim.Framework /// public class InventoryItemBase : InventoryNodeBase, ICloneable { + public static readonly string SUITCASE_FOLDER_NAME = "My Suitcase"; + public static readonly sbyte SUITCASE_FOLDER_TYPE = 100; + public static readonly sbyte SUITCASE_FOLDER_FAKE_TYPE = 8; + /// /// The inventory type of the item. This is slightly different from the asset type in some situations. /// diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 7cb5b53..53217a0 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -1761,6 +1761,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP newBlock.Name = Util.StringToBytes256(folder.Name); newBlock.ParentID = folder.ParentID; newBlock.Type = (sbyte)folder.Type; + if (newBlock.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE) + newBlock.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE; return newBlock; } @@ -2010,8 +2012,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP folderBlock.FolderID = folder.ID; folderBlock.ParentID = folder.ParentID; - //folderBlock.Type = -1; folderBlock.Type = (sbyte)folder.Type; + if (folderBlock.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE) + folderBlock.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE; folderBlock.Name = Util.StringToBytes256(folder.Name); return folderBlock; diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index 8269d36..df797a5 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs @@ -156,9 +156,9 @@ namespace OpenSim.Services.HypergridService if (suitcase == null) { m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder. Creating it...", principalID); - // make one, and let's add it to the user's inventory as a direct child of the root folder - // In the DB we tag it as type 100, but we use -1 (Unknown) outside - suitcase = CreateFolder(principalID, root.folderID, 100, "My Suitcase"); + // Create the My Suitcase folder under the user's root folder. + // In the DB we tag it as type 100, but we use type 8 (Folder) outside, as this affects the sort order. + suitcase = CreateFolder(principalID, root.folderID, InventoryItemBase.SUITCASE_FOLDER_TYPE, InventoryItemBase.SUITCASE_FOLDER_NAME); if (suitcase == null) { m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder"); @@ -464,7 +464,7 @@ namespace OpenSim.Services.HypergridService // Warp! Root folder for travelers XInventoryFolder[] folders = m_Database.GetFolders( new string[] { "agentID", "type" }, - new string[] { principalID.ToString(), "100" }); // This is a special folder type... + new string[] { principalID.ToString(), InventoryItemBase.SUITCASE_FOLDER_TYPE.ToString() }); // This is a special folder type... if (folders != null && folders.Length > 0) return folders[0]; @@ -472,13 +472,13 @@ namespace OpenSim.Services.HypergridService // check to see if we have the old Suitcase folder folders = m_Database.GetFolders( new string[] { "agentID", "folderName", "parentFolderID" }, - new string[] { principalID.ToString(), "My Suitcase", UUID.Zero.ToString() }); + new string[] { principalID.ToString(), InventoryItemBase.SUITCASE_FOLDER_NAME, UUID.Zero.ToString() }); if (folders != null && folders.Length > 0) { // Move it to under the root folder XInventoryFolder root = GetRootXFolder(principalID); folders[0].parentFolderID = root.folderID; - folders[0].type = 100; + folders[0].type = InventoryItemBase.SUITCASE_FOLDER_TYPE; m_Database.StoreFolder(folders[0]); return folders[0]; } @@ -488,7 +488,7 @@ namespace OpenSim.Services.HypergridService private void SetAsNormalFolder(XInventoryFolder suitcase) { - suitcase.type = (short)AssetType.Folder; + suitcase.type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE; } private List GetFolderTree(UUID principalID, UUID folder) diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 3bee433..7c16ca9 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -631,8 +631,8 @@ namespace OpenSim.Services.InventoryService newFolder.ParentID = folder.parentFolderID; newFolder.Type = (short)folder.type; // Viewer can't understand anything that's not in it's LLFolderType enum - if (newFolder.Type == 100) - newFolder.Type = -1; + if (newFolder.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE) + newFolder.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE; newFolder.Version = (ushort)folder.version; newFolder.Name = folder.folderName; newFolder.Owner = folder.agentID; -- cgit v1.1 From df49196e17bae9a1472085402094718ba6997b1e Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 5 May 2014 10:20:04 +0300 Subject: Log whenever an inventory operation is blocked because the item/folder isn't in the Suitcase --- .../HypergridService/HGSuitcaseInventoryService.cs | 60 +++++++++++++++++++--- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index df797a5..3de2330 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs @@ -248,7 +248,10 @@ namespace OpenSim.Services.HypergridService InventoryCollection coll = null; if (!IsWithinSuitcaseTree(principalID, folderID)) + { + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent: folder {0} is not within Suitcase tree", folderID); return new InventoryCollection(); + } coll = base.GetFolderContent(principalID, folderID); @@ -265,7 +268,10 @@ namespace OpenSim.Services.HypergridService // Let's do a bit of sanity checking, more than the base service does // make sure the given folder exists under the suitcase tree of this user if (!IsWithinSuitcaseTree(principalID, folderID)) + { + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderItems: folder {0} is not within Suitcase tree", folderID); return new List(); + } return base.GetFolderItems(principalID, folderID); } @@ -277,7 +283,10 @@ namespace OpenSim.Services.HypergridService // make sure the given folder's parent folder exists under the suitcase tree of this user if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) + { + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder: folder {0} is not within Suitcase tree", folder.ParentID); return false; + } // OK, it's legit if (base.AddFolder(folder)) @@ -297,7 +306,7 @@ namespace OpenSim.Services.HypergridService //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); if (!IsWithinSuitcaseTree(folder.Owner, folder.ID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateFolder: folder {0}/{1} is not within Suitcase tree", folder.Name, folder.ID); return false; } @@ -307,9 +316,17 @@ namespace OpenSim.Services.HypergridService public override bool MoveFolder(InventoryFolderBase folder) { - if (!IsWithinSuitcaseTree(folder.Owner, folder.ID) || - !IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) + if (!IsWithinSuitcaseTree(folder.Owner, folder.ID)) + { + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} is not within Suitcase tree", folder.ID); return false; + } + + if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) + { + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} is not within Suitcase tree", folder.ParentID); + return false; + } return base.MoveFolder(folder); } @@ -331,7 +348,10 @@ namespace OpenSim.Services.HypergridService // Let's do a bit of sanity checking, more than the base service does // make sure the given folder's parent folder exists under the suitcase tree of this user if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) + { + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddItem: folder {0} is not within Suitcase tree", item.Folder); return false; + } // OK, it's legit return base.AddItem(item); @@ -341,7 +361,10 @@ namespace OpenSim.Services.HypergridService public override bool UpdateItem(InventoryItemBase item) { if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) + { + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateItem: folder {0} is not within Suitcase tree", item.Folder); return false; + } return base.UpdateItem(item); } @@ -350,11 +373,28 @@ namespace OpenSim.Services.HypergridService { // Principal is b0rked. *sigh* - if (!IsWithinSuitcaseTree(items[0].Owner, items[0].Folder)) - return false; + // Check the items' destination folders + foreach (InventoryItemBase item in items) + { + if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) + { + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} is not within Suitcase tree", item.Folder); + return false; + } + } - return base.MoveItems(principalID, items); + // Check the items' current folders + foreach (InventoryItemBase item in items) + { + InventoryItemBase originalItem = base.GetItem(item); + if (!IsWithinSuitcaseTree(originalItem.Owner, originalItem.Folder)) + { + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} is not within Suitcase tree", originalItem.Folder); + return false; + } + } + return base.MoveItems(principalID, items); } public override bool DeleteItems(UUID principalID, List itemIDs) @@ -374,8 +414,8 @@ namespace OpenSim.Services.HypergridService if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID)) { - m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", - it.Name, it.Folder); + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0}/{1} (folder {2}) is not within Suitcase tree or Appearance", + it.Name, it.ID, it.Folder); return null; } @@ -396,7 +436,11 @@ namespace OpenSim.Services.HypergridService if (f != null) { if (!IsWithinSuitcaseTree(f.Owner, f.ID)) + { + m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Folder {0}/{1} is not within Suitcase tree", + f.Name, f.ID); return null; + } } return f; -- cgit v1.1 From 1e5cff32fc41356971d6ad601cbee7ad62472c76 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 5 May 2014 11:06:49 +0300 Subject: Show more meaningful error messages when failed to give an item to another user --- OpenSim/Addons/Groups/GroupsModule.cs | 5 +-- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 18 +++++++--- .../Inventory/Transfer/InventoryTransferModule.cs | 11 +++--- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 39 ++++++++++++++++------ .../Framework/Scenes/Tests/UserInventoryTests.cs | 10 +++--- .../Avatar/XmlRpcGroups/GroupsModule.cs | 5 +-- 6 files changed, 59 insertions(+), 29 deletions(-) diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs index f11606a..2831326 100644 --- a/OpenSim/Addons/Groups/GroupsModule.cs +++ b/OpenSim/Addons/Groups/GroupsModule.cs @@ -496,12 +496,13 @@ namespace OpenSim.Groups Util.ParseUniversalUserIdentifier(notice.noticeData.AttachmentOwnerID, out giver, out tmp, out tmp, out tmp, out tmp); m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId); + string message; InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId, - giver, notice.noticeData.AttachmentItemID); + giver, notice.noticeData.AttachmentItemID, out message); if (itemCopy == null) { - remoteClient.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); + remoteClient.SendAgentAlertMessage(message, false); return; } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 79bc5ef..0eb15f8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -865,18 +865,26 @@ namespace OpenSim.Region.ClientStack.Linden item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID)); if (item != null) { - copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID); - if (copyItem != null && client != null) + string message; + copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID, out message); + if (client != null) { - m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder); - client.SendBulkUpdateInventory(copyItem); + if (copyItem != null) + { + m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder); + client.SendBulkUpdateInventory(copyItem); + } + else + { + client.SendAgentAlertMessage(message, false); + } } } else { m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID); if (client != null) - client.SendAlertMessage("Failed to retrieve item"); + client.SendAgentAlertMessage("Failed to retrieve item", false); } } catch (Exception e) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 0b10dd8..c632798 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -180,8 +180,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer "[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory", folderID, new UUID(im.toAgentID)); - InventoryFolderBase folderCopy - = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); + InventoryFolderBase folderCopy + = scene.GiveInventoryFolder(client, receipientID, client.AgentId, folderID, UUID.Zero); if (folderCopy == null) { @@ -217,13 +217,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer "into agent {1}'s inventory", itemID, new UUID(im.toAgentID)); - InventoryItemBase itemCopy = scene.GiveInventoryItem( - new UUID(im.toAgentID), - client.AgentId, itemID); + string message; + InventoryItemBase itemCopy = scene.GiveInventoryItem(new UUID(im.toAgentID), client.AgentId, itemID, out message); if (itemCopy == null) { - client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); + client.SendAgentAlertMessage(message, false); return; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index bb9f457..27cd5c6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -46,7 +46,7 @@ namespace OpenSim.Region.Framework.Scenes { public partial class Scene { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly string LogHeader = "[SCENE INVENTORY]"; /// @@ -534,9 +534,9 @@ namespace OpenSim.Region.Framework.Scenes /// /// ID of the sender of the item /// - public virtual void GiveInventoryItem(IClientAPI recipientClient, UUID senderId, UUID itemId) + public virtual void GiveInventoryItem(IClientAPI recipientClient, UUID senderId, UUID itemId, out string message) { - InventoryItemBase itemCopy = GiveInventoryItem(recipientClient.AgentId, senderId, itemId); + InventoryItemBase itemCopy = GiveInventoryItem(recipientClient.AgentId, senderId, itemId, out message); if (itemCopy != null) recipientClient.SendBulkUpdateInventory(itemCopy); @@ -549,9 +549,9 @@ namespace OpenSim.Region.Framework.Scenes /// ID of the sender of the item /// /// The inventory item copy given, null if the give was unsuccessful - public virtual InventoryItemBase GiveInventoryItem(UUID recipient, UUID senderId, UUID itemId) + public virtual InventoryItemBase GiveInventoryItem(UUID recipient, UUID senderId, UUID itemId, out string message) { - return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero); + return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero, out message); } /// @@ -568,12 +568,15 @@ namespace OpenSim.Region.Framework.Scenes /// The inventory item copy given, null if the give was unsuccessful /// public virtual InventoryItemBase GiveInventoryItem( - UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId) + UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId, out string message) { //Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem"); if (!Permissions.CanTransferUserInventory(itemId, senderId, recipient)) + { + message = "Not allowed to transfer this item."; return null; + } InventoryItemBase item = new InventoryItemBase(itemId, senderId); item = InventoryService.GetItem(item); @@ -582,6 +585,7 @@ namespace OpenSim.Region.Framework.Scenes { m_log.WarnFormat( "[AGENT INVENTORY]: Failed to find item {0} sent by {1} to {2}", itemId, senderId, recipient); + message = string.Format("Item not found: {0}.", itemId); return null; } @@ -590,6 +594,7 @@ namespace OpenSim.Region.Framework.Scenes m_log.WarnFormat( "[AGENT INVENTORY]: Attempt to send item {0} {1} to {2} failed because sender {3} did not match item owner {4}", item.Name, item.ID, recipient, senderId, item.Owner); + message = "Sender did not match item owner."; return null; } @@ -600,7 +605,10 @@ namespace OpenSim.Region.Framework.Scenes if (!Permissions.BypassPermissions()) { if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) + { + message = "Item doesn't have the Transfer permission."; return null; + } } // Insert a copy of the item into the recipient @@ -736,9 +744,14 @@ namespace OpenSim.Region.Framework.Scenes InventoryFolderBase root = InventoryService.GetRootFolder(recipient); if (root != null) + { itemCopy.Folder = root.ID; + } else - return null; // No destination + { + message = "Can't find a folder to add the item to."; + return null; + } } } @@ -763,6 +776,7 @@ namespace OpenSim.Region.Framework.Scenes } } + message = null; return itemCopy; } @@ -780,7 +794,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// The inventory folder copy given, null if the copy was unsuccessful /// - public virtual InventoryFolderBase GiveInventoryFolder( + public virtual InventoryFolderBase GiveInventoryFolder(IClientAPI client, UUID recipientId, UUID senderId, UUID folderId, UUID recipientParentFolderId) { //// Retrieve the folder from the sender @@ -815,13 +829,18 @@ namespace OpenSim.Region.Framework.Scenes InventoryCollection contents = InventoryService.GetFolderContent(senderId, folderId); foreach (InventoryFolderBase childFolder in contents.Folders) { - GiveInventoryFolder(recipientId, senderId, childFolder.ID, newFolder.ID); + GiveInventoryFolder(client, recipientId, senderId, childFolder.ID, newFolder.ID); } // Give all the items foreach (InventoryItemBase item in contents.Items) { - GiveInventoryItem(recipientId, senderId, item.ID, newFolder.ID); + string message; + if (GiveInventoryItem(recipientId, senderId, item.ID, newFolder.ID, out message) == null) + { + if (client != null) + client.SendAgentAlertMessage(message, false); + } } return newFolder; diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs index e50b4da..0736278 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs @@ -95,7 +95,9 @@ namespace OpenSim.Region.Framework.Tests UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); - scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID); + string message; + + scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID, out message); InventoryItemBase retrievedItem1 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1"); @@ -103,7 +105,7 @@ namespace OpenSim.Region.Framework.Tests Assert.That(retrievedItem1, Is.Not.Null); // Try giving back the freshly received item - scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID); + scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID, out message); List reretrievedItems = UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1"); @@ -123,7 +125,7 @@ namespace OpenSim.Region.Framework.Tests InventoryFolderBase folder1 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1", false); - scene.GiveInventoryFolder(user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero); + scene.GiveInventoryFolder(null, user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero); InventoryFolderBase retrievedFolder1 = UserInventoryHelpers.GetInventoryFolder(scene.InventoryService, user2.PrincipalID, "folder1"); @@ -131,7 +133,7 @@ namespace OpenSim.Region.Framework.Tests Assert.That(retrievedFolder1, Is.Not.Null); // Try giving back the freshly received folder - scene.GiveInventoryFolder(user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero); + scene.GiveInventoryFolder(null, user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero); List reretrievedFolders = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, "folder1"); diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index fc8cae2..f34152c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs @@ -560,12 +560,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups if (m_debugEnabled) m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId); + string message; InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId, - giver, attachmentUUID); + giver, attachmentUUID, out message); if (itemCopy == null) { - remoteClient.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); + remoteClient.SendAgentAlertMessage(message, false); return; } -- cgit v1.1 From eb79c882eab090ee5ee51cadac7bd1dc2e5ddb9f Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 5 May 2014 15:59:24 +0300 Subject: Show more meaningful error messages when failed to move an item from a prim to a user's inventory. Also, actually show the error to the user in more cases. (Previously, sometimes the operation failed without telling the user anything.) --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 64 ++++++++++++++-------- .../Framework/Scenes/Tests/TaskInventoryTests.cs | 6 +- .../Shared/Api/Implementation/LSL_Api.cs | 6 +- .../Shared/Api/Implementation/OSSL_Api.cs | 9 +-- 4 files changed, 56 insertions(+), 29 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 27cd5c6..4988868 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1167,11 +1167,19 @@ namespace OpenSim.Region.Framework.Scenes InventoryFolderBase destFolder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder); - // Move the item to trash. If this is a copiable item, only + // Move the item to trash. If this is a copyable item, only // a copy will be moved and we will still need to delete - // the item from the prim. If it was no copy, is will be + // the item from the prim. If it was no copy, it will be // deleted by this method. - MoveTaskInventoryItem(remoteClient, destFolder.ID, part, itemID); + string message; + InventoryItemBase item2 = MoveTaskInventoryItem(remoteClient, destFolder.ID, part, itemID, out message); + + if (item2 == null) + { + m_log.WarnFormat("[SCENE INVENTORY]: RemoveTaskInventory of item {0} failed: {1}", itemID, message); + remoteClient.SendAgentAlertMessage(message, false); + return; + } if (group.GetInventoryItem(localID, itemID) != null) { @@ -1183,11 +1191,12 @@ namespace OpenSim.Region.Framework.Scenes group.RemoveInventoryItem(localID, itemID); } + part.SendPropertiesToClient(remoteClient); } } - private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) + private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId, out string message) { TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId); @@ -1198,12 +1207,13 @@ namespace OpenSim.Region.Framework.Scenes + " inventory item from a prim's inventory item " + " but the required item does not exist in the prim's inventory", itemId, part.Name, part.UUID); - + message = "Item not found: " + itemId; return null; } if ((destAgent != taskItem.OwnerID) && ((taskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) { + message = "Item doesn't have the Transfer permission."; return null; } @@ -1263,6 +1273,7 @@ namespace OpenSim.Region.Framework.Scenes } } + message = null; return agentItem; } @@ -1273,19 +1284,19 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public InventoryItemBase MoveTaskInventoryItem(IClientAPI remoteClient, UUID folderId, SceneObjectPart part, UUID itemId) + public InventoryItemBase MoveTaskInventoryItem(IClientAPI remoteClient, UUID folderId, SceneObjectPart part, UUID itemId, out string message) { m_log.DebugFormat( "[PRIM INVENTORY]: Adding item {0} from {1} to folder {2} for {3}", itemId, part.Name, folderId, remoteClient.Name); - InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(remoteClient.AgentId, part, itemId); - + InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(remoteClient.AgentId, part, itemId, out message); if (agentItem == null) return null; agentItem.Folder = folderId; AddInventoryItem(remoteClient, agentItem); + message = null; return agentItem; } @@ -1336,7 +1347,11 @@ namespace OpenSim.Region.Framework.Scenes return; } - MoveTaskInventoryItem(remoteClient, folderId, part, itemId); + string message; + InventoryItemBase item = MoveTaskInventoryItem(remoteClient, folderId, part, itemId, out message); + + if (item == null) + remoteClient.SendAgentAlertMessage(message, false); } /// @@ -1350,17 +1365,17 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public InventoryItemBase MoveTaskInventoryItem(UUID avatarId, UUID folderId, SceneObjectPart part, UUID itemId) + public InventoryItemBase MoveTaskInventoryItem(UUID avatarId, UUID folderId, SceneObjectPart part, UUID itemId, out string message) { ScenePresence avatar; if (TryGetScenePresence(avatarId, out avatar)) { - return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); + return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId, out message); } else { - InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(avatarId, part, itemId); + InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(avatarId, part, itemId, out message); if (agentItem == null) return null; @@ -1474,6 +1489,11 @@ namespace OpenSim.Region.Framework.Scenes public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List items) { + ScenePresence avatar; + IClientAPI remoteClient = null; + if (TryGetScenePresence(destID, out avatar)) + remoteClient = avatar.ControllingClient; + InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); UUID newFolderID = UUID.Random(); @@ -1483,7 +1503,8 @@ namespace OpenSim.Region.Framework.Scenes foreach (UUID itemID in items) { - InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(destID, host, itemID); + string message; + InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(destID, host, itemID, out message); if (agentItem != null) { @@ -1491,18 +1512,17 @@ namespace OpenSim.Region.Framework.Scenes AddInventoryItem(agentItem); } + else + { + if (remoteClient != null) + remoteClient.SendAgentAlertMessage(message, false); + } } - ScenePresence avatar = null; - if (TryGetScenePresence(destID, out avatar)) + if (remoteClient != null) { - //profile.SendInventoryDecendents(avatar.ControllingClient, - // profile.RootFolder.ID, true, false); - //profile.SendInventoryDecendents(avatar.ControllingClient, - // newFolderID, false, true); - - SendInventoryUpdate(avatar.ControllingClient, rootFolder, true, false); - SendInventoryUpdate(avatar.ControllingClient, newFolder, false, true); + SendInventoryUpdate(remoteClient, rootFolder, true, false); + SendInventoryUpdate(remoteClient, newFolder, false, true); } return newFolderID; diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 6e0ea7d..f809267 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -136,7 +136,8 @@ namespace OpenSim.Region.Framework.Tests = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; // Perform test - scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID); + string message; + scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID, out message); InventoryItemBase ncUserItem = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Objects/ncItem"); @@ -165,7 +166,8 @@ namespace OpenSim.Region.Framework.Tests scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); // Perform test - scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); + string message; + scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID, out message); InventoryItemBase ncUserItem = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Notecards/ncItem"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0e6b24a..d169912 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4127,10 +4127,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } // destination is an avatar - InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); + string message; + InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId, out message); if (agentItem == null) + { + llSay(0, message); return; + } if (m_TransferModule != null) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 6302455..de2c3f7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -3397,14 +3397,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (sp == null) return; - InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID); + string message; + InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID, out message); if (newItem == null) { m_log.ErrorFormat( - "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}", - itemName, m_host.Name, attachmentPoint, World.Name); - + "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}: {4}", + itemName, m_host.Name, attachmentPoint, World.Name, message); + ((LSL_Api)m_LSL_Api).llSay(0, message); return; } -- cgit v1.1 From 614b9e14c42d69bf8048218c889cc047756b0b5a Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 5 May 2014 16:09:51 +0300 Subject: When moving an item from a prim to a user's inventory, don't delete the item from the prim until it was successfully copied to the user --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 4988868..91f1b63 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1196,6 +1196,10 @@ namespace OpenSim.Region.Framework.Scenes } } + + /// + /// Creates (in memory only) a user inventory item that will contain a copy of a task inventory item. + /// private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId, out string message) { TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId); @@ -1259,11 +1263,24 @@ namespace OpenSim.Region.Framework.Scenes agentItem.GroupPermissions = taskItem.GroupPermissions; } + message = null; + return agentItem; + } + + /// + /// If the task item is not-copyable then remove it from the prim. + /// + private void RemoveNonCopyTaskItemFromPrim(SceneObjectPart part, UUID itemId) + { + TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId); + if (taskItem == null) + return; + if (!Permissions.BypassPermissions()) { if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) { - if (taskItem.Type == 10) + if (taskItem.Type == (int)AssetType.LSLText) { part.RemoveScriptEvents(itemId); EventManager.TriggerRemoveScript(part.LocalId, itemId); @@ -1272,9 +1289,6 @@ namespace OpenSim.Region.Framework.Scenes part.Inventory.RemoveInventoryItem(itemId); } } - - message = null; - return agentItem; } /// @@ -1296,6 +1310,9 @@ namespace OpenSim.Region.Framework.Scenes agentItem.Folder = folderId; AddInventoryItem(remoteClient, agentItem); + + RemoveNonCopyTaskItemFromPrim(part, itemId); + message = null; return agentItem; } @@ -1384,6 +1401,8 @@ namespace OpenSim.Region.Framework.Scenes AddInventoryItem(agentItem); + RemoveNonCopyTaskItemFromPrim(part, itemId); + return agentItem; } } @@ -1511,6 +1530,8 @@ namespace OpenSim.Region.Framework.Scenes agentItem.Folder = newFolderID; AddInventoryItem(agentItem); + + RemoveNonCopyTaskItemFromPrim(host, itemID); } else { -- cgit v1.1 From ef262799ca2795cabf9e2f63e29698872e0c9414 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 6 May 2014 09:43:07 +0300 Subject: Better error handling in AssetServerPostHandler. Invalid XML causes an InvalidOperationException, not an XmlException --- OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs index 5122a77..a77e67d 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs @@ -64,7 +64,7 @@ namespace OpenSim.Server.Handlers.Asset { asset = (AssetBase)xs.Deserialize(request); } - catch (XmlException) + catch (Exception) { httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; return null; -- cgit v1.1