mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 09:45:47 +08:00
* 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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// Adds a new friend to the database for XUser
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,12 +86,42 @@ namespace OpenSim.Region.Environment.Modules
|
||||
/// <param name="avatarID"></param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user