/// <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)
        {
            //m_log.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)
            {
                Scene        scene = (Scene)remoteClient.Scene;
                IMoneyModule mm    = scene.RequestModuleInterface <IMoneyModule>();

                if (mm != null)
                {
                    if (!mm.UploadCovered(remoteClient))
                    {
                        remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
                        return;
                    }
                }
            }

            //m_log.Debug("asset upload of " + assetID);
            AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);

            AssetXferUploader uploader = transactions.RequestXferUploader(transaction);

            if (uploader != null)
            {
                uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the collection of asset transactions for the given user.
        /// If one does not already exist, it is created.
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        private AgentAssetTransactions GetUserTransactions(UUID userID)
        {
            m_RwLock.AcquireReaderLock(-1);
            try
            {
                if (!AgentTransactions.ContainsKey(userID))
                {
                    AgentAssetTransactions transactions =
                        new AgentAssetTransactions(userID, m_Scene,
                                                   m_dumpAssetsToFile);

                    LockCookie lc = m_RwLock.UpgradeToWriterLock(-1);
                    try
                    {
                        AgentTransactions.Add(userID, transactions);
                    }
                    finally
                    {
                        m_RwLock.DowngradeFromWriterLock(ref lc);
                    }
                }

                return(AgentTransactions[userID]);
            }
            finally
            {
                m_RwLock.ReleaseReaderLock();
            }
        }
        /// <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);

            transactions.HandleXfer(xferID, packetID, data);
        }
Ejemplo n.º 4
0
 public AssetXferUploader(AgentAssetTransactions transactions, Scene scene, UUID assetID, bool dumpAssetToFile)
 {
     m_transactions = transactions;
     m_Scene = scene;
     m_asset = new AssetBase() { FullID = assetID };
     m_dumpAssetToFile = dumpAssetToFile;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// AssetXferUploader constructor
        /// </summary>
        /// <param name='transactions'>/param>
        /// <param name='scene'></param>
        /// <param name='transactionID'></param>
        /// <param name='dumpAssetToFile'>
        /// If true then when the asset is uploaded it is dumped to a file with the format
        /// 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);
        /// for debugging purposes.
        /// </param>
        public AssetXferUploader(
            AgentAssetTransactions transactions, Scene scene, UUID transactionID, bool dumpAssetToFile)
        {
            m_asset = new AssetBase();

            m_transactions    = transactions;
            m_transactionID   = transactionID;
            m_Scene           = scene;
            m_dumpAssetToFile = dumpAssetToFile;
        }
        /// <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 bool HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID,
                                                    InventoryItemBase item)
        {
            m_log.DebugFormat(
                "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0} transaction {1}",
                item.Name, transactionID);

            AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);

            return(transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Update an inventory item with data that has been received through a
        /// transaction.
        /// </summary>
        /// <remarks>
        /// 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.
        /// </remarks>
        /// <param name="remoteClient"></param>
        /// <param name="transactionID"></param>
        /// <param name="item"></param>
        public void HandleItemUpdateFromTransaction(IClientAPI remoteClient,
                                                    UUID transactionID, InventoryItemBase item)
        {
//            m_log.DebugFormat(
//                "[ASSET TRANSACTION MODULE]: Called HandleItemUpdateFromTransaction with item {0}",
//                item.Name);

            AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);

            transactions.RequestUpdateInventoryItem(remoteClient, transactionID, 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="transactionID"></param>
        /// <param name="item"></param>
        public void HandleTaskItemUpdateFromTransaction(
            IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
        {
            //            m_log.DebugFormat(
            //                "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}",
            //                item.Name);

            AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);

            transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item);
        }
Ejemplo n.º 9
0
        /// <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, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
        {
//            m_log.DebugFormat(
//                "[ASSET TRANSACTION MODULE]: Called HandleTaskItemUpdateFromTransaction with item {0} in {1} for {2} in {3}",
//                item.Name, part.Name, remoteClient.Name, m_Scene.RegionInfo.RegionName);

            AgentAssetTransactions transactions =
                GetUserTransactions(remoteClient.AgentId);

            transactions.RequestUpdateTaskInventoryItem(remoteClient, part,
                                                        transactionID, item);
        }
        /// <summary>
        /// Get the collection of asset transactions for the given user.  If one does not already exist, it
        /// is created.
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        private AgentAssetTransactions GetUserTransactions(UUID userID)
        {
            lock (AgentTransactions)
            {
                if (!AgentTransactions.ContainsKey(userID))
                {
                    AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
                    AgentTransactions.Add(userID, transactions);
                }

                return(AgentTransactions[userID]);
            }
        }
        /// <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)
        {
            //            m_log.DebugFormat(
            //                "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);

            AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);

            transactions.RequestCreateInventoryItem(
                remoteClient, transactionID, folderID, callbackID, description,
                name, invType, type, wearableType, nextOwnerMask);
        }
