UserManagerBase.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  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 System.Security.Cryptography;
  32. using libsecondlife;
  33. using libsecondlife.StructuredData;
  34. using log4net;
  35. using Nwc.XmlRpc;
  36. using OpenSim.Framework.Statistics;
  37. namespace OpenSim.Framework.Communications
  38. {
  39. /// <summary>
  40. /// Base class for user management (create, read, etc)
  41. /// </summary>
  42. public abstract class UserManagerBase : IUserService, IAvatarService
  43. {
  44. private static readonly ILog m_log
  45. = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  46. public UserConfig _config;
  47. private Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>();
  48. /// <summary>
  49. /// Adds a new user server plugin - user servers will be requested in the order they were loaded.
  50. /// </summary>
  51. /// <param name="FileName">The filename to the user server plugin DLL</param>
  52. public void AddPlugin(string FileName, string connect)
  53. {
  54. if (!String.IsNullOrEmpty(FileName))
  55. {
  56. m_log.Info("[USERSTORAGE]: Attempting to load " + FileName);
  57. Assembly pluginAssembly = Assembly.LoadFrom(FileName);
  58. m_log.Info("[USERSTORAGE]: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
  59. foreach (Type pluginType in pluginAssembly.GetTypes())
  60. {
  61. if (!pluginType.IsAbstract)
  62. {
  63. Type typeInterface = pluginType.GetInterface("IUserData", true);
  64. if (typeInterface != null)
  65. {
  66. IUserData plug =
  67. (IUserData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
  68. AddPlugin(plug, connect);
  69. }
  70. }
  71. }
  72. }
  73. }
  74. public void AddPlugin(IUserData plug, string connect)
  75. {
  76. plug.Initialise(connect);
  77. _plugins.Add(plug.Name, plug);
  78. m_log.Info("[USERSTORAGE]: Added IUserData Interface");
  79. }
  80. #region Get UserProfile
  81. // see IUserService
  82. public UserProfileData GetUserProfile(string fname, string lname)
  83. {
  84. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  85. {
  86. UserProfileData profile = plugin.Value.GetUserByName(fname, lname);
  87. if (profile != null)
  88. {
  89. profile.CurrentAgent = GetUserAgent(profile.ID);
  90. return profile;
  91. }
  92. }
  93. return null;
  94. }
  95. public UserAgentData GetAgentByUUID(LLUUID userId)
  96. {
  97. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  98. {
  99. UserAgentData agent = plugin.Value.GetAgentByUUID(userId);
  100. if (agent != null)
  101. {
  102. return agent;
  103. }
  104. }
  105. return null;
  106. }
  107. // see IUserService
  108. public UserProfileData GetUserProfile(LLUUID uuid)
  109. {
  110. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  111. {
  112. UserProfileData profile = plugin.Value.GetUserByUUID(uuid);
  113. if (null != profile)
  114. {
  115. profile.CurrentAgent = GetUserAgent(profile.ID);
  116. return profile;
  117. }
  118. }
  119. return null;
  120. }
  121. public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
  122. {
  123. List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>();
  124. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  125. {
  126. try
  127. {
  128. pickerlist = plugin.Value.GeneratePickerResults(queryID, query);
  129. }
  130. catch (Exception)
  131. {
  132. m_log.Info("[USERSTORAGE]: Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")");
  133. return new List<AvatarPickerAvatar>();
  134. }
  135. }
  136. return pickerlist;
  137. }
  138. /// <summary>
  139. /// Updates a user profile from data object
  140. /// </summary>
  141. /// <param name="data"></param>
  142. /// <returns></returns>
  143. public bool UpdateUserProfile(UserProfileData data)
  144. {
  145. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  146. {
  147. try
  148. {
  149. plugin.Value.UpdateUserProfile(data);
  150. return true;
  151. }
  152. catch (Exception e)
  153. {
  154. m_log.InfoFormat("[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", data.FirstName, data.SurName,
  155. plugin.Key, e.ToString());
  156. }
  157. }
  158. return false;
  159. }
  160. #endregion
  161. #region Get UserAgent
  162. /// <summary>
  163. /// Loads a user agent by uuid (not called directly)
  164. /// </summary>
  165. /// <param name="uuid">The agent's UUID</param>
  166. /// <returns>Agent profiles</returns>
  167. public UserAgentData GetUserAgent(LLUUID uuid)
  168. {
  169. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  170. {
  171. try
  172. {
  173. return plugin.Value.GetAgentByUUID(uuid);
  174. }
  175. catch (Exception e)
  176. {
  177. m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
  178. }
  179. }
  180. return null;
  181. }
  182. /// <summary>
  183. /// Loads a user agent by name (not called directly)
  184. /// </summary>
  185. /// <param name="name">The agent's name</param>
  186. /// <returns>A user agent</returns>
  187. public UserAgentData GetUserAgent(string name)
  188. {
  189. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  190. {
  191. try
  192. {
  193. return plugin.Value.GetAgentByName(name);
  194. }
  195. catch (Exception e)
  196. {
  197. m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
  198. }
  199. }
  200. return null;
  201. }
  202. /// <summary>
  203. /// Loads a user agent by name (not called directly)
  204. /// </summary>
  205. /// <param name="fname">The agent's firstname</param>
  206. /// <param name="lname">The agent's lastname</param>
  207. /// <returns>A user agent</returns>
  208. public UserAgentData GetUserAgent(string fname, string lname)
  209. {
  210. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  211. {
  212. try
  213. {
  214. return plugin.Value.GetAgentByName(fname, lname);
  215. }
  216. catch (Exception e)
  217. {
  218. m_log.Info("[USERSTORAGE]: Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
  219. }
  220. }
  221. return null;
  222. }
  223. public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle)
  224. {
  225. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  226. {
  227. try
  228. {
  229. plugin.Value.UpdateUserCurrentRegion(avatarid, regionuuid, regionhandle);
  230. }
  231. catch (Exception e)
  232. {
  233. m_log.Info("[USERSTORAGE]: Unable to updateuser location via " + plugin.Key + "(" + e.ToString() + ")");
  234. }
  235. }
  236. }
  237. /// <summary>
  238. /// Loads a user's friend list
  239. /// </summary>
  240. /// <param name="name">the UUID of the friend list owner</param>
  241. /// <returns>A List of FriendListItems that contains info about the user's friends</returns>
  242. public List<FriendListItem> GetUserFriendList(LLUUID ownerID)
  243. {
  244. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  245. {
  246. try
  247. {
  248. return plugin.Value.GetUserFriendList(ownerID);
  249. }
  250. catch (Exception e)
  251. {
  252. m_log.Info("[USERSTORAGE]: Unable to GetUserFriendList via " + plugin.Key + "(" + e.ToString() + ")");
  253. }
  254. }
  255. return null;
  256. }
  257. public void StoreWebLoginKey(LLUUID agentID, LLUUID webLoginKey)
  258. {
  259. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  260. {
  261. try
  262. {
  263. plugin.Value.StoreWebLoginKey(agentID, webLoginKey);
  264. }
  265. catch (Exception e)
  266. {
  267. m_log.Info("[USERSTORAGE]: Unable to Store WebLoginKey via " + plugin.Key + "(" + e.ToString() + ")");
  268. }
  269. }
  270. }
  271. public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
  272. {
  273. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  274. {
  275. try
  276. {
  277. plugin.Value.AddNewUserFriend(friendlistowner,friend,perms);
  278. }
  279. catch (Exception e)
  280. {
  281. m_log.Info("[USERSTORAGE]: Unable to AddNewUserFriend via " + plugin.Key + "(" + e.ToString() + ")");
  282. }
  283. }
  284. }
  285. public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
  286. {
  287. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  288. {
  289. try
  290. {
  291. plugin.Value.RemoveUserFriend(friendlistowner, friend);
  292. }
  293. catch (Exception e)
  294. {
  295. m_log.Info("[USERSTORAGE]: Unable to RemoveUserFriend via " + plugin.Key + "(" + e.ToString() + ")");
  296. }
  297. }
  298. }
  299. public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
  300. {
  301. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  302. {
  303. try
  304. {
  305. plugin.Value.UpdateUserFriendPerms(friendlistowner, friend, perms);
  306. }
  307. catch (Exception e)
  308. {
  309. m_log.Info("[USERSTORAGE]: Unable to UpdateUserFriendPerms via " + plugin.Key + "(" + e.ToString() + ")");
  310. }
  311. }
  312. }
  313. /// <summary>
  314. /// Resets the currentAgent in the user profile
  315. /// </summary>
  316. /// <param name="agentID">The agent's ID</param>
  317. public void ClearUserAgent(LLUUID agentID)
  318. {
  319. UserProfileData profile = GetUserProfile(agentID);
  320. profile.CurrentAgent = null;
  321. UpdateUserProfile(profile);
  322. }
  323. #endregion
  324. #region CreateAgent
  325. /// <summary>
  326. /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB
  327. /// </summary>
  328. /// <param name="profile">The users profile</param>
  329. /// <param name="request">The users loginrequest</param>
  330. public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
  331. {
  332. Hashtable requestData = (Hashtable) request.Params[0];
  333. UserAgentData agent = new UserAgentData();
  334. // User connection
  335. agent.AgentOnline = true;
  336. // Generate sessions
  337. RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
  338. byte[] randDataS = new byte[16];
  339. byte[] randDataSS = new byte[16];
  340. rand.GetBytes(randDataS);
  341. rand.GetBytes(randDataSS);
  342. agent.SecureSessionID = new LLUUID(randDataSS, 0);
  343. agent.SessionID = new LLUUID(randDataS, 0);
  344. // Profile UUID
  345. agent.ProfileID = profile.ID;
  346. // Current position (from Home)
  347. agent.Handle = profile.HomeRegion;
  348. agent.Position = profile.HomeLocation;
  349. // If user specified additional start, use that
  350. if (requestData.ContainsKey("start"))
  351. {
  352. string startLoc = ((string)requestData["start"]).Trim();
  353. if (("last" == startLoc) && (profile.CurrentAgent != null))
  354. {
  355. if ((profile.CurrentAgent.Position.X > 0)
  356. && (profile.CurrentAgent.Position.Y > 0)
  357. && (profile.CurrentAgent.Position.Z > 0)
  358. )
  359. {
  360. // TODO: Right now, currentRegion has not been used in GridServer for requesting region.
  361. // TODO: It is only using currentHandle.
  362. agent.Region = profile.CurrentAgent.Region;
  363. agent.Handle = profile.CurrentAgent.Handle;
  364. agent.Position = profile.CurrentAgent.Position;
  365. }
  366. }
  367. // if (!(startLoc == "last" || startLoc == "home"))
  368. // {
  369. // // Format: uri:Ahern&162&213&34
  370. // try
  371. // {
  372. // string[] parts = startLoc.Remove(0, 4).Split('&');
  373. // //string region = parts[0];
  374. //
  375. // ////////////////////////////////////////////////////
  376. // //SimProfile SimInfo = new SimProfile();
  377. // //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey);
  378. // }
  379. // catch (Exception)
  380. // {
  381. // }
  382. // }
  383. }
  384. // What time did the user login?
  385. agent.LoginTime = Util.UnixTimeSinceEpoch();
  386. agent.LogoutTime = 0;
  387. // Current location
  388. agent.InitialRegion = LLUUID.Zero; // Fill in later
  389. agent.Region = LLUUID.Zero; // Fill in later
  390. profile.CurrentAgent = agent;
  391. }
  392. /// <summary>
  393. /// Process a user logoff from OpenSim.
  394. /// </summary>
  395. /// <param name="userid"></param>
  396. /// <param name="regionid"></param>
  397. /// <param name="regionhandle"></param>
  398. /// <param name="posx"></param>
  399. /// <param name="posy"></param>
  400. /// <param name="posz"></param>
  401. public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz)
  402. {
  403. if (StatsManager.UserStats != null)
  404. StatsManager.UserStats.AddLogout();
  405. UserProfileData userProfile;
  406. UserAgentData userAgent;
  407. LLVector3 currentPos = new LLVector3(posx, posy, posz);
  408. userProfile = GetUserProfile(userid);
  409. if (userProfile != null)
  410. {
  411. // This line needs to be in side the above if statement or the UserServer will crash on some logouts.
  412. m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + posx + "," + posy + "," + posz + ")");
  413. userAgent = userProfile.CurrentAgent;
  414. if (userAgent != null)
  415. {
  416. userAgent.AgentOnline = false;
  417. userAgent.LogoutTime = Util.UnixTimeSinceEpoch();
  418. //userAgent.sessionID = LLUUID.Zero;
  419. if (regionid != LLUUID.Zero)
  420. {
  421. userAgent.Region = regionid;
  422. }
  423. userAgent.Handle = regionhandle;
  424. userAgent.Position = currentPos;
  425. userProfile.CurrentAgent = userAgent;
  426. CommitAgent(ref userProfile);
  427. }
  428. else
  429. {
  430. // If currentagent is null, we can't reference it here or the UserServer crashes!
  431. m_log.Info("[LOGOUT]: didn't save logout position: " + userid.ToString());
  432. }
  433. }
  434. else
  435. {
  436. m_log.Warn("[LOGOUT]: Unknown User logged out");
  437. }
  438. }
  439. public void CreateAgent(UserProfileData profile, LLSD request)
  440. {
  441. UserAgentData agent = new UserAgentData();
  442. // User connection
  443. agent.AgentOnline = true;
  444. // Generate sessions
  445. RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
  446. byte[] randDataS = new byte[16];
  447. byte[] randDataSS = new byte[16];
  448. rand.GetBytes(randDataS);
  449. rand.GetBytes(randDataSS);
  450. agent.SecureSessionID = new LLUUID(randDataSS, 0);
  451. agent.SessionID = new LLUUID(randDataS, 0);
  452. // Profile UUID
  453. agent.ProfileID = profile.ID;
  454. // Current position (from Home)
  455. agent.Handle = profile.HomeRegion;
  456. agent.Position = profile.HomeLocation;
  457. // What time did the user login?
  458. agent.LoginTime = Util.UnixTimeSinceEpoch();
  459. agent.LogoutTime = 0;
  460. // Current location
  461. agent.InitialRegion = LLUUID.Zero; // Fill in later
  462. agent.Region = LLUUID.Zero; // Fill in later
  463. profile.CurrentAgent = agent;
  464. }
  465. /// <summary>
  466. /// Saves a target agent to the database
  467. /// </summary>
  468. /// <param name="profile">The users profile</param>
  469. /// <returns>Successful?</returns>
  470. public bool CommitAgent(ref UserProfileData profile)
  471. {
  472. // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents"
  473. // TODO: what is the logic should be?
  474. bool ret = false;
  475. ret = AddUserAgent(profile.CurrentAgent);
  476. ret = ret & UpdateUserProfile(profile);
  477. return ret;
  478. }
  479. #endregion
  480. /// <summary>
  481. ///
  482. /// </summary>
  483. /// <param name="user"></param>
  484. public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
  485. {
  486. UserProfileData user = new UserProfileData();
  487. user.HomeLocation = new LLVector3(128, 128, 100);
  488. user.ID = LLUUID.Random();
  489. user.FirstName = firstName;
  490. user.SurName = lastName;
  491. user.PasswordHash = pass;
  492. user.PasswordSalt = String.Empty;
  493. user.Created = Util.UnixTimeSinceEpoch();
  494. user.HomeLookAt = new LLVector3(100, 100, 100);
  495. user.HomeRegionX = regX;
  496. user.HomeRegionY = regY;
  497. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  498. {
  499. try
  500. {
  501. plugin.Value.AddNewUserProfile(user);
  502. }
  503. catch (Exception e)
  504. {
  505. m_log.Info("[USERSTORAGE]: Unable to add user via " + plugin.Key + "(" + e.ToString() + ")");
  506. }
  507. }
  508. return user.ID;
  509. }
  510. public bool UpdateUserProfileProperties(UserProfileData UserProfile)
  511. {
  512. if (null == GetUserProfile(UserProfile.ID))
  513. {
  514. m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.ID.ToString());
  515. return false;
  516. }
  517. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  518. {
  519. try
  520. {
  521. plugin.Value.UpdateUserProfile(UserProfile);
  522. }
  523. catch (Exception e)
  524. {
  525. m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.ID.ToString()
  526. + " via " + plugin.Key + "(" + e.ToString() + ")");
  527. return false;
  528. }
  529. }
  530. return true;
  531. }
  532. public abstract UserProfileData SetupMasterUser(string firstName, string lastName);
  533. public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password);
  534. public abstract UserProfileData SetupMasterUser(LLUUID uuid);
  535. /// <summary>
  536. /// Add agent to DB
  537. /// </summary>
  538. /// <param name="agentdata">The agent data to be added</param>
  539. public bool AddUserAgent(UserAgentData agentdata)
  540. {
  541. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  542. {
  543. try
  544. {
  545. plugin.Value.AddNewUserAgent(agentdata);
  546. return true;
  547. }
  548. catch (Exception e)
  549. {
  550. m_log.Info("[USERSTORAGE]: Unable to add agent via " + plugin.Key + "(" + e.ToString() + ")");
  551. }
  552. }
  553. return false;
  554. }
  555. /// Appearance
  556. /// TODO: stubs for now to get us to a compiling state gently
  557. public AvatarAppearance GetUserAppearance(LLUUID user)
  558. {
  559. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  560. {
  561. try
  562. {
  563. return plugin.Value.GetUserAppearance(user);
  564. }
  565. catch (Exception e)
  566. {
  567. m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString());
  568. }
  569. }
  570. return null;
  571. }
  572. public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
  573. {
  574. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  575. {
  576. try
  577. {
  578. plugin.Value.UpdateUserAppearance(user, appearance);
  579. }
  580. catch (Exception e)
  581. {
  582. m_log.InfoFormat("[USERSTORAGE]: Unable to update user appearance {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString());
  583. }
  584. }
  585. }
  586. public void AddAttachment(LLUUID user, LLUUID item)
  587. {
  588. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  589. {
  590. try
  591. {
  592. plugin.Value.AddAttachment(user, item);
  593. }
  594. catch (Exception e)
  595. {
  596. m_log.InfoFormat("[USERSTORAGE]: Unable to attach {3} => {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString(), item.ToString());
  597. }
  598. }
  599. }
  600. public void RemoveAttachment(LLUUID user, LLUUID item)
  601. {
  602. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  603. {
  604. try
  605. {
  606. plugin.Value.RemoveAttachment(user, item);
  607. }
  608. catch (Exception e)
  609. {
  610. m_log.InfoFormat("[USERSTORAGE]: Unable to remove attachment {3} => {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString(), item.ToString());
  611. }
  612. }
  613. }
  614. public List<LLUUID> GetAttachments(LLUUID user)
  615. {
  616. foreach (KeyValuePair<string, IUserData> plugin in _plugins)
  617. {
  618. try
  619. {
  620. return plugin.Value.GetAttachments(user);
  621. }
  622. catch (Exception e)
  623. {
  624. m_log.InfoFormat("[USERSTORAGE]: Unable to get attachments for {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString());
  625. }
  626. }
  627. return new List<LLUUID>();
  628. }
  629. }
  630. }