diff --git a/OpenSim/Framework/Communications/IUserServices.cs b/OpenSim/Framework/Communications/IUserServices.cs index cd97b52394..40a318296d 100644 --- a/OpenSim/Framework/Communications/IUserServices.cs +++ b/OpenSim/Framework/Communications/IUserServices.cs @@ -35,6 +35,7 @@ namespace OpenSim.Framework.Communications UserProfileData GetUserProfile(string firstName, string lastName); UserProfileData GetUserProfile(string name); UserProfileData GetUserProfile(LLUUID avatarID); + void clearUserAgent(LLUUID avatarID); UserProfileData SetupMasterUser(string firstName, string lastName); UserProfileData SetupMasterUser(string firstName, string lastName, string password); diff --git a/OpenSim/Framework/Data.DB4o/DB4oManager.cs b/OpenSim/Framework/Data.DB4o/DB4oManager.cs index 43f9095a8a..0e32938b6a 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oManager.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oManager.cs @@ -129,26 +129,31 @@ namespace OpenSim.Framework.Data.DB4o } /// - /// Adds a new profile to the database (Warning: Probably slow.) + /// Adds or updates a record to the user database. Do this when changes are needed + /// in the user profile that need to be persistant. + /// + /// TODO: the logic here is not ACID, the local cache will be + /// updated even if the persistant data is not. This may lead + /// to unexpected results. /// - /// The profile to add - /// Successful? - public bool AddRow(UserProfileData row) + /// The profile to update + /// true on success, false on fail to persist to db + public bool UpdateRecord(UserProfileData record) { - if (userProfiles.ContainsKey(row.UUID)) + if (userProfiles.ContainsKey(record.UUID)) { - userProfiles[row.UUID] = row; + userProfiles[record.UUID] = record; } else { - userProfiles.Add(row.UUID, row); + userProfiles.Add(record.UUID, record); } try { IObjectContainer database; database = Db4oFactory.OpenFile(dbfl); - database.Set(row); + database.Set(record); database.Close(); return true; } @@ -157,7 +162,5 @@ namespace OpenSim.Framework.Data.DB4o return false; } } - - } } diff --git a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs index 831b198007..88caeb828e 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs @@ -139,13 +139,30 @@ namespace OpenSim.Framework.Data.DB4o { try { - manager.AddRow(user); + manager.UpdateRecord(user); } catch (Exception e) { Console.WriteLine(e.ToString()); } } + + /// + /// Creates a new user profile + /// + /// The profile to add to the database + /// True on success, false on error + public bool updateUserProfile(UserProfileData user) + { + try { + return manager.UpdateRecord(user); + } catch (Exception e) { + Console.WriteLine(e.ToString()); + return false; + } + } + + /// /// Creates a new user agent diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 66ea4652d5..e301eb8ce9 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs @@ -224,6 +224,13 @@ namespace OpenSim.Framework.Data.MySQL { // Do nothing. } + + + public bool updateUserProfile(UserProfileData user) + { + return true; + // TODO: implement + } /// /// Performs a money transfer request between two accounts diff --git a/OpenSim/Framework/Data/UserData.cs b/OpenSim/Framework/Data/UserData.cs index d849e126ce..cf8ec7b084 100644 --- a/OpenSim/Framework/Data/UserData.cs +++ b/OpenSim/Framework/Data/UserData.cs @@ -84,6 +84,12 @@ namespace OpenSim.Framework.Data /// UserProfile to add void addNewUserProfile(UserProfileData user); + /// + /// Updates an existing user profile + /// + /// UserProfile to update + bool updateUserProfile(UserProfileData user); + /// /// Adds a new agent to the database /// diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs index bc923b66cb..61b5df48c3 100644 --- a/OpenSim/Framework/UserManager/UserManagerBase.cs +++ b/OpenSim/Framework/UserManager/UserManagerBase.cs @@ -155,6 +155,28 @@ namespace OpenSim.Framework.UserManagement return null; } + + /// + /// Set's user profile from object + /// + /// First name + /// Last name + /// A user profile + public bool setUserProfile(UserProfileData data) + { + foreach (KeyValuePair plugin in _plugins) + { + try { + plugin.Value.updateUserProfile(data); + return true; + } catch (Exception e) { + MainLog.Instance.Verbose( "Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return false; + } + #endregion #region Get UserAgent @@ -202,6 +224,15 @@ namespace OpenSim.Framework.UserManagement return null; } + // TODO: document + public void clearUserAgent(LLUUID agentID) + { + UserProfileData profile = getUserProfile(agentID); + profile.currentAgent = null; + setUserProfile(profile); + } + + /// /// Loads a user agent by name (not called directly) /// diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index cd9c4fe15a..0459e8048a 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -86,6 +86,11 @@ namespace OpenSim.Region.Communications.OGS1 return null; } + public void clearUserAgent(LLUUID avatarID) + { + // TODO: implement + } + public UserProfileData SetupMasterUser(string firstName, string lastName) { return SetupMasterUser(firstName, lastName, ""); diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 70aead3156..dbc6f92186 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -674,7 +674,9 @@ namespace OpenSim.Region.Environment.Scenes } } // TODO: Add the removal from physics ? - + + // Remove client agent from profile, so new logins will work + commsManager.UserServer.clearUserAgent(agentID); return; }