Inheritance: WhiteCore.Framework.Modules.IDataTransferable
        public IUserProfileInfo GetUserProfile(UUID agentID)
        {
            IUserProfileInfo UserProfile = new IUserProfileInfo();
            lock (UserProfilesCache)
            {
                //Try from the user profile first before getting from the DB
                if (UserProfilesCache.TryGetValue(agentID, out UserProfile))
                    return UserProfile;
            }

            object remoteValue = DoRemote(agentID);
            if (remoteValue != null || m_doRemoteOnly)
            {
                UserProfile = (IUserProfileInfo)remoteValue;
                //Add to the cache
                lock (UserProfilesCache)
                    UserProfilesCache[agentID] = UserProfile;
                return UserProfile;
            }

            QueryFilter filter = new QueryFilter();
            filter.andFilters["ID"] = agentID;
            filter.andFilters["`Key`"] = "LLProfile";
            List<string> query = null;
            //Grab it from the almost generic interface
            query = GD.Query(new[] { "Value" }, m_userProfileTable, filter, null, null, null);

            if (query == null || query.Count == 0)
                return null;
            //Pull out the OSDmap
            OSDMap profile = (OSDMap) OSDParser.DeserializeLLSDXml(query[0]);

            UserProfile = new IUserProfileInfo();
            UserProfile.FromOSD(profile);

            //Add to the cache
            lock(UserProfilesCache)
                UserProfilesCache[agentID] = UserProfile;

            return UserProfile;
        }
        void SendProfile(IClientAPI remoteClient, IUserProfileInfo Profile, UserAccount account,
            uint agentOnline)
        {
            Byte[] charterMember;
            if (Profile.MembershipGroup == "")
            {
                charterMember = new Byte[1];
                if (account != null)
                    charterMember [0] = (Byte)((account.UserFlags & Constants.USER_FLAG_CHARTERMEMBER) >> 8);   // CharterMember == 0xf00
            } else
                charterMember = Utils.StringToBytes (Profile.MembershipGroup);

            // 19-06-2015 Fly-Man-
            // When charterMember set this character └ the viewer recognizes it
            // as a Grid Master. Not sure what we want to do with that in WhiteCore
            //
            // Perhaps a talk with viewer devs to allow more options for this
            //

            if (Utilities.IsSystemUser (Profile.PrincipalID))
            {
                charterMember = Utils.StringToBytes ("└");
            }

            uint membershipGroupINT = 0;
            if (Profile.MembershipGroup != "")
                membershipGroupINT = 4;

            uint flags = Convert.ToUInt32 (Profile.AllowPublish) + Convert.ToUInt32 (Profile.MaturePublish) +
                         membershipGroupINT + agentOnline + (uint)(account != null ? account.UserFlags : 0);

            remoteClient.SendAvatarInterestsReply (
                Profile.PrincipalID,
                Convert.ToUInt32 (Profile.Interests.WantToMask),
                Profile.Interests.WantToText,
                Convert.ToUInt32 (Profile.Interests.CanDoMask),
                Profile.Interests.CanDoText,
                Profile.Interests.Languages
            );

            remoteClient.SendAvatarProperties (
                Profile.PrincipalID,
                Profile.AboutText,
                Util.ToDateTime (Profile.Created).ToString ("M/d/yyyy", CultureInfo.InvariantCulture),
                charterMember,
                Profile.FirstLifeAboutText,
                flags,
                Profile.FirstLifeImage,
                Profile.Image,
                Profile.WebURL,
                Profile.Partner
            );
        }
