protected string GetObjectPhysicsDataHandler(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            // m_log.DebugFormat("[ASSETCAPS] Got a GetObjectPhysicsData Packet {0}.", request);

            OSDMap   resp           = new OSDMap();
            OSDMap   requestmap     = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
            OSDArray itemsRequested = (OSDArray)requestmap["object_ids"];

            foreach (OSDUUID osdItemId in itemsRequested)
            {
                UUID            itemId = osdItemId.AsUUID();
                SceneObjectPart item   = m_Scene.GetSceneObjectPart(itemId);

                if ((item != null) && (item.PhysActor != null))
                {
                    Physics.Manager.IMaterial material = item.PhysActor.Properties.Material;
                    OSDMap object_data = new OSDMap();

                    object_data["PhysicsShapeType"]  = (byte)item.Shape.PreferredPhysicsShape;      // obj.PhysicsShapeType;
                    object_data["Density"]           = material.Density;                            // obj.Density;
                    object_data["Friction"]          = material.StaticFriction;                     // obj.Friction;
                    object_data["Restitution"]       = material.Restitution;                        // obj.Restitution;
                    object_data["GravityMultiplier"] = 1.0f;                                        // material.obj.GravityModifier;

                    resp[itemId.ToString()] = object_data;
                }
            }

            string response = OSDParser.SerializeLLSDXmlString(resp);

            // m_log.DebugFormat("[ASSETCAPS] Sending a GetObjectPhysicsData Response {0}.", response);
            return(response);
        }
Esempio n. 2
0
        public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
//            m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capabilty request");

            OSDMap   requestmap     = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
            OSDArray itemsRequested = (OSDArray)requestmap["items"];

            string             reply;
            LLSDFetchInventory llsdReply = new LLSDFetchInventory();

            foreach (OSDMap osdItemId in itemsRequested)
            {
                UUID itemId = osdItemId["item_id"].AsUUID();

                InventoryItemBase item = m_inventoryService.GetItem(new InventoryItemBase(itemId, m_agentID));

                if (item != null)
                {
                    // We don't know the agent that this request belongs to so we'll use the agent id of the item
                    // which will be the same for all items.
                    llsdReply.agent_id = item.Owner;

                    llsdReply.items.Array.Add(ConvertInventoryItem(item));
                }
            }

            reply = LLSDHelpers.SerialiseLLSDReply(llsdReply);

            return(reply);
        }
Esempio n. 3
0
        private static OSDArray WrapOSDMap(OSDMap wrapMe)
        {
            OSDArray array = new OSDArray();

            array.Add(wrapMe);
            return(array);
        }
        public string RenderMaterialsPostCap(string request, UUID agentID)
        {
            OSDMap   req     = (OSDMap)OSDParser.DeserializeLLSDXml(request);
            OSDMap   resp    = new OSDMap();
            OSDArray respArr = new OSDArray();

            if (req.ContainsKey("Zipped"))
            {
                byte[] inBytes = req["Zipped"].AsBinary();

                try
                {
                    OSD osd = ZDecompressBytesToOsd(inBytes);
                    if (osd == null)
                    {
                        m_log.Warn("[MaterialsModule]: Decoded Materials request is empty");
                    }
                    else if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries
                    {
                        ReturnRequestedMaterials(ref respArr, osd as OSDArray);
                    }
                    else if (osd is OSDMap) // request to assign a material
                    {
                        AssignRequestedMaterials(osd as OSDMap, agentID);
                    }
                }
                catch (Exception e)
                {
                    m_log.Warn("[RenderMaterials]: exception decoding zipped CAP payload: " + e.ToString());
                }
            }

            resp["Zipped"] = ZCompressOSD(respArr, false);
            return(OSDParser.SerializeLLSDXmlString(resp));
        }
        public static void GetMeshVertexCount(byte[] data, out int vertex_count)
        {
            vertex_count = 0;

            try
            {
                long   start = 0;
                OSDMap map   = TryExtractOSDMapFromLLSDBinary(ref start, data);

                if (map.ContainsKey("high_lod"))
                {
                    map = (OSDMap)map["high_lod"];
                    OSDArray lod_data = DecodeMeshLODArray(data, start, map);
                    foreach (OSD subMeshOsd in lod_data)
                    {
                        // We get a list of faces.  Sum each "face"
                        if (subMeshOsd is OSDMap)
                        {
                            vertex_count += DecodeMeshFace(subMeshOsd as OSDMap);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[MESH]: exception meshing object: {0}", e);
                vertex_count = 0;
            }
        }
Esempio n. 6
0
        private string HandleUntrustedSimulatorMessage(string request,
                                                       string path, string param, IOSHttpRequest httpRequest,
                                                       IOSHttpResponse httpResponse)
        {
            OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(request);

            string message = osd["message"].AsString();

            if (message == "GodKickUser")
            {
                OSDMap   body     = (OSDMap)osd["body"];
                OSDArray userInfo = (OSDArray)body["UserInfo"];
                OSDMap   userData = (OSDMap)userInfo[0];

                UUID          agentID      = userData["AgentID"].AsUUID();
                UUID          godID        = userData["GodID"].AsUUID();
                UUID          godSessionID = userData["GodSessionID"].AsUUID();
                uint          kickFlags    = userData["KickFlags"].AsUInteger();
                string        reason       = userData["Reason"].AsString();
                ScenePresence god          = m_scene.GetScenePresence(godID);
                if (god == null || god.ControllingClient.SessionId != godSessionID)
                {
                    return(String.Empty);
                }

                KickUser(godID, godSessionID, agentID, kickFlags, Util.StringToBytes1024(reason));
            }
            else
            {
                m_log.ErrorFormat("[GOD]: Unhandled UntrustedSimulatorMessage: {0}", message);
            }
            return(String.Empty);
        }
Esempio n. 7
0
        public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request);

            OSDMap   requestmap     = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
            OSDArray itemsRequested = (OSDArray)requestmap["items"];

            string             reply;
            LLSDFetchInventory llsdReply = new LLSDFetchInventory();

            UUID[] itemIDs = new UUID[itemsRequested.Count];
            int    i       = 0;

            foreach (OSDMap osdItemId in itemsRequested)
            {
                itemIDs[i++] = osdItemId["item_id"].AsUUID();
            }

            InventoryItemBase[] items = null;

            if (m_agentID != UUID.Zero)
            {
                items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs);

                if (items == null)
                {
                    // OMG!!! One by one!!! This is fallback code, in case the backend isn't updated
                    m_log.WarnFormat("[FETCH INVENTORY HANDLER]: GetMultipleItems failed. Falling back to fetching inventory items one by one.");
                    items = new InventoryItemBase[itemsRequested.Count];
                    foreach (UUID id in itemIDs)
                    {
                        items[i++] = m_inventoryService.GetItem(m_agentID, id);
                    }
                }
            }
            else
            {
                items = new InventoryItemBase[itemsRequested.Count];
                foreach (UUID id in itemIDs)
                {
                    items[i++] = m_inventoryService.GetItem(UUID.Zero, id);
                }
            }

            foreach (InventoryItemBase item in items)
            {
                if (item != null)
                {
                    // We don't know the agent that this request belongs to so we'll use the agent id of the item
                    // which will be the same for all items.
                    llsdReply.agent_id = item.Owner;
                    llsdReply.items.Array.Add(ConvertInventoryItem(item));
                }
            }

            reply = LLSDHelpers.SerialiseLLSDReply(llsdReply);

            return(reply);
        }
Esempio n. 8
0
        public void FetchInventorySimpleRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, OSDMap requestmap, ExpiringKey <UUID> BadRequests)
        {
            //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request);

            if (BadRequests == null)
            {
                httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
                return;
            }

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

            UUID[] itemIDs = new UUID[itemsRequested.Count];
            int    i       = 0;

            foreach (OSDMap osdItemId in itemsRequested)
            {
                UUID id = osdItemId["item_id"].AsUUID();
                if (!BadRequests.ContainsKey(id))
                {
                    itemIDs[i++] = id;
                }
            }

            InventoryItemBase[] items = null;
            try
            {
                // badrequests still not filled
                items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs);
            }
            catch { }

            StringBuilder lsl = LLSDxmlEncode.Start(4096);

            LLSDxmlEncode.AddMap(lsl);

            LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl);

            if (items == null || items.Length == 0)
            {
                LLSDxmlEncode.AddEmptyArray("items", lsl);
            }
            else
            {
                LLSDxmlEncode.AddArray("items", lsl);
                foreach (InventoryItemBase item in items)
                {
                    if (item != null)
                    {
                        item.ToLLSDxml(lsl, 0xff);
                    }
                }
                LLSDxmlEncode.AddEndArray(lsl);
            }

            LLSDxmlEncode.AddEndMap(lsl);
            httpResponse.RawBuffer  = Util.UTF8.GetBytes(LLSDxmlEncode.End(lsl));
            httpResponse.StatusCode = (int)HttpStatusCode.OK;
        }
Esempio n. 9
0
        public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
        {
            uint xstart = 0;
            uint ystart = 0;

            Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out xstart, out ystart);

            OSDMap responsemap               = new OSDMap();
            List <ScenePresence> avatars     = m_scene.GetAvatars();
            OSDArray             responsearr = new OSDArray(avatars.Count);
            OSDMap responsemapdata           = new OSDMap();
            int    tc = Environment.TickCount;

            /*
             * foreach (ScenePresence av in avatars)
             * {
             *  responsemapdata = new OSDMap();
             *  responsemapdata["X"] = OSD.FromInteger((int)(xstart + av.AbsolutePosition.X));
             *  responsemapdata["Y"] = OSD.FromInteger((int)(ystart + av.AbsolutePosition.Y));
             *  responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
             *  responsemapdata["Name"] = OSD.FromString("TH");
             *  responsemapdata["Extra"] = OSD.FromInteger(0);
             *  responsemapdata["Extra2"] = OSD.FromInteger(0);
             *  responsearr.Add(responsemapdata);
             * }
             * responsemap["1"] = responsearr;
             */
            if (avatars.Count == 0)
            {
                responsemapdata           = new OSDMap();
                responsemapdata["X"]      = OSD.FromInteger((int)(xstart + 1));
                responsemapdata["Y"]      = OSD.FromInteger((int)(ystart + 1));
                responsemapdata["ID"]     = OSD.FromUUID(UUID.Zero);
                responsemapdata["Name"]   = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
                responsemapdata["Extra"]  = OSD.FromInteger(0);
                responsemapdata["Extra2"] = OSD.FromInteger(0);
                responsearr.Add(responsemapdata);

                responsemap["6"] = responsearr;
            }
            else
            {
                responsearr = new OSDArray(avatars.Count);
                foreach (ScenePresence av in avatars)
                {
                    responsemapdata           = new OSDMap();
                    responsemapdata["X"]      = OSD.FromInteger((int)(xstart + av.AbsolutePosition.X));
                    responsemapdata["Y"]      = OSD.FromInteger((int)(ystart + av.AbsolutePosition.Y));
                    responsemapdata["ID"]     = OSD.FromUUID(UUID.Zero);
                    responsemapdata["Name"]   = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
                    responsemapdata["Extra"]  = OSD.FromInteger(1);
                    responsemapdata["Extra2"] = OSD.FromInteger(0);
                    responsearr.Add(responsemapdata);
                }
                responsemap["6"] = responsearr;
            }
            return(responsemap);
        }
