diff options
Diffstat (limited to 'OpenSim/Data/Null')
-rw-r--r-- | OpenSim/Data/Null/NullAuthenticationData.cs | 80 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullAvatarData.cs | 93 | ||||
-rwxr-xr-x | OpenSim/Data/Null/NullEstateData.cs | 138 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullFriendsData.cs | 110 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullInventoryData.cs | 220 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullPresenceData.cs | 227 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullRegionData.cs | 133 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullSimulationData.cs (renamed from OpenSim/Data/Null/NullDataStore.cs) | 39 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullUserAccountData.cs | 202 |
9 files changed, 1226 insertions, 16 deletions
diff --git a/OpenSim/Data/Null/NullAuthenticationData.cs b/OpenSim/Data/Null/NullAuthenticationData.cs new file mode 100644 index 0000000..620deb9 --- /dev/null +++ b/OpenSim/Data/Null/NullAuthenticationData.cs | |||
@@ -0,0 +1,80 @@ | |||
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 | } \ No newline at end of file | ||
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/NullEstateData.cs b/OpenSim/Data/Null/NullEstateData.cs new file mode 100755 index 0000000..d64136d --- /dev/null +++ b/OpenSim/Data/Null/NullEstateData.cs | |||
@@ -0,0 +1,138 @@ | |||
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.Reflection; | ||
31 | using log4net; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | |||
37 | namespace OpenSim.Data.Null | ||
38 | { | ||
39 | public class NullEstateStore : IEstateDataStore | ||
40 | { | ||
41 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | |||
43 | // private string m_connectionString; | ||
44 | |||
45 | protected virtual Assembly Assembly | ||
46 | { | ||
47 | get { return GetType().Assembly; } | ||
48 | } | ||
49 | |||
50 | public NullEstateStore() | ||
51 | { | ||
52 | } | ||
53 | |||
54 | public NullEstateStore(string connectionString) | ||
55 | { | ||
56 | Initialise(connectionString); | ||
57 | } | ||
58 | |||
59 | public void Initialise(string connectionString) | ||
60 | { | ||
61 | // m_connectionString = connectionString; | ||
62 | } | ||
63 | |||
64 | private string[] FieldList | ||
65 | { | ||
66 | get { return new string[0]; } | ||
67 | } | ||
68 | |||
69 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) | ||
70 | { | ||
71 | // This fools the initialization caller into thinking an estate was fetched (a check in OpenSimBase). | ||
72 | // The estate info is pretty empty so don't try banning anyone. | ||
73 | EstateSettings oneEstate = new EstateSettings(); | ||
74 | oneEstate.EstateID = 1; | ||
75 | return oneEstate; | ||
76 | } | ||
77 | |||
78 | public void StoreEstateSettings(EstateSettings es) | ||
79 | { | ||
80 | return; | ||
81 | } | ||
82 | |||
83 | public EstateSettings LoadEstateSettings(int estateID) | ||
84 | { | ||
85 | return new EstateSettings(); | ||
86 | } | ||
87 | |||
88 | public EstateSettings CreateNewEstate() | ||
89 | { | ||
90 | return new EstateSettings(); | ||
91 | } | ||
92 | |||
93 | public List<EstateSettings> LoadEstateSettingsAll() | ||
94 | { | ||
95 | List<EstateSettings> allEstateSettings = new List<EstateSettings>(); | ||
96 | allEstateSettings.Add(new EstateSettings()); | ||
97 | return allEstateSettings; | ||
98 | } | ||
99 | |||
100 | public List<int> GetEstatesAll() | ||
101 | { | ||
102 | List<int> result = new List<int>(); | ||
103 | return result; | ||
104 | } | ||
105 | |||
106 | public List<int> GetEstates(string search) | ||
107 | { | ||
108 | List<int> result = new List<int>(); | ||
109 | return result; | ||
110 | } | ||
111 | |||
112 | public bool LinkRegion(UUID regionID, int estateID) | ||
113 | { | ||
114 | return false; | ||
115 | } | ||
116 | |||
117 | public List<UUID> GetRegions(int estateID) | ||
118 | { | ||
119 | List<UUID> result = new List<UUID>(); | ||
120 | return result; | ||
121 | } | ||
122 | |||
123 | public bool DeleteEstate(int estateID) | ||
124 | { | ||
125 | return false; | ||
126 | } | ||
127 | |||
128 | #region IEstateDataStore Members | ||
129 | |||
130 | |||
131 | public List<int> GetEstatesByOwner(UUID ownerID) | ||
132 | { | ||
133 | return new List<int>(); | ||
134 | } | ||
135 | |||
136 | #endregion | ||
137 | } | ||
138 | } | ||
diff --git a/OpenSim/Data/Null/NullFriendsData.cs b/OpenSim/Data/Null/NullFriendsData.cs new file mode 100644 index 0000000..0a4b242 --- /dev/null +++ b/OpenSim/Data/Null/NullFriendsData.cs | |||
@@ -0,0 +1,110 @@ | |||
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 NullFriendsData : IFriendsData | ||
38 | { | ||
39 | private static List<FriendsData> m_Data = new List<FriendsData>(); | ||
40 | |||
41 | public NullFriendsData(string connectionString, string realm) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | public FriendsData[] GetFriends(UUID principalID) | ||
46 | { | ||
47 | return GetFriends(principalID.ToString()); | ||
48 | } | ||
49 | |||
50 | /// <summary> | ||
51 | /// Tries to implement the Get [] semantics, but it cuts corners. | ||
52 | /// Specifically, it gets all friendships even if they weren't accepted yet. | ||
53 | /// </summary> | ||
54 | /// <param name="fields"></param> | ||
55 | /// <param name="values"></param> | ||
56 | /// <returns></returns> | ||
57 | public FriendsData[] GetFriends(string userID) | ||
58 | { | ||
59 | List<FriendsData> lst = m_Data.FindAll(fdata => | ||
60 | { | ||
61 | return fdata.PrincipalID == userID.ToString(); | ||
62 | }); | ||
63 | |||
64 | if (lst != null) | ||
65 | { | ||
66 | lst.ForEach(f => | ||
67 | { | ||
68 | FriendsData f2 = m_Data.Find(candidateF2 => f.Friend == candidateF2.PrincipalID); | ||
69 | if (f2 != null) { f.Data["TheirFlags"] = f2.Data["Flags"]; } | ||
70 | }); | ||
71 | |||
72 | return lst.ToArray(); | ||
73 | } | ||
74 | |||
75 | return new FriendsData[0]; | ||
76 | } | ||
77 | |||
78 | public bool Store(FriendsData data) | ||
79 | { | ||
80 | if (data == null) | ||
81 | return false; | ||
82 | |||
83 | m_Data.Add(data); | ||
84 | |||
85 | return true; | ||
86 | } | ||
87 | |||
88 | public bool Delete(UUID principalID, string friend) | ||
89 | { | ||
90 | return Delete(principalID.ToString(), friend); | ||
91 | } | ||
92 | |||
93 | public bool Delete(string userID, string friendID) | ||
94 | { | ||
95 | List<FriendsData> lst = m_Data.FindAll(delegate(FriendsData fdata) { return fdata.PrincipalID == userID.ToString(); }); | ||
96 | if (lst != null) | ||
97 | { | ||
98 | FriendsData friend = lst.Find(delegate(FriendsData fdata) { return fdata.Friend == friendID; }); | ||
99 | if (friendID != null) | ||
100 | { | ||
101 | m_Data.Remove(friend); | ||
102 | return true; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | return false; | ||
107 | } | ||
108 | |||
109 | } | ||
110 | } | ||
diff --git a/OpenSim/Data/Null/NullInventoryData.cs b/OpenSim/Data/Null/NullInventoryData.cs new file mode 100644 index 0000000..fe9ed01 --- /dev/null +++ b/OpenSim/Data/Null/NullInventoryData.cs | |||
@@ -0,0 +1,220 @@ | |||
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 | |||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | |||
34 | namespace OpenSim.Data.Null | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// This class is completely null. | ||
38 | /// </summary> | ||
39 | public class NullInventoryData : IInventoryDataPlugin | ||
40 | { | ||
41 | public string Version { get { return "1.0.0.0"; } } | ||
42 | |||
43 | public void Initialise() | ||
44 | { | ||
45 | } | ||
46 | |||
47 | public void Dispose() | ||
48 | { | ||
49 | // Do nothing. | ||
50 | } | ||
51 | |||
52 | public string Name | ||
53 | { | ||
54 | get { return "Null Inventory Data Interface"; } | ||
55 | } | ||
56 | |||
57 | public void Initialise(string connect) | ||
58 | { | ||
59 | } | ||
60 | |||
61 | |||
62 | /// <summary> | ||
63 | /// Returns all descendent folders of this folder. Does not return the parent folder itself. | ||
64 | /// </summary> | ||
65 | /// <param name="parentID">The folder to get subfolders for</param> | ||
66 | /// <returns>A list of inventory folders</returns> | ||
67 | public List<InventoryFolderBase> getFolderHierarchy(UUID parentID) | ||
68 | { | ||
69 | return new List<InventoryFolderBase>(); | ||
70 | } | ||
71 | |||
72 | /// <summary> | ||
73 | /// Returns a list of inventory items contained within the specified folder | ||
74 | /// </summary> | ||
75 | /// <param name="folderID">The UUID of the target folder</param> | ||
76 | /// <returns>A List of InventoryItemBase items</returns> | ||
77 | public List<InventoryItemBase> getInventoryInFolder(UUID folderID) | ||
78 | { | ||
79 | return new List<InventoryItemBase>(); | ||
80 | } | ||
81 | |||
82 | /// <summary> | ||
83 | /// Returns a list of the root folders within a users inventory | ||
84 | /// </summary> | ||
85 | /// <param name="user">The user whos inventory is to be searched</param> | ||
86 | /// <returns>A list of folder objects</returns> | ||
87 | public List<InventoryFolderBase> getUserRootFolders(UUID user) | ||
88 | { | ||
89 | return new List<InventoryFolderBase>(); | ||
90 | } | ||
91 | |||
92 | /// <summary> | ||
93 | /// Returns the users inventory root folder. | ||
94 | /// </summary> | ||
95 | /// <param name="user">The UUID of the user who is having inventory being returned</param> | ||
96 | /// <returns>Root inventory folder, null if no root inventory folder was found</returns> | ||
97 | public InventoryFolderBase getUserRootFolder(UUID user) | ||
98 | { | ||
99 | return null; | ||
100 | } | ||
101 | |||
102 | /// <summary> | ||
103 | /// Returns a list of inventory folders contained in the folder 'parentID' | ||
104 | /// </summary> | ||
105 | /// <param name="parentID">The folder to get subfolders for</param> | ||
106 | /// <returns>A list of inventory folders</returns> | ||
107 | public List<InventoryFolderBase> getInventoryFolders(UUID parentID) | ||
108 | { | ||
109 | return new List<InventoryFolderBase>(); | ||
110 | } | ||
111 | |||
112 | /// <summary> | ||
113 | /// Returns an inventory item by its UUID | ||
114 | /// </summary> | ||
115 | /// <param name="item">The UUID of the item to be returned</param> | ||
116 | /// <returns>A class containing item information</returns> | ||
117 | public InventoryItemBase getInventoryItem(UUID item) | ||
118 | { | ||
119 | return null; | ||
120 | } | ||
121 | |||
122 | /// <summary> | ||
123 | /// Returns a specified inventory folder by its UUID | ||
124 | /// </summary> | ||
125 | /// <param name="folder">The UUID of the folder to be returned</param> | ||
126 | /// <returns>A class containing folder information</returns> | ||
127 | public InventoryFolderBase getInventoryFolder(UUID folder) | ||
128 | { | ||
129 | return null; | ||
130 | } | ||
131 | |||
132 | /// <summary> | ||
133 | /// Creates a new inventory item based on item | ||
134 | /// </summary> | ||
135 | /// <param name="item">The item to be created</param> | ||
136 | public void addInventoryItem(InventoryItemBase item) | ||
137 | { | ||
138 | } | ||
139 | |||
140 | /// <summary> | ||
141 | /// Updates an inventory item with item (updates based on ID) | ||
142 | /// </summary> | ||
143 | /// <param name="item">The updated item</param> | ||
144 | public void updateInventoryItem(InventoryItemBase item) | ||
145 | { | ||
146 | } | ||
147 | |||
148 | /// <summary> | ||
149 | /// | ||
150 | /// </summary> | ||
151 | /// <param name="item"></param> | ||
152 | public void deleteInventoryItem(UUID item) | ||
153 | { | ||
154 | } | ||
155 | |||
156 | /// <summary> | ||
157 | /// | ||
158 | /// </summary> | ||
159 | /// <param name="item"></param> | ||
160 | public InventoryItemBase queryInventoryItem(UUID item) | ||
161 | { | ||
162 | return null; | ||
163 | } | ||
164 | |||
165 | /// <summary> | ||
166 | /// | ||
167 | /// </summary> | ||
168 | /// <param name="item"></param> | ||
169 | public InventoryFolderBase queryInventoryFolder(UUID folder) | ||
170 | { | ||
171 | return null; | ||
172 | } | ||
173 | |||
174 | /// <summary> | ||
175 | /// Adds a new folder specified by folder | ||
176 | /// </summary> | ||
177 | /// <param name="folder">The inventory folder</param> | ||
178 | public void addInventoryFolder(InventoryFolderBase folder) | ||
179 | { | ||
180 | } | ||
181 | |||
182 | /// <summary> | ||
183 | /// Updates a folder based on its ID with folder | ||
184 | /// </summary> | ||
185 | /// <param name="folder">The inventory folder</param> | ||
186 | public void updateInventoryFolder(InventoryFolderBase folder) | ||
187 | { | ||
188 | } | ||
189 | |||
190 | /// <summary> | ||
191 | /// Updates a folder based on its ID with folder | ||
192 | /// </summary> | ||
193 | /// <param name="folder">The inventory folder</param> | ||
194 | public void moveInventoryFolder(InventoryFolderBase folder) | ||
195 | { | ||
196 | } | ||
197 | |||
198 | /// <summary> | ||
199 | /// Deletes a folder. Thie will delete both the folder itself and its contents (items and descendent folders) | ||
200 | /// </summary> | ||
201 | /// <param name="folder">The id of the folder</param> | ||
202 | public void deleteInventoryFolder(UUID folder) | ||
203 | { | ||
204 | } | ||
205 | |||
206 | /// <summary> | ||
207 | /// Returns all activated gesture-items in the inventory of the specified avatar. | ||
208 | /// </summary> | ||
209 | /// <param name="avatarID"> | ||
210 | /// The <see cref="UUID"/> of the avatar | ||
211 | /// </param> | ||
212 | /// <returns> | ||
213 | /// The list of gestures (<see cref="InventoryItemBase"/>s) | ||
214 | /// </returns> | ||
215 | public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) | ||
216 | { | ||
217 | return new List<InventoryItemBase>(); | ||
218 | } | ||
219 | } | ||
220 | } | ||
diff --git a/OpenSim/Data/Null/NullPresenceData.cs b/OpenSim/Data/Null/NullPresenceData.cs new file mode 100644 index 0000000..91f1cc5 --- /dev/null +++ b/OpenSim/Data/Null/NullPresenceData.cs | |||
@@ -0,0 +1,227 @@ | |||
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.Reflection; | ||
32 | using log4net; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Data; | ||
36 | |||
37 | namespace OpenSim.Data.Null | ||
38 | { | ||
39 | public class NullPresenceData : IPresenceData | ||
40 | { | ||
41 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | |||
43 | private static NullPresenceData Instance; | ||
44 | |||
45 | Dictionary<UUID, PresenceData> m_presenceData = new Dictionary<UUID, PresenceData>(); | ||
46 | |||
47 | public NullPresenceData(string connectionString, string realm) | ||
48 | { | ||
49 | if (Instance == null) | ||
50 | { | ||
51 | Instance = this; | ||
52 | |||
53 | //Console.WriteLine("[XXX] NullRegionData constructor"); | ||
54 | } | ||
55 | } | ||
56 | |||
57 | public bool Store(PresenceData data) | ||
58 | { | ||
59 | if (Instance != this) | ||
60 | return Instance.Store(data); | ||
61 | |||
62 | // m_log.DebugFormat("[NULL PRESENCE DATA]: Storing presence {0}", data.UserID); | ||
63 | // Console.WriteLine("HOME for " + data.UserID + " is " + (data.Data.ContainsKey("HomeRegionID") ? data.Data["HomeRegionID"] : "Not found")); | ||
64 | |||
65 | m_presenceData[data.SessionID] = data; | ||
66 | return true; | ||
67 | } | ||
68 | |||
69 | public PresenceData Get(UUID sessionID) | ||
70 | { | ||
71 | if (Instance != this) | ||
72 | return Instance.Get(sessionID); | ||
73 | |||
74 | if (m_presenceData.ContainsKey(sessionID)) | ||
75 | { | ||
76 | return m_presenceData[sessionID]; | ||
77 | } | ||
78 | |||
79 | return null; | ||
80 | } | ||
81 | |||
82 | public void LogoutRegionAgents(UUID regionID) | ||
83 | { | ||
84 | if (Instance != this) | ||
85 | { | ||
86 | Instance.LogoutRegionAgents(regionID); | ||
87 | return; | ||
88 | } | ||
89 | |||
90 | List<UUID> toBeDeleted = new List<UUID>(); | ||
91 | foreach (KeyValuePair<UUID, PresenceData> kvp in m_presenceData) | ||
92 | if (kvp.Value.RegionID == regionID) | ||
93 | toBeDeleted.Add(kvp.Key); | ||
94 | |||
95 | foreach (UUID u in toBeDeleted) | ||
96 | m_presenceData.Remove(u); | ||
97 | } | ||
98 | |||
99 | public bool ReportAgent(UUID sessionID, UUID regionID) | ||
100 | { | ||
101 | if (Instance != this) | ||
102 | return Instance.ReportAgent(sessionID, regionID); | ||
103 | |||
104 | if (m_presenceData.ContainsKey(sessionID)) | ||
105 | { | ||
106 | m_presenceData[sessionID].RegionID = regionID; | ||
107 | return true; | ||
108 | } | ||
109 | |||
110 | return false; | ||
111 | } | ||
112 | |||
113 | |||
114 | public PresenceData[] Get(string field, string data) | ||
115 | { | ||
116 | if (Instance != this) | ||
117 | return Instance.Get(field, data); | ||
118 | |||
119 | // m_log.DebugFormat( | ||
120 | // "[NULL PRESENCE DATA]: Getting presence data for field {0} with parameter {1}", field, data); | ||
121 | |||
122 | List<PresenceData> presences = new List<PresenceData>(); | ||
123 | if (field == "UserID") | ||
124 | { | ||
125 | foreach (PresenceData p in m_presenceData.Values) | ||
126 | { | ||
127 | if (p.UserID == data) | ||
128 | { | ||
129 | presences.Add(p); | ||
130 | // Console.WriteLine("HOME for " + p.UserID + " is " + (p.Data.ContainsKey("HomeRegionID") ? p.Data["HomeRegionID"] : "Not found")); | ||
131 | } | ||
132 | } | ||
133 | |||
134 | return presences.ToArray(); | ||
135 | } | ||
136 | else if (field == "SessionID") | ||
137 | { | ||
138 | UUID session = UUID.Zero; | ||
139 | if (!UUID.TryParse(data, out session)) | ||
140 | return presences.ToArray(); | ||
141 | |||
142 | if (m_presenceData.ContainsKey(session)) | ||
143 | { | ||
144 | presences.Add(m_presenceData[session]); | ||
145 | return presences.ToArray(); | ||
146 | } | ||
147 | } | ||
148 | else if (field == "RegionID") | ||
149 | { | ||
150 | UUID region = UUID.Zero; | ||
151 | if (!UUID.TryParse(data, out region)) | ||
152 | return presences.ToArray(); | ||
153 | foreach (PresenceData p in m_presenceData.Values) | ||
154 | if (p.RegionID == region) | ||
155 | presences.Add(p); | ||
156 | return presences.ToArray(); | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | foreach (PresenceData p in m_presenceData.Values) | ||
161 | { | ||
162 | if (p.Data.ContainsKey(field) && p.Data[field] == data) | ||
163 | presences.Add(p); | ||
164 | } | ||
165 | return presences.ToArray(); | ||
166 | } | ||
167 | |||
168 | return presences.ToArray(); | ||
169 | } | ||
170 | |||
171 | |||
172 | public bool Delete(string field, string data) | ||
173 | { | ||
174 | // m_log.DebugFormat( | ||
175 | // "[NULL PRESENCE DATA]: Deleting presence data for field {0} with parameter {1}", field, data); | ||
176 | |||
177 | if (Instance != this) | ||
178 | return Instance.Delete(field, data); | ||
179 | |||
180 | List<UUID> presences = new List<UUID>(); | ||
181 | if (field == "UserID") | ||
182 | { | ||
183 | foreach (KeyValuePair<UUID, PresenceData> p in m_presenceData) | ||
184 | if (p.Value.UserID == data) | ||
185 | presences.Add(p.Key); | ||
186 | } | ||
187 | else if (field == "SessionID") | ||
188 | { | ||
189 | UUID session = UUID.Zero; | ||
190 | if (UUID.TryParse(data, out session)) | ||
191 | { | ||
192 | if (m_presenceData.ContainsKey(session)) | ||
193 | { | ||
194 | presences.Add(session); | ||
195 | } | ||
196 | } | ||
197 | } | ||
198 | else if (field == "RegionID") | ||
199 | { | ||
200 | UUID region = UUID.Zero; | ||
201 | if (UUID.TryParse(data, out region)) | ||
202 | { | ||
203 | foreach (KeyValuePair<UUID, PresenceData> p in m_presenceData) | ||
204 | if (p.Value.RegionID == region) | ||
205 | presences.Add(p.Key); | ||
206 | } | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | foreach (KeyValuePair<UUID, PresenceData> p in m_presenceData) | ||
211 | { | ||
212 | if (p.Value.Data.ContainsKey(field) && p.Value.Data[field] == data) | ||
213 | presences.Add(p.Key); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | foreach (UUID u in presences) | ||
218 | m_presenceData.Remove(u); | ||
219 | |||
220 | if (presences.Count == 0) | ||
221 | return false; | ||
222 | |||
223 | return true; | ||
224 | } | ||
225 | |||
226 | } | ||
227 | } | ||
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index e8263ea..deb50cb 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs | |||
@@ -31,36 +31,94 @@ 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 | /// <summary> | ||
44 | /// Should we use the static instance for all invocations? | ||
45 | /// </summary> | ||
46 | private bool m_useStaticInstance = true; | ||
47 | |||
48 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
39 | Dictionary<UUID, RegionData> m_regionData = new Dictionary<UUID, RegionData>(); | 50 | Dictionary<UUID, RegionData> m_regionData = new Dictionary<UUID, RegionData>(); |
40 | 51 | ||
41 | public NullRegionData(string connectionString, string realm) | 52 | public NullRegionData(string connectionString, string realm) |
42 | { | 53 | { |
43 | //Console.WriteLine("[XXX] NullRegionData constructor"); | 54 | // m_log.DebugFormat( |
55 | // "[NULL REGION DATA]: Constructor got connectionString {0}, realm {1}", connectionString, realm); | ||
56 | |||
57 | // The !static connection string is a hack so that regression tests can use this module without a high degree of fragility | ||
58 | // in having to deal with the static reference in the once-loaded NullRegionData class. | ||
59 | // | ||
60 | // In standalone operation, we have to use only one instance of this class since the login service and | ||
61 | // simulator have no other way of using a common data store. | ||
62 | if (connectionString == "!static") | ||
63 | m_useStaticInstance = false; | ||
64 | else if (Instance == null) | ||
65 | Instance = this; | ||
44 | } | 66 | } |
45 | 67 | ||
68 | private delegate bool Matcher(string value); | ||
69 | |||
46 | public List<RegionData> Get(string regionName, UUID scopeID) | 70 | public List<RegionData> Get(string regionName, UUID scopeID) |
47 | { | 71 | { |
48 | List<RegionData> ret = new List<RegionData>(); | 72 | if (m_useStaticInstance && Instance != this) |
73 | return Instance.Get(regionName, scopeID); | ||
49 | 74 | ||
50 | foreach (RegionData r in m_regionData.Values) | 75 | // m_log.DebugFormat("[NULL REGION DATA]: Getting region {0}, scope {1}", regionName, scopeID); |
76 | |||
77 | string cleanName = regionName.ToLower(); | ||
78 | |||
79 | // Handle SQL wildcards | ||
80 | const string wildcard = "%"; | ||
81 | bool wildcardPrefix = false; | ||
82 | bool wildcardSuffix = false; | ||
83 | if (cleanName.Equals(wildcard)) | ||
84 | { | ||
85 | wildcardPrefix = wildcardSuffix = true; | ||
86 | cleanName = string.Empty; | ||
87 | } | ||
88 | else | ||
51 | { | 89 | { |
52 | if (regionName.Contains("%")) | 90 | if (cleanName.StartsWith(wildcard)) |
53 | { | 91 | { |
54 | if (r.RegionName.Contains(regionName.Replace("%", ""))) | 92 | wildcardPrefix = true; |
55 | ret.Add(r); | 93 | cleanName = cleanName.Substring(1); |
56 | } | 94 | } |
57 | else | 95 | if (regionName.EndsWith(wildcard)) |
58 | { | 96 | { |
59 | if (r.RegionName == regionName) | 97 | wildcardSuffix = true; |
60 | ret.Add(r); | 98 | cleanName = cleanName.Remove(cleanName.Length - 1); |
61 | } | 99 | } |
62 | } | 100 | } |
63 | 101 | ||
102 | Matcher queryMatch; | ||
103 | if (wildcardPrefix && wildcardSuffix) | ||
104 | queryMatch = delegate(string s) { return s.Contains(cleanName); }; | ||
105 | else if (wildcardSuffix) | ||
106 | queryMatch = delegate(string s) { return s.StartsWith(cleanName); }; | ||
107 | else if (wildcardPrefix) | ||
108 | queryMatch = delegate(string s) { return s.EndsWith(cleanName); }; | ||
109 | else | ||
110 | queryMatch = delegate(string s) { return s.Equals(cleanName); }; | ||
111 | |||
112 | // Find region data | ||
113 | List<RegionData> ret = new List<RegionData>(); | ||
114 | |||
115 | foreach (RegionData r in m_regionData.Values) | ||
116 | { | ||
117 | // m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanName, r.RegionName.ToLower()); | ||
118 | if (queryMatch(r.RegionName.ToLower())) | ||
119 | ret.Add(r); | ||
120 | } | ||
121 | |||
64 | if (ret.Count > 0) | 122 | if (ret.Count > 0) |
65 | return ret; | 123 | return ret; |
66 | 124 | ||
@@ -69,6 +127,9 @@ namespace OpenSim.Data.Null | |||
69 | 127 | ||
70 | public RegionData Get(int posX, int posY, UUID scopeID) | 128 | public RegionData Get(int posX, int posY, UUID scopeID) |
71 | { | 129 | { |
130 | if (m_useStaticInstance && Instance != this) | ||
131 | return Instance.Get(posX, posY, scopeID); | ||
132 | |||
72 | List<RegionData> ret = new List<RegionData>(); | 133 | List<RegionData> ret = new List<RegionData>(); |
73 | 134 | ||
74 | foreach (RegionData r in m_regionData.Values) | 135 | foreach (RegionData r in m_regionData.Values) |
@@ -85,6 +146,9 @@ namespace OpenSim.Data.Null | |||
85 | 146 | ||
86 | public RegionData Get(UUID regionID, UUID scopeID) | 147 | public RegionData Get(UUID regionID, UUID scopeID) |
87 | { | 148 | { |
149 | if (m_useStaticInstance && Instance != this) | ||
150 | return Instance.Get(regionID, scopeID); | ||
151 | |||
88 | if (m_regionData.ContainsKey(regionID)) | 152 | if (m_regionData.ContainsKey(regionID)) |
89 | return m_regionData[regionID]; | 153 | return m_regionData[regionID]; |
90 | 154 | ||
@@ -93,6 +157,9 @@ namespace OpenSim.Data.Null | |||
93 | 157 | ||
94 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) | 158 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) |
95 | { | 159 | { |
160 | if (m_useStaticInstance && Instance != this) | ||
161 | return Instance.Get(startX, startY, endX, endY, scopeID); | ||
162 | |||
96 | List<RegionData> ret = new List<RegionData>(); | 163 | List<RegionData> ret = new List<RegionData>(); |
97 | 164 | ||
98 | foreach (RegionData r in m_regionData.Values) | 165 | foreach (RegionData r in m_regionData.Values) |
@@ -106,6 +173,12 @@ namespace OpenSim.Data.Null | |||
106 | 173 | ||
107 | public bool Store(RegionData data) | 174 | public bool Store(RegionData data) |
108 | { | 175 | { |
176 | if (m_useStaticInstance && Instance != this) | ||
177 | return Instance.Store(data); | ||
178 | |||
179 | // m_log.DebugFormat( | ||
180 | // "[NULL REGION DATA]: Storing region {0} {1}, scope {2}", data.RegionName, data.RegionID, data.ScopeID); | ||
181 | |||
109 | m_regionData[data.RegionID] = data; | 182 | m_regionData[data.RegionID] = data; |
110 | 183 | ||
111 | return true; | 184 | return true; |
@@ -113,6 +186,9 @@ namespace OpenSim.Data.Null | |||
113 | 186 | ||
114 | public bool SetDataItem(UUID regionID, string item, string value) | 187 | public bool SetDataItem(UUID regionID, string item, string value) |
115 | { | 188 | { |
189 | if (m_useStaticInstance && Instance != this) | ||
190 | return Instance.SetDataItem(regionID, item, value); | ||
191 | |||
116 | if (!m_regionData.ContainsKey(regionID)) | 192 | if (!m_regionData.ContainsKey(regionID)) |
117 | return false; | 193 | return false; |
118 | 194 | ||
@@ -123,6 +199,11 @@ namespace OpenSim.Data.Null | |||
123 | 199 | ||
124 | public bool Delete(UUID regionID) | 200 | public bool Delete(UUID regionID) |
125 | { | 201 | { |
202 | if (m_useStaticInstance && Instance != this) | ||
203 | return Instance.Delete(regionID); | ||
204 | |||
205 | // m_log.DebugFormat("[NULL REGION DATA]: Deleting region {0}", regionID); | ||
206 | |||
126 | if (!m_regionData.ContainsKey(regionID)) | 207 | if (!m_regionData.ContainsKey(regionID)) |
127 | return false; | 208 | return false; |
128 | 209 | ||
@@ -130,5 +211,39 @@ namespace OpenSim.Data.Null | |||
130 | 211 | ||
131 | return true; | 212 | return true; |
132 | } | 213 | } |
214 | |||
215 | public List<RegionData> GetDefaultRegions(UUID scopeID) | ||
216 | { | ||
217 | return Get((int)RegionFlags.DefaultRegion, scopeID); | ||
218 | } | ||
219 | |||
220 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) | ||
221 | { | ||
222 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); | ||
223 | RegionDataDistanceCompare distanceComparer = new RegionDataDistanceCompare(x, y); | ||
224 | regions.Sort(distanceComparer); | ||
225 | return regions; | ||
226 | } | ||
227 | |||
228 | public List<RegionData> GetHyperlinks(UUID scopeID) | ||
229 | { | ||
230 | return Get((int)RegionFlags.Hyperlink, scopeID); | ||
231 | } | ||
232 | |||
233 | private List<RegionData> Get(int regionFlags, UUID scopeID) | ||
234 | { | ||
235 | if (Instance != this) | ||
236 | return Instance.Get(regionFlags, scopeID); | ||
237 | |||
238 | List<RegionData> ret = new List<RegionData>(); | ||
239 | |||
240 | foreach (RegionData r in m_regionData.Values) | ||
241 | { | ||
242 | if ((Convert.ToInt32(r.Data["flags"]) & regionFlags) != 0) | ||
243 | ret.Add(r); | ||
244 | } | ||
245 | |||
246 | return ret; | ||
247 | } | ||
133 | } | 248 | } |
134 | } | 249 | } |
diff --git a/OpenSim/Data/Null/NullDataStore.cs b/OpenSim/Data/Null/NullSimulationData.cs index 4b6d0f3..b788976 100644 --- a/OpenSim/Data/Null/NullDataStore.cs +++ b/OpenSim/Data/Null/NullSimulationData.cs | |||
@@ -36,8 +36,17 @@ namespace OpenSim.Data.Null | |||
36 | /// <summary> | 36 | /// <summary> |
37 | /// NULL DataStore, do not store anything | 37 | /// NULL DataStore, do not store anything |
38 | /// </summary> | 38 | /// </summary> |
39 | public class NullDataStore : IRegionDataStore | 39 | public class NullSimulationData : ISimulationDataStore |
40 | { | 40 | { |
41 | public NullSimulationData() | ||
42 | { | ||
43 | } | ||
44 | |||
45 | public NullSimulationData(string connectionString) | ||
46 | { | ||
47 | Initialise(connectionString); | ||
48 | } | ||
49 | |||
41 | public void Initialise(string dbfile) | 50 | public void Initialise(string dbfile) |
42 | { | 51 | { |
43 | return; | 52 | return; |
@@ -50,19 +59,28 @@ namespace OpenSim.Data.Null | |||
50 | public void StoreRegionSettings(RegionSettings rs) | 59 | public void StoreRegionSettings(RegionSettings rs) |
51 | { | 60 | { |
52 | } | 61 | } |
53 | public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID) | 62 | |
63 | public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) | ||
54 | { | 64 | { |
55 | //This connector doesn't support the windlight module yet | 65 | //This connector doesn't support the windlight module yet |
56 | //Return default LL windlight settings | 66 | //Return default LL windlight settings |
57 | return new RegionMeta7WindlightData(); | 67 | return new RegionLightShareData(); |
58 | } | 68 | } |
59 | public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl) | 69 | |
70 | public void RemoveRegionWindlightSettings(UUID regionID) | ||
71 | { | ||
72 | } | ||
73 | |||
74 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | ||
60 | { | 75 | { |
61 | //This connector doesn't support the windlight module yet | 76 | //This connector doesn't support the windlight module yet |
62 | } | 77 | } |
78 | |||
63 | public RegionSettings LoadRegionSettings(UUID regionUUID) | 79 | public RegionSettings LoadRegionSettings(UUID regionUUID) |
64 | { | 80 | { |
65 | return null; | 81 | RegionSettings rs = new RegionSettings(); |
82 | rs.RegionUUID = regionUUID; | ||
83 | return rs; | ||
66 | } | 84 | } |
67 | 85 | ||
68 | public void StoreObject(SceneObjectGroup obj, UUID regionUUID) | 86 | public void StoreObject(SceneObjectGroup obj, UUID regionUUID) |
@@ -73,7 +91,6 @@ namespace OpenSim.Data.Null | |||
73 | { | 91 | { |
74 | } | 92 | } |
75 | 93 | ||
76 | // see IRegionDatastore | ||
77 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) | 94 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) |
78 | { | 95 | { |
79 | } | 96 | } |
@@ -83,12 +100,20 @@ namespace OpenSim.Data.Null | |||
83 | return new List<SceneObjectGroup>(); | 100 | return new List<SceneObjectGroup>(); |
84 | } | 101 | } |
85 | 102 | ||
103 | Dictionary<UUID, double[,]> m_terrains = new Dictionary<UUID, double[,]>(); | ||
86 | public void StoreTerrain(double[,] ter, UUID regionID) | 104 | public void StoreTerrain(double[,] ter, UUID regionID) |
87 | { | 105 | { |
106 | if (m_terrains.ContainsKey(regionID)) | ||
107 | m_terrains.Remove(regionID); | ||
108 | m_terrains.Add(regionID, ter); | ||
88 | } | 109 | } |
89 | 110 | ||
90 | public double[,] LoadTerrain(UUID regionID) | 111 | public double[,] LoadTerrain(UUID regionID) |
91 | { | 112 | { |
113 | if (m_terrains.ContainsKey(regionID)) | ||
114 | { | ||
115 | return m_terrains[regionID]; | ||
116 | } | ||
92 | return null; | 117 | return null; |
93 | } | 118 | } |
94 | 119 | ||
diff --git a/OpenSim/Data/Null/NullUserAccountData.cs b/OpenSim/Data/Null/NullUserAccountData.cs new file mode 100644 index 0000000..241616b --- /dev/null +++ b/OpenSim/Data/Null/NullUserAccountData.cs | |||
@@ -0,0 +1,202 @@ | |||
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.Reflection; | ||
32 | using System.Text; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Data; | ||
37 | |||
38 | namespace OpenSim.Data.Null | ||
39 | { | ||
40 | public class NullUserAccountData : IUserAccountData | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | private Dictionary<UUID, UserAccountData> m_DataByUUID = new Dictionary<UUID, UserAccountData>(); | ||
45 | private Dictionary<string, UserAccountData> m_DataByName = new Dictionary<string, UserAccountData>(); | ||
46 | private Dictionary<string, UserAccountData> m_DataByEmail = new Dictionary<string, UserAccountData>(); | ||
47 | |||
48 | public NullUserAccountData(string connectionString, string realm) | ||
49 | { | ||
50 | // m_log.DebugFormat( | ||
51 | // "[NULL USER ACCOUNT DATA]: Initializing new NullUserAccountData with connectionString [{0}], realm [{1}]", | ||
52 | // connectionString, realm); | ||
53 | } | ||
54 | |||
55 | /// <summary> | ||
56 | /// Tries to implement the Get [] semantics, but it cuts corners like crazy. | ||
57 | /// Specifically, it relies on the knowledge that the only Gets used are | ||
58 | /// keyed on PrincipalID, Email, and FirstName+LastName. | ||
59 | /// </summary> | ||
60 | /// <param name="fields"></param> | ||
61 | /// <param name="values"></param> | ||
62 | /// <returns></returns> | ||
63 | public UserAccountData[] Get(string[] fields, string[] values) | ||
64 | { | ||
65 | // if (m_log.IsDebugEnabled) | ||
66 | // { | ||
67 | // m_log.DebugFormat( | ||
68 | // "[NULL USER ACCOUNT DATA]: Called Get with fields [{0}], values [{1}]", | ||
69 | // string.Join(", ", fields), string.Join(", ", values)); | ||
70 | // } | ||
71 | |||
72 | UserAccountData[] userAccounts = new UserAccountData[0]; | ||
73 | |||
74 | List<string> fieldsLst = new List<string>(fields); | ||
75 | if (fieldsLst.Contains("PrincipalID")) | ||
76 | { | ||
77 | int i = fieldsLst.IndexOf("PrincipalID"); | ||
78 | UUID id = UUID.Zero; | ||
79 | if (UUID.TryParse(values[i], out id)) | ||
80 | if (m_DataByUUID.ContainsKey(id)) | ||
81 | userAccounts = new UserAccountData[] { m_DataByUUID[id] }; | ||
82 | } | ||
83 | else if (fieldsLst.Contains("FirstName") && fieldsLst.Contains("LastName")) | ||
84 | { | ||
85 | int findex = fieldsLst.IndexOf("FirstName"); | ||
86 | int lindex = fieldsLst.IndexOf("LastName"); | ||
87 | if (m_DataByName.ContainsKey(values[findex] + " " + values[lindex])) | ||
88 | { | ||
89 | userAccounts = new UserAccountData[] { m_DataByName[values[findex] + " " + values[lindex]] }; | ||
90 | } | ||
91 | } | ||
92 | else if (fieldsLst.Contains("Email")) | ||
93 | { | ||
94 | int i = fieldsLst.IndexOf("Email"); | ||
95 | if (m_DataByEmail.ContainsKey(values[i])) | ||
96 | userAccounts = new UserAccountData[] { m_DataByEmail[values[i]] }; | ||
97 | } | ||
98 | |||
99 | // if (m_log.IsDebugEnabled) | ||
100 | // { | ||
101 | // StringBuilder sb = new StringBuilder(); | ||
102 | // foreach (UserAccountData uad in userAccounts) | ||
103 | // sb.AppendFormat("({0} {1} {2}) ", uad.FirstName, uad.LastName, uad.PrincipalID); | ||
104 | // | ||
105 | // m_log.DebugFormat( | ||
106 | // "[NULL USER ACCOUNT DATA]: Returning {0} user accounts out of {1}: [{2}]", userAccounts.Length, m_DataByName.Count, sb); | ||
107 | // } | ||
108 | |||
109 | return userAccounts; | ||
110 | } | ||
111 | |||
112 | public bool Store(UserAccountData data) | ||
113 | { | ||
114 | if (data == null) | ||
115 | return false; | ||
116 | |||
117 | m_log.DebugFormat( | ||
118 | "[NULL USER ACCOUNT DATA]: Storing user account {0} {1} {2} {3}", | ||
119 | data.FirstName, data.LastName, data.PrincipalID, this.GetHashCode()); | ||
120 | |||
121 | m_DataByUUID[data.PrincipalID] = data; | ||
122 | m_DataByName[data.FirstName + " " + data.LastName] = data; | ||
123 | if (data.Data.ContainsKey("Email") && data.Data["Email"] != null && data.Data["Email"] != string.Empty) | ||
124 | m_DataByEmail[data.Data["Email"]] = data; | ||
125 | |||
126 | // m_log.DebugFormat("m_DataByUUID count is {0}, m_DataByName count is {1}", m_DataByUUID.Count, m_DataByName.Count); | ||
127 | |||
128 | return true; | ||
129 | } | ||
130 | |||
131 | public UserAccountData[] GetUsers(UUID scopeID, string query) | ||
132 | { | ||
133 | // m_log.DebugFormat( | ||
134 | // "[NULL USER ACCOUNT DATA]: Called GetUsers with scope [{0}], query [{1}]", scopeID, query); | ||
135 | |||
136 | string[] words = query.Split(new char[] { ' ' }); | ||
137 | |||
138 | for (int i = 0; i < words.Length; i++) | ||
139 | { | ||
140 | if (words[i].Length < 3) | ||
141 | { | ||
142 | if (i != words.Length - 1) | ||
143 | Array.Copy(words, i + 1, words, i, words.Length - i - 1); | ||
144 | Array.Resize(ref words, words.Length - 1); | ||
145 | } | ||
146 | } | ||
147 | |||
148 | if (words.Length == 0) | ||
149 | return new UserAccountData[0]; | ||
150 | |||
151 | if (words.Length > 2) | ||
152 | return new UserAccountData[0]; | ||
153 | |||
154 | List<string> lst = new List<string>(m_DataByName.Keys); | ||
155 | if (words.Length == 1) | ||
156 | { | ||
157 | lst = lst.FindAll(delegate(string s) { return s.StartsWith(words[0]); }); | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | lst = lst.FindAll(delegate(string s) { return s.Contains(words[0]) || s.Contains(words[1]); }); | ||
162 | } | ||
163 | |||
164 | if (lst == null || (lst != null && lst.Count == 0)) | ||
165 | return new UserAccountData[0]; | ||
166 | |||
167 | UserAccountData[] result = new UserAccountData[lst.Count]; | ||
168 | int n = 0; | ||
169 | foreach (string key in lst) | ||
170 | result[n++] = m_DataByName[key]; | ||
171 | |||
172 | return result; | ||
173 | } | ||
174 | |||
175 | public bool Delete(string field, string val) | ||
176 | { | ||
177 | // Only delete by PrincipalID | ||
178 | if (field.Equals("PrincipalID")) | ||
179 | { | ||
180 | UUID uuid = UUID.Zero; | ||
181 | if (UUID.TryParse(val, out uuid) && m_DataByUUID.ContainsKey(uuid)) | ||
182 | { | ||
183 | UserAccountData account = m_DataByUUID[uuid]; | ||
184 | m_DataByUUID.Remove(uuid); | ||
185 | if (m_DataByName.ContainsKey(account.FirstName + " " + account.LastName)) | ||
186 | m_DataByName.Remove(account.FirstName + " " + account.LastName); | ||
187 | if (account.Data.ContainsKey("Email") && account.Data["Email"] != string.Empty && m_DataByEmail.ContainsKey(account.Data["Email"])) | ||
188 | m_DataByEmail.Remove(account.Data["Email"]); | ||
189 | |||
190 | return true; | ||
191 | } | ||
192 | } | ||
193 | |||
194 | return false; | ||
195 | } | ||
196 | |||
197 | public UserAccountData[] GetUsersWhere(UUID scopeID, string where) | ||
198 | { | ||
199 | return null; | ||
200 | } | ||
201 | } | ||
202 | } | ||