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.
---
.../Communications/CommunicationsManager.cs | 6 ++
.../Framework/Communications/UserManagerBase.cs | 31 +++++-
OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs | 14 +--
OpenSim/Framework/Data.MySQL/MySQLManager.cs | 113 ++++++++++++++++++++-
OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 8 +-
OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | 8 +-
OpenSim/Framework/IClientAPI.cs | 3 +
OpenSim/Framework/IUserService.cs | 7 ++
OpenSim/Framework/Util.cs | 22 +++-
OpenSim/Grid/UserServer/Main.cs | 1 +
OpenSim/Grid/UserServer/UserManager.cs | 55 ++++++++++
OpenSim/Region/ClientStack/ClientView.cs | 27 ++++-
.../Region/Communications/OGS1/OGS1UserServices.cs | 42 ++++++++
.../Environment/Modules/AvatarProfilesModule.cs | 45 ++++++--
.../Region/Examples/SimpleApp/MyNpcCharacter.cs | 2 +
15 files changed, 349 insertions(+), 35 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index 4ad808a..655abd7 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -229,6 +229,12 @@ namespace OpenSim.Framework.Communications
#region Packet Handlers
+ public void UpdateAvatarPropertiesRequest(IClientAPI remote_client, UserProfileData UserProfile)
+ {
+ m_userService.UpdateUserProfileProperties(UserProfile);
+ return;
+ }
+
public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client)
{
if (uuid == m_userProfileCacheService.libraryRoot.agentID)
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index 733d62b..3380e90 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -139,11 +139,10 @@ namespace OpenSim.Framework.UserManagement
}
///
- /// Set's user profile from object
+ /// Set's user profile from data object
///
- /// First name
- /// Last name
- /// A user profile
+ ///
+ ///
public bool setUserProfile(UserProfileData data)
{
foreach (KeyValuePair plugin in _plugins)
@@ -158,7 +157,6 @@ namespace OpenSim.Framework.UserManagement
m_log.Info("[USERSTORAGE]: Unable to set user via " + plugin.Key + "(" + e.ToString() + ")");
}
}
-
return false;
}
@@ -534,6 +532,29 @@ namespace OpenSim.Framework.UserManagement
return user.UUID;
}
+ public bool UpdateUserProfileProperties(UserProfileData UserProfile)
+ {
+ if (null == GetUserProfile(UserProfile.UUID))
+ {
+ m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.UUID.ToString());
+ return false;
+ }
+ foreach (KeyValuePair plugin in _plugins)
+ {
+ try
+ {
+ plugin.Value.UpdateUserProfile(UserProfile);
+ }
+ catch (Exception e)
+ {
+ m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.UUID.ToString()
+ + " via " + plugin.Key + "(" + e.ToString() + ")");
+ return false;
+ }
+ }
+ return true;
+ }
+
public abstract UserProfileData SetupMasterUser(string firstName, string lastName);
public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password);
public abstract UserProfileData SetupMasterUser(LLUUID uuid);
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
index 402a88f..2244f4b 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
@@ -588,10 +588,10 @@ namespace OpenSim.Framework.Data.MSSQL
parameters["userAssetURI"] = String.Empty;
parameters["profileCanDoMask"] = "0";
parameters["profileWantDoMask"] = "0";
- parameters["profileAboutText"] = String.Empty;
- parameters["profileFirstText"] = String.Empty;
- parameters["profileImage"] = LLUUID.Zero.ToString();
- parameters["profileFirstImage"] = LLUUID.Zero.ToString();
+ parameters["profileAboutText"] = aboutText;
+ parameters["profileFirstText"] = firstText;
+ parameters["profileImage"] = profileImage.ToString();
+ parameters["profileFirstImage"] = firstImage.ToString();
parameters["webLoginKey"] = LLUUID.Random().ToString();
bool returnval = false;
@@ -670,8 +670,8 @@ namespace OpenSim.Framework.Data.MSSQL
SqlParameter param18 = new SqlParameter("@profileWantDoMask", Convert.ToInt32(user.profileWantDoMask));
SqlParameter param19 = new SqlParameter("@profileAboutText", user.profileAboutText);
SqlParameter param20 = new SqlParameter("@profileFirstText", user.profileFirstText);
- SqlParameter param21 = new SqlParameter("@profileImage", LLUUID.Zero.ToString());
- SqlParameter param22 = new SqlParameter("@profileFirstImage", LLUUID.Zero.ToString());
+ SqlParameter param21 = new SqlParameter("@profileImage", user.profileImage.ToString());
+ SqlParameter param22 = new SqlParameter("@profileFirstImage", user.profileFirstImage.ToString());
SqlParameter param23 = new SqlParameter("@keyUUUID", user.UUID.ToString());
SqlParameter param24 = new SqlParameter("@webLoginKey", user.webLoginKey.UUID.ToString());
command.Parameters.Add(param1);
@@ -768,4 +768,4 @@ namespace OpenSim.Framework.Data.MSSQL
{
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
index 1a90eea..ea11aa0 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
@@ -452,11 +452,25 @@ namespace OpenSim.Framework.Data.MySQL
retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString());
retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString());
- retval.profileAboutText = (string) reader["profileAboutText"];
- retval.profileFirstText = (string) reader["profileFirstText"];
+ if (reader.IsDBNull(reader.GetOrdinal("profileAboutText")))
+ retval.profileAboutText = "";
+ else
+ retval.profileAboutText = (string) reader["profileAboutText"];
- LLUUID.TryParse((string)reader["profileImage"], out retval.profileImage);
- LLUUID.TryParse((string)reader["profileFirstImage"], out retval.profileFirstImage);
+ if (reader.IsDBNull( reader.GetOrdinal( "profileFirstText" ) ) )
+ retval.profileFirstText = "";
+ else
+ retval.profileFirstText = (string)reader["profileFirstText"];
+
+ if (reader.IsDBNull( reader.GetOrdinal( "profileImage" ) ) )
+ retval.profileImage = LLUUID.Zero;
+ else
+ LLUUID.TryParse((string)reader["profileImage"], out retval.profileImage);
+
+ if (reader.IsDBNull( reader.GetOrdinal( "profileFirstImage" ) ) )
+ retval.profileFirstImage = LLUUID.Zero;
+ else
+ LLUUID.TryParse((string)reader["profileFirstImage"], out retval.profileFirstImage);
if( reader.IsDBNull( reader.GetOrdinal( "webLoginKey" ) ) )
{
@@ -553,6 +567,7 @@ namespace OpenSim.Framework.Data.MySQL
string aboutText, string firstText,
LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey)
{
+ m_log.Debug("[MySQLManager]: Fetching profile for " + uuid.ToString());
string sql =
"INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, ";
sql +=
@@ -610,9 +625,99 @@ namespace OpenSim.Framework.Data.MySQL
return false;
}
+ m_log.Debug("[MySQLManager]: Fetch user retval == " + returnval.ToString());
return returnval;
}
+ ///
+ /// Creates a new user and inserts it into the database
+ ///
+ /// User ID
+ /// First part of the login
+ /// Second part of the login
+ /// A salted hash of the users password
+ /// The salt used for the password hash
+ /// A regionHandle of the users home region
+ /// Home region position vector
+ /// Home region position vector
+ /// Home region position vector
+ /// Home region 'look at' vector
+ /// Home region 'look at' vector
+ /// Home region 'look at' vector
+ /// Account created (unix timestamp)
+ /// Last login (unix timestamp)
+ /// Users inventory URI
+ /// Users asset URI
+ /// I can do mask
+ /// I want to do mask
+ /// Profile text
+ /// Firstlife text
+ /// UUID for profile image
+ /// UUID for firstlife image
+ /// Success?
+ public bool updateUserRow(LLUUID uuid, string username, string lastname, string passwordHash,
+ string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ,
+ float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin,
+ string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask,
+ string aboutText, string firstText,
+ LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey)
+ {
+ string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname ";
+ sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , ";
+ sql += "`homeRegion` = ?homeRegion , `homeLocationX` = ?homeLocationX , ";
+ sql += "`homeLocationY` = ?homeLocationY , `homeLocationZ` = ?homeLocationZ , ";
+ sql += "`homeLookAtX` = ?homeLookAtX , `homeLookAtY` = ?homeLookAtY , ";
+ sql += "`homeLookAtZ` = ?homeLookAtZ , `created` = ?created , `lastLogin` = ?lastLogin , ";
+ sql += "`userInventoryURI` = ?userInventoryURI , `userAssetURI` = ?userAssetURI , ";
+ sql += "`profileCanDoMask` = ?profileCanDoMask , `profileWantDoMask` = ?profileWantDoMask , ";
+ sql += "`profileAboutText` = ?profileAboutText , `profileFirstText` = ?profileFirstText, ";
+ sql += "`profileImage` = ?profileImage , `profileFirstImage` = ?profileFirstImage , ";
+ sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID";
+
+ Dictionary parameters = new Dictionary();
+ parameters["?UUID"] = uuid.ToString();
+ parameters["?username"] = username.ToString();
+ parameters["?lastname"] = lastname.ToString();
+ parameters["?passwordHash"] = passwordHash.ToString();
+ parameters["?passwordSalt"] = passwordSalt.ToString();
+ parameters["?homeRegion"] = homeRegion.ToString();
+ parameters["?homeLocationX"] = homeLocX.ToString();
+ parameters["?homeLocationY"] = homeLocY.ToString();
+ parameters["?homeLocationZ"] = homeLocZ.ToString();
+ parameters["?homeLookAtX"] = homeLookAtX.ToString();
+ parameters["?homeLookAtY"] = homeLookAtY.ToString();
+ parameters["?homeLookAtZ"] = homeLookAtZ.ToString();
+ parameters["?created"] = created.ToString();
+ parameters["?lastLogin"] = lastlogin.ToString();
+ parameters["?userInventoryURI"] = inventoryURI;
+ parameters["?userAssetURI"] = assetURI;
+ parameters["?profileCanDoMask"] = "0";
+ parameters["?profileWantDoMask"] = "0";
+ parameters["?profileAboutText"] = aboutText;
+ parameters["?profileFirstText"] = firstText;
+ parameters["?profileImage"] = profileImage.ToString();
+ parameters["?profileFirstImage"] = firstImage.ToString();
+ parameters["?webLoginKey"] = webLoginKey.ToString();
+
+ bool returnval = false;
+ try
+ {
+ IDbCommand result = Query(sql, parameters);
+
+ if (result.ExecuteNonQuery() == 1)
+ returnval = true;
+
+ result.Dispose();
+ }
+ catch (Exception e)
+ {
+ m_log.Error(e.ToString());
+ return false;
+ }
+
+ m_log.Debug("[MySQLManager]: update user retval == " + returnval.ToString());
+ return returnval;
+ }
///
/// Inserts a new region into the database
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
index bc18376..2bba6ce 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
@@ -594,7 +594,11 @@ namespace OpenSim.Framework.Data.MySQL
/// The profile data to use to update the DB
public bool UpdateUserProfile(UserProfileData user)
{
- // TODO: implement
+ database.updateUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt
+ , user.homeRegion, user.homeLocation.X, user.homeLocation.Y, user.homeLocation.Z, user.homeLookAt.X
+ , user.homeLookAt.Y, user.homeLookAt.Z, user.created, user.lastLogin, user.userInventoryURI
+ , user.userAssetURI, user.profileCanDoMask, user.profileWantDoMask, user.profileAboutText
+ , user.profileFirstText, user.profileImage, user.profileFirstImage, user.webLoginKey);
return true;
}
@@ -641,4 +645,4 @@ namespace OpenSim.Framework.Data.MySQL
return "0.1";
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
index 2316de8..22f0053 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
@@ -590,7 +590,7 @@ namespace OpenSim.Framework.Data.SQLite
// interesting has to be done to actually get these values
// back out. Not enough time to figure it out yet.
UserProfileData user = new UserProfileData();
- user.UUID = new LLUUID((String) row["UUID"]);
+ LLUUID.TryParse((String)row["UUID"], out user.UUID);
user.username = (String) row["username"];
user.surname = (String) row["surname"];
user.passwordHash = (String) row["passwordHash"];
@@ -617,8 +617,8 @@ namespace OpenSim.Framework.Data.SQLite
user.profileWantDoMask = Convert.ToUInt32(row["profileWantDoMask"]);
user.profileAboutText = (String) row["profileAboutText"];
user.profileFirstText = (String) row["profileFirstText"];
- user.profileImage = new LLUUID((String) row["profileImage"]);
- user.profileFirstImage = new LLUUID((String) row["profileFirstImage"]);
+ LLUUID.TryParse((String)row["profileImage"], out user.profileImage);
+ LLUUID.TryParse((String)row["profileFirstImage"], out user.profileFirstImage);
user.webLoginKey = new LLUUID((String) row["webLoginKey"]);
return user;
@@ -832,4 +832,4 @@ namespace OpenSim.Framework.Data.SQLite
return true;
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 511bbad..5001f00 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -264,6 +264,8 @@ namespace OpenSim.Framework
public delegate void RequestAvatarProperties(IClientAPI remoteClient, LLUUID avatarID);
+ public delegate void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData ProfileData);
+
public delegate void SetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun);
public delegate void GenericCall2();
@@ -530,6 +532,7 @@ namespace OpenSim.Framework
event MoneyTransferRequest OnMoneyTransferRequest;
event MoneyBalanceRequest OnMoneyBalanceRequest;
+ event UpdateAvatarProperties OnUpdateAvatarProperties;
LLVector3 StartPos { get; set; }
diff --git a/OpenSim/Framework/IUserService.cs b/OpenSim/Framework/IUserService.cs
index 3b84486..0faf12e 100644
--- a/OpenSim/Framework/IUserService.cs
+++ b/OpenSim/Framework/IUserService.cs
@@ -87,6 +87,13 @@ namespace OpenSim.Framework
void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms);
///
+ /// Updates a user profile
+ ///
+ /// Profile to update
+ ///
+ bool UpdateUserProfileProperties(UserProfileData UserProfile);
+
+ ///
/// Logs off a user on the user server
///
/// UUID of the user
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 856cac3..35e795b 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -181,9 +181,25 @@ namespace OpenSim.Framework
public static int UnixTimeSinceEpoch()
{
- TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
- int timestamp = (int) t.TotalSeconds;
- return timestamp;
+ return ToUnixTime(DateTime.UtcNow);
+ }
+
+ public static int ToUnixTime(DateTime stamp)
+ {
+ TimeSpan t = (stamp.ToUniversalTime() - Convert.ToDateTime("1/1/1970 8:00:00 AM"));
+ return (int)t.TotalSeconds;
+ }
+
+ public static DateTime ToDateTime(ulong seconds)
+ {
+ DateTime epoch = Convert.ToDateTime("1/1/1970 8:00:00 AM");
+ return epoch.AddSeconds(seconds);
+ }
+
+ public static DateTime ToDateTime(int seconds)
+ {
+ DateTime epoch = Convert.ToDateTime("1/1/1970 8:00:00 AM");
+ return epoch.AddSeconds(seconds);
}
public static string Md5Hash(string pass)
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index fcf9de6..c3d65c4 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -127,6 +127,7 @@ namespace OpenSim.Grid.UserServer
httpServer.AddStreamHandler(
new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
+ httpServer.AddXmlRPCHandler("update_user_profile", m_userManager.XmlRpcResponseXmlRPCUpdateUserProfile);
httpServer.Start();
m_log.Info("[SERVER]: Userserver 0.5 - Startup complete");
}
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
index 367b5d7..153ac75 100644
--- a/OpenSim/Grid/UserServer/UserManager.cs
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -313,6 +313,61 @@ namespace OpenSim.Grid.UserServer
return ProfileToXmlRPCResponse(userProfile);
}
+
+ public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserProfile(XmlRpcRequest request)
+ {
+ m_log.Debug("[UserManager]: Got request to update user profile");
+ XmlRpcResponse response = new XmlRpcResponse();
+ Hashtable requestData = (Hashtable)request.Params[0];
+ Hashtable responseData = new Hashtable();
+
+ UserProfileData userProfile;
+ if (!requestData.Contains("avatar_uuid"))
+ {
+ return CreateUnknownUserErrorResponse();
+ }
+
+ LLUUID UserUUID = new LLUUID((string)requestData["avatar_uuid"]);
+ userProfile = GetUserProfile(UserUUID);
+ if (null == userProfile)
+ {
+ return CreateUnknownUserErrorResponse();
+ }
+ // don't know how yet.
+ if (requestData.Contains("AllowPublish"))
+ {
+ }
+ if (requestData.Contains("FLImageID"))
+ {
+ userProfile.profileFirstImage = new LLUUID((string)requestData["FLImageID"]);
+ }
+ if (requestData.Contains("ImageID"))
+ {
+ userProfile.profileImage = new LLUUID((string)requestData["ImageID"]);
+ }
+ // dont' know how yet
+ if (requestData.Contains("MaturePublish"))
+ {
+ }
+ if (requestData.Contains("AboutText"))
+ {
+ userProfile.profileAboutText = (string)requestData["AboutText"];
+ }
+ if (requestData.Contains("FLAboutText"))
+ {
+ userProfile.profileFirstText = (string)requestData["FLAboutText"];
+ }
+ // not in DB yet.
+ if (requestData.Contains("ProfileURL"))
+ {
+ }
+ // call plugin!
+ bool ret = UpdateUserProfileProperties(userProfile);
+ responseData["returnString"] = ret.ToString();
+ response.Value = responseData;
+ return response;
+ }
+
public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request)
{
XmlRpcResponse response = new XmlRpcResponse();
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