Esempio n. 1
0
        private byte[] SimConsoleAsyncResponder(Stream request, UUID agentID)
        {
            IScenePresence SP = m_Scene.GetScenePresence(agentID);

            if (SP == null)
            {
                return(new byte[0]); //They don't exist
            }
            OSD rm = OSDParser.DeserializeLLSDXml(request);

            string message = rm.AsString();

            //Is a god, or they authenticated to the server and have write access
            if (AuthenticateUser(SP, message) && CanWrite(SP.UUID))
            {
                FireConsole(message);
            }
            return(OSDParser.SerializeLLSDXmlBytes(""));
        }
        protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            StreamReader reader  = new StreamReader(request);
            string       message = reader.ReadToEnd();

            OSD osd = OSDParser.DeserializeLLSDXml(message);

            string cmd = osd.AsString();

            if (cmd == "set console on")
            {
                if (m_isGod)
                {
                    MainConsole.Instance.OnOutput += ConsoleSender;
                    m_consoleIsOn = true;
                    m_consoleModule.SendConsoleOutput(m_agentID, "Console is now on");
                }
                return(new byte[0]);
            }
            else if (cmd == "set console off")
            {
                MainConsole.Instance.OnOutput -= ConsoleSender;
                m_consoleIsOn = false;
                m_consoleModule.SendConsoleOutput(m_agentID, "Console is now off");
                return(new byte[0]);
            }

            if (m_consoleIsOn == false && m_consoleModule.RunCommand(osd.AsString().Trim(), m_agentID))
            {
                return(new byte[0]);
            }

            if (m_isGod && m_consoleIsOn)
            {
                MainConsole.Instance.RunCommand(osd.AsString().Trim());
            }
            else
            {
                m_consoleModule.SendConsoleOutput(m_agentID, "Unknown command");
            }

            return(new byte[0]);
        }
Esempio n. 3
0
        /// <summary>
        ///     Callback for a map layer request
        /// </summary>
        /// <param name="request"></param>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <param name="agentID"></param>
        /// <returns></returns>
        public byte[] MapLayerRequest(string request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            int bottom = (m_region.RegionLocY / Constants.RegionSize) - m_mapDistance;
            int top    = (m_region.RegionLocY / Constants.RegionSize) + m_mapDistance;
            int left   = (m_region.RegionLocX / Constants.RegionSize) - m_mapDistance;
            int right  = (m_region.RegionLocX / Constants.RegionSize) + m_mapDistance;

            OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(request);

            int flags = map["Flags"].AsInteger();

            OSDArray layerData = new OSDArray
            {
                GetOSDMapLayerResponse(bottom, left, right, top,
                                       new UUID("00000000-0000-1111-9999-000000000006"))
            };
            OSDArray mapBlocksData = new OSDArray();

            if (m_allowCapsMessage)
            {
                if (m_mapLayer == null || m_mapLayer.Count == 0)
                {
                    List <GridRegion> regions = m_gridService.GetRegionRange(
                        m_userScopeIDs,
                        left * Constants.RegionSize,
                        right * Constants.RegionSize,
                        bottom * Constants.RegionSize,
                        top * Constants.RegionSize);
                    foreach (GridRegion r in regions)
                    {
                        m_mapLayer.Add(MapBlockFromGridRegion(r, flags));
                    }
                }
            }
            foreach (MapBlockData block in m_mapLayer)
            {
                //Add to the array
                mapBlocksData.Add(block.ToOSD());
            }
            OSDMap response = MapLayerResponce(layerData, mapBlocksData, flags);

            return(OSDParser.SerializeLLSDXmlBytes(response));
        }
