XInventoryInConnector.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  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.Reflection;
  29. using System.Text;
  30. using System.Xml;
  31. using System.Collections.Generic;
  32. using System.IO;
  33. using Nini.Config;
  34. using OpenSim.Framework;
  35. using OpenSim.Server.Base;
  36. using OpenSim.Services.Interfaces;
  37. using OpenSim.Framework.Servers.HttpServer;
  38. using OpenSim.Server.Handlers.Base;
  39. using log4net;
  40. using OpenMetaverse;
  41. namespace OpenSim.Server.Handlers.Asset
  42. {
  43. public class XInventoryInConnector : ServiceConnector
  44. {
  45. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  46. private IInventoryService m_InventoryService;
  47. private string m_ConfigName = "InventoryService";
  48. public XInventoryInConnector(IConfigSource config, IHttpServer server, string configName) :
  49. base(config, server, configName)
  50. {
  51. if (configName != String.Empty)
  52. m_ConfigName = configName;
  53. m_log.DebugFormat("[XInventoryInConnector]: Starting with config name {0}", m_ConfigName);
  54. IConfig serverConfig = config.Configs[m_ConfigName];
  55. if (serverConfig == null)
  56. throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
  57. string inventoryService = serverConfig.GetString("LocalServiceModule",
  58. String.Empty);
  59. if (inventoryService == String.Empty)
  60. throw new Exception("No InventoryService in config file");
  61. Object[] args = new Object[] { config };
  62. m_InventoryService =
  63. ServerUtils.LoadPlugin<IInventoryService>(inventoryService, args);
  64. server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService));
  65. }
  66. }
  67. public class XInventoryConnectorPostHandler : BaseStreamHandler
  68. {
  69. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  70. private IInventoryService m_InventoryService;
  71. public XInventoryConnectorPostHandler(IInventoryService service) :
  72. base("POST", "/xinventory")
  73. {
  74. m_InventoryService = service;
  75. }
  76. public override byte[] Handle(string path, Stream requestData,
  77. OSHttpRequest httpRequest, OSHttpResponse httpResponse)
  78. {
  79. StreamReader sr = new StreamReader(requestData);
  80. string body = sr.ReadToEnd();
  81. sr.Close();
  82. body = body.Trim();
  83. //m_log.DebugFormat("[XXX]: query String: {0}", body);
  84. try
  85. {
  86. Dictionary<string, object> request =
  87. ServerUtils.ParseQueryString(body);
  88. if (!request.ContainsKey("METHOD"))
  89. return FailureResult();
  90. string method = request["METHOD"].ToString();
  91. request.Remove("METHOD");
  92. switch (method)
  93. {
  94. case "CREATEUSERINVENTORY":
  95. return HandleCreateUserInventory(request);
  96. case "GETINVENTORYSKELETON":
  97. return HandleGetInventorySkeleton(request);
  98. case "GETROOTFOLDER":
  99. return HandleGetRootFolder(request);
  100. case "GETFOLDERFORTYPE":
  101. return HandleGetFolderForType(request);
  102. case "GETFOLDERCONTENT":
  103. return HandleGetFolderContent(request);
  104. case "GETFOLDERITEMS":
  105. return HandleGetFolderItems(request);
  106. case "ADDFOLDER":
  107. return HandleAddFolder(request);
  108. case "UPDATEFOLDER":
  109. return HandleUpdateFolder(request);
  110. case "MOVEFOLDER":
  111. return HandleMoveFolder(request);
  112. case "DELETEFOLDERS":
  113. return HandleDeleteFolders(request);
  114. case "PURGEFOLDER":
  115. return HandlePurgeFolder(request);
  116. case "ADDITEM":
  117. return HandleAddItem(request);
  118. case "UPDATEITEM":
  119. return HandleUpdateItem(request);
  120. case "MOVEITEMS":
  121. return HandleMoveItems(request);
  122. case "DELETEITEMS":
  123. return HandleDeleteItems(request);
  124. case "GETITEM":
  125. return HandleGetItem(request);
  126. case "GETFOLDER":
  127. return HandleGetFolder(request);
  128. case "GETACTIVEGESTURES":
  129. return HandleGetActiveGestures(request);
  130. case "GETASSETPERMISSIONS":
  131. return HandleGetAssetPermissions(request);
  132. }
  133. m_log.DebugFormat("[XINVENTORY HANDLER]: unknown method request: {0}", method);
  134. }
  135. catch (Exception e)
  136. {
  137. m_log.Debug("[XINVENTORY HANDLER]: Exception {0}", e);
  138. }
  139. return FailureResult();
  140. }
  141. private byte[] FailureResult()
  142. {
  143. return BoolResult(false);
  144. }
  145. private byte[] SuccessResult()
  146. {
  147. return BoolResult(true);
  148. }
  149. private byte[] BoolResult(bool value)
  150. {
  151. XmlDocument doc = new XmlDocument();
  152. XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
  153. "", "");
  154. doc.AppendChild(xmlnode);
  155. XmlElement rootElement = doc.CreateElement("", "ServerResponse",
  156. "");
  157. doc.AppendChild(rootElement);
  158. XmlElement result = doc.CreateElement("", "RESULT", "");
  159. result.AppendChild(doc.CreateTextNode(value.ToString()));
  160. rootElement.AppendChild(result);
  161. return DocToBytes(doc);
  162. }
  163. private byte[] DocToBytes(XmlDocument doc)
  164. {
  165. MemoryStream ms = new MemoryStream();
  166. XmlTextWriter xw = new XmlTextWriter(ms, null);
  167. xw.Formatting = Formatting.Indented;
  168. doc.WriteTo(xw);
  169. xw.Flush();
  170. return ms.ToArray();
  171. }
  172. byte[] HandleCreateUserInventory(Dictionary<string,object> request)
  173. {
  174. Dictionary<string,object> result = new Dictionary<string,object>();
  175. if (!request.ContainsKey("PRINCIPAL"))
  176. return FailureResult();
  177. if (m_InventoryService.CreateUserInventory(new UUID(request["PRINCIPAL"].ToString())))
  178. result["RESULT"] = "True";
  179. else
  180. result["RESULT"] = "False";
  181. string xmlString = ServerUtils.BuildXmlResponse(result);
  182. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  183. UTF8Encoding encoding = new UTF8Encoding();
  184. return encoding.GetBytes(xmlString);
  185. }
  186. byte[] HandleGetInventorySkeleton(Dictionary<string,object> request)
  187. {
  188. Dictionary<string,object> result = new Dictionary<string,object>();
  189. if (!request.ContainsKey("PRINCIPAL"))
  190. return FailureResult();
  191. List<InventoryFolderBase> folders = m_InventoryService.GetInventorySkeleton(new UUID(request["PRINCIPAL"].ToString()));
  192. Dictionary<string, object> sfolders = new Dictionary<string, object>();
  193. if (folders != null)
  194. {
  195. int i = 0;
  196. foreach (InventoryFolderBase f in folders)
  197. {
  198. sfolders["folder_" + i.ToString()] = EncodeFolder(f);
  199. i++;
  200. }
  201. }
  202. result["FOLDERS"] = sfolders;
  203. string xmlString = ServerUtils.BuildXmlResponse(result);
  204. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  205. UTF8Encoding encoding = new UTF8Encoding();
  206. return encoding.GetBytes(xmlString);
  207. }
  208. byte[] HandleGetRootFolder(Dictionary<string,object> request)
  209. {
  210. Dictionary<string,object> result = new Dictionary<string,object>();
  211. UUID principal = UUID.Zero;
  212. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  213. InventoryFolderBase rfolder = m_InventoryService.GetRootFolder(principal);
  214. if (rfolder != null)
  215. result["folder"] = EncodeFolder(rfolder);
  216. string xmlString = ServerUtils.BuildXmlResponse(result);
  217. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  218. UTF8Encoding encoding = new UTF8Encoding();
  219. return encoding.GetBytes(xmlString);
  220. }
  221. byte[] HandleGetFolderForType(Dictionary<string,object> request)
  222. {
  223. Dictionary<string,object> result = new Dictionary<string,object>();
  224. UUID principal = UUID.Zero;
  225. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  226. int type = 0;
  227. Int32.TryParse(request["TYPE"].ToString(), out type);
  228. InventoryFolderBase folder = m_InventoryService.GetFolderForType(principal, (AssetType)type);
  229. if (folder != null)
  230. result["folder"] = EncodeFolder(folder);
  231. string xmlString = ServerUtils.BuildXmlResponse(result);
  232. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  233. UTF8Encoding encoding = new UTF8Encoding();
  234. return encoding.GetBytes(xmlString);
  235. }
  236. byte[] HandleGetFolderContent(Dictionary<string,object> request)
  237. {
  238. Dictionary<string,object> result = new Dictionary<string,object>();
  239. UUID principal = UUID.Zero;
  240. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  241. UUID folderID = UUID.Zero;
  242. UUID.TryParse(request["FOLDER"].ToString(), out folderID);
  243. InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID);
  244. if (icoll != null)
  245. {
  246. Dictionary<string, object> folders = new Dictionary<string, object>();
  247. int i = 0;
  248. foreach (InventoryFolderBase f in icoll.Folders)
  249. {
  250. folders["folder_" + i.ToString()] = EncodeFolder(f);
  251. i++;
  252. }
  253. result["FOLDERS"] = folders;
  254. i = 0;
  255. Dictionary<string, object> items = new Dictionary<string, object>();
  256. foreach (InventoryItemBase it in icoll.Items)
  257. {
  258. items["item_" + i.ToString()] = EncodeItem(it);
  259. i++;
  260. }
  261. result["ITEMS"] = items;
  262. }
  263. string xmlString = ServerUtils.BuildXmlResponse(result);
  264. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  265. UTF8Encoding encoding = new UTF8Encoding();
  266. return encoding.GetBytes(xmlString);
  267. }
  268. byte[] HandleGetFolderItems(Dictionary<string,object> request)
  269. {
  270. Dictionary<string,object> result = new Dictionary<string,object>();
  271. UUID principal = UUID.Zero;
  272. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  273. UUID folderID = UUID.Zero;
  274. UUID.TryParse(request["FOLDER"].ToString(), out folderID);
  275. List<InventoryItemBase> items = m_InventoryService.GetFolderItems(principal, folderID);
  276. Dictionary<string, object> sitems = new Dictionary<string, object>();
  277. if (items != null)
  278. {
  279. int i = 0;
  280. foreach (InventoryItemBase item in items)
  281. {
  282. sitems["item_" + i.ToString()] = EncodeItem(item);
  283. i++;
  284. }
  285. }
  286. result["ITEMS"] = sitems;
  287. string xmlString = ServerUtils.BuildXmlResponse(result);
  288. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  289. UTF8Encoding encoding = new UTF8Encoding();
  290. return encoding.GetBytes(xmlString);
  291. }
  292. byte[] HandleAddFolder(Dictionary<string,object> request)
  293. {
  294. Dictionary<string,object> result = new Dictionary<string,object>();
  295. InventoryFolderBase folder = BuildFolder(request);
  296. if (m_InventoryService.AddFolder(folder))
  297. return SuccessResult();
  298. else
  299. return FailureResult();
  300. }
  301. byte[] HandleUpdateFolder(Dictionary<string,object> request)
  302. {
  303. Dictionary<string, object> result = new Dictionary<string, object>();
  304. InventoryFolderBase folder = BuildFolder(request);
  305. if (m_InventoryService.UpdateFolder(folder))
  306. return SuccessResult();
  307. else
  308. return FailureResult();
  309. }
  310. byte[] HandleMoveFolder(Dictionary<string,object> request)
  311. {
  312. Dictionary<string, object> result = new Dictionary<string, object>();
  313. UUID parentID = UUID.Zero;
  314. UUID.TryParse(request["ParentID"].ToString(), out parentID);
  315. UUID folderID = UUID.Zero;
  316. UUID.TryParse(request["ID"].ToString(), out folderID);
  317. UUID principal = UUID.Zero;
  318. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  319. InventoryFolderBase folder = new InventoryFolderBase(folderID, "", principal, parentID);
  320. if (m_InventoryService.MoveFolder(folder))
  321. return SuccessResult();
  322. else
  323. return FailureResult();
  324. }
  325. byte[] HandleDeleteFolders(Dictionary<string,object> request)
  326. {
  327. Dictionary<string,object> result = new Dictionary<string,object>();
  328. UUID principal = UUID.Zero;
  329. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  330. List<string> slist = (List<string>)request["FOLDERS"];
  331. List<UUID> uuids = new List<UUID>();
  332. foreach (string s in slist)
  333. {
  334. UUID u = UUID.Zero;
  335. if (UUID.TryParse(s, out u))
  336. uuids.Add(u);
  337. }
  338. if (m_InventoryService.DeleteFolders(principal, uuids))
  339. return SuccessResult();
  340. else
  341. return
  342. FailureResult();
  343. }
  344. byte[] HandlePurgeFolder(Dictionary<string,object> request)
  345. {
  346. Dictionary<string,object> result = new Dictionary<string,object>();
  347. UUID folderID = UUID.Zero;
  348. UUID.TryParse(request["ID"].ToString(), out folderID);
  349. InventoryFolderBase folder = new InventoryFolderBase(folderID);
  350. if (m_InventoryService.PurgeFolder(folder))
  351. return SuccessResult();
  352. else
  353. return FailureResult();
  354. }
  355. byte[] HandleAddItem(Dictionary<string,object> request)
  356. {
  357. Dictionary<string, object> result = new Dictionary<string, object>();
  358. InventoryItemBase item = BuildItem(request);
  359. if (m_InventoryService.AddItem(item))
  360. return SuccessResult();
  361. else
  362. return FailureResult();
  363. }
  364. byte[] HandleUpdateItem(Dictionary<string,object> request)
  365. {
  366. Dictionary<string, object> result = new Dictionary<string, object>();
  367. InventoryItemBase item = BuildItem(request);
  368. if (m_InventoryService.UpdateItem(item))
  369. return SuccessResult();
  370. else
  371. return FailureResult();
  372. }
  373. byte[] HandleMoveItems(Dictionary<string,object> request)
  374. {
  375. Dictionary<string,object> result = new Dictionary<string,object>();
  376. List<string> idlist = (List<string>)request["IDLIST"];
  377. List<string> destlist = (List<string>)request["DESTLIST"];
  378. UUID principal = UUID.Zero;
  379. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  380. List<InventoryItemBase> items = new List<InventoryItemBase>();
  381. int n = 0;
  382. try
  383. {
  384. foreach (string s in idlist)
  385. {
  386. UUID u = UUID.Zero;
  387. if (UUID.TryParse(s, out u))
  388. {
  389. UUID fid = UUID.Zero;
  390. if (UUID.TryParse(destlist[n++], out fid))
  391. {
  392. InventoryItemBase item = new InventoryItemBase(u, principal);
  393. item.Folder = fid;
  394. items.Add(item);
  395. }
  396. }
  397. }
  398. }
  399. catch (Exception e)
  400. {
  401. m_log.DebugFormat("[XINVENTORY IN CONNECTOR]: Exception in HandleMoveItems: {0}", e.Message);
  402. return FailureResult();
  403. }
  404. if (m_InventoryService.MoveItems(principal, items))
  405. return SuccessResult();
  406. else
  407. return FailureResult();
  408. }
  409. byte[] HandleDeleteItems(Dictionary<string,object> request)
  410. {
  411. Dictionary<string, object> result = new Dictionary<string, object>();
  412. UUID principal = UUID.Zero;
  413. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  414. List<string> slist = (List<string>)request["ITEMS"];
  415. List<UUID> uuids = new List<UUID>();
  416. foreach (string s in slist)
  417. {
  418. UUID u = UUID.Zero;
  419. if (UUID.TryParse(s, out u))
  420. uuids.Add(u);
  421. }
  422. if (m_InventoryService.DeleteItems(principal, uuids))
  423. return SuccessResult();
  424. else
  425. return
  426. FailureResult();
  427. }
  428. byte[] HandleGetItem(Dictionary<string,object> request)
  429. {
  430. Dictionary<string,object> result = new Dictionary<string,object>();
  431. UUID id = UUID.Zero;
  432. UUID.TryParse(request["ID"].ToString(), out id);
  433. InventoryItemBase item = new InventoryItemBase(id);
  434. item = m_InventoryService.GetItem(item);
  435. if (item != null)
  436. result["item"] = EncodeItem(item);
  437. string xmlString = ServerUtils.BuildXmlResponse(result);
  438. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  439. UTF8Encoding encoding = new UTF8Encoding();
  440. return encoding.GetBytes(xmlString);
  441. }
  442. byte[] HandleGetFolder(Dictionary<string,object> request)
  443. {
  444. Dictionary<string, object> result = new Dictionary<string, object>();
  445. UUID id = UUID.Zero;
  446. UUID.TryParse(request["ID"].ToString(), out id);
  447. InventoryFolderBase folder = new InventoryFolderBase(id);
  448. folder = m_InventoryService.GetFolder(folder);
  449. if (folder != null)
  450. result["folder"] = EncodeFolder(folder);
  451. string xmlString = ServerUtils.BuildXmlResponse(result);
  452. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  453. UTF8Encoding encoding = new UTF8Encoding();
  454. return encoding.GetBytes(xmlString);
  455. }
  456. byte[] HandleGetActiveGestures(Dictionary<string,object> request)
  457. {
  458. Dictionary<string,object> result = new Dictionary<string,object>();
  459. UUID principal = UUID.Zero;
  460. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  461. List<InventoryItemBase> gestures = m_InventoryService.GetActiveGestures(principal);
  462. Dictionary<string, object> items = new Dictionary<string, object>();
  463. if (gestures != null)
  464. {
  465. int i = 0;
  466. foreach (InventoryItemBase item in gestures)
  467. {
  468. items["item_" + i.ToString()] = EncodeItem(item);
  469. i++;
  470. }
  471. }
  472. result["ITEMS"] = items;
  473. string xmlString = ServerUtils.BuildXmlResponse(result);
  474. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  475. UTF8Encoding encoding = new UTF8Encoding();
  476. return encoding.GetBytes(xmlString);
  477. }
  478. byte[] HandleGetAssetPermissions(Dictionary<string,object> request)
  479. {
  480. Dictionary<string,object> result = new Dictionary<string,object>();
  481. UUID principal = UUID.Zero;
  482. UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
  483. UUID assetID = UUID.Zero;
  484. UUID.TryParse(request["ASSET"].ToString(), out assetID);
  485. int perms = m_InventoryService.GetAssetPermissions(principal, assetID);
  486. result["RESULT"] = perms.ToString();
  487. string xmlString = ServerUtils.BuildXmlResponse(result);
  488. //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
  489. UTF8Encoding encoding = new UTF8Encoding();
  490. return encoding.GetBytes(xmlString);
  491. }
  492. private Dictionary<string, object> EncodeFolder(InventoryFolderBase f)
  493. {
  494. Dictionary<string, object> ret = new Dictionary<string, object>();
  495. ret["ParentID"] = f.ParentID.ToString();
  496. ret["Type"] = f.Type.ToString();
  497. ret["Version"] = f.Version.ToString();
  498. ret["Name"] = f.Name;
  499. ret["Owner"] = f.Owner.ToString();
  500. ret["ID"] = f.ID.ToString();
  501. return ret;
  502. }
  503. private Dictionary<string, object> EncodeItem(InventoryItemBase item)
  504. {
  505. Dictionary<string, object> ret = new Dictionary<string, object>();
  506. ret["AssetID"] = item.AssetID.ToString();
  507. ret["AssetType"] = item.AssetType.ToString();
  508. ret["BasePermissions"] = item.BasePermissions.ToString();
  509. ret["CreationDate"] = item.CreationDate.ToString();
  510. ret["CreatorId"] = item.CreatorId.ToString();
  511. ret["CurrentPermissions"] = item.CurrentPermissions.ToString();
  512. ret["Description"] = item.Description.ToString();
  513. ret["EveryOnePermissions"] = item.EveryOnePermissions.ToString();
  514. ret["Flags"] = item.Flags.ToString();
  515. ret["Folder"] = item.Folder.ToString();
  516. ret["GroupID"] = item.GroupID.ToString();
  517. ret["GroupOwned"] = item.GroupOwned.ToString();
  518. ret["GroupPermissions"] = item.GroupPermissions.ToString();
  519. ret["ID"] = item.ID.ToString();
  520. ret["InvType"] = item.InvType.ToString();
  521. ret["Name"] = item.Name.ToString();
  522. ret["NextPermissions"] = item.NextPermissions.ToString();
  523. ret["Owner"] = item.Owner.ToString();
  524. ret["SalePrice"] = item.SalePrice.ToString();
  525. ret["SaleType"] = item.SaleType.ToString();
  526. return ret;
  527. }
  528. private InventoryFolderBase BuildFolder(Dictionary<string,object> data)
  529. {
  530. InventoryFolderBase folder = new InventoryFolderBase();
  531. folder.ParentID = new UUID(data["ParentID"].ToString());
  532. folder.Type = short.Parse(data["Type"].ToString());
  533. folder.Version = ushort.Parse(data["Version"].ToString());
  534. folder.Name = data["Name"].ToString();
  535. folder.Owner = new UUID(data["Owner"].ToString());
  536. folder.ID = new UUID(data["ID"].ToString());
  537. return folder;
  538. }
  539. private InventoryItemBase BuildItem(Dictionary<string,object> data)
  540. {
  541. InventoryItemBase item = new InventoryItemBase();
  542. item.AssetID = new UUID(data["AssetID"].ToString());
  543. item.AssetType = int.Parse(data["AssetType"].ToString());
  544. item.Name = data["Name"].ToString();
  545. item.Owner = new UUID(data["Owner"].ToString());
  546. item.ID = new UUID(data["ID"].ToString());
  547. item.InvType = int.Parse(data["InvType"].ToString());
  548. item.Folder = new UUID(data["Folder"].ToString());
  549. item.CreatorId = data["CreatorId"].ToString();
  550. item.Description = data["Description"].ToString();
  551. item.NextPermissions = uint.Parse(data["NextPermissions"].ToString());
  552. item.CurrentPermissions = uint.Parse(data["CurrentPermissions"].ToString());
  553. item.BasePermissions = uint.Parse(data["BasePermissions"].ToString());
  554. item.EveryOnePermissions = uint.Parse(data["EveryOnePermissions"].ToString());
  555. item.GroupPermissions = uint.Parse(data["GroupPermissions"].ToString());
  556. item.GroupID = new UUID(data["GroupID"].ToString());
  557. item.GroupOwned = bool.Parse(data["GroupOwned"].ToString());
  558. item.SalePrice = int.Parse(data["SalePrice"].ToString());
  559. item.SaleType = byte.Parse(data["SaleType"].ToString());
  560. item.Flags = uint.Parse(data["Flags"].ToString());
  561. item.CreationDate = int.Parse(data["CreationDate"].ToString());
  562. return item;
  563. }
  564. }
  565. }