Ejemplo n.º 1
0
        public override byte [] Handle(string path, Stream request,
                                       OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            var body = HttpServerHandlerHelpers.ReadString(request).Trim();

            try {
                var args = WebUtils.GetOSDMap(body, false);
                if (args != null)
                {
                    return(HandleMap(args));
                }
            } catch (Exception ex) {
                MainConsole.Instance.Warn("[ServerHandler]: Error occurred: " + ex);
            }
            return(MainServer.BadRequest);
        }
Ejemplo n.º 2
0
        public byte[] ChatSessionRequest(string path, Stream request, OSHttpRequest httpRequest,
                                         OSHttpResponse httpResponse)
        {
            try
            {
                OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));

                return(Encoding.UTF8.GetBytes(m_imService.ChatSessionRequest(m_service, rm)));
            }
            catch (Exception e)
            {
                MainConsole.Instance.Error("[IMCAPS]: " + e.ToString());
            }

            return(null);
        }
        private byte[] UntrustedSimulatorMessage(UUID AgentID, Stream request)
        {
            OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));

            if (rm["message"] == "GodKickUser")
            {
                OSDArray innerArray = ((OSDArray)((OSDMap)rm["body"])["UserInfo"]);
                OSDMap   innerMap   = (OSDMap)innerArray[0];
                UUID     toKick     = innerMap["AgentID"].AsUUID();
                UUID     sessionID  = innerMap["GodSessionID"].AsUUID();
                string   reason     = innerMap["Reason"].AsString();
                uint     kickFlags  = innerMap["KickFlags"].AsUInteger();
                KickUser(AgentID, sessionID, toKick, kickFlags, reason);
            }
            return(new byte[0]);
        }
Ejemplo n.º 4
0
            /// <summary>
            /// </summary>
            /// <param name="path"></param>
            /// <param name="request"></param>
            /// <param name="httpRequest"></param>
            /// <param name="httpResponse"></param>
            /// <returns></returns>
            public byte[] uploaderCaps(string path, Stream request,
                                       OSHttpRequest httpRequest, OSHttpResponse httpResponse)
            {
                handlerUpLoad = OnUpLoad;
                handlerUpLoad(m_agentID, m_assetID, HttpServerHandlerHelpers.ReadFully(request));

                OSDMap map = new OSDMap();

                map["new_asset"] = m_assetID.ToString();
                map["item_id"]   = UUID.Zero;
                map["state"]     = "complete";

                MainServer.Instance.RemoveStreamHandler("POST", uploaderPath);

                return(OSDParser.SerializeLLSDXmlBytes(map));
            }
Ejemplo n.º 5
0
        private byte[] GetObjectPhysicsData(UUID agentID, Stream request)
        {
            OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));

            OSDArray keys = (OSDArray)rm["object_ids"];

            IEventQueueService eqs = m_scene.RequestModuleInterface <IEventQueueService>();

            if (eqs != null)
            {
                eqs.ObjectPhysicsProperties(keys.Select(key => m_scene.GetSceneObjectPart(key.AsUUID())).ToArray(),
                                            agentID, m_scene.RegionInfo.RegionID);
            }
            //Send back data
            return(new byte[0]);
        }
