Пример #1
0
        /// <summary>
        /// Called by the notecard update handler.  Provides a URL to which the client can upload a new asset.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="path"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public string NoteCardAgentInventory(string request, string path, string param,
                                             IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            //m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName + "\n" + request);
            //m_log.Debug("[CAPS]: NoteCardAgentInventory Request is: " + request);

            //OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request));
            Hashtable      hash        = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
            LLSDItemUpdate llsdRequest = new LLSDItemUpdate();

            LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest);

            string capsBase     = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
            string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");

            ItemUpdater uploader =
                new ItemUpdater(llsdRequest.item_id, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile);

            uploader.OnUpLoad += ItemUpdated;

            m_HostCapsObj.HttpListener.AddStreamHandler(
                new BinaryStreamHandler(
                    "POST", capsBase + uploaderPath, uploader.uploaderCaps, "NoteCardAgentInventory", null));

            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";

            //            m_log.InfoFormat("[CAPS]: " +
            //                             "NoteCardAgentInventory response: {0}",
            //                             LLSDHelpers.SerialiseLLSDReply(uploadResponse)));

            return(LLSDHelpers.SerialiseLLSDReply(uploadResponse));
        }
Пример #2
0
        private void UpdateInventoryItemAsset(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, OSDMap map, byte atype, bool taskSript = false)
        {
            m_log.Debug("[CAPS]: UpdateInventoryItemAsset Request in region: " + m_regionName + "\n");

            httpResponse.StatusCode = (int)HttpStatusCode.OK;

            UUID itemID   = UUID.Zero;
            UUID objectID = UUID.Zero;

            try
            {
                if (map.TryGetValue("item_id", out OSD itmp))
                {
                    itemID = itmp;
                }
                if (map.TryGetValue("task_id", out OSD tmp))
                {
                    objectID = tmp;
                }
            }
            catch { }

            if (itemID == UUID.Zero)
            {
                LLSDAssetUploadError error = new LLSDAssetUploadError();
                error.message          = "failed to recode request";
                error.identifier       = UUID.Zero;
                httpResponse.RawBuffer = Util.UTF8NBGetbytes(LLSDHelpers.SerialiseLLSDReply(error));
                return;
            }

            if (objectID != UUID.Zero)
            {
                SceneObjectPart sop = m_Scene.GetSceneObjectPart(objectID);
                if (sop == null)
                {
                    LLSDAssetUploadError error = new LLSDAssetUploadError();
                    error.message          = "object not found";
                    error.identifier       = UUID.Zero;
                    httpResponse.RawBuffer = Util.UTF8NBGetbytes(LLSDHelpers.SerialiseLLSDReply(error));
                    return;
                }

                if (!m_Scene.Permissions.CanEditObjectInventory(objectID, m_AgentID))
                {
                    LLSDAssetUploadError error = new LLSDAssetUploadError();
                    error.message          = "No permissions to edit objec";
                    error.identifier       = UUID.Zero;
                    httpResponse.RawBuffer = Util.UTF8NBGetbytes(LLSDHelpers.SerialiseLLSDReply(error));
                    return;
                }
            }

            string uploaderPath = GetNewCapPath();

            string protocol    = m_HostCapsObj.SSLCaps ? "https://" : "http://";
            string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + uploaderPath;
            LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();

            uploadResponse.uploader = uploaderURL;
            uploadResponse.state    = "upload";

            ItemUpdater uploader = new ItemUpdater(itemID, objectID, atype, uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile);

            uploader.m_remoteAdress = httpRequest.RemoteIPEndPoint.Address;

            uploader.OnUpLoad += ItemUpdated;

            var uploaderHandler = new SimpleBinaryHandler("POST", uploaderPath, uploader.process);

            uploaderHandler.MaxDataSize = 10000000; // change per asset type?

            m_HostCapsObj.HttpListener.AddSimpleStreamHandler(uploaderHandler);

            // m_log.InfoFormat("[CAPS]: UpdateAgentInventoryAsset response: {0}",
            //                             LLSDHelpers.SerialiseLLSDReply(uploadResponse)));

            httpResponse.RawBuffer = Util.UTF8NBGetbytes(LLSDHelpers.SerialiseLLSDReply(uploadResponse));
        }