Esempio n. 10
0
        /// <summary>
        /// Sends the mapitem response to the IClientAPI
        /// </summary>
        /// <param name="response">The OSDMap Response for the mapitem</param>
        private void RequestMapItemsCompleted(IAsyncResult iar)
        {
            AsyncResult             result = (AsyncResult)iar;
            RequestMapItemsDelegate icon   = (RequestMapItemsDelegate)result.AsyncDelegate;

            OSDMap response = (OSDMap)icon.EndInvoke(iar);

            Interlocked.Decrement(ref nAsyncRequests);

            if (!response.ContainsKey("requestID"))
            {
                return;
            }

            UUID requestID = response["requestID"].AsUUID();

            if (requestID != UUID.Zero)
            {
                MapRequestState mrs = new MapRequestState();
                mrs.agentID = UUID.Zero;
                lock (m_openRequests)
                {
                    if (m_openRequests.ContainsKey(requestID))
                    {
                        mrs = m_openRequests[requestID];
                        m_openRequests.Remove(requestID);
                    }
                }

                if (mrs.agentID != UUID.Zero)
                {
                    ScenePresence av = null;
                    m_scene.TryGetScenePresence(mrs.agentID, out av);
                    if (av != null)
                    {
                        if (response.ContainsKey(mrs.itemtype.ToString()))
                        {
                            List <mapItemReply> returnitems = new List <mapItemReply>();
                            OSDArray            itemarray   = (OSDArray)response[mrs.itemtype.ToString()];
                            for (int i = 0; i < itemarray.Count; i++)
                            {
                                OSDMap       mapitem = (OSDMap)itemarray[i];
                                mapItemReply mi      = new mapItemReply();
                                mi.x      = (uint)mapitem["X"].AsInteger();
                                mi.y      = (uint)mapitem["Y"].AsInteger();
                                mi.id     = mapitem["ID"].AsUUID();
                                mi.Extra  = mapitem["Extra"].AsInteger();
                                mi.Extra2 = mapitem["Extra2"].AsInteger();
                                mi.name   = mapitem["Name"].AsString();
                                returnitems.Add(mi);
                            }
                            av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Assign The requested materials to the specified part(s).
        /// </summary>
        /// <param name="materialsFromViewer"></param>
        private void AssignRequestedMaterials(OSDMap materialsFromViewer, UUID agentID)
        {
            if (!(materialsFromViewer.ContainsKey("FullMaterialsPerFace") &&
                  (materialsFromViewer["FullMaterialsPerFace"] is OSDArray)))
            {
                m_log.Warn("[RenderMaterials]: AssignRequestedMaterials - FullMaterialsPerFace not defined or incorrect type");
                return;
            }

            OSDArray mats = materialsFromViewer["FullMaterialsPerFace"] as OSDArray;

            foreach (OSDMap matsMap in mats)
            {
                uint   matLocalID = 0;
                int    face       = -1;
                OSDMap matData    = null;

                try
                {
                    matLocalID = matsMap["ID"].AsUInteger();

                    if (matsMap.ContainsKey("Face"))
                    {
                        face = matsMap["Face"].AsInteger();
                    }

                    if (matsMap.ContainsKey("Material"))
                    {
                        matData = matsMap["Material"] as OSDMap;
                    }
                }
                catch (Exception e)
                {
                    m_log.Warn("[RenderMaterials]: cannot decode material from matsMap: " + e.Message);
                    continue;
                }

                /// Look up the scene object this material pertains to.
                var sop = m_scene.GetSceneObjectPart(matLocalID);
                if (sop == null)
                {
                    m_log.Warn("[RenderMaterials]: null SOP for localId: " + matLocalID.ToString());
                    continue;
                }

                // Make sure we can modify it
                if (m_scene.Permissions.CanEditObject(sop.ParentGroup.UUID, agentID, (uint)PermissionMask.Modify) == false)
                {
                    m_log.WarnFormat("[RenderMaterials]: User {0} can't edit object {1} {2}",
                                     agentID, sop.ParentGroup.Name, sop.ParentGroup.UUID);
                    continue;
                }

                AssignSingleMaterial(sop, face, matData);
            }
        }
Esempio n. 12
0
        protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
//            m_log.DebugFormat("[GET_DISPLAY_NAMES]: called {0}", httpRequest.Url.Query);

            NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);

            string[] ids = query.GetValues("ids");


            if (m_UserManagement == null)
            {
                m_log.Error("[GET_DISPLAY_NAMES]: Cannot fetch display names without a user management component");
                httpResponse.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                return(new byte[0]);
            }

            OSDMap   osdReply = new OSDMap();
            OSDArray agents   = new OSDArray();

            osdReply["agents"] = agents;
            foreach (string id in ids)
            {
                UUID uuid = UUID.Zero;
                if (UUID.TryParse(id, out uuid))
                {
                    string name = m_UserManagement.GetUserName(uuid);
                    if (!string.IsNullOrEmpty(name))
                    {
                        string[] parts   = name.Split(new char[] { ' ' });
                        OSDMap   osdname = new OSDMap();
                        // a date that is valid
//                        osdname["display_name_next_update"] = OSD.FromDate(new DateTime(1970,1,1));
                        // but send one that blocks edition, since we actually don't suport this
                        osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(8));
                        osdname["display_name_expires"]     = OSD.FromDate(DateTime.UtcNow.AddMonths(1));
                        osdname["display_name"]             = OSD.FromString(name);
                        osdname["legacy_first_name"]        = parts[0];
                        osdname["legacy_last_name"]         = parts[1];
                        osdname["username"] = OSD.FromString(name);
                        osdname["id"]       = OSD.FromUUID(uuid);
                        osdname["is_display_name_default"] = OSD.FromBoolean(true);

                        agents.Add(osdname);
                    }
                }
            }

            // Full content request
            httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
            //httpResponse.ContentLength = ??;
            httpResponse.ContentType = "application/llsd+xml";

            string reply = OSDParser.SerializeLLSDXmlString(osdReply);

            return(System.Text.Encoding.UTF8.GetBytes(reply));
        }
Esempio n. 13
0
        /// <summary>
        /// Return all of the values for the key. This finds multiple values in the
        /// ini array only.
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public List <string> ParamStringArray(string key)
        {
            string        lkey = key.ToLower();
            List <string> ret  = new List <string>();

            OMVSD.OSD paramVal = null;
            bool      success  = false;

            lock (m_params) {
                try {
                    if (m_runtimeValues.ContainsKey(lkey))
                    {
                        paramVal = m_runtimeValues[lkey](lkey);
                    }
                    else
                    {
                        if (m_params.ContainsKey(lkey))
                        {
                            paramVal = m_params[lkey];
                        }
                    }
                    if (paramVal != null)
                    {
                        if (paramVal.Type == OMVSD.OSDType.Array)
                        {
                            OMVSD.OSDArray values = (OMVSD.OSDArray)paramVal;
                            foreach (OMVSD.OSD val in values)
                            {
                                ret.Add(val.AsString());
                            }
                            success = true;
                        }
                    }
                }
                catch {
                    success = false;
                }
            }
            if (!success)
            {
                switch (ParamErrorMethod)
                {
                case paramErrorType.eDefaultValue:
                    // return empty list
                    break;

                case paramErrorType.eException:
                    throw new ParameterException("String array param '" + key + "' not found");

                case paramErrorType.eNullValue:
                    ret = null;
                    break;
                }
            }
            return(ret);
        }
        protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
//            m_log.DebugFormat("[GET_DISPLAY_NAMES]: called {0}", httpRequest.Url.Query);

            NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
            string[] ids = query.GetValues("ids");


            if (m_UserManagement == null)
            {
                m_log.Error("[GET_DISPLAY_NAMES]: Cannot fetch display names without a user management component");
                httpResponse.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                return new byte[0];
            }

            OSDMap osdReply = new OSDMap();
            OSDArray agents = new OSDArray();

            osdReply["agents"] = agents;
            foreach (string id in ids)
            {
                UUID uuid = UUID.Zero;
                if (UUID.TryParse(id, out uuid))
                {
                    string name = m_UserManagement.GetUserName(uuid);
                    if (!string.IsNullOrEmpty(name))
                    {
                        string[] parts = name.Split(new char[] {' '});
                        OSDMap osdname = new OSDMap();
                        // a date that is valid
//                        osdname["display_name_next_update"] = OSD.FromDate(new DateTime(1970,1,1));
                        // but send one that blocks edition, since we actually don't suport this
                        osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(8));        
                        osdname["display_name_expires"] = OSD.FromDate(DateTime.UtcNow.AddMonths(1));
                        osdname["display_name"] = OSD.FromString(name);
                        osdname["legacy_first_name"] = parts[0];
                        osdname["legacy_last_name"] = parts[1];
                        osdname["username"] = OSD.FromString(name);
                        osdname["id"] = OSD.FromUUID(uuid);
                        osdname["is_display_name_default"] = OSD.FromBoolean(true);

                        agents.Add(osdname);
                    }
                }
            }

            // Full content request
            httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
            //httpResponse.ContentLength = ??;
            httpResponse.ContentType = "application/llsd+xml";

            string reply = OSDParser.SerializeLLSDXmlString(osdReply);
            return System.Text.Encoding.UTF8.GetBytes(reply);

        }
Esempio n. 15
0
        protected string ResourceCostsSelected(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            //m_log.DebugFormat("[ASSETCAPS] Got a ResourceCostsSelected Packet {0}.", request);
            OSDMap resp       = new OSDMap();
            OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));

            float streaming_cost  = 0.0f;
            float simulation_cost = 0.0f;
            float physics_cost    = 0.0f;

            // I dont see selected_prims ever sent but we cover our ass just in case
            string[] tags = { "selected_roots", "selected_prims" };
            foreach (string value in tags)
            {
                if (requestmap.ContainsKey(value) == false)
                {
                    continue;
                }

                OSDArray itemsRequested = (OSDArray)requestmap[value];
                foreach (OSDUUID osdItemId in itemsRequested)
                {
                    UUID            itemId = osdItemId.AsUUID();
                    SceneObjectPart item   = m_Scene.GetSceneObjectPart(itemId);
                    PhysicsActor    physActor;

                    if (item != null)
                    {
                        SceneObjectGroup parent = item.ParentGroup;

                        physActor = parent.RootPart.PhysActor;
                        if (physActor != null)
                        {
                            physics_cost += (float)physActor.TotalComplexity;
                        }
                        streaming_cost  += parent.StreamingCost;
                        simulation_cost += parent.ServerWeight;
                    }
                }
            }

            OSDMap object_data = new OSDMap();

            object_data["physics"]    = physics_cost;
            object_data["streaming"]  = streaming_cost;
            object_data["simulation"] = simulation_cost;
            resp["selected"]          = object_data;

            string response = OSDParser.SerializeLLSDXmlString(resp);

            //m_log.DebugFormat("[ASSETCAPS] Sending a ResourceCostsSelected Response {0}.", response);
            return(response);
        }
Esempio n. 16
0
        private void HandleUntrustedSimulatorMessage(IOSHttpRequest request, IOSHttpResponse response)
        {
            if (request.HttpMethod != "POST")
            {
                response.StatusCode = (int)HttpStatusCode.NotFound;
                return;
            }

            OSDMap osd;

            try
            {
                osd = (OSDMap)OSDParser.DeserializeLLSDXml(request.InputStream);

                string message = osd["message"].AsString();
                if (message == "GodKickUser")
                {
                    OSDMap   body     = (OSDMap)osd["body"];
                    OSDArray userInfo = (OSDArray)body["UserInfo"];
                    OSDMap   userData = (OSDMap)userInfo[0];

                    UUID   agentID      = userData["AgentID"].AsUUID();
                    UUID   godID        = userData["GodID"].AsUUID();
                    UUID   godSessionID = userData["GodSessionID"].AsUUID();
                    uint   kickFlags    = userData["KickFlags"].AsUInteger();
                    string reason       = userData["Reason"].AsString();

                    ScenePresence god = m_scene.GetScenePresence(godID);
                    if (god == null || god.ControllingClient.SessionId != godSessionID)
                    {
                        response.StatusCode = (int)HttpStatusCode.Unauthorized;
                        return;
                    }

                    KickUser(godID, agentID, kickFlags, reason);
                }
                else
                {
                    m_log.ErrorFormat("[GOD]: Unhandled UntrustedSimulatorMessage: {0}", message);
                    response.StatusCode = (int)HttpStatusCode.BadRequest;
                    return;
                }
            }
            catch
            {
                response.StatusCode = (int)HttpStatusCode.BadRequest;
                return;
            }

            response.StatusCode = (int)HttpStatusCode.OK;
        }
