From 3c18c0189a5aa0178f874273f1e25c661651ced4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 4 Jan 2010 00:56:39 +0000 Subject: Avatar appearance skeleton --- OpenSim/Services/AvatarService/AvatarService.cs | 79 ++++++++++++++++++++ .../Services/AvatarService/AvatarServiceBase.cs | 84 ++++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 OpenSim/Services/AvatarService/AvatarService.cs create mode 100644 OpenSim/Services/AvatarService/AvatarServiceBase.cs (limited to 'OpenSim/Services/AvatarService') diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs new file mode 100644 index 0000000..1f5b257 --- /dev/null +++ b/OpenSim/Services/AvatarService/AvatarService.cs @@ -0,0 +1,79 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Reflection; +using Nini.Config; +using log4net; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Data; +using OpenSim.Services.Interfaces; +using OpenMetaverse; + +namespace OpenSim.Services.AvatarService +{ + public class AvatarService : AvatarServiceBase, IAvatarService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + public AvatarService(IConfigSource config) + : base(config) + { + m_log.Debug("[AVATAR SERVICE]: Starting avatar service"); + } + + public AvatarData GetAvatar(UUID userID) + { + return null; + } + + public bool SetAvatar(UUID userID, AvatarData avatar) + { + return false; + } + + public bool ResetAvatar(UUID userID) + { + return false; + } + + public bool SetItems(UUID userID, string[] names, string[] values) + { + return false; + } + + public bool RemoveItems(UUID userID, string[] names) + { + return false; + } + } +} diff --git a/OpenSim/Services/AvatarService/AvatarServiceBase.cs b/OpenSim/Services/AvatarService/AvatarServiceBase.cs new file mode 100644 index 0000000..ab9d7cd --- /dev/null +++ b/OpenSim/Services/AvatarService/AvatarServiceBase.cs @@ -0,0 +1,84 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Data; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Base; + +namespace OpenSim.Services.AvatarService +{ + public class AvatarServiceBase : ServiceBase + { + protected IAvatarData m_Database = null; + + public AvatarServiceBase(IConfigSource config) + : base(config) + { + string dllName = String.Empty; + string connString = String.Empty; + string realm = "Avatars"; + + // + // Try reading the [DatabaseService] section, if it exists + // + IConfig dbConfig = config.Configs["DatabaseService"]; + if (dbConfig != null) + { + if (dllName == String.Empty) + dllName = dbConfig.GetString("StorageProvider", String.Empty); + if (connString == String.Empty) + connString = dbConfig.GetString("ConnectionString", String.Empty); + } + + // + // [AvatarService] section overrides [DatabaseService], if it exists + // + IConfig presenceConfig = config.Configs["AvatarService"]; + if (presenceConfig != null) + { + dllName = presenceConfig.GetString("StorageProvider", dllName); + connString = presenceConfig.GetString("ConnectionString", connString); + realm = presenceConfig.GetString("Realm", realm); + } + + // + // We tried, but this doesn't exist. We can't proceed. + // + if (dllName.Equals(String.Empty)) + throw new Exception("No StorageProvider configured"); + + m_Database = LoadPlugin(dllName, new Object[] { connString, realm }); + if (m_Database == null) + throw new Exception("Could not find a storage interface in the given module " + dllName); + + } + } +} -- cgit v1.1 From 791c6188fd3b0347299c2bb0e88df90cc0747008 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 4 Jan 2010 02:07:31 +0000 Subject: Some work on avatar service. Retrieval and storage done --- OpenSim/Services/AvatarService/AvatarService.cs | 32 +++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'OpenSim/Services/AvatarService') diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs index 1f5b257..ffcdcc5 100644 --- a/OpenSim/Services/AvatarService/AvatarService.cs +++ b/OpenSim/Services/AvatarService/AvatarService.cs @@ -51,27 +51,45 @@ namespace OpenSim.Services.AvatarService m_log.Debug("[AVATAR SERVICE]: Starting avatar service"); } - public AvatarData GetAvatar(UUID userID) + public AvatarData GetAvatar(UUID principalID) { - return null; + + AvatarBaseData[] av = m_Database.Get("PrincipalID", principalID.ToString()); + if (av.Length == 0) + return null; + + AvatarData ret = new AvatarData(); + ret.AvatarType = Convert.ToInt32(av[0].Data["AvatarType"]); + + av[0].Data.Remove("AvatarType"); + + ret.Data = av[0].Data; + + return ret; } - public bool SetAvatar(UUID userID, AvatarData avatar) + public bool SetAvatar(UUID principalID, AvatarData avatar) { - return false; + AvatarBaseData av = new AvatarBaseData(); + + av.PrincipalID = principalID; + av.Data = avatar.Data; + av.Data["AvatarType"] = avatar.AvatarType.ToString(); + + return m_Database.Store(av); } - public bool ResetAvatar(UUID userID) + public bool ResetAvatar(UUID principalID) { return false; } - public bool SetItems(UUID userID, string[] names, string[] values) + public bool SetItems(UUID principalID, string[] names, string[] values) { return false; } - public bool RemoveItems(UUID userID, string[] names) + public bool RemoveItems(UUID principalID, string[] names) { return false; } -- cgit v1.1 From 6e8d94685d4e5784398ff656fdab169310dc219a Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 4 Jan 2010 02:52:43 +0000 Subject: AvatarStore. Untested, but complete --- OpenSim/Services/AvatarService/AvatarService.cs | 63 ++++++++++++++++++++----- 1 file changed, 52 insertions(+), 11 deletions(-) (limited to 'OpenSim/Services/AvatarService') diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs index ffcdcc5..0b351a2 100644 --- a/OpenSim/Services/AvatarService/AvatarService.cs +++ b/OpenSim/Services/AvatarService/AvatarService.cs @@ -53,45 +53,86 @@ namespace OpenSim.Services.AvatarService public AvatarData GetAvatar(UUID principalID) { - AvatarBaseData[] av = m_Database.Get("PrincipalID", principalID.ToString()); if (av.Length == 0) return null; AvatarData ret = new AvatarData(); - ret.AvatarType = Convert.ToInt32(av[0].Data["AvatarType"]); + ret.Data = new Dictionary(); - av[0].Data.Remove("AvatarType"); - - ret.Data = av[0].Data; + foreach (AvatarBaseData b in av) + { + if (b.Data["Name"] == "AvatarType") + ret.AvatarType = Convert.ToInt32(b.Data["Value"]); + else + ret.Data[b.Data["Name"]] = b.Data["Value"]; + } return ret; } public bool SetAvatar(UUID principalID, AvatarData avatar) { + m_Database.Delete("PrincipalID", principalID.ToString()); + AvatarBaseData av = new AvatarBaseData(); + av.Data = new Dictionary(); av.PrincipalID = principalID; - av.Data = avatar.Data; - av.Data["AvatarType"] = avatar.AvatarType.ToString(); + av.Data["Name"] = "AvatarType"; + av.Data["Value"] = avatar.AvatarType.ToString(); + + if (!m_Database.Store(av)) + return false; - return m_Database.Store(av); + foreach (KeyValuePair kvp in avatar.Data) + { + av.Data["Name"] = kvp.Key; + av.Data["Value"] = kvp.Value; + + if (!m_Database.Store(av)) + { + m_Database.Delete("PrincipalID", principalID.ToString()); + return false; + } + } + + return true; } public bool ResetAvatar(UUID principalID) { - return false; + return m_Database.Delete("PrincipalID", principalID.ToString()); } public bool SetItems(UUID principalID, string[] names, string[] values) { - return false; + AvatarBaseData av = new AvatarBaseData(); + av.Data = new Dictionary(); + av.PrincipalID = principalID; + + if (names.Length != values.Length) + return false; + + for (int i = 0 ; i < names.Length ; i++) + { + av.Data["Name"] = names[i]; + av.Data["Value"] = values[i]; + + if (!m_Database.Store(av)) + return false; + } + + return true; } public bool RemoveItems(UUID principalID, string[] names) { - return false; + foreach (string name in names) + { + m_Database.Delete(principalID, name); + } + return true; } } } -- cgit v1.1 From 77e43f480154b0a950d9d5f54df5c225fc64e77a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 11 Jan 2010 17:30:05 -0800 Subject: Fixed a couple of bugs with Appearance. Appearance is all good now. --- OpenSim/Services/AvatarService/AvatarService.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Services/AvatarService') diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs index 0b351a2..19e662c 100644 --- a/OpenSim/Services/AvatarService/AvatarService.cs +++ b/OpenSim/Services/AvatarService/AvatarService.cs @@ -73,6 +73,12 @@ namespace OpenSim.Services.AvatarService public bool SetAvatar(UUID principalID, AvatarData avatar) { + int count = 0; + foreach (KeyValuePair kvp in avatar.Data) + if (kvp.Key.StartsWith("_")) + count++; + + m_log.DebugFormat("[AVATAR SERVICE]: SetAvatar for {0}, attachs={1}", principalID, count); m_Database.Delete("PrincipalID", principalID.ToString()); AvatarBaseData av = new AvatarBaseData(); -- cgit v1.1