public OSDMap ToOSD()
        {
            OSDMap map = new OSDMap();

            map["X"]      = OSD.FromInteger((int)x);
            map["Y"]      = OSD.FromInteger((int)y);
            map["ID"]     = OSD.FromUUID(id);
            map["Name"]   = OSD.FromString(name);
            map["Extra"]  = OSD.FromInteger(Extra);
            map["Extra2"] = OSD.FromInteger(Extra2);
            return(map);
        }
Exemplo n.º 2
0
        private void RezAvatarRequestHandler(IHttpClientContext context, IHttpRequest request, IHttpResponse response)
        {
            OSDMap requestMap = null;

            try { requestMap = OSDParser.Deserialize(request.Body) as OSDMap; }
            catch (Exception ex)
            {
                m_log.Warn("Failed to decode rez_avatar/request message: " + ex.Message);
                response.Status = HttpStatusCode.BadRequest;
                return;
            }

            UUID    userID        = requestMap["agent_id"].AsUUID();
            UUID    sessionID     = requestMap["session_id"].AsUUID();
            bool    childAgent    = requestMap["child"].AsBoolean();
            Vector3 startPosition = requestMap["position"].AsVector3();
            Vector3 velocity      = requestMap["velocity"].AsVector3();
            Vector3 lookAt        = requestMap["look_at"].AsVector3();

            OSDMap responseMap = new OSDMap();

            UserSession session;

            if (m_userClient.TryGetSession(sessionID, out session))
            {
                session.CurrentSceneID  = m_scene.ID;
                session.CurrentPosition = startPosition;
                session.CurrentLookAt   = lookAt;

                if (!childAgent)
                {
                    // Set the agent velocity in case this is a child->root upgrade (border cross)
                    IScenePresence presence;
                    if (m_scene.TryGetPresence(session.User.ID, out presence) && presence is IPhysicalPresence)
                    {
                        ((IPhysicalPresence)presence).Velocity = velocity;
                    }

                    RezRootAgent(session, startPosition, lookAt, ref responseMap);
                }
                else
                {
                    RezChildAgent(session, startPosition, lookAt, ref responseMap);
                }
            }
            else
            {
                m_log.Error("Received a rez_avatar/request for agent " + userID + " with missing sessionID " + sessionID);
                responseMap["message"] = OSD.FromString("Session does not exist");
            }

            WebUtil.SendJSONResponse(response, responseMap);
        }
Exemplo n.º 3
0
        //public override string ToXml(Direction direction)
        //{
        //    if (direction == this.Direction)
        //        return Packet.ToXmlString(this.Packet);
        //    else
        //        return base.ToXml(direction);
        //}

        //public override string ToStringNotation(Direction direction)
        //{
        //    if (direction == this.Direction)
        //        return Packet.GetLLSD(this.Packet).ToString();
        //    else
        //        return base.ToStringNotation(direction);
        //}

        public override byte[] Serialize()
        {
            OSDMap map = new OSDMap(5);

            map["Name"]        = OSD.FromString(this.Name);
            map["Host"]        = OSD.FromString(this.Host);
            map["PacketBytes"] = OSD.FromBinary(this.Packet.ToBytes());
            map["Direction"]   = OSD.FromInteger((int)this.Direction);
            map["ContentType"] = OSD.FromString(this.ContentType);

            return(OpenMetaverse.Utils.StringToBytes(map.ToString()));
        }
        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));
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Send a console message to the viewer
        /// </summary>
        /// <param name="AgentID"></param>
        /// <param name="text"></param>
        private void SendConsoleEventEQM(UUID AgentID, string text)
        {
            OSDMap item = new OSDMap {
                { "body", text }, { "message", OSD.FromString("SimConsoleResponse") }
            };
            IEventQueueService eq = m_Scene.RequestModuleInterface <IEventQueueService>();

            if (eq != null)
            {
                eq.Enqueue(item, AgentID, m_Scene.RegionInfo.RegionID);
            }
        }
        private OSD BuildEQM(int interpolate)
        {
            OSDMap map = new OSDMap();

            OSDMap body = new OSDMap();

            body.Add("Interpolate", interpolate);

            map.Add("body", body);
            map.Add("message", OSD.FromString("WindLightRefresh"));
            return(map);
        }