Esempio n. 4
0
        public byte[] HandleFetchInventory(Stream request, UUID AgentID)
        {
            try
            {
                //MainConsole.Instance.DebugFormat("[InventoryCAPS]: Received FetchInventory request for {0}", AgentID);

                OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
                if (requestmap["items"].Type == OSDType.Unknown)
                {
                    return(MainServer.BadRequest);
                }
                OSDArray foldersrequested = (OSDArray)requestmap["items"];

                OSDMap map = new OSDMap {
                    { "agent_id", OSD.FromUUID(AgentID) }
                };
                //We have to send the agent_id in the main map as well as all the items

                OSDArray items = new OSDArray();
                foreach (
                    OSDArray item in
                    foldersrequested.Cast <OSDMap>()
                    .Select(requestedFolders => requestedFolders["item_id"].AsUUID())
                    .Select(item_id => m_inventoryService.GetOSDItem(m_agentID, item_id))
                    .Where(item => item != null && item.Count > 0))
                {
                    items.Add(item[0]);
                }
                map.Add("items", items);

                byte[] response = OSDParser.SerializeLLSDXmlBytes(map);
                map.Clear();
                return(response);
            }
            catch (Exception ex)
            {
                MainConsole.Instance.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex);
            }
            OSDMap rmap = new OSDMap();

            rmap["items"] = new OSDArray();
            return(OSDParser.SerializeLLSDXmlBytes(rmap));
        }
        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));
        }
Esempio n. 6
0
        public void LoadGrids()
        {
            Grids.Clear();
            Grids.Add(new Grid("agni", "Second Life (agni)", "https://login.agni.lindenlab.com/cgi-bin/login.cgi"));
            Grids.Add(new Grid("aditi", "Second Life Beta (aditi)", "https://login.aditi.lindenlab.com/cgi-bin/login.cgi"));

            try
            {
                string   sysGridsFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "grids.xml");
                OSDArray sysGrids     = (OSDArray)OSDParser.DeserializeLLSDXml(File.ReadAllText(sysGridsFile));
                for (int i = 0; i < sysGrids.Count; i++)
                {
                    RegisterGrid(Grid.FromOSD(sysGrids[i]));
                }
            }
            catch (Exception ex)
            {
                Logger.Log(string.Format("Error loading grid information: {0}", ex.Message), Helpers.LogLevel.Warning);
            }
        }
Esempio n. 7
0
        public byte[] HandleWebFetchInventoryDescendents(string request, UUID AgentID)
        {
            try
            {
                //m_log.DebugFormat("[InventoryCAPS]: Received WebFetchInventoryDescendents request for {0}", AgentID);

                OSDMap   map = (OSDMap)OSDParser.DeserializeLLSDXml(request);
                OSDArray foldersrequested = (OSDArray)map["folders"];

                return(Aurora.DataManager.DataManager.RequestPlugin <IInventoryData>().FetchInventoryReply(foldersrequested, AgentID));
            }
            catch (Exception ex)
            {
                m_log.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex.ToString());
            }
            OSDMap rmap = new OSDMap();

            rmap["folders"] = new OSDArray();
            return(OSDParser.SerializeLLSDXmlBytes(rmap));
        }
Esempio n. 8
0
        /// <summary>
        /// Sets or gets per face media textures.
        /// </summary>
        protected void HandleObjectMediaMessage(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID)
        {
//            m_log.DebugFormat("[MOAP]: Got ObjectMedia path [{0}], raw request [{1}]", path, request);

            try
            {
                OSDMap             osd = (OSDMap)OSDParser.DeserializeLLSDXml(httpRequest.InputStream);
                ObjectMediaMessage omm = new ObjectMediaMessage();
                omm.Deserialize(osd);

                if (omm.Request is ObjectMediaRequest)
                {
                    string ret = HandleObjectMediaRequest(omm.Request as ObjectMediaRequest);
                    if (!string.IsNullOrEmpty(ret))
                    {
                        httpResponse.RawBuffer  = Util.UTF8.GetBytes(ret);
                        httpResponse.StatusCode = (int)HttpStatusCode.OK;
                        return;
                    }
                }
                else if (omm.Request is ObjectMediaUpdate)
                {
                    if (HandleObjectMediaUpdate(omm.Request as ObjectMediaUpdate, agentID))
                    {
                        httpResponse.StatusCode = (int)HttpStatusCode.OK;
                        return;
                    }
                }
                else
                {
                    m_log.ErrorFormat(
                        "[MOAP]: ObjectMediaMessage has unrecognized ObjectMediaBlock of {0}",
                        omm.Request.GetType());
                }
            }
            catch
            {
            }
            httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
            return;
        }
        public IUserProfileInfo GetUserProfile(UUID agentID)
        {
            object remoteValue = DoRemote(agentID);

            if (remoteValue != null || m_doRemoteOnly)
            {
                return((IUserProfileInfo)remoteValue);
            }

            IUserProfileInfo UserProfile = new IUserProfileInfo();

            //Try from the user profile first before getting from the DB
            if (UserProfilesCache.TryGetValue(agentID, out UserProfile))
            {
                return(UserProfile);
            }

            QueryFilter filter = new QueryFilter();

            filter.andFilters["ID"]    = agentID;
            filter.andFilters["`Key`"] = "LLProfile";
            List <string> query = null;

            //Grab it from the almost generic interface
            query = GD.Query(new[] { "Value" }, "userdata", filter, null, null, null);

            if (query == null || query.Count == 0)
            {
                return(null);
            }
            //Pull out the OSDmap
            OSDMap profile = (OSDMap)OSDParser.DeserializeLLSDXml(query[0]);

            UserProfile = new IUserProfileInfo();
            UserProfile.FromOSD(profile);

            //Add to the cache
            UserProfilesCache[agentID] = UserProfile;

            return(UserProfile);
        }