Esempio n. 17
0
        /// <summary>
        /// Get the module specifications from the configuration, load all the modules,
        /// and call their post all loaded entries then start them.
        /// </summary>
        /// <returns>true if it looks like everything worked</returns>
        public bool LoadAndStartModules()
        {
            bool successFlag = true;

            try {
                OMVSD.OSD modulesRaw = m_lgb.AppParams.ParamValue("Modules");
                // modules are specified by an array of maps
                if ((modulesRaw != null) && (modulesRaw.Type == OMVSD.OSDType.Array))
                {
                    OMVSD.OSDArray moduleArray = (OMVSD.OSDArray)modulesRaw;
                    foreach (OMVSD.OSDMap modSpec in moduleArray)
                    {
                        string modAssembly  = modSpec["Assembly"].AsString();
                        string modInterface = modSpec["Interface"].AsString();
                        string modName      = modSpec["Name"].AsString();
                        Object obj          = LoadModule(modAssembly, modInterface, modName);
                        if (obj == null)
                        {
                            m_log.Log(LogLevel.DBADERROR, "Failed to load module."
                                      + " a='" + modAssembly
                                      + "', i='" + modInterface
                                      + "', n=" + modName);
                            successFlag = false;
                            break;
                        }
                    }
                }
                else
                {
                    m_log.Log(LogLevel.DBADERROR, "'Modules' parameter is not an array of maps. Could not load modules");
                    successFlag = false;
                }
            }
            catch (Exception e) {
                m_log.Log(LogLevel.DBADERROR, "Failed starting modules: " + e.ToString());
                successFlag = false;
            }

            try {
                if (successFlag && AfterAllModulesLoaded())
                {
                    successFlag = Start();
                }
            }
            catch (Exception e) {
                m_log.Log(LogLevel.DBADERROR, "Failed starting modules: " + e.ToString());
                successFlag = false;
            }

            return(successFlag);
        }
Esempio n. 18
0
        protected string GetObjectCostHandler(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            // m_log.DebugFormat("[ASSETCAPS] Got a GetObjectCost Packet {0}.", request);

            OSDMap   resp           = new OSDMap();
            OSDMap   requestmap     = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
            OSDArray itemsRequested = (OSDArray)requestmap["object_ids"];

            foreach (OSDUUID osdItemId in itemsRequested)
            {
                UUID            itemId = osdItemId.AsUUID();
                SceneObjectPart item   = m_Scene.GetSceneObjectPart(itemId);
                PhysicsActor    physActor;

                if (item != null)
                {
                    SceneObjectGroup parent      = item.ParentGroup;
                    OSDMap           object_data = new OSDMap();

                    object_data["linked_set_resource_cost"] = parent.LandImpact;
                    object_data["resource_cost"]            = item.ServerWeight;

                    physActor = item.PhysActor;
                    if (physActor != null)
                    {
                        object_data["physics_cost"] = (float)physActor.TotalComplexity;
                    }
                    else
                    {
                        object_data["physics_cost"] = 0.0;
                    }

                    physActor = parent.RootPart.PhysActor;
                    if (physActor != null)
                    {
                        object_data["linked_set_physics_cost"] = (float)physActor.TotalComplexity;
                    }
                    else
                    {
                        object_data["linked_set_physics_cost"] = 0.0;
                    }

                    resp[itemId.ToString()] = object_data;
                }
            }

            string response = OSDParser.SerializeLLSDXmlString(resp);

            // m_log.DebugFormat("[ASSETCAPS] Sending a GetObjectCost Response {0}.", response);
            return(response);
        }
        /// <summary>
        /// Return the last log lines. Output in the format:
        /// <pre>
        /// {"logLines": [
        /// "line1",
        /// "line2",
        /// ...
        /// ]
        /// }
        /// </pre>
        /// </summary>
        /// <param name="pModelResult"></param>
        /// <returns></returns>
        public string RenderJson(Hashtable pModelResult)
        {
            OSDMap logInfo = new OpenMetaverse.StructuredData.OSDMap();

            OSDArray logLines = new OpenMetaverse.StructuredData.OSDArray();
            string   tmp      = normalizeEndLines.Replace(pModelResult["loglines"].ToString(), "\n");

            string[] result = Regex.Split(tmp, "\n");
            for (int i = 0; i < result.Length; i++)
            {
                logLines.Add(new OSDString(result[i]));
            }
            logInfo.Add("logLines", logLines);
            return(logInfo.ToString());
        }
Esempio n. 20
0
        public OSDArray ArrayListToOSDArray(ArrayList arrlst)
        {
            OSDArray llsdBack = new OSDArray();

            foreach (Hashtable ht in arrlst)
            {
                OSDMap mp = new OSDMap();
                foreach (DictionaryEntry deHt in ht)
                {
                    mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value));
                }
                llsdBack.Add(mp);
            }
            return(llsdBack);
        }
Esempio n. 21
0
        /// <summary>
        /// Sends the mapitem response to the IClientAPI
        /// </summary>
        /// <param name="response">The OSDMap Response for the mapitem</param>
        private void RequestMapItemsCompleted(OSDMap response)
        {
            UUID requestID = response["requestID"].AsUUID();

            if (requestID != UUID.Zero)
            {
                MapRequestState mrs = new MapRequestState();
                mrs.agentID = UUID.Zero;
                lock (m_openRequests)
                {
                    if (m_openRequests.ContainsKey(requestID))
                    {
                        mrs = m_openRequests[requestID];
                        m_openRequests.Remove(requestID);
                    }
                }

                if (mrs.agentID != UUID.Zero)
                {
                    ScenePresence av = null;
                    m_scene.TryGetAvatar(mrs.agentID, out av);
                    if (av != null)
                    {
                        if (response.ContainsKey(mrs.itemtype.ToString()))
                        {
                            List <mapItemReply> returnitems = new List <mapItemReply>();
                            OSDArray            itemarray   = (OSDArray)response[mrs.itemtype.ToString()];
                            for (int i = 0; i < itemarray.Count; i++)
                            {
                                OSDMap       mapitem = (OSDMap)itemarray[i];
                                mapItemReply mi      = new mapItemReply();
                                mi.x      = (uint)mapitem["X"].AsInteger();
                                mi.y      = (uint)mapitem["Y"].AsInteger();
                                mi.id     = mapitem["ID"].AsUUID();
                                mi.Extra  = mapitem["Extra"].AsInteger();
                                mi.Extra2 = mapitem["Extra2"].AsInteger();
                                mi.name   = mapitem["Name"].AsString();
                                returnitems.Add(mi);
                            }
                            av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags);
                        }
                    }
                }
            }
        }
        public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
        {
            uint xstart = 0;
            uint ystart = 0;

            Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out xstart, out ystart);

            OSDMap responsemap = new OSDMap();
            int    tc          = Environment.TickCount;

            if (m_scene.GetRootAgentCount() == 0)
            {
                OSDMap responsemapdata = new OSDMap();
                responsemapdata["X"]      = OSD.FromInteger((int)(xstart + 1));
                responsemapdata["Y"]      = OSD.FromInteger((int)(ystart + 1));
                responsemapdata["ID"]     = OSD.FromUUID(UUID.Zero);
                responsemapdata["Name"]   = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
                responsemapdata["Extra"]  = OSD.FromInteger(0);
                responsemapdata["Extra2"] = OSD.FromInteger(0);
                OSDArray responsearr = new OSDArray();
                responsearr.Add(responsemapdata);

                responsemap["6"] = responsearr;
            }
            else
            {
                OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount());
                m_scene.ForEachScenePresence(delegate(ScenePresence sp)
                {
                    OSDMap responsemapdata    = new OSDMap();
                    responsemapdata["X"]      = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X));
                    responsemapdata["Y"]      = OSD.FromInteger((int)(ystart + sp.AbsolutePosition.Y));
                    responsemapdata["ID"]     = OSD.FromUUID(UUID.Zero);
                    responsemapdata["Name"]   = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
                    responsemapdata["Extra"]  = OSD.FromInteger(1);
                    responsemapdata["Extra2"] = OSD.FromInteger(0);
                    responsearr.Add(responsemapdata);
                });
                responsemap["6"] = responsearr;
            }
            return(responsemap);
        }
        /// <summary>
        /// GET request. Return all the materials we know about.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="request"></param>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <returns></returns>

        public string RenderMaterialsGetCap(string request)
        {
            OSDArray allOsd = new OSDArray();

            lock (m_knownMaterials)
            {
                foreach (KeyValuePair <UUID, RenderMaterialEntry> kvp in m_knownMaterials)
                {
                    OSDMap matMap = new OSDMap();
                    matMap["ID"]       = OSD.FromBinary(kvp.Key.GetBytes());
                    matMap["Material"] = kvp.Value.material.GetOSD() as OSDMap;
                    allOsd.Add(matMap);
                }
            }

            m_log.Debug("[RenderMaterials]: matsCount: " + allOsd.Count.ToString());

            OSDMap resp = new OSDMap();

            resp["Zipped"] = ZCompressOSD(allOsd, false);
            return(OSDParser.SerializeLLSDXmlString(resp));
        }
        /// <summary>
        /// Given an array of Materials IDs return the data to the caller.
        /// </summary>
        /// <param name="respArr"></param>
        /// <param name="requestedMaterials"></param>
        private void ReturnRequestedMaterials(ref OSDArray respArr, OSDArray requestedMaterials)
        {
            lock (m_knownMaterials)
            {
                foreach (OSD elem in requestedMaterials)
                {
                    UUID id = new UUID(elem.AsBinary(), 0);
                    if (m_knownMaterials.ContainsKey(id))
                    {
                        m_log.Debug("[RenderMaterials]: request for known material ID: " + id.ToString());

                        var    matEntry = m_knownMaterials[id];
                        OSDMap matMap   = new OSDMap();
                        matMap["ID"]       = elem.AsBinary();
                        matMap["Material"] = matEntry.material.GetOSD() as OSDMap;
                        respArr.Add(matMap);
                    }
                    else
                    {
                        m_log.Debug("[RenderMaterials]: request for UNKNOWN material ID: " + id.ToString());
                    }
                }
            }
        }
Esempio n. 25
0
        public void TestInventoryDescendentsFetch()
        {
            TestHelpers.InMethod();
            TestHelpers.EnableLogging();

            BaseHttpServer httpServer = MainServer.Instance;
            Scene          scene      = new SceneHelpers().SetupScene();

            CapabilitiesModule    capsModule = new CapabilitiesModule();
            WebFetchInvDescModule wfidModule = new WebFetchInvDescModule(false);

            IConfigSource config = new IniConfigSource();

            config.AddConfig("ClientStack.LindenCaps");
            config.Configs["ClientStack.LindenCaps"].Set("Cap_FetchInventoryDescendents2", "localhost");

            SceneHelpers.SetupSceneModules(scene, config, capsModule, wfidModule);

            UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));

            // We need a user present to have any capabilities set up
            SceneHelpers.AddScenePresence(scene, ua.PrincipalID);

            TestHttpRequest req = new TestHttpRequest();

            OpenSim.Framework.Capabilities.Caps userCaps = capsModule.GetCapsForUser(ua.PrincipalID);
            PollServiceEventArgs pseArgs;

            userCaps.TryGetPollHandler("FetchInventoryDescendents2", out pseArgs);
            req.UriPath = pseArgs.Url;
            req.Uri     = new Uri(req.UriPath);

            // Retrieve root folder details directly so that we can request
            InventoryFolderBase folder = scene.InventoryService.GetRootFolder(ua.PrincipalID);

            OSDMap osdFolder = new OSDMap();

            osdFolder["folder_id"]     = folder.ID;
            osdFolder["owner_id"]      = ua.PrincipalID;
            osdFolder["fetch_folders"] = true;
            osdFolder["fetch_items"]   = true;
            osdFolder["sort_order"]    = 0;

            OSDArray osdFoldersArray = new OSDArray();

            osdFoldersArray.Add(osdFolder);

            OSDMap osdReqMap = new OSDMap();

            osdReqMap["folders"] = osdFoldersArray;

            req.Body = new MemoryStream(OSDParser.SerializeLLSDXmlBytes(osdReqMap));

            TestHttpClientContext context = new TestHttpClientContext(false);

            MainServer.Instance.OnRequest(context, new RequestEventArgs(req));

            // Drive processing of the queued inventory request synchronously.
            wfidModule.WaitProcessQueuedInventoryRequest();
            MainServer.Instance.PollServiceRequestManager.WaitPerformResponse();

