From 2c90c6102037e0b0332fd8fe2a48627dee80158a Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 21 Jul 2007 07:29:37 +0000 Subject: * Issue#206 - Casting of a LLUUID from XMLRPC hashtable causes an error. (Thanks Babblefrog) * Issue#205 - MySQLManager User Creation support readded (Thanks Babblefrog + adjohn) * Issue#204 - Clients now recieve terrain updates properly (Thanks Babblefrog) [May do some slight modifications on this to make it an event] --- OpenSim/Framework/Data.MySQL/MySQLManager.cs | 85 ++++++++++++++++++++++++ OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 15 +++++ OpenSim/Framework/UserManager/UserManagerBase.cs | 2 +- 3 files changed, 101 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs index a5434c8..affb8f3 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs @@ -536,6 +536,91 @@ namespace OpenSim.Framework.Data.MySQL 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 insertUserRow(libsecondlife.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, + libsecondlife.LLUUID profileImage, libsecondlife.LLUUID firstImage) + { + string sql = "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, "; + sql += "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; + sql += "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; + sql += "`profileFirstText`, `profileImage`, `profileFirstImage`) VALUES "; + + sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, "; + sql += "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; + sql += "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; + sql += "?profileFirstText, ?profileImage, ?profileFirstImage)"; + + Dictionary parameters = new Dictionary(); + parameters["?UUID"] = uuid.ToStringHyphenated(); + 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"] = ""; + parameters["?userAssetURI"] = ""; + parameters["?profileCanDoMask"] = "0"; + parameters["?profileWantDoMask"] = "0"; + parameters["?profileAboutText"] = ""; + parameters["?profileFirstText"] = ""; + parameters["?profileImage"] = libsecondlife.LLUUID.Zero.ToStringHyphenated(); + parameters["?profileFirstImage"] = libsecondlife.LLUUID.Zero.ToStringHyphenated(); + + bool returnval = false; + + try + { + IDbCommand result = Query(sql, parameters); + + if (result.ExecuteNonQuery() == 1) + returnval = true; + + result.Dispose(); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + return false; + } + + 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 b044bdd..66ea465 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs @@ -199,6 +199,21 @@ namespace OpenSim.Framework.Data.MySQL /// The user profile to create public void addNewUserProfile(UserProfileData user) { + try + { + lock (database) + { + database.insertUserRow(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); + } + } + catch (Exception e) + { + database.Reconnect(); + Console.WriteLine(e.ToString()); + } + } /// diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index c614300..a103f25 100644 --- a/OpenSim/Framework/UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs @@ -614,7 +614,7 @@ namespace OpenSim.Framework.UserManagement System.Console.WriteLine("METHOD BY UUID CALLED"); if (requestData.Contains("avatar_uuid")) { - userProfile = getUserProfile((LLUUID)requestData["avatar_uuid"]); + userProfile = getUserProfile((LLUUID)(string)requestData["avatar_uuid"]); if (userProfile == null) { return CreateUnknownUserErrorResponse(); -- cgit v1.1