Esempio n. 10
0
        public string HandleFetchInventory(string request, UUID AgentID)
        {
            try
            {
                //m_log.DebugFormat("[InventoryCAPS]: Received FetchInventory request for {0}", AgentID);

                OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(OpenMetaverse.Utils.StringToBytes(request));

                OSDArray foldersrequested = (OSDArray)requestmap["items"];

                string response = "";
                OSDMap map      = new OSDMap();
                //We have to send the agent_id in the main map as well as all the items
                map.Add("agent_id", OSD.FromUUID(AgentID));

                OSDArray items = new OSDArray();
                for (int i = 0; i < foldersrequested.Count; i++)
                {
                    OSDMap            requestedFolders = (OSDMap)foldersrequested[i];
                    UUID              owner_id         = requestedFolders["owner_id"].AsUUID();
                    UUID              item_id          = requestedFolders["item_id"].AsUUID();
                    InventoryItemBase item             = m_inventoryService.GetItem(new InventoryItemBase(item_id, owner_id));
                    if (item != null)
                    {
                        items.Add(ConvertInventoryItem(item, owner_id));
                    }
                }
                map.Add("items", items);

                response = OSDParser.SerializeLLSDXmlString(map);
                return(response);
            }
            catch (Exception ex)
            {
                m_log.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex.ToString());
            }
            OSDMap rmap = new OSDMap();

            rmap["items"] = new OSDArray();
            return(OSDParser.SerializeLLSDXmlString(rmap));
        }
Esempio n. 11
0
        public byte [] HandleFetchInventoryDescendents(Stream request, UUID agentID)
        {
            OSDMap   map = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
            OSDArray foldersrequested = (OSDArray)map ["folders"];

            try {
                //MainConsole.Instance.DebugFormat("[InventoryCAPS]: Received WebFetchInventoryDescendents request for {0}", AgentID);
                return(m_inventoryData.FetchInventoryReply(foldersrequested, agentID,
                                                           UUID.Zero, m_libraryService.LibraryOwner));
            } catch (Exception ex) {
                MainConsole.Instance.Warn("[InventoryCAPS]: SERIOUS ISSUE! " + ex);
            } finally {
                map = null;
                foldersrequested = null;
            }

            OSDMap rmap = new OSDMap();

            rmap ["folders"] = new OSDArray();
            return(OSDParser.SerializeLLSDXmlBytes(rmap));
        }
Esempio n. 12
0
        public List <AvatarArchive> GetAvatarArchives()
        {
            List <AvatarArchive> archives = new List <AvatarArchive>();

            foreach (string file in Directory.GetFiles(Environment.CurrentDirectory, "*.aa"))
            {
                try
                {
                    AvatarArchive archive = new AvatarArchive();
                    archive.FromOSD((OSDMap)OSDParser.DeserializeLLSDXml(File.ReadAllText(file)));
                    if (archive.IsPublic)
                    {
                        archives.Add(archive);
                    }
                }
                catch
                {
                }
            }
            return(archives);
        }
