diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/Null/NullAuthenticationData.cs (renamed from OpenSim/Grid/UserServer.Modules/GridInfoServiceModule.cs) | 58 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullAvatarData.cs (renamed from OpenSim/Grid/MessagingServer.Modules/PresenceBackreferenceEntry.cs) | 77 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullPresenceData.cs | 261 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullRegionData.cs | 61 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullUserAccountData.cs | 139 |
5 files changed, 528 insertions, 68 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/GridInfoServiceModule.cs b/OpenSim/Data/Null/NullAuthenticationData.cs index 0c84348..3fb3105 100644 --- a/OpenSim/Grid/UserServer.Modules/GridInfoServiceModule.cs +++ b/OpenSim/Data/Null/NullAuthenticationData.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -26,54 +26,56 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using log4net.Config; | ||
34 | using OpenMetaverse; | 31 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Communications; | 33 | using OpenSim.Data; |
37 | using OpenSim.Framework.Communications.Services; | ||
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | using OpenSim.Framework.Servers; | ||
40 | using OpenSim.Framework.Servers.HttpServer; | ||
41 | using OpenSim.Grid.Communications.OGS1; | ||
42 | using OpenSim.Grid.Framework; | ||
43 | 34 | ||
44 | namespace OpenSim.Grid.UserServer.Modules | 35 | namespace OpenSim.Data.Null |
45 | { | 36 | { |
46 | public class GridInfoServiceModule | 37 | public class NullAuthenticationData : IAuthenticationData |
47 | { | 38 | { |
48 | protected IGridServiceCore m_core; | 39 | private static Dictionary<UUID, AuthenticationData> m_DataByUUID = new Dictionary<UUID, AuthenticationData>(); |
49 | protected GridInfoService m_gridInfoService; | 40 | private static Dictionary<UUID, string> m_Tokens = new Dictionary<UUID, string>(); |
50 | protected BaseHttpServer m_httpServer; | ||
51 | 41 | ||
52 | public GridInfoServiceModule() | 42 | public NullAuthenticationData(string connectionString, string realm) |
53 | { | 43 | { |
54 | } | 44 | } |
55 | 45 | ||
56 | public void Initialise(IGridServiceCore core) | 46 | public AuthenticationData Get(UUID principalID) |
57 | { | 47 | { |
58 | m_core = core; | 48 | if (m_DataByUUID.ContainsKey(principalID)) |
59 | m_gridInfoService = new GridInfoService(); | 49 | return m_DataByUUID[principalID]; |
50 | |||
51 | return null; | ||
60 | } | 52 | } |
61 | 53 | ||
62 | public void PostInitialise() | 54 | public bool Store(AuthenticationData data) |
63 | { | 55 | { |
56 | m_DataByUUID[data.PrincipalID] = data; | ||
57 | return true; | ||
58 | } | ||
64 | 59 | ||
60 | public bool SetDataItem(UUID principalID, string item, string value) | ||
61 | { | ||
62 | // Not implemented | ||
63 | return false; | ||
65 | } | 64 | } |
66 | 65 | ||
67 | public void RegisterHandlers(BaseHttpServer httpServer) | 66 | public bool SetToken(UUID principalID, string token, int lifetime) |
68 | { | 67 | { |
69 | m_httpServer = httpServer; | 68 | m_Tokens[principalID] = token; |
70 | m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", | 69 | return true; |
71 | m_gridInfoService.RestGetGridInfoMethod)); | ||
72 | m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod); | ||
73 | } | 70 | } |
74 | 71 | ||
75 | public void Close() | 72 | public bool CheckToken(UUID principalID, string token, int lifetime) |
76 | { | 73 | { |
74 | if (m_Tokens.ContainsKey(principalID)) | ||
75 | return m_Tokens[principalID] == token; | ||
76 | |||
77 | return false; | ||
77 | } | 78 | } |
79 | |||
78 | } | 80 | } |
79 | } | 81 | } |
diff --git a/OpenSim/Grid/MessagingServer.Modules/PresenceBackreferenceEntry.cs b/OpenSim/Data/Null/NullAvatarData.cs index 67dde6d..c81ba43 100644 --- a/OpenSim/Grid/MessagingServer.Modules/PresenceBackreferenceEntry.cs +++ b/OpenSim/Data/Null/NullAvatarData.cs | |||
@@ -25,72 +25,69 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
29 | using System.Collections; | ||
28 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
29 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Data; | ||
30 | 34 | ||
31 | namespace OpenSim.Grid.MessagingServer.Modules | 35 | namespace OpenSim.Data.Null |
32 | { | 36 | { |
33 | // This is a wrapper for a List<UUID> so it can be happily stored in a hashtable. | 37 | public class NullAvatarData : IAvatarData |
34 | public class PresenceBackreferenceEntry | ||
35 | { | 38 | { |
36 | List<UUID> AgentList = new List<UUID>(); | 39 | private static Dictionary<UUID, AvatarBaseData> m_DataByUUID = new Dictionary<UUID, AvatarBaseData>(); |
37 | 40 | ||
38 | public PresenceBackreferenceEntry() | 41 | public NullAvatarData(string connectionString, string realm) |
39 | { | 42 | { |
40 | |||
41 | } | 43 | } |
42 | 44 | ||
43 | public void Add(UUID item) | 45 | public AvatarBaseData[] Get(string field, string val) |
44 | { | 46 | { |
45 | lock (AgentList) | 47 | if (field == "PrincipalID") |
46 | { | 48 | { |
47 | AgentList.Add(item); | 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] }; | ||
48 | } | 53 | } |
49 | } | ||
50 | 54 | ||
51 | public UUID getitem(int index) | 55 | // Fail |
52 | { | 56 | return new AvatarBaseData[0]; |
53 | UUID result = UUID.Zero; | ||
54 | lock (AgentList) | ||
55 | { | ||
56 | if (index > 0 && index < AgentList.Count) | ||
57 | { | ||
58 | result = AgentList[index]; | ||
59 | } | ||
60 | } | ||
61 | return result; | ||
62 | } | 57 | } |
63 | 58 | ||
64 | public int Count | 59 | public bool Store(AvatarBaseData data) |
65 | { | 60 | { |
66 | get | 61 | m_DataByUUID[data.PrincipalID] = data; |
67 | { | 62 | return true; |
68 | int count = 0; | ||
69 | lock (AgentList) | ||
70 | { | ||
71 | count = AgentList.Count; | ||
72 | } | ||
73 | return count; | ||
74 | } | ||
75 | } | 63 | } |
76 | 64 | ||
77 | public void Remove(UUID item) | 65 | public bool Delete(UUID principalID, string name) |
78 | { | 66 | { |
79 | lock (AgentList) | 67 | if (m_DataByUUID.ContainsKey(principalID) && m_DataByUUID[principalID].Data.ContainsKey(name)) |
80 | { | 68 | { |
81 | if (AgentList.Contains(item)) | 69 | m_DataByUUID[principalID].Data.Remove(name); |
82 | AgentList.Remove(item); | 70 | return true; |
83 | } | 71 | } |
72 | |||
73 | return false; | ||
84 | } | 74 | } |
85 | 75 | ||
86 | public bool contains(UUID item) | 76 | public bool Delete(string field, string val) |
87 | { | 77 | { |
88 | bool result = false; | 78 | if (field == "PrincipalID") |
89 | lock (AgentList) | ||
90 | { | 79 | { |
91 | result = AgentList.Contains(item); | 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 | } | ||
92 | } | 87 | } |
93 | return result; | 88 | |
89 | return false; | ||
94 | } | 90 | } |
91 | |||
95 | } | 92 | } |
96 | } | 93 | } |
diff --git a/OpenSim/Data/Null/NullPresenceData.cs b/OpenSim/Data/Null/NullPresenceData.cs new file mode 100644 index 0000000..5f78691 --- /dev/null +++ b/OpenSim/Data/Null/NullPresenceData.cs | |||
@@ -0,0 +1,261 @@ | |||
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 | { | ||
47 | Instance = this; | ||
48 | |||
49 | //Console.WriteLine("[XXX] NullRegionData constructor"); | ||
50 | // Let's stick in a test presence | ||
51 | PresenceData p = new PresenceData(); | ||
52 | p.SessionID = UUID.Zero; | ||
53 | p.UserID = UUID.Zero.ToString(); | ||
54 | p.Data = new Dictionary<string, string>(); | ||
55 | p.Data["Online"] = true.ToString(); | ||
56 | m_presenceData.Add(UUID.Zero, p); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | public bool Store(PresenceData data) | ||
61 | { | ||
62 | if (Instance != this) | ||
63 | return Instance.Store(data); | ||
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, string position, string lookAt) | ||
100 | { | ||
101 | if (Instance != this) | ||
102 | return Instance.ReportAgent(sessionID, regionID, position, lookAt); | ||
103 | if (m_presenceData.ContainsKey(sessionID)) | ||
104 | { | ||
105 | m_presenceData[sessionID].RegionID = regionID; | ||
106 | m_presenceData[sessionID].Data["Position"] = position; | ||
107 | m_presenceData[sessionID].Data["LookAt"] = lookAt; | ||
108 | return true; | ||
109 | } | ||
110 | |||
111 | return false; | ||
112 | } | ||
113 | |||
114 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
115 | { | ||
116 | if (Instance != this) | ||
117 | return Instance.SetHomeLocation(userID, regionID, position, lookAt); | ||
118 | |||
119 | bool foundone = false; | ||
120 | foreach (PresenceData p in m_presenceData.Values) | ||
121 | { | ||
122 | if (p.UserID == userID) | ||
123 | { | ||
124 | p.Data["HomeRegionID"] = regionID.ToString(); | ||
125 | p.Data["HomePosition"] = position.ToString(); | ||
126 | p.Data["HomeLookAt"] = lookAt.ToString(); | ||
127 | foundone = true; | ||
128 | } | ||
129 | } | ||
130 | |||
131 | return foundone; | ||
132 | } | ||
133 | |||
134 | public PresenceData[] Get(string field, string data) | ||
135 | { | ||
136 | if (Instance != this) | ||
137 | return Instance.Get(field, data); | ||
138 | |||
139 | List<PresenceData> presences = new List<PresenceData>(); | ||
140 | if (field == "UserID") | ||
141 | { | ||
142 | foreach (PresenceData p in m_presenceData.Values) | ||
143 | if (p.UserID == data) | ||
144 | presences.Add(p); | ||
145 | return presences.ToArray(); | ||
146 | } | ||
147 | else if (field == "SessionID") | ||
148 | { | ||
149 | UUID session = UUID.Zero; | ||
150 | if (!UUID.TryParse(data, out session)) | ||
151 | return presences.ToArray(); | ||
152 | |||
153 | if (m_presenceData.ContainsKey(session)) | ||
154 | { | ||
155 | presences.Add(m_presenceData[session]); | ||
156 | return presences.ToArray(); | ||
157 | } | ||
158 | } | ||
159 | else if (field == "RegionID") | ||
160 | { | ||
161 | UUID region = UUID.Zero; | ||
162 | if (!UUID.TryParse(data, out region)) | ||
163 | return presences.ToArray(); | ||
164 | foreach (PresenceData p in m_presenceData.Values) | ||
165 | if (p.RegionID == region) | ||
166 | presences.Add(p); | ||
167 | return presences.ToArray(); | ||
168 | } | ||
169 | else | ||
170 | { | ||
171 | foreach (PresenceData p in m_presenceData.Values) | ||
172 | { | ||
173 | if (p.Data.ContainsKey(field) && p.Data[field] == data) | ||
174 | presences.Add(p); | ||
175 | } | ||
176 | return presences.ToArray(); | ||
177 | } | ||
178 | |||
179 | return presences.ToArray(); | ||
180 | } | ||
181 | |||
182 | public void Prune(string userID) | ||
183 | { | ||
184 | if (Instance != this) | ||
185 | { | ||
186 | Instance.Prune(userID); | ||
187 | return; | ||
188 | } | ||
189 | |||
190 | List<UUID> deleteSessions = new List<UUID>(); | ||
191 | int online = 0; | ||
192 | |||
193 | foreach (KeyValuePair<UUID, PresenceData> kvp in m_presenceData) | ||
194 | { | ||
195 | bool on = false; | ||
196 | if (bool.TryParse(kvp.Value.Data["Online"], out on) && on) | ||
197 | online++; | ||
198 | else | ||
199 | deleteSessions.Add(kvp.Key); | ||
200 | } | ||
201 | if (online == 0 && deleteSessions.Count > 0) | ||
202 | deleteSessions.RemoveAt(0); | ||
203 | |||
204 | foreach (UUID s in deleteSessions) | ||
205 | m_presenceData.Remove(s); | ||
206 | |||
207 | } | ||
208 | |||
209 | public bool Delete(string field, string data) | ||
210 | { | ||
211 | if (Instance != this) | ||
212 | return Delete(field, data); | ||
213 | |||
214 | List<UUID> presences = new List<UUID>(); | ||
215 | if (field == "UserID") | ||
216 | { | ||
217 | foreach (KeyValuePair<UUID, PresenceData> p in m_presenceData) | ||
218 | if (p.Value.UserID == data) | ||
219 | presences.Add(p.Key); | ||
220 | } | ||
221 | else if (field == "SessionID") | ||
222 | { | ||
223 | UUID session = UUID.Zero; | ||
224 | if (UUID.TryParse(data, out session)) | ||
225 | { | ||
226 | if (m_presenceData.ContainsKey(session)) | ||
227 | { | ||
228 | presences.Add(session); | ||
229 | } | ||
230 | } | ||
231 | } | ||
232 | else if (field == "RegionID") | ||
233 | { | ||
234 | UUID region = UUID.Zero; | ||
235 | if (UUID.TryParse(data, out region)) | ||
236 | { | ||
237 | foreach (KeyValuePair<UUID, PresenceData> p in m_presenceData) | ||
238 | if (p.Value.RegionID == region) | ||
239 | presences.Add(p.Key); | ||
240 | } | ||
241 | } | ||
242 | else | ||
243 | { | ||
244 | foreach (KeyValuePair<UUID, PresenceData> p in m_presenceData) | ||
245 | { | ||
246 | if (p.Value.Data.ContainsKey(field) && p.Value.Data[field] == data) | ||
247 | presences.Add(p.Key); | ||
248 | } | ||
249 | } | ||
250 | |||
251 | foreach (UUID u in presences) | ||
252 | m_presenceData.Remove(u); | ||
253 | |||
254 | if (presences.Count == 0) | ||
255 | return false; | ||
256 | |||
257 | return true; | ||
258 | } | ||
259 | |||
260 | } | ||
261 | } | ||
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 | } | ||