Ejemplo n.º 6
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;

                /*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);
        }
Ejemplo n.º 7
0
        byte [] HandleHttpCloseSession(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            DoExpire();

            Hashtable post = DecodePostString(HttpServerHandlerHelpers.ReadString(request));

            httpResponse.StatusCode  = 401;
            httpResponse.ContentType = "text/plain";
            if (post ["ID"] == null)
            {
                return(MainServer.BlankResponse);
            }

            UUID id;

            if (!UUID.TryParse(post ["ID"].ToString(), out id))
            {
                return(MainServer.BlankResponse);
            }

            lock (m_Connections) {
                if (m_Connections.ContainsKey(id))
                {
                    m_Connections.Remove(id);
                    CloseConnection(id);
                }
            }

            XmlDocument xmldoc  = new XmlDocument();
            XmlNode     xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");

            xmldoc.AppendChild(xmlnode);
            XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession", "");

            xmldoc.AppendChild(rootElement);

            XmlElement res = xmldoc.CreateElement("", "Result", "");

            res.AppendChild(xmldoc.CreateTextNode("OK"));

            rootElement.AppendChild(res);

            httpResponse.StatusCode  = 200;
            httpResponse.ContentType = "text/xml";
            return(Encoding.UTF8.GetBytes(xmldoc.InnerXml));
        }
Ejemplo n.º 8
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="data"></param>
            /// <param name="path"></param>
            /// <param name="param"></param>
            /// <returns></returns>
            public byte[] uploaderCaps(string path, Stream request,
                                       OSHttpRequest httpRequest, OSHttpResponse httpResponse)
            {
                handlerUpLoad = OnUpLoad;
                UUID newAssetID;

                handlerUpLoad(HttpServerHandlerHelpers.ReadFully(request), out newAssetID);

                OSDMap map = new OSDMap();

                map["new_asset"] = newAssetID.ToString();
                map["item_id"]   = UUID.Zero;
                map["state"]     = "complete";
                clientCaps.RemoveStreamHandler(uploadMethod, "POST", uploaderPath);

                return(OSDParser.SerializeLLSDXmlBytes(map));
            }
Ejemplo n.º 9
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(HttpServerHandlerHelpers.ReadFully(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(""));
        }
Ejemplo n.º 10
0
        public byte [] HandleFetchLibDescendents(Stream request, UUID agentID)
        {
            try {
                //MainConsole.Instance.DebugFormat("[InventoryCAPS]: Received FetchLibDescendents request for {0}", agentID);
                OSDMap   map = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
                OSDArray foldersrequested = (OSDArray)map ["folders"];

                return(m_inventoryData.FetchInventoryReply(foldersrequested,
                                                           m_libraryService.LibraryOwner,
                                                           agentID, m_libraryService.LibraryOwner));
            } catch (Exception ex) {
                MainConsole.Instance.Warn("[InventoryCAPS]: SERIOUS ISSUE! " + ex);
            }

            OSDMap rmap = new OSDMap();

            rmap ["folders"] = new OSDArray();
            return(OSDParser.SerializeLLSDXmlBytes(rmap));
        }
Ejemplo n.º 11
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));
        }
Ejemplo n.º 12
0
            ///<summary>
            ///</summary>
            ///<param name = "data"></param>
            ///<param name = "path"></param>
            ///<param name = "param"></param>
            ///<returns></returns>
            public byte[] uploaderCaps(string path, Stream request,
                                       OSHttpRequest httpRequest, OSHttpResponse httpResponse)
            {
                UUID inv = inventoryItemID;

                byte[] data = HttpServerHandlerHelpers.ReadFully(request);
                clientCaps.RemoveStreamHandler(uploadMethod, "POST", uploaderPath);

                newAssetID = m_invCaps.UploadCompleteHandler(m_assetName, m_assetDes, newAssetID, inv, parentFolder,
                                                             data, m_invType, m_assetType, m_everyone_mask, m_group_mask,
                                                             m_next_owner_mask);

                OSDMap map = new OSDMap();

                map["new_asset"]          = newAssetID.ToString();
                map["new_inventory_item"] = inv;
                map["state"] = "complete";

                return(OSDParser.SerializeLLSDXmlBytes(map));
            }
Ejemplo 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));
        }
Ejemplo n.º 14
0
        public byte[] NewAgentInventoryRequestVariablePrice(string path, Stream request, OSHttpRequest httpRequest,
                                                            OSHttpResponse httpResponse)
        {
            OSDMap map          = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(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));
        }
Ejemplo n.º 15
0
        private byte[] ProcessSendUserReportWithScreenshot(UUID AgentID, string path, Stream request, OSHttpRequest httpRequest,
                                                           OSHttpResponse httpResponse)
        {
            IScenePresence SP  = findScenePresence(AgentID);
            OSDMap         map = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(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);
            }
        }
Ejemplo n.º 16
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));
        }
Ejemplo n.º 17
0
        public byte[] FreeSwitchConfigHTTPHandler(string path, Stream request, OSHttpRequest httpRequest,
                                                  OSHttpResponse httpResponse)
        {
            Hashtable requestBody = ParseRequestBody(HttpServerHandlerHelpers.ReadString(request));

            string section = httpRequest.QueryString["section"];

            if (section == "directory")
            {
                return(m_FreeswitchService.HandleDirectoryRequest(requestBody, httpRequest, httpResponse));
            }
            else if (section == "dialplan")
            {
                return(m_FreeswitchService.HandleDialplanRequest(requestBody, httpRequest, httpResponse));
            }
            else
            {
                MainConsole.Instance.WarnFormat("[FreeSwitchVoice]: section was {0}", section);
            }

            return(MainServer.BadRequest);
        }
Ejemplo n.º 18
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));
        }
Ejemplo n.º 19
0
        private byte[] ProcessUpdateAgentLanguage(Stream request, UUID agentID)
        {
            OSDMap rm = OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request)) as OSDMap;

            if (rm == null)
            {
                return(MainServer.BadRequest);
            }
            IAgentConnector AgentFrontend = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>();

            if (AgentFrontend != null)
            {
                IAgentInfo IAI = AgentFrontend.GetAgent(agentID);
                if (IAI == null)
                {
                    return(MainServer.BadRequest);
                }
                IAI.Language         = rm["language"].AsString();
                IAI.LanguageIsPublic = int.Parse(rm["language_is_public"].AsString()) == 1;
                AgentFrontend.UpdateAgent(IAI);
            }
            return(MainServer.BlankResponse);
        }
Ejemplo n.º 20
0
        public byte [] HandleFetchLibDescendents(Stream request, UUID agentID)
        {
            try {
                // MainConsole.Instance.DebugFormat("[InventoryCAPS]: Received FetchLibDescendents request for {0}", agentID);
                OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
                if (map ["folders"].Type == OSDType.Unknown)
                {
                    MainConsole.Instance.Error("[InventoryCAPS]: Call to 'FetchLibDescendants' with missing 'folders' parameter");
                    return(MainServer.BadRequest);
                }
                OSDArray foldersrequested = (OSDArray)map ["folders"];

                return(m_inventoryData.FetchInventoryReply(foldersrequested, m_libraryService.LibraryOwnerUUID,
                                                           agentID, m_libraryService.LibraryOwnerUUID));
            } catch (Exception ex) {
                MainConsole.Instance.Warn("[InventoryCAPS]: SERIOUS ISSUE! " + ex);
            }

            OSDMap rmap = new OSDMap();

            rmap ["folders"] = new OSDArray();
            return(OSDParser.SerializeLLSDXmlBytes(rmap));
        }
Ejemplo n.º 21
0
        private byte[] DispatchOpenRegionSettings(Stream request, UUID agentID)
        {
            IScenePresence SP = m_scene.GetScenePresence(agentID);

            if (SP == null || !SP.Scene.Permissions.CanIssueEstateCommand(SP.UUID, false))
            {
                return(new byte[0]);
            }

            OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));

            m_settings.DefaultDrawDistance           = rm["draw_distance"].AsInteger();
            m_settings.ForceDrawDistance             = rm["force_draw_distance"].AsBoolean();
            m_settings.DisplayMinimap                = rm["allow_minimap"].AsBoolean();
            m_settings.AllowPhysicalPrims            = rm["allow_physical_prims"].AsBoolean();
            m_settings.MaxDragDistance               = (float)rm["max_drag_distance"].AsReal();
            m_settings.MinimumHoleSize               = (float)rm["min_hole_size"].AsReal();
            m_settings.MaximumHollowSize             = (float)rm["max_hollow_size"].AsReal();
            m_settings.MaximumInventoryItemsTransfer = rm["max_inventory_items_transfer"].AsInteger();
            m_settings.MaximumLinkCount              = (int)rm["max_link_count"].AsReal();
            m_settings.MaximumLinkCountPhys          = (int)rm["max_link_count_phys"].AsReal();
            m_settings.MaximumPhysPrimScale          = (float)rm["max_phys_prim_scale"].AsReal();
            m_settings.MaximumPrimScale              = (float)rm["max_prim_scale"].AsReal();
            m_settings.MinimumPrimScale              = (float)rm["min_prim_scale"].AsReal();
            m_settings.RenderWater        = rm["render_water"].AsBoolean();
            m_settings.TerrainDetailScale = (float)rm["terrain_detail_scale"].AsReal();
            m_settings.ShowTags           = (int)rm["show_tags"].AsReal();
            m_settings.MaxGroups          = (int)rm["max_groups"].AsReal();
            m_settings.EnableTeenMode     = rm["enable_teen_mode"].AsBoolean();

            m_scene.RegionInfo.OpenRegionSettings = m_settings;

            //Update all clients about changes
            SendToAllClients();

            return(new byte[0]);
        }
Ejemplo n.º 22
0
        /// <summary>
        ///     Sets or gets per face media textures.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="path"></param>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <returns></returns>
        protected byte[] HandleObjectMediaMessage(string path, Stream request, OSHttpRequest httpRequest,
                                                  OSHttpResponse httpResponse)
        {
//            MainConsole.Instance.DebugFormat("[MOAP]: Got ObjectMedia path [{0}], raw request [{1}]", path, request);

            OSDMap             osd = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
            ObjectMediaMessage omm = new ObjectMediaMessage();

            omm.Deserialize(osd);

            if (omm.Request is ObjectMediaRequest)
            {
                return(HandleObjectMediaRequest(omm.Request as ObjectMediaRequest));
            }
            else if (omm.Request is ObjectMediaUpdate)
            {
                return(HandleObjectMediaUpdate(path, omm.Request as ObjectMediaUpdate));
            }

            throw new Exception(
                      string.Format(
                          "[MOAP]: ObjectMediaMessage has unrecognized ObjectMediaBlock of {0}",
                          omm.Request.GetType()));
        }
        /// <summary>
        ///     Parses ad request
        /// </summary>
        /// <param name="request"></param>
        /// <param name="response"></param>
        /// <param name="AgentId"></param>
        /// <returns></returns>
        public byte[] ProcessAdd(Stream request, OSHttpResponse response, UUID AgentId)
        {
            IScenePresence avatar;

            if (!m_scene.TryGetScenePresence(AgentId, out avatar))
            {
                return(MainServer.BlankResponse);
            }

            OSDMap r = (OSDMap)OSDParser.Deserialize(HttpServerHandlerHelpers.ReadFully(request));
            UploadObjectAssetMessage message = new UploadObjectAssetMessage();

            try
            {
                message.Deserialize(r);
            }
            catch (Exception ex)
            {
                MainConsole.Instance.Error("[UploadObjectAssetModule]: Error de-serializing message " + ex);
                message = null;
            }

            if (message == null)
            {
                response.StatusCode = 400; //501; //410; //404;
                return
                    (Encoding.UTF8.GetBytes(
                         "<llsd><map><key>error</key><string>Error parsing Object</string></map></llsd>"));
            }

            Vector3    pos     = avatar.AbsolutePosition + (Vector3.UnitX * avatar.Rotation);
            Quaternion rot     = Quaternion.Identity;
            Vector3    rootpos = Vector3.Zero;

            SceneObjectGroup rootGroup = null;

            SceneObjectGroup[] allparts = new SceneObjectGroup[message.Objects.Length];
            for (int i = 0; i < message.Objects.Length; i++)
            {
                UploadObjectAssetMessage.Object obj = message.Objects[i];
                PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();

                if (i == 0)
                {
                    rootpos = obj.Position;
                }


                // Combine the extraparams data into it's ugly blob again....
                //int bytelength = 0;
                //for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++)
                //{
                //    bytelength += obj.ExtraParams[extparams].ExtraParamData.Length;
                //}
                //byte[] extraparams = new byte[bytelength];
                //int position = 0;


                //for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++)
                //{
                //    Buffer.BlockCopy(obj.ExtraParams[extparams].ExtraParamData, 0, extraparams, position,
                //                     obj.ExtraParams[extparams].ExtraParamData.Length);
                //
                //    position += obj.ExtraParams[extparams].ExtraParamData.Length;
                // }

                //pbs.ExtraParams = extraparams;
                foreach (UploadObjectAssetMessage.Object.ExtraParam extraParam in obj.ExtraParams)
                {
                    switch ((ushort)extraParam.Type)
                    {
                    case (ushort)ExtraParamType.Sculpt:
                        Primitive.SculptData sculpt = new Primitive.SculptData(extraParam.ExtraParamData, 0);

                        pbs.SculptEntry = true;

                        pbs.SculptTexture = obj.SculptID;
                        pbs.SculptType    = (byte)sculpt.Type;

                        break;

                    case (ushort)ExtraParamType.Flexible:
                        Primitive.FlexibleData flex = new Primitive.FlexibleData(extraParam.ExtraParamData, 0);
                        pbs.FlexiEntry    = true;
                        pbs.FlexiDrag     = flex.Drag;
                        pbs.FlexiForceX   = flex.Force.X;
                        pbs.FlexiForceY   = flex.Force.Y;
                        pbs.FlexiForceZ   = flex.Force.Z;
                        pbs.FlexiGravity  = flex.Gravity;
                        pbs.FlexiSoftness = flex.Softness;
                        pbs.FlexiTension  = flex.Tension;
                        pbs.FlexiWind     = flex.Wind;
                        break;

                    case (ushort)ExtraParamType.Light:
                        Primitive.LightData light = new Primitive.LightData(extraParam.ExtraParamData, 0);
                        pbs.LightColorA    = light.Color.A;
                        pbs.LightColorB    = light.Color.B;
                        pbs.LightColorG    = light.Color.G;
                        pbs.LightColorR    = light.Color.R;
                        pbs.LightCutoff    = light.Cutoff;
                        pbs.LightEntry     = true;
                        pbs.LightFalloff   = light.Falloff;
                        pbs.LightIntensity = light.Intensity;
                        pbs.LightRadius    = light.Radius;
                        break;

                    case 0x40:
                        pbs.ReadProjectionData(extraParam.ExtraParamData, 0);
                        break;
                    }
                }
                pbs.PathBegin        = (ushort)obj.PathBegin;
                pbs.PathCurve        = (byte)obj.PathCurve;
                pbs.PathEnd          = (ushort)obj.PathEnd;
                pbs.PathRadiusOffset = (sbyte)obj.RadiusOffset;
                pbs.PathRevolutions  = (byte)obj.Revolutions;
                pbs.PathScaleX       = (byte)obj.ScaleX;
                pbs.PathScaleY       = (byte)obj.ScaleY;
                pbs.PathShearX       = (byte)obj.ShearX;
                pbs.PathShearY       = (byte)obj.ShearY;
                pbs.PathSkew         = (sbyte)obj.Skew;
                pbs.PathTaperX       = (sbyte)obj.TaperX;
                pbs.PathTaperY       = (sbyte)obj.TaperY;
                pbs.PathTwist        = (sbyte)obj.Twist;
                pbs.PathTwistBegin   = (sbyte)obj.TwistBegin;
                pbs.HollowShape      = (HollowShape)obj.ProfileHollow;
                pbs.PCode            = (byte)PCode.Prim;
                pbs.ProfileBegin     = (ushort)obj.ProfileBegin;
                pbs.ProfileCurve     = (byte)obj.ProfileCurve;
                pbs.ProfileEnd       = (ushort)obj.ProfileEnd;
                pbs.Scale            = obj.Scale;
                pbs.State            = 0;
                SceneObjectPart prim = new SceneObjectPart(AgentId, pbs, obj.Position, obj.Rotation,
                                                           Vector3.Zero, obj.Name)
                {
                    UUID      = UUID.Random(),
                    CreatorID = AgentId,
                    OwnerID   = AgentId,
                    GroupID   = obj.GroupID
                };
                prim.LastOwnerID  = prim.OwnerID;
                prim.CreationDate = Util.UnixTimeSinceEpoch();
                prim.Name         = obj.Name;
                prim.Description  = "";

                prim.PayPrice[0] = -2;
                prim.PayPrice[1] = -2;
                prim.PayPrice[2] = -2;
                prim.PayPrice[3] = -2;
                prim.PayPrice[4] = -2;
                Primitive.TextureEntry tmp =
                    new Primitive.TextureEntry(UUID.Parse("89556747-24cb-43ed-920b-47caed15465f"));

                for (int j = 0; j < obj.Faces.Length; j++)
                {
                    UploadObjectAssetMessage.Object.Face face = obj.Faces[j];

                    Primitive.TextureEntryFace primFace = tmp.CreateFace((uint)j);

                    primFace.Bump       = face.Bump;
                    primFace.RGBA       = face.Color;
                    primFace.Fullbright = face.Fullbright;
                    primFace.Glow       = face.Glow;
                    primFace.TextureID  = face.ImageID;
                    primFace.Rotation   = face.ImageRot;
                    primFace.MediaFlags = ((face.MediaFlags & 1) != 0);

                    primFace.OffsetU    = face.OffsetS;
                    primFace.OffsetV    = face.OffsetT;
                    primFace.RepeatU    = face.ScaleS;
                    primFace.RepeatV    = face.ScaleT;
                    primFace.TexMapType = (MappingType)(face.MediaFlags & 6);
                }
                pbs.TextureEntry = tmp.GetBytes();
                prim.Shape       = pbs;
                prim.Scale       = obj.Scale;

                SceneObjectGroup grp = new SceneObjectGroup(prim, m_scene);

                prim.ParentID = 0;
                if (i == 0)
                {
                    rootGroup = grp;
                }

                grp.AbsolutePosition = obj.Position;
                prim.SetRotationOffset(true, obj.Rotation, true);

                grp.RootPart.IsAttachment = false;

                string reason;
                if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos, out reason))
                {
                    m_scene.SceneGraph.AddPrimToScene(grp);
                    grp.AbsolutePosition = obj.Position;
                }
                else
                {
                    //Stop now then
                    avatar.ControllingClient.SendAlertMessage("You do not have permission to rez objects here: " +
                                                              reason);
                    return(MainServer.BlankResponse);
                }
                allparts[i] = grp;
            }

            if (rootGroup != null)
            {
                for (int j = 1; j < allparts.Length; j++)
                {
                    rootGroup.LinkToGroup(allparts [j]);
                }

                rootGroup.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
                pos = m_scene.SceneGraph.GetNewRezLocation(Vector3.Zero, rootpos, UUID.Zero, rot, 1, 1, true,
                                                           allparts [0].GroupScale(), false);
            }
            else
            {
                MainConsole.Instance.Error("[UploadObjectAssetModule]: Unable to locate root group!");
            }

            OSDMap map = new OSDMap();

            map["local_id"] = allparts[0].LocalId;
            return(OSDParser.SerializeLLSDXmlBytes(map));
        }
Ejemplo n.º 24
0
        public byte[] ProcessAdd(Stream request, UUID AgentId)
        {
            IScenePresence avatar;

            if (!m_scene.TryGetScenePresence(AgentId, out avatar))
            {
                return(MainServer.BadRequest);
            }


            OSD r = OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
            //UUID session_id = UUID.Zero;
            bool       bypass_raycast          = false;
            uint       everyone_mask           = 0;
            uint       group_mask              = 0;
            uint       next_owner_mask         = 0;
            uint       flags                   = 0;
            UUID       group_id                = UUID.Zero;
            int        hollow                  = 0;
            int        material                = 0;
            int        p_code                  = 0;
            int        path_begin              = 0;
            int        path_curve              = 0;
            int        path_end                = 0;
            int        path_radius_offset      = 0;
            int        path_revolutions        = 0;
            int        path_scale_x            = 0;
            int        path_scale_y            = 0;
            int        path_shear_x            = 0;
            int        path_shear_y            = 0;
            int        path_skew               = 0;
            int        path_taper_x            = 0;
            int        path_taper_y            = 0;
            int        path_twist              = 0;
            int        path_twist_begin        = 0;
            int        profile_begin           = 0;
            int        profile_curve           = 0;
            int        profile_end             = 0;
            Vector3    ray_end                 = Vector3.Zero;
            bool       ray_end_is_intersection = false;
            Vector3    ray_start               = Vector3.Zero;
            UUID       ray_target_id           = UUID.Zero;
            Quaternion rotation                = Quaternion.Identity;
            Vector3    scale                   = Vector3.Zero;
            int        state                   = 0;

            if (r.Type != OSDType.Map) // not a proper req
            {
                return(MainServer.BadRequest);
            }

            OSDMap rm = (OSDMap)r;

            if (rm.ContainsKey("ObjectData")) //v2
            {
                if (rm["ObjectData"].Type != OSDType.Map)
                {
                    return(Encoding.UTF8.GetBytes("Has ObjectData key, but data not in expected format"));
                }

                OSDMap ObjMap = (OSDMap)rm["ObjectData"];

                bypass_raycast  = ObjMap["BypassRaycast"].AsBoolean();
                everyone_mask   = ObjMap["EveryoneMask"];
                flags           = ObjMap["Flags"];
                group_mask      = ObjMap["GroupMask"];
                material        = ObjMap["Material"].AsInteger();
                next_owner_mask = ObjMap["NextOwnerMask"];
                p_code          = ObjMap["PCode"].AsInteger();

                if (ObjMap.ContainsKey("Path"))
                {
                    if (ObjMap["Path"].Type != OSDType.Map)
                    {
                        return(Encoding.UTF8.GetBytes("Has Path key, but data not in expected format"));
                    }

                    OSDMap PathMap = (OSDMap)ObjMap["Path"];
                    path_begin         = PathMap["Begin"].AsInteger();
                    path_curve         = PathMap["Curve"].AsInteger();
                    path_end           = PathMap["End"].AsInteger();
                    path_radius_offset = PathMap["RadiusOffset"].AsInteger();
                    path_revolutions   = PathMap["Revolutions"].AsInteger();
                    path_scale_x       = PathMap["ScaleX"].AsInteger();
                    path_scale_y       = PathMap["ScaleY"].AsInteger();
                    path_shear_x       = PathMap["ShearX"].AsInteger();
                    path_shear_y       = PathMap["ShearY"].AsInteger();
                    path_skew          = PathMap["Skew"].AsInteger();
                    path_taper_x       = PathMap["TaperX"].AsInteger();
                    path_taper_y       = PathMap["TaperY"].AsInteger();
                    path_twist         = PathMap["Twist"].AsInteger();
                    path_twist_begin   = PathMap["TwistBegin"].AsInteger();
                }

                if (ObjMap.ContainsKey("Profile"))
                {
                    if (ObjMap["Profile"].Type != OSDType.Map)
                    {
                        return(Encoding.UTF8.GetBytes("Has Profile key, but data not in expected format"));
                    }

                    OSDMap ProfileMap = (OSDMap)ObjMap["Profile"];

                    profile_begin = ProfileMap["Begin"].AsInteger();
                    profile_curve = ProfileMap["Curve"].AsInteger();
                    profile_end   = ProfileMap["End"].AsInteger();
                    hollow        = ProfileMap["Hollow"].AsInteger();
                }
                ray_end_is_intersection = ObjMap["RayEndIsIntersection"].AsBoolean();

                ray_target_id = ObjMap["RayTargetId"].AsUUID();
                state         = ObjMap["State"].AsInteger();
                try
                {
                    ray_end   = (ObjMap["RayEnd"]).AsVector3();
                    ray_start = (ObjMap["RayStart"]).AsVector3();
                    scale     = (ObjMap["Scale"]).AsVector3();
                    rotation  = (ObjMap["Rotation"]).AsQuaternion();
                }
                catch (Exception)
                {
                    return(Encoding.UTF8.GetBytes("RayEnd, RayStart, Scale or Rotation wasn't in the expected format"));
                }

                if (rm.ContainsKey("AgentData"))
                {
                    if (rm["AgentData"].Type != OSDType.Map)
                    {
                        return(Encoding.UTF8.GetBytes("Has AgentData key, but data not in expected format"));
                    }

                    OSDMap AgentDataMap = (OSDMap)rm["AgentData"];

                    //session_id = AgentDataMap["SessionId"].AsUUID();
                    group_id = AgentDataMap["GroupId"].AsUUID();
                }
            }
            else
            {
                //v1
                bypass_raycast = rm["bypass_raycast"].AsBoolean();

                everyone_mask      = rm["everyone_mask"];
                flags              = rm["flags"];
                group_id           = rm["group_id"].AsUUID();
                group_mask         = rm["group_mask"];
                hollow             = rm["hollow"].AsInteger();
                material           = rm["material"].AsInteger();
                next_owner_mask    = rm["next_owner_mask"];
                hollow             = rm["hollow"].AsInteger();
                p_code             = rm["p_code"].AsInteger();
                path_begin         = rm["path_begin"].AsInteger();
                path_curve         = rm["path_curve"].AsInteger();
                path_end           = rm["path_end"].AsInteger();
                path_radius_offset = rm["path_radius_offset"].AsInteger();
                path_revolutions   = rm["path_revolutions"].AsInteger();
                path_scale_x       = rm["path_scale_x"].AsInteger();
                path_scale_y       = rm["path_scale_y"].AsInteger();
                path_shear_x       = rm["path_shear_x"].AsInteger();
                path_shear_y       = rm["path_shear_y"].AsInteger();
                path_skew          = rm["path_skew"].AsInteger();
                path_taper_x       = rm["path_taper_x"].AsInteger();
                path_taper_y       = rm["path_taper_y"].AsInteger();
                path_twist         = rm["path_twist"].AsInteger();
                path_twist_begin   = rm["path_twist_begin"].AsInteger();
                profile_begin      = rm["profile_begin"].AsInteger();
                profile_curve      = rm["profile_curve"].AsInteger();
                profile_end        = rm["profile_end"].AsInteger();

                ray_end_is_intersection = rm["ray_end_is_intersection"].AsBoolean();

                ray_target_id = rm["ray_target_id"].AsUUID();


                //session_id = rm["session_id"].AsUUID();
                state = rm["state"].AsInteger();
                try
                {
                    ray_end   = (rm["ray_end"]).AsVector3();
                    ray_start = (rm["ray_start"]).AsVector3();
                    rotation  = (rm["rotation"]).AsQuaternion();
                    scale     = (rm["scale"]).AsVector3();
                }
                catch (Exception)
                {
                    return(Encoding.UTF8.GetBytes("RayEnd, RayStart, Scale or Rotation wasn't in the expected format"));
                }
            }


            Vector3 pos = m_scene.SceneGraph.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation,
                                                               (bypass_raycast) ? (byte)1 : (byte)0,
                                                               (ray_end_is_intersection) ? (byte)1 : (byte)0, true,
                                                               scale, false);

            PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();

            pbs.PathBegin        = (ushort)path_begin;
            pbs.PathCurve        = (byte)path_curve;
            pbs.PathEnd          = (ushort)path_end;
            pbs.PathRadiusOffset = (sbyte)path_radius_offset;
            pbs.PathRevolutions  = (byte)path_revolutions;
            pbs.PathScaleX       = (byte)path_scale_x;
            pbs.PathScaleY       = (byte)path_scale_y;
            pbs.PathShearX       = (byte)path_shear_x;
            pbs.PathShearY       = (byte)path_shear_y;
            pbs.PathSkew         = (sbyte)path_skew;
            pbs.PathTaperX       = (sbyte)path_taper_x;
            pbs.PathTaperY       = (sbyte)path_taper_y;
            pbs.PathTwist        = (sbyte)path_twist;
            pbs.PathTwistBegin   = (sbyte)path_twist_begin;
            pbs.HollowShape      = (HollowShape)hollow;
            pbs.PCode            = (byte)p_code;
            pbs.ProfileBegin     = (ushort)profile_begin;
            pbs.ProfileCurve     = (byte)profile_curve;
            pbs.ProfileEnd       = (ushort)profile_end;
            pbs.Scale            = scale;
            pbs.State            = (byte)state;

            ISceneEntity obj = null;

            string reason;

            if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos, out reason))
            {
                // rez ON the ground, not IN the ground
                // pos.Z += 0.25F;

                obj = m_scene.SceneGraph.AddNewPrim(avatar.UUID, group_id, pos, rotation, pbs);
            }
            else
            {
                avatar.ControllingClient.SendAlertMessage("You do not have permission to rez objects here: " + reason);
            }


            if (obj == null)
            {
                return(MainServer.BadRequest);
            }

            ISceneChildEntity rootpart = obj.RootChild;

            rootpart.Shape         = pbs;
            rootpart.Flags        |= (PrimFlags)flags;
            rootpart.EveryoneMask  = everyone_mask;
            rootpart.GroupID       = group_id;
            rootpart.GroupMask     = group_mask;
            rootpart.NextOwnerMask = next_owner_mask;
            rootpart.UpdateMaterial(material);

            OSDMap map = new OSDMap();

            map["local_id"] = obj.LocalId;
            return(OSDParser.SerializeLLSDXmlBytes(map));
        }
Ejemplo n.º 25
0
        protected byte[] FindAndSendPage(string path, Stream request, OSHttpRequest httpRequest,
                                         OSHttpResponse httpResponse)
        {
            byte[] response = MainServer.BlankResponse;
            string filename = GetFileNameFromHTMLPath(path, httpRequest.Query);

            if (filename == null)
            {
                return(MainServer.BlankResponse);
            }
            if (httpRequest.HttpMethod == "POST")
            {
                httpResponse.KeepAlive = false;
            }
            MainConsole.Instance.Debug("[WebInterface]: Serving " + filename + ", keep-alive: " + httpResponse.KeepAlive);
            IWebInterfacePage page = GetPage(filename);

            if (page != null)
            {
                httpResponse.ContentType = GetContentType(filename, httpResponse);
                string text;
                if (!File.Exists(filename))
                {
                    if (!page.AttemptFindPage(filename, ref httpResponse, out text))
                    {
                        return(MainServer.BadRequest);
                    }
                }
                else
                {
                    text = File.ReadAllText(filename);
                }

                var requestParameters = request != null
                                            ? ParseQueryString(HttpServerHandlerHelpers.ReadString(request))
                                            : new Dictionary <string, object>();

                if (filename.EndsWith(".xsl"))
                {
                    AuroraXmlDocument vars = GetXML(filename, httpRequest, httpResponse, requestParameters);

                    var xslt = new XslCompiledTransform();
                    if (File.Exists(path))
                    {
                        xslt.Load(GetFileNameFromHTMLPath(path, httpRequest.Query));
                    }
                    else if (text != "")
                    {
                        xslt.Load(new XmlTextReader(new StringReader(text)));
                    }
                    var stm = new MemoryStream();
                    xslt.Transform(vars, null, stm);
                    stm.Position = 1;
                    var    sr      = new StreamReader(stm);
                    string results = sr.ReadToEnd().Trim();
                    return(Encoding.UTF8.GetBytes(Regex.Replace(results, @"[^\u0000-\u007F]", string.Empty)));
                }
                else
                {
                    string respStr = null;
                    var    vars    = AddVarsForPage(filename, filename, httpRequest,
                                                    httpResponse, requestParameters, out respStr);

                    AddDefaultVarsForPage(ref vars);

                    if (!string.IsNullOrEmpty(respStr))
                    {
                        return(response = Encoding.UTF8.GetBytes(respStr));
                    }
                    if (httpResponse.StatusCode != 200)
                    {
                        return(MainServer.BlankResponse);
                    }
                    if (vars == null)
                    {
                        return(MainServer.BadRequest);
                    }
                    response = Encoding.UTF8.GetBytes(ConvertHTML(filename, text, httpRequest, httpResponse,
                                                                  requestParameters, vars));
                }
            }
            else
            {
                httpResponse.ContentType = GetContentType(filename, httpResponse);
                if (httpResponse.ContentType == null || !File.Exists(filename))
                {
                    return(MainServer.BadRequest);
                }
                response = File.ReadAllBytes(filename);
            }
            return(response);
        }
Ejemplo n.º 26
0
        /// <summary>
        ///     Received from the viewer if a user has changed the url of a media texture.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="path"></param>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <returns></returns>
        protected byte[] HandleObjectMediaNavigateMessage(string path, Stream request, OSHttpRequest httpRequest,
                                                          OSHttpResponse httpResponse)
        {
//            MainConsole.Instance.DebugFormat("[MOAP]: Got ObjectMediaNavigate request [{0}]", request);

            OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
            ObjectMediaNavigateMessage omn = new ObjectMediaNavigateMessage();

            omn.Deserialize(osd);

            UUID primId = omn.PrimID;

            ISceneChildEntity part = m_scene.GetSceneObjectPart(primId);

            if (null == part)
            {
                MainConsole.Instance.WarnFormat(
                    "[MOAP]: Received an ObjectMediaNavigateMessage for prim {0} but this doesn't exist in region {1}",
                    primId, m_scene.RegionInfo.RegionName);
                return(MainServer.BlankResponse);
            }

            UUID agentId = default(UUID);

            lock (m_omuCapUsers)
                agentId = m_omuCapUsers[path];

            if (!m_scene.Permissions.CanInteractWithPrimMedia(agentId, part.UUID, omn.Face))
            {
                return(MainServer.BlankResponse);
            }

//            MainConsole.Instance.DebugFormat(
//                "[MOAP]: Received request to update media entry for face {0} on prim {1} {2} to {3}",
//                omn.Face, part.Name, part.UUID, omn.URL);

            // If media has never been set for this prim, then just return.
            if (null == part.Shape.Media)
            {
                return(MainServer.BlankResponse);
            }

            MediaEntry me = null;

            lock (part.Shape.Media)
                me = part.Shape.Media[omn.Face];

            // Do the same if media has not been set up for a specific face
            if (null == me)
            {
                return(MainServer.BlankResponse);
            }

            if (me.EnableWhiteList)
            {
                if (!CheckUrlAgainstWhitelist(omn.URL, me.WhiteList))
                {
//                    MainConsole.Instance.DebugFormat(
//                        "[MOAP]: Blocking change of face {0} on prim {1} {2} to {3} since it's not on the enabled whitelist",
//                        omn.Face, part.Name, part.UUID, omn.URL);

                    return(MainServer.BlankResponse);
                }
            }

            me.CurrentURL = omn.URL;

            UpdateMediaUrl(part, agentId);

            part.ScheduleUpdate(PrimUpdateFlags.FullUpdate);

            part.TriggerScriptChangedEvent(Changed.MEDIA);

            return(OSDParser.SerializeLLSDXmlBytes(new OSD()));
        }
Ejemplo n.º 27
0
        byte[] TeleportLocation(Stream request, UUID agentID)
        {
            OSDMap retVal = new OSDMap();

            if (_isInTeleportCurrently)
            {
                retVal.Add("reason", "Duplicate teleport request.");
                retVal.Add("success", OSD.FromBoolean(false));
                return(OSDParser.SerializeLLSDXmlBytes(retVal));
            }
            _isInTeleportCurrently = true;

            OSDMap  rm       = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
            OSDMap  pos      = rm ["LocationPos"] as OSDMap;
            Vector3 position = new Vector3(
                (float)pos ["X"].AsReal(),
                (float)pos ["Y"].AsReal(),
                (float)pos ["Z"].AsReal());

            /*OSDMap lookat = rm["LocationLookAt"] as OSDMap;
             * Vector3 lookAt = new Vector3((float)lookat["X"].AsReal(),
             *  (float)lookat["Y"].AsReal(),
             *  (float)lookat["Z"].AsReal());*/
            ulong      RegionHandle = rm ["RegionHandle"].AsULong();
            const uint tpFlags      = 16;

            if (m_service.ClientCaps.GetRootCapsService().RegionHandle != m_service.RegionHandle)
            {
                retVal.Add("reason", "Contacted by non-root region for teleport. Protocol implementation is wrong.");
                retVal.Add("success", OSD.FromBoolean(false));
                return(OSDParser.SerializeLLSDXmlBytes(retVal));
            }

            string reason = "";
            int    x, y;

            Util.UlongToInts(RegionHandle, out x, out y);
            GridRegion destination = m_service.Registry.RequestModuleInterface <IGridService> ().GetRegionByPosition(
                m_service.ClientCaps.AccountInfo.AllScopeIDs, x, y);
            ISimulationService simService  = m_service.Registry.RequestModuleInterface <ISimulationService> ();
            AgentData          ad          = new AgentData();
            AgentCircuitData   circuitData = null;

            if (destination != null)
            {
                simService.RetrieveAgent(m_service.Region, m_service.AgentID, true, out ad, out circuitData);
                if (ad != null)
                {
                    ad.Position = position;
                    ad.Center   = position;
                    circuitData.StartingPosition = position;
                }
            }
            if (destination == null || circuitData == null)
            {
                retVal.Add("reason", "Could not find the destination region.");
                retVal.Add("success", OSD.FromBoolean(false));
                return(OSDParser.SerializeLLSDXmlBytes(retVal));
            }
            circuitData.IsChildAgent = false;

            if (m_agentProcessing.TeleportAgent(ref destination, tpFlags, circuitData, ad,
                                                m_service.AgentID, m_service.RegionID, out reason) || reason == "")
            {
                retVal.Add("success", OSD.FromBoolean(true));
            }
            else
            {
                if (reason != "Already in a teleport")
                {
                    //If this error occurs... don't kick them out of their current region
                    simService.FailedToMoveAgentIntoNewRegion(m_service.AgentID, destination);
                }
                retVal.Add("reason", reason);
                retVal.Add("success", OSD.FromBoolean(false));
            }

            //Send back data
            _isInTeleportCurrently = false;
            return(OSDParser.SerializeLLSDXmlBytes(retVal));
        }