//            System.Threading.Thread.Sleep(10000);

            OSDMap   responseOsd = (OSDMap)OSDParser.DeserializeLLSDXml(context.ResponseBody);
            OSDArray foldersOsd  = (OSDArray)responseOsd["folders"];
            OSDMap   folderOsd   = (OSDMap)foldersOsd[0];

            // A sanity check that the response has the expected number of descendents for a default inventory
            // TODO: Need a more thorough check.
            Assert.That((int)folderOsd["descendents"], Is.EqualTo(16));
        }
Esempio n. 26
0
        public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request);

            OSDMap   requestmap     = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
            OSDArray itemsRequested = (OSDArray)requestmap["items"];

            UUID[] itemIDs = new UUID[itemsRequested.Count];
            int    i       = 0;

            foreach (OSDMap osdItemId in itemsRequested)
            {
                itemIDs[i++] = osdItemId["item_id"].AsUUID();
            }

            InventoryItemBase[] items = null;

            if (m_agentID != UUID.Zero)
            {
                items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs);
            }
            else
            {
                items = new InventoryItemBase[itemsRequested.Count];
                foreach (UUID id in itemIDs)
                {
                    items[i++] = m_inventoryService.GetItem(UUID.Zero, id);
                }
            }

            StringBuilder lsl = LLSDxmlEncode.Start(4096);

            LLSDxmlEncode.AddMap(lsl);

            if (m_agentID == UUID.Zero && items.Length > 0)
            {
                LLSDxmlEncode.AddElem("agent_id", items[0].Owner, lsl);
            }
            else
            {
                LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl);
            }

            if (items == null || items.Length == 0)
            {
                LLSDxmlEncode.AddEmptyArray("items", lsl);
            }
            else
            {
                LLSDxmlEncode.AddArray("items", lsl);
                foreach (InventoryItemBase item in items)
                {
                    if (item != null)
                    {
                        item.ToLLSDxml(lsl, 0xff);
                    }
                }
                LLSDxmlEncode.AddEndArray(lsl);
            }

            LLSDxmlEncode.AddEndMap(lsl);
            return(LLSDxmlEncode.End(lsl));;
        }
Esempio n. 27
0
        // parses a LOD or physics mesh component
        private bool submesh(byte[] data, int offset, int size, out int ntriangles, out int nsides)
        {
            ntriangles = 0;
            nsides     = 0;

            OSD decodedMeshOsd = new OSD();

            try
            {
                using (MemoryStream outMs = new MemoryStream())
                {
                    using (MemoryStream inMs = new MemoryStream(data, offset, size))
                    {
                        using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress))
                        {
                            byte[] readBuffer = new byte[2048];
                            inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header
                            int readLen = 0;

                            while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
                            {
                                outMs.Write(readBuffer, 0, readLen);
                            }
                        }
                    }
                    outMs.Seek(0, SeekOrigin.Begin);
                    decodedMeshOsd = OSDParser.DeserializeLLSDBinary(outMs);
                }
            }
            catch
            {
                return(false);
            }

            OSDArray decodedMeshOsdArray = null;

            byte[] dummy;

            decodedMeshOsdArray = (OSDArray)decodedMeshOsd;
            foreach (OSD subMeshOsd in decodedMeshOsdArray)
            {
                if (subMeshOsd is OSDMap)
                {
                    OSDMap subtmpmap = (OSDMap)subMeshOsd;
                    if (subtmpmap.ContainsKey("NoGeometry") && ((OSDBoolean)subtmpmap["NoGeometry"]))
                    {
                        continue;
                    }

                    if (!subtmpmap.ContainsKey("Position"))
                    {
                        return(false);
                    }

                    if (subtmpmap.ContainsKey("TriangleList"))
                    {
                        dummy       = subtmpmap["TriangleList"].AsBinary();
                        ntriangles += dummy.Length / bytesPerCoord;
                    }
                    else
                    {
                        return(false);
                    }
                    nsides++;
                }
            }

            return(true);
        }
Esempio n. 28
0
 protected static OSDMap MapLayerResponce(OSDArray layerData, OSDArray mapBlocksData)
 {
     OSDMap map = new OSDMap();
     OSDMap agentMap = new OSDMap();
     agentMap["Flags"] = 0;
     map["AgentData"] = agentMap;
     map["LayerData"] = layerData;
     map["MapBlocks"] = mapBlocksData;
     return map;
 }
Esempio n. 29
0
        public OSD HandleRemoteMapItemRequest(string path, OSD request, IPEndPoint endpoint)
        {
            uint xstart = 0;
            uint ystart = 0;

            Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart);

            OSDMap responsemap = new OSDMap();
            OSDMap responsemapdata = new OSDMap();
            int tc = Environment.TickCount;

            List<ScenePresence> avatars = m_scene.GetAvatars();
            OSDArray responsearr = new OSDArray(avatars.Count);

            if (avatars.Count == 0)
            {
                responsemapdata = new OSDMap();
                responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1));
                responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1));
                responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
                responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
                responsemapdata["Extra"] = OSD.FromInteger(0);
                responsemapdata["Extra2"] = OSD.FromInteger(0);
                responsearr.Add(responsemapdata);

                responsemap["6"] = responsearr;
            }
            else
            {
                responsearr = new OSDArray(avatars.Count);
                foreach (ScenePresence av in avatars)
                {
                    Vector3 avpos;
                    if (av.HasSafePosition(out avpos))
                    {
                        responsemapdata = new OSDMap();
                        responsemapdata["X"] = OSD.FromInteger((int)(xstart + avpos.X));
                        responsemapdata["Y"] = OSD.FromInteger((int)(ystart + avpos.Y));
                        responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
                        responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
                        responsemapdata["Extra"] = OSD.FromInteger(1);
                        responsemapdata["Extra2"] = OSD.FromInteger(0);
                        responsearr.Add(responsemapdata);
                    }
                }
                responsemap["6"] = responsearr;
            }
            return responsemap;
        }
Esempio n. 30
0
 public OSDArray ArrayListToOSDArray(ArrayList arrlst)
 {
     OSDArray llsdBack = new OSDArray();
     foreach (Hashtable ht in arrlst)
     {
         OSDMap mp = new OSDMap();
         foreach (DictionaryEntry deHt in ht)
         {
             mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value));
         }
         llsdBack.Add(mp);
     }
     return llsdBack;
 }
Esempio n. 31
0
 private static OSDArray WrapOSDMap(OSDMap wrapMe)
 {
     OSDArray array = new OSDArray();
     array.Add(wrapMe);
     return array;
 }
Esempio n. 32
0
        // parses a LOD or physics mesh component
        private bool submesh(byte[] data, int offset, int size, out int ntriangles)
        {
            ntriangles = 0;

            OSD decodedMeshOsd = new OSD();

            byte[] meshBytes = new byte[size];
            System.Buffer.BlockCopy(data, offset, meshBytes, 0, size);
            try
            {
                using (MemoryStream inMs = new MemoryStream(meshBytes))
                {
                    using (MemoryStream outMs = new MemoryStream())
                    {
                        using (ZOutputStream zOut = new ZOutputStream(outMs))
                        {
                            byte[] readBuffer = new byte[4096];
                            int    readLen    = 0;
                            while ((readLen = inMs.Read(readBuffer, 0, readBuffer.Length)) > 0)
                            {
                                zOut.Write(readBuffer, 0, readLen);
                            }
                            zOut.Flush();
                            outMs.Seek(0, SeekOrigin.Begin);

                            byte[] decompressedBuf = outMs.GetBuffer();
                            decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf);
                        }
                    }
                }
            }
            catch
            {
                return(false);
            }

            OSDArray decodedMeshOsdArray = null;

            byte[] dummy;

            decodedMeshOsdArray = (OSDArray)decodedMeshOsd;
            foreach (OSD subMeshOsd in decodedMeshOsdArray)
            {
                if (subMeshOsd is OSDMap)
                {
                    OSDMap subtmpmap = (OSDMap)subMeshOsd;
                    if (subtmpmap.ContainsKey("NoGeometry") && ((OSDBoolean)subtmpmap["NoGeometry"]))
                    {
                        continue;
                    }

                    if (!subtmpmap.ContainsKey("Position"))
                    {
                        return(false);
                    }

                    if (subtmpmap.ContainsKey("TriangleList"))
                    {
                        dummy       = subtmpmap["TriangleList"].AsBinary();
                        ntriangles += dummy.Length / bytesPerCoord;
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 33
0
 protected void InitLoginParameters()
 {
     m_connectionParams.Add(FIELDFIRST, "");
     m_connectionParams.Add(FIELDLAST, "");
     m_connectionParams.Add(FIELDPASS, "");
     m_connectionParams.Add(FIELDGRID, "");
     m_connectionParams.Add(FIELDSIM, "");
     m_connectionParams.Add(FIELDMSG, delegate(string k) {
     return new OMVSD.OSDString(m_loginMsg);
     });
     // some of the values are calculated when they are fetched. Provide delgates
     m_connectionParams.Add(FIELDCURRENTSIM, RuntimeValueFetch);
     m_connectionParams.Add(FIELDCURRENTGRID, RuntimeValueFetch);
     m_connectionParams.Add(FIELDPOSSIBLEGRIDS, delegate(string k) {
     try {
         OMVSD.OSDArray gridNames = new OMVSD.OSDArray();
         World.World.Instance.Grids.ForEach(delegate(OMVSD.OSDMap gg) { gridNames.Add(gg["Name"]); });
         return gridNames;
     }
     catch {
     }
     return new OMVSD.OSDArray();
     });
     m_connectionParams.Add(FIELDLOGINSTATE, delegate(string k) {
     if (m_isLoggedIn) {
         return new OMVSD.OSDString("login");
     }
     if (m_isLoggingIn) {
         return new OMVSD.OSDString("loggingin");
     }
     if (m_isLoggingOut) {
         return new OMVSD.OSDString("loggingout");
     }
     return new OMVSD.OSDString("logout");
     });
     m_connectionParams.Add(FIELDPOSITIONX, RuntimeValueFetch);
     m_connectionParams.Add(FIELDPOSITIONY, RuntimeValueFetch);
     m_connectionParams.Add(FIELDPOSITIONZ, RuntimeValueFetch);
 }
Esempio n. 34
0
        /// <summary>
        /// Convert raw uploaded data into the appropriate asset and item.
        /// </summary>
        /// <param name="assetID"></param>
        /// <param name="inventoryItem"></param>
        /// <param name="data"></param>
        public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
                                          UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
                                          string assetType)
        {
            m_log.DebugFormat(
                "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}",
                assetID, inventoryItem, inventoryType, assetType);

            sbyte assType = 0;
            sbyte inType  = 0;

            if (inventoryType == "sound")
            {
                inType  = 1;
                assType = 1;
            }
            else if (inventoryType == "animation")
            {
                inType  = 19;
                assType = 20;
            }
            else if (inventoryType == "wearable")
            {
                inType = 18;
                switch (assetType)
                {
                case "bodypart":
                    assType = 13;
                    break;

                case "clothing":
                    assType = 5;
                    break;
                }
            }
            else if (inventoryType == "object")
            {
                inType  = (sbyte)InventoryType.Object;
                assType = (sbyte)AssetType.Object;

                List <Vector3>    positions     = new List <Vector3>();
                List <Quaternion> rotations     = new List <Quaternion>();
                OSDMap            request       = (OSDMap)OSDParser.DeserializeLLSDXml(data);
                OSDArray          instance_list = (OSDArray)request["instance_list"];
                OSDArray          mesh_list     = (OSDArray)request["mesh_list"];
                OSDArray          texture_list  = (OSDArray)request["texture_list"];
                SceneObjectGroup  grp           = null;

                List <UUID> textures = new List <UUID>();
                for (int i = 0; i < texture_list.Count; i++)
                {
                    AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, "");
                    textureAsset.Data = texture_list[i].AsBinary();
                    m_assetService.Store(textureAsset);
                    textures.Add(textureAsset.FullID);
                }

                for (int i = 0; i < mesh_list.Count; i++)
                {
                    PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();

                    Primitive.TextureEntry textureEntry
                        = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE);
                    OSDMap inner_instance_list = (OSDMap)instance_list[i];

                    OSDArray face_list = (OSDArray)inner_instance_list["face_list"];
                    for (uint face = 0; face < face_list.Count; face++)
                    {
                        OSDMap faceMap = (OSDMap)face_list[(int)face];
                        Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face);
                        if (faceMap.ContainsKey("fullbright"))
                        {
                            f.Fullbright = faceMap["fullbright"].AsBoolean();
                        }
                        if (faceMap.ContainsKey("diffuse_color"))
                        {
                            f.RGBA = faceMap["diffuse_color"].AsColor4();
                        }

                        int   textureNum = faceMap["image"].AsInteger();
                        float imagerot   = faceMap["imagerot"].AsInteger();
                        float offsets    = (float)faceMap["offsets"].AsReal();
                        float offsett    = (float)faceMap["offsett"].AsReal();
                        float scales     = (float)faceMap["scales"].AsReal();
                        float scalet     = (float)faceMap["scalet"].AsReal();

                        if (imagerot != 0)
                        {
                            f.Rotation = imagerot;
                        }

                        if (offsets != 0)
                        {
                            f.OffsetU = offsets;
                        }

                        if (offsett != 0)
                        {
                            f.OffsetV = offsett;
                        }

                        if (scales != 0)
                        {
                            f.RepeatU = scales;
                        }

                        if (scalet != 0)
                        {
                            f.RepeatV = scalet;
                        }

                        if (textures.Count > textureNum)
                        {
                            f.TextureID = textures[textureNum];
                        }
                        else
                        {
                            f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE;
                        }

                        textureEntry.FaceTextures[face] = f;
                    }

                    pbs.TextureEntry = textureEntry.GetBytes();

                    AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, "");
                    meshAsset.Data = mesh_list[i].AsBinary();
                    m_assetService.Store(meshAsset);

                    pbs.SculptEntry   = true;
                    pbs.SculptTexture = meshAsset.FullID;
                    pbs.SculptType    = (byte)SculptType.Mesh;
                    pbs.SculptData    = meshAsset.Data;

                    Vector3    position = inner_instance_list["position"].AsVector3();
                    Vector3    scale    = inner_instance_list["scale"].AsVector3();
                    Quaternion rotation = inner_instance_list["rotation"].AsQuaternion();

// no longer used - begin ------------------------
//                    int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger();
//                    int material = inner_instance_list["material"].AsInteger();
//                    int mesh = inner_instance_list["mesh"].AsInteger();

//                    OSDMap permissions = (OSDMap)inner_instance_list["permissions"];
//                    int base_mask = permissions["base_mask"].AsInteger();
//                    int everyone_mask = permissions["everyone_mask"].AsInteger();
//                    UUID creator_id = permissions["creator_id"].AsUUID();
//                    UUID group_id = permissions["group_id"].AsUUID();
//                    int group_mask = permissions["group_mask"].AsInteger();
//                    bool is_owner_group = permissions["is_owner_group"].AsBoolean();
//                    UUID last_owner_id = permissions["last_owner_id"].AsUUID();
//                    int next_owner_mask = permissions["next_owner_mask"].AsInteger();
//                    UUID owner_id = permissions["owner_id"].AsUUID();
//                    int owner_mask = permissions["owner_mask"].AsInteger();
// no longer used - end ------------------------

                    UUID owner_id = m_HostCapsObj.AgentID;

                    SceneObjectPart prim
                        = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero);

                    prim.Scale          = scale;
                    prim.OffsetPosition = position;
                    rotations.Add(rotation);
                    positions.Add(position);
                    prim.UUID         = UUID.Random();
                    prim.CreatorID    = owner_id;
                    prim.OwnerID      = owner_id;
                    prim.GroupID      = UUID.Zero;
                    prim.LastOwnerID  = prim.OwnerID;
                    prim.CreationDate = Util.UnixTimeSinceEpoch();
                    prim.Name         = assetName;
                    prim.Description  = "";

