From 41440e184b1c12f1b83d894b2cd5b7b801b4ca38 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 19 Aug 2008 18:34:46 +0000 Subject: Attachment persistence (Mantis #1711) Change user server to handle attachment assets record properly. Ensure that attachments are not re-rezzed on region crossing. Persistence will NOT WORK with earliser UGAI!! Change region server to match. --- OpenSim/Data/MSSQL/MSSQLUserData.cs | 35 ++------------ OpenSim/Data/MySQL/MySQLUserData.cs | 39 ++++------------ OpenSim/Data/NHibernate/NHibernateUserData.cs | 13 +----- OpenSim/Data/SQLite/SQLiteUserData.cs | 37 ++------------- OpenSim/Data/UserDataBase.cs | 4 +- OpenSim/Framework/Communications/LoginService.cs | 6 +++ .../Framework/Communications/UserManagerBase.cs | 53 +++------------------- OpenSim/Framework/IUserData.cs | 5 +- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 29 ++++++++---- 9 files changed, 52 insertions(+), 169 deletions(-) diff --git a/OpenSim/Data/MSSQL/MSSQLUserData.cs b/OpenSim/Data/MSSQL/MSSQLUserData.cs index e63a9fe..cfe5f50 100644 --- a/OpenSim/Data/MSSQL/MSSQLUserData.cs +++ b/OpenSim/Data/MSSQL/MSSQLUserData.cs @@ -893,37 +893,6 @@ namespace OpenSim.Data.MSSQL } /// - /// add an attachement to an avatar - /// - /// the avatar UUID - /// the item UUID - override public void AddAttachment(LLUUID user, LLUUID item) - { - // TBI? - } - - /// - /// Remove an attachement from an avatar - /// - /// the avatar UUID - /// the item UUID - override public void RemoveAttachment(LLUUID user, LLUUID item) - { - // TBI? - } - - /// - /// get (fetch?) all attached item to an avatar - /// - /// the avatar UUID - /// List of attached item - /// return an empty list - override public List GetAttachments(LLUUID user) - { - return new List(); - } - - /// /// Database provider name /// /// Provider name @@ -948,5 +917,9 @@ namespace OpenSim.Data.MSSQL public void runQuery(string query) { } + + override public void ResetAttachments(LLUUID userID) + { + } } } diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 9a056b2..caae677 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -779,36 +779,6 @@ namespace OpenSim.Data.MySQL } /// - /// Adds an attachment item to a user - /// - /// the user UUID - /// the item UUID - override public void AddAttachment(LLUUID user, LLUUID item) - { - return; - } - - /// - /// Removes an attachment from a user - /// - /// the user UUID - /// the item UUID - override public void RemoveAttachment(LLUUID user, LLUUID item) - { - return; - } - - /// - /// Get the list of item attached to a user - /// - /// the user UUID - /// UUID list of attached item - override public List GetAttachments(LLUUID user) - { - return new List(); - } - - /// /// Database provider name /// /// Provider name @@ -845,5 +815,14 @@ namespace OpenSim.Data.MySQL { database.writeAttachments(agentID, data); } + + override public void ResetAttachments(LLUUID userID) + { + MySqlCommand cmd = (MySqlCommand) (database.Connection.CreateCommand()); + cmd.CommandText = "update avatarattachments set asset = '00000000-0000-0000-0000-000000000000' where UUID = ?uuid"; + cmd.Parameters.AddWithValue("?uuid", userID.ToString()); + + cmd.ExecuteNonQuery(); + } } } diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs index c776474..8435762 100644 --- a/OpenSim/Data/NHibernate/NHibernateUserData.cs +++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs @@ -303,19 +303,8 @@ namespace OpenSim.Data.NHibernate } } - override public void AddAttachment(LLUUID user, LLUUID item) + public override void ResetAttachments(LLUUID userID) { - return; - } - - override public void RemoveAttachment(LLUUID user, LLUUID item) - { - return; - } - - override public List GetAttachments(LLUUID user) - { - return new List(); } public override string Name { diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs index 08a97f09..beff2a4 100644 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserData.cs @@ -583,39 +583,6 @@ namespace OpenSim.Data.SQLite } /// - /// Add an attachment item to an avatar - /// - /// the user UUID - /// the item UUID - /// DO NOTHING ? - override public void AddAttachment(LLUUID user, LLUUID item) - { - return; - } - - /// - /// Remove an attachement item from an avatar - /// - /// the user UUID - /// the item UUID - /// DO NOTHING ? - override public void RemoveAttachment(LLUUID user, LLUUID item) - { - return; - } - - /// - /// Get list of attached item - /// - /// the user UUID - /// List of attached item - /// DO NOTHING ? - override public List GetAttachments(LLUUID user) - { - return new List(); - } - - /// /// Returns the name of the storage provider /// /// Storage provider name @@ -1040,5 +1007,9 @@ namespace OpenSim.Data.SQLite // return true; } + + override public void ResetAttachments(LLUUID userID) + { + } } } diff --git a/OpenSim/Data/UserDataBase.cs b/OpenSim/Data/UserDataBase.cs index b984c10..e57c8f8 100644 --- a/OpenSim/Data/UserDataBase.cs +++ b/OpenSim/Data/UserDataBase.cs @@ -72,9 +72,7 @@ namespace OpenSim.Data // aplist[user] = appearance; // m_log.Info("[APPEARANCE] Setting appearance for " + user.ToString() + appearance.ToString()); // } - public abstract void AddAttachment(LLUUID user, LLUUID item); - public abstract void RemoveAttachment(LLUUID user, LLUUID item); - public abstract List GetAttachments(LLUUID user); + public abstract void ResetAttachments(LLUUID userID); public abstract string Version {get;} public abstract string Name {get;} diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 40064d3..73fba1e 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -220,6 +220,9 @@ namespace OpenSim.Framework.Communications } // Otherwise... // Create a new agent session + + m_userManager.ResetAttachments(userProfile.ID); + CreateAgent(userProfile, request); try @@ -390,6 +393,9 @@ namespace OpenSim.Framework.Communications // Otherwise... // Create a new agent session + + m_userManager.ResetAttachments(userProfile.ID); + CreateAgent(userProfile, request); try diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index feeb666..ef900ea 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -83,6 +83,13 @@ namespace OpenSim.Framework.Communications return null; } + public void ResetAttachments(LLUUID userID) + { + foreach (IUserDataPlugin plugin in _plugins) + { + plugin.ResetAttachments(userID); + } + } public UserAgentData GetAgentByUUID(LLUUID userId) { foreach (IUserDataPlugin plugin in _plugins) @@ -639,51 +646,5 @@ namespace OpenSim.Framework.Communications } } } - - public void AddAttachment(LLUUID user, LLUUID item) - { - foreach (IUserDataPlugin plugin in _plugins) - { - try - { - plugin.AddAttachment(user, item); - } - catch (Exception e) - { - m_log.InfoFormat("[USERSTORAGE]: Unable to attach {3} => {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString(), item.ToString()); - } - } - } - - public void RemoveAttachment(LLUUID user, LLUUID item) - { - foreach (IUserDataPlugin plugin in _plugins) - { - try - { - plugin.RemoveAttachment(user, item); - } - catch (Exception e) - { - m_log.InfoFormat("[USERSTORAGE]: Unable to remove attachment {3} => {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString(), item.ToString()); - } - } - } - - public List GetAttachments(LLUUID user) - { - foreach (IUserDataPlugin plugin in _plugins) - { - try - { - return plugin.GetAttachments(user); - } - catch (Exception e) - { - m_log.InfoFormat("[USERSTORAGE]: Unable to get attachments for {0} via {1} ({2})", user.ToString(), plugin.Name, e.ToString()); - } - } - return new List(); - } } } diff --git a/OpenSim/Framework/IUserData.cs b/OpenSim/Framework/IUserData.cs index f74c0db..ffde002 100644 --- a/OpenSim/Framework/IUserData.cs +++ b/OpenSim/Framework/IUserData.cs @@ -165,10 +165,7 @@ namespace OpenSim.Framework void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance); - - void AddAttachment(LLUUID user, LLUUID item); - void RemoveAttachment(LLUUID user, LLUUID item); - List GetAttachments(LLUUID user); + void ResetAttachments(LLUUID userID); } public class UserDataInitialiser : PluginInitialiserBase diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 706fd61..4bc5d34 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -2880,24 +2880,33 @@ namespace OpenSim.Region.Environment.Scenes if (attachpoint == 0) return; + LLUUID asset = m_appearance.GetAttachedAsset(attachpoint); + if (asset == LLUUID.Zero) // We have just logged in + { + m_log.InfoFormat("[ATTACHMENT] Rez attachment {0}", + itemID.ToString()); + + // Rez from inventory + m_scene.RezSingleAttachment(ControllingClient, itemID, + (uint)attachpoint, 0, 0); + return; + } + SceneObjectPart att = m_scene.GetSceneObjectPart(m_appearance.GetAttachedAsset(attachpoint)); - // If this is null, then we have just rezzed in. Non null means - // we're crossing + // If this is null, then the asset has not yet appeared in world + // so we revisit this when it does // if (att != null) { - System.Console.WriteLine("Attach from world {0}", itemID.ToString()); + m_log.InfoFormat("[ATTACHEMENT] Attach from world {0}", + itemID.ToString()); + // Attach from world if (att.ParentGroup != null) - m_scene.RezSingleAttachment(att.ParentGroup, ControllingClient, itemID, (uint)attachpoint, 0, 0); - } - else - { - System.Console.WriteLine("Rez attachment {0}", itemID.ToString()); - // Rez from inventory - m_scene.RezSingleAttachment(ControllingClient, itemID, (uint)attachpoint, 0, 0); + m_scene.RezSingleAttachment(att.ParentGroup, + ControllingClient, itemID, (uint)attachpoint, 0, 0); } } } -- cgit v1.1