Esempio n. 13
0
        public byte [] CreateInventoryCategory(string path, Stream request, OSHttpRequest httpRequest,
                                               OSHttpResponse httpResponse)
        {
            OSDMap map       = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
            UUID   folder_id = map ["folder_id"].AsUUID();
            UUID   parent_id = map ["parent_id"].AsUUID();
            int    type      = map ["type"].AsInteger();
            string name      = map ["name"].AsString();

            InventoryFolderBase newFolder = new InventoryFolderBase(folder_id, name, m_agentID, (short)type, parent_id, 1);

            m_inventoryService.AddFolder(newFolder);
            OSDMap resp = new OSDMap();

            resp ["folder_id"] = folder_id;
            resp ["parent_id"] = parent_id;
            resp ["type"]      = type;
            resp ["name"]      = name;

            return(OSDParser.SerializeLLSDXmlBytes(map));
        }
Esempio n. 14
0
        /// <summary>
        /// Gets the info about the agent (TOS data, maturity info, language, etc)
        /// </summary>
        /// <param name="agentID"></param>
        /// <returns></returns>
        public IAgentInfo GetAgent(UUID agentID)
        {
            IAgentInfo    agent = new IAgentInfo();
            List <string> query = null;

            try
            {
                query = GD.Query(new string[] { "ID", "`Key`" }, new object[] { agentID, "AgentInfo" }, "userdata", "Value");
            }
            catch
            {
            }
            if (query == null || query.Count == 0)
            {
                return(null); //Couldn't find it, return null then.
            }
            OSDMap agentInfo = (OSDMap)OSDParser.DeserializeLLSDXml(query[0]);

            agent.FromOSD(agentInfo);
            return(agent);
        }
Esempio n. 15
0
        /// <summary>
        /// Find the materials used in one Face, and add them to 'm_regionMaterials'.
        /// </summary>
        private void GetStoredMaterialInFace(SceneObjectPart part, Primitive.TextureEntryFace face)
        {
            UUID id = face.MaterialID;

            if (id == UUID.Zero)
            {
                return;
            }

            lock (m_Materials)
            {
                if (m_Materials.ContainsKey(id))
                {
                    m_MaterialsRefCount[id]++;
                    return;
                }

                AssetBase matAsset = m_scene.AssetService.Get(id.ToString());
                if (matAsset == null || matAsset.Data == null || matAsset.Data.Length == 0)
                {
                    //m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id);
                    return;
                }

                byte[] data = matAsset.Data;
                OSDMap mat;
                try
                {
                    mat = (OSDMap)OSDParser.DeserializeLLSDXml(data);
                }
                catch (Exception e)
                {
                    m_log.WarnFormat("[Materials]: cannot decode material asset {0}: {1}", id, e.Message);
                    return;
                }

                m_Materials[id]         = mat;
                m_MaterialsRefCount[id] = 1;
            }
        }
Esempio n. 16
0
        private byte[] UpdateAvatarAppearance(string path, Stream request, OSHttpRequest httpRequest,
                                              OSHttpResponse httpResponse)
        {
            try
            {
                OSDMap rm          = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
                int    cof_version = rm["cof_version"].AsInteger();

                bool             success    = false;
                string           error      = "";
                AvatarAppearance appearance = m_appearanceService.BakeAppearance(m_agentID, cof_version);

                OSDMap map = new OSDMap();
                if (appearance == null)
                {
                    map["success"]  = false;
                    map["error"]    = "Wrong COF";
                    map["agent_id"] = m_agentID;
                    return(OSDParser.SerializeLLSDXmlBytes(map));
                }

                OSDMap uaamap = new OSDMap();
                uaamap["Method"]     = "UpdateAvatarAppearance";
                uaamap["AgentID"]    = m_agentID;
                uaamap["Appearance"] = appearance.ToOSD();
                m_syncMessage.Post(m_region.ServerURI, uaamap);
                success = true;

                map["success"]  = success;
                map["error"]    = error;
                map["agent_id"] = m_agentID;
                return(OSDParser.SerializeLLSDXmlBytes(map));
            }
            catch (Exception e)
            {
                MainConsole.Instance.Error("[CAPS]: " + e);
            }

            return(null);
        }