Ejemplo n.º 12
0
        /// <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);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Request that a client (agent) begin an asset transfer.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="assetID"></param>
        /// <param name="transactionID"></param>
        /// <param name="type"></param>
        /// <param name="data"></param></param>
        /// <param name="tempFile"></param>
        public void HandleUDPUploadRequest(IClientAPI remoteClient,
                                           UUID assetID, UUID transactionID, sbyte type, byte[] data,
                                           bool storeLocal, bool tempFile)
        {
//            m_log.DebugFormat(
//                "[ASSET TRANSACTION MODULE]: HandleUDPUploadRequest - assetID: {0}, transaction {1}, type {2}, storeLocal {3}, tempFile {4}, data.Length {5}",
//                assetID, transactionID, type, storeLocal, tempFile, data.Length);

            if (((AssetType)type == AssetType.Texture ||
                 (AssetType)type == AssetType.Sound ||
                 (AssetType)type == AssetType.TextureTGA ||
                 (AssetType)type == AssetType.Animation) &&
                tempFile == false)
            {
                ScenePresence avatar = null;
                Scene         scene  = (Scene)remoteClient.Scene;
                scene.TryGetScenePresence(remoteClient.AgentId, out avatar);

                // check user level
                if (avatar != null)
                {
                    if (avatar.UserLevel < m_levelUpload)
                    {
                        remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false);
                        return;
                    }
                }

                // check funds
                IMoneyModule mm = scene.RequestModuleInterface <IMoneyModule>();

                if (mm != null)
                {
                    if (!mm.UploadCovered(remoteClient.AgentId, mm.UploadCharge))
                    {
                        remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
                        return;
                    }
                }
            }

            AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
            AssetXferUploader      uploader     = transactions.RequestXferUploader(transactionID);

            uploader.StartUpload(remoteClient, assetID, transactionID, type, data, storeLocal, tempFile);
        }
Ejemplo n.º 14
0
        /// <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)
        {
//            m_log.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)
            {
                ScenePresence avatar = null;
                Scene         scene  = (Scene)remoteClient.Scene;
                scene.TryGetScenePresence(remoteClient.AgentId, out avatar);

                // check user level
                if (avatar != null)
                {
                    if (avatar.UserLevel < m_levelUpload)
                    {
                        remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false);
                        return;
                    }
                }

                // check funds
                IMoneyModule mm = scene.RequestModuleInterface <IMoneyModule>();

                if (mm != null)
                {
                    if (!mm.UploadCovered(remoteClient.AgentId, mm.UploadCharge))
                    {
                        remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
                        return;
                    }
                }
            }

            AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
            AssetXferUploader      uploader     = transactions.RequestXferUploader(transaction);

            uploader.StartUpload(remoteClient, assetID, transaction, type, data, storeLocal, tempFile);
        }
Ejemplo n.º 15
0
        /// <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="transactionID"></param>
        /// <param name="item"></param>
        public void HandleTaskItemUpdateFromTransaction(
            IClientAPI remoteClient, ISceneChildEntity part, UUID transactionID, TaskInventoryItem item)
        {
            //            m_log.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 = (INetworkMonitor)monitorModule.GetMonitor(m_scene.RegionInfo.RegionID.ToString(), "Network Monitor");
                networkMonitor.AddPendingUploads(1);
            }

            transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item);
        }
Ejemplo n.º 16
0
        /// <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)
        {
            //            m_log.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 = (INetworkMonitor)monitorModule.GetMonitor(m_scene.RegionInfo.RegionID.ToString(), "Network Monitor");
                networkMonitor.AddPendingUploads(1);
            }

            transactions.RequestCreateInventoryItem(
                remoteClient, transactionID, folderID, callbackID, description,
                name, invType, type, wearableType, nextOwnerMask);
        }
        /// <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)
        {
//            m_log.Debug("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile);
            Scene        scene = (Scene)remoteClient.Scene;
            IMoneyModule mm    = scene.RequestModuleInterface <IMoneyModule>();

            if (mm == null)
            {
                remoteClient.SendAgentAlertMessage("Server configuration error - cannot upload asset.", false);
                return;
            }

            if (mm.UploadChargeApplies((AssetType)type) && !tempFile)
            {
                if (!mm.UploadCovered(remoteClient.AgentId))
                {
                    remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
                    return;
                }
            }

            //m_log.Debug("asset upload of " + assetID);
            AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
            AssetXferUploader      uploader     = transactions.RequestXferUploader(transaction);

            if (uploader == null)
            {
                remoteClient.SendAgentAlertMessage("Server error uploading asset. Could not allocate uploader.", false);
                return;
            }
//            m_log.Debug("HandleUDPUploadRequest(Initialize) - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile);

            // Okay, start the upload.
            uploader.Initialize(remoteClient, assetID, transaction, type, data, storeLocal, tempFile);
        }
Ejemplo n.º 18
0
 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
 {
     m_userTransactions = transactions;
     m_dumpAssetToFile = dumpAssetToFile;
 }
Ejemplo n.º 19
0
 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
 {
     m_userTransactions = transactions;
     m_dumpAssetToFile = dumpAssetToFile;
     m_lastAccess = DateTime.Now;
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Get the collection of asset transactions for the given user.  If one does not already exist, it
        /// is created.
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        private AgentAssetTransactions GetUserTransactions(UUID userID)
        {
            lock (AgentTransactions)
            {
                if (!AgentTransactions.ContainsKey(userID))
                {
                    AgentAssetTransactions transactions  = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
                    AgentTransactions.Add(userID, transactions);
                }

                return AgentTransactions[userID];
            }
        }
Ejemplo n.º 21
0
 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
 {
     m_userTransactions = transactions;
     m_dumpAssetToFile  = dumpAssetToFile;
     m_lastAccess       = DateTime.Now;
 }
Ejemplo n.º 22
0
 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
 {
     m_userTransactions = transactions;
     m_dumpAssetToFile  = dumpAssetToFile;
 }
Ejemplo n.º 23
0
 public AssetXferUploader(AgentAssetTransactions transactions)
 {
     m_userTransactions = transactions;
 }