/// <summary> /// Return the xfer uploader for the given transaction. /// </summary> /// <remarks> /// If an uploader does not already exist for this transaction then it is created, otherwise the existing /// uploader is returned. /// </remarks> /// <param name="transactionID"></param> /// <returns>The asset xfer uploader</returns> public AssetXferUploader RequestXferUploader(UUID transactionID) { AssetXferUploader uploader; lock (XferUploaders) { if (!XferUploaders.ContainsKey(transactionID)) { uploader = new AssetXferUploader(this, m_Scene, transactionID, m_dumpAssetsToFile); // MainConsole.Instance.DebugFormat( // "[AGENT ASSETS TRANSACTIONS]: Adding asset xfer uploader {0} since it didn't previously exist", transactionID); XferUploaders.Add(transactionID, uploader); } else { uploader = XferUploaders[transactionID]; } } IMonitorModule monitorModule = m_Scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = monitorModule.GetMonitor <INetworkMonitor>(m_Scene); networkMonitor.AddPendingUploads(1); } return(uploader); }
protected void SendCompleteMessage(IClientAPI remoteClient) { remoteClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID); m_finished = true; if (m_createItem) { DoCreateItem(m_createItemCallback, remoteClient); } else if (m_storeLocal) { m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); } IMonitorModule monitorModule = m_userTransactions.Manager.MyScene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor)monitorModule.GetMonitor(m_userTransactions.Manager.MyScene.RegionInfo.RegionID.ToString(), "Network Monitor"); networkMonitor.AddPendingUploads(-1); } m_log.DebugFormat( "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}", m_asset.FullID, TransactionID); if (m_dumpAssetToFile) { DateTime now = DateTime.Now; string filename = String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, m_asset.Name, m_asset.Type); SaveAssetToFile(filename, m_asset.Data); } }
protected void SendCompleteMessage(IClientAPI remoteClient) { lock (_finishedLock) { m_finished = true; if (FinishedEvent != null) { FinishedEvent(); } if (m_createItem) { DoCreateItem(m_createItemCallback, remoteClient); } else if (m_storeLocal) { m_asset.ID = m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); } } remoteClient.SendAssetUploadCompleteMessage((sbyte)m_asset.Type, true, m_asset.ID); IMonitorModule monitorModule = m_userTransactions.Manager.MyScene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor) monitorModule.GetMonitor(m_userTransactions.Manager.MyScene.RegionInfo.RegionID.ToString(), MonitorModuleHelper.NetworkMonitor); networkMonitor.AddPendingUploads(-1); } MainConsole.Instance.DebugFormat( "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}", m_asset.ID, TransactionID); }
//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 // { // MainConsole.Instance.ErrorFormat( // "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation", // ourClient.AgentId); // } //} public void RequestUpdateTaskInventoryItem( IClientAPI remoteClient, ISceneChildEntity part, UUID transactionID, TaskInventoryItem item) { if (XferUploaders.ContainsKey(transactionID)) { AssetBase asset = XferUploaders[transactionID].GetAssetData(); if (asset != null) { MainConsole.Instance.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.ID; IMonitorModule monitorModule = Manager.MyScene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor) monitorModule.GetMonitor(Manager.MyScene.RegionInfo.RegionID.ToString(), MonitorModuleHelper.NetworkMonitor); networkMonitor.AddPendingUploads(-1); } asset.ID = Manager.MyScene.AssetService.Store(asset); item.AssetID = asset.ID; 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); } } } }
/// <summary> /// Handle asset transfer data packets received in response to the asset upload request in /// HandleUDPUploadRequest() /// </summary> /// <param name="remoteClient"></param> /// <param name="xferID"></param> /// <param name="packetID"></param> /// <param name="data"></param> public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) { //MainConsole.Instance.Debug("xferID: " + xferID + " packetID: " + packetID + " data!"); AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = monitorModule.GetMonitor <INetworkMonitor>(m_scene); networkMonitor.AddPendingUploads(1); } transactions.HandleXfer(remoteClient, xferID, packetID, data); }
/// <summary> /// Handle asset transfer data packets received in response to the asset upload request in /// HandleUDPUploadRequest() /// </summary> /// <param name="remoteClient"></param> /// <param name="xferID"></param> /// <param name="packetID"></param> /// <param name="data"></param> public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) { //m_log.Debug("xferID: " + xferID + " packetID: " + packetID + " data!"); AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor)monitorModule.GetMonitor(m_scene.RegionInfo.RegionID.ToString(), "Network Monitor"); networkMonitor.AddPendingUploads(1); } transactions.HandleXfer(remoteClient, xferID, packetID, data); }
private void DoCreateItem(uint callbackID, IClientAPI remoteClient) { m_asset.ID = m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); IMonitorModule monitorModule = m_userTransactions.Manager.MyScene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor) monitorModule.GetMonitor(m_userTransactions.Manager.MyScene.RegionInfo.RegionID.ToString(), MonitorModuleHelper.NetworkMonitor); networkMonitor.AddPendingUploads(-1); } InventoryItemBase item = new InventoryItemBase { Owner = remoteClient.AgentId, CreatorId = remoteClient.AgentId.ToString(), ID = UUID.Random(), AssetID = m_asset.ID, Description = m_description, Name = m_name, AssetType = type, InvType = invType, Folder = InventFolder, BasePermissions = 0x7fffffff, CurrentPermissions = 0x7fffffff, GroupPermissions = 0, EveryOnePermissions = 0, NextPermissions = nextPerm, Flags = wearableType, CreationDate = Util.UnixTimeSinceEpoch() }; ILLClientInventory inventoryModule = m_userTransactions.Manager.MyScene.RequestModuleInterface <ILLClientInventory>(); if (inventoryModule != null && inventoryModule.AddInventoryItem(item)) { remoteClient.SendInventoryItemCreateUpdate(item, callbackID); } else { remoteClient.SendAlertMessage("Unable to create inventory item"); } }
/// <summary> /// Update a task inventory item with data that has been received through a transaction. /// This is currently called when, for instance, a notecard in a prim is saved. The data is sent /// up through a single AssetUploadRequest. A subsequent UpdateTaskInventory then references the transaction /// and comes through this method. /// </summary> /// <param name="remoteClient"></param> /// <param name="part"></param> /// <param name="transactionID"></param> /// <param name="item"></param> public void HandleTaskItemUpdateFromTransaction( IClientAPI remoteClient, ISceneChildEntity part, UUID transactionID, TaskInventoryItem item) { // MainConsole.Instance.DebugFormat("[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}", item.Name); AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = monitorModule.GetMonitor <INetworkMonitor>(m_scene); networkMonitor.AddPendingUploads(1); } transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item); }
/// <summary> /// Request that a client (agent) begin an asset transfer. /// </summary> /// <param name = "remoteClient"></param> /// <param name = "assetID"></param> /// <param name = "transaction"></param> /// <param name = "type"></param> /// <param name = "data"></param> /// </param> /// <param name = "tempFile"></param> public void HandleUDPUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, byte[] data, bool storeLocal, bool tempFile) { // MainConsole.Instance.Debug("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile); if (((AssetType)type == AssetType.Texture || (AssetType)type == AssetType.Sound || (AssetType)type == AssetType.TextureTGA || (AssetType)type == AssetType.Animation) && tempFile == false) { IScene scene = remoteClient.Scene; IMoneyModule mm = scene.RequestModuleInterface <IMoneyModule>(); if (mm != null) { if (!mm.Charge(remoteClient, mm.UploadCharge)) { remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); return; } } } AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor) monitorModule.GetMonitor(m_scene.RegionInfo.RegionID.ToString(), MonitorModuleHelper.NetworkMonitor); networkMonitor.AddPendingUploads(1); } AssetXferUploader uploader = transactions.RequestXferUploader(transaction); if (uploader != null) { uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); } }
/// <summary> /// Update an inventory item with data that has been received through a transaction. /// /// This is called when clothing or body parts are updated (for instance, with new textures or /// colours). It may also be called in other situations. /// </summary> /// <param name="remoteClient"></param> /// <param name="transactionID"></param> /// <param name="item"></param> public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, InventoryItemBase item) { // m_log.DebugFormat( // "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", // item.Name); AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor)monitorModule.GetMonitor(m_scene.RegionInfo.RegionID.ToString(), "Network Monitor"); networkMonitor.AddPendingUploads(1); } transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item); }
/// <summary> /// Create an inventory item from data that has been received through a transaction. /// This is called when new clothing or body parts are created. It may also be called in other /// situations. /// </summary> /// <param name="remoteClient"></param> /// <param name="transactionID"></param> /// <param name="folderID"></param> /// <param name="callbackID"></param> /// <param name="description"></param> /// <param name="name"></param> /// <param name="invType"></param> /// <param name="type"></param> /// <param name="wearableType"></param> /// <param name="nextOwnerMask"></param> public void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) { // MainConsole.Instance.DebugFormat("[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = monitorModule.GetMonitor <INetworkMonitor>(m_scene); networkMonitor.AddPendingUploads(1); } transactions.RequestCreateInventoryItem( remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); }
public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, InventoryItemBase item) { if (XferUploaders.ContainsKey(transactionID)) { UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId); AssetBase asset = Manager.MyScene.AssetService.Get(assetID.ToString()); if (asset == null) { asset = GetTransactionAsset(transactionID); } if (asset != null && asset.ID == assetID) { // Assets never get updated, new ones get created asset.ID = UUID.Random(); asset.Name = item.Name; asset.Description = item.Description; asset.Type = (sbyte)item.AssetType; item.AssetID = asset.ID; asset.ID = Manager.MyScene.AssetService.Store(asset); item.AssetID = asset.ID; } IMonitorModule monitorModule = Manager.MyScene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor) monitorModule.GetMonitor(Manager.MyScene.RegionInfo.RegionID.ToString(), MonitorModuleHelper.NetworkMonitor); networkMonitor.AddPendingUploads(-1); } IInventoryService invService = Manager.MyScene.InventoryService; invService.UpdateItem(item); } }
private void UpdateInventoryItemWithAsset(InventoryItemBase item, UUID assetID, UUID transactionID) { AssetXferUploader uploader = XferUploaders[transactionID]; AssetBase asset = uploader.GetAssetData(); if (asset != null && asset.ID == assetID) { // Assets never get updated, new ones get created asset.ID = UUID.Random(); asset.Name = item.Name; asset.Description = item.Description; asset.Type = (sbyte)item.AssetType; item.AssetID = asset.ID; asset.ID = Manager.MyScene.AssetService.Store(asset); item.AssetID = asset.ID; XferUploaders.Remove(transactionID); } else { return; } IMonitorModule monitorModule = Manager.MyScene.RequestModuleInterface <IMonitorModule>(); if (monitorModule != null) { INetworkMonitor networkMonitor = (INetworkMonitor) monitorModule.GetMonitor(Manager.MyScene.RegionInfo.RegionID.ToString(), MonitorModuleHelper.NetworkMonitor); networkMonitor.AddPendingUploads(-1); } IInventoryService invService = Manager.MyScene.InventoryService; invService.UpdateItem(item); }