//                    prim.BaseMask = (uint)base_mask;
//                    prim.EveryoneMask = (uint)everyone_mask;
//                    prim.GroupMask = (uint)group_mask;
//                    prim.NextOwnerMask = (uint)next_owner_mask;
//                    prim.OwnerMask = (uint)owner_mask;

                    if (grp == null)
                    {
                        grp = new SceneObjectGroup(prim);
                    }
                    else
                    {
                        grp.AddPart(prim);
                    }
                }

                // Fix first link number
                if (grp.Parts.Length > 1)
                {
                    grp.RootPart.LinkNum++;
                }

                Vector3 rootPos = positions[0];
                grp.AbsolutePosition = rootPos;
                for (int i = 0; i < positions.Count; i++)
                {
                    Vector3 offset = positions[i] - rootPos;
                    grp.Parts[i].OffsetPosition = offset;
                }

                for (int i = 0; i < rotations.Count; i++)
                {
                    if (i != 0)
                    {
                        grp.Parts[i].RotationOffset = rotations[i];
                    }
                }

                grp.UpdateGroupRotationR(rotations[0]);
                data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp));
            }

            AssetBase asset;

            asset      = new AssetBase(assetID, assetName, assType, m_HostCapsObj.AgentID.ToString());
            asset.Data = data;
            if (AddNewAsset != null)
            {
                AddNewAsset(asset);
            }
            else if (m_assetService != null)
            {
                m_assetService.Store(asset);
            }

            InventoryItemBase item = new InventoryItemBase();

            item.Owner       = m_HostCapsObj.AgentID;
            item.CreatorId   = m_HostCapsObj.AgentID.ToString();
            item.CreatorData = String.Empty;
            item.ID          = inventoryItem;
            item.AssetID     = asset.FullID;
            item.Description = assetDescription;
            item.Name        = assetName;
            item.AssetType   = assType;
            item.InvType     = inType;
            item.Folder      = parentFolder;

            // If we set PermissionMask.All then when we rez the item the next permissions will replace the current
            // (owner) permissions.  This becomes a problem if next permissions are changed.
            item.CurrentPermissions
                = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);

            item.BasePermissions     = (uint)PermissionMask.All;
            item.EveryOnePermissions = 0;
            item.NextPermissions     = (uint)PermissionMask.All;
            item.CreationDate        = Util.UnixTimeSinceEpoch();

            if (AddNewInventoryItem != null)
            {
                AddNewInventoryItem(m_HostCapsObj.AgentID, item);
            }
        }
Esempio n. 35
0
        private OSDMap invokeRezAvatarCap(OSDMap responseMap, string CapAddress, OGPState userState)
        {
            Scene reg = GetRootScene();

            WebRequest DeRezRequest = WebRequest.Create(CapAddress);
            DeRezRequest.Method = "POST";
            DeRezRequest.ContentType = "application/xml+llsd";

            OSDMap RAMap = new OSDMap();
            OSDMap AgentParms = new OSDMap();
            OSDMap RegionParms = new OSDMap();

            OSDArray Parameter = new OSDArray(2);

            OSDMap version = new OSDMap();
            version["version"] = OSD.FromInteger(userState.src_version);
            Parameter.Add(version);

            OSDMap SrcData = new OSDMap();
            SrcData["estate_id"] = OSD.FromInteger(reg.RegionInfo.EstateSettings.EstateID);
            SrcData["parent_estate_id"] = OSD.FromInteger((reg.RegionInfo.EstateSettings.ParentEstateID == 100 ? 1 : reg.RegionInfo.EstateSettings.ParentEstateID));
            SrcData["region_id"] = OSD.FromUUID(reg.RegionInfo.originRegionID);
            SrcData["visible_to_parent"] = OSD.FromBoolean(userState.visible_to_parent);
            Parameter.Add(SrcData);

            AgentParms["first_name"] = OSD.FromString(userState.first_name);
            AgentParms["last_name"] = OSD.FromString(userState.last_name);
            AgentParms["agent_id"] = OSD.FromUUID(userState.agent_id);
            RegionParms["region_id"] = OSD.FromUUID(userState.region_id);
            AgentParms["circuit_code"] = OSD.FromInteger(userState.circuit_code);
            AgentParms["secure_session_id"] = OSD.FromUUID(userState.secure_session_id);
            AgentParms["session_id"] = OSD.FromUUID(userState.session_id);
            AgentParms["agent_access"] = OSD.FromBoolean(userState.agent_access);
            AgentParms["god_level"] = OSD.FromInteger(userState.god_level);
            AgentParms["god_overide"] = OSD.FromBoolean(userState.god_overide);
            AgentParms["identified"] = OSD.FromBoolean(userState.identified);
            AgentParms["transacted"] = OSD.FromBoolean(userState.transacted);
            AgentParms["age_verified"] = OSD.FromBoolean(userState.age_verified);
            AgentParms["limited_to_estate"] = OSD.FromInteger(userState.limited_to_estate);
            AgentParms["inventory_host"] = OSD.FromString(userState.inventory_host);

            // version 1
            RAMap = AgentParms;

            // Planned for version 2
            // RAMap["agent_params"] = AgentParms;

            RAMap["region_params"] = RegionParms;
            RAMap["parameter"] = Parameter;

            string RAMapString = RAMap.ToString();
            m_log.InfoFormat("[OGP] RAMap string {0}", RAMapString);
            OSD LLSDofRAMap = RAMap; // RENAME if this works

            m_log.InfoFormat("[OGP]: LLSD of map as string  was {0}", LLSDofRAMap.ToString());
            //m_log.InfoFormat("[OGP]: LLSD+XML: {0}", LLSDParser.SerializeXmlString(LLSDofRAMap));
            byte[] buffer = OSDParser.SerializeLLSDXmlBytes(LLSDofRAMap);

            //string bufferDump = System.Text.Encoding.ASCII.GetString(buffer);
            //m_log.InfoFormat("[OGP]: buffer form is {0}",bufferDump);
            //m_log.InfoFormat("[OGP]: LLSD of map was {0}",buffer.Length);

            Stream os = null;
            try
            { // send the Post
                DeRezRequest.ContentLength = buffer.Length;   //Count bytes to send
                os = DeRezRequest.GetRequestStream();
                os.Write(buffer, 0, buffer.Length);         //Send it
                os.Close();
                m_log.InfoFormat("[OGP]: Derez Avatar Posted Rez Avatar request to remote sim {0}", CapAddress);
            }
            catch (WebException ex)
            {
                m_log.InfoFormat("[OGP] Bad send on de_rez_avatar {0}", ex.Message);
                responseMap["connect"] = OSD.FromBoolean(false);

                return responseMap;
            }

            m_log.Info("[OGP] waiting for a reply after rez avatar send");
            string rez_avatar_reply = null;
            { // get the response
                try
                {
                    WebResponse webResponse = DeRezRequest.GetResponse();
                    if (webResponse == null)
                    {
                        m_log.Info("[OGP:] Null reply on rez_avatar post");
                    }

                    StreamReader sr = new StreamReader(webResponse.GetResponseStream());
                    rez_avatar_reply = sr.ReadToEnd().Trim();
                    m_log.InfoFormat("[OGP]: rez_avatar reply was {0} ", rez_avatar_reply);

                }
                catch (WebException ex)
                {
                    m_log.InfoFormat("[OGP]: exception on read after send of rez avatar {0}", ex.Message);
                    responseMap["connect"] = OSD.FromBoolean(false);

                    return responseMap;
                }
                OSD rezResponse = null;
                try
                {
                    rezResponse = OSDParser.DeserializeLLSDXml(rez_avatar_reply);

                    responseMap = (OSDMap)rezResponse;
                }
                catch (Exception ex)
                {
                    m_log.InfoFormat("[OGP]: exception on parse of rez reply {0}", ex.Message);
                    responseMap["connect"] = OSD.FromBoolean(false);

                    return responseMap;
                }
            }
            return responseMap;
        }
