From c176caeb05c2264654b764e4d010561da60c24fc Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 10 Apr 2008 13:53:06 +0000 Subject: moved fields to properties for UserDataProfile, which was actually a little more work than I expected given the copious use of out params. --- .../Communications/Cache/CachedUserInfo.cs | 10 +- .../Communications/CommunicationsManager.cs | 10 +- OpenSim/Framework/Communications/LoginService.cs | 46 ++-- .../Framework/Communications/UserManagerBase.cs | 72 +++--- OpenSim/Framework/UserProfileData.cs | 244 +++++++++++++++++++-- 5 files changed, 290 insertions(+), 92 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index e39333b..75fe1aa 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -114,7 +114,7 @@ namespace OpenSim.Framework.Communications.Cache // "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", // folderInfo.name, folderInfo.folderID, userID); - if (userID == UserProfile.UUID) + if (userID == UserProfile.Id) { if (RootFolder == null) { @@ -169,7 +169,7 @@ namespace OpenSim.Framework.Communications.Cache /// public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.UUID) && (RootFolder != null)) + if ((userID == UserProfile.Id) && (RootFolder != null)) { if (itemInfo.Folder == RootFolder.ID) { @@ -194,7 +194,7 @@ namespace OpenSim.Framework.Communications.Cache public void AddItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.UUID) && (RootFolder != null)) + if ((userID == UserProfile.Id) && (RootFolder != null)) { ItemReceive(userID, itemInfo); m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); @@ -203,7 +203,7 @@ namespace OpenSim.Framework.Communications.Cache public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == UserProfile.UUID) && (RootFolder != null)) + if ((userID == UserProfile.Id) && (RootFolder != null)) { m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } @@ -212,7 +212,7 @@ namespace OpenSim.Framework.Communications.Cache public bool DeleteItem(LLUUID userID, InventoryItemBase item) { bool result = false; - if ((userID == UserProfile.UUID) && (RootFolder != null)) + if ((userID == UserProfile.Id) && (RootFolder != null)) { result = RootFolder.DeleteItem(item.ID); if (result) diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 95a0e05..6b01d8f 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -164,9 +164,9 @@ namespace OpenSim.Framework.Communications } else { - m_inventoryService.CreateNewUserInventory(userProf.UUID); + m_inventoryService.CreateNewUserInventory(userProf.Id); m_log.Info("[USERS]: Created new inventory set for " + firstName + " " + lastName); - return userProf.UUID; + return userProf.Id; } } @@ -249,9 +249,9 @@ namespace OpenSim.Framework.Communications UserProfileData profileData = m_userService.GetUserProfile(uuid); if (profileData != null) { - LLUUID profileId = profileData.UUID; - string firstname = profileData.username; - string lastname = profileData.surname; + LLUUID profileId = profileData.Id; + string firstname = profileData.FirstName; + string lastname = profileData.SurName; remote_client.SendNameReply(profileId, firstname, lastname); } diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 6f558a0..e5ad7a0 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -184,13 +184,13 @@ namespace OpenSim.Framework.UserManagement else { // If we already have a session... - if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) + if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.agentOnline) { //TODO: The following statements can cause trouble: // If agentOnline could not turn from true back to false normally // because of some problem, for instance, the crashment of server or client, // the user cannot log in any longer. - userProfile.currentAgent.agentOnline = false; + userProfile.CurrentAgent.agentOnline = false; m_userManager.CommitAgent(ref userProfile); // Reject the login @@ -207,7 +207,7 @@ namespace OpenSim.Framework.UserManagement try { - LLUUID agentID = userProfile.UUID; + LLUUID agentID = userProfile.Id; // Inventory Library Section InventoryData inventData = GetInventorySkeleton(agentID); @@ -217,16 +217,16 @@ namespace OpenSim.Framework.UserManagement InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); ArrayList InventoryRoot = new ArrayList(); InventoryRoot.Add(InventoryRootHash); - userProfile.rootInventoryFolderID = inventData.RootFolderID; + userProfile.RootInventoryFolderID = inventData.RootFolderID; // Circuit Code uint circode = (uint) (Util.RandomClass.Next()); - logResponse.Lastname = userProfile.surname; - logResponse.Firstname = userProfile.username; + logResponse.Lastname = userProfile.SurName; + logResponse.Firstname = userProfile.FirstName; logResponse.AgentID = agentID.ToString(); - logResponse.SessionID = userProfile.currentAgent.sessionID.ToString(); - logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToString(); + logResponse.SessionID = userProfile.CurrentAgent.sessionID.ToString(); + logResponse.SecureSessionID = userProfile.CurrentAgent.secureSessionID.ToString(); logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); @@ -334,9 +334,9 @@ namespace OpenSim.Framework.UserManagement else { // If we already have a session... - if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) + if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.agentOnline) { - userProfile.currentAgent = null; + userProfile.CurrentAgent = null; m_userManager.CommitAgent(ref userProfile); // Reject the login @@ -349,7 +349,7 @@ namespace OpenSim.Framework.UserManagement try { - LLUUID agentID = userProfile.UUID; + LLUUID agentID = userProfile.Id; // Inventory Library Section InventoryData inventData = GetInventorySkeleton(agentID); @@ -359,16 +359,16 @@ namespace OpenSim.Framework.UserManagement InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); ArrayList InventoryRoot = new ArrayList(); InventoryRoot.Add(InventoryRootHash); - userProfile.rootInventoryFolderID = inventData.RootFolderID; + userProfile.RootInventoryFolderID = inventData.RootFolderID; // Circuit Code uint circode = (uint)(Util.RandomClass.Next()); - logResponse.Lastname = userProfile.surname; - logResponse.Firstname = userProfile.username; + logResponse.Lastname = userProfile.SurName; + logResponse.Firstname = userProfile.FirstName; logResponse.AgentID = agentID.ToString(); - logResponse.SessionID = userProfile.currentAgent.sessionID.ToString(); - logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToString(); + logResponse.SessionID = userProfile.CurrentAgent.sessionID.ToString(); + logResponse.SecureSessionID = userProfile.CurrentAgent.secureSessionID.ToString(); logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; logResponse.InventoryLibrary = GetInventoryLibrary(); @@ -491,7 +491,7 @@ namespace OpenSim.Framework.UserManagement if (goodweblogin) { LLUUID webloginkey = LLUUID.Random(); - m_userManager.StoreWebLoginKey(user.UUID, webloginkey); + m_userManager.StoreWebLoginKey(user.Id, webloginkey); statuscode = 301; string redirectURL = "about:blank?redirect-http-hack=" + @@ -639,7 +639,7 @@ namespace OpenSim.Framework.UserManagement public virtual bool AuthenticateUser(UserProfileData profile, string password) { bool passwordSuccess = false; - m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID); + m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.Id); // Web Login method seems to also occasionally send the hashed password itself @@ -650,13 +650,13 @@ namespace OpenSim.Framework.UserManagement password = password.Remove(0, 3); //remove $1$ - string s = Util.Md5Hash(password + ":" + profile.passwordSalt); + string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); // Testing... //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); - passwordSuccess = (profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) - || profile.passwordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); + passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) + || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); return passwordSuccess; } @@ -664,10 +664,10 @@ namespace OpenSim.Framework.UserManagement public virtual bool AuthenticateUser(UserProfileData profile, LLUUID webloginkey) { bool passwordSuccess = false; - m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID); + m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.Id); // Match web login key unless it's the default weblogin key LLUUID.Zero - passwordSuccess = ((profile.webLoginKey==webloginkey) && profile.webLoginKey != LLUUID.Zero); + passwordSuccess = ((profile.WebLoginKey==webloginkey) && profile.WebLoginKey != LLUUID.Zero); return passwordSuccess; } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 332583c..02be6bd 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -96,7 +96,7 @@ namespace OpenSim.Framework.UserManagement if (profile != null) { - profile.currentAgent = getUserAgent(profile.UUID); + profile.CurrentAgent = getUserAgent(profile.Id); return profile; } } @@ -113,7 +113,7 @@ namespace OpenSim.Framework.UserManagement if (null != profile) { - profile.currentAgent = getUserAgent(profile.UUID); + profile.CurrentAgent = getUserAgent(profile.Id); return profile; } } @@ -298,7 +298,7 @@ namespace OpenSim.Framework.UserManagement public void clearUserAgent(LLUUID agentID) { UserProfileData profile = GetUserProfile(agentID); - profile.currentAgent = null; + profile.CurrentAgent = null; setUserProfile(profile); } @@ -355,28 +355,28 @@ namespace OpenSim.Framework.UserManagement agent.sessionID = new LLUUID(randDataS, 0); // Profile UUID - agent.UUID = profile.UUID; + agent.UUID = profile.Id; // Current position (from Home) - agent.currentHandle = profile.homeRegion; - agent.currentPos = profile.homeLocation; + agent.currentHandle = profile.HomeRegion; + agent.currentPos = profile.HomeLocation; // If user specified additional start, use that if (requestData.ContainsKey("start")) { string startLoc = ((string)requestData["start"]).Trim(); - if (("last" == startLoc) && (profile.currentAgent != null)) + if (("last" == startLoc) && (profile.CurrentAgent != null)) { - if ((profile.currentAgent.currentPos.X > 0) - && (profile.currentAgent.currentPos.Y > 0) - && (profile.currentAgent.currentPos.Z > 0) + if ((profile.CurrentAgent.currentPos.X > 0) + && (profile.CurrentAgent.currentPos.Y > 0) + && (profile.CurrentAgent.currentPos.Z > 0) ) { // TODO: Right now, currentRegion has not been used in GridServer for requesting region. // TODO: It is only using currentHandle. - agent.currentRegion = profile.currentAgent.currentRegion; - agent.currentHandle = profile.currentAgent.currentHandle; - agent.currentPos = profile.currentAgent.currentPos; + agent.currentRegion = profile.CurrentAgent.currentRegion; + agent.currentHandle = profile.CurrentAgent.currentHandle; + agent.currentPos = profile.CurrentAgent.currentPos; } } @@ -406,7 +406,7 @@ namespace OpenSim.Framework.UserManagement agent.regionID = LLUUID.Zero; // Fill in later agent.currentRegion = LLUUID.Zero; // Fill in later - profile.currentAgent = agent; + profile.CurrentAgent = agent; } /// @@ -432,9 +432,9 @@ namespace OpenSim.Framework.UserManagement if (userProfile != null) { // This line needs to be in side the above if statement or the UserServer will crash on some logouts. - m_log.Info("[LOGOUT]: " + userProfile.username + " " + userProfile.surname + " from " + regionhandle + "(" + posx + "," + posy + "," + posz + ")"); + m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + posx + "," + posy + "," + posz + ")"); - userAgent = userProfile.currentAgent; + userAgent = userProfile.CurrentAgent; if (userAgent != null) { userAgent.agentOnline = false; @@ -447,7 +447,7 @@ namespace OpenSim.Framework.UserManagement userAgent.currentHandle = regionhandle; userAgent.currentPos = currentPos; - userProfile.currentAgent = userAgent; + userProfile.CurrentAgent = userAgent; CommitAgent(ref userProfile); } @@ -481,11 +481,11 @@ namespace OpenSim.Framework.UserManagement agent.sessionID = new LLUUID(randDataS, 0); // Profile UUID - agent.UUID = profile.UUID; + agent.UUID = profile.Id; // Current position (from Home) - agent.currentHandle = profile.homeRegion; - agent.currentPos = profile.homeLocation; + agent.currentHandle = profile.HomeRegion; + agent.currentPos = profile.HomeLocation; // What time did the user login? agent.loginTime = Util.UnixTimeSinceEpoch(); @@ -495,7 +495,7 @@ namespace OpenSim.Framework.UserManagement agent.regionID = LLUUID.Zero; // Fill in later agent.currentRegion = LLUUID.Zero; // Fill in later - profile.currentAgent = agent; + profile.CurrentAgent = agent; } /// @@ -508,7 +508,7 @@ namespace OpenSim.Framework.UserManagement // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents" // TODO: what is the logic should be? bool ret = false; - ret = AddUserAgent(profile.currentAgent); + ret = AddUserAgent(profile.CurrentAgent); ret = ret & setUserProfile(profile); return ret; } @@ -522,16 +522,16 @@ namespace OpenSim.Framework.UserManagement public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) { UserProfileData user = new UserProfileData(); - user.homeLocation = new LLVector3(128, 128, 100); - user.UUID = LLUUID.Random(); - user.username = firstName; - user.surname = lastName; - user.passwordHash = pass; - user.passwordSalt = String.Empty; - user.created = Util.UnixTimeSinceEpoch(); - user.homeLookAt = new LLVector3(100, 100, 100); - user.homeRegionX = regX; - user.homeRegionY = regY; + user.HomeLocation = new LLVector3(128, 128, 100); + user.Id = LLUUID.Random(); + user.FirstName = firstName; + user.SurName = lastName; + user.PasswordHash = pass; + user.PasswordSalt = String.Empty; + user.Created = Util.UnixTimeSinceEpoch(); + user.HomeLookAt = new LLVector3(100, 100, 100); + user.HomeRegionX = regX; + user.HomeRegionY = regY; foreach (KeyValuePair plugin in _plugins) { @@ -545,14 +545,14 @@ namespace OpenSim.Framework.UserManagement } } - return user.UUID; + return user.Id; } public bool UpdateUserProfileProperties(UserProfileData UserProfile) { - if (null == GetUserProfile(UserProfile.UUID)) + if (null == GetUserProfile(UserProfile.Id)) { - m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.UUID.ToString()); + m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.Id.ToString()); return false; } foreach (KeyValuePair plugin in _plugins) @@ -563,7 +563,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.UUID.ToString() + m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.Id.ToString() + " via " + plugin.Key + "(" + e.ToString() + ")"); return false; } diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs index 6a49f0d..016dc8d 100644 --- a/OpenSim/Framework/UserProfileData.cs +++ b/OpenSim/Framework/UserProfileData.cs @@ -38,37 +38,37 @@ namespace OpenSim.Framework /// /// The ID value for this user /// - public LLUUID UUID; + private LLUUID _id; /// /// The last used Web_login_key /// - public LLUUID webLoginKey; + private LLUUID webLoginKey; /// /// The first component of a users account name /// - public string username; + private string username; /// /// The second component of a users account name /// - public string surname; + private string surname; /// /// A salted hash containing the users password, in the format md5(md5(password) + ":" + salt) /// /// This is double MD5'd because the client sends an unsalted MD5 to the loginserver - public string passwordHash; + private string passwordHash; /// /// The salt used for the users hash, should be 32 bytes or longer /// - public string passwordSalt; + private string passwordSalt; /// /// The regionhandle of the users preffered home region. If multiple sims occupy the same spot, the grid may decide which region the user logs into /// - public ulong homeRegion + public ulong HomeRegion { get { return Helpers.UIntsToLong((homeRegionX * (uint)Constants.RegionSize), (homeRegionY * (uint)Constants.RegionSize)); } set @@ -78,74 +78,272 @@ namespace OpenSim.Framework } } - public uint homeRegionX; - public uint homeRegionY; + public LLUUID Id { + get { + return _id; + } + set { + _id = value; + } + } + + public LLUUID WebLoginKey { + get { + return webLoginKey; + } + set { + webLoginKey = value; + } + } + + public string FirstName { + get { + return username; + } + set { + username = value; + } + } + + public string SurName { + get { + return surname; + } + set { + surname = value; + } + } + + public string PasswordHash { + get { + return passwordHash; + } + set { + passwordHash = value; + } + } + + public string PasswordSalt { + get { + return passwordSalt; + } + set { + passwordSalt = value; + } + } + + public uint HomeRegionX { + get { + return homeRegionX; + } + set { + homeRegionX = value; + } + } + + public uint HomeRegionY { + get { + return homeRegionY; + } + set { + homeRegionY = value; + } + } + + public LLVector3 HomeLocation { + get { + return homeLocation; + } + set { + homeLocation = value; + } + } + + public LLVector3 HomeLookAt { + get { + return homeLookAt; + } + set { + homeLookAt = value; + } + } + + public int Created { + get { + return created; + } + set { + created = value; + } + } + + public int LastLogin { + get { + return lastLogin; + } + set { + lastLogin = value; + } + } + + public LLUUID RootInventoryFolderID { + get { + return rootInventoryFolderID; + } + set { + rootInventoryFolderID = value; + } + } + + public string UserInventoryURI { + get { + return userInventoryURI; + } + set { + userInventoryURI = value; + } + } + + public string UserAssetURI { + get { + return userAssetURI; + } + set { + userAssetURI = value; + } + } + + public uint ProfileCanDoMask { + get { + return profileCanDoMask; + } + set { + profileCanDoMask = value; + } + } + + public uint ProfileWantDoMask { + get { + return profileWantDoMask; + } + set { + profileWantDoMask = value; + } + } + + public string ProfileAboutText { + get { + return profileAboutText; + } + set { + profileAboutText = value; + } + } + + public string ProfileFirstText { + get { + return profileFirstText; + } + set { + profileFirstText = value; + } + } + + public LLUUID ProfileImage { + get { + return profileImage; + } + set { + profileImage = value; + } + } + + public LLUUID ProfileFirstImage { + get { + return profileFirstImage; + } + set { + profileFirstImage = value; + } + } + + public UserAgentData CurrentAgent { + get { + return currentAgent; + } + set { + currentAgent = value; + } + } + + private uint homeRegionX; + private uint homeRegionY; /// /// The coordinates inside the region of the home location /// - public LLVector3 homeLocation; + private LLVector3 homeLocation; /// /// Where the user will be looking when they rez. /// - public LLVector3 homeLookAt; + private LLVector3 homeLookAt; /// /// A UNIX Timestamp (seconds since epoch) for the users creation /// - public int created; + private int created; /// /// A UNIX Timestamp for the users last login date / time /// - public int lastLogin; + private int lastLogin; - public LLUUID rootInventoryFolderID; + private LLUUID rootInventoryFolderID; /// /// A URI to the users inventory server, used for foreigners and large grids /// - public string userInventoryURI = String.Empty; + private string userInventoryURI = String.Empty; /// /// A URI to the users asset server, used for foreigners and large grids. /// - public string userAssetURI = String.Empty; + private string userAssetURI = String.Empty; /// /// A uint mask containing the "I can do" fields of the users profile /// - public uint profileCanDoMask; + private uint profileCanDoMask; /// /// A uint mask containing the "I want to do" part of the users profile /// - public uint profileWantDoMask; // Profile window "I want to" mask + private uint profileWantDoMask; // Profile window "I want to" mask /// /// The about text listed in a users profile. /// - public string profileAboutText = String.Empty; + private string profileAboutText = String.Empty; /// /// The first life about text listed in a users profile /// - public string profileFirstText = String.Empty; + private string profileFirstText = String.Empty; /// /// The profile image for an avatar stored on the asset server /// - public LLUUID profileImage; + private LLUUID profileImage; /// /// The profile image for the users first life tab /// - public LLUUID profileFirstImage; + private LLUUID profileFirstImage; /// /// The users last registered agent (filled in on the user server) /// - public UserAgentData currentAgent; + private UserAgentData currentAgent; } } -- cgit v1.1