public bool Charge(UUID agentID, int amount, string text, int daysUntilNextCharge, TransactionType type, string identifer, bool chargeImmediately) { IMoneyModule moneyModule = m_registry.RequestModuleInterface <IMoneyModule>(); if (moneyModule != null) { if (chargeImmediately) { bool success = moneyModule.Charge(agentID, amount, text, type); if (!success) { return(false); } } IScheduleService scheduler = m_registry.RequestModuleInterface <IScheduleService>(); if (scheduler != null) { OSDMap itemInfo = new OSDMap(); itemInfo.Add("AgentID", agentID); itemInfo.Add("Amount", amount); itemInfo.Add("Text", text); itemInfo.Add("Type", (int)type); SchedulerItem item = new SchedulerItem("ScheduledPayment" + identifer, OSDParser.SerializeJsonString(itemInfo), false, DateTime.UtcNow, daysUntilNextCharge, RepeatType.days, agentID); itemInfo.Add("SchedulerID", item.id); scheduler.Save(item); } } return(true); }
/// <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 name="storeLocal"></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.AgentId, mm.UploadCharge, "", TransactionType.UploadCharge)) { remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); return; } } } AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); AssetXferUploader uploader = transactions.RequestXferUploader(transaction); if (uploader != null) { uploader.StartUpload(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); } }
private object ChargeNext(string functionName, object parameters) { if (functionName.StartsWith("ScheduledPayment")) { OSDMap itemInfo = (OSDMap)OSDParser.DeserializeJson(parameters.ToString()); IMoneyModule moneyModule = m_registry.RequestModuleInterface <IMoneyModule>(); UUID agentID = itemInfo["AgentID"]; string scdID = itemInfo["SchedulerID"]; string text = itemInfo["Text"]; int amount = itemInfo["Amount"]; TransactionType type = !itemInfo.ContainsKey("Type") ? TransactionType.SystemGenerated : (TransactionType)itemInfo["Type"].AsInteger(); if (CheckWhetherUserShouldPay(agentID, text)) { bool success = moneyModule.Charge(agentID, amount, text, type); if (!success) { if (OnUserDidNotPay != null) { OnUserDidNotPay(agentID, functionName.Replace("ScheduledPayment", ""), text); } } } else { IScheduleService scheduler = m_registry.RequestModuleInterface <IScheduleService>(); if (scheduler != null) { scheduler.Remove(scdID); } } } return(null); }
private object ChargeNext(string functionName, object parameters) { if (functionName == "ScheduledPayment") { OSDMap itemInfo = (OSDMap)OSDParser.DeserializeJson(parameters.ToString()); IMoneyModule moneyModule = m_registry.RequestModuleInterface <IMoneyModule>(); UUID agentID = itemInfo["AgentID"]; string scdID = itemInfo["SchedulerID"]; string text = itemInfo["Text"]; int amount = itemInfo["Amount"]; if (CheckWhetherUserShouldPay(agentID, text)) { bool success = moneyModule.Charge(agentID, amount, text); if (!success) { if (OnUserDidNotPay != null) { OnUserDidNotPay(agentID, text); } } } else { IScheduleService scheduler = m_registry.RequestModuleInterface <IScheduleService>(); if (scheduler != null) { scheduler.Remove(scdID); } } } return(null); }
public bool Charge(UUID agentID, int amount, string text, int daysUntilNextCharge) { IMoneyModule moneyModule = m_registry.RequestModuleInterface <IMoneyModule>(); if (moneyModule != null) { bool success = moneyModule.Charge(agentID, amount, text); if (!success) { return(false); } IScheduleService scheduler = m_registry.RequestModuleInterface <IScheduleService>(); if (scheduler != null) { OSDMap itemInfo = new OSDMap(); itemInfo.Add("AgentID", agentID); itemInfo.Add("Amount", amount); itemInfo.Add("Text", text); SchedulerItem item = new SchedulerItem("ScheduledPayment", OSDParser.SerializeJsonString(itemInfo), false, DateTime.Now.AddDays(daysUntilNextCharge) - DateTime.Now); itemInfo.Add("SchedulerID", item.id); scheduler.Save(item); } } return(true); }
private bool ChargeUser(string asset_type, OSDMap map, out int charge, out int resourceCost) { IMoneyModule mm = m_service.Registry.RequestModuleInterface <IMoneyModule>(); charge = 0; resourceCost = 0; if (mm != null) { if (asset_type == "texture" || asset_type == "animation" || asset_type == "snapshot" || asset_type == "sound") { charge = mm.UploadCharge; } else if (asset_type == "mesh" || asset_type == "object") { OSDMap meshMap = (OSDMap)map["asset_resources"]; OSDArray instance_list = (OSDArray)meshMap["instance_list"]; OSDArray mesh_list = (OSDArray)meshMap["mesh_list"]; OSDArray texture_list = (OSDArray)meshMap["texture_list"]; charge = texture_list.Count * mm.UploadCharge + meshMap.Count * mm.UploadCharge; resourceCost = meshMap.Count * mm.UploadCharge; } if (charge > 0 && !mm.Charge(m_service.AgentID, mm.UploadCharge, "Upload Charge")) { return(false); } } return(true); }
/// <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.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(), "Network Monitor"); networkMonitor.AddPendingUploads(1); } AssetXferUploader uploader = transactions.RequestXferUploader(transaction); if (uploader != null) { uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); } }
public string NewAgentInventoryRequest(string request, UUID agentID) { OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(request); //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit // You need to be aware of this and //if (llsdRequest.asset_type == "texture" || // llsdRequest.asset_type == "animation" || // llsdRequest.asset_type == "sound") // { IClientAPI client = null; IMoneyModule mm = m_scene.RequestModuleInterface <IMoneyModule>(); if (mm != null) { if (m_scene.TryGetClient(agentID, out client)) { if (!mm.Charge(agentID, mm.UploadCharge, "Asset upload")) { if (client != null) { client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); } map = new OSDMap(); map["rsvp"] = ""; map["state"] = "error"; return(OSDParser.SerializeLLSDXmlString(map)); } } } // } string asset_type = map["asset_type"].AsString(); string assetName = map["name"].AsString(); string assetDes = map["description"].AsString(); string capsBase = "/CAPS/NewFileAgentInventoryVariablePrice/"; string inventory_type = map["inventory_type"].AsString(); UUID newAsset = UUID.Random(); UUID newInvItem = UUID.Random(); UUID parentFolder = map["folder_id"].AsUUID(); string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, inventory_type, asset_type, capsBase + uploaderPath, MainServer.Instance, agentID, this); MainServer.Instance.AddStreamHandler( new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = m_scene.RegionInfo.ServerURI + capsBase + uploaderPath; map = new OSDMap(); map["rsvp"] = uploaderURL; map["state"] = "upload"; map["resource_cost"] = 0; map["upload_price"] = 0; return(OSDParser.SerializeLLSDXmlString(map)); }
public void ClassifiedInfoUpdate(UUID queryClassifiedID, uint queryCategory, string queryName, string queryDescription, UUID queryParcelID, uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos, byte queryclassifiedFlags, int queryclassifiedPrice, IClientAPI remoteClient) { IScenePresence p = remoteClient.Scene.GetScenePresence(remoteClient.AgentId); if (p == null) { return; //Just fail } IScheduledMoneyModule scheduledMoneyModule = p.Scene.RequestModuleInterface <IScheduledMoneyModule> (); IMoneyModule moneyModule = p.Scene.RequestModuleInterface <IMoneyModule> (); Classified classcheck = ProfileFrontend.GetClassified(queryClassifiedID); if (((queryclassifiedFlags & 32) != 32) && moneyModule != null) { //Single week if (!moneyModule.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified", TransactionType.ClassifiedCharge)) { remoteClient.SendAlertMessage("You do not have enough money to create this classified."); return; } } else if (scheduledMoneyModule != null) { //Auto-renew if (classcheck != null) { scheduledMoneyModule.RemoveFromScheduledCharge("[Classified: " + queryClassifiedID + "]"); } var payOK = scheduledMoneyModule.Charge( remoteClient.AgentId, // who to charge queryclassifiedPrice, // how much "Add Reoccurring Classified (" + queryClassifiedID + ")", // description TransactionType.ClassifiedCharge, // transaction type "[Classified: " + queryClassifiedID + "]", // scheduler identifier true, // charger immediately false); // run once if (!payOK) { remoteClient.SendAlertMessage("You do not have enough money to create this classified."); return; } } UUID creatorUUID = remoteClient.AgentId; UUID classifiedUUID = queryClassifiedID; uint category = queryCategory; string name = queryName; string description = queryDescription; uint parentestate = queryParentEstate; UUID snapshotUUID = querySnapshotID; string simname = remoteClient.Scene.RegionInfo.RegionName; Vector3 globalpos = queryGlobalPos; byte classifiedFlags = queryclassifiedFlags; int classifiedPrice = queryclassifiedPrice; UUID parceluuid = p.CurrentParcelUUID; string parcelname = "Unknown"; IParcelManagementModule parcelManagement = remoteClient.Scene.RequestModuleInterface <IParcelManagementModule> (); if (parcelManagement != null) { ILandObject parcel = parcelManagement.GetLandObject(p.AbsolutePosition.X, p.AbsolutePosition.Y); if (parcel != null) { parcelname = parcel.LandData.Name; parceluuid = parcel.LandData.GlobalID; } } uint creationdate = (uint)Util.UnixTimeSinceEpoch(); uint expirationdate = (uint)Util.UnixTimeSinceEpoch() + (365 * 24 * 60 * 60); Classified classified = new Classified { ClassifiedUUID = classifiedUUID, CreatorUUID = creatorUUID, CreationDate = creationdate, ExpirationDate = expirationdate, Category = category, Name = name, Description = description, ParcelUUID = parceluuid, ParentEstate = parentestate, SnapshotUUID = snapshotUUID, SimName = simname, GlobalPos = globalpos, ParcelName = parcelname, ClassifiedFlags = classifiedFlags, PriceForListing = classifiedPrice, ScopeID = remoteClient.ScopeID }; ProfileFrontend.AddClassified(classified); }
public void ClassifiedInfoUpdate(UUID queryclassifiedID, uint queryCategory, string queryName, string queryDescription, UUID queryParcelID, uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos, byte queryclassifiedFlags, int queryclassifiedPrice, IClientAPI remoteClient) { IScenePresence p = remoteClient.Scene.GetScenePresence(remoteClient.AgentId); if (p == null) { return; //Just fail } IMoneyModule money = p.Scene.RequestModuleInterface <IMoneyModule>(); if (money != null) { Classified classcheck = ProfileFrontend.GetClassified(queryclassifiedID); if (classcheck == null) { if (!money.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified")) { remoteClient.SendAlertMessage("You do not have enough money to create this classified."); return; } } } UUID creatorUUID = remoteClient.AgentId; UUID classifiedUUID = queryclassifiedID; uint category = queryCategory; string name = queryName; string description = queryDescription; uint parentestate = queryParentEstate; UUID snapshotUUID = querySnapshotID; string simname = remoteClient.Scene.RegionInfo.RegionName; Vector3 globalpos = queryGlobalPos; byte classifiedFlags = queryclassifiedFlags; int classifiedPrice = queryclassifiedPrice; UUID parceluuid = p.CurrentParcelUUID; string parcelname = "Unknown"; IParcelManagementModule parcelManagement = remoteClient.Scene.RequestModuleInterface <IParcelManagementModule>(); if (parcelManagement != null) { ILandObject parcel = parcelManagement.GetLandObject(p.AbsolutePosition.X, p.AbsolutePosition.Y); if (parcel != null) { parcelname = parcel.LandData.Name; parceluuid = parcel.LandData.InfoUUID; } } uint creationdate = (uint)Util.UnixTimeSinceEpoch(); uint expirationdate = (uint)Util.UnixTimeSinceEpoch() + (365 * 24 * 60 * 60); Classified classified = new Classified { ClassifiedUUID = classifiedUUID, CreatorUUID = creatorUUID, CreationDate = creationdate, ExpirationDate = expirationdate, Category = category, Name = name, Description = description, ParcelUUID = parceluuid, ParentEstate = parentestate, SnapshotUUID = snapshotUUID, SimName = simname, GlobalPos = globalpos, ParcelName = parcelname, ClassifiedFlags = classifiedFlags, PriceForListing = classifiedPrice, ScopeID = remoteClient.ScopeID }; ProfileFrontend.AddClassified(classified); }