Esempio n. 36
0
        public OSD DerezAvatarMethod(string path, OSD request)
        {
            m_log.ErrorFormat("DerezPath: {0}, Request: {1}", path, request.ToString());

            //LLSD llsdResponse = null;
            OSDMap responseMap = new OSDMap();

            string[] PathArray = path.Split('/');
            m_log.InfoFormat("[OGP]: prefix {0}, uuid {1}, suffix {2}", PathArray[1], PathArray[2], PathArray[3]);
            string uuidString = PathArray[2];
            m_log.InfoFormat("[OGP]: Request to Derez avatar with UUID {0}", uuidString);
            UUID userUUID = UUID.Zero;
            if (UUID.TryParse(uuidString, out userUUID))
            {
                UUID RemoteID = (UUID)uuidString;
                UUID LocalID = RemoteID;
                // FIXME: TODO: Routine to map RemoteUUIDs to LocalUUIds
                //         would be done already..  but the client connects with the Aditi UUID
                //         regardless over the UDP stack

                OGPState userState = GetOGPState(LocalID);
                if (userState.agent_id != UUID.Zero)
                {
                    //OSDMap outboundRequestMap = new OSDMap();
                    OSDMap inboundRequestMap = (OSDMap)request;
                    string rezAvatarString = inboundRequestMap["rez_avatar"].AsString();
                    if (rezAvatarString.Length == 0)
                    {
                        rezAvatarString = inboundRequestMap["rez_avatar/rez"].AsString();
                    }
                    OSDArray LookAtArray = new OSDArray();
                    LookAtArray.Add(OSD.FromInteger(1));
                    LookAtArray.Add(OSD.FromInteger(1));
                    LookAtArray.Add(OSD.FromInteger(1));

                    OSDArray PositionArray = new OSDArray();
                    PositionArray.Add(OSD.FromInteger(128));
                    PositionArray.Add(OSD.FromInteger(128));
                    PositionArray.Add(OSD.FromInteger(40));

                    OSDArray lookArray = new OSDArray();
                    lookArray.Add(OSD.FromInteger(128));
                    lookArray.Add(OSD.FromInteger(128));
                    lookArray.Add(OSD.FromInteger(40));

                    responseMap["connect"] = OSD.FromBoolean(true);// it's okay to give this user up
                    responseMap["look_at"] = LookAtArray;

                    m_log.WarnFormat("[OGP]: Invoking rez_avatar on host:{0} for avatar: {1} {2}", rezAvatarString, userState.first_name, userState.last_name);

                    OSDMap rezResponseMap = invokeRezAvatarCap(responseMap, rezAvatarString,userState);

                    // If invoking it returned an error, parse and end
                    if (rezResponseMap.ContainsKey("connect"))
                    {
                        if (rezResponseMap["connect"].AsBoolean() == false)
                        {
                            return responseMap;
                        }
                    }

                    string rezRespSeedCap = "";

                    // DEPRECATED
                    if (rezResponseMap.ContainsKey("seed_capability"))
                        rezRespSeedCap = rezResponseMap["seed_capability"].AsString();
                    
                    // REPLACEMENT
                    if (rezResponseMap.ContainsKey("region_seed_capability"))
                        rezRespSeedCap = rezResponseMap["region_seed_capability"].AsString();

                    // REPLACEMENT
                    if (rezResponseMap.ContainsKey("rez_avatar/rez"))
                        rezRespSeedCap = rezResponseMap["rez_avatar/rez"].AsString();

                    // DEPRECATED
                    string rezRespSim_ip = rezResponseMap["sim_ip"].AsString();
                    
                    string rezRespSim_host = rezResponseMap["sim_host"].AsString();

                    int rrPort = rezResponseMap["sim_port"].AsInteger();
                    int rrX = rezResponseMap["region_x"].AsInteger();
                    int rrY = rezResponseMap["region_y"].AsInteger();
                    m_log.ErrorFormat("X:{0}, Y:{1}", rrX, rrY);
                    UUID rrRID = rezResponseMap["region_id"].AsUUID();
                    OSDArray RezResponsePositionArray = null;
                    string rrAccess = rezResponseMap["sim_access"].AsString();
                    if (rezResponseMap.ContainsKey("position"))
                    {
                        RezResponsePositionArray = (OSDArray)rezResponseMap["position"];
                    }
                    // DEPRECATED
                    responseMap["seed_capability"] = OSD.FromString(rezRespSeedCap);
                    
                    // REPLACEMENT r3
                    responseMap["region_seed_capability"] = OSD.FromString(rezRespSeedCap);

                    // DEPRECATED
                    responseMap["sim_ip"] = OSD.FromString(Util.GetHostFromDNS(rezRespSim_ip).ToString());
                    
                    responseMap["sim_host"] = OSD.FromString(rezRespSim_host);
                    responseMap["sim_port"] = OSD.FromInteger(rrPort);
                    responseMap["region_x"] = OSD.FromInteger(rrX);
                    responseMap["region_y"] = OSD.FromInteger(rrY);
                    responseMap["region_id"] = OSD.FromUUID(rrRID);
                    responseMap["sim_access"] = OSD.FromString(rrAccess);

                    if (RezResponsePositionArray != null)
                    {
                        responseMap["position"] = RezResponsePositionArray;
                    }
                    responseMap["look_at"] = lookArray;
                    responseMap["connect"] = OSD.FromBoolean(true);

                    ShutdownConnection(LocalID,this);
                    // PLEASE STOP CHANGING THIS TO an M_LOG, M_LOG DOESN'T WORK ON MULTILINE .TOSTRINGS
                    Console.WriteLine("RESPONSEDEREZ: " + responseMap.ToString());
                    return responseMap;
                }
                else
                {
                    return GenerateNoStateMessage(LocalID);
                }
            }
            else
            {
                return GenerateNoHandlerMessage();
            }

            //return responseMap;
        }
Esempio n. 37
0
        public void FetchInventoryDescendentsRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, ExpiringKey <UUID> BadRequests)
        {
            //m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request);

            List <LLSDFetchInventoryDescendents> folders = null;
            List <UUID> bad_folders = new List <UUID>();

            try
            {
                OSDArray foldersrequested = null;
                OSD      tmp = OSDParser.DeserializeLLSDXml(httpRequest.InputStream);
                httpRequest.InputStream.Dispose();

                OSDMap map = (OSDMap)tmp;
                if (map.TryGetValue("folders", out tmp) && tmp is OSDArray)
                {
                    foldersrequested = tmp as OSDArray;
                }

                if (foldersrequested == null || foldersrequested.Count == 0)
                {
                    httpResponse.RawBuffer = EmptyResponse;
                    return;
                }

                folders = new List <LLSDFetchInventoryDescendents>(foldersrequested.Count);
                for (int i = 0; i < foldersrequested.Count; i++)
                {
                    OSDMap mfolder = foldersrequested[i] as OSDMap;
                    UUID   id      = mfolder["folder_id"].AsUUID();
                    if (BadRequests.ContainsKey(id))
                    {
                        bad_folders.Add(id);
                    }
                    else
                    {
                        LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents();
                        try
                        {
                            llsdRequest.folder_id     = id;
                            llsdRequest.owner_id      = mfolder["owner_id"].AsUUID();
                            llsdRequest.sort_order    = mfolder["sort_order"].AsInteger();
                            llsdRequest.fetch_folders = mfolder["fetch_folders"].AsBoolean();
                            llsdRequest.fetch_items   = mfolder["fetch_items"].AsBoolean();
                        }
                        catch (Exception e)
                        {
                            m_log.Debug("[WEB FETCH INV DESC HANDLER]: caught exception doing OSD deserialize" + e.Message);
                            continue;
                        }
                        folders.Add(llsdRequest);
                    }
                }
                foldersrequested = null;
                map.Clear();
                map = null;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[FETCH INV DESC]: fail parsing request: {0}", e.Message);
                httpResponse.RawBuffer = EmptyResponse;
                return;
            }

            if (folders == null || folders.Count == 0)
            {
                if (bad_folders.Count == 0)
                {
                    httpResponse.RawBuffer = EmptyResponse;
                    return;
                }

                StringBuilder sb = osStringBuilderCache.Acquire();
                sb.Append("[WEB FETCH INV DESC HANDLER]: Unable to fetch folders owned by ");
                sb.Append("Unknown");
                sb.Append(" :");
                int limit = 5;
                int count = 0;
                foreach (UUID bad in bad_folders)
                {
                    if (BadRequests.ContainsKey(bad))
                    {
                        continue;
                    }
                    sb.Append(" ");
                    sb.Append(bad.ToString());
                    ++count;
                    if (--limit < 0)
                    {
                        break;
                    }
                }

                if (count > 0)
                {
                    if (limit < 0)
                    {
                        sb.Append(" ...");
                    }
                    m_log.Warn(osStringBuilderCache.GetStringAndRelease(sb));
                }
                else
                {
                    osStringBuilderCache.Release(sb);
                }

                sb = osStringBuilderCache.Acquire();
                sb.Append("<llsd><map><key>folders</key><array /></map><map><key>bad_folders</key><array>");
                foreach (UUID bad in bad_folders)
                {
                    sb.Append("<map><key>folder_id</key><uuid>");
                    sb.Append(bad.ToString());
                    sb.Append("</uuid><key>error</key><string>Unknown</string></map>");
                }
                sb.Append("</array></map></llsd>");
                httpResponse.RawBuffer = Util.UTF8NBGetbytes(osStringBuilderCache.GetStringAndRelease(sb));
                return;
            }

            int total_folders = 0;
            int total_items   = 0;

            UUID requester = folders[0].owner_id;

            List <InventoryCollection> invcollSet = Fetch(folders, bad_folders, ref total_folders, ref total_items);
            //m_log.DebugFormat("[XXX]: Got {0} folders from a request of {1}", invcollSet.Count, folders.Count);

            int invcollSetCount = 0;

            if (invcollSet != null)
            {
                invcollSetCount = invcollSet.Count;
            }

            int mem = 8192 + ((256 * invcollSetCount +
                               384 * total_folders +
                               1024 * total_items +
                               128 * bad_folders.Count) & 0x7ffff000);

            StringBuilder lastresponse = new StringBuilder(mem);

            lastresponse.Append("<llsd>");

            if (invcollSetCount > 0)
            {
                lastresponse.Append("<map><key>folders</key><array>");
                int i = 0;
                InventoryCollection thiscoll;
                for (i = 0; i < invcollSetCount; i++)
                {
                    thiscoll      = invcollSet[i];
                    invcollSet[i] = null;

                    LLSDxmlEncode.AddMap(lastresponse);
                    LLSDxmlEncode.AddElem("agent_id", thiscoll.OwnerID, lastresponse);
                    LLSDxmlEncode.AddElem("descendents", thiscoll.Descendents, lastresponse);
                    LLSDxmlEncode.AddElem("folder_id", thiscoll.FolderID, lastresponse);

                    if (thiscoll.Folders == null || thiscoll.Folders.Count == 0)
                    {
                        LLSDxmlEncode.AddEmptyArray("categories", lastresponse);
                    }
                    else
                    {
                        LLSDxmlEncode.AddArray("categories", lastresponse);
                        foreach (InventoryFolderBase invFolder in thiscoll.Folders)
                        {
                            LLSDxmlEncode.AddMap(lastresponse);

                            LLSDxmlEncode.AddElem("folder_id", invFolder.ID, lastresponse);
                            LLSDxmlEncode.AddElem("parent_id", invFolder.ParentID, lastresponse);
                            LLSDxmlEncode.AddElem("name", invFolder.Name, lastresponse);
                            LLSDxmlEncode.AddElem("type", invFolder.Type, lastresponse);
                            LLSDxmlEncode.AddElem("preferred_type", (int)-1, lastresponse);
                            LLSDxmlEncode.AddElem("version", invFolder.Version, lastresponse);

                            LLSDxmlEncode.AddEndMap(lastresponse);
                        }
                        LLSDxmlEncode.AddEndArray(lastresponse);
                    }

                    if (thiscoll.Items == null || thiscoll.Items.Count == 0)
                    {
                        LLSDxmlEncode.AddEmptyArray("items", lastresponse);
                    }
                    else
                    {
                        LLSDxmlEncode.AddArray("items", lastresponse);
                        foreach (InventoryItemBase invItem in thiscoll.Items)
                        {
                            invItem.ToLLSDxml(lastresponse);
                        }

                        LLSDxmlEncode.AddEndArray(lastresponse);
                    }

                    LLSDxmlEncode.AddElem("owner_id", thiscoll.OwnerID, lastresponse);
                    LLSDxmlEncode.AddElem("version", thiscoll.Version, lastresponse);

                    LLSDxmlEncode.AddEndMap(lastresponse);
                    invcollSet[i] = null;
                }
                lastresponse.Append("</array></map>");
                thiscoll = null;
            }
            else
            {
                lastresponse.Append("<map><key>folders</key><array /></map>");
            }

            if (bad_folders.Count > 0)
            {
                lastresponse.Append("<map><key>bad_folders</key><array>");
                foreach (UUID bad in bad_folders)
                {
                    BadRequests.Add(bad);
                    lastresponse.Append("<map><key>folder_id</key><uuid>");
                    lastresponse.Append(bad.ToString());
                    lastresponse.Append("</uuid><key>error</key><string>Unknown</string></map>");
                }
                lastresponse.Append("</array></map>");

                StringBuilder sb = osStringBuilderCache.Acquire();
                sb.Append("[WEB FETCH INV DESC HANDLER]: Unable to fetch folders owned by ");
                sb.Append(requester.ToString());
                sb.Append(" :");
                int limit = 9;
                foreach (UUID bad in bad_folders)
                {
                    sb.Append(" ");
                    sb.Append(bad.ToString());
                    if (--limit < 0)
                    {
                        break;
                    }
                }
                if (limit < 0)
                {
                    sb.Append(" ...");
                }
                m_log.Warn(osStringBuilderCache.GetStringAndRelease(sb));
            }
            lastresponse.Append("</llsd>");

            httpResponse.RawBuffer = Util.UTF8NBGetbytes(lastresponse.ToString());
        }
