private OSDMap InternalNewAgentInventoryRequest(OSDMap map, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { string asset_type = map["asset_type"].AsString(); //MainConsole.Instance.Info("[CAPS]: NewAgentInventoryRequest Request is: " + map.ToString()); //MainConsole.Instance.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); UUID parentFolder = map["folder_id"].AsUUID(); string inventory_type = map["inventory_type"].AsString(); uint everyone_mask = map["everyone_mask"].AsUInteger(); uint group_mask = map["group_mask"].AsUInteger(); uint next_owner_mask = map["next_owner_mask"].AsUInteger(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); string uploadpath = "/CAPS/Upload/" + UUID.Random() + "/"; AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, uploadpath, everyone_mask, group_mask, next_owner_mask, UploadCompleteHandler); MainServer.Instance.AddStreamHandler(new GenericStreamHandler("POST", uploadpath, uploader.uploaderCaps)); string uploaderURL = MainServer.Instance.ServerURI + uploadpath; map = new OSDMap(); map["uploader"] = uploaderURL; map["state"] = "upload"; return(map); }
/// <summary> /// /// </summary> /// <param name="llsdRequest"></param> /// <returns></returns> public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) { if (llsdRequest.asset_type == "texture" || llsdRequest.asset_type == "animation" || llsdRequest.asset_type == "sound") { IClientAPI client = null; IScene scene = null; if (GetClient != null) { client = GetClient(m_agentID); scene = client.Scene; IMoneyModule mm = scene.RequestModuleInterface <IMoneyModule>(); if (mm != null) { if (!mm.UploadCovered(client, mm.UploadCharge)) { if (client != null) { client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); } LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; return(errorResponse); } } } } string assetName = llsdRequest.name; string assetDes = llsdRequest.description; string capsBase = "/CAPS/" + m_capsObjectPath; UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, m_httpListener, m_dumpAssetsToFile); m_httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string protocol = "http://"; if (m_httpListener.UseSSL) { protocol = "https://"; } string uploaderURL = protocol + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; uploader.OnUpLoad += UploadCompleteHandler; return(uploadResponse); }
private OSDMap InternalNewAgentInventoryRequest(OSDMap map, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { string asset_type = map["asset_type"].AsString(); //MainConsole.Instance.Info("[CAPS]: NewAgentInventoryRequest Request is: " + map.ToString()); //MainConsole.Instance.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); UUID parentFolder = map["folder_id"].AsUUID(); string inventory_type = map["inventory_type"].AsString(); uint everyone_mask = map["everyone_mask"].AsUInteger(); uint group_mask = map["group_mask"].AsUInteger(); uint next_owner_mask = map["next_owner_mask"].AsUInteger(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); string uploadpath = m_service.CreateCAPS("Upload" + uploaderPath, uploaderPath); AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, uploadpath, "Upload" + uploaderPath, m_service, this, everyone_mask, group_mask, next_owner_mask); m_service.AddStreamHandler("Upload" + uploaderPath, new GenericStreamHandler("POST", uploadpath, uploader.uploaderCaps)); string uploaderURL = m_service.HostUri + uploadpath; map = new OSDMap(); map["uploader"] = uploaderURL; map["state"] = "upload"; return(map); }
/// <summary> /// /// </summary> /// <param name="llsdRequest"></param> /// <returns></returns> public string NewAgentInventoryRequest(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(request); string asset_type = map["asset_type"].AsString(); m_log.Info("[CAPS]: NewAgentInventoryRequest Request is: " + map.ToString()); //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); if (asset_type == "texture" || asset_type == "animation" || asset_type == "sound") { /* Disabled until we have a money module that can hook up to this * IMoneyModule mm = .RequestModuleInterface<IMoneyModule>(); * * if (mm != null) * { * if (!mm.UploadCovered(client, mm.UploadCharge)) * { * if (client != null) * client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); * * map = new OSDMap(); * map["uploader"] = ""; * map["state"] = "error"; * return OSDParser.SerializeLLSDXmlString(map); * } * else * mm.ApplyUploadCharge(client.AgentId, mm.UploadCharge, "Upload asset."); * } */ } string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); UUID parentFolder = map["folder_id"].AsUUID(); string inventory_type = map["inventory_type"].AsString(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); string uploadpath = m_service.CreateCAPS("Upload" + uploaderPath, uploaderPath); AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, uploadpath, "Upload" + uploaderPath, m_service, this); m_service.AddStreamHandler("Upload" + uploaderPath, new BinaryStreamHandler("POST", uploadpath, uploader.uploaderCaps)); string uploaderURL = m_service.HostUri + uploadpath; map = new OSDMap(); map["uploader"] = uploaderURL; map["state"] = "upload"; return(OSDParser.SerializeLLSDXmlString(map)); }
static void UploadScene() { Debug.Log("Upload Start"); var accessToken = GetEnv("ACCESS_TOKEN"); var venueId = new VenueID(GetEnv("VENUE_ID")); AssetUploader.Upload(accessToken, venueId); Debug.Log("Upload End"); }
public string HandleInventoryItemCreate(string request, UUID AgentID) { OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(request); string asset_type = map["asset_type"].AsString(); if (!ChargeUser(asset_type, map)) { map = new OSDMap(); map["uploader"] = ""; map["state"] = "error"; return(OSDParser.SerializeLLSDXmlString(map)); } string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); UUID parentFolder = map["folder_id"].AsUUID(); string inventory_type = map["inventory_type"].AsString(); uint everyone_mask = map["everyone_mask"].AsUInteger(); uint group_mask = map["group_mask"].AsUInteger(); uint next_owner_mask = map["next_owner_mask"].AsUInteger(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); string uploadpath = m_service.CreateCAPS("Upload" + uploaderPath, uploaderPath); AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, uploadpath, "Upload" + uploaderPath, m_service, this, everyone_mask, group_mask, next_owner_mask); m_service.AddStreamHandler("Upload" + uploaderPath, new GenericStreamHandler("POST", uploadpath, uploader.uploaderCaps)); string uploaderURL = m_service.HostUri + uploadpath; map = new OSDMap(); map["uploader"] = uploaderURL; map["state"] = "upload"; return(OSDParser.SerializeLLSDXmlString(map)); }
public string HandleInventoryItemCreate(string request, UUID AgentID) { OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(request); string asset_type = map["asset_type"].AsString(); if (!ChargeUser(asset_type, map)) { map = new OSDMap(); map["uploader"] = ""; map["state"] = "error"; return(OSDParser.SerializeLLSDXmlString(map)); } string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); UUID parentFolder = map["folder_id"].AsUUID(); string inventory_type = map["inventory_type"].AsString(); uint everyone_mask = map["everyone_mask"].AsUInteger(); uint group_mask = map["group_mask"].AsUInteger(); uint next_owner_mask = map["next_owner_mask"].AsUInteger(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); string uploadpath = "/CAPS/Upload/" + UUID.Random() + "/"; AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, uploadpath, everyone_mask, group_mask, next_owner_mask, UploadCompleteHandler); MainServer.Instance.AddStreamHandler(new GenericStreamHandler("POST", uploadpath, uploader.uploaderCaps)); string uploaderURL = MainServer.Instance.ServerURI + uploadpath; map = new OSDMap(); map["uploader"] = uploaderURL; map["state"] = "upload"; return(OSDParser.SerializeLLSDXmlString(map)); }
public string NewAgentInventoryRequest(string request, UUID agentID) { OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(request); //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 //if (llsdRequest.asset_type == "texture" || // llsdRequest.asset_type == "animation" || // llsdRequest.asset_type == "sound") // { IClientAPI client = null; IMoneyModule mm = m_scene.RequestModuleInterface <IMoneyModule>(); if (mm != null) { if (m_scene.TryGetClient(agentID, out client)) { if (!mm.Charge(agentID, mm.UploadCharge, "Asset upload")) { if (client != null) { client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); } map = new OSDMap(); map["rsvp"] = ""; map["state"] = "error"; return(OSDParser.SerializeLLSDXmlString(map)); } } } // } string asset_type = map["asset_type"].AsString(); string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); string capsBase = "/CAPS/NewFileAgentInventoryVariablePrice/"; string inventory_type = map["inventory_type"].AsString(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); UUID parentFolder = map["folder_id"].AsUUID(); string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, capsBase + uploaderPath, MainServer.Instance, agentID, this); MainServer.Instance.AddStreamHandler( new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = m_scene.RegionInfo.ServerURI + capsBase + uploaderPath; map = new OSDMap(); map["rsvp"] = uploaderURL; map["state"] = "upload"; map["resource_cost"] = 0; map["upload_price"] = 0; return(OSDParser.SerializeLLSDXmlString(map)); }
/// <summary> /// /// </summary> /// <param name="llsdRequest"></param> /// <returns></returns> 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 = null; IScene scene = null; if (GetClient != null) { client = GetClient(m_HostCapsObj.AgentID); scene = client.Scene; IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>(); if (mm != null) { if (!mm.UploadCovered(client, mm.UploadCharge)) { if (client != null) client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; return errorResponse; } } } } string assetName = llsdRequest.name; string assetDes = llsdRequest.description; string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string protocol = "http://"; if (m_HostCapsObj.SSLCaps) protocol = "https://"; string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase + uploaderPath; LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; uploader.OnUpLoad += UploadCompleteHandler; return uploadResponse; }
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 //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) { 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; } } // check funds IMoneyModule mm = m_scene.RequestModuleInterface<IMoneyModule>(); if (mm != null) { 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; } } // } string assetName = llsdRequest.name; string assetDes = llsdRequest.description; string capsBase = "/CAPS/NewFileAgentInventoryVariablePrice/"; UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; 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, "NewFileAgentInventoryVariablePrice", agentID.ToString())); string protocol = "http://"; if (MainServer.Instance.UseSSL) protocol = "https://"; string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase + uploaderPath; LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); uploadResponse.rsvp = uploaderURL; uploadResponse.state = "upload"; uploadResponse.resource_cost = 0; uploadResponse.upload_price = 0; uploader.OnUpLoad += //UploadCompleteHandler; delegate( string passetName, string passetDescription, UUID passetID, UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, string passetType) { UploadCompleteHandler(passetName, passetDescription, passetID, pinventoryItem, pparentFolder, pdata, pinventoryType, passetType,agentID); }; return uploadResponse; }
/// <summary> /// /// </summary> /// <param name="llsdRequest"></param> /// <returns></returns> 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); // start by getting the client IClientAPI client = null; m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); // check current state so we only have one service at a time lock (m_ModelCost) { switch (m_FileAgentInventoryState) { case FileAgentInventoryState.processRequest: case FileAgentInventoryState.processUpload: LLSDAssetUploadError resperror = new LLSDAssetUploadError(); resperror.message = "Uploader busy processing previus request"; resperror.identifier = UUID.Zero; LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; errorResponse.error = resperror; return errorResponse; break; case FileAgentInventoryState.waitUpload: // todo stop current uploader server break; case FileAgentInventoryState.idle: default: break; } m_FileAgentInventoryState = FileAgentInventoryState.processRequest; } int cost = 0; int nreqtextures = 0; int nreqmeshs= 0; int nreqinstances = 0; bool IsAtestUpload = false; string assetName = llsdRequest.name; LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); if (llsdRequest.asset_type == "texture" || llsdRequest.asset_type == "animation" || llsdRequest.asset_type == "animatn" || // this is the asset name actually used by viewers llsdRequest.asset_type == "mesh" || llsdRequest.asset_type == "sound") { ScenePresence avatar = null; m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar); // check user level if (avatar != null) { if (avatar.UserLevel < m_levelUpload) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); resperror.message = "Insufficient permissions to upload"; resperror.identifier = UUID.Zero; LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; errorResponse.error = resperror; lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; } } // check test upload and funds if (client != null) { IMoneyModule mm = m_Scene.RequestModuleInterface<IMoneyModule>(); int baseCost = 0; if (mm != null) baseCost = mm.UploadCharge; string warning = String.Empty; if (llsdRequest.asset_type == "mesh") { string error; int modelcost; if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, meshcostdata, out error, ref warning)) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); resperror.message = error; resperror.identifier = UUID.Zero; LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; errorResponse.error = resperror; lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; } cost = modelcost; } else { cost = baseCost; } if (cost > 0 && mm != null) { // check for test upload if (m_ForceFreeTestUpload) // all are test { if (!(assetName.Length > 5 && assetName.StartsWith("TEST-"))) // has normal name lets change it assetName = "TEST-" + assetName; IsAtestUpload = true; } else if (m_enableFreeTestUpload) // only if prefixed with "TEST-" { IsAtestUpload = (assetName.Length > 5 && assetName.StartsWith("TEST-")); } if(IsAtestUpload) // let user know, still showing cost estimation warning += "Upload will have no cost, for testing purposes only. Other uses are prohibited. Items will not work after 48 hours or on other regions"; // check funds else { if (!mm.UploadCovered(client.AgentId, (int)cost)) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); resperror.message = "Insuficient funds"; resperror.identifier = UUID.Zero; LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; errorResponse.error = resperror; lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; } } } if (client != null && warning != String.Empty) client.SendAgentAlertMessage(warning, true); } } string assetDes = llsdRequest.description; string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); UUID texturesFolder = UUID.Zero; if(!IsAtestUpload && m_enableModelUploadTextureToInventory) texturesFolder = llsdRequest.texture_folder_id; AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost, texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload, llsdRequest.next_owner_mask, llsdRequest.group_mask, llsdRequest.everyone_mask); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( "POST", capsBase + uploaderPath, uploader.uploaderCaps, "NewAgentInventoryRequest", m_HostCapsObj.AgentID.ToString())); string protocol = "http://"; if (m_HostCapsObj.SSLCaps) protocol = "https://"; string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase + uploaderPath; LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; uploadResponse.upload_price = (int)cost; if (llsdRequest.asset_type == "mesh") { uploadResponse.data = meshcostdata; } uploader.OnUpLoad += UploadCompleteHandler; lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.waitUpload; return uploadResponse; }
/// <summary> /// /// </summary> /// <param name="llsdRequest"></param> /// <returns></returns> public LLSDAssetUploadResponse NewAgentInventoryRequest (LLSDAssetUploadRequest llsdRequest) { if (m_log.IsDebugEnabled) { m_log.Debug ("[BunchOfCaps]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString ()); m_log.Debug ("[BunchOfCaps]: asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); } if (llsdRequest.asset_type == "texture" || llsdRequest.asset_type == "animation" || llsdRequest.asset_type == "sound") { ScenePresence avatar = null; IClientAPI client = null; m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar); // check user level if (avatar != null) { client = avatar.ControllingClient; if (avatar.UserLevel < m_levelUpload) { if (client != null) client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; return errorResponse; } } // check funds if (client != null) { IMoneyModule mm = m_Scene.RequestModuleInterface<IMoneyModule>(); if (mm != null) { if (!mm.UploadCovered(client.AgentId, mm.UploadCharge)) { client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; return errorResponse; } } } } string assetName = llsdRequest.name; string assetDes = llsdRequest.description; string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( "POST", capsBase + uploaderPath, uploader.uploaderCaps, "NewAgentInventoryRequest", m_HostCapsObj.AgentID.ToString())); string protocol = "http://"; if (m_HostCapsObj.SSLCaps) protocol = "https://"; string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase + uploaderPath; LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; uploader.OnUpLoad += UploadCompleteHandler; return uploadResponse; }
public string NewAgentInventoryRequest(string request, UUID agentID) { OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(request); //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 make sure to deal with it appropriately //if (llsdRequest.asset_type == "texture" || // llsdRequest.asset_type == "animation" || // llsdRequest.asset_type == "sound") // { IClientAPI client = null; IMoneyModule mm = m_scene.RequestModuleInterface<IMoneyModule>(); int uploadPrice = 0; if (mm != null) { if (m_scene.TryGetClient(agentID, out client)) { uploadPrice = mm.UploadCharge; if (!mm.Charge(agentID, mm.UploadCharge, "Asset upload")) { if (client != null) client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); map = new OSDMap(); map["rsvp"] = ""; map["state"] = "error"; return OSDParser.SerializeLLSDXmlString(map); } } } // } string asset_type = map["asset_type"].AsString(); string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); string capsBase = "/CAPS/NewFileAgentInventoryVariablePrice/"; string inventory_type = map["inventory_type"].AsString(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); UUID parentFolder = map["folder_id"].AsUUID(); string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, capsBase + uploaderPath, MainServer.Instance, agentID, this); MainServer.Instance.AddStreamHandler( new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = m_scene.RegionInfo.ServerURI + capsBase + uploaderPath; map = new OSDMap(); map["rsvp"] = uploaderURL; map["state"] = "upload"; map["resource_cost"] = 0; map["upload_price"] = uploadPrice; return OSDParser.SerializeLLSDXmlString(map); }
/// <summary> /// Handle the NewAgentInventory Upload request. /// </summary> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="httpRequest"></param> /// <param name="httpResponse"></param> /// <returns></returns> public string NewAgentInventoryRequest(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request)); string asset_type = map["asset_type"].AsString(); int uploadCost = 0; int resourceCost = 0; // Check to see if mesh uploads are enabled. if (asset_type == "mesh") { ISimulatorFeaturesModule m_SimulatorFeatures = m_Scene.RequestModuleInterface<ISimulatorFeaturesModule>(); if ((m_SimulatorFeatures == null) || (m_SimulatorFeatures.MeshEnabled == false)) { OSDMap errorResponse = new OSDMap(); errorResponse["uploader"] = String.Empty; errorResponse["state"] = "error"; return (errorResponse); } } string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); UUID parentFolder = map["folder_id"].AsUUID(); string inventory_type = map["inventory_type"].AsString(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); IMoneyModule mm = m_Scene.RequestModuleInterface<IMoneyModule>(); CalculateCosts(mm, asset_type, map, out uploadCost, out resourceCost); IClientAPI client = m_Scene.SceneContents.GetControllingClient(m_agentID); if (!mm.AmountCovered(client.AgentId, uploadCost)) { if (client != null) client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); OSDMap errorResponse = new OSDMap(); errorResponse["uploader"] = String.Empty; errorResponse["state"] = "error"; return OSDParser.SerializeLLSDXmlString(errorResponse); } // Build the response OSDMap uploadResponse = new OSDMap(); try { // Handle mesh asset "data" block if (asset_type == "mesh") { OSDMap meshMap = (OSDMap)map["asset_resources"]; OSDArray mesh_list = (OSDArray)meshMap["mesh_list"]; OSDArray instance_list = (OSDArray)meshMap["instance_list"]; float streaming_cost = 0.0f; float server_weight = 0.0f; for (int i = 0; i < mesh_list.Count; i++) { OSDMap inner_instance_list = (OSDMap)instance_list[i]; byte[] mesh_data = mesh_list[i].AsBinary(); Vector3 scale = inner_instance_list["scale"].AsVector3(); int vertex_count = 0; int hibytes = 0; int midbytes = 0; int lowbytes = 0; int lowestbytes = 0; SceneObjectPartMeshCost.GetMeshVertexCount(mesh_data, out vertex_count); SceneObjectPartMeshCost.GetMeshLODByteCounts(mesh_data, out hibytes, out midbytes, out lowbytes, out lowestbytes); server_weight += PrimitiveBaseShape.GetServerWeight(vertex_count); streaming_cost += PrimitiveBaseShape.GetStreamingCost(scale, hibytes, midbytes, lowbytes, lowestbytes); } OSDMap data = new OSDMap(); data["resource_cost"] = Math.Min(server_weight, streaming_cost); data["model_streaming_cost"] = streaming_cost; data["simulation_cost"] = server_weight; data["physics_cost"] = 0.0f; uploadResponse["data"] = data; } } catch (Exception) { OSDMap errorResponse = new OSDMap(); errorResponse["uploader"] = String.Empty; errorResponse["state"] = "error"; return OSDParser.SerializeLLSDXmlString(errorResponse); } string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); string uploaderURL = m_Caps.HttpListener.ServerURI + m_Caps.CapsBase + uploaderPath; AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, m_Caps.CapsBase + uploaderPath, m_Caps.HttpListener); uploader.OnUpLoad += UploadCompleteHandler; m_Caps.HttpListener.AddStreamHandler( new BinaryStreamHandler("POST", m_Caps.CapsBase + uploaderPath, uploader.uploaderCaps)); uploadResponse["uploader"] = uploaderURL; uploadResponse["state"] = "upload"; uploadResponse["resource_cost"] = resourceCost; uploadResponse["upload_price"] = uploadCost; return OSDParser.SerializeLLSDXmlString(uploadResponse); }
private OSDMap InternalNewAgentInventoryRequest(OSDMap map, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { string asset_type = map["asset_type"].AsString(); //MainConsole.Instance.Info("[CAPS]: NewAgentInventoryRequest Request is: " + map.ToString()); //MainConsole.Instance.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); UUID parentFolder = map["folder_id"].AsUUID(); string inventory_type = map["inventory_type"].AsString(); uint everyone_mask = map["everyone_mask"].AsUInteger(); uint group_mask = map["group_mask"].AsUInteger(); uint next_owner_mask = map["next_owner_mask"].AsUInteger(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); string uploadpath = m_service.CreateCAPS("Upload" + uploaderPath, uploaderPath); AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, uploadpath, "Upload" + uploaderPath, m_service, this, everyone_mask, group_mask, next_owner_mask); m_service.AddStreamHandler("Upload" + uploaderPath, new GenericStreamHandler("POST", uploadpath, uploader.uploaderCaps)); string uploaderURL = m_service.HostUri + uploadpath; map = new OSDMap(); map["uploader"] = uploaderURL; map["state"] = "upload"; return map; }
public string HandleInventoryItemCreate(string request, UUID AgentID) { OSDMap map = (OSDMap) OSDParser.DeserializeLLSDXml(request); string asset_type = map["asset_type"].AsString(); if (!ChargeUser(asset_type, map)) { map = new OSDMap(); map["uploader"] = ""; map["state"] = "error"; return OSDParser.SerializeLLSDXmlString(map); } string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); UUID parentFolder = map["folder_id"].AsUUID(); string inventory_type = map["inventory_type"].AsString(); uint everyone_mask = map["everyone_mask"].AsUInteger(); uint group_mask = map["group_mask"].AsUInteger(); uint next_owner_mask = map["next_owner_mask"].AsUInteger(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); string uploadpath = m_service.CreateCAPS("Upload" + uploaderPath, uploaderPath); AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, uploadpath, "Upload" + uploaderPath, m_service, this, everyone_mask, group_mask, next_owner_mask); m_service.AddStreamHandler("Upload" + uploaderPath, new GenericStreamHandler("POST", uploadpath, uploader.uploaderCaps)); string uploaderURL = m_service.HostUri + uploadpath; map = new OSDMap(); map["uploader"] = uploaderURL; map["state"] = "upload"; return OSDParser.SerializeLLSDXmlString(map); }
public string HandleInventoryItemCreate(string request, UUID AgentID) { OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(request); string asset_type = map["asset_type"].AsString(); //m_log.Info("[CAPS]: NewAgentInventoryRequest Request is: " + map.ToString()); //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); if (asset_type == "texture" || asset_type == "animation" || asset_type == "sound") { /* Disabled until we have a money module that can hook up to this * IMoneyModule mm = .RequestModuleInterface<IMoneyModule>(); if (mm != null) { if (!mm.UploadCovered(client, mm.UploadCharge)) { if (client != null) client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); map = new OSDMap(); map["uploader"] = ""; map["state"] = "error"; return OSDParser.SerializeLLSDXmlString(map); } else mm.ApplyUploadCharge(client.AgentId, mm.UploadCharge, "Upload asset."); } */ } string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); UUID parentFolder = map["folder_id"].AsUUID(); string inventory_type = map["inventory_type"].AsString(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); string uploadpath = m_service.CreateCAPS("Upload" + uploaderPath, uploaderPath); AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, uploadpath, "Upload" + uploaderPath, m_service, this); m_service.AddStreamHandler("Upload" + uploaderPath, new BinaryStreamHandler("POST", uploadpath, uploader.uploaderCaps)); string uploaderURL = m_service.HostUri + uploadpath; map = new OSDMap(); map["uploader"] = uploaderURL; map["state"] = "upload"; return OSDParser.SerializeLLSDXmlString(map); }
OSDMap InternalNewAgentInventoryRequest (OSDMap map, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { string asset_type = map ["asset_type"].AsString (); //MainConsole.Instance.Info("[CAPS]: NewAgentInventoryRequest Request is: " + map.ToString()); //MainConsole.Instance.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); string assetName = map ["name"].AsString (); string assetDes = map ["description"].AsString (); UUID parentFolder = map ["folder_id"].AsUUID (); string inventory_type = map ["inventory_type"].AsString (); uint everyone_mask = map ["everyone_mask"].AsUInteger (); uint group_mask = map ["group_mask"].AsUInteger (); uint next_owner_mask = map ["next_owner_mask"].AsUInteger (); UUID newAsset = UUID.Random (); UUID newInvItem = UUID.Random (); string uploadpath = "/CAPS/Upload/" + UUID.Random () + "/"; AssetUploader uploader = new AssetUploader (assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, uploadpath, everyone_mask, group_mask, next_owner_mask, UploadCompleteHandler); MainServer.Instance.AddStreamHandler (new GenericStreamHandler ("POST", uploadpath, uploader.UploaderCaps)); string uploaderURL = MainServer.Instance.ServerURI + uploadpath; map = new OSDMap (); map ["uploader"] = uploaderURL; map ["state"] = "upload"; return map; }
public string HandleInventoryItemCreate(string request, UUID AgentID) { OSDMap map = (OSDMap) OSDParser.DeserializeLLSDXml(request); string asset_type = map["asset_type"].AsString(); if (!ChargeUser(asset_type, map)) { map = new OSDMap(); map["uploader"] = ""; map["state"] = "error"; return OSDParser.SerializeLLSDXmlString(map); } string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); UUID parentFolder = map["folder_id"].AsUUID(); string inventory_type = map["inventory_type"].AsString(); uint everyone_mask = map["everyone_mask"].AsUInteger(); uint group_mask = map["group_mask"].AsUInteger(); uint next_owner_mask = map["next_owner_mask"].AsUInteger(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); string uploadpath = "/CAPS/Upload/" + UUID.Random() + "/"; AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, uploadpath, everyone_mask, group_mask, next_owner_mask, UploadCompleteHandler); MainServer.Instance.AddStreamHandler(new GenericStreamHandler("POST", uploadpath, uploader.uploaderCaps)); string uploaderURL = MainServer.Instance.ServerURI + uploadpath; map = new OSDMap(); map["uploader"] = uploaderURL; map["state"] = "upload"; return OSDParser.SerializeLLSDXmlString(map); }