diff options
author | Diva Canto | 2013-05-07 18:01:48 -0700 |
---|---|---|
committer | Diva Canto | 2013-05-07 18:01:48 -0700 |
commit | e92c05ebbdc44084326c3dcfa0a2ca0958e4b5e6 (patch) | |
tree | 00f06fd1fabe55c5d579f4c33964f5ecbce13e46 /OpenSim | |
parent | BulletSim: normalize quaternian rotations when building compound linksets. (diff) | |
download | opensim-SC-e92c05ebbdc44084326c3dcfa0a2ca0958e4b5e6.zip opensim-SC-e92c05ebbdc44084326c3dcfa0a2ca0958e4b5e6.tar.gz opensim-SC-e92c05ebbdc44084326c3dcfa0a2ca0958e4b5e6.tar.bz2 opensim-SC-e92c05ebbdc44084326c3dcfa0a2ca0958e4b5e6.tar.xz |
Added AvatarPickerSearch capability handler.
Diffstat (limited to 'OpenSim')
6 files changed, 393 insertions, 35 deletions
diff --git a/OpenSim/Capabilities/Handlers/AvatarPickerSearch/AvatarPickerSearchHandler.cs b/OpenSim/Capabilities/Handlers/AvatarPickerSearch/AvatarPickerSearchHandler.cs new file mode 100644 index 0000000..4dca592 --- /dev/null +++ b/OpenSim/Capabilities/Handlers/AvatarPickerSearch/AvatarPickerSearchHandler.cs | |||
@@ -0,0 +1,116 @@ | |||
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.Collections.Specialized; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using System.Web; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Capabilities; | ||
39 | using OpenSim.Framework.Servers; | ||
40 | using OpenSim.Framework.Servers.HttpServer; | ||
41 | //using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Services.Interfaces; | ||
43 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
44 | |||
45 | namespace OpenSim.Capabilities.Handlers | ||
46 | { | ||
47 | public class AvatarPickerSearchHandler : BaseStreamHandler | ||
48 | { | ||
49 | private static readonly ILog m_log = | ||
50 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | private IPeople m_PeopleService; | ||
52 | |||
53 | public AvatarPickerSearchHandler(string path, IPeople peopleService, string name, string description) | ||
54 | : base("GET", path, name, description) | ||
55 | { | ||
56 | m_PeopleService = peopleService; | ||
57 | } | ||
58 | |||
59 | public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
60 | { | ||
61 | // Try to parse the texture ID from the request URL | ||
62 | NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); | ||
63 | string names = query.GetOne("names"); | ||
64 | string psize = query.GetOne("page_size"); | ||
65 | string pnumber = query.GetOne("page"); | ||
66 | |||
67 | if (m_PeopleService == null) | ||
68 | return FailureResponse(names, (int)System.Net.HttpStatusCode.InternalServerError, httpResponse); | ||
69 | |||
70 | if (string.IsNullOrEmpty(names) || names.Length < 3) | ||
71 | return FailureResponse(names, (int)System.Net.HttpStatusCode.BadRequest, httpResponse); | ||
72 | |||
73 | m_log.DebugFormat("[AVATAR PICKER SEARCH]: search for {0}", names); | ||
74 | |||
75 | int page_size = (string.IsNullOrEmpty(psize) ? 500 : Int32.Parse(psize)); | ||
76 | int page_number = (string.IsNullOrEmpty(pnumber) ? 1 : Int32.Parse(pnumber)); | ||
77 | |||
78 | // Full content request | ||
79 | httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK; | ||
80 | //httpResponse.ContentLength = ??; | ||
81 | httpResponse.ContentType = "application/llsd+xml"; | ||
82 | |||
83 | List<UserData> users = m_PeopleService.GetUserData(names, page_size, page_number); | ||
84 | |||
85 | LLSDAvatarPicker osdReply = new LLSDAvatarPicker(); | ||
86 | osdReply.next_page_url = httpRequest.RawUrl; | ||
87 | foreach (UserData u in users) | ||
88 | osdReply.agents.Array.Add(ConvertUserData(u)); | ||
89 | |||
90 | string reply = LLSDHelpers.SerialiseLLSDReply(osdReply); | ||
91 | return System.Text.Encoding.UTF8.GetBytes(reply); | ||
92 | } | ||
93 | |||
94 | private LLSDPerson ConvertUserData(UserData user) | ||
95 | { | ||
96 | LLSDPerson p = new LLSDPerson(); | ||
97 | p.legacy_first_name = user.FirstName; | ||
98 | p.legacy_last_name = user.LastName; | ||
99 | p.display_name = user.FirstName + " " + user.LastName; | ||
100 | if (user.LastName.StartsWith("@")) | ||
101 | p.username = user.FirstName.ToLower() + user.LastName.ToLower(); | ||
102 | else | ||
103 | p.username = user.FirstName.ToLower() + "." + user.LastName.ToLower(); | ||
104 | p.id = user.Id; | ||
105 | p.is_display_name_default = false; | ||
106 | return p; | ||
107 | } | ||
108 | |||
109 | private byte[] FailureResponse(string names, int statuscode, IOSHttpResponse httpResponse) | ||
110 | { | ||
111 | m_log.Error("[AVATAR PICKER SEARCH]: Error searching for " + names); | ||
112 | httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; | ||
113 | return System.Text.Encoding.UTF8.GetBytes(string.Empty); | ||
114 | } | ||
115 | } | ||
116 | } \ No newline at end of file | ||
diff --git a/OpenSim/Capabilities/LLSDAvatarPicker.cs b/OpenSim/Capabilities/LLSDAvatarPicker.cs new file mode 100644 index 0000000..d0b3f3a --- /dev/null +++ b/OpenSim/Capabilities/LLSDAvatarPicker.cs | |||
@@ -0,0 +1,51 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using OpenMetaverse; | ||
29 | |||
30 | namespace OpenSim.Framework.Capabilities | ||
31 | { | ||
32 | [OSDMap] | ||
33 | public class LLSDAvatarPicker | ||
34 | { | ||
35 | public string next_page_url; | ||
36 | // an array of LLSDPerson | ||
37 | public OSDArray agents = new OSDArray(); | ||
38 | } | ||
39 | |||
40 | [OSDMap] | ||
41 | public class LLSDPerson | ||
42 | { | ||
43 | public string username; | ||
44 | public string display_name; | ||
45 | //'display_name_next_update':d"1970-01-01T00:00:00Z" | ||
46 | public string legacy_first_name; | ||
47 | public string legacy_last_name; | ||
48 | public UUID id; | ||
49 | public bool is_display_name_default; | ||
50 | } | ||
51 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/IPeople.cs b/OpenSim/Framework/IPeople.cs new file mode 100644 index 0000000..b88e103 --- /dev/null +++ b/OpenSim/Framework/IPeople.cs | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Framework | ||
33 | { | ||
34 | public class UserData | ||
35 | { | ||
36 | public UUID Id { get; set; } | ||
37 | public string FirstName { get; set; } | ||
38 | public string LastName { get; set; } | ||
39 | public string HomeURL { get; set; } | ||
40 | public Dictionary<string, object> ServerURLs { get; set; } | ||
41 | } | ||
42 | |||
43 | public interface IPeople | ||
44 | { | ||
45 | List<UserData> GetUserData(string query, int page_size, int page_number); | ||
46 | } | ||
47 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/AvatarPickerSearchModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/AvatarPickerSearchModule.cs new file mode 100644 index 0000000..d7af1f2 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/AvatarPickerSearchModule.cs | |||
@@ -0,0 +1,140 @@ | |||
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.Specialized; | ||
31 | using System.Drawing; | ||
32 | using System.Drawing.Imaging; | ||
33 | using System.Reflection; | ||
34 | using System.IO; | ||
35 | using System.Web; | ||
36 | using log4net; | ||
37 | using Nini.Config; | ||
38 | using Mono.Addins; | ||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.StructuredData; | ||
41 | using OpenSim.Framework; | ||
42 | using OpenSim.Framework.Servers; | ||
43 | using OpenSim.Framework.Servers.HttpServer; | ||
44 | using OpenSim.Region.Framework.Interfaces; | ||
45 | using OpenSim.Region.Framework.Scenes; | ||
46 | using OpenSim.Services.Interfaces; | ||
47 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
48 | using OpenSim.Capabilities.Handlers; | ||
49 | |||
50 | namespace OpenSim.Region.ClientStack.Linden | ||
51 | { | ||
52 | |||
53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AvatarPickerSearchModule")] | ||
54 | public class AvatarPickerSearchModule : INonSharedRegionModule | ||
55 | { | ||
56 | private static readonly ILog m_log = | ||
57 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
58 | |||
59 | private Scene m_scene; | ||
60 | private IPeople m_People; | ||
61 | private bool m_Enabled = false; | ||
62 | |||
63 | private string m_URL; | ||
64 | |||
65 | #region ISharedRegionModule Members | ||
66 | |||
67 | public void Initialise(IConfigSource source) | ||
68 | { | ||
69 | IConfig config = source.Configs["ClientStack.LindenCaps"]; | ||
70 | if (config == null) | ||
71 | return; | ||
72 | |||
73 | m_URL = config.GetString("Cap_AvatarPickerSearch", string.Empty); | ||
74 | m_log.DebugFormat("[XXX]: Cap_AvatarPickerSearch = {0}", m_URL); | ||
75 | // Cap doesn't exist | ||
76 | if (m_URL != string.Empty) | ||
77 | m_Enabled = true; | ||
78 | } | ||
79 | |||
80 | public void AddRegion(Scene s) | ||
81 | { | ||
82 | if (!m_Enabled) | ||
83 | return; | ||
84 | |||
85 | m_scene = s; | ||
86 | } | ||
87 | |||
88 | public void RemoveRegion(Scene s) | ||
89 | { | ||
90 | if (!m_Enabled) | ||
91 | return; | ||
92 | |||
93 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
94 | m_scene = null; | ||
95 | } | ||
96 | |||
97 | public void RegionLoaded(Scene s) | ||
98 | { | ||
99 | if (!m_Enabled) | ||
100 | return; | ||
101 | |||
102 | m_People = m_scene.RequestModuleInterface<IPeople>(); | ||
103 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
104 | } | ||
105 | |||
106 | public void PostInitialise() | ||
107 | { | ||
108 | } | ||
109 | |||
110 | public void Close() { } | ||
111 | |||
112 | public string Name { get { return "AvatarPickerSearchModule"; } } | ||
113 | |||
114 | public Type ReplaceableInterface | ||
115 | { | ||
116 | get { return null; } | ||
117 | } | ||
118 | |||
119 | #endregion | ||
120 | |||
121 | public void RegisterCaps(UUID agentID, Caps caps) | ||
122 | { | ||
123 | UUID capID = UUID.Random(); | ||
124 | |||
125 | if (m_URL == "localhost") | ||
126 | { | ||
127 | m_log.DebugFormat("[AVATAR PICKER SEARCH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); | ||
128 | caps.RegisterHandler( | ||
129 | "AvatarPickerSearch", | ||
130 | new AvatarPickerSearchHandler("/CAPS/" + capID + "/", m_People, "AvatarPickerSearch", "Search for avatars by name")); | ||
131 | } | ||
132 | else | ||
133 | { | ||
134 | // m_log.DebugFormat("[AVATAR PICKER SEARCH]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); | ||
135 | caps.RegisterHandler("AvatarPickerSearch", m_URL); | ||
136 | } | ||
137 | } | ||
138 | |||
139 | } | ||
140 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs index 8ce20e9..fac93e6 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs | |||
@@ -70,7 +70,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
70 | 70 | ||
71 | #endregion ISharedRegionModule | 71 | #endregion ISharedRegionModule |
72 | 72 | ||
73 | protected override void AddAdditionalUsers(UUID avatarID, string query, List<UserData> users) | 73 | protected override void AddAdditionalUsers(string query, List<UserData> users) |
74 | { | 74 | { |
75 | if (query.Contains("@")) // First.Last@foo.com, maybe? | 75 | if (query.Contains("@")) // First.Last@foo.com, maybe? |
76 | { | 76 | { |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 7b823ba..6847e57 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -46,17 +46,8 @@ using Mono.Addins; | |||
46 | 46 | ||
47 | namespace OpenSim.Region.CoreModules.Framework.UserManagement | 47 | namespace OpenSim.Region.CoreModules.Framework.UserManagement |
48 | { | 48 | { |
49 | public class UserData | ||
50 | { | ||
51 | public UUID Id { get; set; } | ||
52 | public string FirstName { get; set; } | ||
53 | public string LastName { get; set; } | ||
54 | public string HomeURL { get; set; } | ||
55 | public Dictionary<string, object> ServerURLs { get; set; } | ||
56 | } | ||
57 | |||
58 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UserManagementModule")] | 49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UserManagementModule")] |
59 | public class UserManagementModule : ISharedRegionModule, IUserManagement | 50 | public class UserManagementModule : ISharedRegionModule, IUserManagement, IPeople |
60 | { | 51 | { |
61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
62 | 53 | ||
@@ -101,6 +92,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
101 | m_Scenes.Add(scene); | 92 | m_Scenes.Add(scene); |
102 | 93 | ||
103 | scene.RegisterModuleInterface<IUserManagement>(this); | 94 | scene.RegisterModuleInterface<IUserManagement>(this); |
95 | scene.RegisterModuleInterface<IPeople>(this); | ||
104 | scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); | 96 | scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); |
105 | scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); | 97 | scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); |
106 | } | 98 | } |
@@ -181,29 +173,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
181 | 173 | ||
182 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: HandleAvatarPickerRequest for {0}", query); | 174 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: HandleAvatarPickerRequest for {0}", query); |
183 | 175 | ||
184 | // searhc the user accounts service | 176 | List<UserData> users = GetUserData(query, 500, 1); |
185 | List<UserAccount> accs = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query); | ||
186 | |||
187 | List<UserData> users = new List<UserData>(); | ||
188 | if (accs != null) | ||
189 | { | ||
190 | foreach (UserAccount acc in accs) | ||
191 | { | ||
192 | UserData ud = new UserData(); | ||
193 | ud.FirstName = acc.FirstName; | ||
194 | ud.LastName = acc.LastName; | ||
195 | ud.Id = acc.PrincipalID; | ||
196 | users.Add(ud); | ||
197 | } | ||
198 | } | ||
199 | |||
200 | // search the local cache | ||
201 | foreach (UserData data in m_UserCache.Values) | ||
202 | if (users.Find(delegate(UserData d) { return d.Id == data.Id; }) == null && | ||
203 | (data.FirstName.ToLower().StartsWith(query.ToLower()) || data.LastName.ToLower().StartsWith(query.ToLower()))) | ||
204 | users.Add(data); | ||
205 | |||
206 | AddAdditionalUsers(avatarID, query, users); | ||
207 | 177 | ||
208 | AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); | 178 | AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); |
209 | // TODO: don't create new blocks if recycling an old packet | 179 | // TODO: don't create new blocks if recycling an old packet |
@@ -249,12 +219,46 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
249 | client.SendAvatarPickerReply(agent_data, data_args); | 219 | client.SendAvatarPickerReply(agent_data, data_args); |
250 | } | 220 | } |
251 | 221 | ||
252 | protected virtual void AddAdditionalUsers(UUID avatarID, string query, List<UserData> users) | 222 | protected virtual void AddAdditionalUsers(string query, List<UserData> users) |
253 | { | 223 | { |
254 | } | 224 | } |
255 | 225 | ||
256 | #endregion Event Handlers | 226 | #endregion Event Handlers |
257 | 227 | ||
228 | #region IPeople | ||
229 | |||
230 | public List<UserData> GetUserData(string query, int page_size, int page_number) | ||
231 | { | ||
232 | // search the user accounts service | ||
233 | List<UserAccount> accs = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query); | ||
234 | |||
235 | List<UserData> users = new List<UserData>(); | ||
236 | if (accs != null) | ||
237 | { | ||
238 | foreach (UserAccount acc in accs) | ||
239 | { | ||
240 | UserData ud = new UserData(); | ||
241 | ud.FirstName = acc.FirstName; | ||
242 | ud.LastName = acc.LastName; | ||
243 | ud.Id = acc.PrincipalID; | ||
244 | users.Add(ud); | ||
245 | } | ||
246 | } | ||
247 | |||
248 | // search the local cache | ||
249 | foreach (UserData data in m_UserCache.Values) | ||
250 | if (users.Find(delegate(UserData d) { return d.Id == data.Id; }) == null && | ||
251 | (data.FirstName.ToLower().StartsWith(query.ToLower()) || data.LastName.ToLower().StartsWith(query.ToLower()))) | ||
252 | users.Add(data); | ||
253 | |||
254 | AddAdditionalUsers(query, users); | ||
255 | |||
256 | return users; | ||
257 | |||
258 | } | ||
259 | |||
260 | #endregion IPeople | ||
261 | |||
258 | private void CacheCreators(SceneObjectGroup sog) | 262 | private void CacheCreators(SceneObjectGroup sog) |
259 | { | 263 | { |
260 | //m_log.DebugFormat("[USER MANAGEMENT MODULE]: processing {0} {1}; {2}", sog.RootPart.Name, sog.RootPart.CreatorData, sog.RootPart.CreatorIdentification); | 264 | //m_log.DebugFormat("[USER MANAGEMENT MODULE]: processing {0} {1}; {2}", sog.RootPart.Name, sog.RootPart.CreatorData, sog.RootPart.CreatorIdentification); |