/// <summary> /// Add a scene object as a new attachment in the user inventory. /// </summary> /// <param name="remoteClient"></param> /// <param name="grp"></param> /// <returns>The user inventory item created that holds the attachment.</returns> private InventoryItemBase AddSceneObjectAsNewAttachmentInInv(IScenePresence sp, SceneObjectGroup grp) { if (m_invAccessModule == null) { return(null); } // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2}", // grp.Name, grp.LocalId, remoteClient.Name); InventoryItemBase newItem = m_invAccessModule.CopyToInventory( DeRezAction.TakeCopy, m_scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object).ID, new List <SceneObjectGroup> { grp }, sp.ControllingClient, true)[0]; // sets itemID so client can show item as 'attached' in inventory grp.FromItemID = newItem.ID; return(newItem); }
/// <summary> /// Move the next object in the queue to inventory. Then delete it properly from the scene. /// </summary> /// <returns></returns> public bool InventoryDeQueueAndDelete() { DeleteToInventoryHolder x = null; try { lock (m_inventoryDeletes) { int left = m_inventoryDeletes.Count; if (left > 0) { x = m_inventoryDeletes.Dequeue(); // m_log.DebugFormat( // "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.", // left, x.action, x.objectGroups.Count); try { IInventoryAccessModule invAccess = m_scene.RequestModuleInterface <IInventoryAccessModule>(); if (invAccess != null) { invAccess.CopyToInventory(x.action, x.folderID, x.objectGroups, x.remoteClient, false); } if (x.permissionToDelete) { foreach (SceneObjectGroup g in x.objectGroups) { m_scene.DeleteSceneObject(g, true); } } } catch (Exception e) { m_log.ErrorFormat( "[ASYNC DELETER]: Exception background sending object: {0}{1}", e.Message, e.StackTrace); } return(true); } } } catch (Exception e) { // We can't put the object group details in here since the root part may have disappeared (which is where these sit). // FIXME: This needs to be fixed. m_log.ErrorFormat( "[ASYNC DELETER]: Queued sending of scene object to agent {0} {1} failed: {2} {3}", (x != null ? x.remoteClient.Name : "unavailable"), (x != null ? x.remoteClient.AgentId.ToString() : "unavailable"), e.Message, e.StackTrace); } // m_log.Debug("[ASYNC DELETER]: No objects left in inventory send queue."); return(false); }
/// <summary> /// Move the next object in the queue to inventory. Then delete it properly from the scene. /// </summary> /// <returns></returns> public void InventoryDeQueueAndDelete() { lock (m_threadLock) { IInventoryAccessModule invAccess = m_scene.RequestModuleInterface <IInventoryAccessModule>(); if (invAccess == null) { return; } int count = 0; while (m_inventoryDeletes.TryDequeue(out DeleteToInventoryHolder x)) { // m_log.DebugFormat( // "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.", // left, x.action, x.objectGroups.Count); try { invAccess.CopyToInventory(x.action, x.folderID, x.objectGroups, x.remoteClient, false); if (x.permissionToDelete) { foreach (SceneObjectGroup g in x.objectGroups) { m_scene.DeleteSceneObject(g, true); } } count += x.objectGroups.Count; if (count > 256) { Thread.Sleep(50); // throttle count = 0; } } catch // catch (Exception e) { //m_log.ErrorFormat( // "[ASYNC OBJECT DELETER]: Exception background sending object: {0}{1}", e.Message, e.StackTrace); } } // m_log.Debug("[ASYNC DELETER]: No objects left in inventory send queue."); m_running = false; } }