Example #1
0
        private static OSDArray WrapOSDMap(OSDMap wrapMe)
        {
            OSDArray array = new OSDArray();

            array.Add(wrapMe);
            return(array);
        }
Example #2
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);
        }
Example #3
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));
        }
Example #4
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);
        }
        /// <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 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));
        }
        private static OSD DeserializeLLSDNotationArray(TextReader reader)
        {
            int      character;
            OSDArray osdArray = new OSDArray();

            while (((character = PeekAndSkipWhitespace(reader)) > 0))
            {
                if ((char)character == arrayEndNotationMarker)
                {
                    reader.Read();
                    break;
                }
                else
                {
                    osdArray.Add(DeserializeLLSDNotationElement(reader));

                    character = ReadAndSkipWhitespace(reader);
                    if (character < 0)
                    {
                        throw new OSDException("Notation LLSD parsing: Unexpected end of array discovered.");
                    }
                    else if ((char)character == kommaNotationDelimiter)
                    {
                        continue;
                    }
                    else if ((char)character == arrayEndNotationMarker)
                    {
                        break;
                    }
                }
            }
            if (character < 0)
            {
                throw new OSDException("Notation LLSD parsing: Unexpected end of array discovered.");
            }

            return((OSD)osdArray);
        }
        /// <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());
                    }
                }
            }
        }
Example #10
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;
		}
Example #11
0
 private static OSDArray WrapOSDMap(OSDMap wrapMe)
 {
     OSDArray array = new OSDArray();
     array.Add(wrapMe);
     return array;
 }
Example #12
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;
 }
        /// <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);
        }
Example #14
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;
        }
Example #15
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;
        }
Example #16
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));
        }
 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);
 }
        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));
        }
Example #20
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();
        }
Example #21
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;
        }
Example #22
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));
        }
Example #23
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;
        }
        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();
                        osdname["display_name_next_update"] = OSD.FromDate(DateTime.MinValue);
                        osdname["display_name_expires"] = OSD.FromDate(DateTime.Now.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);

        }
Example #25
0
 public static object ToObject(Type type, OSD value)
 {
     if (type == typeof(ulong))
     {
         if (value.Type == OSDType.Binary)
         {
             byte[] bytes = value.AsBinary();
             return(Utils.BytesToUInt64(bytes));
         }
         else
         {
             return((ulong)value.AsInteger());
         }
     }
     else if (type == typeof(uint))
     {
         if (value.Type == OSDType.Binary)
         {
             byte[] bytes = value.AsBinary();
             return(Utils.BytesToUInt(bytes));
         }
         else
         {
             return((uint)value.AsInteger());
         }
     }
     else if (type == typeof(ushort))
     {
         return((ushort)value.AsInteger());
     }
     else if (type == typeof(byte))
     {
         return((byte)value.AsInteger());
     }
     else if (type == typeof(short))
     {
         return((short)value.AsInteger());
     }
     else if (type == typeof(string))
     {
         return(value.AsString());
     }
     else if (type == typeof(bool))
     {
         return(value.AsBoolean());
     }
     else if (type == typeof(float))
     {
         return((float)value.AsReal());
     }
     else if (type == typeof(double))
     {
         return(value.AsReal());
     }
     else if (type == typeof(int))
     {
         return(value.AsInteger());
     }
     else if (type == typeof(UUID))
     {
         return(value.AsUUID());
     }
     else if (type == typeof(Vector3))
     {
         if (value.Type == OSDType.Array)
         {
             return(((OSDArray)value).AsVector3());
         }
         else
         {
             return(Vector3.Zero);
         }
     }
     else if (type == typeof(Vector4))
     {
         if (value.Type == OSDType.Array)
         {
             return(((OSDArray)value).AsVector4());
         }
         else
         {
             return(Vector4.Zero);
         }
     }
     else if (type == typeof(Quaternion))
     {
         if (value.Type == OSDType.Array)
         {
             return(((OSDArray)value).AsQuaternion());
         }
         else
         {
             return(Quaternion.Identity);
         }
     }
     else if (type == typeof(OSDArray))
     {
         OSDArray newArray = new OSDArray();
         foreach (OSD o in (OSDArray)value)
         {
             newArray.Add(o);
         }
         return(newArray);
     }
     else if (type == typeof(OSDMap))
     {
         OSDMap newMap = new OSDMap();
         foreach (KeyValuePair <string, OSD> o in (OSDMap)value)
         {
             newMap.Add(o);
         }
         return(newMap);
     }
     else
     {
         return(null);
     }
 }
Example #26
0
        public static OSD DeserializeJson(JsonData json)
        {
            switch (json.GetJsonType())
            {
            case JsonType.Boolean:
                return(OSD.FromBoolean((bool)json));

            case JsonType.Int:
                return(OSD.FromInteger((int)json));

            case JsonType.Long:
                return(OSD.FromLong((long)json));

            case JsonType.Double:
                return(OSD.FromReal((double)json));

            case JsonType.String:
                string str = (string)json;

                if (String.IsNullOrEmpty(str))
                {
                    return(new OSD());
                }
                else
                {
                    switch (str[0])
                    {
                    case 'd':
                        if (str.StartsWith("date::"))
                        {
                            DateTime dt;
                            if (DateTime.TryParse(str.Substring(6), out dt))
                            {
                                return(OSD.FromDate(dt));
                            }
                        }
                        break;

                    case 'u':
                        if (str.StartsWith("uuid::"))
                        {
                            UUID id;
                            if (UUID.TryParse(str.Substring(6), out id))
                            {
                                return(OSD.FromUUID(id));
                            }
                        }
                        else if (str.StartsWith("uri::"))
                        {
                            try
                            {
                                Uri uri = new Uri(str.Substring(5));
                                return(OSD.FromUri(uri));
                            }
                            catch (UriFormatException) { }
                        }
                        break;

                    case 'b':
                        if (str.StartsWith("b64::"))
                        {
                            try
                            {
                                byte[] data = Convert.FromBase64String(str.Substring(5));
                                return(OSD.FromBinary(data));
                            }
                            catch (FormatException) { }
                        }
                        break;
                    }

                    return(OSD.FromString((string)json));
                }

            case JsonType.Array:
                OSDArray array = new OSDArray(json.Count);
                for (int i = 0; i < json.Count; i++)
                {
                    array.Add(DeserializeJson(json[i]));
                }
                return(array);

            case JsonType.Object:
                OSDMap map = new OSDMap(json.Count);
                foreach (KeyValuePair <string, JsonData> kvp in json)
                {
                    map.Add(kvp.Key, DeserializeJson(kvp.Value));
                }
                return(map);

            case JsonType.None:
            default:
                return(new OSD());
            }
        }
Example #27
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;
        }
        /// <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());
                    }
                }
            }
        }