From 107052b23db4d16c8d1d5f8c828da7d6f6afd6b4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 4 Sep 2010 00:09:53 +0100 Subject: Create Scene.Inventory.cs.AddInventoryItem(InventoryItemBase item) The agentID in AddInventoryItem(UUID agentID, InventoryItemBase item) is redundant since it's contained in item.Owner, and it doesn't make sense for agentID != item.Owner, hence the method is deprecated. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 35 +++++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 0674e62..7cedde0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -92,25 +92,44 @@ namespace OpenSim.Region.Framework.Scenes } } - public void AddInventoryItem(UUID AgentID, InventoryItemBase item) + /// + /// Add the given inventory item to a user's inventory. + /// + /// + public void AddInventoryItem(InventoryItemBase item) { if (InventoryService.AddItem(item)) { int userlevel = 0; - if (Permissions.IsGod(AgentID)) + if (Permissions.IsGod(item.Owner)) { userlevel = 1; } - EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel); + EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); } else { m_log.WarnFormat( "[AGENT INVENTORY]: Agent {0} could not add item {1} {2}", - AgentID, item.Name, item.ID); + item.Owner, item.Name, item.ID); return; - } + } + } + + /// + /// Add the given inventory item to a user's inventory. + /// + /// + /// A + /// + /// + /// A + /// + [Obsolete("Use AddInventoryItem(InventoryItemBase item) instead. This was deprecated in OpenSim 0.7.1")] + public void AddInventoryItem(UUID AgentID, InventoryItemBase item) + { + AddInventoryItem(item); } /// @@ -121,7 +140,7 @@ namespace OpenSim.Region.Framework.Scenes /// in which the item is to be placed. public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) { - AddInventoryItem(remoteClient.AgentId, item); + AddInventoryItem(item); remoteClient.SendInventoryItemCreateUpdate(item, 0); } @@ -1108,7 +1127,7 @@ namespace OpenSim.Region.Framework.Scenes agentItem.Folder = folderId; - AddInventoryItem(avatarId, agentItem); + AddInventoryItem(agentItem); return agentItem; } @@ -1232,7 +1251,7 @@ namespace OpenSim.Region.Framework.Scenes { agentItem.Folder = newFolderID; - AddInventoryItem(destID, agentItem); + AddInventoryItem(agentItem); } } -- cgit v1.1 From 1e8e98a07fdad6cff4be780083b3d9ad2360b8e7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 4 Sep 2010 01:36:26 +0100 Subject: Move code that allows llGiveInvetory() to move item into appropriate system folder up from connectors into Scene.Inventory.cs This fixes the problem for all architectures (hg as well as local and grid) and means we don't have to dupe code between connectors. Not ideal in that it becomes non-modular, but methods in Scene.Inventory.cs should eventually be modularized anyway. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 48 ++++++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 7cedde0..4e871d9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -70,18 +70,18 @@ namespace OpenSim.Region.Framework.Scenes public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) { - IMoneyModule money=RequestModuleInterface(); + IMoneyModule money = RequestModuleInterface(); if (money != null) { money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload"); } - AddInventoryItem(agentID, item); + AddInventoryItem(item); } public bool AddInventoryItemReturned(UUID AgentId, InventoryItemBase item) { - if (InventoryService.AddItem(item)) + if (AddInventoryItem(item)) return true; else { @@ -96,8 +96,36 @@ namespace OpenSim.Region.Framework.Scenes /// Add the given inventory item to a user's inventory. /// /// - public void AddInventoryItem(InventoryItemBase item) + public bool AddInventoryItem(InventoryItemBase item) { + if (UUID.Zero == item.Folder) + { + InventoryFolderBase f = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); + if (f != null) + { +// m_log.DebugFormat( +// "[LOCAL INVENTORY SERVICES CONNECTOR]: Found folder {0} type {1} for item {2}", +// f.Name, (AssetType)f.Type, item.Name); + + item.Folder = f.ID; + } + else + { + f = InventoryService.GetRootFolder(item.Owner); + if (f != null) + { + item.Folder = f.ID; + } + else + { + m_log.WarnFormat( + "[AGENT INVENTORY]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified", + item.Owner, item.Name); + return false; + } + } + } + if (InventoryService.AddItem(item)) { int userlevel = 0; @@ -106,6 +134,8 @@ namespace OpenSim.Region.Framework.Scenes userlevel = 1; } EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); + + return true; } else { @@ -113,7 +143,7 @@ namespace OpenSim.Region.Framework.Scenes "[AGENT INVENTORY]: Agent {0} could not add item {1} {2}", item.Owner, item.Name, item.ID); - return; + return false; } } @@ -538,7 +568,7 @@ namespace OpenSim.Region.Framework.Scenes itemCopy.SalePrice = item.SalePrice; itemCopy.SaleType = item.SaleType; - if (InventoryService.AddItem(itemCopy)) + if (AddInventoryItem(itemCopy)) { IInventoryAccessModule invAccess = RequestModuleInterface(); if (invAccess != null) @@ -764,8 +794,10 @@ namespace OpenSim.Region.Framework.Scenes item.BasePermissions = baseMask; item.CreationDate = creationDate; - if (InventoryService.AddItem(item)) + if (AddInventoryItem(item)) + { remoteClient.SendInventoryItemCreateUpdate(item, callbackID); + } else { m_dialogModule.SendAlertToUser(remoteClient, "Failed to create item"); @@ -1886,7 +1918,7 @@ namespace OpenSim.Region.Framework.Scenes // sets itemID so client can show item as 'attached' in inventory grp.SetFromItemID(item.ID); - if (InventoryService.AddItem(item)) + if (AddInventoryItem(item)) remoteClient.SendInventoryItemCreateUpdate(item, 0); else m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); -- cgit v1.1 From 68f107b27e37df88618993b8234316288782d15e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 4 Sep 2010 18:46:27 -0700 Subject: Logout the presence if client IP verification fails. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 56ac2c2..49f29ad 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2643,6 +2643,8 @@ namespace OpenSim.Region.Framework.Scenes try { ScenePresence sp = GetScenePresence(agentID); + PresenceService.LogoutAgent(sp.ControllingClient.SessionId); + if (sp != null) sp.ControllingClient.Close(); -- cgit v1.1