MySQLUserData.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  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.Generic;
  29. using System.Data;
  30. using System.Reflection;
  31. using System.Text.RegularExpressions;
  32. using libsecondlife;
  33. using log4net;
  34. using OpenSim.Framework;
  35. using OpenSim.Data.Base;
  36. namespace OpenSim.Data.MySQL
  37. {
  38. /// <summary>
  39. /// A database interface class to a user profile storage system
  40. /// </summary>
  41. internal class MySQLUserData : UserDataBase
  42. {
  43. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  44. /// <summary>
  45. /// Database manager for MySQL
  46. /// </summary>
  47. public MySQLManager database;
  48. private string m_agentsTableName;
  49. private string m_usersTableName;
  50. private string m_userFriendsTableName;
  51. private string m_appearanceTableName = "avatarappearance";
  52. private string m_connectString;
  53. /// <summary>
  54. /// Loads and initialises the MySQL storage plugin
  55. /// </summary>
  56. override public void Initialise(string connect)
  57. {
  58. if (connect == String.Empty) {
  59. // TODO: actually do something with our connect string
  60. // instead of loading the second config
  61. m_log.Warn("Using obsoletely mysql_connection.ini, try using user_source connect string instead");
  62. IniFile iniFile = new IniFile("mysql_connection.ini");
  63. string settingHostname = iniFile.ParseFileReadValue("hostname");
  64. string settingDatabase = iniFile.ParseFileReadValue("database");
  65. string settingUsername = iniFile.ParseFileReadValue("username");
  66. string settingPassword = iniFile.ParseFileReadValue("password");
  67. string settingPooling = iniFile.ParseFileReadValue("pooling");
  68. string settingPort = iniFile.ParseFileReadValue("port");
  69. m_usersTableName = iniFile.ParseFileReadValue("userstablename");
  70. if (m_usersTableName == null)
  71. {
  72. m_usersTableName = "users";
  73. }
  74. m_userFriendsTableName = iniFile.ParseFileReadValue("userfriendstablename");
  75. if (m_userFriendsTableName == null)
  76. {
  77. m_userFriendsTableName = "userfriends";
  78. }
  79. m_agentsTableName = iniFile.ParseFileReadValue("agentstablename");
  80. if (m_agentsTableName == null)
  81. {
  82. m_agentsTableName = "agents";
  83. }
  84. m_connectString = "Server=" + settingHostname + ";Port=" + settingPort + ";Database=" + settingDatabase + ";User ID=" +
  85. settingUsername + ";Password=" + settingPassword + ";Pooling=" + settingPooling + ";";
  86. database = new MySQLManager(m_connectString);
  87. }
  88. else
  89. {
  90. m_connectString = connect;
  91. m_agentsTableName = "agents";
  92. m_usersTableName = "users";
  93. m_userFriendsTableName = "userfriends";
  94. database = new MySQLManager(m_connectString);
  95. }
  96. TestTables();
  97. }
  98. #region Test and initialization code
  99. /// <summary>
  100. /// Ensure that the user related tables exists and are at the latest version
  101. /// </summary>
  102. private void TestTables()
  103. {
  104. Dictionary<string, string> tableList = new Dictionary<string, string>();
  105. tableList[m_agentsTableName] = null;
  106. tableList[m_usersTableName] = null;
  107. tableList[m_userFriendsTableName] = null;
  108. tableList[m_appearanceTableName] = null;
  109. database.GetTableVersion(tableList);
  110. UpgradeAgentsTable(tableList[m_agentsTableName]);
  111. UpgradeUsersTable(tableList[m_usersTableName]);
  112. UpgradeFriendsTable(tableList[m_userFriendsTableName]);
  113. UpgradeAppearanceTable(tableList[m_appearanceTableName]);
  114. }
  115. /// <summary>
  116. /// Create or upgrade the table if necessary
  117. /// </summary>
  118. /// <param name="oldVersion">A null indicates that the table does not
  119. /// currently exist</param>
  120. private void UpgradeAgentsTable(string oldVersion)
  121. {
  122. // null as the version, indicates that the table didn't exist
  123. if (oldVersion == null)
  124. {
  125. database.ExecuteResourceSql("CreateAgentsTable.sql");
  126. return;
  127. }
  128. }
  129. /// <summary>
  130. /// Create or upgrade the table if necessary
  131. /// </summary>
  132. /// <param name="oldVersion">A null indicates that the table does not
  133. /// currently exist</param>
  134. private void UpgradeUsersTable(string oldVersion)
  135. {
  136. // null as the version, indicates that the table didn't exist
  137. if (oldVersion == null)
  138. {
  139. database.ExecuteResourceSql("CreateUsersTable.sql");
  140. return;
  141. }
  142. else if (oldVersion.Contains("Rev. 1"))
  143. {
  144. database.ExecuteResourceSql("UpgradeUsersTableToVersion2.sql");
  145. return;
  146. }
  147. //m_log.Info("[DB]: DBVers:" + oldVersion);
  148. }
  149. /// <summary>
  150. /// Create or upgrade the table if necessary
  151. /// </summary>
  152. /// <param name="oldVersion">A null indicates that the table does not
  153. /// currently exist</param>
  154. private void UpgradeFriendsTable(string oldVersion)
  155. {
  156. // null as the version, indicates that the table didn't exist
  157. if (oldVersion == null)
  158. {
  159. database.ExecuteResourceSql("CreateUserFriendsTable.sql");
  160. return;
  161. }
  162. }
  163. /// <summary>
  164. /// Create or upgrade the table if necessary
  165. /// </summary>
  166. /// <param name="oldVersion">A null indicates that the table does not
  167. /// currently exist</param>
  168. private void UpgradeAppearanceTable(string oldVersion)
  169. {
  170. // null as the version, indicates that the table didn't exist
  171. if (oldVersion == null)
  172. {
  173. database.ExecuteResourceSql("CreateAvatarAppearance.sql");
  174. return;
  175. }
  176. else if (oldVersion.Contains("Rev.1"))
  177. {
  178. database.ExecuteSql("drop table avatarappearance");
  179. database.ExecuteResourceSql("CreateAvatarAppearance.sql");
  180. return;
  181. }
  182. }
  183. #endregion
  184. // see IUserData
  185. override public UserProfileData GetUserByName(string user, string last)
  186. {
  187. try
  188. {
  189. lock (database)
  190. {
  191. Dictionary<string, string> param = new Dictionary<string, string>();
  192. param["?first"] = user;
  193. param["?second"] = last;
  194. IDbCommand result =
  195. database.Query("SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param);
  196. IDataReader reader = result.ExecuteReader();
  197. UserProfileData row = database.readUserRow(reader);
  198. reader.Close();
  199. result.Dispose();
  200. return row;
  201. }
  202. }
  203. catch (Exception e)
  204. {
  205. database.Reconnect();
  206. m_log.Error(e.ToString());
  207. return null;
  208. }
  209. }
  210. #region User Friends List Data
  211. override public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
  212. {
  213. int dtvalue = Util.UnixTimeSinceEpoch();
  214. Dictionary<string, string> param = new Dictionary<string, string>();
  215. param["?ownerID"] = friendlistowner.UUID.ToString();
  216. param["?friendID"] = friend.UUID.ToString();
  217. param["?friendPerms"] = perms.ToString();
  218. param["?datetimestamp"] = dtvalue.ToString();
  219. try
  220. {
  221. lock (database)
  222. {
  223. IDbCommand adder =
  224. database.Query(
  225. "INSERT INTO `" + m_userFriendsTableName + "` " +
  226. "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
  227. "VALUES " +
  228. "(?ownerID,?friendID,?friendPerms,?datetimestamp)",
  229. param);
  230. adder.ExecuteNonQuery();
  231. adder =
  232. database.Query(
  233. "INSERT INTO `" + m_userFriendsTableName + "` " +
  234. "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
  235. "VALUES " +
  236. "(?friendID,?ownerID,?friendPerms,?datetimestamp)",
  237. param);
  238. adder.ExecuteNonQuery();
  239. }
  240. }
  241. catch (Exception e)
  242. {
  243. database.Reconnect();
  244. m_log.Error(e.ToString());
  245. return;
  246. }
  247. }
  248. override public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
  249. {
  250. Dictionary<string, string> param = new Dictionary<string, string>();
  251. param["?ownerID"] = friendlistowner.UUID.ToString();
  252. param["?friendID"] = friend.UUID.ToString();
  253. try
  254. {
  255. lock (database)
  256. {
  257. IDbCommand updater =
  258. database.Query(
  259. "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID",
  260. param);
  261. updater.ExecuteNonQuery();
  262. updater =
  263. database.Query(
  264. "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID",
  265. param);
  266. updater.ExecuteNonQuery();
  267. }
  268. }
  269. catch (Exception e)
  270. {
  271. database.Reconnect();
  272. m_log.Error(e.ToString());
  273. return;
  274. }
  275. }
  276. override public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
  277. {
  278. Dictionary<string, string> param = new Dictionary<string, string>();
  279. param["?ownerID"] = friendlistowner.UUID.ToString();
  280. param["?friendID"] = friend.UUID.ToString();
  281. param["?friendPerms"] = perms.ToString();
  282. try
  283. {
  284. lock (database)
  285. {
  286. IDbCommand updater =
  287. database.Query(
  288. "update " + m_userFriendsTableName +
  289. " SET friendPerms = ?friendPerms " +
  290. "where ownerID = ?ownerID and friendID = ?friendID",
  291. param);
  292. updater.ExecuteNonQuery();
  293. }
  294. }
  295. catch (Exception e)
  296. {
  297. database.Reconnect();
  298. m_log.Error(e.ToString());
  299. return;
  300. }
  301. }
  302. override public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner)
  303. {
  304. List<FriendListItem> Lfli = new List<FriendListItem>();
  305. Dictionary<string, string> param = new Dictionary<string, string>();
  306. param["?ownerID"] = friendlistowner.UUID.ToString();
  307. try
  308. {
  309. lock (database)
  310. {
  311. //Left Join userfriends to itself
  312. IDbCommand result =
  313. database.Query(
  314. "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" +
  315. " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID",
  316. param);
  317. IDataReader reader = result.ExecuteReader();
  318. while (reader.Read())
  319. {
  320. FriendListItem fli = new FriendListItem();
  321. fli.FriendListOwner = new LLUUID((string)reader["ownerID"]);
  322. fli.Friend = new LLUUID((string)reader["friendID"]);
  323. fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]);
  324. // This is not a real column in the database table, it's a joined column from the opposite record
  325. fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]);
  326. Lfli.Add(fli);
  327. }
  328. reader.Close();
  329. result.Dispose();
  330. }
  331. }
  332. catch (Exception e)
  333. {
  334. database.Reconnect();
  335. m_log.Error(e.ToString());
  336. return Lfli;
  337. }
  338. return Lfli;
  339. }
  340. #endregion
  341. override public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid)
  342. {
  343. m_log.Info("[USER DB]: Stub UpdateUserCUrrentRegion called");
  344. }
  345. override public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
  346. {
  347. List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
  348. Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]");
  349. string[] querysplit;
  350. querysplit = query.Split(' ');
  351. if (querysplit.Length == 2)
  352. {
  353. Dictionary<string, string> param = new Dictionary<string, string>();
  354. param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";
  355. param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%";
  356. try
  357. {
  358. lock (database)
  359. {
  360. IDbCommand result =
  361. database.Query(
  362. "SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username like ?first AND lastname like ?second LIMIT 100",
  363. param);
  364. IDataReader reader = result.ExecuteReader();
  365. while (reader.Read())
  366. {
  367. AvatarPickerAvatar user = new AvatarPickerAvatar();
  368. user.AvatarID = new LLUUID((string) reader["UUID"]);
  369. user.firstName = (string) reader["username"];
  370. user.lastName = (string) reader["lastname"];
  371. returnlist.Add(user);
  372. }
  373. reader.Close();
  374. result.Dispose();
  375. }
  376. }
  377. catch (Exception e)
  378. {
  379. database.Reconnect();
  380. m_log.Error(e.ToString());
  381. return returnlist;
  382. }
  383. }
  384. else if (querysplit.Length == 1)
  385. {
  386. try
  387. {
  388. lock (database)
  389. {
  390. Dictionary<string, string> param = new Dictionary<string, string>();
  391. param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";
  392. IDbCommand result =
  393. database.Query(
  394. "SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username like ?first OR lastname like ?first LIMIT 100",
  395. param);
  396. IDataReader reader = result.ExecuteReader();
  397. while (reader.Read())
  398. {
  399. AvatarPickerAvatar user = new AvatarPickerAvatar();
  400. user.AvatarID = new LLUUID((string) reader["UUID"]);
  401. user.firstName = (string) reader["username"];
  402. user.lastName = (string) reader["lastname"];
  403. returnlist.Add(user);
  404. }
  405. reader.Close();
  406. result.Dispose();
  407. }
  408. }
  409. catch (Exception e)
  410. {
  411. database.Reconnect();
  412. m_log.Error(e.ToString());
  413. return returnlist;
  414. }
  415. }
  416. return returnlist;
  417. }
  418. // see IUserData
  419. override public UserProfileData GetUserByUUID(LLUUID uuid)
  420. {
  421. try
  422. {
  423. lock (database)
  424. {
  425. Dictionary<string, string> param = new Dictionary<string, string>();
  426. param["?uuid"] = uuid.ToString();
  427. IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param);
  428. IDataReader reader = result.ExecuteReader();
  429. UserProfileData row = database.readUserRow(reader);
  430. reader.Close();
  431. result.Dispose();
  432. return row;
  433. }
  434. }
  435. catch (Exception e)
  436. {
  437. database.Reconnect();
  438. m_log.Error(e.ToString());
  439. return null;
  440. }
  441. }
  442. /// <summary>
  443. /// Returns a user session searching by name
  444. /// </summary>
  445. /// <param name="name">The account name</param>
  446. /// <returns>The users session</returns>
  447. override public UserAgentData GetAgentByName(string name)
  448. {
  449. return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
  450. }
  451. /// <summary>
  452. /// Returns a user session by account name
  453. /// </summary>
  454. /// <param name="user">First part of the users account name</param>
  455. /// <param name="last">Second part of the users account name</param>
  456. /// <returns>The users session</returns>
  457. override public UserAgentData GetAgentByName(string user, string last)
  458. {
  459. UserProfileData profile = GetUserByName(user, last);
  460. return GetAgentByUUID(profile.ID);
  461. }
  462. override public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey)
  463. {
  464. Dictionary<string, string> param = new Dictionary<string, string>();
  465. param["?UUID"] = AgentID.UUID.ToString();
  466. param["?webLoginKey"] = WebLoginKey.UUID.ToString();
  467. try
  468. {
  469. lock (database)
  470. {
  471. IDbCommand updater =
  472. database.Query(
  473. "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " +
  474. "where UUID = ?UUID",
  475. param);
  476. updater.ExecuteNonQuery();
  477. }
  478. }
  479. catch (Exception e)
  480. {
  481. database.Reconnect();
  482. m_log.Error(e.ToString());
  483. return;
  484. }
  485. }
  486. /// <summary>
  487. /// Returns an agent session by account UUID
  488. /// </summary>
  489. /// <param name="uuid">The accounts UUID</param>
  490. /// <returns>The users session</returns>
  491. override public UserAgentData GetAgentByUUID(LLUUID uuid)
  492. {
  493. try
  494. {
  495. lock (database)
  496. {
  497. Dictionary<string, string> param = new Dictionary<string, string>();
  498. param["?uuid"] = uuid.ToString();
  499. IDbCommand result = database.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param);
  500. IDataReader reader = result.ExecuteReader();
  501. UserAgentData row = database.readAgentRow(reader);
  502. reader.Close();
  503. result.Dispose();
  504. return row;
  505. }
  506. }
  507. catch (Exception e)
  508. {
  509. database.Reconnect();
  510. m_log.Error(e.ToString());
  511. return null;
  512. }
  513. }
  514. /// <summary>
  515. /// Creates a new users profile
  516. /// </summary>
  517. /// <param name="user">The user profile to create</param>
  518. override public void AddNewUserProfile(UserProfileData user)
  519. {
  520. try
  521. {
  522. lock (database)
  523. {
  524. database.insertUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt,
  525. user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y,
  526. user.HomeLocation.Z,
  527. user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created,
  528. user.LastLogin, user.UserInventoryURI, user.UserAssetURI,
  529. user.CanDoMask, user.WantDoMask,
  530. user.AboutText, user.FirstLifeAboutText, user.Image,
  531. user.FirstLifeImage, user.WebLoginKey);
  532. }
  533. }
  534. catch (Exception e)
  535. {
  536. database.Reconnect();
  537. m_log.Error(e.ToString());
  538. }
  539. }
  540. /// <summary>
  541. /// Creates a new agent
  542. /// </summary>
  543. /// <param name="agent">The agent to create</param>
  544. override public void AddNewUserAgent(UserAgentData agent)
  545. {
  546. try
  547. {
  548. lock (database)
  549. {
  550. database.insertAgentRow(agent);
  551. }
  552. }
  553. catch (Exception e)
  554. {
  555. database.Reconnect();
  556. m_log.Error(e.ToString());
  557. }
  558. }
  559. /// <summary>
  560. /// Updates a user profile stored in the DB
  561. /// </summary>
  562. /// <param name="user">The profile data to use to update the DB</param>
  563. override public bool UpdateUserProfile(UserProfileData user)
  564. {
  565. lock (database)
  566. {
  567. database.updateUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt,
  568. user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X,
  569. user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI,
  570. user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText,
  571. user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey);
  572. }
  573. return true;
  574. }
  575. /// <summary>
  576. /// Performs a money transfer request between two accounts
  577. /// </summary>
  578. /// <param name="from">The senders account ID</param>
  579. /// <param name="to">The receivers account ID</param>
  580. /// <param name="amount">The amount to transfer</param>
  581. /// <returns>Success?</returns>
  582. override public bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount)
  583. {
  584. return false;
  585. }
  586. /// <summary>
  587. /// Performs an inventory transfer request between two accounts
  588. /// </summary>
  589. /// <remarks>TODO: Move to inventory server</remarks>
  590. /// <param name="from">The senders account ID</param>
  591. /// <param name="to">The receivers account ID</param>
  592. /// <param name="item">The item to transfer</param>
  593. /// <returns>Success?</returns>
  594. override public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
  595. {
  596. return false;
  597. }
  598. /// Appearance
  599. /// TODO: stubs for now to get us to a compiling state gently
  600. // override
  601. override public AvatarAppearance GetUserAppearance(LLUUID user)
  602. {
  603. try {
  604. lock (database)
  605. {
  606. Dictionary<string, string> param = new Dictionary<string, string>();
  607. param["?owner"] = user.ToString();
  608. IDbCommand result = database.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param);
  609. IDataReader reader = result.ExecuteReader();
  610. AvatarAppearance appearance = database.readAppearanceRow(reader);
  611. reader.Close();
  612. result.Dispose();
  613. return appearance;
  614. }
  615. }
  616. catch (Exception e)
  617. {
  618. database.Reconnect();
  619. m_log.Error(e.ToString());
  620. return null;
  621. }
  622. }
  623. // override
  624. override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
  625. {
  626. try
  627. {
  628. lock (database)
  629. {
  630. appearance.Owner = user;
  631. database.insertAppearanceRow(appearance);
  632. }
  633. }
  634. catch (Exception e)
  635. {
  636. database.Reconnect();
  637. m_log.Error(e.ToString());
  638. }
  639. }
  640. override public void AddAttachment(LLUUID user, LLUUID item)
  641. {
  642. return;
  643. }
  644. override public void RemoveAttachment(LLUUID user, LLUUID item)
  645. {
  646. return;
  647. }
  648. override public List<LLUUID> GetAttachments(LLUUID user)
  649. {
  650. return new List<LLUUID>();
  651. }
  652. /// <summary>
  653. /// Database provider name
  654. /// </summary>
  655. /// <returns>Provider name</returns>
  656. override public string Name
  657. {
  658. get {return "MySQL Userdata Interface";}
  659. }
  660. /// <summary>
  661. /// Database provider version
  662. /// </summary>
  663. /// <returns>provider version</returns>
  664. override public string Version
  665. {
  666. get {return "0.1";}
  667. }
  668. }
  669. }