From 231a3bf147315a9284140476d2b09e13c3fee1c0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 3 May 2012 01:45:49 +0100 Subject: Implement optional name and description on http stream handlers so that we can relate a slow request to what the handler actually does and the agent it serves, if applicable. This is most useful for capabilities where the url is not self-describing. --- .../NewFileAgentInventoryVariablePriceModule.cs | 93 ++++++++++++---------- 1 file changed, 49 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs index 91872c5..52c4f44 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs @@ -115,67 +115,66 @@ namespace OpenSim.Region.ClientStack.Linden UUID capID = UUID.Random(); // m_log.Debug("[NEW FILE AGENT INVENTORY VARIABLE PRICE]: /CAPS/" + capID); - caps.RegisterHandler("NewFileAgentInventoryVariablePrice", - - new LLSDStreamhandler("POST", - "/CAPS/" + capID.ToString(), - delegate(LLSDAssetUploadRequest req) - { - return NewAgentInventoryRequest(req,agentID); - })); - + caps.RegisterHandler( + "NewFileAgentInventoryVariablePrice", + new LLSDStreamhandler( + "POST", + "/CAPS/" + capID.ToString(), + req => NewAgentInventoryRequest(req, agentID), + "NewFileAgentInventoryVariablePrice", + agentID.ToString())); } #endregion public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) { - //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit - // You need to be aware of this and - + // you need to be aware of this //if (llsdRequest.asset_type == "texture" || // llsdRequest.asset_type == "animation" || // llsdRequest.asset_type == "sound") // { // check user level - ScenePresence avatar = null; - IClientAPI client = null; - m_scene.TryGetScenePresence(agentID, out avatar); - if (avatar != null) + ScenePresence avatar = null; + IClientAPI client = null; + m_scene.TryGetScenePresence(agentID, out avatar); + + if (avatar != null) + { + client = avatar.ControllingClient; + + if (avatar.UserLevel < m_levelUpload) { - client = avatar.ControllingClient; - - if (avatar.UserLevel < m_levelUpload) - { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); - - LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - errorResponse.rsvp = ""; - errorResponse.state = "error"; - return errorResponse; - } + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); + + LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); + errorResponse.rsvp = ""; + errorResponse.state = "error"; + return errorResponse; } + } - // check funds - IMoneyModule mm = m_scene.RequestModuleInterface(); + // check funds + IMoneyModule mm = m_scene.RequestModuleInterface(); - if (mm != null) + if (mm != null) + { + if (!mm.UploadCovered(agentID, mm.UploadCharge)) { - if (!mm.UploadCovered(agentID, mm.UploadCharge)) - { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); - - LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - errorResponse.rsvp = ""; - errorResponse.state = "error"; - return errorResponse; - } + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + + LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); + errorResponse.rsvp = ""; + errorResponse.state = "error"; + return errorResponse; } + } + // } string assetName = llsdRequest.name; @@ -189,8 +188,14 @@ namespace OpenSim.Region.ClientStack.Linden AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile); + MainServer.Instance.AddStreamHandler( - new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); + new BinaryStreamHandler( + "POST", + capsBase + uploaderPath, + uploader.uploaderCaps, + "NewFileAgentInventoryVariablePrice", + agentID.ToString())); string protocol = "http://"; @@ -199,10 +204,9 @@ namespace OpenSim.Region.ClientStack.Linden string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase + uploaderPath; - + LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - uploadResponse.rsvp = uploaderURL; uploadResponse.state = "upload"; @@ -220,6 +224,7 @@ namespace OpenSim.Region.ClientStack.Linden pinventoryItem, pparentFolder, pdata, pinventoryType, passetType,agentID); }; + return uploadResponse; } -- cgit v1.1