Exemplo n.º 3
0
        private void PackUserInfo(IUserProfileInfo info, UserAccount account, ref OSDArray agents)
        {
            OSDMap agentMap = new OSDMap();
            agentMap["username"] = account.Name;
            agentMap["display_name"] = (info == null || info.DisplayName == "") ? account.Name : info.DisplayName;
            agentMap["display_name_next_update"] =
                OSD.FromDate(
                    DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z",
                                        DateTimeFormatInfo.InvariantInfo).ToUniversalTime());
            agentMap["legacy_first_name"] = account.FirstName;
            agentMap["legacy_last_name"] = account.LastName;
            agentMap["id"] = account.PrincipalID;
            agentMap["is_display_name_default"] = isDefaultDisplayName(account.FirstName, account.LastName, account.Name,
                                                                       info == null ? account.Name : info.DisplayName);

            agents.Add(agentMap);
        }
        public bool UpdateUserProfile(IUserProfileInfo Profile)
        {
            object remoteValue = DoRemote(Profile);
            if (remoteValue != null || m_doRemoteOnly)
                return remoteValue != null && (bool) remoteValue;

            IUserProfileInfo previousProfile = GetUserProfile(Profile.PrincipalID);
            //Make sure the previous one exists
            if (previousProfile == null)
                return false;
            //Now fix values that the sim cannot change
            Profile.Partner = previousProfile.Partner;
            Profile.CustomType = previousProfile.CustomType;
            Profile.MembershipGroup = previousProfile.MembershipGroup;
            Profile.Created = previousProfile.Created;

            Dictionary<string, object> values = new Dictionary<string, object>(1);
            values["Value"] = OSDParser.SerializeLLSDXmlString(Profile.ToOSD());

            QueryFilter filter = new QueryFilter();
            filter.andFilters["ID"] = Profile.PrincipalID.ToString();
            filter.andFilters["`Key`"] = "LLProfile";

            //Update cache
            lock(UserProfilesCache)
                UserProfilesCache[Profile.PrincipalID] = Profile;

            return GD.Update("userdata", values, null, filter, null, null);
        }
        /// <summary>
        ///     Create a new profile for a user
        /// </summary>
        /// <param name="AgentID"></param>
        //[CanBeReflected(ThreatLevel = ThreatLevel.Full)]
        public void CreateNewProfile(UUID AgentID)
        {
            /*object remoteValue = DoRemote(AgentID);
            if (remoteValue != null || m_doRemoteOnly)
                return;*/

            List<object> values = new List<object> {AgentID.ToString(), "LLProfile"};

            //Create a new basic profile for them
            IUserProfileInfo profile = new IUserProfileInfo {PrincipalID = AgentID};

            values.Add(OSDParser.SerializeLLSDXmlString(profile.ToOSD())); //Value which is a default Profile

            GD.Insert("userdata", values.ToArray());
        }
Exemplo n.º 6
0
        void PackUserInfo (IUserProfileInfo info, UserAccount account, ref OSDArray agents)
        {
            OSDMap agentMap = new OSDMap ();
            agentMap ["username"] = account.Name;
            agentMap ["display_name"] = (info == null || info.DisplayName == "") ? account.Name : info.DisplayName;
            agentMap ["legacy_first_name"] = account.FirstName;
            agentMap ["legacy_last_name"] = account.LastName;
            agentMap ["id"] = account.PrincipalID;
            agentMap ["is_display_name_default"] = isDefaultDisplayName (account.FirstName, account.LastName, account.Name,
                                                                       info == null ? account.Name : info.DisplayName);
            if (info != null) {
                if (m_update_days > 0)
                    agentMap ["display_name_next_update"] = OSD.FromDate (info.DisplayNameUpdated.AddDays (m_update_days));
                else
                    agentMap ["display_name_next_update"] = OSD.FromDate (info.DisplayNameUpdated);
            }

            agents.Add (agentMap);
        }
        private void SendProfile(IClientAPI remoteClient, IUserProfileInfo Profile, UserAccount account,
            uint agentOnline)
        {
            Byte[] charterMember;
            if (Profile.MembershipGroup == "")
            {
                charterMember = new Byte[1];
                if (account != null)
                    charterMember[0] = (Byte) ((account.UserFlags & 0xf00) >> 8);
            }
            else
                charterMember = Utils.StringToBytes(Profile.MembershipGroup);

            uint membershipGroupINT = 0;
            if (Profile.MembershipGroup != "")
                membershipGroupINT = 4;

            uint flags = Convert.ToUInt32(Profile.AllowPublish) + Convert.ToUInt32(Profile.MaturePublish) +
                         membershipGroupINT + agentOnline + (uint) (account != null ? account.UserFlags : 0);
            remoteClient.SendAvatarInterestsReply(Profile.PrincipalID, Convert.ToUInt32(Profile.Interests.WantToMask),
                                                  Profile.Interests.WantToText,
                                                  Convert.ToUInt32(Profile.Interests.CanDoMask),
                                                  Profile.Interests.CanDoText, Profile.Interests.Languages);
            remoteClient.SendAvatarProperties(Profile.PrincipalID, Profile.AboutText,
                                              Util.ToDateTime(Profile.Created).ToString("M/d/yyyy",
                                                                                        CultureInfo.InvariantCulture),
                                              charterMember, Profile.FirstLifeAboutText, flags,
                                              Profile.FirstLifeImage, Profile.Image, Profile.WebURL,
                                              Profile.Partner);
        }