aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLatif Khalifa2014-07-04 13:48:00 +0200
committerJustin Clark-Casey2014-08-02 00:52:07 +0100
commit45e280274ca476fcad0d806f350043eb873d7eea (patch)
treef69cc5d3b9d625552194e183f2e5f37f7bc7a1a1
parentStill log (but this time with warning rather than an exception) if we regener... (diff)
downloadopensim-SC_OLD-45e280274ca476fcad0d806f350043eb873d7eea.zip
opensim-SC_OLD-45e280274ca476fcad0d806f350043eb873d7eea.tar.gz
opensim-SC_OLD-45e280274ca476fcad0d806f350043eb873d7eea.tar.bz2
opensim-SC_OLD-45e280274ca476fcad0d806f350043eb873d7eea.tar.xz
When uploading mesh objects with textures also create inventory items for uploaded textures.
This implements: http://opensimulator.org/mantis/view.php?id=7250
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs63
1 files changed, 63 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index 0eb15f8..1d7938b 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -44,6 +44,7 @@ using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Serialization; 44using OpenSim.Region.Framework.Scenes.Serialization;
45using OpenSim.Framework.Servers; 45using OpenSim.Framework.Servers;
46using OpenSim.Framework.Servers.HttpServer; 46using OpenSim.Framework.Servers.HttpServer;
47using OpenSim.Framework.Client;
47using OpenSim.Services.Interfaces; 48using OpenSim.Services.Interfaces;
48 49
49using Caps = OpenSim.Framework.Capabilities.Caps; 50using Caps = OpenSim.Framework.Capabilities.Caps;
@@ -536,6 +537,39 @@ namespace OpenSim.Region.ClientStack.Linden
536 OSDArray texture_list = (OSDArray)request["texture_list"]; 537 OSDArray texture_list = (OSDArray)request["texture_list"];
537 SceneObjectGroup grp = null; 538 SceneObjectGroup grp = null;
538 539
540 InventoryFolderBase textureUploadFolder = null;
541
542 List<InventoryFolderBase> foldersToUpdate = new List<InventoryFolderBase>();
543 List<InventoryItemBase> itemsToUpdate = new List<InventoryItemBase>();
544 IClientInventory clientInv = null;
545
546 if (texture_list.Count > 0)
547 {
548 ScenePresence avatar = null;
549 IClientAPI client = null;
550 m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar);
551
552 if (avatar != null)
553 {
554 IClientCore core = (IClientCore)avatar.ControllingClient;
555
556 if (core.TryGet<IClientInventory>(out clientInv))
557 {
558 var systemTextureFolder = m_Scene.InventoryService.GetFolderForType(m_HostCapsObj.AgentID, AssetType.Texture);
559 textureUploadFolder = new InventoryFolderBase(UUID.Random(), assetName, m_HostCapsObj.AgentID, (short)AssetType.Unknown, systemTextureFolder.ID, 1);
560 if (m_Scene.InventoryService.AddFolder(textureUploadFolder))
561 {
562 foldersToUpdate.Add(textureUploadFolder);
563 m_log.DebugFormat("Created new folder '{0}' ({1}) for textures uploaded with mesh object {2}", textureUploadFolder.Name, textureUploadFolder.ID, assetName);
564 }
565 else
566 {
567 textureUploadFolder = null;
568 }
569 }
570 }
571 }
572
539 List<UUID> textures = new List<UUID>(); 573 List<UUID> textures = new List<UUID>();
540 for (int i = 0; i < texture_list.Count; i++) 574 for (int i = 0; i < texture_list.Count; i++)
541 { 575 {
@@ -543,6 +577,35 @@ namespace OpenSim.Region.ClientStack.Linden
543 textureAsset.Data = texture_list[i].AsBinary(); 577 textureAsset.Data = texture_list[i].AsBinary();
544 m_assetService.Store(textureAsset); 578 m_assetService.Store(textureAsset);
545 textures.Add(textureAsset.FullID); 579 textures.Add(textureAsset.FullID);
580
581 if (textureUploadFolder != null)
582 {
583 InventoryItemBase textureItem = new InventoryItemBase();
584 textureItem.Owner = m_HostCapsObj.AgentID;
585 textureItem.CreatorId = m_HostCapsObj.AgentID.ToString();
586 textureItem.CreatorData = String.Empty;
587 textureItem.ID = UUID.Random();
588 textureItem.AssetID = textureAsset.FullID;
589 textureItem.Description = assetDescription;
590 textureItem.Name = assetName + " - Texture " + (i + 1).ToString();
591 textureItem.AssetType = (int)AssetType.Texture;
592 textureItem.InvType = (int)InventoryType.Texture;
593 textureItem.Folder = textureUploadFolder.ID;
594 textureItem.CurrentPermissions
595 = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Export);
596 textureItem.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export;
597 textureItem.EveryOnePermissions = 0;
598 textureItem.NextPermissions = (uint)PermissionMask.All;
599 textureItem.CreationDate = Util.UnixTimeSinceEpoch();
600 m_Scene.InventoryService.AddItem(textureItem);
601 itemsToUpdate.Add(textureItem);
602 m_log.DebugFormat("Created new inventory item '{0}' ({1}) for texture uploaded with mesh object {2}", textureItem.Name, textureItem.ID, assetName);
603 }
604 }
605
606 if (clientInv != null && (foldersToUpdate.Count > 0 || itemsToUpdate.Count > 0))
607 {
608 clientInv.SendBulkUpdateInventory(foldersToUpdate.ToArray(), itemsToUpdate.ToArray());
546 } 609 }
547 610
548 for (int i = 0; i < mesh_list.Count; i++) 611 for (int i = 0; i < mesh_list.Count; i++)