From 00b88f844a8428006d203eefb645e69e9e0c3ef9 Mon Sep 17 00:00:00 2001 From: Fernando Oliveira Date: Thu, 4 Jul 2013 15:58:36 -0300 Subject: [PATCH 1/5] sinc --- syncdiva.bat | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 syncdiva.bat diff --git a/syncdiva.bat b/syncdiva.bat new file mode 100644 index 0000000000..40285f80be --- /dev/null +++ b/syncdiva.bat @@ -0,0 +1,6 @@ +rem git remote add https://github.com/diva/diva-distribution.git + +git fetch upstream + +git merge upstream/master + From b315e1c7cc49f36f46f52cba5f02ea39bab06e60 Mon Sep 17 00:00:00 2001 From: Fernando Oliveira Date: Tue, 8 Oct 2013 13:23:45 -0300 Subject: [PATCH 2/5] pause on batch --- syncdiva.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/syncdiva.bat b/syncdiva.bat index 40285f80be..c4ffefc837 100644 --- a/syncdiva.bat +++ b/syncdiva.bat @@ -4,3 +4,4 @@ git fetch upstream git merge upstream/master +pause ok From bd223e3c480c9d245965ec12268f33f906c8f9df Mon Sep 17 00:00:00 2001 From: Fernando Oliveira Date: Tue, 8 Oct 2013 17:46:06 -0300 Subject: [PATCH 3/5] Created new project PGSQL for PostgreSQL database --- addon-modules/0Data/PGSQL/PGSQLAssetData.cs | 49 +++++++++ .../0Data/PGSQL/PGSQLAuthenticationData.cs | 53 +++++++++ addon-modules/0Data/PGSQL/PGSQLAvatarData.cs | 54 +++++++++ addon-modules/0Data/PGSQL/PGSQLEstateData.cs | 51 +++++++++ addon-modules/0Data/PGSQL/PGSQLFriendsData.cs | 50 +++++++++ .../0Data/PGSQL/PGSQLGenericTableHandler.cs | 52 +++++++++ .../0Data/PGSQL/PGSQLGridUserData.cs | 99 +++++++++++++++++ addon-modules/0Data/PGSQL/PGSQLGroupsData.cs | 46 ++++++++ .../0Data/PGSQL/PGSQLHGTravelData.cs | 52 +++++++++ .../0Data/PGSQL/PGSQLInventoryStore.cs | 41 +++++++ .../0Data/PGSQL/PGSQLOfflineIMData.cs | 50 +++++++++ .../0Data/PGSQL/PGSQLPresenceData.cs | 53 +++++++++ addon-modules/0Data/PGSQL/PGSQLRegionData.cs | 76 +++++++++++++ .../0Data/PGSQL/PGSQLSimulationData.cs | 55 +++++++++ .../0Data/PGSQL/PGSQLUserAccountData.cs | 104 ++++++++++++++++++ .../0Data/PGSQL/PGSQLUserProfilesData.cs | 50 +++++++++ .../0Data/PGSQL/PGSQLXInventoryData.cs | 46 ++++++++ .../0Data/PGSQL/Properties/AssemblyInfo.cs | 33 ++++++ .../PGSQL/Resources/GridUserStore.migrations | 25 +++++ addon-modules/0Data/prebuild.PGSQL.xml | 43 ++++++++ 20 files changed, 1082 insertions(+) create mode 100644 addon-modules/0Data/PGSQL/PGSQLAssetData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLAuthenticationData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLAvatarData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLEstateData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLFriendsData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLGenericTableHandler.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLGridUserData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLGroupsData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLHGTravelData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLInventoryStore.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLOfflineIMData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLPresenceData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLRegionData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLSimulationData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLUserAccountData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLUserProfilesData.cs create mode 100644 addon-modules/0Data/PGSQL/PGSQLXInventoryData.cs create mode 100644 addon-modules/0Data/PGSQL/Properties/AssemblyInfo.cs create mode 100644 addon-modules/0Data/PGSQL/Resources/GridUserStore.migrations create mode 100644 addon-modules/0Data/prebuild.PGSQL.xml diff --git a/addon-modules/0Data/PGSQL/PGSQLAssetData.cs b/addon-modules/0Data/PGSQL/PGSQLAssetData.cs new file mode 100644 index 0000000000..bad5d37b80 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLAssetData.cs @@ -0,0 +1,49 @@ +/* + * 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 System.Collections.Generic; +using log4net; + +using OpenSim.Data; +using OpenSim.Data.PGSQL; + +namespace Diva.Data.PGSQL +{ + /// + /// An asset storage interface for the PGSQL database system + /// + public class PGSQLAssetData : OpenSim.Data.PGSQL.PGSQLAssetData + { + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLAuthenticationData.cs b/addon-modules/0Data/PGSQL/PGSQLAuthenticationData.cs new file mode 100644 index 0000000000..2fe61c3f81 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLAuthenticationData.cs @@ -0,0 +1,53 @@ +/* + * 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; +using System.Collections.Generic; +using System.Reflection; +using OpenMetaverse; +using Npgsql; + +using OpenSim.Framework; +using OpenSim.Data; +using OpenSim.Data.PGSQL; + +namespace Diva.Data.PGSQL +{ + public class PGSQLAuthenticationData : OpenSim.Data.PGSQL.PGSqlAuthenticationData + { + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + public PGSQLAuthenticationData(string connectionString, string realm) + : base(connectionString, realm) + { + } + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLAvatarData.cs b/addon-modules/0Data/PGSQL/PGSQLAvatarData.cs new file mode 100644 index 0000000000..d2fddce76c --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLAvatarData.cs @@ -0,0 +1,54 @@ +/* + * 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.Reflection; +using log4net; +using Npgsql; + +using OpenSim.Data; +using OpenSim.Data.PGSQL; + +namespace Diva.Data.PGSQL +{ + /// + /// A SQLite Interface for Avatar Data + /// + public class PGSQLAvatarData : OpenSim.Data.PGSQL.PGSQLAvatarData + { + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + public PGSQLAvatarData(string connectionString, string realm) : + base(connectionString, realm) + { + } + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLEstateData.cs b/addon-modules/0Data/PGSQL/PGSQLEstateData.cs new file mode 100644 index 0000000000..172b822fe6 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLEstateData.cs @@ -0,0 +1,51 @@ +/* + * 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.Reflection; +using Npgsql; + +namespace Diva.Data.PGSQL +{ + public class PGSQLEstateStore : OpenSim.Data.PGSQL.PGSQLEstateStore + { + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + public PGSQLEstateStore() : base() + { + } + + public PGSQLEstateStore(string connectionString) : base(connectionString) + { + } + + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLFriendsData.cs b/addon-modules/0Data/PGSQL/PGSQLFriendsData.cs new file mode 100644 index 0000000000..a7ea50a962 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLFriendsData.cs @@ -0,0 +1,50 @@ +/* + * 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; +using System.Collections.Generic; +using System.Reflection; + +using OpenSim.Data.PGSQL; + +namespace Diva.Data.PGSQL +{ + public class PGSQLFriendsData : OpenSim.Data.PGSQL.PGSqlFriendsData + { + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + + public PGSQLFriendsData(string connectionString, string realm) + : base(connectionString, realm) + { + } + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLGenericTableHandler.cs b/addon-modules/0Data/PGSQL/PGSQLGenericTableHandler.cs new file mode 100644 index 0000000000..1d27681d5d --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLGenericTableHandler.cs @@ -0,0 +1,52 @@ +/* + * Copyright (c) Marcus Kirsch (aka Marck). All rights reserved. + * + * 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.Reflection; + +using Npgsql; + +namespace Diva.Data.PGSQL +{ + public class PGSQLGenericTableHandler : OpenSim.Data.PGSQL.PGSQLGenericTableHandler where T : class, new() + { + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + public PGSQLGenericTableHandler(string connectionString, string realm, string storeName) + : base(connectionString, realm, storeName) { } + + new public virtual T[] DoQuery(NpgsqlCommand cmd) + { + return base.DoQuery(cmd); + } + + } + +} diff --git a/addon-modules/0Data/PGSQL/PGSQLGridUserData.cs b/addon-modules/0Data/PGSQL/PGSQLGridUserData.cs new file mode 100644 index 0000000000..1ab8dfda91 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLGridUserData.cs @@ -0,0 +1,99 @@ +/* + * 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; +using System.Collections.Generic; +using System.Reflection; + +using OpenSim.Data; +using OpenSim.Data.PGSQL; +using Npgsql; + +namespace Diva.Data.PGSQL +{ + public class PGSQLGridUserData : OpenSim.Data.PGSQL.PGSQLGridUserData, IGridUserData + { + private PGSQLGenericTableHandler m_DatabaseHandler; + + //protected override Assembly Assembly + //{ + // // WARNING! Moving migrations to this assembly!!! + // get { return GetType().Assembly; } + //} + + public PGSQLGridUserData(string connectionString, string realm) + : base(connectionString, realm) + { + m_DatabaseHandler = new PGSQLGenericTableHandler(connectionString, realm, "GridUserStore"); + } + + public GridUserData[] GetOnlineUsers() + { + return m_DatabaseHandler.Get("Online", true.ToString()); + } + + public long GetOnlineUserCount() + { + return m_DatabaseHandler.GetCount("Online", true.ToString()); + } + + public long GetActiveUserCount(int period) + { + return m_DatabaseHandler.GetCount(string.Format(" \"Online\" = {0} OR Date_Part('day', now()-to_timestamp(Logout)) <= {1}", "true", period)); + } + + public GridUserData[] GetUsers(string pattern) + { + if (string.IsNullOrEmpty(pattern) || pattern.Trim().Length == 0) + pattern = "1 ORDER BY \"UserID\" "; + else + pattern = string.Format(" \"UserID\" LIKE '%{0}%' ORDER BY \"UserID\" ", pattern); + + return m_DatabaseHandler.Get(pattern); + } + + public void ResetTOS() + { + using (NpgsqlCommand cmd = new NpgsqlCommand()) + { + cmd.CommandText = String.Format("update {0} set \"TOS\"= :tos", m_Realm); + cmd.Parameters.AddWithValue("tos", string.Empty); + ExecuteNonQuery(cmd); + } + } + + public void ResetOnline() + { + using (NpgsqlCommand cmd = new NpgsqlCommand()) + { + cmd.CommandText = String.Format("update {0} set \"Online\"=False ", m_Realm); + ExecuteNonQuery(cmd); + } + } + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLGroupsData.cs b/addon-modules/0Data/PGSQL/PGSQLGroupsData.cs new file mode 100644 index 0000000000..cb26450c36 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLGroupsData.cs @@ -0,0 +1,46 @@ +/* + * 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 OpenSim.Data; + +namespace Diva.Data.PGSQL +{ + /// + /// A PGSQL Interface for Groups + /// + public class PGSQLGroupsData : OpenSim.Data.PGSQL.PGSQLGroupsData + { + public PGSQLGroupsData(string conn, string realm) + : base(conn, realm) + { + } + + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLHGTravelData.cs b/addon-modules/0Data/PGSQL/PGSQLHGTravelData.cs new file mode 100644 index 0000000000..8aa31179e9 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLHGTravelData.cs @@ -0,0 +1,52 @@ +/* + * 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; +using System.Collections.Generic; +using System.Reflection; + +using OpenSim.Data; +using OpenSim.Data.PGSQL; +using Npgsql; + +namespace Diva.Data.PGSQL +{ + public class PGSQLHGTravelData : OpenSim.Data.PGSQL.PGSQLHGTravelData, IHGTravelingData + { + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + public PGSQLHGTravelData(string connectionString, string realm) + : base(connectionString, realm) + { + } + + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLInventoryStore.cs b/addon-modules/0Data/PGSQL/PGSQLInventoryStore.cs new file mode 100644 index 0000000000..6a91126f19 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLInventoryStore.cs @@ -0,0 +1,41 @@ +/* + * 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 OpenSim.Data.PGSQL; + +namespace Diva.Data.PGSQL +{ + /// + /// An Inventory Interface to the PGSQL database + /// + public class PGSQLInventoryStore : OpenSim.Data.PGSQL.PGSQLInventoryData + { + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLOfflineIMData.cs b/addon-modules/0Data/PGSQL/PGSQLOfflineIMData.cs new file mode 100644 index 0000000000..7350ca2be8 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLOfflineIMData.cs @@ -0,0 +1,50 @@ +/* + * 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 OpenSim.Data; + +namespace Diva.Data.PGSQL +{ + /// + /// A PGSQL Interface for the Grid Server + /// + public class PGSQLOfflineIMData : OpenSim.Data.PGSQL.PGSQLOfflineIMData + { + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + public PGSQLOfflineIMData(string connectionString, string realm) : + base(connectionString, realm) + { + } + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLPresenceData.cs b/addon-modules/0Data/PGSQL/PGSQLPresenceData.cs new file mode 100644 index 0000000000..0b0501b308 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLPresenceData.cs @@ -0,0 +1,53 @@ +/* + * 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.Reflection; +using Npgsql; + +using OpenSim.Data; +using OpenSim.Data.PGSQL; + +namespace Diva.Data.PGSQL +{ + /// + /// A PGSQL Interface for the Grid Server + /// + public class PGSQLPresenceData : OpenSim.Data.PGSQL.PGSQLPresenceData + { + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + public PGSQLPresenceData(string connectionString, string realm) : + base(connectionString, realm) + { + } + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLRegionData.cs b/addon-modules/0Data/PGSQL/PGSQLRegionData.cs new file mode 100644 index 0000000000..f46f6ff608 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLRegionData.cs @@ -0,0 +1,76 @@ +/* + * Copyright (c) Crista Lopes (aka Diva) and Marcus Kirsch (aka Marck). All rights reserved. + * + * 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.Reflection; + +using Npgsql; +using OpenMetaverse; + +using OpenSim.Data; +using OpenSim.Data.PGSQL; + +namespace Diva.Data.PGSQL +{ + /// + /// A RegionData Interface to the PGSQL database + /// + public class PGSQLRegionData : OpenSim.Data.PGSQL.PGSqlRegionData, IRegionData + { + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + private PGSQLGenericTableHandler m_DatabaseHandler; + + public PGSQLRegionData(string connectionString, string realm) + : base(connectionString, realm) + { + m_DatabaseHandler = new PGSQLGenericTableHandler(connectionString, realm, "GridStore"); + } + + public RegionData[] Get(UUID scopeID, int regionFlags, int excludeFlags) + { + return m_DatabaseHandler.Get(CreateWhereClause(scopeID, regionFlags, excludeFlags)); + } + + public long GetCount(UUID scopeID, int regionFlags, int excludeFlags) + { + return m_DatabaseHandler.GetCount(CreateWhereClause(scopeID, regionFlags, excludeFlags)); + } + + private string CreateWhereClause(UUID scopeID, int regionFlags, int excludeFlags) + { + string where = "(flags & {0}) <> 0 and (flags & {1}) = 0"; + if (scopeID != UUID.Zero) + where += " and \"ScopeID\" = " + scopeID.ToString(); + + return string.Format(where, regionFlags.ToString(), excludeFlags.ToString()); + } + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLSimulationData.cs b/addon-modules/0Data/PGSQL/PGSQLSimulationData.cs new file mode 100644 index 0000000000..7348232f21 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLSimulationData.cs @@ -0,0 +1,55 @@ +/* + * 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.Reflection; + +using OpenSim.Data.PGSQL; + +namespace Diva.Data.PGSQL +{ + /// + /// A PGSQL Interface for the Region Server + /// + public class PGSQLSimulationData : OpenSim.Data.PGSQL.PGSQLSimulationData + { + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + public PGSQLSimulationData() : base() + { + } + + public PGSQLSimulationData(string connectionString) : base(connectionString) + { + } + + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLUserAccountData.cs b/addon-modules/0Data/PGSQL/PGSQLUserAccountData.cs new file mode 100644 index 0000000000..5991dbe88a --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLUserAccountData.cs @@ -0,0 +1,104 @@ +/* + * 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; +using System.Collections.Generic; +using System.Data; +using System.Reflection; + +using OpenMetaverse; +using OpenSim.Data; +using OpenSim.Data.PGSQL; +using Npgsql; + +namespace Diva.Data.PGSQL +{ + public class PGSQLUserAccountData : OpenSim.Data.PGSQL.PGSqlUserAccountData, IUserAccountData + { + private PGSQLGenericTableHandler m_DatabaseHandler; + + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + public PGSQLUserAccountData(string connectionString, string realm) + : base(connectionString, realm) + { + m_DatabaseHandler = new PGSQLGenericTableHandler(connectionString, realm, "UserAccount"); + } + + public UserAccountData[] GetActiveAccounts(UUID scopeID, string query, string excludeTerm) + { + string[] words = query.Split(new char[] { ' ' }); + + for (int i = 0; i < words.Length; i++) + { + if (words[i].Length < 3) + { + if (i != words.Length - 1) + Array.Copy(words, i + 1, words, i, words.Length - i - 1); + Array.Resize(ref words, words.Length - 1); + } + } + + if (words.Length == 0) + return new UserAccountData[0]; + + if (words.Length > 2) + return new UserAccountData[0]; + + NpgsqlCommand cmd = new NpgsqlCommand(); + + if (words.Length == 1) + { + cmd.CommandText = String.Format("select * from {0} where (\"ScopeID\"=:ScopeID or \"ScopeID\"='00000000-0000-0000-0000-000000000000') and (lower(\"FirstName\") like lower(:search) or lower(\"LastName\") like lower(:search) )", m_Realm); + cmd.Parameters.AddWithValue("search", "%" + words[0] + "%"); + cmd.Parameters.AddWithValue("ScopeID", scopeID.ToString()); + } + else + { + cmd.CommandText = String.Format("select * from {0} where (\"ScopeID\"=:ScopeID or \"ScopeID\"='00000000-0000-0000-0000-000000000000') and (lower(\"FirstName\") like lower(:searchFirst) or lower(\"LastName\") like lower(:searchLast) )", m_Realm); + cmd.Parameters.AddWithValue("searchFirst", "%" + words[0] + "%"); + cmd.Parameters.AddWithValue("searchLast", "%" + words[1] + "%"); + cmd.Parameters.AddWithValue("ScopeID", scopeID.ToString()); + } + cmd.CommandText = cmd.CommandText + " and (lower(\"FirstName\") not like lower(:exclude) )"; + cmd.Parameters.AddWithValue("exclude", excludeTerm + "%"); + + return m_DatabaseHandler.DoQuery(cmd); + } + + public long GetActiveAccountsCount(UUID scopeID, string excludeTerm) + { + string where = string.Format("(\"ScopeID\"='{0}' or \"ScopeID\"='00000000-0000-0000-0000-000000000000') and (lower(\"FirstName\") not like lower('{1}%') )", scopeID, excludeTerm); + + return m_DatabaseHandler.GetCount(where); + } + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLUserProfilesData.cs b/addon-modules/0Data/PGSQL/PGSQLUserProfilesData.cs new file mode 100644 index 0000000000..e747c0ac86 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLUserProfilesData.cs @@ -0,0 +1,50 @@ +/* + * 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 OpenSim.Data; + +namespace Diva.Data.PGSQL +{ + /// + /// A PGSQL Interface for the Grid Server + /// + public class PGSQLUserProfilesData : OpenSim.Data.PGSQL.UserProfilesData + { + protected override Assembly Assembly + { + get { return GetType().BaseType.Assembly; } + } + + public PGSQLUserProfilesData(string connectionString) : + base(connectionString) + { + } + } +} diff --git a/addon-modules/0Data/PGSQL/PGSQLXInventoryData.cs b/addon-modules/0Data/PGSQL/PGSQLXInventoryData.cs new file mode 100644 index 0000000000..630b9cefa8 --- /dev/null +++ b/addon-modules/0Data/PGSQL/PGSQLXInventoryData.cs @@ -0,0 +1,46 @@ +/* + * 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 OpenSim.Data.PGSQL; + +namespace Diva.Data.PGSQL +{ + /// + /// A PGSQL Interface for the Inventory + /// + public class PGSQLXInventoryData : OpenSim.Data.PGSQL.PGSQLXInventoryData + { + public PGSQLXInventoryData(string conn, string realm) + : base(conn, realm) + { + } + + } +} diff --git a/addon-modules/0Data/PGSQL/Properties/AssemblyInfo.cs b/addon-modules/0Data/PGSQL/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c697cf3b9e --- /dev/null +++ b/addon-modules/0Data/PGSQL/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Diva.Data.PGSQL")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Diva Distribution")] +[assembly: AssemblyCopyright("Crista Lopes aka Diva Canto, and contributors")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("82bceb97-dbf1-43d9-831c-c4d66937f93e")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.6.*")] + diff --git a/addon-modules/0Data/PGSQL/Resources/GridUserStore.migrations b/addon-modules/0Data/PGSQL/Resources/GridUserStore.migrations new file mode 100644 index 0000000000..d5a1bf66e9 --- /dev/null +++ b/addon-modules/0Data/PGSQL/Resources/GridUserStore.migrations @@ -0,0 +1,25 @@ +:VERSION 1 # -------------------------- + +BEGIN; + +CREATE TABLE GridUser ( + "UserID" VARCHAR(255) NOT NULL PRIMARY KEY, + "HomeRegionID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + "HomePosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>', + "HomeLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>', + "LastRegionID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + "LastPosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>', + "LastLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>', + "Online" CHAR(5) NOT NULL DEFAULT 'false', + "Login" CHAR(16) NOT NULL DEFAULT '0', + "Logout" CHAR(16) NOT NULL DEFAULT '0' +); + +COMMIT; + +:VERSION 2 # -------------------------- +BEGIN; + +ALTER TABLE GridUser ADD "TOS" char(128); + +COMMIT; diff --git a/addon-modules/0Data/prebuild.PGSQL.xml b/addon-modules/0Data/prebuild.PGSQL.xml new file mode 100644 index 0000000000..722635253d --- /dev/null +++ b/addon-modules/0Data/prebuild.PGSQL.xml @@ -0,0 +1,43 @@ + + + + + ../../../bin/ + + + + + ../../../bin/ + + + + ../../../bin/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 9066a1be88c1ae74d07c7a39eca7f74a2382d0ff Mon Sep 17 00:00:00 2001 From: Fernando Oliveira Date: Tue, 8 Oct 2013 18:27:56 -0300 Subject: [PATCH 4/5] Fixed classes names from Opensim for Postgresql --- addon-modules/0Data/PGSQL/PGSQLAuthenticationData.cs | 2 +- addon-modules/0Data/PGSQL/PGSQLFriendsData.cs | 2 +- addon-modules/0Data/PGSQL/PGSQLRegionData.cs | 2 +- addon-modules/0Data/PGSQL/PGSQLUserAccountData.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addon-modules/0Data/PGSQL/PGSQLAuthenticationData.cs b/addon-modules/0Data/PGSQL/PGSQLAuthenticationData.cs index 2fe61c3f81..d4f2de6229 100644 --- a/addon-modules/0Data/PGSQL/PGSQLAuthenticationData.cs +++ b/addon-modules/0Data/PGSQL/PGSQLAuthenticationData.cs @@ -38,7 +38,7 @@ namespace Diva.Data.PGSQL { - public class PGSQLAuthenticationData : OpenSim.Data.PGSQL.PGSqlAuthenticationData + public class PGSQLAuthenticationData : OpenSim.Data.PGSQL.PGSQLAuthenticationData { protected override Assembly Assembly { diff --git a/addon-modules/0Data/PGSQL/PGSQLFriendsData.cs b/addon-modules/0Data/PGSQL/PGSQLFriendsData.cs index a7ea50a962..e83596fa66 100644 --- a/addon-modules/0Data/PGSQL/PGSQLFriendsData.cs +++ b/addon-modules/0Data/PGSQL/PGSQLFriendsData.cs @@ -34,7 +34,7 @@ namespace Diva.Data.PGSQL { - public class PGSQLFriendsData : OpenSim.Data.PGSQL.PGSqlFriendsData + public class PGSQLFriendsData : OpenSim.Data.PGSQL.PGSQLFriendsData { protected override Assembly Assembly { diff --git a/addon-modules/0Data/PGSQL/PGSQLRegionData.cs b/addon-modules/0Data/PGSQL/PGSQLRegionData.cs index f46f6ff608..8dfd0dd8c5 100644 --- a/addon-modules/0Data/PGSQL/PGSQLRegionData.cs +++ b/addon-modules/0Data/PGSQL/PGSQLRegionData.cs @@ -39,7 +39,7 @@ namespace Diva.Data.PGSQL /// /// A RegionData Interface to the PGSQL database /// - public class PGSQLRegionData : OpenSim.Data.PGSQL.PGSqlRegionData, IRegionData + public class PGSQLRegionData : OpenSim.Data.PGSQL.PGSQLRegionData, IRegionData { protected override Assembly Assembly { diff --git a/addon-modules/0Data/PGSQL/PGSQLUserAccountData.cs b/addon-modules/0Data/PGSQL/PGSQLUserAccountData.cs index 5991dbe88a..5cf5cdb5ac 100644 --- a/addon-modules/0Data/PGSQL/PGSQLUserAccountData.cs +++ b/addon-modules/0Data/PGSQL/PGSQLUserAccountData.cs @@ -38,7 +38,7 @@ namespace Diva.Data.PGSQL { - public class PGSQLUserAccountData : OpenSim.Data.PGSQL.PGSqlUserAccountData, IUserAccountData + public class PGSQLUserAccountData : OpenSim.Data.PGSQL.PGSQLUserAccountData, IUserAccountData { private PGSQLGenericTableHandler m_DatabaseHandler; From bbe51c0d448129e1f1cd032797d62095f2d99d47 Mon Sep 17 00:00:00 2001 From: Fernando Oliveira Date: Wed, 9 Oct 2013 02:11:57 -0300 Subject: [PATCH 5/5] fix for opensim 0.8.0 --- addon-modules/0Data/PGSQL/PGSQLGridUserData.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addon-modules/0Data/PGSQL/PGSQLGridUserData.cs b/addon-modules/0Data/PGSQL/PGSQLGridUserData.cs index 1ab8dfda91..2a3f8d9e0a 100644 --- a/addon-modules/0Data/PGSQL/PGSQLGridUserData.cs +++ b/addon-modules/0Data/PGSQL/PGSQLGridUserData.cs @@ -49,28 +49,28 @@ public class PGSQLGridUserData : OpenSim.Data.PGSQL.PGSQLGridUserData, IGridUser public PGSQLGridUserData(string connectionString, string realm) : base(connectionString, realm) { - m_DatabaseHandler = new PGSQLGenericTableHandler(connectionString, realm, "GridUserStore"); + m_DatabaseHandler = new Diva.Data.PGSQL.PGSQLGenericTableHandler(connectionString, realm, "GridUserStore"); } public GridUserData[] GetOnlineUsers() { - return m_DatabaseHandler.Get("Online", true.ToString()); + return m_DatabaseHandler.Get("Online", "'true'"); } public long GetOnlineUserCount() { - return m_DatabaseHandler.GetCount("Online", true.ToString()); + return m_DatabaseHandler.GetCount("Online", "'true'"); } public long GetActiveUserCount(int period) { - return m_DatabaseHandler.GetCount(string.Format(" \"Online\" = {0} OR Date_Part('day', now()-to_timestamp(Logout)) <= {1}", "true", period)); + return m_DatabaseHandler.GetCount(string.Format(" \"Online\" = '{0}' OR Date_Part('day', now()-to_timestamp(cast(\"Logout\" as double precision))) <= {1}", "true", period)); } public GridUserData[] GetUsers(string pattern) { if (string.IsNullOrEmpty(pattern) || pattern.Trim().Length == 0) - pattern = "1 ORDER BY \"UserID\" "; + pattern = " ORDER BY \"UserID\" "; else pattern = string.Format(" \"UserID\" LIKE '%{0}%' ORDER BY \"UserID\" ", pattern); @@ -91,7 +91,7 @@ public void ResetOnline() { using (NpgsqlCommand cmd = new NpgsqlCommand()) { - cmd.CommandText = String.Format("update {0} set \"Online\"=False ", m_Realm); + cmd.CommandText = String.Format("update {0} set \"Online\"='False' ", m_Realm); ExecuteNonQuery(cmd); } }