From fe49c96ee0db0974a91b9b175ac1b00aef035797 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 3 Mar 2008 08:30:36 +0000 Subject: * Applying Ahzz's profile patch. Thanks Ahzz! * Fixed a few bugs in the patch that are sim crashers. * There's still a bug in mySQL mode/ grid mode where the main userprofile text doesn't save. --- OpenSim/Region/ClientStack/ClientView.cs | 27 +++++++++++-- .../Region/Communications/OGS1/OGS1UserServices.cs | 42 ++++++++++++++++++++ .../Environment/Modules/AvatarProfilesModule.cs | 45 +++++++++++++++++++--- .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 2 + 4 files changed, 106 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index d032a2e..fe12cb7 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -123,6 +123,7 @@ namespace OpenSim.Region.ClientStack //- used so we don't create new objects for each incoming packet and then toss it out later */ private RequestAvatarProperties handlerRequestAvatarProperties = null; //OnRequestAvatarProperties; + private UpdateAvatarProperties handlerUpdateAvatarProperties = null; // OnUpdateAvatarProperties; private ChatFromViewer handlerChatFromViewer = null; //OnChatFromViewer; private ChatFromViewer handlerChatFromViewer2 = null; //OnChatFromViewer; private ImprovedInstantMessage handlerInstantMessage = null; //OnInstantMessage; @@ -217,7 +218,6 @@ namespace OpenSim.Region.ClientStack private PacketStats handlerPacketStats = null; // OnPacketStats;# private RequestAsset handlerRequestAsset = null; // OnRequestAsset; - /* Properties */ public LLUUID SecureSessionId @@ -670,6 +670,7 @@ namespace OpenSim.Region.ClientStack public event FetchInventory OnAgentDataUpdateRequest; public event FetchInventory OnUserInfoRequest; public event TeleportLocationRequest OnSetStartLocationRequest; + public event UpdateAvatarProperties OnUpdateAvatarProperties; public event CreateNewInventoryItem OnCreateNewInventoryItem; @@ -1591,7 +1592,10 @@ namespace OpenSim.Region.ClientStack avatarReply.PropertiesData.AboutText = Helpers.StringToField(aboutText); avatarReply.PropertiesData.BornOn = Helpers.StringToField(bornOn); avatarReply.PropertiesData.CharterMember = Helpers.StringToField(charterMember); - avatarReply.PropertiesData.FLAboutText = Helpers.StringToField(flAbout); + if (flAbout != null) + avatarReply.PropertiesData.FLAboutText = Helpers.StringToField(flAbout); + else + avatarReply.PropertiesData.FLAboutText = Helpers.StringToField(""); avatarReply.PropertiesData.Flags = 0; avatarReply.PropertiesData.FLImageID = flImageID; avatarReply.PropertiesData.ImageID = imageID; @@ -2901,10 +2905,25 @@ namespace OpenSim.Region.ClientStack if (handlerChatFromViewer != null) handlerChatFromViewer(this, args); } + break; + case PacketType.AvatarPropertiesUpdate: + AvatarPropertiesUpdatePacket Packet = (AvatarPropertiesUpdatePacket)Pack; - - + handlerUpdateAvatarProperties = OnUpdateAvatarProperties; + if (handlerUpdateAvatarProperties != null) + { + AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = Packet.PropertiesData; + UserProfileData UserProfile = new UserProfileData(); + UserProfile.UUID = AgentId; + UserProfile.profileAboutText = Util.FieldToString(Properties.AboutText); + UserProfile.profileFirstText = Util.FieldToString(Properties.FLAboutText); + UserProfile.profileFirstImage = Properties.FLImageID; + UserProfile.profileImage = Properties.ImageID; + + handlerUpdateAvatarProperties(this, UserProfile); + } break; + case PacketType.ScriptDialogReply: ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack; int ch = rdialog.Data.ChatChannel; diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 8ad4468..7dcbb46 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -270,6 +270,48 @@ namespace OpenSim.Region.Communications.OGS1 throw new Exception("The method or operation is not implemented."); } + public bool UpdateUserProfileProperties(UserProfileData UserProfile) + { + m_log.Debug("[OGS1UserService]: Asking UserServer to update profile."); + Hashtable param = new Hashtable(); + param["avatar_uuid"] = UserProfile.UUID.ToString(); + //param["AllowPublish"] = UserProfile.ToString(); + param["FLImageID"] = UserProfile.profileFirstImage.ToString(); + param["ImageID"] = UserProfile.profileImage.ToString(); + //param["MaturePublish"] = MaturePublish.ToString(); + param["AboutText"] = UserProfile.profileAboutText; + param["FLAboutText"] = UserProfile.profileFirstText; + //param["ProfileURL"] = UserProfile.ProfileURL.ToString(); + IList parameters = new ArrayList(); + parameters.Add(param); + + XmlRpcRequest req = new XmlRpcRequest("update_user_profile", parameters); + XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000); + Hashtable respData = (Hashtable)resp.Value; + if (respData != null) + { + if (respData.Contains("returnString")) + { + if (((string)respData["returnString"]).ToUpper() != "TRUE") + { + m_log.Warn("[GRID]: Unable to update user profile, User Server Reported an issue"); + return false; + } + } + else + { + m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!"); + return false; + } + } + else + { + m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!"); + return false; + } + return true; + } + #region IUserServices Friend Methods /// /// Adds a new friend to the database for XUser diff --git a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs index 8f4a0a1..711236d 100644 --- a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs @@ -36,6 +36,7 @@ namespace OpenSim.Region.Environment.Modules { public class AvatarProfilesModule : IRegionModule { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; public AvatarProfilesModule() @@ -69,11 +70,13 @@ namespace OpenSim.Region.Environment.Modules public void NewClient(IClientAPI client) { client.OnRequestAvatarProperties += RequestAvatarProperty; + client.OnUpdateAvatarProperties += UpdateAvatarProperties; } public void RemoveClient(IClientAPI client) { client.OnRequestAvatarProperties -= RequestAvatarProperty; + client.OnUpdateAvatarProperties -= UpdateAvatarProperties; } /// @@ -83,12 +86,42 @@ namespace OpenSim.Region.Environment.Modules /// public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) { - string about = "OpenSim crash test dummy"; - string bornOn = "Before now"; - string flAbout = "First life? What is one of those? OpenSim is my life!"; + // FIXME: finish adding fields such as url, masking, etc. LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); - remoteClient.SendAvatarProperties(avatarID, about, bornOn, System.String.Empty, flAbout, 0, LLUUID.Zero, LLUUID.Zero, System.String.Empty, - partner); + UserProfileData profile = m_scene.CommsManager.UserService.GetUserProfile(avatarID); + if (null != profile) + { + remoteClient.SendAvatarProperties(profile.UUID, profile.profileAboutText, + Util.ToDateTime(profile.created).ToString(), + System.String.Empty, profile.profileFirstText, profile.profileCanDoMask, + profile.profileFirstImage, profile.profileImage, System.String.Empty, partner); + } + else + { + m_log.Debug("[AvatarProfilesModule]: Got null for profile for " + avatarID.ToString()); + } + } + + public void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData newProfile) + { + UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.UUID); + + // if it's the profile of the user requesting the update, then we change only a few things. + if (remoteClient.AgentId.CompareTo(Profile.UUID) == 0) + { + Profile.profileImage = newProfile.profileImage; + Profile.profileFirstImage = newProfile.profileFirstImage; + Profile.profileAboutText = newProfile.profileAboutText; + Profile.profileFirstText = newProfile.profileFirstText; + } + else + { + return; + } + if (m_scene.CommsManager.UserService.UpdateUserProfileProperties(Profile)) + { + RequestAvatarProperty(remoteClient, newProfile.UUID); + } } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index 30a41b7..cb2c908 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -154,6 +154,8 @@ namespace SimpleApp public event FriendshipTermination OnTerminateFriendship; public event PacketStats OnPacketStats; public event MoneyBalanceRequest OnMoneyBalanceRequest; + public event UpdateAvatarProperties OnUpdateAvatarProperties; + #pragma warning restore 67 -- cgit v1.1