Ejemplo n.º 28
0
        byte[] ProcessUpdateAgentPreferences(Stream request, UUID agentID)
        {
            OSDMap rm = OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request)) as OSDMap;

            if (rm == null)
            {
                return(MainServer.BadRequest);
            }
            IAgentConnector data = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector> ();

            if (data != null)
            {
                IAgentInfo agent = data.GetAgent(agentID);
                if (agent == null)
                {
                    return(MainServer.BadRequest);
                }
                // Access preferences ?
                if (rm.ContainsKey("access_prefs"))
                {
                    OSDMap accessPrefs = (OSDMap)rm ["access_prefs"];
                    string Level       = accessPrefs ["max"].AsString();
                    int    maxLevel    = 0;
                    if (Level == "PG")
                    {
                        maxLevel = 0;
                    }
                    if (Level == "M")
                    {
                        maxLevel = 1;
                    }
                    if (Level == "A")
                    {
                        maxLevel = 2;
                    }
                    agent.MaturityRating = maxLevel;
                }
                // Next permissions
                if (rm.ContainsKey("default_object_perm_masks"))
                {
                    OSDMap permsMap = (OSDMap)rm ["default_object_perm_masks"];
                    agent.PermEveryone  = permsMap ["Everyone"].AsInteger();
                    agent.PermGroup     = permsMap ["Group"].AsInteger();
                    agent.PermNextOwner = permsMap ["NextOwner"].AsInteger();
                }
                // Hoverheight
                if (rm.ContainsKey("hover_height"))
                {
                    agent.HoverHeight = rm ["hover_height"].AsReal();
                }
                // Language
                if (rm.ContainsKey("language"))
                {
                    agent.Language = rm ["language"].AsString();
                }
                // Show Language to others / objects
                if (rm.ContainsKey("language_is_public"))
                {
                    agent.LanguageIsPublic = rm ["language_is_public"].AsBoolean();
                }
                data.UpdateAgent(agent);
                // Build a response that can be send back to the viewer
                OSDMap resp            = new OSDMap();
                OSDMap respAccessPrefs = new OSDMap();
                respAccessPrefs ["max"] = Utilities.GetMaxMaturity(agent.MaxMaturity);
                resp ["access_prefs"]   = respAccessPrefs;
                OSDMap respDefaultPerms = new OSDMap();
                respDefaultPerms ["Everyone"]      = agent.PermEveryone;
                respDefaultPerms ["Group"]         = agent.PermGroup;
                respDefaultPerms ["NextOwner"]     = agent.PermNextOwner;
                resp ["default_object_perm_masks"] = respDefaultPerms;
                resp ["god_level"]          = 0; // *TODO: Add this
                resp ["hover_height"]       = agent.HoverHeight;
                resp ["language"]           = agent.Language;
                resp ["language_is_public"] = agent.LanguageIsPublic;

                return(OSDParser.SerializeLLSDXmlBytes(resp));
            }
            return(MainServer.BlankResponse);
        }
        private byte[] SetEnvironment(Stream request, UUID agentID)
        {
            IScenePresence SP = m_scene.GetScenePresence(agentID);

            if (SP == null)
            {
                return(new byte[0]); //They don't exist
            }
            bool   success     = false;
            string fail_reason = "";

            if (SP.Scene.Permissions.CanIssueEstateCommand(agentID, false))
            {
                m_scene.RegionInfo.EnvironmentSettings = OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
                success = true;

                //Tell everyone about the changes
                TriggerWindlightUpdate(1);
            }
            else
            {
                fail_reason = "You don't have permissions to set the windlight settings here.";
                SP.ControllingClient.SendAlertMessage(
                    "You don't have the correct permissions to set the Windlight Settings");
            }
            OSDMap result = new OSDMap()
            {
                new KeyValuePair <string, OSD>("success", success),
                new KeyValuePair <string, OSD>("regionID", SP.Scene.RegionInfo.RegionID)
            };

            if (fail_reason != "")
            {
                result["fail_reason"] = fail_reason;
            }

            return(OSDParser.SerializeLLSDXmlBytes(result));
        }