Esempio n. 17
0
        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));
        }
Esempio n. 18
0
        private byte[] UpdateAvatarAppearance(string path, Stream request, OSHttpRequest httpRequest,
                                              OSHttpResponse httpResponse)
        {
            try
            {
                OSDMap rm          = (OSDMap)OSDParser.DeserializeLLSDXml(request);
                int    cof_version = rm["cof_version"].AsInteger();

                bool             success    = false;
                string           error      = "";
                AvatarAppearance appearance = m_appearanceService.BakeAppearance(m_agentID, cof_version);


                OSDMap uaamap = new OSDMap();
                uaamap["Method"]     = "UpdateAvatarAppearance";
                uaamap["AgentID"]    = m_agentID;
                uaamap["Appearance"] = appearance.ToOSD();
                m_syncMessage.Post(m_region.ServerURI, uaamap);
                success = true;

                OSDMap map = new OSDMap();
                map["success"]  = success;
                map["error"]    = error;
                map["agent_id"] = m_agentID;

                /*map["avatar_scale"] = appearance.AvatarHeight;
                 * map["textures"] = newBakeIDs.ToOSDArray();
                 * OSDArray visualParams = new OSDArray();
                 * foreach(byte b in appearance.VisualParams)
                 *  visualParams.Add((int)b);
                 * map["visual_params"] = visualParams;*/
                return(OSDParser.SerializeLLSDXmlBytes(map));
            }
            catch (Exception e)
            {
                MainConsole.Instance.Error("[CAPS]: " + e);
            }

            return(null);
        }
Esempio n. 19
0
        public string HandleFetchLibDescendents(string request, UUID AgentID)
        {
            try
            {
                //m_log.DebugFormat("[InventoryCAPS]: Received FetchLibDescendents request for {0}", AgentID);

                OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(OpenMetaverse.Utils.StringToBytes(request));

                OSDArray foldersrequested = (OSDArray)map["folders"];

                string response = FetchInventoryReply(foldersrequested, AgentID, true);
                return(response);
            }
            catch (Exception ex)
            {
                m_log.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex.ToString());
            }
            OSDMap rmap = new OSDMap();

            rmap["folders"] = new OSDArray();
            return(OSDParser.SerializeLLSDXmlString(rmap));
        }
Esempio n. 20
0
        public bool DelinkRegion(UUID regionID, string password)
        {
            List <string> query = null;

            try
            {
                //First make sure they are in the estate
                query = GD.Query(new string[] { "ID", "`Key`" }, new object[] { regionID, "EstateID" }, "estates", "Value");
            }
            catch
            {
            }
            if (query == null || query.Count == 0)
            {
                return(false); //Couldn't find it, return default then.
            }
            try
            {
                //Now pull the estate settings to check the password
                query = GD.Query(new string[] { "ID", "`Key`" }, new object[] { query[0], "EstateSettings" }, "estates", "Value");
            }
            catch
            {
            }

            OSDMap estateInfo = (OSDMap)OSDParser.DeserializeLLSDXml(query[0]);

            if (estateInfo["EstatePass"].AsString() != password)
            {
                return(false); //fakers!
            }
            GD.Delete("estates", new string[] { "ID", "Key" },
                      new object[] {
                regionID,
                "EstateID"
            });

            return(true);
        }
Esempio n. 21
0
        public byte[] NewAgentInventoryRequestVariablePrice(string path, Stream request, OSHttpRequest httpRequest,
                                                            OSHttpResponse httpResponse)
        {
            OSDMap map          = (OSDMap)OSDParser.DeserializeLLSDXml(request);
            string asset_type   = map["asset_type"].AsString();
            int    charge       = 0;
            int    resourceCost = 0;

            if (!ChargeUser(asset_type, map, out charge, out resourceCost))
            {
                map             = new OSDMap();
                map["uploader"] = "";
                map["state"]    = "error";
                return(OSDParser.SerializeLLSDXmlBytes(map));
            }
            OSDMap resp = InternalNewAgentInventoryRequest(map, httpRequest, httpResponse);

            resp["resource_cost"] = resourceCost;
            resp["upload_price"]  = charge; //Set me if you want to use variable cost stuff

            return(OSDParser.SerializeLLSDXmlBytes(map));
        }
