Ejemplo n.º 1
0
        private void SendAvatarProperties(LLAgent agent, UUID avatarID, User user)
        {
            AvatarPropertiesReplyPacket reply = new AvatarPropertiesReplyPacket();

            reply.AgentData.AgentID  = agent.ID;
            reply.AgentData.AvatarID = avatarID;

            // TODO: Check for ProfileFlags.Online (including permission check)
            ProfileFlags profileFlags = 0;

            if (user != null)
            {
                if (user.AccessLevel > 0)
                {
                    profileFlags |= ProfileFlags.Identified;
                }

                reply.PropertiesData.AboutText     = Utils.StringToBytes(user.GetField("About").AsString());
                reply.PropertiesData.BornOn        = Utils.StringToBytes(user.GetField("CreationDate").AsDate().ToString("M/d/yyyy", System.Globalization.CultureInfo.InvariantCulture));
                reply.PropertiesData.CharterMember = (user.AccessLevel >= 200) ? Utils.StringToBytes("Operator") : Utils.EmptyBytes;
                reply.PropertiesData.FLAboutText   = Utils.StringToBytes(user.GetField("FLAbout").AsString());
                reply.PropertiesData.Flags         = (uint)profileFlags;
                reply.PropertiesData.FLImageID     = user.GetField("FLImage").AsUUID();
                reply.PropertiesData.ImageID       = user.GetField("Image").AsUUID();
                reply.PropertiesData.PartnerID     = user.GetField("Partner").AsUUID();
                reply.PropertiesData.ProfileURL    = Utils.StringToBytes(user.GetField("URL").AsString());
            }
            else
            {
                reply.PropertiesData.AboutText     = Utils.EmptyBytes;
                reply.PropertiesData.BornOn        = Utils.EmptyBytes;
                reply.PropertiesData.CharterMember = Utils.EmptyBytes;
                reply.PropertiesData.FLAboutText   = Utils.EmptyBytes;
                reply.PropertiesData.ProfileURL    = Utils.EmptyBytes;
            }

            m_udp.SendPacket(agent, reply, ThrottleCategory.Task, false);
        }
Ejemplo n.º 2
0
        private void RequestAvatarPropertiesHandler(IClientAPI client, UUID avatarID)
        {
            m_log.DebugFormat("[SIMIAN PROFILES]: Request avatar properties for {0}", avatarID);

            OSDMap user = FetchUserData(avatarID);

            ProfileFlags flags = ProfileFlags.AllowPublish | ProfileFlags.MaturePublish;

            if (user != null)
            {
                OSDMap about = null;
                if (user.ContainsKey("LLAbout"))
                {
                    try
                    {
                        about = OSDParser.DeserializeJson(user["LLAbout"].AsString()) as OSDMap;
                    }
                    catch
                    {
                        m_log.WarnFormat("[SIMIAN PROFILES]: Unable to decode LLAbout");
                    }
                }

                if (about == null)
                {
                    about = new OSDMap(0);
                }

                // Check if this user is a grid operator
                byte[] charterMember;
                if (user["AccessLevel"].AsInteger() >= 200)
                {
                    charterMember = Utils.StringToBytes("Operator");
                }
                else
                {
                    charterMember = Utils.EmptyBytes;
                }

                // Check if the user is online
                if (client.Scene is Scene)
                {
                    OpenSim.Services.Interfaces.PresenceInfo[] presences = ((Scene)client.Scene).PresenceService.GetAgents(new string[] { avatarID.ToString() });
                    if (presences != null && presences.Length > 0)
                    {
                        flags |= ProfileFlags.Online;
                    }
                }

                // Check if the user is identified
                if (user["Identified"].AsBoolean())
                {
                    flags |= ProfileFlags.Identified;
                }

                client.SendAvatarProperties(avatarID, about["About"].AsString(), user["CreationDate"].AsDate().ToString("M/d/yyyy",
                                                                                                                        System.Globalization.CultureInfo.InvariantCulture), charterMember, about["FLAbout"].AsString(), (uint)flags,
                                            about["FLImage"].AsUUID(), about["Image"].AsUUID(), about["URL"].AsString(), user["Partner"].AsUUID());

                OSDMap interests = null;
                if (user.ContainsKey("LLInterests"))
                {
                    try
                    {
                        interests = OSDParser.DeserializeJson(user["LLInterests"].AsString()) as OSDMap;
                        client.SendAvatarInterestsReply(avatarID, interests["WantMask"].AsUInteger(), interests["WantText"].AsString(), interests["SkillsMask"].AsUInteger(), interests["SkillsText"].AsString(), interests["Languages"].AsString());
                    }
                    catch { }
                }

                if (about == null)
                {
                    about = new OSDMap(0);
                }
            }
            else
            {
                m_log.Warn("[SIMIAN PROFILES]: Failed to fetch profile information for " + client.Name + ", returning default values");
                client.SendAvatarProperties(avatarID, String.Empty, "1/1/1970", Utils.EmptyBytes,
                                            String.Empty, (uint)flags, UUID.Zero, UUID.Zero, String.Empty, UUID.Zero);
            }
        }