Esempio n. 38
0
        public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
        {
            uint xstart = 0;
            uint ystart = 0;

            Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart);

            // Service 6 (MAP_ITEM_AGENTS_LOCATION; green dots)

            OSDMap responsemap = new OSDMap();
            int tc = Environment.TickCount;
            if (m_scene.GetRootAgentCount() == 0)
            {
                OSDMap responsemapdata = new OSDMap();
                responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1));
                responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1));
                responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
                responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
                responsemapdata["Extra"] = OSD.FromInteger(0);
                responsemapdata["Extra2"] = OSD.FromInteger(0);
                OSDArray responsearr = new OSDArray();
                responsearr.Add(responsemapdata);

                responsemap["6"] = responsearr;
            }
            else
            {
                OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount());
                m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
                {
                    OSDMap responsemapdata = new OSDMap();
                    responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X));
                    responsemapdata["Y"] = OSD.FromInteger((int)(ystart + sp.AbsolutePosition.Y));
                    responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
                    responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
                    responsemapdata["Extra"] = OSD.FromInteger(1);
                    responsemapdata["Extra2"] = OSD.FromInteger(0);
                    responsearr.Add(responsemapdata);
                });
                responsemap["6"] = responsearr;
            }

            // Service 7 (MAP_ITEM_LAND_FOR_SALE)

            ILandChannel landChannel = m_scene.LandChannel;
            List<ILandObject> parcels = landChannel.AllParcels();

            if ((parcels == null) || (parcels.Count == 0))
            {
                OSDMap responsemapdata = new OSDMap();
                responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1));
                responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1));
                responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
                responsemapdata["Name"] = OSD.FromString("");
                responsemapdata["Extra"] = OSD.FromInteger(0);
                responsemapdata["Extra2"] = OSD.FromInteger(0);
                OSDArray responsearr = new OSDArray();
                responsearr.Add(responsemapdata);

                responsemap["7"] = responsearr;
            }
            else
            {
                OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount());
                foreach (ILandObject parcel_interface in parcels)
                {
                    // Play it safe
                    if (!(parcel_interface is LandObject))
                        continue;

                    LandObject land = (LandObject)parcel_interface;
                    LandData parcel = land.LandData;

                    // Show land for sale
                    if ((parcel.Flags & (uint)ParcelFlags.ForSale) == (uint)ParcelFlags.ForSale)
                    {
                        Vector3 min = parcel.AABBMin;
                        Vector3 max = parcel.AABBMax;
                        float x = (min.X+max.X)/2;
                        float y = (min.Y+max.Y)/2;

                        OSDMap responsemapdata = new OSDMap();
                        responsemapdata["X"] = OSD.FromInteger((int)(xstart + x));
                        responsemapdata["Y"] = OSD.FromInteger((int)(ystart + y));
                        // responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y));
                        responsemapdata["ID"] = OSD.FromUUID(parcel.GlobalID);
                        responsemapdata["Name"] = OSD.FromString(parcel.Name);
                        responsemapdata["Extra"] = OSD.FromInteger(parcel.Area);
                        responsemapdata["Extra2"] = OSD.FromInteger(parcel.SalePrice);
                        responsearr.Add(responsemapdata);
                    }
                }
                responsemap["7"] = responsearr;
            }

            if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero)
            {
                SceneObjectGroup sog = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject);
                if (sog != null)
                {
                    OSDArray responsearr = new OSDArray();
                    OSDMap responsemapdata = new OSDMap();
                    responsemapdata["X"] = OSD.FromInteger((int)(xstart + sog.AbsolutePosition.X));
                    responsemapdata["Y"] = OSD.FromInteger((int)(ystart + sog.AbsolutePosition.Y));
                    // responsemapdata["Z"] = OSD.FromInteger((int)m_scene.GetGroundHeight(x,y));
                    responsemapdata["ID"] = OSD.FromUUID(sog.UUID);
                    responsemapdata["Name"] = OSD.FromString(sog.Name);
                    responsemapdata["Extra"] = OSD.FromInteger(0); // color (unused)
                    responsemapdata["Extra2"] = OSD.FromInteger(0); // 0 = telehub / 1 = infohub
                    responsearr.Add(responsemapdata);

                    responsemap["1"] = responsearr;
                }
            }

            return responsemap;
        }
        public void TestInventoryDescendentsFetch()
        {
            TestHelpers.InMethod();
            TestHelpers.EnableLogging();

            BaseHttpServer httpServer = MainServer.Instance;
            Scene scene = new SceneHelpers().SetupScene();

            CapabilitiesModule capsModule = new CapabilitiesModule();
            WebFetchInvDescModule wfidModule = new WebFetchInvDescModule(false);

            IConfigSource config = new IniConfigSource();
            config.AddConfig("ClientStack.LindenCaps");
            config.Configs["ClientStack.LindenCaps"].Set("Cap_FetchInventoryDescendents2", "localhost");

            SceneHelpers.SetupSceneModules(scene, config, capsModule, wfidModule);

            UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));

            // We need a user present to have any capabilities set up
            SceneHelpers.AddScenePresence(scene, ua.PrincipalID);

            TestHttpRequest req = new TestHttpRequest();
            OpenSim.Framework.Capabilities.Caps userCaps = capsModule.GetCapsForUser(ua.PrincipalID);
            PollServiceEventArgs pseArgs;
            userCaps.TryGetPollHandler("FetchInventoryDescendents2", out pseArgs);
            req.UriPath = pseArgs.Url;
            req.Uri = new Uri(req.UriPath);

            // Retrieve root folder details directly so that we can request
            InventoryFolderBase folder = scene.InventoryService.GetRootFolder(ua.PrincipalID);

            OSDMap osdFolder = new OSDMap();
            osdFolder["folder_id"] = folder.ID;
            osdFolder["owner_id"] = ua.PrincipalID;
            osdFolder["fetch_folders"] = true;
            osdFolder["fetch_items"] = true;
            osdFolder["sort_order"] = 0;

            OSDArray osdFoldersArray = new OSDArray();
            osdFoldersArray.Add(osdFolder);

            OSDMap osdReqMap = new OSDMap();
            osdReqMap["folders"] = osdFoldersArray;

            req.Body = new MemoryStream(OSDParser.SerializeLLSDXmlBytes(osdReqMap));

            TestHttpClientContext context = new TestHttpClientContext(false);
            MainServer.Instance.OnRequest(context, new RequestEventArgs(req));

            // Drive processing of the queued inventory request synchronously.
            wfidModule.WaitProcessQueuedInventoryRequest();
            MainServer.Instance.PollServiceRequestManager.WaitPerformResponse();

//            System.Threading.Thread.Sleep(10000);

            OSDMap responseOsd = (OSDMap)OSDParser.DeserializeLLSDXml(context.ResponseBody);
            OSDArray foldersOsd = (OSDArray)responseOsd["folders"];
            OSDMap folderOsd = (OSDMap)foldersOsd[0];
           
            // A sanity check that the response has the expected number of descendents for a default inventory
            // TODO: Need a more thorough check.
            Assert.That((int)folderOsd["descendents"], Is.EqualTo(14));
        }
Esempio n. 40
0
		/// <summary>
		/// Callback for a map layer request
		/// </summary>
		/// <param name="request"></param>
		/// <param name="path"></param>
		/// <param name="param"></param>
		/// <param name="agentID"></param>
		/// <param name="caps"></param>
		/// <returns></returns>
		public string MapLayerRequest(string request, string path, string param,
		                              UUID agentID, Caps caps)
        {
            int bottom = (int)m_scene.RegionInfo.RegionLocY - MapViewLength;
            int top = (int)m_scene.RegionInfo.RegionLocY + MapViewLength;
            int left = (int)m_scene.RegionInfo.RegionLocX - MapViewLength;
            int right = (int)m_scene.RegionInfo.RegionLocX + MapViewLength;


            OSDArray layerData = new OSDArray();
            layerData.Add(GetOSDMapLayerResponse(bottom, left, right, top, new UUID("00000000-0000-1111-9999-000000000006")));
            OSDArray mapBlocksData = new OSDArray();
            
            ScenePresence avatarPresence = null;

            m_scene.TryGetScenePresence(agentID, out avatarPresence);

            if (avatarPresence != null)
            {
                List<MapBlockData> mapBlocks = new List<MapBlockData>();
                if (m_mapLayer != null)
                {
                    mapBlocks = m_mapLayer;
                }
                else
                {
                    List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
                            left * (int)Constants.RegionSize,
                            right * (int)Constants.RegionSize,
                            bottom * (int)Constants.RegionSize,
                            top * (int)Constants.RegionSize);
                    foreach (GridRegion r in regions)
                    {
                        mapBlocks.Add(MapBlockFromGridRegion(r));
                    }
                    m_mapLayer = mapBlocks;
                }
                foreach (MapBlockData block in m_mapLayer)
                {
                    //Add to the array
                    mapBlocksData.Add(block.ToOSD());
                }
            }
            OSDMap response = MapLayerResponce(layerData, mapBlocksData);
            string resp = OSDParser.SerializeLLSDXmlString(response);
            return resp;
		}
        /// <summary>
        /// GET request. Return all the materials we know about.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="request"></param>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <returns></returns>

        public string RenderMaterialsGetCap(string request)
        {
            OSDArray allOsd = new OSDArray();

            lock (m_knownMaterials)
            {
                foreach (KeyValuePair<UUID, RenderMaterialEntry> kvp in m_knownMaterials)
                {
                    OSDMap matMap = new OSDMap();
                    matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes());
                    matMap["Material"] = kvp.Value.material.GetOSD() as OSDMap;
                    allOsd.Add(matMap);
                }
            }

            m_log.Debug("[RenderMaterials]: matsCount: " + allOsd.Count.ToString());

            OSDMap resp = new OSDMap();
            resp["Zipped"] = ZCompressOSD(allOsd, false);
            return OSDParser.SerializeLLSDXmlString(resp);
        }