Esempio n. 22
0
        public byte [] HandleFetchLib(Stream request, UUID agentID)
        {
            try {
                // MainConsole.Instance.DebugFormat("[InventoryCAPS]: Received FetchLib request for {0}", agentID);
                OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
                if (requestmap ["items"].Type == OSDType.Unknown)
                {
                    MainConsole.Instance.Error("[InventoryCAPS]: Call to 'FetchLib' with missing 'items' parameter");
                    return(MainServer.BadRequest);
                }
                OSDArray foldersrequested = (OSDArray)requestmap ["items"];
                OSDMap   map = new OSDMap {
                    { "agent_id", OSD.FromUUID(agentID) }
                };
                OSDArray items = new OSDArray();

                foreach (
                    OSDArray item in
                    foldersrequested.Cast <OSDMap> ()
                    .Select(requestedFolders => requestedFolders ["item_id"].AsUUID())
                    .Select(item_id => m_inventoryService.GetOSDItem(UUID.Zero, item_id))
                    .Where(item => item != null && item.Count > 0))
                {
                    items.Add(item [0]);
                }
                map.Add("items", items);

                byte [] response = OSDParser.SerializeLLSDXmlBytes(map);
                map.Clear();
                return(response);
            } catch (Exception ex) {
                MainConsole.Instance.Warn("[InventoryCAPS]: SERIOUS ISSUE! " + ex);
            }

            OSDMap rmap = new OSDMap();

            rmap ["items"] = new OSDArray();
            return(OSDParser.SerializeLLSDXmlBytes(rmap));
        }
Esempio n. 23
0
        protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            StreamReader reader      = new StreamReader(request);
            string       requestBody = reader.ReadToEnd();

            OSD osd = OSDParser.DeserializeLLSDXml(requestBody);

            string      action    = ((OSDMap)osd)["action"].AsString();
            OSDArray    selection = (OSDArray)((OSDMap)osd)["selection"];
            List <uint> sel       = new List <uint>();

            for (int i = 0; i < selection.Count; i++)
            {
                sel.Add(selection[i].AsUInteger());
            }

            Util.FireAndForget(x => { m_module.HandleMenuSelection(action, m_agentID, sel); });

            Encoding encoding = Encoding.UTF8;

            return(encoding.GetBytes(OSDParser.SerializeLLSDXmlString(new OSD())));
        }
Esempio n. 24
0
        private byte[] ProcessSendUserReportWithScreenshot(UUID AgentID, string path, Stream request, OSHttpRequest httpRequest,
                                                           OSHttpResponse httpResponse)
        {
            IScenePresence SP           = findScenePresence(AgentID);
            OSDMap         map          = (OSDMap)OSDParser.DeserializeLLSDXml(request);
            string         RegionName   = map["abuse-region-name"];
            UUID           AbuserID     = map["abuser-id"];
            uint           Category     = map["category"];
            uint           CheckFlags   = map["check-flags"];
            string         details      = map["details"];
            UUID           objectID     = map["object-id"];
            Vector3        position     = map["position"];
            uint           ReportType   = map["report-type"];
            UUID           ScreenShotID = map["screenshot-id"];
            string         summary      = map["summary"];

            UserReport(SP.ControllingClient, SP.Scene.RegionInfo.RegionName, AbuserID, (byte)Category, (byte)CheckFlags,
                       details, objectID, position, (byte)ReportType, ScreenShotID, summary, SP.UUID);

            if (ScreenShotID != UUID.Zero)
            {
                string uploadpath             = "/CAPS/Upload/" + UUID.Random() + "/";
                AbuseTextureUploader uploader = new AbuseTextureUploader(uploadpath, SP.UUID, ScreenShotID);
                uploader.OnUpLoad += AbuseTextureUploaded;

                MainServer.Instance.AddStreamHandler(new GenericStreamHandler("POST", uploadpath,
                                                                              uploader.uploaderCaps));

                string uploaderURL = MainServer.Instance.ServerURI + uploadpath;
                OSDMap resp        = new OSDMap();
                resp["uploader"] = uploaderURL;
                resp["state"]    = "upload";
                return(OSDParser.SerializeLLSDXmlBytes(resp));
            }
            else
            {
                return(MainServer.BlankResponse);
            }
        }
