From 6f71d5c2c65802bd6b0196e825cabbfe8d34fe9e Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 5 Jun 2015 08:52:25 -0600 Subject: Support for Linden AgentPreferences capability and friends (UpdateAgentLanguage and UpdateAgentInformation) and Mantis #7157 Signed-off-by: Diva Canto --- OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs | 73 +++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs (limited to 'OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs') diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs new file mode 100644 index 0000000..0ea2f64 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2015, Cinder Roxley + * + * Permission is hereby granted, free of charge, to any person or organization + * obtaining a copy of the software and accompanying documentation covered by + * this license (the "Software") to use, reproduce, display, distribute, + * execute, and transmit the Software, and to prepare derivative works of the + * Software, and to permit third-parties to whom the Software is furnished to + * do so, all subject to the following: + * + * The copyright notices in the Software and this entire statement, including + * the above license grant, this restriction and the following disclaimer, + * must be included in all copies of the Software, in whole or in part, and + * all derivative works of the Software, unless such copies or derivative + * works are solely in the form of machine-executable object code generated by + * a source language processor. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT + * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE + * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using OpenMetaverse; +using OpenSim.Framework; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + public class MySQLAgentPreferencesData : MySQLGenericTableHandler, IAgentPreferencesData + { + public MySQLAgentPreferencesData(string connectionString, string realm) + : base(connectionString, realm, "AgentPrefs") + { + } + + public AgentPreferencesData GetPrefs(UUID agentID) + { + AgentPreferencesData[] ret = Get("PrincipalID", agentID.ToString()); + + if (ret.Length == 0) + return null; + + return ret[0]; + } + + public void StorePrefs(AgentPreferencesData data) + { + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText = String.Format("replace into `{0}` (`PrincipalID`, `AccessPrefs`, `HoverHeight`, `Language`, `LanguageIsPublic`, `PermEveryone`, `PermGroup`, `PermNextOwner`) VALUES (?Principal, ?AP, ?HH, ?Lang, ?LIP, ?PE, ?PG, ?PNO)", m_Realm); + cmd.Parameters.AddWithValue("?Principal", data.PrincipalID.ToString()); + cmd.Parameters.AddWithValue("?AP", data.AccessPrefs); + cmd.Parameters.AddWithValue("?HH", data.HoverHeight); + cmd.Parameters.AddWithValue("?Lang", data.Language); + cmd.Parameters.AddWithValue("?LIP", data.LanguageIsPublic); + cmd.Parameters.AddWithValue("?PE", data.PermEveryone); + cmd.Parameters.AddWithValue("?PG", data.PermGroup); + cmd.Parameters.AddWithValue("?PNO", data.PermNextOwner); + + ExecuteNonQuery(cmd); + } + } + } +} + -- cgit v1.1 From c1ddb7f05e337a65c9505ea714879038b9a215d4 Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 5 Jun 2015 18:13:42 -0600 Subject: Relicense AgentPreferences files to BSD and OpenSimulator Signed-off-by: Diva Canto --- OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs | 47 +++++++++++++------------ 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs') diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs index 0ea2f64..cd9004a 100644 --- a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs +++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs @@ -1,27 +1,28 @@ /* - * Copyright (C) 2015, Cinder Roxley - * - * Permission is hereby granted, free of charge, to any person or organization - * obtaining a copy of the software and accompanying documentation covered by - * this license (the "Software") to use, reproduce, display, distribute, - * execute, and transmit the Software, and to prepare derivative works of the - * Software, and to permit third-parties to whom the Software is furnished to - * do so, all subject to the following: - * - * The copyright notices in the Software and this entire statement, including - * the above license grant, this restriction and the following disclaimer, - * must be included in all copies of the Software, in whole or in part, and - * all derivative works of the Software, unless such copies or derivative - * works are solely in the form of machine-executable object code generated by - * a source language processor. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT - * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE - * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * 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; -- cgit v1.1 From 0fa94f222df8ed7f308730c3692bf2a774138718 Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 12 Jun 2015 18:48:07 -0600 Subject: Refactor AgentPreferences so that database operations happen centrally. the opensim way. Signed-off-by: Diva Canto --- OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs') diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs index cd9004a..bf188ee 100644 --- a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs +++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs @@ -52,22 +52,9 @@ namespace OpenSim.Data.MySQL return ret[0]; } - public void StorePrefs(AgentPreferencesData data) + public void Store(AgentPreferencesData data) { - using (MySqlCommand cmd = new MySqlCommand()) - { - cmd.CommandText = String.Format("replace into `{0}` (`PrincipalID`, `AccessPrefs`, `HoverHeight`, `Language`, `LanguageIsPublic`, `PermEveryone`, `PermGroup`, `PermNextOwner`) VALUES (?Principal, ?AP, ?HH, ?Lang, ?LIP, ?PE, ?PG, ?PNO)", m_Realm); - cmd.Parameters.AddWithValue("?Principal", data.PrincipalID.ToString()); - cmd.Parameters.AddWithValue("?AP", data.AccessPrefs); - cmd.Parameters.AddWithValue("?HH", data.HoverHeight); - cmd.Parameters.AddWithValue("?Lang", data.Language); - cmd.Parameters.AddWithValue("?LIP", data.LanguageIsPublic); - cmd.Parameters.AddWithValue("?PE", data.PermEveryone); - cmd.Parameters.AddWithValue("?PG", data.PermGroup); - cmd.Parameters.AddWithValue("?PNO", data.PermNextOwner); - - ExecuteNonQuery(cmd); - } + base.Store(data); } } } -- cgit v1.1 From 3853904b80c659ae94db780f4de713d639200e50 Mon Sep 17 00:00:00 2001 From: Cinder Date: Sun, 14 Jun 2015 08:45:22 -0600 Subject: Quell three new warnings I introduced with AgentPrefsData, return an empty llsd map instead of an empty llsd block when no AgentPrefs service is available to try and appease Firestorm Signed-off-by: Diva Canto --- OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs') diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs index bf188ee..6be205e 100644 --- a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs +++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs @@ -52,9 +52,9 @@ namespace OpenSim.Data.MySQL return ret[0]; } - public void Store(AgentPreferencesData data) + public override bool Store(AgentPreferencesData data) { - base.Store(data); + return base.Store(data); } } } -- cgit v1.1 From 496f35b4e85b2145138de0924add1c0be7be5320 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 14 Jun 2015 08:04:25 -0700 Subject: Removing the Store methods in the DB layer of AgentPreferences, as they were simply calling the base ones. --- OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs') diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs index 6be205e..ed0ab98 100644 --- a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs +++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs @@ -51,11 +51,6 @@ namespace OpenSim.Data.MySQL return ret[0]; } - - public override bool Store(AgentPreferencesData data) - { - return base.Store(data); - } } } -- cgit v1.1