Ejemplo n.º 30
0
        public void IncomingCapsRequest(UUID agentID, GridRegion region, ISimulationBase simbase, ref OSDMap capURLs)
        {
            m_agentID      = agentID;
            m_region       = region;
            m_userScopeIDs = simbase.ApplicationRegistry.RequestModuleInterface <IUserAccountService> ().GetUserAccount(null, m_agentID).AllScopeIDs;

            m_gridService = simbase.ApplicationRegistry.RequestModuleInterface <IGridService> ();
            IConfig config = simbase.ConfigSource.Configs ["MapCAPS"];

            if (config != null)
            {
                m_allowCapsMessage = config.GetBoolean("AllowCapsMessage", m_allowCapsMessage);
            }

            HttpServerHandle method = (path, request, httpRequest, httpResponse) => MapLayerRequest(HttpServerHandlerHelpers.ReadString(request), httpRequest, httpResponse);

            m_uri = "/CAPS/MapLayer/" + UUID.Random() + "/";
            capURLs ["MapLayer"]    = MainServer.Instance.ServerURI + m_uri;
            capURLs ["MapLayerGod"] = MainServer.Instance.ServerURI + m_uri;

            MainServer.Instance.AddStreamHandler(new GenericStreamHandler("POST", m_uri, method));
        }