From 7322e1921249f4b64a87a1825de1b3b5707b24d6 Mon Sep 17 00:00:00 2001 From: diva Date: Fri, 3 Apr 2009 16:08:07 +0000 Subject: Added one more delegate to Caps, and a few guards, so that these objects can be used from more than just Scenes. Added the NewFileAgentInvengory cap to HGInventoryService. --- .../Framework/Communications/Capabilities/Caps.cs | 42 ++++++++++++++-------- .../Communications/Services/HGInventoryService.cs | 14 ++++++++ 2 files changed, 42 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 94614a1..1423e3a 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -49,6 +49,8 @@ namespace OpenSim.Framework.Communications.Capabilities public delegate void NewInventoryItem(UUID userID, InventoryItemBase item); + public delegate void NewAsset(AssetBase asset); + public delegate UUID ItemUpdatedCallback(UUID userID, UUID itemID, byte[] data); public delegate void TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID, @@ -120,6 +122,7 @@ namespace OpenSim.Framework.Communications.Capabilities // These are callbacks which will be setup by the scene so that we can update scene data when we // receive capability calls public NewInventoryItem AddNewInventoryItem = null; + public NewAsset AddNewAsset = null; public ItemUpdatedCallback ItemUpdatedCall = null; public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; @@ -674,30 +677,38 @@ namespace OpenSim.Framework.Communications.Capabilities /// public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) { + //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); + //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); + if (llsdRequest.asset_type == "texture" || llsdRequest.asset_type == "animation" || llsdRequest.asset_type == "sound") { - IClientAPI client = GetClient(m_agentID); - IScene scene = client.Scene; + IClientAPI client = null; + IScene scene = null; + if (GetClient != null) + { + client = GetClient(m_agentID); + scene = client.Scene; - IMoneyModule mm = scene.RequestModuleInterface(); + IMoneyModule mm = scene.RequestModuleInterface(); - if (mm != null) - { - if (!mm.UploadCovered(client)) + if (mm != null) { - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); - - LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); - errorResponse.uploader = ""; - errorResponse.state = "error"; - return errorResponse; + if (!mm.UploadCovered(client)) + { + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + return errorResponse; + } } } } - //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); string assetName = llsdRequest.name; string assetDes = llsdRequest.description; @@ -771,7 +782,10 @@ namespace OpenSim.Framework.Communications.Capabilities asset.Type = assType; asset.Name = assetName; asset.Data = data; - m_assetCache.AddAsset(asset); + if (AddNewAsset != null) + AddNewAsset(asset); + else if (m_assetCache != null) + m_assetCache.AddAsset(asset); InventoryItemBase item = new InventoryItemBase(); item.Owner = m_agentID; diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index 7eaed89..d59d1ae 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs @@ -234,6 +234,11 @@ namespace OpenSim.Framework.Communications.Services } } + public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) + { + AddItem(item); + } + public InventoryItemBase UpdateItem(InventoryItemBase item) { m_log.DebugFormat("[HGStandaloneInvService]: Update item {0} from {1}", item.ID, item.Owner); @@ -372,6 +377,11 @@ namespace OpenSim.Framework.Communications.Services return true; } + public void PostAnAsset(AssetBase asset) + { + PostAsset(asset); + } + /// /// CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[]) /// @@ -598,6 +608,10 @@ namespace OpenSim.Framework.Communications.Services Caps caps = new Caps(null, httpServer, m_thisHostname, m_thisPort, authToken, userID, false, "Inventory"); caps.RegisterInventoryServiceHandlers("/" + authToken + "/InventoryCap/"); caps.ItemUpdatedCall = UpdateInventoryItemAsset; + caps.AddNewInventoryItem = AddUploadedInventoryItem; + caps.AddNewAsset = PostAnAsset; + //caps.GetClient = + Hashtable capsHandlers = caps.CapsHandlers.CapsDetails; httpServer.AddStreamHandler(new RestDeserialiseSecureHandler( -- cgit v1.1