Esempio n. 25
0
        public void DeserializeStrings()
        {
            OSD       theSD   = null;
            OSDArray  array   = null;
            OSDString tempStr = null;

            String testSD = @"<?xml version='1.0' encoding='UTF-8'?>
            <llsd>
                <array>
                    <string>Kissling</string>
                    <string>Attack ships on fire off the shoulder of Orion</string>
                    <string>&lt; &gt; &amp; &apos; &quot;</string>
                    <string/>
                </array>
            </llsd>";

            //Deserialize the string
            byte[] bytes = Encoding.UTF8.GetBytes(testSD);
            theSD = OSDParser.DeserializeLLSDXml(bytes);

            Assert.IsTrue(theSD is OSDArray);
            array = (OSDArray)theSD;

            Assert.AreEqual(OSDType.String, array[0].Type);
            tempStr = (OSDString)array[0];
            Assert.AreEqual("Kissling", tempStr.AsString());

            Assert.AreEqual(OSDType.String, array[1].Type);
            tempStr = (OSDString)array[1];
            Assert.AreEqual("Attack ships on fire off the shoulder of Orion", tempStr.AsString());

            Assert.AreEqual(OSDType.String, array[2].Type);
            tempStr = (OSDString)array[2];
            Assert.AreEqual("< > & \' \"", tempStr.AsString());

            Assert.AreEqual(OSDType.String, array[3].Type);
            tempStr = (OSDString)array[3];
            Assert.AreEqual("", tempStr.AsString());
        }
Esempio n. 26
0
        /// <summary>
        ///     Converts an XML string to an OSD object whilst sanitizing the XML-LLSD
        /// </summary>
        /// <param name="data">the XML string to covnert</param>
        /// <returns>the OSD object</returns>
        public static OpenMetaverse.StructuredData.OSD XMLToOSD(string data)
        {
            XDocument doc;

            using (var reader = new StringReader(data))
            {
                doc = XDocument.Load(reader);
            }

            OSDSanitizeMap.AsParallel().ForAll(o => { XML.RenameNodes(doc.Root, o.Key, o.Value); });

            using (var memoryStream = new MemoryStream())
            {
                using (TextWriter textWriter = new StreamWriter(memoryStream, Encoding.UTF8))
                {
                    doc.Save(textWriter);
                }
                data = Utils.BytesToString(memoryStream.ToArray());
            }

            return(OSDParser.DeserializeLLSDXml(data));
        }
Esempio n. 27
0
        public byte[] HandleFetchLib(string request, UUID AgentID)
        {
            try
            {
                //m_log.DebugFormat("[InventoryCAPS]: Received FetchLib request for {0}", AgentID);

                OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(OpenMetaverse.Utils.StringToBytes(request));

                OSDArray foldersrequested = (OSDArray)requestmap["items"];

                OSDMap map = new OSDMap();
                map.Add("agent_id", OSD.FromUUID(AgentID));
                OSDArray items = new OSDArray();
                for (int i = 0; i < foldersrequested.Count; i++)
                {
                    OSDMap requestedFolders = (OSDMap)foldersrequested[i];
                    //UUID owner_id = requestedFolders["owner_id"].AsUUID();
                    UUID     item_id = requestedFolders["item_id"].AsUUID();
                    OSDArray item    = m_inventoryService.GetItem(item_id);
                    if (item != null && item.Count > 0)
                    {
                        items.Add(item[0]);
                    }
                }
                map.Add("items", items);

                byte[] response = OSDParser.SerializeLLSDXmlBytes(map);
                map.Clear();
                return(response);
            }
            catch (Exception ex)
            {
                m_log.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex.ToString());
            }
            OSDMap rmap = new OSDMap();

            rmap["items"] = new OSDArray();
            return(OSDParser.SerializeLLSDXmlBytes(rmap));
        }
