Example #1
0
        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);

            IClientAPI client = null;
            if (GetClient != null)
            {
                client = GetClient(m_agentID);
            }

            #region Upload permissions
            if (client != null)
            {
                IUploadPermissions uploadPermissionModule = client.Scene.RequestModuleInterface<IUploadPermissions>();
                if (uploadPermissionModule != null)
                {
                    if (!uploadPermissionModule.CanUpload(m_agentID))
                    {
                        client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false);

                        LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
                        errorResponse.uploader = "";
                        errorResponse.state = "error";
                        return errorResponse;
                    }
                }
            }
            #endregion

            #region Fancy money module stuff:
            /*
            if (llsdRequest.asset_type == "texture" ||
                llsdRequest.asset_type == "animation" ||
                llsdRequest.asset_type == "sound" ||
                llsdRequest.asset_type == "ogremesh" ||
                llsdRequest.asset_type == "flashani")
            {
                IScene scene = null;
                if (client != null)
                {
                    scene = client.Scene;

                    IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>();

                    if (mm != null)
                    {
                        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;
                        }
                    }
                }
            }
             * */
            #endregion

            string assetName = llsdRequest.name;
            string assetDes = llsdRequest.description;
            string capsBase = "/CAPS/" + Caps.CapsObjectPath;
            UUID newAsset = UUID.Random();
            UUID newInvItem = UUID.Random();
            UUID parentFolder = llsdRequest.folder_id;
            string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");

            Caps.AssetUploader uploader =
                new Caps.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;
        }
        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 


            //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.UploadCovered(client, 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") + "/";

            Caps.AssetUploader uploader =
                new Caps.AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
                                  llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance);
            MainServer.Instance.AddStreamHandler(
                new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));

            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;
        }
Example #3
0
        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


            //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.UploadCovered(client, 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") + "/";

            Caps.AssetUploader uploader =
                new Caps.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));

            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);
        }