From 181a90967ee9084676f84e74b2393855218c5723 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 14 Aug 2007 17:29:15 +0000 Subject: Start of inventory items, when you upload a texture the data will now be stored in the inventory database and you will still have that texture in inventory on later logins (Again only in standalone mode with authentication.) Also there might be some problems if you upload textures in other regions to the start one (due to us not updating the CAPS url properly). --- .../Communications/Cache/AssetTransactions.cs | 4 +- .../Communications/Cache/CachedUserInfo.cs | 21 ++++++++++- .../Communications/Cache/UserProfileCache.cs | 2 +- .../Framework/Communications/Capabilities/Caps.cs | 43 ++++++++++++++++++---- .../Framework/Communications/IInventoryServices.cs | 1 + 5 files changed, 60 insertions(+), 11 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index c906b76..e12d234 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -128,7 +128,7 @@ namespace OpenSim.Framework.Communications.Caches } if (this.OnUpLoad != null) { - this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data); + this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data); } return text; } @@ -266,7 +266,7 @@ namespace OpenSim.Framework.Communications.Caches } if (this.OnUpLoad != null) { - this.OnUpLoad(this.m_assetName, this.newAssetID, inventoryItemID, data); + this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data); } return text; } diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index fc2f948..123e692 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -40,10 +40,16 @@ namespace OpenSim.Framework.Communications.Caches { public class CachedUserInfo { + private CommunicationsManager m_parentCommsManager; // Fields public InventoryFolder RootFolder = null; public UserProfileData UserProfile = null; + public CachedUserInfo(CommunicationsManager commsManager) + { + m_parentCommsManager = commsManager; + } + // Methods public void FolderReceive(LLUUID userID, InventoryFolder folderInfo) { @@ -73,6 +79,7 @@ namespace OpenSim.Framework.Communications.Caches public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { + Console.WriteLine("received new inventory item " + itemInfo.inventoryID + " with asset id of " + itemInfo.assetID); if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) { if (itemInfo.parentFolderID == this.RootFolder.folderID) @@ -84,11 +91,23 @@ namespace OpenSim.Framework.Communications.Caches InventoryFolder folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); if (folder != null) { - folder.Items.Add(itemInfo.inventoryID, itemInfo); + folder.Items.Add(itemInfo.inventoryID, itemInfo); } } } } + + public void AddItem(LLUUID userID, InventoryItemBase itemInfo) + { + if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + { + this.ItemReceive(userID, itemInfo); + Console.WriteLine("now adding inventory item to database"); + this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo); + } + } } + + } diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index e65b6b2..02c5f65 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -61,7 +61,7 @@ namespace OpenSim.Framework.Communications.Caches { if (!this.UserProfiles.ContainsKey(userID)) { - CachedUserInfo userInfo = new CachedUserInfo(); + CachedUserInfo userInfo = new CachedUserInfo(this.m_parent); userInfo.UserProfile = this.RequestUserProfileForUser(userID); if (userInfo.UserProfile != null) { diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 82ef08d..eb88aa7 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -35,10 +35,12 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using OpenSim.Framework.Communications.Caches; +using OpenSim.Framework.Data; namespace OpenSim.Region.Capabilities { - public delegate void UpLoadedTexture(string assetName, LLUUID assetID, LLUUID inventoryItem, byte[] data); + public delegate void UpLoadedTexture(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data); + public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); public class Caps { @@ -56,6 +58,7 @@ namespace OpenSim.Region.Capabilities private AssetCache assetCache; private int eventQueueCount = 1; private Queue CapsEventQueue = new Queue(); + public NewInventoryItem AddNewInventoryItem = null; public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent) { @@ -122,7 +125,7 @@ namespace OpenSim.Region.Capabilities string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; caps.MapLayer = capsBaseUrl + m_mapLayerPath; caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; - caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; + // caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; return caps; } @@ -242,7 +245,7 @@ namespace OpenSim.Region.Capabilities LLUUID newInvItem = LLUUID.Random(); string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - AssetUploader uploader = new AssetUploader(assetName, newAsset, newInvItem, capsBase + uploaderPath, this.httpListener); + AssetUploader uploader = new AssetUploader(assetName, "description", newAsset, newInvItem, LLUUID.Zero, "", "", capsBase + uploaderPath, this.httpListener); httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; @@ -261,13 +264,16 @@ namespace OpenSim.Region.Capabilities public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) { // Console.WriteLine("asset upload request via CAPS"); + string assetName = llsdRequest.name; + string assetDes = llsdRequest.description; string capsBase = "/CAPS/" + m_capsObjectPath; LLUUID newAsset = LLUUID.Random(); LLUUID newInvItem = LLUUID.Random(); + LLUUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - AssetUploader uploader = new AssetUploader(assetName, newAsset, newInvItem, capsBase + uploaderPath, this.httpListener); + AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, "" , "", capsBase + uploaderPath, this.httpListener); httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; @@ -284,7 +290,7 @@ namespace OpenSim.Region.Capabilities /// /// /// - public void UploadCompleteHandler(string assetName, LLUUID assetID, LLUUID inventoryItem, byte[] data) + public void UploadCompleteHandler(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data) { AssetBase asset; asset = new AssetBase(); @@ -294,6 +300,25 @@ namespace OpenSim.Region.Capabilities asset.Name = assetName; asset.Data = data; this.assetCache.AddAsset(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.avatarID = agentID; + item.creatorsID = agentID; + item.inventoryID = inventoryItem; + item.assetID = asset.FullID; + item.inventoryDescription = assetDescription; + item.inventoryName = assetName; + item.assetType = 0; + item.invType = 0; + item.parentFolderID = parentFolder; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = 2147483647; + + if (AddNewInventoryItem != null) + { + AddNewInventoryItem(agentID, item); + } + } public class AssetUploader @@ -303,9 +328,11 @@ namespace OpenSim.Region.Capabilities private string uploaderPath = ""; private LLUUID newAssetID; private LLUUID inventoryItemID; + private LLUUID parentFolder; private BaseHttpServer httpListener; private bool SaveAssets = false; private string m_assetName = ""; + private string m_assetDes = ""; /// /// @@ -314,13 +341,15 @@ namespace OpenSim.Region.Capabilities /// /// /// - public AssetUploader(string assetName, LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer) + public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolderID, string invType, string assetType, string path, BaseHttpServer httpServer) { m_assetName = assetName; + m_assetDes = description; newAssetID = assetID; inventoryItemID = inventoryItem; uploaderPath = path; httpListener = httpServer; + parentFolder = parentFolderID; } /// @@ -348,7 +377,7 @@ namespace OpenSim.Region.Capabilities if (OnUpLoad != null) { - OnUpLoad(m_assetName, newAssetID, inv, data); + OnUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data); } return res; diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 777dbe2..6f01cf2 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -15,5 +15,6 @@ namespace OpenSim.Framework.Communications { void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); + void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); } } -- cgit v1.1