UserManager.cs 32 KB

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