InventoryService.cs 25 KB

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