Scene.PacketHandlers.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System.Collections.Generic;
  28. using System.Threading;
  29. using OpenMetaverse;
  30. using OpenMetaverse.Packets;
  31. using OpenSim.Framework;
  32. using OpenSim.Framework.Communications;
  33. using OpenSim.Framework.Communications.Cache;
  34. namespace OpenSim.Region.Environment.Scenes
  35. {
  36. public partial class Scene
  37. {
  38. protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
  39. UUID fromID, bool fromAgent, bool broadcast)
  40. {
  41. OSChatMessage args = new OSChatMessage();
  42. args.Message = Utils.BytesToString(message);
  43. args.Channel = channel;
  44. args.Type = type;
  45. args.Position = fromPos;
  46. args.SenderUUID = fromID;
  47. args.Scene = this;
  48. if (fromAgent)
  49. {
  50. ScenePresence user = GetScenePresence(fromID);
  51. if (user != null)
  52. args.Sender = user.ControllingClient;
  53. }
  54. else
  55. {
  56. SceneObjectPart obj = GetSceneObjectPart(fromID);
  57. args.SenderObject = obj;
  58. }
  59. args.From = fromName;
  60. //args.
  61. if (broadcast)
  62. EventManager.TriggerOnChatBroadcast(this, args);
  63. else
  64. EventManager.TriggerOnChatFromWorld(this, args);
  65. }
  66. /// <summary>
  67. ///
  68. /// </summary>
  69. /// <param name="message"></param>
  70. /// <param name="type"></param>
  71. /// <param name="fromPos"></param>
  72. /// <param name="fromName"></param>
  73. /// <param name="fromAgentID"></param>
  74. public void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
  75. UUID fromID, bool fromAgent)
  76. {
  77. SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, false);
  78. }
  79. /// <summary>
  80. ///
  81. /// </summary>
  82. /// <param name="message"></param>
  83. /// <param name="type"></param>
  84. /// <param name="fromPos"></param>
  85. /// <param name="fromName"></param>
  86. /// <param name="fromAgentID"></param>
  87. public void SimChatBroadcast(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
  88. UUID fromID, bool fromAgent)
  89. {
  90. SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true);
  91. }
  92. /// <summary>
  93. /// Invoked when the client selects a prim.
  94. /// </summary>
  95. /// <param name="primLocalID"></param>
  96. /// <param name="remoteClient"></param>
  97. public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
  98. {
  99. List<EntityBase> EntityList = GetEntities();
  100. foreach (EntityBase ent in EntityList)
  101. {
  102. if (ent is SceneObjectGroup)
  103. {
  104. if (((SceneObjectGroup) ent).LocalId == primLocalID)
  105. {
  106. ((SceneObjectGroup) ent).GetProperties(remoteClient);
  107. ((SceneObjectGroup) ent).IsSelected = true;
  108. // A prim is only tainted if it's allowed to be edited by the person clicking it.
  109. if (Permissions.CanEditObject(((SceneObjectGroup)ent).UUID, remoteClient.AgentId)
  110. || Permissions.CanMoveObject(((SceneObjectGroup)ent).UUID, remoteClient.AgentId))
  111. {
  112. EventManager.TriggerParcelPrimCountTainted();
  113. }
  114. break;
  115. }
  116. else
  117. {
  118. // We also need to check the children of this prim as they
  119. // can be selected as well and send property information
  120. bool foundPrim = false;
  121. foreach (KeyValuePair<UUID, SceneObjectPart> child in ((SceneObjectGroup) ent).Children)
  122. {
  123. if (child.Value.LocalId == primLocalID)
  124. {
  125. child.Value.GetProperties(remoteClient);
  126. foundPrim = true;
  127. break;
  128. }
  129. }
  130. if (foundPrim) break;
  131. }
  132. }
  133. }
  134. }
  135. /// <summary>
  136. /// Handle the deselection of a prim from the client.
  137. /// </summary>
  138. /// <param name="primLocalID"></param>
  139. /// <param name="remoteClient"></param>
  140. public void DeselectPrim(uint primLocalID, IClientAPI remoteClient)
  141. {
  142. SceneObjectPart part = GetSceneObjectPart(primLocalID);
  143. if (part == null)
  144. return;
  145. // The prim is in the process of being deleted.
  146. if (null == part.ParentGroup.RootPart)
  147. return;
  148. // A deselect packet contains all the local prims being deselected. However, since selection is still
  149. // group based we only want the root prim to trigger a full update - otherwise on objects with many prims
  150. // we end up sending many duplicate ObjectUpdates
  151. if (part.ParentGroup.RootPart.LocalId != part.LocalId)
  152. return;
  153. bool isAttachment = false;
  154. // This is wrong, wrong, wrong. Selection should not be
  155. // handled by group, but by prim. Legacy cruft.
  156. // TODO: Make selection flagging per prim!
  157. //
  158. part.ParentGroup.IsSelected = false;
  159. if (part.ParentGroup.IsAttachment)
  160. isAttachment = true;
  161. else
  162. part.ParentGroup.ScheduleGroupForFullUpdate();
  163. // If it's not an attachment, and we are allowed to move it,
  164. // then we might have done so. If we moved across a parcel
  165. // boundary, we will need to recount prims on the parcels.
  166. // For attachments, that makes no sense.
  167. //
  168. if (!isAttachment)
  169. {
  170. if (Permissions.CanEditObject(
  171. part.UUID, remoteClient.AgentId)
  172. || Permissions.CanMoveObject(
  173. part.UUID, remoteClient.AgentId))
  174. EventManager.TriggerParcelPrimCountTainted();
  175. }
  176. }
  177. public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount,
  178. int transactiontype, string description)
  179. {
  180. EventManager.MoneyTransferArgs args = new EventManager.MoneyTransferArgs(source, destination, amount,
  181. transactiontype, description);
  182. EventManager.TriggerMoneyTransfer(this, args);
  183. }
  184. public virtual void ProcessParcelBuy(UUID agentId, UUID groupId, bool final, bool groupOwned,
  185. bool removeContribution, int parcelLocalID, int parcelArea, int parcelPrice, bool authenticated)
  186. {
  187. EventManager.LandBuyArgs args = new EventManager.LandBuyArgs(agentId, groupId, final, groupOwned,
  188. removeContribution, parcelLocalID, parcelArea,
  189. parcelPrice, authenticated);
  190. // First, allow all validators a stab at it
  191. m_eventManager.TriggerValidateLandBuy(this, args);
  192. // Then, check validation and transfer
  193. m_eventManager.TriggerLandBuy(this, args);
  194. }
  195. public virtual void ProcessObjectGrab(uint localID, Vector3 offsetPos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
  196. {
  197. List<EntityBase> EntityList = GetEntities();
  198. SurfaceTouchEventArgs surfaceArg = null;
  199. if (surfaceArgs != null && surfaceArgs.Count > 0)
  200. surfaceArg = surfaceArgs[0];
  201. foreach (EntityBase ent in EntityList)
  202. {
  203. if (ent is SceneObjectGroup)
  204. {
  205. SceneObjectGroup obj = ent as SceneObjectGroup;
  206. if (obj != null)
  207. {
  208. // Is this prim part of the group
  209. if (obj.HasChildPrim(localID))
  210. {
  211. // Currently only grab/touch for the single prim
  212. // the client handles rez correctly
  213. obj.ObjectGrabHandler(localID, offsetPos, remoteClient);
  214. SceneObjectPart part = obj.GetChildPart(localID);
  215. // If the touched prim handles touches, deliver it
  216. // If not, deliver to root prim
  217. if ((part.ScriptEvents & scriptEvents.touch_start) != 0)
  218. EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
  219. else
  220. EventManager.TriggerObjectGrab(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
  221. return;
  222. }
  223. }
  224. }
  225. }
  226. }
  227. public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient)
  228. {
  229. List<EntityBase> EntityList = GetEntities();
  230. foreach (EntityBase ent in EntityList)
  231. {
  232. if (ent is SceneObjectGroup)
  233. {
  234. SceneObjectGroup obj = ent as SceneObjectGroup;
  235. // Is this prim part of the group
  236. if (obj.HasChildPrim(localID))
  237. {
  238. SceneObjectPart part=obj.GetChildPart(localID);
  239. if (part != null)
  240. {
  241. // If the touched prim handles touches, deliver it
  242. // If not, deliver to root prim
  243. if ((part.ScriptEvents & scriptEvents.touch_end) != 0)
  244. EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient);
  245. else
  246. EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient);
  247. return;
  248. }
  249. return;
  250. }
  251. }
  252. }
  253. }
  254. public void ProcessAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query)
  255. {
  256. //EventManager.TriggerAvatarPickerRequest();
  257. List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>();
  258. AvatarResponses = m_sceneGridService.GenerateAgentPickerRequestResponse(RequestID, query);
  259. AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
  260. // TODO: don't create new blocks if recycling an old packet
  261. AvatarPickerReplyPacket.DataBlock[] searchData =
  262. new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count];
  263. AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
  264. agentData.AgentID = avatarID;
  265. agentData.QueryID = RequestID;
  266. replyPacket.AgentData = agentData;
  267. //byte[] bytes = new byte[AvatarResponses.Count*32];
  268. int i = 0;
  269. foreach (AvatarPickerAvatar item in AvatarResponses)
  270. {
  271. UUID translatedIDtem = item.AvatarID;
  272. searchData[i] = new AvatarPickerReplyPacket.DataBlock();
  273. searchData[i].AvatarID = translatedIDtem;
  274. searchData[i].FirstName = Utils.StringToBytes((string) item.firstName);
  275. searchData[i].LastName = Utils.StringToBytes((string) item.lastName);
  276. i++;
  277. }
  278. if (AvatarResponses.Count == 0)
  279. {
  280. searchData = new AvatarPickerReplyPacket.DataBlock[0];
  281. }
  282. replyPacket.Data = searchData;
  283. AvatarPickerReplyAgentDataArgs agent_data = new AvatarPickerReplyAgentDataArgs();
  284. agent_data.AgentID = replyPacket.AgentData.AgentID;
  285. agent_data.QueryID = replyPacket.AgentData.QueryID;
  286. List<AvatarPickerReplyDataArgs> data_args = new List<AvatarPickerReplyDataArgs>();
  287. for (i = 0; i < replyPacket.Data.Length; i++)
  288. {
  289. AvatarPickerReplyDataArgs data_arg = new AvatarPickerReplyDataArgs();
  290. data_arg.AvatarID = replyPacket.Data[i].AvatarID;
  291. data_arg.FirstName = replyPacket.Data[i].FirstName;
  292. data_arg.LastName = replyPacket.Data[i].LastName;
  293. data_args.Add(data_arg);
  294. }
  295. client.SendAvatarPickerReply(agent_data, data_args);
  296. }
  297. public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID,
  298. UUID itemID)
  299. {
  300. SceneObjectPart part=GetSceneObjectPart(objectID);
  301. if (part == null)
  302. return;
  303. if (Permissions.CanResetScript(objectID, itemID, remoteClient.AgentId))
  304. {
  305. EventManager.TriggerScriptReset(part.LocalId, itemID);
  306. }
  307. }
  308. /// <summary>
  309. /// Handle a fetch inventory request from the client
  310. /// </summary>
  311. /// <param name="remoteClient"></param>
  312. /// <param name="itemID"></param>
  313. /// <param name="ownerID"></param>
  314. public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID)
  315. {
  316. if (ownerID == CommsManager.UserProfileCacheService.LibraryRoot.Owner)
  317. {
  318. //Console.WriteLine("request info for library item");
  319. return;
  320. }
  321. CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
  322. if (null == userProfile)
  323. {
  324. m_log.ErrorFormat(
  325. "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
  326. remoteClient.Name, remoteClient.AgentId);
  327. return;
  328. }
  329. if (userProfile.HasReceivedInventory)
  330. {
  331. InventoryItemBase item = null;
  332. if (userProfile.RootFolder == null)
  333. m_log.ErrorFormat(
  334. "[AGENT INVENTORY]: User {0} {1} does not have a root folder.",
  335. remoteClient.Name, remoteClient.AgentId);
  336. else
  337. item = userProfile.RootFolder.FindItem(itemID);
  338. if (item != null)
  339. {
  340. remoteClient.SendInventoryItemDetails(ownerID, item);
  341. }
  342. }
  343. }
  344. /// <summary>
  345. /// Tell the client about the various child items and folders contained in the requested folder.
  346. /// </summary>
  347. /// <param name="remoteClient"></param>
  348. /// <param name="folderID"></param>
  349. /// <param name="ownerID"></param>
  350. /// <param name="fetchFolders"></param>
  351. /// <param name="fetchItems"></param>
  352. /// <param name="sortOrder"></param>
  353. public void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID,
  354. bool fetchFolders, bool fetchItems, int sortOrder)
  355. {
  356. // FIXME MAYBE: We're not handling sortOrder!
  357. // TODO: This code for looking in the folder for the library should be folded back into the
  358. // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
  359. // can be handled transparently).
  360. InventoryFolderImpl fold = null;
  361. if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null)
  362. {
  363. remoteClient.SendInventoryFolderDetails(
  364. fold.Owner, folderID, fold.RequestListOfItems(),
  365. fold.RequestListOfFolders(), fetchFolders, fetchItems);
  366. return;
  367. }
  368. CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
  369. if (null == userProfile)
  370. {
  371. m_log.ErrorFormat(
  372. "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
  373. remoteClient.Name, remoteClient.AgentId);
  374. return;
  375. }
  376. userProfile.SendInventoryDecendents(remoteClient, folderID, fetchFolders, fetchItems);
  377. }
  378. /// <summary>
  379. /// Handle the caps inventory descendents fetch.
  380. ///
  381. /// Since the folder structure is sent to the client on login, I believe we only need to handle items.
  382. /// </summary>
  383. /// <param name="agentID"></param>
  384. /// <param name="folderID"></param>
  385. /// <param name="ownerID"></param>
  386. /// <param name="fetchFolders"></param>
  387. /// <param name="fetchItems"></param>
  388. /// <param name="sortOrder"></param>
  389. /// <returns>null if the inventory look up failed</returns>
  390. public List<InventoryItemBase> HandleFetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID,
  391. bool fetchFolders, bool fetchItems, int sortOrder)
  392. {
  393. // m_log.DebugFormat(
  394. // "[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}",
  395. // fetchFolders, fetchItems, folderID, agentID);
  396. // FIXME MAYBE: We're not handling sortOrder!
  397. // TODO: This code for looking in the folder for the library should be folded back into the
  398. // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
  399. // can be handled transparently).
  400. InventoryFolderImpl fold;
  401. if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null)
  402. {
  403. return fold.RequestListOfItems();
  404. }
  405. CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(agentID);
  406. if (null == userProfile)
  407. {
  408. m_log.ErrorFormat("[AGENT INVENTORY]: Could not find user profile for {0}", agentID);
  409. return null;
  410. }
  411. // XXX: When a client crosses into a scene, their entire inventory is fetched
  412. // asynchronously. If the client makes a request before the inventory is received, we need
  413. // to give the inventory a chance to come in.
  414. //
  415. // This is a crude way of dealing with that by retrying the lookup. It's not quite as bad
  416. // in CAPS as doing this with the udp request, since here it won't hold up other packets.
  417. // In fact, here we'll be generous and try for longer.
  418. if (!userProfile.HasReceivedInventory)
  419. {
  420. int attempts = 0;
  421. while (attempts++ < 30)
  422. {
  423. m_log.DebugFormat(
  424. "[INVENTORY CACHE]: Poll number {0} for inventory items in folder {1} for user {2}",
  425. attempts, folderID, agentID);
  426. Thread.Sleep(2000);
  427. if (userProfile.HasReceivedInventory)
  428. {
  429. break;
  430. }
  431. }
  432. }
  433. if (userProfile.HasReceivedInventory)
  434. {
  435. if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null)
  436. {
  437. return fold.RequestListOfItems();
  438. }
  439. else
  440. {
  441. m_log.WarnFormat(
  442. "[AGENT INVENTORY]: Could not find folder {0} requested by user {1}",
  443. folderID, agentID);
  444. return null;
  445. }
  446. }
  447. else
  448. {
  449. m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", agentID);
  450. return null;
  451. }
  452. }
  453. /// <summary>
  454. /// Handle an inventory folder creation request from the client.
  455. /// </summary>
  456. /// <param name="remoteClient"></param>
  457. /// <param name="folderID"></param>
  458. /// <param name="folderType"></param>
  459. /// <param name="folderName"></param>
  460. /// <param name="parentID"></param>
  461. public void HandleCreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType,
  462. string folderName, UUID parentID)
  463. {
  464. CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
  465. if (null == userProfile)
  466. {
  467. m_log.ErrorFormat(
  468. "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
  469. remoteClient.Name, remoteClient.AgentId);
  470. return;
  471. }
  472. if (!userProfile.CreateFolder(folderName, folderID, folderType, parentID))
  473. {
  474. m_log.ErrorFormat(
  475. "[AGENT INVENTORY]: Failed to move create folder for user {0} {1}",
  476. remoteClient.Name, remoteClient.AgentId);
  477. }
  478. }
  479. /// <summary>
  480. /// Handle a client request to update the inventory folder
  481. /// </summary>
  482. ///
  483. /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE
  484. /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing,
  485. /// and needs to be changed.
  486. ///
  487. /// <param name="remoteClient"></param>
  488. /// <param name="folderID"></param>
  489. /// <param name="type"></param>
  490. /// <param name="name"></param>
  491. /// <param name="parentID"></param>
  492. public void HandleUpdateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort type, string name,
  493. UUID parentID)
  494. {
  495. // m_log.DebugFormat(
  496. // "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId);
  497. CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
  498. if (null == userProfile)
  499. {
  500. m_log.ErrorFormat(
  501. "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
  502. remoteClient.Name, remoteClient.AgentId);
  503. return;
  504. }
  505. if (!userProfile.UpdateFolder(name, folderID, type, parentID))
  506. {
  507. m_log.ErrorFormat(
  508. "[AGENT INVENTORY]: Failed to update folder for user {0} {1}",
  509. remoteClient.Name, remoteClient.AgentId);
  510. }
  511. }
  512. /// <summary>
  513. /// Handle an inventory folder move request from the client.
  514. /// </summary>
  515. /// <param name="remoteClient"></param>
  516. /// <param name="folderID"></param>
  517. /// <param name="parentID"></param>
  518. public void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID)
  519. {
  520. CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
  521. if (null == userProfile)
  522. {
  523. m_log.ErrorFormat(
  524. "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
  525. remoteClient.Name, remoteClient.AgentId);
  526. return;
  527. }
  528. if (!userProfile.MoveFolder(folderID, parentID))
  529. {
  530. m_log.ErrorFormat(
  531. "[AGENT INVENTORY]: Failed to move folder {0} to {1} for user {2}",
  532. folderID, parentID, remoteClient.Name);
  533. }
  534. }
  535. /// <summary>
  536. /// This should delete all the items and folders in the given directory.
  537. /// </summary>
  538. /// <param name="remoteClient"></param>
  539. /// <param name="folderID"></param>
  540. public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID)
  541. {
  542. CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
  543. if (null == userProfile)
  544. {
  545. m_log.ErrorFormat(
  546. "[AGENT INVENTORY]: Could not find user profile for {0} {1}",
  547. remoteClient.Name, remoteClient.AgentId);
  548. return;
  549. }
  550. if (!userProfile.PurgeFolder(folderID))
  551. {
  552. m_log.ErrorFormat(
  553. "[AGENT INVENTORY]: Failed to purge folder for user {0} {1}",
  554. remoteClient.Name, remoteClient.AgentId);
  555. }
  556. }
  557. }
  558. }