XInventoryService.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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 OpenMetaverse;
  30. using log4net;
  31. using Nini.Config;
  32. using System.Reflection;
  33. using OpenSim.Services.Base;
  34. using OpenSim.Services.Interfaces;
  35. using OpenSim.Data;
  36. using OpenSim.Framework;
  37. namespace OpenSim.Services.InventoryService
  38. {
  39. public class XInventoryService : ServiceBase, IInventoryService
  40. {
  41. private static readonly ILog m_log =
  42. LogManager.GetLogger(
  43. MethodBase.GetCurrentMethod().DeclaringType);
  44. protected IXInventoryData m_Database;
  45. protected bool m_AllowDelete = true;
  46. public XInventoryService(IConfigSource config) : base(config)
  47. {
  48. string dllName = String.Empty;
  49. string connString = String.Empty;
  50. //string realm = "Inventory"; // OSG version doesn't use this
  51. //
  52. // Try reading the [InventoryService] section first, if it exists
  53. //
  54. IConfig authConfig = config.Configs["InventoryService"];
  55. if (authConfig != null)
  56. {
  57. dllName = authConfig.GetString("StorageProvider", dllName);
  58. connString = authConfig.GetString("ConnectionString", connString);
  59. m_AllowDelete = authConfig.GetBoolean("AllowDelete", true);
  60. // realm = authConfig.GetString("Realm", realm);
  61. }
  62. //
  63. // Try reading the [DatabaseService] section, if it exists
  64. //
  65. IConfig dbConfig = config.Configs["DatabaseService"];
  66. if (dbConfig != null)
  67. {
  68. if (dllName == String.Empty)
  69. dllName = dbConfig.GetString("StorageProvider", String.Empty);
  70. if (connString == String.Empty)
  71. connString = dbConfig.GetString("ConnectionString", String.Empty);
  72. }
  73. //
  74. // We tried, but this doesn't exist. We can't proceed.
  75. //
  76. if (dllName == String.Empty)
  77. throw new Exception("No StorageProvider configured");
  78. m_Database = LoadPlugin<IXInventoryData>(dllName,
  79. new Object[] {connString, String.Empty});
  80. if (m_Database == null)
  81. throw new Exception("Could not find a storage interface in the given module");
  82. }
  83. public virtual bool CreateUserInventory(UUID principalID)
  84. {
  85. // This is braindeaad. We can't ever communicate that we fixed
  86. // an existing inventory. Well, just return root folder status,
  87. // but check sanity anyway.
  88. //
  89. bool result = false;
  90. InventoryFolderBase rootFolder = GetRootFolder(principalID);
  91. if (rootFolder == null)
  92. {
  93. rootFolder = ConvertToOpenSim(CreateFolder(principalID, UUID.Zero, (int)AssetType.RootFolder, "My Inventory"));
  94. result = true;
  95. }
  96. XInventoryFolder[] sysFolders = GetSystemFolders(principalID);
  97. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Animation) return true; return false; }))
  98. CreateFolder(principalID, rootFolder.ID, (int)AssetType.Animation, "Animations");
  99. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Bodypart) return true; return false; }))
  100. CreateFolder(principalID, rootFolder.ID, (int)AssetType.Bodypart, "Body Parts");
  101. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.CallingCard) return true; return false; }))
  102. CreateFolder(principalID, rootFolder.ID, (int)AssetType.CallingCard, "Calling Cards");
  103. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Clothing) return true; return false; }))
  104. CreateFolder(principalID, rootFolder.ID, (int)AssetType.Clothing, "Clothing");
  105. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; }))
  106. CreateFolder(principalID, rootFolder.ID, (int)AssetType.Gesture, "Gestures");
  107. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Landmark) return true; return false; }))
  108. CreateFolder(principalID, rootFolder.ID, (int)AssetType.Landmark, "Landmarks");
  109. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.LostAndFoundFolder) return true; return false; }))
  110. CreateFolder(principalID, rootFolder.ID, (int)AssetType.LostAndFoundFolder, "Lost And Found");
  111. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Notecard) return true; return false; }))
  112. CreateFolder(principalID, rootFolder.ID, (int)AssetType.Notecard, "Notecards");
  113. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Object) return true; return false; }))
  114. CreateFolder(principalID, rootFolder.ID, (int)AssetType.Object, "Objects");
  115. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.SnapshotFolder) return true; return false; }))
  116. CreateFolder(principalID, rootFolder.ID, (int)AssetType.SnapshotFolder, "Photo Album");
  117. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.LSLText) return true; return false; }))
  118. CreateFolder(principalID, rootFolder.ID, (int)AssetType.LSLText, "Scripts");
  119. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Sound) return true; return false; }))
  120. CreateFolder(principalID, rootFolder.ID, (int)AssetType.Sound, "Sounds");
  121. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Texture) return true; return false; }))
  122. CreateFolder(principalID, rootFolder.ID, (int)AssetType.Texture, "Textures");
  123. if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.TrashFolder) return true; return false; }))
  124. CreateFolder(principalID, rootFolder.ID, (int)AssetType.TrashFolder, "Trash");
  125. return result;
  126. }
  127. protected XInventoryFolder CreateFolder(UUID principalID, UUID parentID, int type, string name)
  128. {
  129. XInventoryFolder newFolder = new XInventoryFolder();
  130. newFolder.folderName = name;
  131. newFolder.type = type;
  132. newFolder.version = 1;
  133. newFolder.folderID = UUID.Random();
  134. newFolder.agentID = principalID;
  135. newFolder.parentFolderID = parentID;
  136. m_Database.StoreFolder(newFolder);
  137. return newFolder;
  138. }
  139. protected virtual XInventoryFolder[] GetSystemFolders(UUID principalID)
  140. {
  141. // m_log.DebugFormat("[XINVENTORY SERVICE]: Getting system folders for {0}", principalID);
  142. XInventoryFolder[] allFolders = m_Database.GetFolders(
  143. new string[] { "agentID" },
  144. new string[] { principalID.ToString() });
  145. XInventoryFolder[] sysFolders = Array.FindAll(
  146. allFolders,
  147. delegate (XInventoryFolder f)
  148. {
  149. if (f.type > 0)
  150. return true;
  151. return false;
  152. });
  153. // m_log.DebugFormat(
  154. // "[XINVENTORY SERVICE]: Found {0} system folders for {1}", sysFolders.Length, principalID);
  155. return sysFolders;
  156. }
  157. public virtual List<InventoryFolderBase> GetInventorySkeleton(UUID principalID)
  158. {
  159. XInventoryFolder[] allFolders = m_Database.GetFolders(
  160. new string[] { "agentID" },
  161. new string[] { principalID.ToString() });
  162. if (allFolders.Length == 0)
  163. return null;
  164. List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
  165. foreach (XInventoryFolder x in allFolders)
  166. {
  167. //m_log.DebugFormat("[XINVENTORY SERVICE]: Adding folder {0} to skeleton", x.folderName);
  168. folders.Add(ConvertToOpenSim(x));
  169. }
  170. return folders;
  171. }
  172. public virtual InventoryFolderBase GetRootFolder(UUID principalID)
  173. {
  174. XInventoryFolder[] folders = m_Database.GetFolders(
  175. new string[] { "agentID", "parentFolderID"},
  176. new string[] { principalID.ToString(), UUID.Zero.ToString() });
  177. if (folders.Length == 0)
  178. return null;
  179. XInventoryFolder root = null;
  180. foreach (XInventoryFolder folder in folders)
  181. if (folder.folderName == "My Inventory")
  182. root = folder;
  183. if (folders == null) // oops
  184. root = folders[0];
  185. return ConvertToOpenSim(root);
  186. }
  187. public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
  188. {
  189. // m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
  190. XInventoryFolder[] folders = m_Database.GetFolders(
  191. new string[] { "agentID", "type"},
  192. new string[] { principalID.ToString(), ((int)type).ToString() });
  193. if (folders.Length == 0)
  194. {
  195. // m_log.WarnFormat("[XINVENTORY SERVICE]: Found no folder for type {0} for user {1}", type, principalID);
  196. return null;
  197. }
  198. // m_log.DebugFormat(
  199. // "[XINVENTORY SERVICE]: Found folder {0} {1} for type {2} for user {3}",
  200. // folders[0].folderName, folders[0].folderID, type, principalID);
  201. return ConvertToOpenSim(folders[0]);
  202. }
  203. public virtual InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
  204. {
  205. // This method doesn't receive a valud principal id from the
  206. // connector. So we disregard the principal and look
  207. // by ID.
  208. //
  209. //m_log.DebugFormat("[XINVENTORY SERVICE]: Fetch contents for folder {0}", folderID.ToString());
  210. InventoryCollection inventory = new InventoryCollection();
  211. inventory.UserID = principalID;
  212. inventory.Folders = new List<InventoryFolderBase>();
  213. inventory.Items = new List<InventoryItemBase>();
  214. XInventoryFolder[] folders = m_Database.GetFolders(
  215. new string[] { "parentFolderID"},
  216. new string[] { folderID.ToString() });
  217. foreach (XInventoryFolder x in folders)
  218. {
  219. //m_log.DebugFormat("[XINVENTORY]: Adding folder {0} to response", x.folderName);
  220. inventory.Folders.Add(ConvertToOpenSim(x));
  221. }
  222. XInventoryItem[] items = m_Database.GetItems(
  223. new string[] { "parentFolderID"},
  224. new string[] { folderID.ToString() });
  225. foreach (XInventoryItem i in items)
  226. {
  227. //m_log.DebugFormat("[XINVENTORY]: Adding item {0} to response", i.inventoryName);
  228. inventory.Items.Add(ConvertToOpenSim(i));
  229. }
  230. return inventory;
  231. }
  232. public virtual List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
  233. {
  234. // m_log.DebugFormat("[XINVENTORY]: Fetch items for folder {0}", folderID);
  235. // Since we probably don't get a valid principal here, either ...
  236. //
  237. List<InventoryItemBase> invItems = new List<InventoryItemBase>();
  238. XInventoryItem[] items = m_Database.GetItems(
  239. new string[] { "parentFolderID" },
  240. new string[] { folderID.ToString() });
  241. foreach (XInventoryItem i in items)
  242. invItems.Add(ConvertToOpenSim(i));
  243. return invItems;
  244. }
  245. public virtual bool AddFolder(InventoryFolderBase folder)
  246. {
  247. InventoryFolderBase check = GetFolder(folder);
  248. if (check != null)
  249. return false;
  250. XInventoryFolder xFolder = ConvertFromOpenSim(folder);
  251. return m_Database.StoreFolder(xFolder);
  252. }
  253. public virtual bool UpdateFolder(InventoryFolderBase folder)
  254. {
  255. XInventoryFolder xFolder = ConvertFromOpenSim(folder);
  256. InventoryFolderBase check = GetFolder(folder);
  257. if (check == null)
  258. return AddFolder(folder);
  259. if (check.Type != -1 || xFolder.type != -1)
  260. {
  261. if (xFolder.version > check.Version)
  262. return false;
  263. check.Version = (ushort)xFolder.version;
  264. xFolder = ConvertFromOpenSim(check);
  265. return m_Database.StoreFolder(xFolder);
  266. }
  267. if (xFolder.version < check.Version)
  268. xFolder.version = check.Version;
  269. xFolder.folderID = check.ID;
  270. return m_Database.StoreFolder(xFolder);
  271. }
  272. public virtual bool MoveFolder(InventoryFolderBase folder)
  273. {
  274. XInventoryFolder[] x = m_Database.GetFolders(
  275. new string[] { "folderID" },
  276. new string[] { folder.ID.ToString() });
  277. if (x.Length == 0)
  278. return false;
  279. x[0].parentFolderID = folder.ParentID;
  280. return m_Database.StoreFolder(x[0]);
  281. }
  282. // We don't check the principal's ID here
  283. //
  284. public virtual bool DeleteFolders(UUID principalID, List<UUID> folderIDs)
  285. {
  286. if (!m_AllowDelete)
  287. return false;
  288. // Ignore principal ID, it's bogus at connector level
  289. //
  290. foreach (UUID id in folderIDs)
  291. {
  292. if (!ParentIsTrash(id))
  293. continue;
  294. InventoryFolderBase f = new InventoryFolderBase();
  295. f.ID = id;
  296. PurgeFolder(f);
  297. m_Database.DeleteFolders("folderID", id.ToString());
  298. }
  299. return true;
  300. }
  301. public virtual bool PurgeFolder(InventoryFolderBase folder)
  302. {
  303. if (!m_AllowDelete)
  304. return false;
  305. if (!ParentIsTrash(folder.ID))
  306. return false;
  307. XInventoryFolder[] subFolders = m_Database.GetFolders(
  308. new string[] { "parentFolderID" },
  309. new string[] { folder.ID.ToString() });
  310. foreach (XInventoryFolder x in subFolders)
  311. {
  312. PurgeFolder(ConvertToOpenSim(x));
  313. m_Database.DeleteFolders("folderID", x.folderID.ToString());
  314. }
  315. m_Database.DeleteItems("parentFolderID", folder.ID.ToString());
  316. return true;
  317. }
  318. public virtual bool AddItem(InventoryItemBase item)
  319. {
  320. // m_log.DebugFormat(
  321. // "[XINVENTORY SERVICE]: Adding item {0} to folder {1} for {2}", item.ID, item.Folder, item.Owner);
  322. return m_Database.StoreItem(ConvertFromOpenSim(item));
  323. }
  324. public virtual bool UpdateItem(InventoryItemBase item)
  325. {
  326. return m_Database.StoreItem(ConvertFromOpenSim(item));
  327. }
  328. public virtual bool MoveItems(UUID principalID, List<InventoryItemBase> items)
  329. {
  330. // Principal is b0rked. *sigh*
  331. //
  332. foreach (InventoryItemBase i in items)
  333. {
  334. m_Database.MoveItem(i.ID.ToString(), i.Folder.ToString());
  335. }
  336. return true;
  337. }
  338. public virtual bool DeleteItems(UUID principalID, List<UUID> itemIDs)
  339. {
  340. if (!m_AllowDelete)
  341. return false;
  342. // Just use the ID... *facepalms*
  343. //
  344. foreach (UUID id in itemIDs)
  345. m_Database.DeleteItems("inventoryID", id.ToString());
  346. return true;
  347. }
  348. public virtual InventoryItemBase GetItem(InventoryItemBase item)
  349. {
  350. XInventoryItem[] items = m_Database.GetItems(
  351. new string[] { "inventoryID" },
  352. new string[] { item.ID.ToString() });
  353. if (items.Length == 0)
  354. return null;
  355. return ConvertToOpenSim(items[0]);
  356. }
  357. public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder)
  358. {
  359. XInventoryFolder[] folders = m_Database.GetFolders(
  360. new string[] { "folderID"},
  361. new string[] { folder.ID.ToString() });
  362. if (folders.Length == 0)
  363. return null;
  364. return ConvertToOpenSim(folders[0]);
  365. }
  366. public virtual List<InventoryItemBase> GetActiveGestures(UUID principalID)
  367. {
  368. XInventoryItem[] items = m_Database.GetActiveGestures(principalID);
  369. if (items.Length == 0)
  370. return new List<InventoryItemBase>();
  371. List<InventoryItemBase> ret = new List<InventoryItemBase>();
  372. foreach (XInventoryItem x in items)
  373. ret.Add(ConvertToOpenSim(x));
  374. return ret;
  375. }
  376. public virtual int GetAssetPermissions(UUID principalID, UUID assetID)
  377. {
  378. return m_Database.GetAssetPermissions(principalID, assetID);
  379. }
  380. // CM never needed those. Left unimplemented.
  381. // Obsolete in core
  382. //
  383. public InventoryCollection GetUserInventory(UUID userID)
  384. {
  385. return null;
  386. }
  387. public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
  388. {
  389. }
  390. // Unused.
  391. //
  392. public bool HasInventoryForUser(UUID userID)
  393. {
  394. return false;
  395. }
  396. // CM Helpers
  397. //
  398. protected InventoryFolderBase ConvertToOpenSim(XInventoryFolder folder)
  399. {
  400. InventoryFolderBase newFolder = new InventoryFolderBase();
  401. newFolder.ParentID = folder.parentFolderID;
  402. newFolder.Type = (short)folder.type;
  403. newFolder.Version = (ushort)folder.version;
  404. newFolder.Name = folder.folderName;
  405. newFolder.Owner = folder.agentID;
  406. newFolder.ID = folder.folderID;
  407. return newFolder;
  408. }
  409. protected XInventoryFolder ConvertFromOpenSim(InventoryFolderBase folder)
  410. {
  411. XInventoryFolder newFolder = new XInventoryFolder();
  412. newFolder.parentFolderID = folder.ParentID;
  413. newFolder.type = (int)folder.Type;
  414. newFolder.version = (int)folder.Version;
  415. newFolder.folderName = folder.Name;
  416. newFolder.agentID = folder.Owner;
  417. newFolder.folderID = folder.ID;
  418. return newFolder;
  419. }
  420. protected InventoryItemBase ConvertToOpenSim(XInventoryItem item)
  421. {
  422. InventoryItemBase newItem = new InventoryItemBase();
  423. newItem.AssetID = item.assetID;
  424. newItem.AssetType = item.assetType;
  425. newItem.Name = item.inventoryName;
  426. newItem.Owner = item.avatarID;
  427. newItem.ID = item.inventoryID;
  428. newItem.InvType = item.invType;
  429. newItem.Folder = item.parentFolderID;
  430. newItem.CreatorIdentification = item.creatorID;
  431. newItem.Description = item.inventoryDescription;
  432. newItem.NextPermissions = (uint)item.inventoryNextPermissions;
  433. newItem.CurrentPermissions = (uint)item.inventoryCurrentPermissions;
  434. newItem.BasePermissions = (uint)item.inventoryBasePermissions;
  435. newItem.EveryOnePermissions = (uint)item.inventoryEveryOnePermissions;
  436. newItem.GroupPermissions = (uint)item.inventoryGroupPermissions;
  437. newItem.GroupID = item.groupID;
  438. if (item.groupOwned == 0)
  439. newItem.GroupOwned = false;
  440. else
  441. newItem.GroupOwned = true;
  442. newItem.SalePrice = item.salePrice;
  443. newItem.SaleType = (byte)item.saleType;
  444. newItem.Flags = (uint)item.flags;
  445. newItem.CreationDate = item.creationDate;
  446. return newItem;
  447. }
  448. protected XInventoryItem ConvertFromOpenSim(InventoryItemBase item)
  449. {
  450. XInventoryItem newItem = new XInventoryItem();
  451. newItem.assetID = item.AssetID;
  452. newItem.assetType = item.AssetType;
  453. newItem.inventoryName = item.Name;
  454. newItem.avatarID = item.Owner;
  455. newItem.inventoryID = item.ID;
  456. newItem.invType = item.InvType;
  457. newItem.parentFolderID = item.Folder;
  458. newItem.creatorID = item.CreatorIdentification;
  459. newItem.inventoryDescription = item.Description;
  460. newItem.inventoryNextPermissions = (int)item.NextPermissions;
  461. newItem.inventoryCurrentPermissions = (int)item.CurrentPermissions;
  462. newItem.inventoryBasePermissions = (int)item.BasePermissions;
  463. newItem.inventoryEveryOnePermissions = (int)item.EveryOnePermissions;
  464. newItem.inventoryGroupPermissions = (int)item.GroupPermissions;
  465. newItem.groupID = item.GroupID;
  466. if (item.GroupOwned)
  467. newItem.groupOwned = 1;
  468. else
  469. newItem.groupOwned = 0;
  470. newItem.salePrice = item.SalePrice;
  471. newItem.saleType = (int)item.SaleType;
  472. newItem.flags = (int)item.Flags;
  473. newItem.creationDate = item.CreationDate;
  474. return newItem;
  475. }
  476. private bool ParentIsTrash(UUID folderID)
  477. {
  478. XInventoryFolder[] folder = m_Database.GetFolders(new string[] {"folderID"}, new string[] {folderID.ToString()});
  479. if (folder.Length < 1)
  480. return false;
  481. if (folder[0].type == (int)AssetType.TrashFolder)
  482. return true;
  483. UUID parentFolder = folder[0].parentFolderID;
  484. while (parentFolder != UUID.Zero)
  485. {
  486. XInventoryFolder[] parent = m_Database.GetFolders(new string[] {"folderID"}, new string[] {parentFolder.ToString()});
  487. if (parent.Length < 1)
  488. return false;
  489. if (parent[0].type == (int)AssetType.TrashFolder)
  490. return true;
  491. if (parent[0].type == (int)AssetType.RootFolder)
  492. return false;
  493. parentFolder = parent[0].parentFolderID;
  494. }
  495. return false;
  496. }
  497. }
  498. }