diff options
Diffstat (limited to 'OpenSim/Data/Null')
-rw-r--r-- | OpenSim/Data/Null/NullAuthenticationData.cs | 81 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullAvatarData.cs | 93 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullDataStore.cs | 6 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullFriendsData.cs | 92 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullInventoryData.cs | 193 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullPresenceData.cs | 227 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullRegionData.cs | 69 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullUserAccountData.cs | 160 |
8 files changed, 915 insertions, 6 deletions
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/NullDataStore.cs b/OpenSim/Data/Null/NullDataStore.cs index 4b6d0f3..3ba44bb 100644 --- a/OpenSim/Data/Null/NullDataStore.cs +++ b/OpenSim/Data/Null/NullDataStore.cs | |||
@@ -50,13 +50,13 @@ namespace OpenSim.Data.Null | |||
50 | public void StoreRegionSettings(RegionSettings rs) | 50 | public void StoreRegionSettings(RegionSettings rs) |
51 | { | 51 | { |
52 | } | 52 | } |
53 | public RegionMeta7WindlightData LoadRegionWindlightSettings(UUID regionUUID) | 53 | public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) |
54 | { | 54 | { |
55 | //This connector doesn't support the windlight module yet | 55 | //This connector doesn't support the windlight module yet |
56 | //Return default LL windlight settings | 56 | //Return default LL windlight settings |
57 | return new RegionMeta7WindlightData(); | 57 | return new RegionLightShareData(); |
58 | } | 58 | } |
59 | public void StoreRegionWindlightSettings(RegionMeta7WindlightData wl) | 59 | public void StoreRegionWindlightSettings(RegionLightShareData wl) |
60 | { | 60 | { |
61 | //This connector doesn't support the windlight module yet | 61 | //This connector doesn't support the windlight module yet |
62 | } | 62 | } |
diff --git a/OpenSim/Data/Null/NullFriendsData.cs b/OpenSim/Data/Null/NullFriendsData.cs new file mode 100644 index 0000000..e7f7fd3 --- /dev/null +++ b/OpenSim/Data/Null/NullFriendsData.cs | |||
@@ -0,0 +1,92 @@ | |||
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 | /// <summary> | ||
46 | /// Tries to implement the Get [] semantics, but it cuts corners. | ||
47 | /// Specifically, it gets all friendships even if they weren't accepted yet. | ||
48 | /// </summary> | ||
49 | /// <param name="fields"></param> | ||
50 | /// <param name="values"></param> | ||
51 | /// <returns></returns> | ||
52 | public FriendsData[] GetFriends(UUID userID) | ||
53 | { | ||
54 | List<FriendsData> lst = m_Data.FindAll(delegate (FriendsData fdata) | ||
55 | { | ||
56 | return fdata.PrincipalID == userID; | ||
57 | }); | ||
58 | |||
59 | if (lst != null) | ||
60 | return lst.ToArray(); | ||
61 | |||
62 | return new FriendsData[0]; | ||
63 | } | ||
64 | |||
65 | public bool Store(FriendsData data) | ||
66 | { | ||
67 | if (data == null) | ||
68 | return false; | ||
69 | |||
70 | m_Data.Add(data); | ||
71 | |||
72 | return true; | ||
73 | } | ||
74 | |||
75 | public bool Delete(UUID userID, string friendID) | ||
76 | { | ||
77 | List<FriendsData> lst = m_Data.FindAll(delegate(FriendsData fdata) { return fdata.PrincipalID == userID; }); | ||
78 | if (lst != null) | ||
79 | { | ||
80 | FriendsData friend = lst.Find(delegate(FriendsData fdata) { return fdata.Friend == friendID; }); | ||
81 | if (friendID != null) | ||
82 | { | ||
83 | m_Data.Remove(friend); | ||
84 | return true; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | return false; | ||
89 | } | ||
90 | |||
91 | } | ||
92 | } | ||
diff --git a/OpenSim/Data/Null/NullInventoryData.cs b/OpenSim/Data/Null/NullInventoryData.cs new file mode 100644 index 0000000..8f196e2 --- /dev/null +++ b/OpenSim/Data/Null/NullInventoryData.cs | |||
@@ -0,0 +1,193 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | |||
4 | using OpenMetaverse; | ||
5 | using OpenSim.Framework; | ||
6 | |||
7 | namespace OpenSim.Data.Null | ||
8 | { | ||
9 | /// <summary> | ||
10 | /// This class is completely null. | ||
11 | /// </summary> | ||
12 | public class NullInventoryData : IInventoryDataPlugin | ||
13 | { | ||
14 | public string Version { get { return "1.0.0.0"; } } | ||
15 | |||
16 | public void Initialise() | ||
17 | { | ||
18 | } | ||
19 | |||
20 | public void Dispose() | ||
21 | { | ||
22 | // Do nothing. | ||
23 | } | ||
24 | |||
25 | public string Name | ||
26 | { | ||
27 | get { return "Null Inventory Data Interface"; } | ||
28 | } | ||
29 | |||
30 | public void Initialise(string connect) | ||
31 | { | ||
32 | } | ||
33 | |||
34 | |||
35 | /// <summary> | ||
36 | /// Returns all descendent folders of this folder. Does not return the parent folder itself. | ||
37 | /// </summary> | ||
38 | /// <param name="parentID">The folder to get subfolders for</param> | ||
39 | /// <returns>A list of inventory folders</returns> | ||
40 | public List<InventoryFolderBase> getFolderHierarchy(UUID parentID) | ||
41 | { | ||
42 | return new List<InventoryFolderBase>(); | ||
43 | } | ||
44 | |||
45 | /// <summary> | ||
46 | /// Returns a list of inventory items contained within the specified folder | ||
47 | /// </summary> | ||
48 | /// <param name="folderID">The UUID of the target folder</param> | ||
49 | /// <returns>A List of InventoryItemBase items</returns> | ||
50 | public List<InventoryItemBase> getInventoryInFolder(UUID folderID) | ||
51 | { | ||
52 | return new List<InventoryItemBase>(); | ||
53 | } | ||
54 | |||
55 | /// <summary> | ||
56 | /// Returns a list of the root folders within a users inventory | ||
57 | /// </summary> | ||
58 | /// <param name="user">The user whos inventory is to be searched</param> | ||
59 | /// <returns>A list of folder objects</returns> | ||
60 | public List<InventoryFolderBase> getUserRootFolders(UUID user) | ||
61 | { | ||
62 | return new List<InventoryFolderBase>(); | ||
63 | } | ||
64 | |||
65 | /// <summary> | ||
66 | /// Returns the users inventory root folder. | ||
67 | /// </summary> | ||
68 | /// <param name="user">The UUID of the user who is having inventory being returned</param> | ||
69 | /// <returns>Root inventory folder, null if no root inventory folder was found</returns> | ||
70 | public InventoryFolderBase getUserRootFolder(UUID user) | ||
71 | { | ||
72 | return null; | ||
73 | } | ||
74 | |||
75 | /// <summary> | ||
76 | /// Returns a list of inventory folders contained in the folder 'parentID' | ||
77 | /// </summary> | ||
78 | /// <param name="parentID">The folder to get subfolders for</param> | ||
79 | /// <returns>A list of inventory folders</returns> | ||
80 | public List<InventoryFolderBase> getInventoryFolders(UUID parentID) | ||
81 | { | ||
82 | return new List<InventoryFolderBase>(); | ||
83 | } | ||
84 | |||
85 | /// <summary> | ||
86 | /// Returns an inventory item by its UUID | ||
87 | /// </summary> | ||
88 | /// <param name="item">The UUID of the item to be returned</param> | ||
89 | /// <returns>A class containing item information</returns> | ||
90 | public InventoryItemBase getInventoryItem(UUID item) | ||
91 | { | ||
92 | return null; | ||
93 | } | ||
94 | |||
95 | /// <summary> | ||
96 | /// Returns a specified inventory folder by its UUID | ||
97 | /// </summary> | ||
98 | /// <param name="folder">The UUID of the folder to be returned</param> | ||
99 | /// <returns>A class containing folder information</returns> | ||
100 | public InventoryFolderBase getInventoryFolder(UUID folder) | ||
101 | { | ||
102 | return null; | ||
103 | } | ||
104 | |||
105 | /// <summary> | ||
106 | /// Creates a new inventory item based on item | ||
107 | /// </summary> | ||
108 | /// <param name="item">The item to be created</param> | ||
109 | public void addInventoryItem(InventoryItemBase item) | ||
110 | { | ||
111 | } | ||
112 | |||
113 | /// <summary> | ||
114 | /// Updates an inventory item with item (updates based on ID) | ||
115 | /// </summary> | ||
116 | /// <param name="item">The updated item</param> | ||
117 | public void updateInventoryItem(InventoryItemBase item) | ||
118 | { | ||
119 | } | ||
120 | |||
121 | /// <summary> | ||
122 | /// | ||
123 | /// </summary> | ||
124 | /// <param name="item"></param> | ||
125 | public void deleteInventoryItem(UUID item) | ||
126 | { | ||
127 | } | ||
128 | |||
129 | /// <summary> | ||
130 | /// | ||
131 | /// </summary> | ||
132 | /// <param name="item"></param> | ||
133 | public InventoryItemBase queryInventoryItem(UUID item) | ||
134 | { | ||
135 | return null; | ||
136 | } | ||
137 | |||
138 | /// <summary> | ||
139 | /// | ||
140 | /// </summary> | ||
141 | /// <param name="item"></param> | ||
142 | public InventoryFolderBase queryInventoryFolder(UUID folder) | ||
143 | { | ||
144 | return null; | ||
145 | } | ||
146 | |||
147 | /// <summary> | ||
148 | /// Adds a new folder specified by folder | ||
149 | /// </summary> | ||
150 | /// <param name="folder">The inventory folder</param> | ||
151 | public void addInventoryFolder(InventoryFolderBase folder) | ||
152 | { | ||
153 | } | ||
154 | |||
155 | /// <summary> | ||
156 | /// Updates a folder based on its ID with folder | ||
157 | /// </summary> | ||
158 | /// <param name="folder">The inventory folder</param> | ||
159 | public void updateInventoryFolder(InventoryFolderBase folder) | ||
160 | { | ||
161 | } | ||
162 | |||
163 | /// <summary> | ||
164 | /// Updates a folder based on its ID with folder | ||
165 | /// </summary> | ||
166 | /// <param name="folder">The inventory folder</param> | ||
167 | public void moveInventoryFolder(InventoryFolderBase folder) | ||
168 | { | ||
169 | } | ||
170 | |||
171 | /// <summary> | ||
172 | /// Deletes a folder. Thie will delete both the folder itself and its contents (items and descendent folders) | ||
173 | /// </summary> | ||
174 | /// <param name="folder">The id of the folder</param> | ||
175 | public void deleteInventoryFolder(UUID folder) | ||
176 | { | ||
177 | } | ||
178 | |||
179 | /// <summary> | ||
180 | /// Returns all activated gesture-items in the inventory of the specified avatar. | ||
181 | /// </summary> | ||
182 | /// <param name="avatarID"> | ||
183 | /// The <see cref="UUID"/> of the avatar | ||
184 | /// </param> | ||
185 | /// <returns> | ||
186 | /// The list of gestures (<see cref="InventoryItemBase"/>s) | ||
187 | /// </returns> | ||
188 | public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) | ||
189 | { | ||
190 | return new List<InventoryItemBase>(); | ||
191 | } | ||
192 | } | ||
193 | } | ||
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..d596698 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs | |||
@@ -31,32 +31,45 @@ 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) |
51 | { | 62 | { |
52 | if (regionName.Contains("%")) | 63 | if (regionName.Contains("%")) |
53 | { | 64 | { |
54 | if (r.RegionName.Contains(regionName.Replace("%", ""))) | 65 | string cleanname = regionName.Replace("%", ""); |
66 | m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanname.ToLower(), r.RegionName.ToLower()); | ||
67 | if (r.RegionName.ToLower().Contains(cleanname.ToLower())) | ||
55 | ret.Add(r); | 68 | ret.Add(r); |
56 | } | 69 | } |
57 | else | 70 | else |
58 | { | 71 | { |
59 | if (r.RegionName == regionName) | 72 | if (r.RegionName.ToLower() == regionName.ToLower()) |
60 | ret.Add(r); | 73 | ret.Add(r); |
61 | } | 74 | } |
62 | } | 75 | } |
@@ -69,6 +82,9 @@ namespace OpenSim.Data.Null | |||
69 | 82 | ||
70 | public RegionData Get(int posX, int posY, UUID scopeID) | 83 | public RegionData Get(int posX, int posY, UUID scopeID) |
71 | { | 84 | { |
85 | if (Instance != this) | ||
86 | return Instance.Get(posX, posY, scopeID); | ||
87 | |||
72 | List<RegionData> ret = new List<RegionData>(); | 88 | List<RegionData> ret = new List<RegionData>(); |
73 | 89 | ||
74 | foreach (RegionData r in m_regionData.Values) | 90 | foreach (RegionData r in m_regionData.Values) |
@@ -85,6 +101,9 @@ namespace OpenSim.Data.Null | |||
85 | 101 | ||
86 | public RegionData Get(UUID regionID, UUID scopeID) | 102 | public RegionData Get(UUID regionID, UUID scopeID) |
87 | { | 103 | { |
104 | if (Instance != this) | ||
105 | return Instance.Get(regionID, scopeID); | ||
106 | |||
88 | if (m_regionData.ContainsKey(regionID)) | 107 | if (m_regionData.ContainsKey(regionID)) |
89 | return m_regionData[regionID]; | 108 | return m_regionData[regionID]; |
90 | 109 | ||
@@ -93,6 +112,9 @@ namespace OpenSim.Data.Null | |||
93 | 112 | ||
94 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) | 113 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) |
95 | { | 114 | { |
115 | if (Instance != this) | ||
116 | return Instance.Get(startX, startY, endX, endY, scopeID); | ||
117 | |||
96 | List<RegionData> ret = new List<RegionData>(); | 118 | List<RegionData> ret = new List<RegionData>(); |
97 | 119 | ||
98 | foreach (RegionData r in m_regionData.Values) | 120 | foreach (RegionData r in m_regionData.Values) |
@@ -106,6 +128,9 @@ namespace OpenSim.Data.Null | |||
106 | 128 | ||
107 | public bool Store(RegionData data) | 129 | public bool Store(RegionData data) |
108 | { | 130 | { |
131 | if (Instance != this) | ||
132 | return Instance.Store(data); | ||
133 | |||
109 | m_regionData[data.RegionID] = data; | 134 | m_regionData[data.RegionID] = data; |
110 | 135 | ||
111 | return true; | 136 | return true; |
@@ -113,6 +138,9 @@ namespace OpenSim.Data.Null | |||
113 | 138 | ||
114 | public bool SetDataItem(UUID regionID, string item, string value) | 139 | public bool SetDataItem(UUID regionID, string item, string value) |
115 | { | 140 | { |
141 | if (Instance != this) | ||
142 | return Instance.SetDataItem(regionID, item, value); | ||
143 | |||
116 | if (!m_regionData.ContainsKey(regionID)) | 144 | if (!m_regionData.ContainsKey(regionID)) |
117 | return false; | 145 | return false; |
118 | 146 | ||
@@ -123,6 +151,9 @@ namespace OpenSim.Data.Null | |||
123 | 151 | ||
124 | public bool Delete(UUID regionID) | 152 | public bool Delete(UUID regionID) |
125 | { | 153 | { |
154 | if (Instance != this) | ||
155 | return Instance.Delete(regionID); | ||
156 | |||
126 | if (!m_regionData.ContainsKey(regionID)) | 157 | if (!m_regionData.ContainsKey(regionID)) |
127 | return false; | 158 | return false; |
128 | 159 | ||
@@ -130,5 +161,37 @@ namespace OpenSim.Data.Null | |||
130 | 161 | ||
131 | return true; | 162 | return true; |
132 | } | 163 | } |
164 | |||
165 | public List<RegionData> GetDefaultRegions(UUID scopeID) | ||
166 | { | ||
167 | if (Instance != this) | ||
168 | return Instance.GetDefaultRegions(scopeID); | ||
169 | |||
170 | List<RegionData> ret = new List<RegionData>(); | ||
171 | |||
172 | foreach (RegionData r in m_regionData.Values) | ||
173 | { | ||
174 | if ((Convert.ToInt32(r.Data["flags"]) & 1) != 0) | ||
175 | ret.Add(r); | ||
176 | } | ||
177 | |||
178 | return ret; | ||
179 | } | ||
180 | |||
181 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) | ||
182 | { | ||
183 | if (Instance != this) | ||
184 | return Instance.GetFallbackRegions(scopeID, x, y); | ||
185 | |||
186 | List<RegionData> ret = new List<RegionData>(); | ||
187 | |||
188 | foreach (RegionData r in m_regionData.Values) | ||
189 | { | ||
190 | if ((Convert.ToInt32(r.Data["flags"]) & 2) != 0) | ||
191 | ret.Add(r); | ||
192 | } | ||
193 | |||
194 | return ret; | ||
195 | } | ||
133 | } | 196 | } |
134 | } | 197 | } \ No newline at end of file |
diff --git a/OpenSim/Data/Null/NullUserAccountData.cs b/OpenSim/Data/Null/NullUserAccountData.cs new file mode 100644 index 0000000..9eb94e6 --- /dev/null +++ b/OpenSim/Data/Null/NullUserAccountData.cs | |||
@@ -0,0 +1,160 @@ | |||
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 | public bool Delete(string field, string val) | ||
139 | { | ||
140 | // Only delete by PrincipalID | ||
141 | if (field.Equals("PrincipalID")) | ||
142 | { | ||
143 | UUID uuid = UUID.Zero; | ||
144 | if (UUID.TryParse(val, out uuid) && m_DataByUUID.ContainsKey(uuid)) | ||
145 | { | ||
146 | UserAccountData account = m_DataByUUID[uuid]; | ||
147 | m_DataByUUID.Remove(uuid); | ||
148 | if (m_DataByName.ContainsKey(account.FirstName + " " + account.LastName)) | ||
149 | m_DataByName.Remove(account.FirstName + " " + account.LastName); | ||
150 | if (account.Data.ContainsKey("Email") && account.Data["Email"] != string.Empty && m_DataByEmail.ContainsKey(account.Data["Email"])) | ||
151 | m_DataByEmail.Remove(account.Data["Email"]); | ||
152 | |||
153 | return true; | ||
154 | } | ||
155 | } | ||
156 | |||
157 | return false; | ||
158 | } | ||
159 | } | ||
160 | } | ||