diff options
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 554af14..39e0661 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -38,6 +38,7 @@ using OpenSim.Services.Interfaces; | |||
38 | using OpenSim.Services.Connectors.Hypergrid; | 38 | using OpenSim.Services.Connectors.Hypergrid; |
39 | 39 | ||
40 | using OpenMetaverse; | 40 | using OpenMetaverse; |
41 | using OpenMetaverse.Packets; | ||
41 | using log4net; | 42 | using log4net; |
42 | using Nini.Config; | 43 | using Nini.Config; |
43 | 44 | ||
@@ -149,7 +150,15 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
149 | 150 | ||
150 | void EventManager_OnNewClient(IClientAPI client) | 151 | void EventManager_OnNewClient(IClientAPI client) |
151 | { | 152 | { |
153 | client.OnConnectionClosed += new Action<IClientAPI>(HandleConnectionClosed); | ||
152 | client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest); | 154 | client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest); |
155 | client.OnAvatarPickerRequest += new AvatarPickerRequest(HandleAvatarPickerRequest); | ||
156 | } | ||
157 | |||
158 | void HandleConnectionClosed(IClientAPI client) | ||
159 | { | ||
160 | client.OnNameFromUUIDRequest -= new UUIDNameRequest(HandleUUIDNameRequest); | ||
161 | client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest); | ||
153 | } | 162 | } |
154 | 163 | ||
155 | void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) | 164 | void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) |
@@ -170,6 +179,59 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
170 | } | 179 | } |
171 | } | 180 | } |
172 | 181 | ||
182 | public void HandleAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query) | ||
183 | { | ||
184 | //EventManager.TriggerAvatarPickerRequest(); | ||
185 | |||
186 | List<UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query); | ||
187 | |||
188 | if (accounts == null) | ||
189 | return; | ||
190 | |||
191 | AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); | ||
192 | // TODO: don't create new blocks if recycling an old packet | ||
193 | |||
194 | AvatarPickerReplyPacket.DataBlock[] searchData = | ||
195 | new AvatarPickerReplyPacket.DataBlock[accounts.Count]; | ||
196 | AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); | ||
197 | |||
198 | agentData.AgentID = avatarID; | ||
199 | agentData.QueryID = RequestID; | ||
200 | replyPacket.AgentData = agentData; | ||
201 | //byte[] bytes = new byte[AvatarResponses.Count*32]; | ||
202 | |||
203 | int i = 0; | ||
204 | foreach (UserAccount item in accounts) | ||
205 | { | ||
206 | UUID translatedIDtem = item.PrincipalID; | ||
207 | searchData[i] = new AvatarPickerReplyPacket.DataBlock(); | ||
208 | searchData[i].AvatarID = translatedIDtem; | ||
209 | searchData[i].FirstName = Utils.StringToBytes((string)item.FirstName); | ||
210 | searchData[i].LastName = Utils.StringToBytes((string)item.LastName); | ||
211 | i++; | ||
212 | } | ||
213 | if (accounts.Count == 0) | ||
214 | { | ||
215 | searchData = new AvatarPickerReplyPacket.DataBlock[0]; | ||
216 | } | ||
217 | replyPacket.Data = searchData; | ||
218 | |||
219 | AvatarPickerReplyAgentDataArgs agent_data = new AvatarPickerReplyAgentDataArgs(); | ||
220 | agent_data.AgentID = replyPacket.AgentData.AgentID; | ||
221 | agent_data.QueryID = replyPacket.AgentData.QueryID; | ||
222 | |||
223 | List<AvatarPickerReplyDataArgs> data_args = new List<AvatarPickerReplyDataArgs>(); | ||
224 | for (i = 0; i < replyPacket.Data.Length; i++) | ||
225 | { | ||
226 | AvatarPickerReplyDataArgs data_arg = new AvatarPickerReplyDataArgs(); | ||
227 | data_arg.AvatarID = replyPacket.Data[i].AvatarID; | ||
228 | data_arg.FirstName = replyPacket.Data[i].FirstName; | ||
229 | data_arg.LastName = replyPacket.Data[i].LastName; | ||
230 | data_args.Add(data_arg); | ||
231 | } | ||
232 | client.SendAvatarPickerReply(agent_data, data_args); | ||
233 | } | ||
234 | |||
173 | #endregion Event Handlers | 235 | #endregion Event Handlers |
174 | 236 | ||
175 | private void CacheCreators(SceneObjectGroup sog) | 237 | private void CacheCreators(SceneObjectGroup sog) |