diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Grid/UserServer.Modules/UserManager.cs | 718 |
1 files changed, 0 insertions, 718 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/UserManager.cs b/OpenSim/Grid/UserServer.Modules/UserManager.cs deleted file mode 100644 index 36c6297..0000000 --- a/OpenSim/Grid/UserServer.Modules/UserManager.cs +++ /dev/null | |||
@@ -1,718 +0,0 @@ | |||
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.Net; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Grid.Framework; | ||
41 | |||
42 | namespace OpenSim.Grid.UserServer.Modules | ||
43 | { | ||
44 | public delegate void logOffUser(UUID AgentID); | ||
45 | |||
46 | public class UserManager | ||
47 | { | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | public event logOffUser OnLogOffUser; | ||
51 | private logOffUser handlerLogOffUser; | ||
52 | |||
53 | private UserDataBaseService m_userDataBaseService; | ||
54 | private BaseHttpServer m_httpServer; | ||
55 | |||
56 | /// <summary> | ||
57 | /// | ||
58 | /// </summary> | ||
59 | /// <param name="userDataBaseService"></param> | ||
60 | public UserManager(UserDataBaseService userDataBaseService) | ||
61 | { | ||
62 | m_userDataBaseService = userDataBaseService; | ||
63 | } | ||
64 | |||
65 | public void Initialise(IGridServiceCore core) | ||
66 | { | ||
67 | |||
68 | } | ||
69 | |||
70 | public void PostInitialise() | ||
71 | { | ||
72 | |||
73 | } | ||
74 | |||
75 | private string RESTGetUserProfile(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
76 | { | ||
77 | UUID id; | ||
78 | UserProfileData userProfile; | ||
79 | |||
80 | try | ||
81 | { | ||
82 | id = new UUID(param); | ||
83 | } | ||
84 | catch (Exception) | ||
85 | { | ||
86 | httpResponse.StatusCode = 500; | ||
87 | return "Malformed Param [" + param + "]"; | ||
88 | } | ||
89 | |||
90 | userProfile = m_userDataBaseService.GetUserProfile(id); | ||
91 | |||
92 | if (userProfile == null) | ||
93 | { | ||
94 | httpResponse.StatusCode = 404; | ||
95 | return "Not Found."; | ||
96 | } | ||
97 | |||
98 | return ProfileToXmlRPCResponse(userProfile).ToString(); | ||
99 | } | ||
100 | |||
101 | public void RegisterHandlers(BaseHttpServer httpServer) | ||
102 | { | ||
103 | m_httpServer = httpServer; | ||
104 | |||
105 | m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/users/", RESTGetUserProfile)); | ||
106 | |||
107 | m_httpServer.AddXmlRPCHandler("get_user_by_name", XmlRPCGetUserMethodName); | ||
108 | m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID); | ||
109 | m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar); | ||
110 | |||
111 | // Used by IAR module to do password checks | ||
112 | m_httpServer.AddXmlRPCHandler("authenticate_user_by_password", XmlRPCAuthenticateUserMethodPassword); | ||
113 | |||
114 | m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion); | ||
115 | m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID); | ||
116 | m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID); | ||
117 | |||
118 | m_httpServer.AddXmlRPCHandler("update_user_profile", XmlRpcResponseXmlRPCUpdateUserProfile); | ||
119 | |||
120 | m_httpServer.AddStreamHandler(new RestStreamHandler("DELETE", "/usersessions/", RestDeleteUserSessionMethod)); | ||
121 | } | ||
122 | |||
123 | /// <summary> | ||
124 | /// Deletes an active agent session | ||
125 | /// </summary> | ||
126 | /// <param name="request">The request</param> | ||
127 | /// <param name="path">The path (eg /bork/narf/test)</param> | ||
128 | /// <param name="param">Parameters sent</param> | ||
129 | /// <param name="httpRequest">HTTP request header object</param> | ||
130 | /// <param name="httpResponse">HTTP response header object</param> | ||
131 | /// <returns>Success "OK" else error</returns> | ||
132 | public string RestDeleteUserSessionMethod(string request, string path, string param, | ||
133 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
134 | { | ||
135 | // TODO! Important! | ||
136 | |||
137 | return "OK"; | ||
138 | } | ||
139 | |||
140 | public XmlRpcResponse AvatarPickerListtoXmlRPCResponse(UUID queryID, List<AvatarPickerAvatar> returnUsers) | ||
141 | { | ||
142 | XmlRpcResponse response = new XmlRpcResponse(); | ||
143 | Hashtable responseData = new Hashtable(); | ||
144 | // Query Result Information | ||
145 | responseData["queryid"] = queryID.ToString(); | ||
146 | responseData["avcount"] = returnUsers.Count.ToString(); | ||
147 | |||
148 | for (int i = 0; i < returnUsers.Count; i++) | ||
149 | { | ||
150 | responseData["avatarid" + i] = returnUsers[i].AvatarID.ToString(); | ||
151 | responseData["firstname" + i] = returnUsers[i].firstName; | ||
152 | responseData["lastname" + i] = returnUsers[i].lastName; | ||
153 | } | ||
154 | response.Value = responseData; | ||
155 | |||
156 | return response; | ||
157 | } | ||
158 | |||
159 | /// <summary> | ||
160 | /// Converts a user profile to an XML element which can be returned | ||
161 | /// </summary> | ||
162 | /// <param name="profile">The user profile</param> | ||
163 | /// <returns>A string containing an XML Document of the user profile</returns> | ||
164 | public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile) | ||
165 | { | ||
166 | XmlRpcResponse response = new XmlRpcResponse(); | ||
167 | Hashtable responseData = new Hashtable(); | ||
168 | |||
169 | // Account information | ||
170 | responseData["firstname"] = profile.FirstName; | ||
171 | responseData["lastname"] = profile.SurName; | ||
172 | responseData["email"] = profile.Email; | ||
173 | responseData["uuid"] = profile.ID.ToString(); | ||
174 | // Server Information | ||
175 | responseData["server_inventory"] = profile.UserInventoryURI; | ||
176 | responseData["server_asset"] = profile.UserAssetURI; | ||
177 | // Profile Information | ||
178 | responseData["profile_about"] = profile.AboutText; | ||
179 | responseData["profile_firstlife_about"] = profile.FirstLifeAboutText; | ||
180 | responseData["profile_firstlife_image"] = profile.FirstLifeImage.ToString(); | ||
181 | responseData["profile_can_do"] = profile.CanDoMask.ToString(); | ||
182 | responseData["profile_want_do"] = profile.WantDoMask.ToString(); | ||
183 | responseData["profile_image"] = profile.Image.ToString(); | ||
184 | responseData["profile_created"] = profile.Created.ToString(); | ||
185 | responseData["profile_lastlogin"] = profile.LastLogin.ToString(); | ||
186 | // Home region information | ||
187 | responseData["home_coordinates_x"] = profile.HomeLocation.X.ToString(); | ||
188 | responseData["home_coordinates_y"] = profile.HomeLocation.Y.ToString(); | ||
189 | responseData["home_coordinates_z"] = profile.HomeLocation.Z.ToString(); | ||
190 | |||
191 | responseData["home_region"] = profile.HomeRegion.ToString(); | ||
192 | responseData["home_region_id"] = profile.HomeRegionID.ToString(); | ||
193 | |||
194 | responseData["home_look_x"] = profile.HomeLookAt.X.ToString(); | ||
195 | responseData["home_look_y"] = profile.HomeLookAt.Y.ToString(); | ||
196 | responseData["home_look_z"] = profile.HomeLookAt.Z.ToString(); | ||
197 | |||
198 | responseData["user_flags"] = profile.UserFlags.ToString(); | ||
199 | responseData["god_level"] = profile.GodLevel.ToString(); | ||
200 | responseData["custom_type"] = profile.CustomType; | ||
201 | responseData["partner"] = profile.Partner.ToString(); | ||
202 | response.Value = responseData; | ||
203 | |||
204 | return response; | ||
205 | } | ||
206 | |||
207 | #region XMLRPC User Methods | ||
208 | |||
209 | /// <summary> | ||
210 | /// Authenticate a user using their password | ||
211 | /// </summary> | ||
212 | /// <param name="request">Must contain values for "user_uuid" and "password" keys</param> | ||
213 | /// <param name="remoteClient"></param> | ||
214 | /// <returns></returns> | ||
215 | public XmlRpcResponse XmlRPCAuthenticateUserMethodPassword(XmlRpcRequest request, IPEndPoint remoteClient) | ||
216 | { | ||
217 | // m_log.DebugFormat("[USER MANAGER]: Received authenticated user by password request from {0}", remoteClient); | ||
218 | |||
219 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
220 | string userUuidRaw = (string)requestData["user_uuid"]; | ||
221 | string password = (string)requestData["password"]; | ||
222 | |||
223 | if (null == userUuidRaw) | ||
224 | return Util.CreateUnknownUserErrorResponse(); | ||
225 | |||
226 | UUID userUuid; | ||
227 | if (!UUID.TryParse(userUuidRaw, out userUuid)) | ||
228 | return Util.CreateUnknownUserErrorResponse(); | ||
229 | |||
230 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(userUuid); | ||
231 | if (null == userProfile) | ||
232 | return Util.CreateUnknownUserErrorResponse(); | ||
233 | |||
234 | string authed; | ||
235 | |||
236 | if (null == password) | ||
237 | { | ||
238 | authed = "FALSE"; | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | if (m_userDataBaseService.AuthenticateUserByPassword(userUuid, password)) | ||
243 | authed = "TRUE"; | ||
244 | else | ||
245 | authed = "FALSE"; | ||
246 | } | ||
247 | |||
248 | // m_log.DebugFormat( | ||
249 | // "[USER MANAGER]: Authentication by password result from {0} for {1} is {2}", | ||
250 | // remoteClient, userUuid, authed); | ||
251 | |||
252 | XmlRpcResponse response = new XmlRpcResponse(); | ||
253 | Hashtable responseData = new Hashtable(); | ||
254 | responseData["auth_user"] = authed; | ||
255 | response.Value = responseData; | ||
256 | |||
257 | return response; | ||
258 | } | ||
259 | |||
260 | public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request, IPEndPoint remoteClient) | ||
261 | { | ||
262 | // XmlRpcResponse response = new XmlRpcResponse(); | ||
263 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
264 | List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>(); | ||
265 | UUID queryID = new UUID(UUID.Zero.ToString()); | ||
266 | |||
267 | if (requestData.Contains("avquery") && requestData.Contains("queryid")) | ||
268 | { | ||
269 | queryID = new UUID((string)requestData["queryid"]); | ||
270 | returnAvatar = m_userDataBaseService.GenerateAgentPickerRequestResponse(queryID, (string)requestData["avquery"]); | ||
271 | } | ||
272 | |||
273 | m_log.InfoFormat("[AVATARINFO]: Servicing Avatar Query: " + (string)requestData["avquery"]); | ||
274 | return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar); | ||
275 | } | ||
276 | |||
277 | public XmlRpcResponse XmlRPCAtRegion(XmlRpcRequest request, IPEndPoint remoteClient) | ||
278 | { | ||
279 | XmlRpcResponse response = new XmlRpcResponse(); | ||
280 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
281 | Hashtable responseData = new Hashtable(); | ||
282 | string returnstring = "FALSE"; | ||
283 | |||
284 | if (requestData.Contains("avatar_id") && requestData.Contains("region_handle") && | ||
285 | requestData.Contains("region_uuid")) | ||
286 | { | ||
287 | // ulong cregionhandle = 0; | ||
288 | UUID regionUUID; | ||
289 | UUID avatarUUID; | ||
290 | |||
291 | UUID.TryParse((string)requestData["avatar_id"], out avatarUUID); | ||
292 | UUID.TryParse((string)requestData["region_uuid"], out regionUUID); | ||
293 | |||
294 | if (avatarUUID != UUID.Zero) | ||
295 | { | ||
296 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(avatarUUID); | ||
297 | userProfile.CurrentAgent.Region = regionUUID; | ||
298 | userProfile.CurrentAgent.Handle = (ulong)Convert.ToInt64((string)requestData["region_handle"]); | ||
299 | //userProfile.CurrentAgent. | ||
300 | m_userDataBaseService.CommitAgent(ref userProfile); | ||
301 | //setUserProfile(userProfile); | ||
302 | |||
303 | returnstring = "TRUE"; | ||
304 | } | ||
305 | } | ||
306 | |||
307 | responseData.Add("returnString", returnstring); | ||
308 | response.Value = responseData; | ||
309 | return response; | ||
310 | } | ||
311 | |||
312 | public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request, IPEndPoint remoteClient) | ||
313 | { | ||
314 | // XmlRpcResponse response = new XmlRpcResponse(); | ||
315 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
316 | UserProfileData userProfile; | ||
317 | if (requestData.Contains("avatar_name")) | ||
318 | { | ||
319 | string query = (string)requestData["avatar_name"]; | ||
320 | |||
321 | if (null == query) | ||
322 | return Util.CreateUnknownUserErrorResponse(); | ||
323 | |||
324 | // Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); | ||
325 | |||
326 | string[] querysplit = query.Split(' '); | ||
327 | |||
328 | if (querysplit.Length == 2) | ||
329 | { | ||
330 | userProfile = m_userDataBaseService.GetUserProfile(querysplit[0], querysplit[1]); | ||
331 | if (userProfile == null) | ||
332 | { | ||
333 | return Util.CreateUnknownUserErrorResponse(); | ||
334 | } | ||
335 | } | ||
336 | else | ||
337 | { | ||
338 | return Util.CreateUnknownUserErrorResponse(); | ||
339 | } | ||
340 | } | ||
341 | else | ||
342 | { | ||
343 | return Util.CreateUnknownUserErrorResponse(); | ||
344 | } | ||
345 | |||
346 | return ProfileToXmlRPCResponse(userProfile); | ||
347 | } | ||
348 | |||
349 | public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request, IPEndPoint remoteClient) | ||
350 | { | ||
351 | // XmlRpcResponse response = new XmlRpcResponse(); | ||
352 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
353 | UserProfileData userProfile; | ||
354 | //CFK: this clogs the UserServer log and is not necessary at this time. | ||
355 | //CFK: m_log.Debug("METHOD BY UUID CALLED"); | ||
356 | if (requestData.Contains("avatar_uuid")) | ||
357 | { | ||
358 | try | ||
359 | { | ||
360 | UUID guess = new UUID((string)requestData["avatar_uuid"]); | ||
361 | |||
362 | userProfile = m_userDataBaseService.GetUserProfile(guess); | ||
363 | } | ||
364 | catch (FormatException) | ||
365 | { | ||
366 | return Util.CreateUnknownUserErrorResponse(); | ||
367 | } | ||
368 | |||
369 | if (userProfile == null) | ||
370 | { | ||
371 | return Util.CreateUnknownUserErrorResponse(); | ||
372 | } | ||
373 | } | ||
374 | else | ||
375 | { | ||
376 | return Util.CreateUnknownUserErrorResponse(); | ||
377 | } | ||
378 | |||
379 | return ProfileToXmlRPCResponse(userProfile); | ||
380 | } | ||
381 | |||
382 | public XmlRpcResponse XmlRPCGetAgentMethodUUID(XmlRpcRequest request, IPEndPoint remoteClient) | ||
383 | { | ||
384 | XmlRpcResponse response = new XmlRpcResponse(); | ||
385 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
386 | UserProfileData userProfile; | ||
387 | //CFK: this clogs the UserServer log and is not necessary at this time. | ||
388 | //CFK: m_log.Debug("METHOD BY UUID CALLED"); | ||
389 | if (requestData.Contains("avatar_uuid")) | ||
390 | { | ||
391 | UUID guess; | ||
392 | |||
393 | UUID.TryParse((string)requestData["avatar_uuid"], out guess); | ||
394 | |||
395 | if (guess == UUID.Zero) | ||
396 | { | ||
397 | return Util.CreateUnknownUserErrorResponse(); | ||
398 | } | ||
399 | |||
400 | userProfile = m_userDataBaseService.GetUserProfile(guess); | ||
401 | |||
402 | if (userProfile == null) | ||
403 | { | ||
404 | return Util.CreateUnknownUserErrorResponse(); | ||
405 | } | ||
406 | |||
407 | // no agent??? | ||
408 | if (userProfile.CurrentAgent == null) | ||
409 | { | ||
410 | return Util.CreateUnknownUserErrorResponse(); | ||
411 | } | ||
412 | Hashtable responseData = new Hashtable(); | ||
413 | |||
414 | responseData["handle"] = userProfile.CurrentAgent.Handle.ToString(); | ||
415 | responseData["session"] = userProfile.CurrentAgent.SessionID.ToString(); | ||
416 | if (userProfile.CurrentAgent.AgentOnline) | ||
417 | responseData["agent_online"] = "TRUE"; | ||
418 | else | ||
419 | responseData["agent_online"] = "FALSE"; | ||
420 | |||
421 | response.Value = responseData; | ||
422 | } | ||
423 | else | ||
424 | { | ||
425 | return Util.CreateUnknownUserErrorResponse(); | ||
426 | } | ||
427 | |||
428 | return response; | ||
429 | } | ||
430 | |||
431 | public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserProfile(XmlRpcRequest request, IPEndPoint remoteClient) | ||
432 | { | ||
433 | m_log.Debug("[UserManager]: Got request to update user profile"); | ||
434 | XmlRpcResponse response = new XmlRpcResponse(); | ||
435 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
436 | Hashtable responseData = new Hashtable(); | ||
437 | |||
438 | if (!requestData.Contains("avatar_uuid")) | ||
439 | { | ||
440 | return Util.CreateUnknownUserErrorResponse(); | ||
441 | } | ||
442 | |||
443 | UUID UserUUID = new UUID((string)requestData["avatar_uuid"]); | ||
444 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(UserUUID); | ||
445 | if (null == userProfile) | ||
446 | { | ||
447 | return Util.CreateUnknownUserErrorResponse(); | ||
448 | } | ||
449 | // don't know how yet. | ||
450 | if (requestData.Contains("AllowPublish")) | ||
451 | { | ||
452 | } | ||
453 | if (requestData.Contains("FLImageID")) | ||
454 | { | ||
455 | userProfile.FirstLifeImage = new UUID((string)requestData["FLImageID"]); | ||
456 | } | ||
457 | if (requestData.Contains("ImageID")) | ||
458 | { | ||
459 | userProfile.Image = new UUID((string)requestData["ImageID"]); | ||
460 | } | ||
461 | // dont' know how yet | ||
462 | if (requestData.Contains("MaturePublish")) | ||
463 | { | ||
464 | } | ||
465 | if (requestData.Contains("AboutText")) | ||
466 | { | ||
467 | userProfile.AboutText = (string)requestData["AboutText"]; | ||
468 | } | ||
469 | if (requestData.Contains("FLAboutText")) | ||
470 | { | ||
471 | userProfile.FirstLifeAboutText = (string)requestData["FLAboutText"]; | ||
472 | } | ||
473 | // not in DB yet. | ||
474 | if (requestData.Contains("ProfileURL")) | ||
475 | { | ||
476 | } | ||
477 | if (requestData.Contains("home_region")) | ||
478 | { | ||
479 | try | ||
480 | { | ||
481 | userProfile.HomeRegion = Convert.ToUInt64((string)requestData["home_region"]); | ||
482 | } | ||
483 | catch (ArgumentException) | ||
484 | { | ||
485 | m_log.Error("[PROFILE]:Failed to set home region, Invalid Argument"); | ||
486 | } | ||
487 | catch (FormatException) | ||
488 | { | ||
489 | m_log.Error("[PROFILE]:Failed to set home region, Invalid Format"); | ||
490 | } | ||
491 | catch (OverflowException) | ||
492 | { | ||
493 | m_log.Error("[PROFILE]:Failed to set home region, Value was too large"); | ||
494 | } | ||
495 | } | ||
496 | if (requestData.Contains("home_region_id")) | ||
497 | { | ||
498 | UUID regionID; | ||
499 | UUID.TryParse((string)requestData["home_region_id"], out regionID); | ||
500 | userProfile.HomeRegionID = regionID; | ||
501 | } | ||
502 | if (requestData.Contains("home_pos_x")) | ||
503 | { | ||
504 | try | ||
505 | { | ||
506 | userProfile.HomeLocationX = (float)Convert.ToDecimal((string)requestData["home_pos_x"]); | ||
507 | } | ||
508 | catch (InvalidCastException) | ||
509 | { | ||
510 | m_log.Error("[PROFILE]:Failed to set home postion x"); | ||
511 | } | ||
512 | } | ||
513 | if (requestData.Contains("home_pos_y")) | ||
514 | { | ||
515 | try | ||
516 | { | ||
517 | userProfile.HomeLocationY = (float)Convert.ToDecimal((string)requestData["home_pos_y"]); | ||
518 | } | ||
519 | catch (InvalidCastException) | ||
520 | { | ||
521 | m_log.Error("[PROFILE]:Failed to set home postion y"); | ||
522 | } | ||
523 | } | ||
524 | if (requestData.Contains("home_pos_z")) | ||
525 | { | ||
526 | try | ||
527 | { | ||
528 | userProfile.HomeLocationZ = (float)Convert.ToDecimal((string)requestData["home_pos_z"]); | ||
529 | } | ||
530 | catch (InvalidCastException) | ||
531 | { | ||
532 | m_log.Error("[PROFILE]:Failed to set home postion z"); | ||
533 | } | ||
534 | } | ||
535 | if (requestData.Contains("home_look_x")) | ||
536 | { | ||
537 | try | ||
538 | { | ||
539 | userProfile.HomeLookAtX = (float)Convert.ToDecimal((string)requestData["home_look_x"]); | ||
540 | } | ||
541 | catch (InvalidCastException) | ||
542 | { | ||
543 | m_log.Error("[PROFILE]:Failed to set home lookat x"); | ||
544 | } | ||
545 | } | ||
546 | if (requestData.Contains("home_look_y")) | ||
547 | { | ||
548 | try | ||
549 | { | ||
550 | userProfile.HomeLookAtY = (float)Convert.ToDecimal((string)requestData["home_look_y"]); | ||
551 | } | ||
552 | catch (InvalidCastException) | ||
553 | { | ||
554 | m_log.Error("[PROFILE]:Failed to set home lookat y"); | ||
555 | } | ||
556 | } | ||
557 | if (requestData.Contains("home_look_z")) | ||
558 | { | ||
559 | try | ||
560 | { | ||
561 | userProfile.HomeLookAtZ = (float)Convert.ToDecimal((string)requestData["home_look_z"]); | ||
562 | } | ||
563 | catch (InvalidCastException) | ||
564 | { | ||
565 | m_log.Error("[PROFILE]:Failed to set home lookat z"); | ||
566 | } | ||
567 | } | ||
568 | if (requestData.Contains("user_flags")) | ||
569 | { | ||
570 | try | ||
571 | { | ||
572 | userProfile.UserFlags = Convert.ToInt32((string)requestData["user_flags"]); | ||
573 | } | ||
574 | catch (InvalidCastException) | ||
575 | { | ||
576 | m_log.Error("[PROFILE]:Failed to set user flags"); | ||
577 | } | ||
578 | } | ||
579 | if (requestData.Contains("god_level")) | ||
580 | { | ||
581 | try | ||
582 | { | ||
583 | userProfile.GodLevel = Convert.ToInt32((string)requestData["god_level"]); | ||
584 | } | ||
585 | catch (InvalidCastException) | ||
586 | { | ||
587 | m_log.Error("[PROFILE]:Failed to set god level"); | ||
588 | } | ||
589 | } | ||
590 | if (requestData.Contains("custom_type")) | ||
591 | { | ||
592 | try | ||
593 | { | ||
594 | userProfile.CustomType = (string)requestData["custom_type"]; | ||
595 | } | ||
596 | catch (InvalidCastException) | ||
597 | { | ||
598 | m_log.Error("[PROFILE]:Failed to set custom type"); | ||
599 | } | ||
600 | } | ||
601 | if (requestData.Contains("partner")) | ||
602 | { | ||
603 | try | ||
604 | { | ||
605 | userProfile.Partner = new UUID((string)requestData["partner"]); | ||
606 | } | ||
607 | catch (InvalidCastException) | ||
608 | { | ||
609 | m_log.Error("[PROFILE]:Failed to set partner"); | ||
610 | } | ||
611 | } | ||
612 | else | ||
613 | { | ||
614 | userProfile.Partner = UUID.Zero; | ||
615 | } | ||
616 | |||
617 | // call plugin! | ||
618 | bool ret = m_userDataBaseService.UpdateUserProfile(userProfile); | ||
619 | responseData["returnString"] = ret.ToString(); | ||
620 | response.Value = responseData; | ||
621 | return response; | ||
622 | } | ||
623 | |||
624 | public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request, IPEndPoint remoteClient) | ||
625 | { | ||
626 | XmlRpcResponse response = new XmlRpcResponse(); | ||
627 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
628 | |||
629 | if (requestData.Contains("avatar_uuid")) | ||
630 | { | ||
631 | try | ||
632 | { | ||
633 | UUID userUUID = new UUID((string)requestData["avatar_uuid"]); | ||
634 | UUID RegionID = new UUID((string)requestData["region_uuid"]); | ||
635 | ulong regionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]); | ||
636 | Vector3 position = new Vector3( | ||
637 | (float)Convert.ToDecimal((string)requestData["region_pos_x"]), | ||
638 | (float)Convert.ToDecimal((string)requestData["region_pos_y"]), | ||
639 | (float)Convert.ToDecimal((string)requestData["region_pos_z"])); | ||
640 | Vector3 lookat = new Vector3( | ||
641 | (float)Convert.ToDecimal((string)requestData["lookat_x"]), | ||
642 | (float)Convert.ToDecimal((string)requestData["lookat_y"]), | ||
643 | (float)Convert.ToDecimal((string)requestData["lookat_z"])); | ||
644 | |||
645 | handlerLogOffUser = OnLogOffUser; | ||
646 | if (handlerLogOffUser != null) | ||
647 | handlerLogOffUser(userUUID); | ||
648 | |||
649 | m_userDataBaseService.LogOffUser(userUUID, RegionID, regionhandle, position, lookat); | ||
650 | } | ||
651 | catch (FormatException) | ||
652 | { | ||
653 | m_log.Warn("[LOGOUT]: Error in Logout XMLRPC Params"); | ||
654 | return response; | ||
655 | } | ||
656 | } | ||
657 | else | ||
658 | { | ||
659 | return Util.CreateUnknownUserErrorResponse(); | ||
660 | } | ||
661 | |||
662 | return response; | ||
663 | } | ||
664 | |||
665 | #endregion | ||
666 | |||
667 | |||
668 | public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle) | ||
669 | { | ||
670 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID); | ||
671 | if (userProfile != null) | ||
672 | { | ||
673 | userProfile.CurrentAgent.Region = regionID; | ||
674 | userProfile.CurrentAgent.Handle = regionHandle; | ||
675 | m_userDataBaseService.CommitAgent(ref userProfile); | ||
676 | } | ||
677 | } | ||
678 | |||
679 | public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle) | ||
680 | { | ||
681 | UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID); | ||
682 | if (userProfile != null) | ||
683 | { | ||
684 | if (userProfile.CurrentAgent.Region == regionID) | ||
685 | { | ||
686 | UserAgentData userAgent = userProfile.CurrentAgent; | ||
687 | if (userAgent != null && userAgent.AgentOnline) | ||
688 | { | ||
689 | userAgent.AgentOnline = false; | ||
690 | userAgent.LogoutTime = Util.UnixTimeSinceEpoch(); | ||
691 | if (regionID != UUID.Zero) | ||
692 | { | ||
693 | userAgent.Region = regionID; | ||
694 | } | ||
695 | userAgent.Handle = regionHandle; | ||
696 | userProfile.LastLogin = userAgent.LogoutTime; | ||
697 | |||
698 | m_userDataBaseService.CommitAgent(ref userProfile); | ||
699 | |||
700 | handlerLogOffUser = OnLogOffUser; | ||
701 | if (handlerLogOffUser != null) | ||
702 | handlerLogOffUser(agentID); | ||
703 | } | ||
704 | } | ||
705 | } | ||
706 | } | ||
707 | |||
708 | public void HandleRegionStartup(UUID regionID) | ||
709 | { | ||
710 | m_userDataBaseService.LogoutUsers(regionID); | ||
711 | } | ||
712 | |||
713 | public void HandleRegionShutdown(UUID regionID) | ||
714 | { | ||
715 | m_userDataBaseService.LogoutUsers(regionID); | ||
716 | } | ||
717 | } | ||
718 | } | ||