public bool RequestUpdateTaskInventoryItem( IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) { AssetXferUploader uploader = GetTransactionUploader(transactionID); if (uploader == null) { m_log.WarnFormat("[ASSET TRANSACTIONS]: Transaction {0} NOT FOUND (duplicate removed?) for inventory item update {1}", transactionID, item.Name); return false; } // This may complete now if upload complete, or later when the upload completes. uploader.TriggerWhenUploadComplete(delegate(AssetBase asset) { // This upload transaction is complete. XferUploaders.Remove(transactionID); if (asset == null) return; // UpdateItem() not called m_log.DebugFormat( "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}", item.Name, part.Name, transactionID); asset.Name = item.Name; asset.Description = item.Description; asset.Type = (sbyte)item.Type; try { Manager.MyScene.CommsManager.AssetCache.AddAsset(asset, AssetRequestInfo.GenericNetRequest()); if (part.Inventory.UpdateTaskInventoryItemAsset(part.UUID, item.ItemID, asset.FullID)) { part.GetProperties(remoteClient); } } catch (AssetServerException e) { remoteClient.SendAgentAlertMessage("Unable to upload asset. Please try again later.", false); m_log.ErrorFormat("[ASSET TRANSACTIONS] Unable to update task item due to asset server error {0}", e); } }); // We at least found an uploader with that transaction ID. return true; }
//private void CreateItemFromUpload(AssetBase asset, IClientAPI ourClient, UUID inventoryFolderID, uint nextPerms, uint wearableType) //{ // Manager.MyScene.CommsManager.AssetCache.AddAsset(asset); // CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( // ourClient.AgentId); // if (userInfo != null) // { // InventoryItemBase item = new InventoryItemBase(); // item.Owner = ourClient.AgentId; // item.Creator = ourClient.AgentId; // item.ID = UUID.Random(); // item.AssetID = asset.FullID; // item.Description = asset.Description; // item.Name = asset.Name; // item.AssetType = asset.Type; // item.InvType = asset.Type; // item.Folder = inventoryFolderID; // item.BasePermissions = 0x7fffffff; // item.CurrentPermissions = 0x7fffffff; // item.EveryOnePermissions = 0; // item.NextPermissions = nextPerms; // item.Flags = wearableType; // item.CreationDate = Util.UnixTimeSinceEpoch(); // userInfo.AddItem(item); // ourClient.SendInventoryItemCreateUpdate(item); // } // else // { // m_log.ErrorFormat( // "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation", // ourClient.AgentId); // } //} public void RequestUpdateTaskInventoryItem( IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) { if (XferUploaders.ContainsKey(transactionID)) { AssetBase asset = XferUploaders[transactionID].GetAssetData(); if (asset != null) { m_log.DebugFormat( "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}", item.Name, part.Name, transactionID); asset.Name = item.Name; asset.Description = item.Description; asset.Type = (sbyte)item.Type; item.AssetID = asset.FullID; Manager.MyScene.AssetService.Store(asset); if (part.Inventory.UpdateInventoryItem(item)) part.GetProperties(remoteClient); } } }
//private void CreateItemFromUpload(AssetBase asset, IClientAPI ourClient, UUID inventoryFolderID, uint nextPerms, uint wearableType) //{ // Manager.MyScene.CommsManager.AssetCache.AddAsset(asset); // CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( // ourClient.AgentId); // if (userInfo != null) // { // InventoryItemBase item = new InventoryItemBase(); // item.Owner = ourClient.AgentId; // item.Creator = ourClient.AgentId; // item.ID = UUID.Random(); // item.AssetID = asset.FullID; // item.Description = asset.Description; // item.Name = asset.Name; // item.AssetType = asset.Type; // item.InvType = asset.Type; // item.Folder = inventoryFolderID; // item.BasePermissions = 0x7fffffff; // item.CurrentPermissions = 0x7fffffff; // item.EveryOnePermissions = 0; // item.NextPermissions = nextPerms; // item.Flags = wearableType; // item.CreationDate = Util.UnixTimeSinceEpoch(); // userInfo.AddItem(item); // ourClient.SendInventoryItemCreateUpdate(item); // } // else // { // m_log.ErrorFormat( // "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation", // ourClient.AgentId); // } //} public void RequestUpdateTaskInventoryItem( IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) { if (XferUploaders.ContainsKey(transactionID)) { AssetBase asset = XferUploaders[transactionID].GetAssetData(); if (asset != null) { m_log.DebugFormat( "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}", item.Name, part.Name, transactionID); asset.Name = item.Name; asset.Description = item.Description; asset.Type = (sbyte)item.Type; item.AssetID = asset.FullID; IMonitorModule monitorModule = Manager.MyScene.RequestModuleInterface<IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor)monitorModule.GetMonitor(Manager.MyScene.RegionInfo.RegionID.ToString(), "Network Monitor"); networkMonitor.AddPendingUploads(-1); } Manager.MyScene.AssetService.Store(asset); if (part.Inventory.UpdateInventoryItem(item)) { if ((InventoryType)item.InvType == InventoryType.Notecard) remoteClient.SendAgentAlertMessage("Notecard saved", false); else if ((InventoryType)item.InvType == InventoryType.LSL) remoteClient.SendAgentAlertMessage("Script saved", false); else remoteClient.SendAgentAlertMessage("Item saved", false); part.GetProperties(remoteClient); } } } }