Esempio n. 42
0
        public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
        {
            uint xstart = 0;
            uint ystart = 0;

            Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart);

            OSDMap responsemap = new OSDMap();
            int tc = Environment.TickCount;
            if (m_scene.GetRootAgentCount() == 0)
            {
                OSDMap responsemapdata = new OSDMap();
                responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1));
                responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1));
                responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
                responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
                responsemapdata["Extra"] = OSD.FromInteger(0);
                responsemapdata["Extra2"] = OSD.FromInteger(0);
                OSDArray responsearr = new OSDArray();
                responsearr.Add(responsemapdata);

                responsemap["6"] = responsearr;
            }
            else
            {
                OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount());
                m_scene.ForEachScenePresence(delegate(ScenePresence sp)
                {
                    OSDMap responsemapdata = new OSDMap();
                    responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X));
                    responsemapdata["Y"] = OSD.FromInteger((int)(ystart + sp.AbsolutePosition.Y));
                    responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
                    responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
                    responsemapdata["Extra"] = OSD.FromInteger(1);
                    responsemapdata["Extra2"] = OSD.FromInteger(0);
                    responsearr.Add(responsemapdata);
                });
                responsemap["6"] = responsearr;
            }
            return responsemap;
        }
        /// <summary>
        /// Given an array of Materials IDs return the data to the caller.
        /// </summary>
        /// <param name="respArr"></param>
        /// <param name="requestedMaterials"></param>
        private void ReturnRequestedMaterials(ref OSDArray respArr, OSDArray requestedMaterials)
        {
            lock (m_knownMaterials)
            {
                foreach (OSD elem in requestedMaterials)
                {
                    UUID id = new UUID(elem.AsBinary(), 0);
                    if (m_knownMaterials.ContainsKey(id))
                    {
                        m_log.Debug("[RenderMaterials]: request for known material ID: " + id.ToString());

                        var matEntry = m_knownMaterials[id];
                        OSDMap matMap = new OSDMap();
                        matMap["ID"] = elem.AsBinary();
                        matMap["Material"] = matEntry.material.GetOSD() as OSDMap;
                        respArr.Add(matMap);
                    }
                    else
                    {
                        m_log.Warn("[RenderMaterials]: request for UNKNOWN material ID: " + id.ToString());
                    }
                }
            }
        }
Esempio n. 44
0
        /// <summary>
        /// Return the last log lines. Output in the format:
        /// <pre>
        /// {"logLines": [
        /// "line1",
        /// "line2",
        /// ...
        /// ]
        /// }
        /// </pre>
        /// </summary>
        /// <param name="pModelResult"></param>
        /// <returns></returns>
        public string RenderJson(Hashtable pModelResult)
        {
            OSDMap logInfo = new OpenMetaverse.StructuredData.OSDMap();

            OSDArray logLines = new OpenMetaverse.StructuredData.OSDArray();
            string tmp = normalizeEndLines.Replace(pModelResult["loglines"].ToString(), "\n");
            string[] result = Regex.Split(tmp, "\n");
            for (int i = 0; i < result.Length; i++)
            {
                logLines.Add(new OSDString(result[i]));
            }
            logInfo.Add("logLines", logLines);
            return logInfo.ToString();
        }
        public string RenderMaterialsPostCap(string request, UUID agentID)
        {
            OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
            OSDMap resp = new OSDMap();
            OSDArray respArr = new OSDArray();

            if (req.ContainsKey("Zipped"))
            {
                byte[] inBytes = req["Zipped"].AsBinary();

                try
                {
                    OSD osd = ZDecompressBytesToOsd(inBytes);
                    if (osd == null)
                    {
                        m_log.Warn("[MaterialsModule]: Decoded Materials request is empty");
                    }
                    else if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries
                    {
                        ReturnRequestedMaterials(ref respArr, osd as OSDArray);
                    }
                    else if (osd is OSDMap) // request to assign a material
                    {
                        AssignRequestedMaterials(osd as OSDMap, agentID);
                    }
                }
                catch (Exception e)
                {
                    m_log.Warn("[RenderMaterials]: exception decoding zipped CAP payload: " + e.ToString());
                }
            }

            resp["Zipped"] = ZCompressOSD(respArr, false);
            return OSDParser.SerializeLLSDXmlString(resp);
        }
Esempio n. 46
0
        public OSD RezAvatarMethod(string path, OSD request)
        {
            m_log.WarnFormat("[REZAVATAR]: {0}", request.ToString());

            OSDMap responseMap = new OSDMap();

            AgentCircuitData userData = null;

            // Only people we've issued a cap can go further
            if (TryGetAgentCircuitData(path,out userData))
            {
                OSDMap requestMap = (OSDMap)request;

                // take these values to start.  There's a few more
                UUID SecureSessionID=requestMap["secure_session_id"].AsUUID();
                UUID SessionID = requestMap["session_id"].AsUUID();
                int circuitcode = requestMap["circuit_code"].AsInteger();
                OSDArray Parameter = new OSDArray();
                if (requestMap.ContainsKey("parameter"))
                {
                   Parameter = (OSDArray)requestMap["parameter"];
                }

                //int version = 1;
                int estateID = 1;
                int parentEstateID = 1;
                UUID regionID = UUID.Zero;
                bool visibleToParent = true;

                for (int i = 0; i < Parameter.Count; i++)
                {
                    OSDMap item = (OSDMap)Parameter[i];
//                    if (item.ContainsKey("version"))
//                    {
//                        version = item["version"].AsInteger();
//                    }
                    if (item.ContainsKey("estate_id"))
                    {
                        estateID = item["estate_id"].AsInteger();
                    }
                    if (item.ContainsKey("parent_estate_id"))
                    {
                        parentEstateID = item["parent_estate_id"].AsInteger();

                    }
                    if (item.ContainsKey("region_id"))
                    {
                        regionID = item["region_id"].AsUUID();

                    }
                    if (item.ContainsKey("visible_to_parent"))
                    {
                        visibleToParent = item["visible_to_parent"].AsBoolean();
                    }
                }
                //Update our Circuit data with the real values
                userData.SecureSessionID = SecureSessionID;
                userData.SessionID = SessionID;

                OGPState userState = GetOGPState(userData.AgentID);

                // Locate a home scene suitable for the user.
                Scene homeScene = null;

                homeScene = GetScene(userState.teleported_into_region);
                
                if (homeScene == null)
                    homeScene = GetRootScene();

                if (homeScene != null)
                {
                    // Get a referenceokay -  to their Cap object so we can pull out the capobjectroot
                    Caps userCap 
                        = homeScene.CapsModule.GetCapsHandlerForUser(userData.AgentID);

                    //Update the circuit data in the region so this user is authorized
                    homeScene.UpdateCircuitData(userData);
                    homeScene.ChangeCircuitCode(userData.circuitcode,(uint)circuitcode);

                    // Load state
                    

                    // Keep state changes
                    userState.first_name = requestMap["first_name"].AsString();
                    userState.secure_session_id = requestMap["secure_session_id"].AsUUID();
                    userState.age_verified = requestMap["age_verified"].AsBoolean();
                    userState.region_id = homeScene.RegionInfo.originRegionID; // replace 0000000 with our regionid
                    userState.transacted = requestMap["transacted"].AsBoolean();
                    userState.agent_access = requestMap["agent_access"].AsBoolean();
                    userState.inventory_host = requestMap["inventory_host"].AsString();
                    userState.identified = requestMap["identified"].AsBoolean();
                    userState.session_id = requestMap["session_id"].AsUUID();
                    userState.god_level = (uint)requestMap["god_level"].AsInteger();
                    userState.last_name = requestMap["last_name"].AsString();
                    userState.god_overide = requestMap["god_override"].AsBoolean();
                    userState.circuit_code = (uint)requestMap["circuit_code"].AsInteger();
                    userState.limited_to_estate = requestMap["limited_to_estate"].AsInteger();
                    userState.src_estate_id = estateID;
                    userState.region_id = regionID;
                    userState.src_parent_estate_id = parentEstateID;
                    userState.visible_to_parent = visibleToParent;

                    // Save state changes
                    UpdateOGPState(userData.AgentID, userState);

                    // Get the region information for the home region.
                    RegionInfo reg = homeScene.RegionInfo;

                    // Dummy positional and look at info..  we don't have it.
                    OSDArray PositionArray = new OSDArray();
                    PositionArray.Add(OSD.FromInteger(128));
                    PositionArray.Add(OSD.FromInteger(128));
                    PositionArray.Add(OSD.FromInteger(40));

                    OSDArray LookAtArray = new OSDArray();
                    LookAtArray.Add(OSD.FromInteger(1));
                    LookAtArray.Add(OSD.FromInteger(1));
                    LookAtArray.Add(OSD.FromInteger(1));

                    // Our region's X and Y position in OpenSimulator space.
                    uint fooX = reg.RegionLocX;
                    uint fooY = reg.RegionLocY;
                    m_log.InfoFormat("[OGP]: region x({0}) region y({1})", fooX, fooY);
                    m_log.InfoFormat("[OGP]: region http {0} {1}", reg.ServerURI, reg.HttpPort);
                    m_log.InfoFormat("[OGO]: region UUID {0} ", reg.RegionID);

                    // Convert the X and Y position to LL space
                    responseMap["region_x"] = OSD.FromInteger(fooX * (uint)Constants.RegionSize); // convert it to LL X
                    responseMap["region_y"] = OSD.FromInteger(fooY * (uint)Constants.RegionSize); // convert it to LL Y

                    // Give em a new seed capability
                    responseMap["seed_capability"] = OSD.FromString("http://" + reg.ExternalHostName + ":" + reg.HttpPort + "/CAPS/" + userCap.CapsObjectPath + "0000/");
                    responseMap["region"] = OSD.FromUUID(reg.originRegionID);
                    responseMap["look_at"] = LookAtArray;

                    responseMap["sim_port"] = OSD.FromInteger(reg.InternalEndPoint.Port);
                    responseMap["sim_host"] = OSD.FromString(reg.ExternalHostName);// + ":" + reg.InternalEndPoint.Port.ToString());
                    
                    // DEPRECATED
                    responseMap["sim_ip"] = OSD.FromString(Util.GetHostFromDNS(reg.ExternalHostName).ToString());

                    responseMap["session_id"] = OSD.FromUUID(SessionID);
                    responseMap["secure_session_id"] = OSD.FromUUID(SecureSessionID);
                    responseMap["circuit_code"] = OSD.FromInteger(circuitcode);

                    responseMap["position"] = PositionArray;

                    responseMap["region_id"] = OSD.FromUUID(reg.originRegionID);

                    responseMap["sim_access"] = OSD.FromString("Mature");

                    responseMap["connect"] = OSD.FromBoolean(true);

                   

                    m_log.InfoFormat("[OGP]: host: {0}, IP {1}", responseMap["sim_host"].ToString(), responseMap["sim_ip"].ToString());
                }
            }

            return responseMap;
        }
        protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            //            m_log.DebugFormat("[GET_DISPLAY_NAMES]: called {0}", httpRequest.Url.Query);

            NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);

            string[] ids = query.GetValues("ids");

            if (m_UserManagement == null)
            {
                m_log.Error("[GET_DISPLAY_NAMES]: Cannot fetch display names without a user management component");
                httpResponse.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                return(new byte[0]);
            }

            Dictionary <UUID, string> names = m_UserManagement.GetUsersNames(ids, UUID.Zero);

            OSDMap   osdReply = new OSDMap();
            OSDArray agents   = new OSDArray();

            osdReply["agents"] = agents;
            foreach (KeyValuePair <UUID, string> kvp in names)
            {
                if (string.IsNullOrEmpty(kvp.Value))
                {
                    continue;
                }
                if (kvp.Key == UUID.Zero)
                {
                    continue;
                }

                string[] parts   = kvp.Value.Split(new char[] { ' ' });
                OSDMap   osdname = new OSDMap();
                if (parts[0] == "Unknown")
                {
                    osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddHours(1));
                    osdname["display_name_expires"]     = OSD.FromDate(DateTime.UtcNow.AddHours(2));
                }
                else
                {
                    osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(8));
                    osdname["display_name_expires"]     = OSD.FromDate(DateTime.UtcNow.AddMonths(1));
                }
                osdname["display_name"]      = OSD.FromString(kvp.Value);
                osdname["legacy_first_name"] = parts[0];
                osdname["legacy_last_name"]  = parts[1];
                osdname["username"]          = OSD.FromString(kvp.Value);
                osdname["id"] = OSD.FromUUID(kvp.Key);
                osdname["is_display_name_default"] = OSD.FromBoolean(true);

                agents.Add(osdname);
            }

            // Full content request
            httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
            //httpResponse.ContentLength = ??;
            httpResponse.ContentType = "application/llsd+xml";

            string reply = OSDParser.SerializeLLSDXmlString(osdReply);

            return(System.Text.Encoding.UTF8.GetBytes(reply));
        }