diff options
Diffstat (limited to 'OpenSim/Data')
39 files changed, 1307 insertions, 182 deletions
diff --git a/OpenSim/Data/IAvatarData.cs b/OpenSim/Data/IAvatarData.cs new file mode 100644 index 0000000..0a18e21 --- /dev/null +++ b/OpenSim/Data/IAvatarData.cs | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Data | ||
34 | { | ||
35 | // This MUST be a ref type! | ||
36 | public class AvatarBaseData | ||
37 | { | ||
38 | public UUID PrincipalID; | ||
39 | public Dictionary<string, string> Data; | ||
40 | } | ||
41 | |||
42 | public interface IAvatarData | ||
43 | { | ||
44 | AvatarBaseData[] Get(string field, string val); | ||
45 | bool Store(AvatarBaseData data); | ||
46 | bool Delete(UUID principalID, string name); | ||
47 | bool Delete(string field, string val); | ||
48 | } | ||
49 | } | ||
diff --git a/OpenSim/Data/IFriendsData.cs b/OpenSim/Data/IFriendsData.cs new file mode 100644 index 0000000..1f1a031 --- /dev/null +++ b/OpenSim/Data/IFriendsData.cs | |||
@@ -0,0 +1,51 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Data | ||
34 | { | ||
35 | public class FriendsData | ||
36 | { | ||
37 | public UUID PrincipalID; | ||
38 | public string Friend; | ||
39 | public Dictionary<string, string> Data; | ||
40 | } | ||
41 | |||
42 | /// <summary> | ||
43 | /// An interface for connecting to the friends datastore | ||
44 | /// </summary> | ||
45 | public interface IFriendsData | ||
46 | { | ||
47 | bool Store(FriendsData data); | ||
48 | bool Delete(UUID ownerID, string friend); | ||
49 | FriendsData[] GetFriends(UUID principalID); | ||
50 | } | ||
51 | } | ||
diff --git a/OpenSim/Data/IPresenceData.cs b/OpenSim/Data/IPresenceData.cs index e5a8ebd..71d0e31 100644 --- a/OpenSim/Data/IPresenceData.cs +++ b/OpenSim/Data/IPresenceData.cs | |||
@@ -32,25 +32,28 @@ using OpenSim.Framework; | |||
32 | 32 | ||
33 | namespace OpenSim.Data | 33 | namespace OpenSim.Data |
34 | { | 34 | { |
35 | public struct PresenceData | 35 | // This MUST be a ref type! |
36 | public class PresenceData | ||
36 | { | 37 | { |
37 | public UUID UUID; | 38 | public string UserID; |
38 | public UUID currentRegion; | 39 | public UUID RegionID; |
40 | public UUID SessionID; | ||
39 | public Dictionary<string, string> Data; | 41 | public Dictionary<string, string> Data; |
40 | } | 42 | } |
41 | 43 | ||
42 | /// <summary> | 44 | /// <summary> |
43 | /// An interface for connecting to the authentication datastore | 45 | /// An interface for connecting to the presence datastore |
44 | /// </summary> | 46 | /// </summary> |
45 | public interface IPresenceData | 47 | public interface IPresenceData |
46 | { | 48 | { |
47 | bool Store(PresenceData data); | 49 | bool Store(PresenceData data); |
48 | 50 | ||
49 | PresenceData Get(UUID principalID); | 51 | PresenceData Get(UUID sessionID); |
50 | 52 | void LogoutRegionAgents(UUID regionID); | |
51 | bool SetUserDataItem(UUID principalID, string item, string value); | 53 | bool ReportAgent(UUID sessionID, UUID regionID, string position, string lookAt); |
52 | bool SetRegionDataItem(UUID principalID, string item, string value); | 54 | bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt); |
53 | 55 | PresenceData[] Get(string field, string data); | |
54 | bool Delete(UUID regionID); | 56 | void Prune(string userID); |
57 | bool Delete(string field, string val); | ||
55 | } | 58 | } |
56 | } | 59 | } |
diff --git a/OpenSim/Data/IRegionData.cs b/OpenSim/Data/IRegionData.cs index 7a607ab..8259f9b 100644 --- a/OpenSim/Data/IRegionData.cs +++ b/OpenSim/Data/IRegionData.cs | |||
@@ -60,5 +60,22 @@ namespace OpenSim.Data | |||
60 | 60 | ||
61 | bool Delete(UUID regionID); | 61 | bool Delete(UUID regionID); |
62 | 62 | ||
63 | List<RegionData> GetDefaultRegions(UUID scopeID); | ||
64 | List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y); | ||
65 | } | ||
66 | |||
67 | [Flags] | ||
68 | public enum RegionFlags : int | ||
69 | { | ||
70 | DefaultRegion = 1, // Used for new Rez. Random if multiple defined | ||
71 | FallbackRegion = 2, // Regions we redirect to when the destination is down | ||
72 | RegionOnline = 4, // Set when a region comes online, unset when it unregisters and DeleteOnUnregister is false | ||
73 | NoDirectLogin = 8, // Region unavailable for direct logins (by name) | ||
74 | Persistent = 16, // Don't remove on unregister | ||
75 | LockedOut = 32, // Don't allow registration | ||
76 | NoMove = 64, // Don't allow moving this region | ||
77 | Reservation = 128, // This is an inactive reservation | ||
78 | Authenticate = 256, // Require authentication | ||
79 | Hyperlink = 512 // Record represents a HG link | ||
63 | } | 80 | } |
64 | } | 81 | } |
diff --git a/OpenSim/Data/IUserAccountData.cs b/OpenSim/Data/IUserAccountData.cs index 6bec188..6ee5995 100644 --- a/OpenSim/Data/IUserAccountData.cs +++ b/OpenSim/Data/IUserAccountData.cs | |||
@@ -36,20 +36,18 @@ namespace OpenSim.Data | |||
36 | { | 36 | { |
37 | public UUID PrincipalID; | 37 | public UUID PrincipalID; |
38 | public UUID ScopeID; | 38 | public UUID ScopeID; |
39 | public Dictionary<string, object> Data; | 39 | public string FirstName; |
40 | public string LastName; | ||
41 | public Dictionary<string, string> Data; | ||
40 | } | 42 | } |
41 | 43 | ||
42 | /// <summary> | 44 | /// <summary> |
43 | /// An interface for connecting to the authentication datastore | 45 | /// An interface for connecting to the user accounts datastore |
44 | /// </summary> | 46 | /// </summary> |
45 | public interface IUserAccountData | 47 | public interface IUserAccountData |
46 | { | 48 | { |
47 | UserAccountData Get(UUID principalID, UUID ScopeID); | 49 | UserAccountData[] Get(string[] fields, string[] values); |
48 | |||
49 | List<UserAccountData> Query(UUID principalID, UUID ScopeID, string query); | ||
50 | |||
51 | bool Store(UserAccountData data); | 50 | bool Store(UserAccountData data); |
52 | 51 | UserAccountData[] GetUsers(UUID scopeID, string query); | |
53 | bool SetDataItem(UUID principalID, string item, string value); | ||
54 | } | 52 | } |
55 | } | 53 | } |
diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs index cd9273e..6909136 100644 --- a/OpenSim/Data/IXInventoryData.cs +++ b/OpenSim/Data/IXInventoryData.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Data | |||
58 | public int saleType; | 58 | public int saleType; |
59 | public int creationDate; | 59 | public int creationDate; |
60 | public UUID groupID; | 60 | public UUID groupID; |
61 | public bool groupOwned; | 61 | public int groupOwned; |
62 | public int flags; | 62 | public int flags; |
63 | public UUID inventoryID; | 63 | public UUID inventoryID; |
64 | public UUID avatarID; | 64 | public UUID avatarID; |
diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/MSSQL/MSSQLRegionData.cs index a898aab..fbfb78e 100644 --- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLRegionData.cs | |||
@@ -307,5 +307,15 @@ namespace OpenSim.Data.MSSQL | |||
307 | } | 307 | } |
308 | return false; | 308 | return false; |
309 | } | 309 | } |
310 | |||
311 | public List<RegionData> GetDefaultRegions(UUID scopeID) | ||
312 | { | ||
313 | return null; | ||
314 | } | ||
315 | |||
316 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) | ||
317 | { | ||
318 | return null; | ||
319 | } | ||
310 | } | 320 | } |
311 | } | 321 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs index 2d92cb1..01c64dc 100644 --- a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs +++ b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Data.MSSQL | |||
65 | public UserAccountData Get(UUID principalID, UUID scopeID) | 65 | public UserAccountData Get(UUID principalID, UUID scopeID) |
66 | { | 66 | { |
67 | UserAccountData ret = new UserAccountData(); | 67 | UserAccountData ret = new UserAccountData(); |
68 | ret.Data = new Dictionary<string, object>(); | 68 | ret.Data = new Dictionary<string, string>(); |
69 | 69 | ||
70 | string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm); | 70 | string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm); |
71 | if (scopeID != UUID.Zero) | 71 | if (scopeID != UUID.Zero) |
@@ -168,6 +168,11 @@ namespace OpenSim.Data.MSSQL | |||
168 | return true; | 168 | return true; |
169 | } | 169 | } |
170 | 170 | ||
171 | public bool Store(UserAccountData data, UUID principalID, string token) | ||
172 | { | ||
173 | return false; | ||
174 | } | ||
175 | |||
171 | public bool SetDataItem(UUID principalID, string item, string value) | 176 | public bool SetDataItem(UUID principalID, string item, string value) |
172 | { | 177 | { |
173 | string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item); | 178 | string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item); |
@@ -184,5 +189,15 @@ namespace OpenSim.Data.MSSQL | |||
184 | } | 189 | } |
185 | return false; | 190 | return false; |
186 | } | 191 | } |
192 | |||
193 | public UserAccountData[] Get(string[] keys, string[] vals) | ||
194 | { | ||
195 | return null; | ||
196 | } | ||
197 | |||
198 | public UserAccountData[] GetUsers(UUID scopeID, string query) | ||
199 | { | ||
200 | return null; | ||
201 | } | ||
187 | } | 202 | } |
188 | } | 203 | } |
diff --git a/OpenSim/Data/Migration.cs b/OpenSim/Data/Migration.cs index e51dc22..4622e23 100644 --- a/OpenSim/Data/Migration.cs +++ b/OpenSim/Data/Migration.cs | |||
@@ -128,7 +128,7 @@ namespace OpenSim.Data | |||
128 | return; | 128 | return; |
129 | 129 | ||
130 | // to prevent people from killing long migrations. | 130 | // to prevent people from killing long migrations. |
131 | m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision.", _type); | 131 | m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision {1}.", _type, migrations.Keys[migrations.Count - 1]); |
132 | m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!"); | 132 | m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!"); |
133 | 133 | ||
134 | DbCommand cmd = _conn.CreateCommand(); | 134 | DbCommand cmd = _conn.CreateCommand(); |
@@ -138,7 +138,15 @@ namespace OpenSim.Data | |||
138 | cmd.CommandText = kvp.Value; | 138 | cmd.CommandText = kvp.Value; |
139 | // we need to up the command timeout to infinite as we might be doing long migrations. | 139 | // we need to up the command timeout to infinite as we might be doing long migrations. |
140 | cmd.CommandTimeout = 0; | 140 | cmd.CommandTimeout = 0; |
141 | cmd.ExecuteNonQuery(); | 141 | try |
142 | { | ||
143 | cmd.ExecuteNonQuery(); | ||
144 | } | ||
145 | catch (Exception e) | ||
146 | { | ||
147 | m_log.DebugFormat("[MIGRATIONS] Cmd was {0}", cmd.CommandText); | ||
148 | m_log.DebugFormat("[MIGRATIONS]: An error has occurred in the migration {0}.\n This may mean you could see errors trying to run OpenSim. If you see database related errors, you will need to fix the issue manually. Continuing.", e.Message); | ||
149 | } | ||
142 | 150 | ||
143 | if (version == 0) | 151 | if (version == 0) |
144 | { | 152 | { |
@@ -246,7 +254,8 @@ namespace OpenSim.Data | |||
246 | if (m.Success) | 254 | if (m.Success) |
247 | { | 255 | { |
248 | int version = int.Parse(m.Groups[1].ToString()); | 256 | int version = int.Parse(m.Groups[1].ToString()); |
249 | if (version > after) { | 257 | if (version > after) |
258 | { | ||
250 | using (Stream resource = _assem.GetManifestResourceStream(s)) | 259 | using (Stream resource = _assem.GetManifestResourceStream(s)) |
251 | { | 260 | { |
252 | using (StreamReader resourceReader = new StreamReader(resource)) | 261 | using (StreamReader resourceReader = new StreamReader(resource)) |
diff --git a/OpenSim/Data/MySQL/MySQLAvatarData.cs b/OpenSim/Data/MySQL/MySQLAvatarData.cs new file mode 100644 index 0000000..5611302 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLAvatarData.cs | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using MySql.Data.MySqlClient; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// A MySQL Interface for the Grid Server | ||
42 | /// </summary> | ||
43 | public class MySQLAvatarData : MySQLGenericTableHandler<AvatarBaseData>, | ||
44 | IAvatarData | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | public MySQLAvatarData(string connectionString, string realm) : | ||
49 | base(connectionString, realm, "Avatar") | ||
50 | { | ||
51 | } | ||
52 | |||
53 | public bool Delete(UUID principalID, string name) | ||
54 | { | ||
55 | MySqlCommand cmd = new MySqlCommand(); | ||
56 | |||
57 | cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm); | ||
58 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | ||
59 | cmd.Parameters.AddWithValue("?Name", name); | ||
60 | |||
61 | if (ExecuteNonQuery(cmd) > 0) | ||
62 | return true; | ||
63 | |||
64 | return false; | ||
65 | } | ||
66 | } | ||
67 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs new file mode 100644 index 0000000..7a43bb6 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Data; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using MySql.Data.MySqlClient; | ||
35 | |||
36 | namespace OpenSim.Data.MySQL | ||
37 | { | ||
38 | public class MySqlFriendsData : MySQLGenericTableHandler<FriendsData>, IFriendsData | ||
39 | { | ||
40 | public MySqlFriendsData(string connectionString, string realm) | ||
41 | : base(connectionString, realm, "FriendsStore") | ||
42 | { | ||
43 | } | ||
44 | |||
45 | public bool Delete(UUID principalID, string friend) | ||
46 | { | ||
47 | MySqlCommand cmd = new MySqlCommand(); | ||
48 | |||
49 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); | ||
50 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | ||
51 | cmd.Parameters.AddWithValue("?Friend", friend); | ||
52 | |||
53 | ExecuteNonQuery(cmd); | ||
54 | |||
55 | return true; | ||
56 | } | ||
57 | |||
58 | public FriendsData[] GetFriends(UUID principalID) | ||
59 | { | ||
60 | MySqlCommand cmd = new MySqlCommand(); | ||
61 | |||
62 | cmd.CommandText = String.Format("select a.*,b.Flags as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID and b.Flags is not null", m_Realm); | ||
63 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | ||
64 | |||
65 | return DoQuery(cmd); | ||
66 | } | ||
67 | } | ||
68 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 698bf52..6ad59f6 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | |||
@@ -99,12 +99,12 @@ namespace OpenSim.Data.MySQL | |||
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | public T[] Get(string field, string key) | 102 | public virtual T[] Get(string field, string key) |
103 | { | 103 | { |
104 | return Get(new string[] { field }, new string[] { key }); | 104 | return Get(new string[] { field }, new string[] { key }); |
105 | } | 105 | } |
106 | 106 | ||
107 | public T[] Get(string[] fields, string[] keys) | 107 | public virtual T[] Get(string[] fields, string[] keys) |
108 | { | 108 | { |
109 | if (fields.Length != keys.Length) | 109 | if (fields.Length != keys.Length) |
110 | return new T[0]; | 110 | return new T[0]; |
@@ -198,7 +198,7 @@ namespace OpenSim.Data.MySQL | |||
198 | return result.ToArray(); | 198 | return result.ToArray(); |
199 | } | 199 | } |
200 | 200 | ||
201 | public T[] Get(string where) | 201 | public virtual T[] Get(string where) |
202 | { | 202 | { |
203 | using (MySqlCommand cmd = new MySqlCommand()) | 203 | using (MySqlCommand cmd = new MySqlCommand()) |
204 | { | 204 | { |
@@ -212,7 +212,7 @@ namespace OpenSim.Data.MySQL | |||
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | public bool Store(T row) | 215 | public virtual bool Store(T row) |
216 | { | 216 | { |
217 | using (MySqlCommand cmd = new MySqlCommand()) | 217 | using (MySqlCommand cmd = new MySqlCommand()) |
218 | { | 218 | { |
@@ -252,7 +252,7 @@ namespace OpenSim.Data.MySQL | |||
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | public bool Delete(string field, string val) | 255 | public virtual bool Delete(string field, string val) |
256 | { | 256 | { |
257 | using (MySqlCommand cmd = new MySqlCommand()) | 257 | using (MySqlCommand cmd = new MySqlCommand()) |
258 | { | 258 | { |
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs new file mode 100644 index 0000000..fcbe3d6 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs | |||
@@ -0,0 +1,155 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using MySql.Data.MySqlClient; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// A MySQL Interface for the Grid Server | ||
42 | /// </summary> | ||
43 | public class MySQLPresenceData : MySQLGenericTableHandler<PresenceData>, | ||
44 | IPresenceData | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | public MySQLPresenceData(string connectionString, string realm) : | ||
49 | base(connectionString, realm, "Presence") | ||
50 | { | ||
51 | } | ||
52 | |||
53 | public PresenceData Get(UUID sessionID) | ||
54 | { | ||
55 | PresenceData[] ret = Get("SessionID", | ||
56 | sessionID.ToString()); | ||
57 | |||
58 | if (ret.Length == 0) | ||
59 | return null; | ||
60 | |||
61 | return ret[0]; | ||
62 | } | ||
63 | |||
64 | public void LogoutRegionAgents(UUID regionID) | ||
65 | { | ||
66 | MySqlCommand cmd = new MySqlCommand(); | ||
67 | |||
68 | cmd.CommandText = String.Format("update {0} set Online='false' where `RegionID`=?RegionID", m_Realm); | ||
69 | |||
70 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
71 | |||
72 | ExecuteNonQuery(cmd); | ||
73 | } | ||
74 | |||
75 | public bool ReportAgent(UUID sessionID, UUID regionID, string position, | ||
76 | string lookAt) | ||
77 | { | ||
78 | PresenceData[] pd = Get("SessionID", sessionID.ToString()); | ||
79 | if (pd.Length == 0) | ||
80 | return false; | ||
81 | |||
82 | MySqlCommand cmd = new MySqlCommand(); | ||
83 | |||
84 | cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, Position=?Position, LookAt=?LookAt, Online='true' where `SessionID`=?SessionID", m_Realm); | ||
85 | |||
86 | cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); | ||
87 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
88 | cmd.Parameters.AddWithValue("?Position", position.ToString()); | ||
89 | cmd.Parameters.AddWithValue("?LookAt", lookAt.ToString()); | ||
90 | |||
91 | if (ExecuteNonQuery(cmd) == 0) | ||
92 | return false; | ||
93 | |||
94 | return true; | ||
95 | } | ||
96 | |||
97 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
98 | { | ||
99 | PresenceData[] pd = Get("UserID", userID); | ||
100 | if (pd.Length == 0) | ||
101 | return false; | ||
102 | |||
103 | MySqlCommand cmd = new MySqlCommand(); | ||
104 | |||
105 | cmd.CommandText = String.Format("update {0} set HomeRegionID=?HomeRegionID, HomePosition=?HomePosition, HomeLookAt=?HomeLookAt where UserID=?UserID", m_Realm); | ||
106 | |||
107 | cmd.Parameters.AddWithValue("?UserID", userID); | ||
108 | cmd.Parameters.AddWithValue("?HomeRegionID", regionID.ToString()); | ||
109 | cmd.Parameters.AddWithValue("?HomePosition", position); | ||
110 | cmd.Parameters.AddWithValue("?HomeLookAt", lookAt); | ||
111 | |||
112 | if (ExecuteNonQuery(cmd) == 0) | ||
113 | return false; | ||
114 | |||
115 | return true; | ||
116 | } | ||
117 | |||
118 | public void Prune(string userID) | ||
119 | { | ||
120 | MySqlCommand cmd = new MySqlCommand(); | ||
121 | |||
122 | cmd.CommandText = String.Format("select * from {0} where UserID=?UserID", m_Realm); | ||
123 | |||
124 | cmd.Parameters.AddWithValue("?UserID", userID); | ||
125 | ; | ||
126 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
127 | { | ||
128 | dbcon.Open(); | ||
129 | |||
130 | cmd.Connection = dbcon; | ||
131 | |||
132 | using (IDataReader reader = cmd.ExecuteReader()) | ||
133 | { | ||
134 | |||
135 | List<UUID> deleteSessions = new List<UUID>(); | ||
136 | int online = 0; | ||
137 | |||
138 | while(reader.Read()) | ||
139 | { | ||
140 | if (bool.Parse(reader["Online"].ToString())) | ||
141 | online++; | ||
142 | else | ||
143 | deleteSessions.Add(new UUID(reader["SessionID"].ToString())); | ||
144 | } | ||
145 | |||
146 | if (online == 0 && deleteSessions.Count > 0) | ||
147 | deleteSessions.RemoveAt(0); | ||
148 | |||
149 | foreach (UUID s in deleteSessions) | ||
150 | Delete("SessionID", s.ToString()); | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index a1a08b1..aa9a104 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -283,5 +283,31 @@ namespace OpenSim.Data.MySQL | |||
283 | 283 | ||
284 | return false; | 284 | return false; |
285 | } | 285 | } |
286 | public List<RegionData> GetDefaultRegions(UUID scopeID) | ||
287 | { | ||
288 | string command = "select * from `"+m_Realm+"` where (flags & 1) <> 0"; | ||
289 | if (scopeID != UUID.Zero) | ||
290 | command += " and ScopeID = ?scopeID"; | ||
291 | |||
292 | MySqlCommand cmd = new MySqlCommand(command); | ||
293 | |||
294 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
295 | |||
296 | return RunCommand(cmd); | ||
297 | } | ||
298 | |||
299 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) | ||
300 | { | ||
301 | string command = "select * from `"+m_Realm+"` where (flags & 2) <> 0"; | ||
302 | if (scopeID != UUID.Zero) | ||
303 | command += " and ScopeID = ?scopeID"; | ||
304 | |||
305 | MySqlCommand cmd = new MySqlCommand(command); | ||
306 | |||
307 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
308 | |||
309 | // TODO: distance-sort results | ||
310 | return RunCommand(cmd); | ||
311 | } | ||
286 | } | 312 | } |
287 | } | 313 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index 3cb0010..aa69d68 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs | |||
@@ -35,150 +35,50 @@ using MySql.Data.MySqlClient; | |||
35 | 35 | ||
36 | namespace OpenSim.Data.MySQL | 36 | namespace OpenSim.Data.MySQL |
37 | { | 37 | { |
38 | public class MySqlUserAccountData : MySqlFramework, IUserAccountData | 38 | public class MySqlUserAccountData : MySQLGenericTableHandler<UserAccountData>, IUserAccountData |
39 | { | 39 | { |
40 | private string m_Realm; | ||
41 | private List<string> m_ColumnNames; | ||
42 | // private string m_connectionString; | ||
43 | |||
44 | public MySqlUserAccountData(string connectionString, string realm) | 40 | public MySqlUserAccountData(string connectionString, string realm) |
45 | : base(connectionString) | 41 | : base(connectionString, realm, "UserAccount") |
46 | { | ||
47 | m_Realm = realm; | ||
48 | m_connectionString = connectionString; | ||
49 | |||
50 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
51 | { | ||
52 | dbcon.Open(); | ||
53 | Migration m = new Migration(dbcon, GetType().Assembly, "UserStore"); | ||
54 | m.Update(); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | public List<UserAccountData> Query(UUID principalID, UUID scopeID, string query) | ||
59 | { | 42 | { |
60 | return null; | ||
61 | } | 43 | } |
62 | 44 | ||
63 | public UserAccountData Get(UUID principalID, UUID scopeID) | 45 | public UserAccountData[] GetUsers(UUID scopeID, string query) |
64 | { | 46 | { |
65 | UserAccountData ret = new UserAccountData(); | 47 | string[] words = query.Split(new char[] {' '}); |
66 | ret.Data = new Dictionary<string, object>(); | ||
67 | |||
68 | string command = "select * from `"+m_Realm+"` where UUID = ?principalID"; | ||
69 | if (scopeID != UUID.Zero) | ||
70 | command += " and ScopeID = ?scopeID"; | ||
71 | 48 | ||
72 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 49 | for (int i = 0 ; i < words.Length ; i++) |
73 | { | 50 | { |
74 | dbcon.Open(); | 51 | if (words[i].Length < 3) |
75 | MySqlCommand cmd = new MySqlCommand(command, dbcon); | ||
76 | |||
77 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | ||
78 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
79 | |||
80 | IDataReader result = cmd.ExecuteReader(); | ||
81 | |||
82 | if (result.Read()) | ||
83 | { | 52 | { |
84 | ret.PrincipalID = principalID; | 53 | if (i != words.Length - 1) |
85 | UUID scope; | 54 | Array.Copy(words, i + 1, words, i, words.Length - i - 1); |
86 | UUID.TryParse(result["ScopeID"].ToString(), out scope); | 55 | Array.Resize(ref words, words.Length - 1); |
87 | ret.ScopeID = scope; | ||
88 | |||
89 | if (m_ColumnNames == null) | ||
90 | { | ||
91 | m_ColumnNames = new List<string>(); | ||
92 | |||
93 | DataTable schemaTable = result.GetSchemaTable(); | ||
94 | foreach (DataRow row in schemaTable.Rows) | ||
95 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
96 | } | ||
97 | |||
98 | foreach (string s in m_ColumnNames) | ||
99 | { | ||
100 | if (s == "UUID") | ||
101 | continue; | ||
102 | if (s == "ScopeID") | ||
103 | continue; | ||
104 | |||
105 | ret.Data[s] = result[s].ToString(); | ||
106 | } | ||
107 | |||
108 | return ret; | ||
109 | } | ||
110 | else | ||
111 | { | ||
112 | return null; | ||
113 | } | 56 | } |
114 | } | 57 | } |
115 | } | ||
116 | 58 | ||
117 | public bool Store(UserAccountData data) | 59 | if (words.Length == 0) |
118 | { | 60 | return new UserAccountData[0]; |
119 | if (data.Data.ContainsKey("UUID")) | ||
120 | data.Data.Remove("UUID"); | ||
121 | if (data.Data.ContainsKey("ScopeID")) | ||
122 | data.Data.Remove("ScopeID"); | ||
123 | |||
124 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | ||
125 | |||
126 | using (MySqlCommand cmd = new MySqlCommand()) | ||
127 | { | ||
128 | string update = "update `" + m_Realm + "` set "; | ||
129 | bool first = true; | ||
130 | foreach (string field in fields) | ||
131 | { | ||
132 | if (!first) | ||
133 | update += ", "; | ||
134 | update += "`" + field + "` = ?" + field; | ||
135 | 61 | ||
136 | first = false; | 62 | if (words.Length > 2) |
63 | return new UserAccountData[0]; | ||
137 | 64 | ||
138 | cmd.Parameters.AddWithValue("?" + field, data.Data[field]); | 65 | MySqlCommand cmd = new MySqlCommand(); |
139 | } | ||
140 | |||
141 | update += " where UUID = ?principalID"; | ||
142 | |||
143 | if (data.ScopeID != UUID.Zero) | ||
144 | update += " and ScopeID = ?scopeID"; | ||
145 | 66 | ||
146 | cmd.CommandText = update; | 67 | if (words.Length == 1) |
147 | cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); | 68 | { |
148 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); | 69 | cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search)", m_Realm); |
149 | 70 | cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); | |
150 | if (ExecuteNonQuery(cmd) < 1) | 71 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); |
151 | { | ||
152 | string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + | ||
153 | String.Join("`, `", fields) + | ||
154 | "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; | ||
155 | |||
156 | cmd.CommandText = insert; | ||
157 | |||
158 | if (ExecuteNonQuery(cmd) < 1) | ||
159 | { | ||
160 | cmd.Dispose(); | ||
161 | return false; | ||
162 | } | ||
163 | } | ||
164 | } | 72 | } |
165 | 73 | else | |
166 | return true; | ||
167 | } | ||
168 | |||
169 | public bool SetDataItem(UUID principalID, string item, string value) | ||
170 | { | ||
171 | using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + | ||
172 | item + "` = ?" + item + " where UUID = ?UUID")) | ||
173 | { | 74 | { |
174 | cmd.Parameters.AddWithValue("?" + item, value); | 75 | cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm); |
175 | cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); | 76 | cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); |
176 | 77 | cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); | |
177 | if (ExecuteNonQuery(cmd) > 0) | 78 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); |
178 | return true; | ||
179 | } | 79 | } |
180 | 80 | ||
181 | return false; | 81 | return DoQuery(cmd); |
182 | } | 82 | } |
183 | } | 83 | } |
184 | } | 84 | } |
diff --git a/OpenSim/Data/MySQL/Resources/001_Avatar.sql b/OpenSim/Data/MySQL/Resources/001_Avatar.sql new file mode 100644 index 0000000..27a3072 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_Avatar.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE TABLE Avatars (PrincipalID CHAR(36) NOT NULL, Name VARCHAR(32) NOT NULL, Value VARCHAR(255) NOT NULL DEFAULT '', PRIMARY KEY(PrincipalID, Name), KEY(PrincipalID)); | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/001_Friends.sql b/OpenSim/Data/MySQL/Resources/001_Friends.sql new file mode 100644 index 0000000..e158a2c --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_Friends.sql | |||
@@ -0,0 +1,9 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE TABLE `Friends` ( | ||
4 | `PrincipalID` CHAR(36) NOT NULL, | ||
5 | `FriendID` VARCHAR(255) NOT NULL, | ||
6 | `Flags` CHAR(16) NOT NULL DEFAULT '0' | ||
7 | ) ENGINE=InnoDB; | ||
8 | |||
9 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/001_FriendsStore.sql b/OpenSim/Data/MySQL/Resources/001_FriendsStore.sql new file mode 100644 index 0000000..da2c59c --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_FriendsStore.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE TABLE `Friends` (`PrincipalID` CHAR(36) NOT NULL, `Friend` VARCHAR(255) NOT NULL, `Flags` VARCHAR(16) NOT NULL DEFAULT 0, `Offered` VARCHAR(32) NOT NULL DEFAULT 0, PRIMARY KEY(`PrincipalID`, `Friend`), KEY(`PrincipalID`)); | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/001_Presence.sql b/OpenSim/Data/MySQL/Resources/001_Presence.sql new file mode 100644 index 0000000..b8abaf7 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_Presence.sql | |||
@@ -0,0 +1,15 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE TABLE `Presence` ( | ||
4 | `UserID` VARCHAR(255) NOT NULL, | ||
5 | `RegionID` CHAR(36) NOT NULL, | ||
6 | `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
7 | `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | ||
8 | `Online` CHAR(5) NOT NULL DEFAULT 'false', | ||
9 | `Login` CHAR(16) NOT NULL DEFAULT '0', | ||
10 | `Logout` CHAR(16) NOT NULL DEFAULT '0', | ||
11 | `Position` CHAR(64) NOT NULL DEFAULT '<0,0,0>', | ||
12 | `LookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>' | ||
13 | ) ENGINE=InnoDB; | ||
14 | |||
15 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/001_UserAccount.sql b/OpenSim/Data/MySQL/Resources/001_UserAccount.sql new file mode 100644 index 0000000..07da571 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_UserAccount.sql | |||
@@ -0,0 +1,13 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE TABLE `UserAccounts` ( | ||
4 | `PrincipalID` CHAR(36) NOT NULL, | ||
5 | `ScopeID` CHAR(36) NOT NULL, | ||
6 | `FirstName` VARCHAR(64) NOT NULL, | ||
7 | `LastName` VARCHAR(64) NOT NULL, | ||
8 | `Email` VARCHAR(64), | ||
9 | `ServiceURLs` TEXT, | ||
10 | `Created` INT(11) | ||
11 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
12 | |||
13 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/002_AuthStore.sql b/OpenSim/Data/MySQL/Resources/002_AuthStore.sql new file mode 100644 index 0000000..dc7dfe0 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_AuthStore.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | INSERT INTO auth (UUID, passwordHash, passwordSalt, webLoginKey) SELECT `UUID` AS UUID, `passwordHash` AS passwordHash, `passwordSalt` AS passwordSalt, `webLoginKey` AS webLoginKey FROM users; | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/002_Friends.sql b/OpenSim/Data/MySQL/Resources/002_Friends.sql new file mode 100644 index 0000000..5ff6438 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_Friends.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | INSERT INTO Friends (PrincipalID, FriendID, Flags) SELECT ownerID, friendID, friendPerms FROM userfriends; | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/002_FriendsStore.sql b/OpenSim/Data/MySQL/Resources/002_FriendsStore.sql new file mode 100644 index 0000000..a363867 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_FriendsStore.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | INSERT INTO `Friends` SELECT `ownerID`, `friendID`, `friendPerms`, 0 FROM `userfriends`; | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/002_Presence.sql b/OpenSim/Data/MySQL/Resources/002_Presence.sql new file mode 100644 index 0000000..e65f105 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_Presence.sql | |||
@@ -0,0 +1,7 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | ALTER TABLE Presence ADD COLUMN `HomeRegionID` CHAR(36) NOT NULL; | ||
4 | ALTER TABLE Presence ADD COLUMN `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; | ||
5 | ALTER TABLE Presence ADD COLUMN `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; | ||
6 | |||
7 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/002_UserAccount.sql b/OpenSim/Data/MySQL/Resources/002_UserAccount.sql new file mode 100644 index 0000000..ad2ddda --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_UserAccount.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT `UUID` AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID, username AS FirstName, lastname AS LastName, email as Email, CONCAT('AssetServerURI=', userAssetURI, ' InventoryServerURI=', userInventoryURI, ' GatewayURI= HomeURI=') AS ServiceURLs, created as Created FROM users; | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/003_AuthStore.sql b/OpenSim/Data/MySQL/Resources/003_AuthStore.sql new file mode 100644 index 0000000..af9ffe6 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_AuthStore.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | ALTER TABLE `auth` ADD COLUMN `accountType` VARCHAR(32) NOT NULL DEFAULT 'UserAccount'; | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/003_Presence.sql b/OpenSim/Data/MySQL/Resources/003_Presence.sql new file mode 100644 index 0000000..0efefa8 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_Presence.sql | |||
@@ -0,0 +1,6 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE UNIQUE INDEX SessionID ON Presence(SessionID); | ||
4 | CREATE INDEX UserID ON Presence(UserID); | ||
5 | |||
6 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/003_UserAccount.sql b/OpenSim/Data/MySQL/Resources/003_UserAccount.sql new file mode 100644 index 0000000..e42d93b --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_UserAccount.sql | |||
@@ -0,0 +1,9 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE UNIQUE INDEX PrincipalID ON UserAccounts(PrincipalID); | ||
4 | CREATE INDEX Email ON UserAccounts(Email); | ||
5 | CREATE INDEX FirstName ON UserAccounts(FirstName); | ||
6 | CREATE INDEX LastName ON UserAccounts(LastName); | ||
7 | CREATE INDEX Name ON UserAccounts(FirstName,LastName); | ||
8 | |||
9 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/004_UserAccount.sql b/OpenSim/Data/MySQL/Resources/004_UserAccount.sql new file mode 100644 index 0000000..8abcd53 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/004_UserAccount.sql | |||
@@ -0,0 +1,8 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | ALTER TABLE UserAccounts ADD COLUMN UserLevel integer NOT NULL DEFAULT 0; | ||
4 | ALTER TABLE UserAccounts ADD COLUMN UserFlags integer NOT NULL DEFAULT 0; | ||
5 | ALTER TABLE UserAccounts ADD COLUMN UserTitle varchar(64) NOT NULL DEFAULT ''; | ||
6 | |||
7 | COMMIT; | ||
8 | |||
diff --git a/OpenSim/Data/MySQL/Resources/005_GridStore.sql b/OpenSim/Data/MySQL/Resources/005_GridStore.sql new file mode 100644 index 0000000..835ba89 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/005_GridStore.sql | |||
@@ -0,0 +1,6 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | ALTER TABLE `regions` ADD COLUMN `flags` integer NOT NULL DEFAULT 0; | ||
4 | CREATE INDEX flags ON regions(flags); | ||
5 | |||
6 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/006_GridStore.sql b/OpenSim/Data/MySQL/Resources/006_GridStore.sql new file mode 100644 index 0000000..91322d6 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/006_GridStore.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | ALTER TABLE `regions` ADD COLUMN `last_seen` integer NOT NULL DEFAULT 0; | ||
4 | |||
5 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/007_GridStore.sql b/OpenSim/Data/MySQL/Resources/007_GridStore.sql new file mode 100644 index 0000000..dbec584 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/007_GridStore.sql | |||
@@ -0,0 +1,7 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | ALTER TABLE `regions` ADD COLUMN `PrincipalID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; | ||
4 | ALTER TABLE `regions` ADD COLUMN `Token` varchar(255) NOT NULL; | ||
5 | |||
6 | COMMIT; | ||
7 | |||
diff --git a/OpenSim/Data/Null/NullAuthenticationData.cs b/OpenSim/Data/Null/NullAuthenticationData.cs new file mode 100644 index 0000000..3fb3105 --- /dev/null +++ b/OpenSim/Data/Null/NullAuthenticationData.cs | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Data; | ||
34 | |||
35 | namespace OpenSim.Data.Null | ||
36 | { | ||
37 | public class NullAuthenticationData : IAuthenticationData | ||
38 | { | ||
39 | private static Dictionary<UUID, AuthenticationData> m_DataByUUID = new Dictionary<UUID, AuthenticationData>(); | ||
40 | private static Dictionary<UUID, string> m_Tokens = new Dictionary<UUID, string>(); | ||
41 | |||
42 | public NullAuthenticationData(string connectionString, string realm) | ||
43 | { | ||
44 | } | ||
45 | |||
46 | public AuthenticationData Get(UUID principalID) | ||
47 | { | ||
48 | if (m_DataByUUID.ContainsKey(principalID)) | ||
49 | return m_DataByUUID[principalID]; | ||
50 | |||
51 | return null; | ||
52 | } | ||
53 | |||
54 | public bool Store(AuthenticationData data) | ||
55 | { | ||
56 | m_DataByUUID[data.PrincipalID] = data; | ||
57 | return true; | ||
58 | } | ||
59 | |||
60 | public bool SetDataItem(UUID principalID, string item, string value) | ||
61 | { | ||
62 | // Not implemented | ||
63 | return false; | ||
64 | } | ||
65 | |||
66 | public bool SetToken(UUID principalID, string token, int lifetime) | ||
67 | { | ||
68 | m_Tokens[principalID] = token; | ||
69 | return true; | ||
70 | } | ||
71 | |||
72 | public bool CheckToken(UUID principalID, string token, int lifetime) | ||
73 | { | ||
74 | if (m_Tokens.ContainsKey(principalID)) | ||
75 | return m_Tokens[principalID] == token; | ||
76 | |||
77 | return false; | ||
78 | } | ||
79 | |||
80 | } | ||
81 | } | ||
diff --git a/OpenSim/Data/Null/NullAvatarData.cs b/OpenSim/Data/Null/NullAvatarData.cs new file mode 100644 index 0000000..c81ba43 --- /dev/null +++ b/OpenSim/Data/Null/NullAvatarData.cs | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Data; | ||
34 | |||
35 | namespace OpenSim.Data.Null | ||
36 | { | ||
37 | public class NullAvatarData : IAvatarData | ||
38 | { | ||
39 | private static Dictionary<UUID, AvatarBaseData> m_DataByUUID = new Dictionary<UUID, AvatarBaseData>(); | ||
40 | |||
41 | public NullAvatarData(string connectionString, string realm) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | public AvatarBaseData[] Get(string field, string val) | ||
46 | { | ||
47 | if (field == "PrincipalID") | ||
48 | { | ||
49 | UUID id = UUID.Zero; | ||
50 | if (UUID.TryParse(val, out id)) | ||
51 | if (m_DataByUUID.ContainsKey(id)) | ||
52 | return new AvatarBaseData[] { m_DataByUUID[id] }; | ||
53 | } | ||
54 | |||
55 | // Fail | ||
56 | return new AvatarBaseData[0]; | ||
57 | } | ||
58 | |||
59 | public bool Store(AvatarBaseData data) | ||
60 | { | ||
61 | m_DataByUUID[data.PrincipalID] = data; | ||
62 | return true; | ||
63 | } | ||
64 | |||
65 | public bool Delete(UUID principalID, string name) | ||
66 | { | ||
67 | if (m_DataByUUID.ContainsKey(principalID) && m_DataByUUID[principalID].Data.ContainsKey(name)) | ||
68 | { | ||
69 | m_DataByUUID[principalID].Data.Remove(name); | ||
70 | return true; | ||
71 | } | ||
72 | |||
73 | return false; | ||
74 | } | ||
75 | |||
76 | public bool Delete(string field, string val) | ||
77 | { | ||
78 | if (field == "PrincipalID") | ||
79 | { | ||
80 | UUID id = UUID.Zero; | ||
81 | if (UUID.TryParse(val, out id)) | ||
82 | if (m_DataByUUID.ContainsKey(id)) | ||
83 | { | ||
84 | m_DataByUUID.Remove(id); | ||
85 | return true; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | return false; | ||
90 | } | ||
91 | |||
92 | } | ||
93 | } | ||
diff --git a/OpenSim/Data/Null/NullPresenceData.cs b/OpenSim/Data/Null/NullPresenceData.cs new file mode 100644 index 0000000..40700cf --- /dev/null +++ b/OpenSim/Data/Null/NullPresenceData.cs | |||
@@ -0,0 +1,257 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Data; | ||
34 | |||
35 | namespace OpenSim.Data.Null | ||
36 | { | ||
37 | public class NullPresenceData : IPresenceData | ||
38 | { | ||
39 | private static NullPresenceData Instance; | ||
40 | |||
41 | Dictionary<UUID, PresenceData> m_presenceData = new Dictionary<UUID, PresenceData>(); | ||
42 | |||
43 | public NullPresenceData(string connectionString, string realm) | ||
44 | { | ||
45 | if (Instance == null) | ||
46 | Instance = this; | ||
47 | |||
48 | //Console.WriteLine("[XXX] NullRegionData constructor"); | ||
49 | // Let's stick in a test presence | ||
50 | PresenceData p = new PresenceData(); | ||
51 | p.SessionID = UUID.Zero; | ||
52 | p.UserID = UUID.Zero.ToString(); | ||
53 | p.Data = new Dictionary<string, string>(); | ||
54 | p.Data["Online"] = "true"; | ||
55 | m_presenceData.Add(UUID.Zero, p); | ||
56 | } | ||
57 | |||
58 | public bool Store(PresenceData data) | ||
59 | { | ||
60 | if (Instance != this) | ||
61 | return Instance.Store(data); | ||
62 | |||
63 | m_presenceData[data.SessionID] = data; | ||
64 | return true; | ||
65 | } | ||
66 | |||
67 | public PresenceData Get(UUID sessionID) | ||
68 | { | ||
69 | if (Instance != this) | ||
70 | return Instance.Get(sessionID); | ||
71 | |||
72 | if (m_presenceData.ContainsKey(sessionID)) | ||
73 | return m_presenceData[sessionID]; | ||
74 | |||
75 | return null; | ||
76 | } | ||
77 | |||
78 | public void LogoutRegionAgents(UUID regionID) | ||
79 | { | ||
80 | if (Instance != this) | ||
81 | { | ||
82 | Instance.LogoutRegionAgents(regionID); | ||
83 | return; | ||
84 | } | ||
85 | |||
86 | List<UUID> toBeDeleted = new List<UUID>(); | ||
87 | foreach (KeyValuePair<UUID, PresenceData> kvp in m_presenceData) | ||
88 | if (kvp.Value.RegionID == regionID) | ||
89 | toBeDeleted.Add(kvp.Key); | ||
90 | |||
91 | foreach (UUID u in toBeDeleted) | ||
92 | m_presenceData.Remove(u); | ||
93 | } | ||
94 | |||
95 | public bool ReportAgent(UUID sessionID, UUID regionID, string position, string lookAt) | ||
96 | { | ||
97 | if (Instance != this) | ||
98 | return Instance.ReportAgent(sessionID, regionID, position, lookAt); | ||
99 | if (m_presenceData.ContainsKey(sessionID)) | ||
100 | { | ||
101 | m_presenceData[sessionID].RegionID = regionID; | ||
102 | m_presenceData[sessionID].Data["Position"] = position; | ||
103 | m_presenceData[sessionID].Data["LookAt"] = lookAt; | ||
104 | return true; | ||
105 | } | ||
106 | |||
107 | return false; | ||
108 | } | ||
109 | |||
110 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
111 | { | ||
112 | if (Instance != this) | ||
113 | return Instance.SetHomeLocation(userID, regionID, position, lookAt); | ||
114 | |||
115 | bool foundone = false; | ||
116 | foreach (PresenceData p in m_presenceData.Values) | ||
117 | { | ||
118 | if (p.UserID == userID) | ||
119 | { | ||
120 | p.Data["HomeRegionID"] = regionID.ToString(); | ||
121 | p.Data["HomePosition"] = position.ToString(); | ||
122 | p.Data["HomeLookAt"] = lookAt.ToString(); | ||
123 | foundone = true; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | return foundone; | ||
128 | } | ||
129 | |||
130 | public PresenceData[] Get(string field, string data) | ||
131 | { | ||
132 | if (Instance != this) | ||
133 | return Instance.Get(field, data); | ||
134 | |||
135 | List<PresenceData> presences = new List<PresenceData>(); | ||
136 | if (field == "UserID") | ||
137 | { | ||
138 | foreach (PresenceData p in m_presenceData.Values) | ||
139 | if (p.UserID == data) | ||
140 | presences.Add(p); | ||
141 | return presences.ToArray(); | ||
142 | } | ||
143 | else if (field == "SessionID") | ||
144 | { | ||
145 | UUID session = UUID.Zero; | ||
146 | if (!UUID.TryParse(data, out session)) | ||
147 | return presences.ToArray(); | ||
148 | |||
149 | if (m_presenceData.ContainsKey(session)) | ||
150 | { | ||
151 | presences.Add(m_presenceData[session]); | ||
152 | return presences.ToArray(); | ||
153 | } | ||
154 | } | ||
155 | else if (field == "RegionID") | ||
156 | { | ||
157 | UUID region = UUID.Zero; | ||
158 | if (!UUID.TryParse(data, out region)) | ||
159 | return presences.ToArray(); | ||
160 | foreach (PresenceData p in m_presenceData.Values) | ||
161 | if (p.RegionID == region) | ||
162 | presences.Add(p); | ||
163 | return presences.ToArray(); | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | foreach (PresenceData p in m_presenceData.Values) | ||
168 | { | ||
169 | if (p.Data.ContainsKey(field) && p.Data[field] == data) | ||
170 | presences.Add(p); | ||
171 | } | ||
172 | return presences.ToArray(); | ||
173 | } | ||
174 | |||
175 | return presences.ToArray(); | ||
176 | } | ||
177 | |||
178 | public void Prune(string userID) | ||
179 | { | ||
180 | if (Instance != this) | ||
181 | { | ||
182 | Instance.Prune(userID); | ||
183 | return; | ||
184 | } | ||
185 | |||
186 | List<UUID> deleteSessions = new List<UUID>(); | ||
187 | int online = 0; | ||
188 | |||
189 | foreach (KeyValuePair<UUID, PresenceData> kvp in m_presenceData) | ||
190 | { | ||
191 | bool on = false; | ||
192 | if (bool.TryParse(kvp.Value.Data["Online"], out on) && on) | ||
193 | online++; | ||
194 | else | ||
195 | deleteSessions.Add(kvp.Key); | ||
196 | } | ||
197 | if (online == 0 && deleteSessions.Count > 0) | ||
198 | deleteSessions.RemoveAt(0); | ||
199 | |||
200 | foreach (UUID s in deleteSessions) | ||
201 | m_presenceData.Remove(s); | ||
202 | |||
203 | } | ||
204 | |||
205 | public bool Delete(string field, string data) | ||
206 | { | ||
207 | if (Instance != this) | ||
208 | return Delete(field, data); | ||
209 | |||
210 | List<UUID> presences = new List<UUID>(); | ||
211 | if (field == "UserID") | ||
212 | { | ||
213 | foreach (KeyValuePair<UUID, PresenceData> p in m_presenceData) | ||
214 | if (p.Value.UserID == data) | ||
215 | presences.Add(p.Key); | ||
216 | } | ||
217 | else if (field == "SessionID") | ||
218 | { | ||
219 | UUID session = UUID.Zero; | ||
220 | if (UUID.TryParse(data, out session)) | ||
221 | { | ||
222 | if (m_presenceData.ContainsKey(session)) | ||
223 | { | ||
224 | presences.Add(session); | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | else if (field == "RegionID") | ||
229 | { | ||
230 | UUID region = UUID.Zero; | ||
231 | if (UUID.TryParse(data, out region)) | ||
232 | { | ||
233 | foreach (KeyValuePair<UUID, PresenceData> p in m_presenceData) | ||
234 | if (p.Value.RegionID == region) | ||
235 | presences.Add(p.Key); | ||
236 | } | ||
237 | } | ||
238 | else | ||
239 | { | ||
240 | foreach (KeyValuePair<UUID, PresenceData> p in m_presenceData) | ||
241 | { | ||
242 | if (p.Value.Data.ContainsKey(field) && p.Value.Data[field] == data) | ||
243 | presences.Add(p.Key); | ||
244 | } | ||
245 | } | ||
246 | |||
247 | foreach (UUID u in presences) | ||
248 | m_presenceData.Remove(u); | ||
249 | |||
250 | if (presences.Count == 0) | ||
251 | return false; | ||
252 | |||
253 | return true; | ||
254 | } | ||
255 | |||
256 | } | ||
257 | } | ||
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index e8263ea..5b9898c 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs | |||
@@ -31,20 +31,31 @@ using System.Collections.Generic; | |||
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Data; | 33 | using OpenSim.Data; |
34 | using System.Reflection; | ||
35 | using log4net; | ||
34 | 36 | ||
35 | namespace OpenSim.Data.Null | 37 | namespace OpenSim.Data.Null |
36 | { | 38 | { |
37 | public class NullRegionData : IRegionData | 39 | public class NullRegionData : IRegionData |
38 | { | 40 | { |
41 | private static NullRegionData Instance = null; | ||
42 | |||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
39 | Dictionary<UUID, RegionData> m_regionData = new Dictionary<UUID, RegionData>(); | 45 | Dictionary<UUID, RegionData> m_regionData = new Dictionary<UUID, RegionData>(); |
40 | 46 | ||
41 | public NullRegionData(string connectionString, string realm) | 47 | public NullRegionData(string connectionString, string realm) |
42 | { | 48 | { |
49 | if (Instance == null) | ||
50 | Instance = this; | ||
43 | //Console.WriteLine("[XXX] NullRegionData constructor"); | 51 | //Console.WriteLine("[XXX] NullRegionData constructor"); |
44 | } | 52 | } |
45 | 53 | ||
46 | public List<RegionData> Get(string regionName, UUID scopeID) | 54 | public List<RegionData> Get(string regionName, UUID scopeID) |
47 | { | 55 | { |
56 | if (Instance != this) | ||
57 | return Instance.Get(regionName, scopeID); | ||
58 | |||
48 | List<RegionData> ret = new List<RegionData>(); | 59 | List<RegionData> ret = new List<RegionData>(); |
49 | 60 | ||
50 | foreach (RegionData r in m_regionData.Values) | 61 | foreach (RegionData r in m_regionData.Values) |
@@ -69,6 +80,9 @@ namespace OpenSim.Data.Null | |||
69 | 80 | ||
70 | public RegionData Get(int posX, int posY, UUID scopeID) | 81 | public RegionData Get(int posX, int posY, UUID scopeID) |
71 | { | 82 | { |
83 | if (Instance != this) | ||
84 | return Instance.Get(posX, posY, scopeID); | ||
85 | |||
72 | List<RegionData> ret = new List<RegionData>(); | 86 | List<RegionData> ret = new List<RegionData>(); |
73 | 87 | ||
74 | foreach (RegionData r in m_regionData.Values) | 88 | foreach (RegionData r in m_regionData.Values) |
@@ -85,6 +99,9 @@ namespace OpenSim.Data.Null | |||
85 | 99 | ||
86 | public RegionData Get(UUID regionID, UUID scopeID) | 100 | public RegionData Get(UUID regionID, UUID scopeID) |
87 | { | 101 | { |
102 | if (Instance != this) | ||
103 | return Instance.Get(regionID, scopeID); | ||
104 | |||
88 | if (m_regionData.ContainsKey(regionID)) | 105 | if (m_regionData.ContainsKey(regionID)) |
89 | return m_regionData[regionID]; | 106 | return m_regionData[regionID]; |
90 | 107 | ||
@@ -93,6 +110,9 @@ namespace OpenSim.Data.Null | |||
93 | 110 | ||
94 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) | 111 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) |
95 | { | 112 | { |
113 | if (Instance != this) | ||
114 | return Instance.Get(startX, startY, endX, endY, scopeID); | ||
115 | |||
96 | List<RegionData> ret = new List<RegionData>(); | 116 | List<RegionData> ret = new List<RegionData>(); |
97 | 117 | ||
98 | foreach (RegionData r in m_regionData.Values) | 118 | foreach (RegionData r in m_regionData.Values) |
@@ -106,6 +126,9 @@ namespace OpenSim.Data.Null | |||
106 | 126 | ||
107 | public bool Store(RegionData data) | 127 | public bool Store(RegionData data) |
108 | { | 128 | { |
129 | if (Instance != this) | ||
130 | return Instance.Store(data); | ||
131 | |||
109 | m_regionData[data.RegionID] = data; | 132 | m_regionData[data.RegionID] = data; |
110 | 133 | ||
111 | return true; | 134 | return true; |
@@ -113,6 +136,9 @@ namespace OpenSim.Data.Null | |||
113 | 136 | ||
114 | public bool SetDataItem(UUID regionID, string item, string value) | 137 | public bool SetDataItem(UUID regionID, string item, string value) |
115 | { | 138 | { |
139 | if (Instance != this) | ||
140 | return Instance.SetDataItem(regionID, item, value); | ||
141 | |||
116 | if (!m_regionData.ContainsKey(regionID)) | 142 | if (!m_regionData.ContainsKey(regionID)) |
117 | return false; | 143 | return false; |
118 | 144 | ||
@@ -123,6 +149,9 @@ namespace OpenSim.Data.Null | |||
123 | 149 | ||
124 | public bool Delete(UUID regionID) | 150 | public bool Delete(UUID regionID) |
125 | { | 151 | { |
152 | if (Instance != this) | ||
153 | return Instance.Delete(regionID); | ||
154 | |||
126 | if (!m_regionData.ContainsKey(regionID)) | 155 | if (!m_regionData.ContainsKey(regionID)) |
127 | return false; | 156 | return false; |
128 | 157 | ||
@@ -130,5 +159,37 @@ namespace OpenSim.Data.Null | |||
130 | 159 | ||
131 | return true; | 160 | return true; |
132 | } | 161 | } |
162 | |||
163 | public List<RegionData> GetDefaultRegions(UUID scopeID) | ||
164 | { | ||
165 | if (Instance != this) | ||
166 | return Instance.GetDefaultRegions(scopeID); | ||
167 | |||
168 | List<RegionData> ret = new List<RegionData>(); | ||
169 | |||
170 | foreach (RegionData r in m_regionData.Values) | ||
171 | { | ||
172 | if ((Convert.ToInt32(r.Data["flags"]) & 1) != 0) | ||
173 | ret.Add(r); | ||
174 | } | ||
175 | |||
176 | return ret; | ||
177 | } | ||
178 | |||
179 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) | ||
180 | { | ||
181 | if (Instance != this) | ||
182 | return Instance.GetFallbackRegions(scopeID, x, y); | ||
183 | |||
184 | List<RegionData> ret = new List<RegionData>(); | ||
185 | |||
186 | foreach (RegionData r in m_regionData.Values) | ||
187 | { | ||
188 | if ((Convert.ToInt32(r.Data["flags"]) & 2) != 0) | ||
189 | ret.Add(r); | ||
190 | } | ||
191 | |||
192 | return ret; | ||
193 | } | ||
133 | } | 194 | } |
134 | } | 195 | } |
diff --git a/OpenSim/Data/Null/NullUserAccountData.cs b/OpenSim/Data/Null/NullUserAccountData.cs new file mode 100644 index 0000000..fc2c5d5 --- /dev/null +++ b/OpenSim/Data/Null/NullUserAccountData.cs | |||
@@ -0,0 +1,139 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Data; | ||
34 | |||
35 | namespace OpenSim.Data.Null | ||
36 | { | ||
37 | public class NullUserAccountData : IUserAccountData | ||
38 | { | ||
39 | private static Dictionary<UUID, UserAccountData> m_DataByUUID = new Dictionary<UUID, UserAccountData>(); | ||
40 | private static Dictionary<string, UserAccountData> m_DataByName = new Dictionary<string, UserAccountData>(); | ||
41 | private static Dictionary<string, UserAccountData> m_DataByEmail = new Dictionary<string, UserAccountData>(); | ||
42 | |||
43 | public NullUserAccountData(string connectionString, string realm) | ||
44 | { | ||
45 | } | ||
46 | |||
47 | /// <summary> | ||
48 | /// Tries to implement the Get [] semantics, but it cuts corners like crazy. | ||
49 | /// Specifically, it relies on the knowledge that the only Gets used are | ||
50 | /// keyed on PrincipalID, Email, and FirstName+LastName. | ||
51 | /// </summary> | ||
52 | /// <param name="fields"></param> | ||
53 | /// <param name="values"></param> | ||
54 | /// <returns></returns> | ||
55 | public UserAccountData[] Get(string[] fields, string[] values) | ||
56 | { | ||
57 | List<string> fieldsLst = new List<string>(fields); | ||
58 | if (fieldsLst.Contains("PrincipalID")) | ||
59 | { | ||
60 | int i = fieldsLst.IndexOf("PrincipalID"); | ||
61 | UUID id = UUID.Zero; | ||
62 | if (UUID.TryParse(values[i], out id)) | ||
63 | if (m_DataByUUID.ContainsKey(id)) | ||
64 | return new UserAccountData[] { m_DataByUUID[id] }; | ||
65 | } | ||
66 | if (fieldsLst.Contains("FirstName") && fieldsLst.Contains("LastName")) | ||
67 | { | ||
68 | int findex = fieldsLst.IndexOf("FirstName"); | ||
69 | int lindex = fieldsLst.IndexOf("LastName"); | ||
70 | if (m_DataByName.ContainsKey(values[findex] + " " + values[lindex])) | ||
71 | return new UserAccountData[] { m_DataByName[values[findex] + " " + values[lindex]] }; | ||
72 | } | ||
73 | if (fieldsLst.Contains("Email")) | ||
74 | { | ||
75 | int i = fieldsLst.IndexOf("Email"); | ||
76 | if (m_DataByEmail.ContainsKey(values[i])) | ||
77 | return new UserAccountData[] { m_DataByEmail[values[i]] }; | ||
78 | } | ||
79 | |||
80 | // Fail | ||
81 | return new UserAccountData[0]; | ||
82 | } | ||
83 | |||
84 | public bool Store(UserAccountData data) | ||
85 | { | ||
86 | if (data == null) | ||
87 | return false; | ||
88 | |||
89 | m_DataByUUID[data.PrincipalID] = data; | ||
90 | m_DataByName[data.FirstName + " " + data.LastName] = data; | ||
91 | if (data.Data.ContainsKey("Email") && data.Data["Email"] != string.Empty) | ||
92 | m_DataByEmail[data.Data["Email"]] = data; | ||
93 | |||
94 | return true; | ||
95 | } | ||
96 | |||
97 | public UserAccountData[] GetUsers(UUID scopeID, string query) | ||
98 | { | ||
99 | string[] words = query.Split(new char[] { ' ' }); | ||
100 | |||
101 | for (int i = 0; i < words.Length; i++) | ||
102 | { | ||
103 | if (words[i].Length < 3) | ||
104 | { | ||
105 | if (i != words.Length - 1) | ||
106 | Array.Copy(words, i + 1, words, i, words.Length - i - 1); | ||
107 | Array.Resize(ref words, words.Length - 1); | ||
108 | } | ||
109 | } | ||
110 | |||
111 | if (words.Length == 0) | ||
112 | return new UserAccountData[0]; | ||
113 | |||
114 | if (words.Length > 2) | ||
115 | return new UserAccountData[0]; | ||
116 | |||
117 | List<string> lst = new List<string>(m_DataByName.Keys); | ||
118 | if (words.Length == 1) | ||
119 | { | ||
120 | lst = lst.FindAll(delegate(string s) { return s.StartsWith(words[0]); }); | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | lst = lst.FindAll(delegate(string s) { return s.Contains(words[0]) || s.Contains(words[1]); }); | ||
125 | } | ||
126 | |||
127 | if (lst == null || (lst != null && lst.Count == 0)) | ||
128 | return new UserAccountData[0]; | ||
129 | |||
130 | UserAccountData[] result = new UserAccountData[lst.Count]; | ||
131 | int n = 0; | ||
132 | foreach (string key in lst) | ||
133 | result[n++] = m_DataByName[key]; | ||
134 | |||
135 | return result; | ||
136 | } | ||
137 | |||
138 | } | ||
139 | } | ||
diff --git a/OpenSim/Data/RegionProfileData.cs b/OpenSim/Data/RegionProfileData.cs index 86d7f6b..90713d2 100644 --- a/OpenSim/Data/RegionProfileData.cs +++ b/OpenSim/Data/RegionProfileData.cs | |||
@@ -136,7 +136,6 @@ namespace OpenSim.Data | |||
136 | /// </summary> | 136 | /// </summary> |
137 | public uint maturity; | 137 | public uint maturity; |
138 | 138 | ||
139 | |||
140 | //Data Wrappers | 139 | //Data Wrappers |
141 | public string RegionName | 140 | public string RegionName |
142 | { | 141 | { |
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs index 64591fd..a5e0517 100644 --- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs | |||
@@ -46,10 +46,12 @@ namespace OpenSim.Data.SQLite | |||
46 | private const string invItemsSelect = "select * from inventoryitems"; | 46 | private const string invItemsSelect = "select * from inventoryitems"; |
47 | private const string invFoldersSelect = "select * from inventoryfolders"; | 47 | private const string invFoldersSelect = "select * from inventoryfolders"; |
48 | 48 | ||
49 | private SqliteConnection conn; | 49 | private static SqliteConnection conn; |
50 | private DataSet ds; | 50 | private static DataSet ds; |
51 | private SqliteDataAdapter invItemsDa; | 51 | private static SqliteDataAdapter invItemsDa; |
52 | private SqliteDataAdapter invFoldersDa; | 52 | private static SqliteDataAdapter invFoldersDa; |
53 | |||
54 | private static bool m_Initialized = false; | ||
53 | 55 | ||
54 | public void Initialise() | 56 | public void Initialise() |
55 | { | 57 | { |
@@ -67,39 +69,44 @@ namespace OpenSim.Data.SQLite | |||
67 | /// <param name="dbconnect">connect string</param> | 69 | /// <param name="dbconnect">connect string</param> |
68 | public void Initialise(string dbconnect) | 70 | public void Initialise(string dbconnect) |
69 | { | 71 | { |
70 | if (dbconnect == string.Empty) | 72 | if (!m_Initialized) |
71 | { | 73 | { |
72 | dbconnect = "URI=file:inventoryStore.db,version=3"; | 74 | m_Initialized = true; |
73 | } | 75 | |
74 | m_log.Info("[INVENTORY DB]: Sqlite - connecting: " + dbconnect); | 76 | if (dbconnect == string.Empty) |
75 | conn = new SqliteConnection(dbconnect); | 77 | { |
78 | dbconnect = "URI=file:inventoryStore.db,version=3"; | ||
79 | } | ||
80 | m_log.Info("[INVENTORY DB]: Sqlite - connecting: " + dbconnect); | ||
81 | conn = new SqliteConnection(dbconnect); | ||
76 | 82 | ||
77 | conn.Open(); | 83 | conn.Open(); |
78 | 84 | ||
79 | Assembly assem = GetType().Assembly; | 85 | Assembly assem = GetType().Assembly; |
80 | Migration m = new Migration(conn, assem, "InventoryStore"); | 86 | Migration m = new Migration(conn, assem, "InventoryStore"); |
81 | m.Update(); | 87 | m.Update(); |
82 | 88 | ||
83 | SqliteCommand itemsSelectCmd = new SqliteCommand(invItemsSelect, conn); | 89 | SqliteCommand itemsSelectCmd = new SqliteCommand(invItemsSelect, conn); |
84 | invItemsDa = new SqliteDataAdapter(itemsSelectCmd); | 90 | invItemsDa = new SqliteDataAdapter(itemsSelectCmd); |
85 | // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); | 91 | // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); |
86 | 92 | ||
87 | SqliteCommand foldersSelectCmd = new SqliteCommand(invFoldersSelect, conn); | 93 | SqliteCommand foldersSelectCmd = new SqliteCommand(invFoldersSelect, conn); |
88 | invFoldersDa = new SqliteDataAdapter(foldersSelectCmd); | 94 | invFoldersDa = new SqliteDataAdapter(foldersSelectCmd); |
89 | 95 | ||
90 | ds = new DataSet(); | 96 | ds = new DataSet(); |
91 | 97 | ||
92 | ds.Tables.Add(createInventoryFoldersTable()); | 98 | ds.Tables.Add(createInventoryFoldersTable()); |
93 | invFoldersDa.Fill(ds.Tables["inventoryfolders"]); | 99 | invFoldersDa.Fill(ds.Tables["inventoryfolders"]); |
94 | setupFoldersCommands(invFoldersDa, conn); | 100 | setupFoldersCommands(invFoldersDa, conn); |
95 | m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions"); | 101 | m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions"); |
96 | 102 | ||
97 | ds.Tables.Add(createInventoryItemsTable()); | 103 | ds.Tables.Add(createInventoryItemsTable()); |
98 | invItemsDa.Fill(ds.Tables["inventoryitems"]); | 104 | invItemsDa.Fill(ds.Tables["inventoryitems"]); |
99 | setupItemsCommands(invItemsDa, conn); | 105 | setupItemsCommands(invItemsDa, conn); |
100 | m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions"); | 106 | m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions"); |
101 | 107 | ||
102 | ds.AcceptChanges(); | 108 | ds.AcceptChanges(); |
109 | } | ||
103 | } | 110 | } |
104 | 111 | ||
105 | /// <summary> | 112 | /// <summary> |