Esempio n. 28
0
        private byte[] HomeLocation(Stream request, UUID agentID)
        {
            OSDMap rm           = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
            OSDMap HomeLocation = rm["HomeLocation"] as OSDMap;

            if (HomeLocation != null)
            {
                OSDMap  pos      = HomeLocation["LocationPos"] as OSDMap;
                Vector3 position = new Vector3((float)pos["X"].AsReal(),
                                               (float)pos["Y"].AsReal(),
                                               (float)pos["Z"].AsReal());
                OSDMap  lookat = HomeLocation["LocationLookAt"] as OSDMap;
                Vector3 lookAt = new Vector3((float)lookat["X"].AsReal(),
                                             (float)lookat["Y"].AsReal(),
                                             (float)lookat["Z"].AsReal());

                m_agentInfoService.SetHomePosition(agentID.ToString(), m_service.Region.RegionID, position, lookAt);
            }

            rm.Add("success", OSD.FromBoolean(true));
            return(OSDParser.SerializeLLSDXmlBytes(rm));
        }
Esempio n. 29
0
        public byte[] HandleFetchLib(Stream request, UUID AgentID)
        {
            try
            {
                //MainConsole.Instance.DebugFormat("[InventoryCAPS]: Received FetchLib request for {0}", AgentID);

                OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(request);

                OSDArray foldersrequested = (OSDArray)requestmap["items"];

                OSDMap map = new OSDMap {
                    { "agent_id", OSD.FromUUID(AgentID) }
                };
                OSDArray items = new OSDArray();

                foreach (
                    OSDArray item in
                    foldersrequested.Cast <OSDMap>()
                    .Select(requestedFolders => requestedFolders["item_id"].AsUUID())
                    .Select(item_id => m_inventoryService.GetOSDItem(UUID.Zero, item_id))
                    .Where(item => item != null && item.Count > 0))
                {
                    items.Add(item[0]);
                }
                map.Add("items", items);

                byte[] response = OSDParser.SerializeLLSDXmlBytes(map);
                map.Clear();
                return(response);
            }
            catch (Exception ex)
            {
                MainConsole.Instance.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex);
            }
            OSDMap rmap = new OSDMap();

            rmap["items"] = new OSDArray();
            return(OSDParser.SerializeLLSDXmlBytes(rmap));
        }
Esempio n. 30
0
        public void SaveEstateSettings(OpenSim.Framework.EstateSettings es)
        {
            List <string> query = null;

            try
            {
                query = GD.Query(new string[] { "ID", "`Key`" }, new object[] { es.EstateID, "EstateSettings" }, "estates", "Value");
            }
            catch
            {
            }
            if (query == null || query.Count == 0)
            {
                return; //Couldn't find it, return default then.
            }
            OSDMap estateInfo = (OSDMap)OSDParser.DeserializeLLSDXml(query[0]);

            if (estateInfo["EstatePass"].AsString() != es.EstatePass)
            {
                m_log.Warn("[ESTATE SERVICE]: Wrong estate password in updating of estate " + es.EstateName + "! Possible attempt to hack this estate!");
                return;
            }

            List <string> Keys = new List <string>();

            Keys.Add("Value");
            List <object> Values = new List <object>();

            Values.Add(OSDParser.SerializeLLSDXmlString(Util.DictionaryToOSD(es.ToKeyValuePairs(true))));

            GD.Update("estates", Values.ToArray(), Keys.ToArray(), new string[] { "ID", "`Key`" }, new object[] { es.EstateID, "EstateSettings" });

            SaveBanList(es);
            SaveUUIDList(es.EstateID, "EstateManagers", es.EstateManagers);
            SaveUUIDList(es.EstateID, "EstateAccess", es.EstateAccess);
            SaveUUIDList(es.EstateID, "EstateGroups", es.EstateGroups);

            m_registry.RequestModuleInterface <ISimulationBase>().EventManager.FireGenericEventHandler("EstateUpdated", es);
        }