InventoryService.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  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. using System;
  28. using System.Collections.Generic;
  29. using System.Reflection;
  30. using log4net;
  31. using Nini.Config;
  32. using OpenMetaverse;
  33. using OpenSim.Data;
  34. using OpenSim.Framework;
  35. using OpenSim.Services.Interfaces;
  36. namespace OpenSim.Services.InventoryService
  37. {
  38. /// <summary>
  39. /// The Inventory service reference implementation
  40. /// </summary>
  41. public class InventoryService : InventoryServiceBase, IInventoryService
  42. {
  43. private static readonly ILog m_log
  44. = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  45. public InventoryService(IConfigSource config) : base(config)
  46. {
  47. m_log.Debug("[INVENTORY SERVICE]: Initialized.");
  48. }
  49. #region IInventoryServices methods
  50. public string Host
  51. {
  52. get { return "default"; }
  53. }
  54. public List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
  55. {
  56. m_log.DebugFormat("[INVENTORY SERVICE]: Getting inventory skeleton for {0}", userId);
  57. InventoryFolderBase rootFolder = GetRootFolder(userId);
  58. // Agent has no inventory structure yet.
  59. if (null == rootFolder)
  60. {
  61. m_log.DebugFormat("[INVENTORY SERVICE]: No root folder");
  62. return null;
  63. }
  64. List<InventoryFolderBase> userFolders = new List<InventoryFolderBase>();
  65. userFolders.Add(rootFolder);
  66. IList<InventoryFolderBase> folders = m_Database.getFolderHierarchy(rootFolder.ID);
  67. userFolders.AddRange(folders);
  68. // m_log.DebugFormat("[INVENTORY SERVICE]: Got folder {0} {1}", folder.name, folder.folderID);
  69. return userFolders;
  70. }
  71. public virtual bool HasInventoryForUser(UUID userID)
  72. {
  73. return false;
  74. }
  75. // See IInventoryServices
  76. public virtual InventoryFolderBase GetRootFolder(UUID userID)
  77. {
  78. //m_log.DebugFormat("[INVENTORY SERVICE]: Getting root folder for {0}", userID);
  79. // Retrieve the first root folder we get from the DB.
  80. InventoryFolderBase rootFolder = m_Database.getUserRootFolder(userID);
  81. if (rootFolder != null)
  82. return rootFolder;
  83. // Return nothing if the plugin was unable to supply a root folder
  84. return null;
  85. }
  86. // See IInventoryServices
  87. public bool CreateUserInventory(UUID user)
  88. {
  89. InventoryFolderBase existingRootFolder;
  90. try
  91. {
  92. existingRootFolder = GetRootFolder(user);
  93. }
  94. catch /*(Exception e)*/
  95. {
  96. // Munch the exception, it has already been reported
  97. //
  98. return false;
  99. }
  100. if (null != existingRootFolder)
  101. {
  102. m_log.WarnFormat(
  103. "[INVENTORY SERVICE]: Did not create a new inventory for user {0} since they already have "
  104. + "a root inventory folder with id {1}",
  105. user, existingRootFolder.ID);
  106. }
  107. else
  108. {
  109. UsersInventory inven = new UsersInventory();
  110. inven.CreateNewInventorySet(user);
  111. AddNewInventorySet(inven);
  112. return true;
  113. }
  114. return false;
  115. }
  116. // See IInventoryServices
  117. /// <summary>
  118. /// Return a user's entire inventory synchronously
  119. /// </summary>
  120. /// <param name="rawUserID"></param>
  121. /// <returns>The user's inventory. If an inventory cannot be found then an empty collection is returned.</returns>
  122. public InventoryCollection GetUserInventory(UUID userID)
  123. {
  124. m_log.InfoFormat("[INVENTORY SERVICE]: Processing request for inventory of {0}", userID);
  125. // Uncomment me to simulate a slow responding inventory server
  126. //Thread.Sleep(16000);
  127. InventoryCollection invCollection = new InventoryCollection();
  128. List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID);
  129. if (null == allFolders)
  130. {
  131. m_log.WarnFormat("[INVENTORY SERVICE]: No inventory found for user {0}", userID);
  132. return invCollection;
  133. }
  134. List<InventoryItemBase> allItems = new List<InventoryItemBase>();
  135. foreach (InventoryFolderBase folder in allFolders)
  136. {
  137. List<InventoryItemBase> items = GetFolderItems(userID, folder.ID);
  138. if (items != null)
  139. {
  140. allItems.InsertRange(0, items);
  141. }
  142. }
  143. invCollection.UserID = userID;
  144. invCollection.Folders = allFolders;
  145. invCollection.Items = allItems;
  146. // foreach (InventoryFolderBase folder in invCollection.Folders)
  147. // {
  148. // m_log.DebugFormat("[GRID INVENTORY SERVICE]: Sending back folder {0} {1}", folder.Name, folder.ID);
  149. // }
  150. //
  151. // foreach (InventoryItemBase item in invCollection.Items)
  152. // {
  153. // m_log.DebugFormat("[GRID INVENTORY SERVICE]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder);
  154. // }
  155. m_log.InfoFormat(
  156. "[INVENTORY SERVICE]: Sending back inventory response to user {0} containing {1} folders and {2} items",
  157. invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count);
  158. return invCollection;
  159. }
  160. /// <summary>
  161. /// Asynchronous inventory fetch.
  162. /// </summary>
  163. /// <param name="userID"></param>
  164. /// <param name="callback"></param>
  165. public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
  166. {
  167. m_log.InfoFormat("[INVENTORY SERVICE]: Requesting inventory for user {0}", userID);
  168. List<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
  169. List<InventoryItemBase> items = new List<InventoryItemBase>();
  170. List<InventoryFolderBase> skeletonFolders = GetInventorySkeleton(userID);
  171. if (skeletonFolders != null)
  172. {
  173. InventoryFolderImpl rootFolder = null;
  174. // Need to retrieve the root folder on the first pass
  175. foreach (InventoryFolderBase folder in skeletonFolders)
  176. {
  177. if (folder.ParentID == UUID.Zero)
  178. {
  179. rootFolder = new InventoryFolderImpl(folder);
  180. folders.Add(rootFolder);
  181. items.AddRange(GetFolderItems(userID, rootFolder.ID));
  182. break; // Only 1 root folder per user
  183. }
  184. }
  185. if (rootFolder != null)
  186. {
  187. foreach (InventoryFolderBase folder in skeletonFolders)
  188. {
  189. if (folder.ID != rootFolder.ID)
  190. {
  191. folders.Add(new InventoryFolderImpl(folder));
  192. items.AddRange(GetFolderItems(userID, folder.ID));
  193. }
  194. }
  195. }
  196. m_log.InfoFormat(
  197. "[INVENTORY SERVICE]: Received inventory response for user {0} containing {1} folders and {2} items",
  198. userID, folders.Count, items.Count);
  199. }
  200. else
  201. {
  202. m_log.WarnFormat("[INVENTORY SERVICE]: User {0} inventory not available", userID);
  203. }
  204. Util.FireAndForget(delegate { callback(folders, items); });
  205. }
  206. public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
  207. {
  208. // Uncomment me to simulate a slow responding inventory server
  209. //Thread.Sleep(16000);
  210. InventoryCollection invCollection = new InventoryCollection();
  211. List<InventoryItemBase> items = GetFolderItems(userID, folderID);
  212. List<InventoryFolderBase> folders = RequestSubFolders(folderID);
  213. invCollection.UserID = userID;
  214. invCollection.Folders = folders;
  215. invCollection.Items = items;
  216. m_log.DebugFormat("[INVENTORY SERVICE]: Found {0} items and {1} folders in folder {2}", items.Count, folders.Count, folderID);
  217. return invCollection;
  218. }
  219. public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
  220. {
  221. // m_log.DebugFormat("[INVENTORY SERVICE]: Looking for folder type {0} for user {1}", type, userID);
  222. InventoryFolderBase root = m_Database.getUserRootFolder(userID);
  223. if (root != null)
  224. {
  225. List<InventoryFolderBase> folders = RequestSubFolders(root.ID);
  226. foreach (InventoryFolderBase folder in folders)
  227. {
  228. if (folder.Type == (short)type)
  229. {
  230. // m_log.DebugFormat(
  231. // "[INVENTORY SERVICE]: Found folder {0} type {1}", folder.Name, (AssetType)folder.Type);
  232. return folder;
  233. }
  234. }
  235. }
  236. // we didn't find any folder of that type. Return the root folder
  237. // hopefully the root folder is not null. If it is, too bad
  238. return root;
  239. }
  240. public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
  241. {
  242. InventoryFolderBase root = GetRootFolder(userID);
  243. if (root != null)
  244. {
  245. InventoryCollection content = GetFolderContent(userID, root.ID);
  246. if (content != null)
  247. {
  248. Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
  249. foreach (InventoryFolderBase folder in content.Folders)
  250. {
  251. if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
  252. folders[(AssetType)folder.Type] = folder;
  253. }
  254. m_log.DebugFormat("[INVENTORY SERVICE]: Got {0} system folders for {1}", folders.Count, userID);
  255. return folders;
  256. }
  257. }
  258. m_log.WarnFormat("[INVENTORY SERVICE]: System folders for {0} not found", userID);
  259. return new Dictionary<AssetType, InventoryFolderBase>();
  260. }
  261. public List<InventoryItemBase> GetActiveGestures(UUID userId)
  262. {
  263. List<InventoryItemBase> activeGestures = new List<InventoryItemBase>();
  264. activeGestures.AddRange(m_Database.fetchActiveGestures(userId));
  265. return activeGestures;
  266. }
  267. #endregion
  268. #region Methods used by GridInventoryService
  269. public List<InventoryFolderBase> RequestSubFolders(UUID parentFolderID)
  270. {
  271. List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
  272. inventoryList.AddRange(m_Database.getInventoryFolders(parentFolderID));
  273. return inventoryList;
  274. }
  275. public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
  276. {
  277. List<InventoryItemBase> itemsList = new List<InventoryItemBase>();
  278. itemsList.AddRange(m_Database.getInventoryInFolder(folderID));
  279. // m_log.DebugFormat(
  280. // "[INVENTORY SERVICE]: Found {0} items in folder {1} for {2}", itemsList.Count, folderID, userID);
  281. return itemsList;
  282. }
  283. #endregion
  284. // See IInventoryServices
  285. public virtual bool AddFolder(InventoryFolderBase folder)
  286. {
  287. m_log.DebugFormat(
  288. "[INVENTORY SERVICE]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
  289. m_Database.addInventoryFolder(folder);
  290. // FIXME: Should return false on failure
  291. return true;
  292. }
  293. // See IInventoryServices
  294. public virtual bool UpdateFolder(InventoryFolderBase folder)
  295. {
  296. m_log.DebugFormat(
  297. "[INVENTORY SERVICE]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
  298. m_Database.updateInventoryFolder(folder);
  299. // FIXME: Should return false on failure
  300. return true;
  301. }
  302. // See IInventoryServices
  303. public virtual bool MoveFolder(InventoryFolderBase folder)
  304. {
  305. m_log.DebugFormat(
  306. "[INVENTORY SERVICE]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
  307. m_Database.moveInventoryFolder(folder);
  308. // FIXME: Should return false on failure
  309. return true;
  310. }
  311. // See IInventoryServices
  312. public virtual bool AddItem(InventoryItemBase item)
  313. {
  314. // m_log.DebugFormat(
  315. // "[INVENTORY SERVICE]: Adding item {0} {1} to folder {2} for {3}",
  316. // item.Name, item.ID, item.Folder, item.Owner);
  317. m_Database.addInventoryItem(item);
  318. // FIXME: Should return false on failure
  319. return true;
  320. }
  321. // See IInventoryServices
  322. public virtual bool UpdateItem(InventoryItemBase item)
  323. {
  324. m_log.InfoFormat(
  325. "[INVENTORY SERVICE]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder);
  326. m_Database.updateInventoryItem(item);
  327. // FIXME: Should return false on failure
  328. return true;
  329. }
  330. public virtual bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
  331. {
  332. m_log.InfoFormat(
  333. "[INVENTORY SERVICE]: Moving {0} items from user {1}", items.Count, ownerID);
  334. InventoryItemBase itm = null;
  335. foreach (InventoryItemBase item in items)
  336. {
  337. itm = GetInventoryItem(item.ID);
  338. itm.Folder = item.Folder;
  339. if ((item.Name != null) && !item.Name.Equals(string.Empty))
  340. itm.Name = item.Name;
  341. m_Database.updateInventoryItem(itm);
  342. }
  343. return true;
  344. }
  345. // See IInventoryServices
  346. public virtual bool DeleteItems(UUID owner, List<UUID> itemIDs)
  347. {
  348. m_log.InfoFormat(
  349. "[INVENTORY SERVICE]: Deleting {0} items from user {1}", itemIDs.Count, owner);
  350. // uhh.....
  351. foreach (UUID uuid in itemIDs)
  352. m_Database.deleteInventoryItem(uuid);
  353. // FIXME: Should return false on failure
  354. return true;
  355. }
  356. public virtual InventoryItemBase GetItem(InventoryItemBase item)
  357. {
  358. InventoryItemBase result = m_Database.getInventoryItem(item.ID);
  359. if (result != null)
  360. return result;
  361. m_log.DebugFormat("[INVENTORY SERVICE]: GetItem failed to find item {0}", item.ID);
  362. return null;
  363. }
  364. public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder)
  365. {
  366. InventoryFolderBase result = m_Database.getInventoryFolder(folder.ID);
  367. if (result != null)
  368. return result;
  369. m_log.DebugFormat("[INVENTORY SERVICE]: GetFolder failed to find folder {0}", folder.ID);
  370. return null;
  371. }
  372. public virtual bool DeleteFolders(UUID ownerID, List<UUID> folderIDs)
  373. {
  374. m_log.InfoFormat("[INVENTORY SERVICE]: Deleting {0} folders from user {1}", folderIDs.Count, ownerID);
  375. foreach (UUID id in folderIDs)
  376. {
  377. InventoryFolderBase folder = new InventoryFolderBase(id, ownerID);
  378. PurgeFolder(folder);
  379. m_Database.deleteInventoryFolder(id);
  380. }
  381. return true;
  382. }
  383. /// <summary>
  384. /// Purge a folder of all items items and subfolders.
  385. ///
  386. /// FIXME: Really nasty in a sense, because we have to query the database to get information we may
  387. /// already know... Needs heavy refactoring.
  388. /// </summary>
  389. /// <param name="folder"></param>
  390. public virtual bool PurgeFolder(InventoryFolderBase folder)
  391. {
  392. m_log.DebugFormat(
  393. "[INVENTORY SERVICE]: Purging folder {0} {1} of its contents", folder.Name, folder.ID);
  394. List<InventoryFolderBase> subFolders = RequestSubFolders(folder.ID);
  395. foreach (InventoryFolderBase subFolder in subFolders)
  396. {
  397. // m_log.DebugFormat("[INVENTORY SERVICE]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID);
  398. m_Database.deleteInventoryFolder(subFolder.ID);
  399. }
  400. List<InventoryItemBase> items = GetFolderItems(folder.Owner, folder.ID);
  401. List<UUID> uuids = new List<UUID>();
  402. foreach (InventoryItemBase item in items)
  403. {
  404. uuids.Add(item.ID);
  405. }
  406. DeleteItems(folder.Owner, uuids);
  407. // FIXME: Should return false on failure
  408. return true;
  409. }
  410. private void AddNewInventorySet(UsersInventory inventory)
  411. {
  412. foreach (InventoryFolderBase folder in inventory.Folders.Values)
  413. {
  414. AddFolder(folder);
  415. }
  416. }
  417. public InventoryItemBase GetInventoryItem(UUID itemID)
  418. {
  419. InventoryItemBase item = m_Database.getInventoryItem(itemID);
  420. if (item != null)
  421. return item;
  422. return null;
  423. }
  424. public int GetAssetPermissions(UUID userID, UUID assetID)
  425. {
  426. InventoryFolderBase parent = GetRootFolder(userID);
  427. return FindAssetPerms(parent, assetID);
  428. }
  429. private int FindAssetPerms(InventoryFolderBase folder, UUID assetID)
  430. {
  431. InventoryCollection contents = GetFolderContent(folder.Owner, folder.ID);
  432. int perms = 0;
  433. foreach (InventoryItemBase item in contents.Items)
  434. {
  435. if (item.AssetID == assetID)
  436. perms = (int)item.CurrentPermissions | perms;
  437. }
  438. foreach (InventoryFolderBase subfolder in contents.Folders)
  439. perms = perms | FindAssetPerms(subfolder, assetID);
  440. return perms;
  441. }
  442. /// <summary>
  443. /// Used to create a new user inventory.
  444. /// </summary>
  445. private class UsersInventory
  446. {
  447. public Dictionary<UUID, InventoryFolderBase> Folders = new Dictionary<UUID, InventoryFolderBase>();
  448. public Dictionary<UUID, InventoryItemBase> Items = new Dictionary<UUID, InventoryItemBase>();
  449. public virtual void CreateNewInventorySet(UUID user)
  450. {
  451. InventoryFolderBase folder = new InventoryFolderBase();
  452. folder.ParentID = UUID.Zero;
  453. folder.Owner = user;
  454. folder.ID = UUID.Random();
  455. folder.Name = "My Inventory";
  456. folder.Type = (short)AssetType.Folder;
  457. folder.Version = 1;
  458. Folders.Add(folder.ID, folder);
  459. UUID rootFolder = folder.ID;
  460. folder = new InventoryFolderBase();
  461. folder.ParentID = rootFolder;
  462. folder.Owner = user;
  463. folder.ID = UUID.Random();
  464. folder.Name = "Animations";
  465. folder.Type = (short)AssetType.Animation;
  466. folder.Version = 1;
  467. Folders.Add(folder.ID, folder);
  468. folder = new InventoryFolderBase();
  469. folder.ParentID = rootFolder;
  470. folder.Owner = user;
  471. folder.ID = UUID.Random();
  472. folder.Name = "Body Parts";
  473. folder.Type = (short)AssetType.Bodypart;
  474. folder.Version = 1;
  475. Folders.Add(folder.ID, folder);
  476. folder = new InventoryFolderBase();
  477. folder.ParentID = rootFolder;
  478. folder.Owner = user;
  479. folder.ID = UUID.Random();
  480. folder.Name = "Calling Cards";
  481. folder.Type = (short)AssetType.CallingCard;
  482. folder.Version = 1;
  483. Folders.Add(folder.ID, folder);
  484. folder = new InventoryFolderBase();
  485. folder.ParentID = rootFolder;
  486. folder.Owner = user;
  487. folder.ID = UUID.Random();
  488. folder.Name = "Clothing";
  489. folder.Type = (short)AssetType.Clothing;
  490. folder.Version = 1;
  491. Folders.Add(folder.ID, folder);
  492. folder = new InventoryFolderBase();
  493. folder.ParentID = rootFolder;
  494. folder.Owner = user;
  495. folder.ID = UUID.Random();
  496. folder.Name = "Gestures";
  497. folder.Type = (short)AssetType.Gesture;
  498. folder.Version = 1;
  499. Folders.Add(folder.ID, folder);
  500. folder = new InventoryFolderBase();
  501. folder.ParentID = rootFolder;
  502. folder.Owner = user;
  503. folder.ID = UUID.Random();
  504. folder.Name = "Landmarks";
  505. folder.Type = (short)AssetType.Landmark;
  506. folder.Version = 1;
  507. Folders.Add(folder.ID, folder);
  508. folder = new InventoryFolderBase();
  509. folder.ParentID = rootFolder;
  510. folder.Owner = user;
  511. folder.ID = UUID.Random();
  512. folder.Name = "Lost And Found";
  513. folder.Type = (short)AssetType.LostAndFoundFolder;
  514. folder.Version = 1;
  515. Folders.Add(folder.ID, folder);
  516. folder = new InventoryFolderBase();
  517. folder.ParentID = rootFolder;
  518. folder.Owner = user;
  519. folder.ID = UUID.Random();
  520. folder.Name = "Notecards";
  521. folder.Type = (short)AssetType.Notecard;
  522. folder.Version = 1;
  523. Folders.Add(folder.ID, folder);
  524. folder = new InventoryFolderBase();
  525. folder.ParentID = rootFolder;
  526. folder.Owner = user;
  527. folder.ID = UUID.Random();
  528. folder.Name = "Objects";
  529. folder.Type = (short)AssetType.Object;
  530. folder.Version = 1;
  531. Folders.Add(folder.ID, folder);
  532. folder = new InventoryFolderBase();
  533. folder.ParentID = rootFolder;
  534. folder.Owner = user;
  535. folder.ID = UUID.Random();
  536. folder.Name = "Photo Album";
  537. folder.Type = (short)AssetType.SnapshotFolder;
  538. folder.Version = 1;
  539. Folders.Add(folder.ID, folder);
  540. folder = new InventoryFolderBase();
  541. folder.ParentID = rootFolder;
  542. folder.Owner = user;
  543. folder.ID = UUID.Random();
  544. folder.Name = "Scripts";
  545. folder.Type = (short)AssetType.LSLText;
  546. folder.Version = 1;
  547. Folders.Add(folder.ID, folder);
  548. folder = new InventoryFolderBase();
  549. folder.ParentID = rootFolder;
  550. folder.Owner = user;
  551. folder.ID = UUID.Random();
  552. folder.Name = "Sounds";
  553. folder.Type = (short)AssetType.Sound;
  554. folder.Version = 1;
  555. Folders.Add(folder.ID, folder);
  556. folder = new InventoryFolderBase();
  557. folder.ParentID = rootFolder;
  558. folder.Owner = user;
  559. folder.ID = UUID.Random();
  560. folder.Name = "Textures";
  561. folder.Type = (short)AssetType.Texture;
  562. folder.Version = 1;
  563. Folders.Add(folder.ID, folder);
  564. folder = new InventoryFolderBase();
  565. folder.ParentID = rootFolder;
  566. folder.Owner = user;
  567. folder.ID = UUID.Random();
  568. folder.Name = "Trash";
  569. folder.Type = (short)AssetType.TrashFolder;
  570. folder.Version = 1;
  571. Folders.Add(folder.ID, folder);
  572. }
  573. }
  574. }
  575. }