Beispiel #1
0
        public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID)
        {
            m_log.DebugFormat("[NewFileAgentInventoryVariablePriceModule]: NewAgentInventroryRequest({0},{1})", llsdRequest.name, agentID.ToString());
            //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);
        }
Beispiel #2
0
        /// <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")
            {
                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);
        }