* 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:
Teravus Ovares
2008-03-03 08:30:36 +00:00
parent c953e51c11
commit fe49c96ee0
15 changed files with 350 additions and 36 deletions

View File

@@ -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)

View File

@@ -139,11 +139,10 @@ namespace OpenSim.Framework.UserManagement
}
/// <summary>
/// Set's user profile from object
/// Set's user profile from data object
/// </summary>
/// <param name="fname">First name</param>
/// <param name="lname">Last name</param>
/// <returns>A user profile</returns>
/// <param name="data"></param>
/// <returns></returns>
public bool setUserProfile(UserProfileData data)
{
foreach (KeyValuePair<string, IUserData> 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<string, IUserData> 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);

View File

@@ -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
{
}
}
}
}

View File

@@ -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;
}
/// <summary>
/// Creates a new user and inserts it into the database
/// </summary>
/// <param name="uuid">User ID</param>
/// <param name="username">First part of the login</param>
/// <param name="lastname">Second part of the login</param>
/// <param name="passwordHash">A salted hash of the users password</param>
/// <param name="passwordSalt">The salt used for the password hash</param>
/// <param name="homeRegion">A regionHandle of the users home region</param>
/// <param name="homeLocX">Home region position vector</param>
/// <param name="homeLocY">Home region position vector</param>
/// <param name="homeLocZ">Home region position vector</param>
/// <param name="homeLookAtX">Home region 'look at' vector</param>
/// <param name="homeLookAtY">Home region 'look at' vector</param>
/// <param name="homeLookAtZ">Home region 'look at' vector</param>
/// <param name="created">Account created (unix timestamp)</param>
/// <param name="lastlogin">Last login (unix timestamp)</param>
/// <param name="inventoryURI">Users inventory URI</param>
/// <param name="assetURI">Users asset URI</param>
/// <param name="canDoMask">I can do mask</param>
/// <param name="wantDoMask">I want to do mask</param>
/// <param name="aboutText">Profile text</param>
/// <param name="firstText">Firstlife text</param>
/// <param name="profileImage">UUID for profile image</param>
/// <param name="firstImage">UUID for firstlife image</param>
/// <returns>Success?</returns>
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<string, string> parameters = new Dictionary<string, string>();
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;
}
/// <summary>
/// Inserts a new region into the database

View File

@@ -594,7 +594,11 @@ namespace OpenSim.Framework.Data.MySQL
/// <param name="user">The profile data to use to update the DB</param>
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";
}
}
}
}

View File

@@ -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;
}
}
}
}

View File

@@ -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; }

View File

@@ -86,6 +86,13 @@ namespace OpenSim.Framework
/// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms);
/// <summary>
/// Updates a user profile
/// </summary>
/// <param name="UserProfile">Profile to update</param>
/// <returns></returns>
bool UpdateUserProfileProperties(UserProfileData UserProfile);
/// <summary>
/// Logs off a user on the user server
/// </summary>

View File

@@ -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)