Exemplo n.º 7
0
        public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt,
                                      IPEndPoint newRegionExternalEndPoint,
                                      string capsURL, UUID agentID, UUID sessionID)
        {
            OSDArray lookAtArr = new OSDArray(3);

            lookAtArr.Add(OSD.FromReal(lookAt.X));
            lookAtArr.Add(OSD.FromReal(lookAt.Y));
            lookAtArr.Add(OSD.FromReal(lookAt.Z));

            OSDArray positionArr = new OSDArray(3);

            positionArr.Add(OSD.FromReal(pos.X));
            positionArr.Add(OSD.FromReal(pos.Y));
            positionArr.Add(OSD.FromReal(pos.Z));

            OSDMap infoMap = new OSDMap(2);

            infoMap.Add("LookAt", lookAtArr);
            infoMap.Add("Position", positionArr);

            OSDArray infoArr = new OSDArray(1);

            infoArr.Add(infoMap);

            OSDMap agentDataMap = new OSDMap(2);

            agentDataMap.Add("AgentID", OSD.FromUUID(agentID));
            agentDataMap.Add("SessionID", OSD.FromUUID(sessionID));

            OSDArray agentDataArr = new OSDArray(1);

            agentDataArr.Add(agentDataMap);

            OSDMap regionDataMap = new OSDMap(4);

            regionDataMap.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(handle)));
            regionDataMap.Add("SeedCapability", OSD.FromString(capsURL));
            regionDataMap.Add("SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes()));
            regionDataMap.Add("SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port));

            OSDArray regionDataArr = new OSDArray(1);

            regionDataArr.Add(regionDataMap);

            OSDMap llsdBody = new OSDMap(3);

            llsdBody.Add("Info", infoArr);
            llsdBody.Add("AgentData", agentDataArr);
            llsdBody.Add("RegionData", regionDataArr);

            return(buildEvent("CrossedRegion", llsdBody));
        }
Exemplo n.º 8
0
        /// <summary>
        /// POST URL-encoded form data to a web service that returns LLSD or
        /// JSON data
        /// </summary>
        public static OSDMap PostToService(string url, NameValueCollection data)
        {
            string errorMessage;

            try
            {
                string queryString = BuildQueryString(data);
                byte[] requestData = System.Text.Encoding.UTF8.GetBytes(queryString);

                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
                request.Method        = "POST";
                request.ContentLength = requestData.Length;
                request.ContentType   = "application/x-www-form-urlencoded";

                Stream requestStream = request.GetRequestStream();
                requestStream.Write(requestData, 0, requestData.Length);
                requestStream.Close();

                using (WebResponse response = request.GetResponse())
                {
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        try
                        {
                            string responseStr = responseStream.GetStreamString();
                            OSD    responseOSD = OSDParser.Deserialize(responseStr);
                            if (responseOSD.Type == OSDType.Map)
                            {
                                return((OSDMap)responseOSD);
                            }
                            else
                            {
                                errorMessage = "Response format was invalid (" + responseOSD.Type + ")";
                            }
                        }
                        catch
                        {
                            errorMessage = "Failed to parse the response (" + responseStream.Length + " bytes of " + response.ContentType + ")";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                m_log.Warn("POST to URL " + url + " failed: " + ex);
                errorMessage = ex.Message;
            }

            return(new OSDMap {
                { "Message", OSD.FromString("Service request failed. " + errorMessage) }
            });
        }
Exemplo n.º 9
0
        /// <summary>
        ///   Since there are no consistencies in the way web requests are
        ///   formed, we need to do a little guessing about the result format.
        ///   Keys:
        ///   Success|success == the success fail of the request
        ///   _RawResult == the raw string that came back
        ///   _Result == the OSD unpacked string
        /// </summary>
        private static OSDMap CanonicalizeResults(string response, bool deserializeResponse, bool returnRawResult)
        {
            OSDMap result = new OSDMap();

            if (returnRawResult)
            {
                OSD responseOSD = OSDParser.Deserialize(response);
                if (responseOSD.Type == OSDType.Map)
                {
                    result = (OSDMap)responseOSD;
                }
                return(result);
            }

            // Default values
            result["Success"]    = OSD.FromBoolean(true);
            result["success"]    = OSD.FromBoolean(true);
            result["_RawResult"] = OSD.FromString(response);
            result["_Result"]    = new OSDMap();

            if (response.Equals("true", StringComparison.OrdinalIgnoreCase))
            {
                return(result);
            }

            if (response.Equals("false", StringComparison.OrdinalIgnoreCase))
            {
                result["Success"] = OSD.FromBoolean(false);
                result["success"] = OSD.FromBoolean(false);
                return(result);
            }

            if (deserializeResponse)
            {
                try
                {
                    OSD responseOSD = OSDParser.Deserialize(response);
                    if (responseOSD.Type == OSDType.Map)
                    {
                        result["_Result"] = responseOSD;
                        return(result);
                    }
                }
                catch (Exception e)
                {
                    // don't need to treat this as an error... we're just guessing anyway
                    MainConsole.Instance.InfoFormat("[WebUtils] couldn't decode <{0}>: {1}", response, e.Message);
                }
            }

            return(result);
        }
Exemplo n.º 10
0
        OSDMap GroupNotices(OSDMap map)
        {
            var resp = new OSDMap();

            resp ["GroupNotices"] = new OSDArray();
            resp ["Total"]        = 0;
            var groups = DataPlugins.RequestPlugin <IGroupsServiceConnector> ();

            if (map.ContainsKey("Groups") && groups != null && map ["Groups"].Type.ToString() == "Array")
            {
                var groupIDs = (OSDArray)map ["Groups"];
                var GroupIDs = new List <UUID> ();
                foreach (string groupID in groupIDs)
                {
                    UUID foo;
                    if (UUID.TryParse(groupID, out foo))
                    {
                        GroupIDs.Add(foo);
                    }
                }
                if (GroupIDs.Count > 0)
                {
                    var start           = map.ContainsKey("Start") ? uint.Parse(map ["Start"]) : 0;
                    var count           = map.ContainsKey("Count") ? uint.Parse(map ["Count"]) : 10;
                    var groupNoticeList = groups.GetGroupNotices(AdminAgentID, start, count, GroupIDs);
                    var groupNotices    = new OSDArray(groupNoticeList.Count);

                    foreach (GroupNoticeData GND in groupNoticeList)
                    {
                        var gnd = new OSDMap();

                        gnd ["GroupID"]       = OSD.FromUUID(GND.GroupID);
                        gnd ["NoticeID"]      = OSD.FromUUID(GND.NoticeID);
                        gnd ["Timestamp"]     = OSD.FromInteger((int)GND.Timestamp);
                        gnd ["FromName"]      = OSD.FromString(GND.FromName);
                        gnd ["Subject"]       = OSD.FromString(GND.Subject);
                        gnd ["HasAttachment"] = OSD.FromBoolean(GND.HasAttachment);
                        gnd ["ItemID"]        = OSD.FromUUID(GND.ItemID);
                        gnd ["AssetType"]     = OSD.FromInteger((int)GND.AssetType);
                        gnd ["ItemName"]      = OSD.FromString(GND.ItemName);

                        var notice = groups.GetGroupNotice(AdminAgentID, GND.NoticeID);
                        gnd ["Message"] = OSD.FromString(notice.Message);
                        groupNotices.Add(gnd);
                    }
                    resp ["GroupNotices"] = groupNotices;
                    resp ["Total"]        = (int)groups.GetNumberOfGroupNotices(AdminAgentID, GroupIDs);
                }
            }

            return(resp);
        }
Exemplo n.º 11
0
        public void SendConsoleOutput(UUID agentID, string message)
        {
            OSD osd = OSD.FromString(message);

            m_eventQueue.Enqueue(EventQueueHelper.BuildEvent("SimConsoleResponse", osd), agentID);

            ConsoleMessage handlerConsoleMessage = OnConsoleMessage;

            if (handlerConsoleMessage != null)
            {
                handlerConsoleMessage(agentID, message);
            }
        }
Exemplo n.º 12
0
        private void UpdateAvatarPropertiesHandler(IClientAPI client, UserProfileData profileData)
        {
            OSDMap map = new OSDMap
            {
                { "About", OSD.FromString(profileData.AboutText) },
                { "Image", OSD.FromUUID(profileData.Image) },
                { "FLAbout", OSD.FromString(profileData.FirstLifeAboutText) },
                { "FLImage", OSD.FromUUID(profileData.FirstLifeImage) },
                { "URL", OSD.FromString(profileData.ProfileUrl) }
            };

            AddUserData(client.AgentId, "LLAbout", map);
        }
Exemplo n.º 13
0
            public OSD GetOSD()
            {
                OSDMap InterestsOSD = new OSDMap(5)
                {
                    ["languages_text"] = OSD.FromString(LanguagesText),
                    ["skills_mask"]    = OSD.FromUInteger(SkillsMask),
                    ["skills_text"]    = OSD.FromString(SkillsText),
                    ["want_to_mask"]   = OSD.FromUInteger(WantToMask),
                    ["want_to_text"]   = OSD.FromString(WantToText)
                };

                return(InterestsOSD);
            }
Exemplo n.º 14
0
        /// <summary>
        /// Send a console message to the viewer
        /// </summary>
        /// <param name="AgentID"></param>
        /// <param name="text"></param>
        private void SendConsoleEventEQM(UUID AgentID, string text)
        {
            OSDMap item = new OSDMap();

            item.Add("body", text);
            item.Add("message", OSD.FromString("SimConsoleResponse"));
            IEventQueueService eq = m_scenes[0].RequestModuleInterface <IEventQueueService> ();

            if (eq != null)
            {
                eq.Enqueue(item, AgentID, findScene(AgentID).RegionInfo.RegionHandle);
            }
        }
Exemplo n.º 15
0
        public override byte[] Serialize()
        {
            OSDMap map = new OSDMap(6);

            map["Name"]        = OSD.FromString(this.Name);
            map["Host"]        = OSD.FromString(this.Host);
            map["Data"]        = OSD.FromString(this.Data.ToString());
            map["Direction"]   = OSD.FromInteger((int)this.Direction);
            map["ContentType"] = OSD.FromString(this.ContentType);
            map["Protocol"]    = OSD.FromString(this.Protocol);

            return(OpenMetaverse.Utils.StringToBytes(map.ToString()));
        }
        public override byte[] Handle(string path, Stream requestData,
                                      OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            StreamReader sr   = new StreamReader(requestData);
            string       body = sr.ReadToEnd();

            sr.Close();
            body = body.Trim();

            //MainConsole.Instance.DebugFormat("[XXX]: query String: {0}", body);
            try
            {
                OSDMap map = (OSDMap)OSDParser.DeserializeJson(body);
                //Make sure that the person who is calling can access the web service
                if (VerifyPassword(map))
                {
                    string method = map["Method"].AsString();
                    if (method == "Validate")
                    {
                        return(Validate(map));
                    }
                    if (method == "IPNData")
                    {
                        return(Validate2(map));
                    }
                    if (method == "CheckPurchaseStatus")
                    {
                        return(PrePurchaseCheck(map));
                    }
                    if (method == "OrderSubscription")
                    {
                        return(OrderSubscription(map));
                    }
                }
                else
                {
                    MainConsole.Instance.Error("[Stardust] Web password did not match.");
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.ErrorFormat("[Stardust] Error processing method: {0}", e.ToString());
            }
            OSDMap resp = new OSDMap {
                { "response", OSD.FromString("Failed") }
            };
            string       xmlString = OSDParser.SerializeJsonString(resp);
            UTF8Encoding encoding  = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
Exemplo n.º 17
0
        public static OSD GroupMembership(AgentGroupDataUpdatePacket groupUpdatePacket)
        {
            OSDMap groupUpdate = new OSDMap {
                { "message", OSD.FromString("AgentGroupDataUpdate") }
            };

            OSDMap   body         = new OSDMap();
            OSDArray agentData    = new OSDArray();
            OSDMap   agentDataMap = new OSDMap {
                { "AgentID", OSD.FromUUID(groupUpdatePacket.AgentData.AgentID) }
            };

            agentData.Add(agentDataMap);
            body.Add("AgentData", agentData);

            OSDArray groupData = new OSDArray();

#if (!ISWIN)
            foreach (AgentGroupDataUpdatePacket.GroupDataBlock groupDataBlock in groupUpdatePacket.GroupData)
            {
                OSDMap groupDataMap = new OSDMap();
                groupDataMap.Add("ListInProfile", OSD.FromBoolean(false));
                groupDataMap.Add("GroupID", OSD.FromUUID(groupDataBlock.GroupID));
                groupDataMap.Add("GroupInsigniaID", OSD.FromUUID(groupDataBlock.GroupInsigniaID));
                groupDataMap.Add("Contribution", OSD.FromInteger(groupDataBlock.Contribution));
                groupDataMap.Add("GroupPowers", OSD.FromBinary(ulongToByteArray(groupDataBlock.GroupPowers)));
                groupDataMap.Add("GroupName", OSD.FromString(Utils.BytesToString(groupDataBlock.GroupName)));
                groupDataMap.Add("AcceptNotices", OSD.FromBoolean(groupDataBlock.AcceptNotices));

                groupData.Add(groupDataMap);
            }
#else
            foreach (OSDMap groupDataMap in groupUpdatePacket.GroupData.Select(groupDataBlock => new OSDMap
            {
                { "ListInProfile", OSD.FromBoolean(false) },
                { "GroupID", OSD.FromUUID(groupDataBlock.GroupID) },
                { "GroupInsigniaID", OSD.FromUUID(groupDataBlock.GroupInsigniaID) },
                { "Contribution", OSD.FromInteger(groupDataBlock.Contribution) },
                { "GroupPowers", OSD.FromBinary(ulongToByteArray(groupDataBlock.GroupPowers)) },
                { "GroupName", OSD.FromString(Utils.BytesToString(groupDataBlock.GroupName)) },
                { "AcceptNotices", OSD.FromBoolean(groupDataBlock.AcceptNotices) }
            }))
            {
                groupData.Add(groupDataMap);
            }
#endif
            body.Add("GroupData", groupData);
            groupUpdate.Add("body", body);

            return(groupUpdate);
        }
Exemplo n.º 18
0
        private void SaveItem(UUID ItemID, OSDMap itemMap, OSDMap assets)
        {
            InventoryItemBase saveItem = InventoryService.GetItem(new InventoryItemBase(ItemID));

            if (saveItem == null)
            {
                m_log.Warn("[AvatarArchive]: Could not find item to save: " + ItemID.ToString());
                return;
            }
            m_log.Info("[AvatarArchive]: Saving item " + ItemID.ToString());
            string serialization = UserInventoryItemSerializer.Serialize(saveItem);

            itemMap[ItemID.ToString()] = OSD.FromString(serialization);
        }
Exemplo n.º 19
0
        public OSD GenerateFailureResponseLLSD(string reason, string message, string login)
        {
            OSDMap map = new OSDMap();

            // Ensure Login Failed message/reason;
            ErrorMessage = message;
            ErrorReason  = reason;

            map["reason"]  = OSD.FromString(ErrorReason);
            map["message"] = OSD.FromString(ErrorMessage);
            map["login"]   = OSD.FromString(login);

            return(map);
        }
Exemplo n.º 20
0
        private byte[] CheckIfUserExists(OSDMap map)
        {
            IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService>();
            UserAccount         user           = accountService.GetUserAccount(UUID.Zero, map["Name"].AsString());

            bool   Verified = user != null;
            OSDMap resp     = new OSDMap();

            resp["Verified"] = OSD.FromString(Verified.ToString());
            string       xmlString = OSDParser.SerializeJsonString(resp);
            UTF8Encoding encoding  = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
Exemplo n.º 21
0
        public override OSDMap ToOSD()
        {
            OSDMap map = new OSDMap();

            map["GroupID"]          = OSD.FromUUID(GroupID);
            map["IsGroupOwned"]     = OSD.FromBoolean(IsGroupOwned);
            map["OwnerID"]          = OSD.FromUUID(OwnerID);
            map["Maturity"]         = OSD.FromInteger(Maturity);
            map["Area"]             = OSD.FromInteger(Area);
            map["AuctionID"]        = OSD.FromUInteger(AuctionID);
            map["SalePrice"]        = OSD.FromInteger(SalePrice);
            map["InfoUUID"]         = OSD.FromUUID(InfoUUID);
            map["Dwell"]            = OSD.FromInteger(Dwell);
            map["Flags"]            = OSD.FromInteger((int)Flags);
            map["Name"]             = OSD.FromString(Name);
            map["Description"]      = OSD.FromString(Description);
            map["UserLocation"]     = OSD.FromVector3(UserLocation);
            map["LocalID"]          = OSD.FromInteger(LocalID);
            map["GlobalID"]         = OSD.FromUUID(GlobalID);
            map["RegionID"]         = OSD.FromUUID(RegionID);
            map["ScopeID"]          = OSD.FromUUID(ScopeID);
            map["MediaDescription"] = OSD.FromString(MediaDescription);
            map["MediaWidth"]       = OSD.FromInteger(MediaWidth);
            map["MediaHeight"]      = OSD.FromInteger(MediaHeight);
            map["MediaLoop"]        = OSD.FromBoolean(MediaLoop);
            map["MediaType"]        = OSD.FromString(MediaType);
            map["ObscureMedia"]     = OSD.FromBoolean(ObscureMedia);
            map["ObscureMusic"]     = OSD.FromBoolean(ObscureMusic);
            map["SnapshotID"]       = OSD.FromUUID(SnapshotID);
            map["MediaAutoScale"]   = OSD.FromInteger(MediaAutoScale);
            map["MediaLoopSet"]     = OSD.FromReal(MediaLoopSet);
            map["MediaURL"]         = OSD.FromString(MediaURL);
            map["MusicURL"]         = OSD.FromString(MusicURL);
            map["Bitmap"]           = OSD.FromBinary(Bitmap);
            map["Category"]         = OSD.FromInteger((int)Category);
            map["FirstParty"]       = OSD.FromBoolean(FirstParty);
            map["ClaimDate"]        = OSD.FromInteger(ClaimDate);
            map["ClaimPrice"]       = OSD.FromInteger(ClaimPrice);
            map["Status"]           = OSD.FromInteger((int)Status);
            map["LandingType"]      = OSD.FromInteger(LandingType);
            map["PassHours"]        = OSD.FromReal(PassHours);
            map["PassPrice"]        = OSD.FromInteger(PassPrice);
            map["UserLookAt"]       = OSD.FromVector3(UserLookAt);
            map["AuthBuyerID"]      = OSD.FromUUID(AuthBuyerID);
            map["OtherCleanTime"]   = OSD.FromInteger(OtherCleanTime);
            map["RegionHandle"]     = OSD.FromULong(RegionHandle);
            map["Private"]          = OSD.FromBoolean(Private);
            map["GenericDataMap"]   = GenericData;
            return(map);
        }
Exemplo n.º 22
0
        private void AvatarInterestUpdateHandler(IClientAPI client, uint wantmask, string wanttext, uint skillsmask,
                                                 string skillstext, string languages)
        {
            OSDMap map = new OSDMap
            {
                { "WantMask", OSD.FromInteger(wantmask) },
                { "WantText", OSD.FromString(wanttext) },
                { "SkillsMask", OSD.FromInteger(skillsmask) },
                { "SkillsText", OSD.FromString(skillstext) },
                { "Languages", OSD.FromString(languages) }
            };

            AddUserData(client.AgentId, "LLInterests", map);
        }
Exemplo n.º 23
0
        public void AvatarNotesUpdate(IClientAPI remoteClient, UUID queryTargetID, string queryNotes)
        {
            IUserProfileInfo UPI = ProfileFrontend.GetUserProfile(remoteClient.AgentId);

            if (UPI == null)
            {
                return;
            }
            string notes = queryNotes;

            UPI.Notes [queryTargetID.ToString()] = OSD.FromString(notes);

            ProfileFrontend.UpdateUserProfile(UPI);
        }
Exemplo n.º 24
0
        public static OSDMap FromDictionaryString(Dictionary <string, string> dict)
        {
            if (dict != null)
            {
                OSDMap map = new OSDMap(dict.Count);
                foreach (KeyValuePair <string, string> entry in dict)
                {
                    map.Add(entry.Key, OSD.FromString(entry.Value));
                }
                return(map);
            }

            return(new OSDMap(0));
        }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
0
        private void SendRegionOnline(SceneInfo neighbor)
        {
            // Build the region/online message
            uint regionX, regionY;

            GetRegionXY(m_scene.MinPosition, out regionX, out regionY);

            OSDMap regionOnline = new OSDMap
            {
                { "region_id", OSD.FromUUID(m_scene.ID) },
                { "region_name", OSD.FromString(m_scene.Name) },
                { "region_x", OSD.FromInteger(regionX) },
                { "region_y", OSD.FromInteger(regionY) }
            };

            // Put our public region seed capability into the message
            Uri publicSeedCap;

            if (m_scene.TryGetPublicCapability("public_region_seed_capability", out publicSeedCap))
            {
                regionOnline["public_region_seed_capability"] = OSD.FromUri(publicSeedCap);
            }
            else
            {
                m_log.Warn("Registering scene " + m_scene.Name + " with neighbor " + neighbor.Name + " without a public seed capability");
            }

            // Send the hello notification
            Uri regionOnlineCap;

            if (neighbor.TryGetCapability("region/online", out regionOnlineCap))
            {
                try
                {
                    UntrustedHttpWebRequest.PostToUntrustedUrl(regionOnlineCap, OSDParser.SerializeJsonString(regionOnline));
                    //m_log.Debug(scene.Name + " sent region/online to " + curScene.Name);
                }
                catch (Exception ex)
                {
                    m_log.Warn(m_scene.Name + " failed to send region/online to " + neighbor.Name + ": " +
                               ex.Message);
                }
            }
            else
            {
                m_log.Warn("No region/online capability found for " + neighbor.Name + ", " +
                           m_scene.Name + " is skipping it");
            }
        }
Exemplo n.º 27
0
        protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
        {
            OSDMap args = RegionClient.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            // retrieve the regionhandle
            ulong regionhandle = 0;
            bool  authorize    = false;

            if (args.ContainsKey("destination_handle"))
            {
                UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
            }
            if (args.ContainsKey("authorize_user")) // not implemented on the sending side yet
            {
                bool.TryParse(args["authorize_user"].AsString(), out authorize);
            }

            AgentCircuitData aCircuit = new AgentCircuitData();

            try
            {
                aCircuit.UnpackAgentCircuitData(args);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildCreate message {0}", ex.Message);
                return;
            }

            OSDMap resp   = new OSDMap(2);
            string reason = String.Empty;

            // This is the meaning of POST agent
            bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit, authorize, out reason);

            resp["reason"]  = OSD.FromString(reason);
            resp["success"] = OSD.FromBoolean(result);

            // TODO: add reason if not String.Empty?
            responsedata["int_response_code"]   = 200;
            responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
        }
Exemplo n.º 28
0
        public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
        {
            // m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: CreateAgent start");

            myipaddress = String.Empty;
            reason      = String.Empty;

            if (destination == null)
            {
                m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Given destination is null");
                return(false);
            }

            string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/";

            try
            {
                OSDMap args = aCircuit.PackAgentCircuitData();

                args["destination_x"]    = OSD.FromString(destination.RegionLocX.ToString());
                args["destination_y"]    = OSD.FromString(destination.RegionLocY.ToString());
                args["destination_name"] = OSD.FromString(destination.RegionName);
                args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
                args["teleport_flags"]   = OSD.FromString(flags.ToString());

                OSDMap result = WebUtil.PostToService(uri, args, 80000);
                if (result["Success"].AsBoolean())
                {
                    OSDMap unpacked = (OSDMap)result["_Result"];

                    if (unpacked != null)
                    {
                        reason      = unpacked["reason"].AsString();
                        myipaddress = unpacked["your_ip"].AsString();
                        return(unpacked["success"].AsBoolean());
                    }
                }

                reason = result["Message"] != null ? result["Message"].AsString() : "error";
                return(false);
            }
            catch (Exception e)
            {
                m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString());
                reason = e.Message;
            }

            return(false);
        }
Exemplo n.º 29
0
            public OSD GetOSD()
            {
                OSDMap tex = new OSDMap(9);

                tex["first_life_text"]  = OSD.FromString(FirstLifeText);
                tex["first_life_image"] = OSD.FromUUID(FirstLifeImage);
                tex["partner"]          = OSD.FromUUID(Partner);
                tex["about_text"]       = OSD.FromString(AboutText);
                tex["born_on"]          = OSD.FromString(BornOn);
                tex["charter_member"]   = OSD.FromString(CharterMember);
                tex["profile_image"]    = OSD.FromUUID(ProfileImage);
                tex["flags"]            = OSD.FromInteger((byte)Flags);
                tex["profile_url"]      = OSD.FromString(ProfileURL);
                return(tex);
            }
Exemplo n.º 30
0
        public void SerializeDictionary()
        {
            OSDMap llsdEmptyMap = new OSDMap();
            byte[] binaryEmptyMapSerialized = OSDParser.SerializeLLSDBinary(llsdEmptyMap);
            Assert.AreEqual(binaryEmptyMap, binaryEmptyMapSerialized);

            OSDMap llsdSimpleMap = new OSDMap();
            llsdSimpleMap["test"] = OSD.FromInteger(0);
            byte[] binarySimpleMapSerialized = OSDParser.SerializeLLSDBinary(llsdSimpleMap);
            Assert.AreEqual(binarySimpleMap, binarySimpleMapSerialized);

            OSDMap llsdSimpleMapTwo = new OSDMap();
            llsdSimpleMapTwo["t0st"] = OSD.FromInteger(241);
            llsdSimpleMapTwo["tes1"] = OSD.FromString("aha");
            llsdSimpleMapTwo["test"] = new OSD();
            byte[] binarySimpleMapTwoSerialized = OSDParser.SerializeLLSDBinary(llsdSimpleMapTwo);

            // We dont compare here to the original serialized value, because, as maps dont preserve order,
            // the original serialized value is not *exactly* the same. Instead we compare to a deserialized
            // version created by this deserializer.
            OSDMap llsdSimpleMapDeserialized = (OSDMap)OSDParser.DeserializeLLSDBinary(binarySimpleMapTwoSerialized);
            Assert.AreEqual(OSDType.Map, llsdSimpleMapDeserialized.Type);
            Assert.AreEqual(3, llsdSimpleMapDeserialized.Count);
            Assert.AreEqual(OSDType.Integer, llsdSimpleMapDeserialized["t0st"].Type);
            Assert.AreEqual(241, llsdSimpleMapDeserialized["t0st"].AsInteger());
            Assert.AreEqual(OSDType.String, llsdSimpleMapDeserialized["tes1"].Type);
            Assert.AreEqual("aha", llsdSimpleMapDeserialized["tes1"].AsString());
            Assert.AreEqual(OSDType.Unknown, llsdSimpleMapDeserialized["test"].Type);

            // we also test for a 4byte key character.
            string xml = "<x>&#x10137;</x>";
            byte[] bytes = Encoding.UTF8.GetBytes(xml);
            XmlTextReader xtr = new XmlTextReader(new MemoryStream(bytes, false));
            xtr.Read();
            xtr.Read();
            string content = xtr.ReadString();

            OSDMap llsdSimpleMapThree = new OSDMap();
            OSD llsdSimpleValue = OSD.FromString(content);
            llsdSimpleMapThree[content] = llsdSimpleValue;
            Assert.AreEqual(content, llsdSimpleMapThree[content].AsString());

            byte[] binarySimpleMapThree = OSDParser.SerializeLLSDBinary(llsdSimpleMapThree);
            OSDMap llsdSimpleMapThreeDS = (OSDMap)OSDParser.DeserializeLLSDBinary(binarySimpleMapThree);
            Assert.AreEqual(OSDType.Map, llsdSimpleMapThreeDS.Type);
            Assert.AreEqual(1, llsdSimpleMapThreeDS.Count);
            Assert.AreEqual(content, llsdSimpleMapThreeDS[content].AsString());
        }