/// <summary> /// Classifieds info update. /// </summary> /// <param name='queryclassifiedID'> /// Queryclassified I. /// </param> /// <param name='queryCategory'> /// Query category. /// </param> /// <param name='queryName'> /// Query name. /// </param> /// <param name='queryDescription'> /// Query description. /// </param> /// <param name='queryParcelID'> /// Query parcel I. /// </param> /// <param name='queryParentEstate'> /// Query parent estate. /// </param> /// <param name='querySnapshotID'> /// Query snapshot I. /// </param> /// <param name='queryGlobalPos'> /// Query global position. /// </param> /// <param name='queryclassifiedFlags'> /// Queryclassified flags. /// </param> /// <param name='queryclassifiedPrice'> /// Queryclassified price. /// </param> /// <param name='remoteClient'> /// Remote client. /// </param> 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) { Scene s = (Scene)remoteClient.Scene; IMoneyModule money = s.RequestModuleInterface <IMoneyModule>(); if (money != null) { if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice)) { remoteClient.SendAgentAlertMessage("You do not have enough money to create requested classified.", false); return; } money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge); } UserClassifiedAdd ad = new UserClassifiedAdd(); Vector3 pos = remoteClient.SceneAgent.AbsolutePosition; ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y); ScenePresence p = FindPresence(remoteClient.AgentId); string serverURI = string.Empty; GetUserProfileServerURI(remoteClient.AgentId, out serverURI); if (land == null) { ad.ParcelName = string.Empty; } else { ad.ParcelName = land.LandData.Name; } ad.CreatorId = remoteClient.AgentId; ad.ClassifiedId = queryclassifiedID; ad.Category = Convert.ToInt32(queryCategory); ad.Name = queryName; ad.Description = queryDescription; ad.ParentEstate = Convert.ToInt32(queryParentEstate); ad.SnapshotId = querySnapshotID; ad.SimName = remoteClient.Scene.RegionInfo.RegionName; ad.GlobalPos = queryGlobalPos.ToString(); ad.Flags = queryclassifiedFlags; ad.Price = queryclassifiedPrice; ad.ParcelId = p.currentParcelUUID; object Ad = ad; OSD.SerializeMembers(Ad); if (!rpc.JsonRpcRequest(ref Ad, "classified_update", serverURI, UUID.Random().ToString())) { remoteClient.SendAgentAlertMessage( "Error updating classified", false); return; } }
protected void ObjectBuy(IClientAPI remoteClient, UUID sessionID, UUID groupID, UUID categoryID, uint localID, byte saleType, int salePrice) { // We're actually validating that the client is sending the data // that it should. In theory, the client should already know what to send here because it'll see it when it // gets the object data. If the data sent by the client doesn't match the object, the viewer probably has an // old idea of what the object properties are. Viewer developer Hazim informed us that the base module // didn't check the client sent data against the object do any. Since the base modules are the // 'crowning glory' examples of good practice.. ISceneChildEntity part = ((Scene)remoteClient.Scene).GetSceneObjectPart(localID); if (part == null) { remoteClient.SendAgentAlertMessage("Unable to buy now. The object was not found.", false); return; } // Validate that the client sent the price that the object is being sold for if (part.SalePrice != salePrice) { remoteClient.SendAgentAlertMessage("Cannot buy at this price. Buy Failed. If you continue to get this relog.", false); return; } // Validate that the client sent the proper sale type the object has set if (part.ObjectSaleType != saleType) { remoteClient.SendAgentAlertMessage("Cannot buy this way. Buy Failed. If you continue to get this relog.", false); return; } IMoneyModule moneyMod = remoteClient.Scene.RequestModuleInterface <IMoneyModule>(); if (moneyMod != null) { if (!moneyMod.ApplyCharge(remoteClient.AgentId, part.SalePrice, "Object Purchase")) { remoteClient.SendAgentAlertMessage("You do not have enough money to buy this object.", false); return; } } BuyObject(remoteClient, categoryID, localID, saleType, salePrice); }
// Classifieds Update 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) { Hashtable ReqHash = new Hashtable(); Scene s = (Scene)remoteClient.Scene; Vector3 pos = remoteClient.SceneAgent.AbsolutePosition; ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y); if (land == null) { ReqHash["parcelname"] = String.Empty; } else { ReqHash["parcelname"] = land.LandData.Name; } ReqHash["creatorUUID"] = remoteClient.AgentId.ToString(); ReqHash["classifiedUUID"] = queryclassifiedID.ToString(); ReqHash["category"] = queryCategory.ToString(); ReqHash["name"] = queryName; ReqHash["description"] = queryDescription; ReqHash["parentestate"] = queryParentEstate.ToString(); ReqHash["snapshotUUID"] = querySnapshotID.ToString(); ReqHash["sim_name"] = remoteClient.Scene.RegionInfo.RegionName; ReqHash["globalpos"] = queryGlobalPos.ToString(); ReqHash["classifiedFlags"] = queryclassifiedFlags.ToString(); ReqHash["classifiedPrice"] = queryclassifiedPrice.ToString(); ScenePresence p = FindPresence(remoteClient.AgentId); string serverURI = string.Empty; GetUserProfileServerURI(remoteClient.AgentId, out serverURI); Vector3 avaPos = p.AbsolutePosition; // Getting the parceluuid for this parcel ReqHash["parcelUUID"] = p.currentParcelUUID.ToString(); // Getting the global position for the Avatar Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.RegionLocX * Constants.RegionSize + avaPos.X, remoteClient.Scene.RegionInfo.RegionLocY * Constants.RegionSize + avaPos.Y, avaPos.Z); ReqHash["pos_global"] = posGlobal.ToString(); //Check available funds if there is a money module present IMoneyModule money = s.RequestModuleInterface <IMoneyModule>(); if (money != null) { if (!money.AmountCovered(remoteClient.AgentId, queryclassifiedPrice)) { remoteClient.SendCreateGroupReply(UUID.Zero, false, "Insufficient funds to create a classified ad."); return; } } Hashtable result = GenericXMLRPCRequest(ReqHash, "classified_update", serverURI); if (!Convert.ToBoolean(result["success"])) { remoteClient.SendAgentAlertMessage( result["errorMessage"].ToString(), false); return; } if (money != null && Convert.ToBoolean(result["created"])) { money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, MoneyTransactionType.ClassifiedCharge, queryName); } }
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 = GetRegionUserIsIn(remoteClient.AgentId).GetScenePresence(remoteClient.AgentId); if (p == null) { return; //Just fail } IMoneyModule money = p.Scene.RequestModuleInterface <IMoneyModule>(); if (money != null) { if (!money.ApplyCharge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified")) { remoteClient.SendAlertMessage("You do not have enough money to complete this upload."); 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 = GetRegionUserIsIn(remoteClient.AgentId).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(); classified.ClassifiedUUID = classifiedUUID; classified.CreatorUUID = creatorUUID; classified.CreationDate = creationdate; classified.ExpirationDate = expirationdate; classified.Category = category; classified.Name = name; classified.Description = description; classified.ParcelUUID = parceluuid; classified.ParentEstate = parentestate; classified.SnapshotUUID = snapshotUUID; classified.SimName = simname; classified.GlobalPos = globalpos; classified.ParcelName = parcelname; classified.ClassifiedFlags = classifiedFlags; classified.PriceForListing = classifiedPrice; ProfileFrontend.AddClassified(classified); }
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.ApplyCharge(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)); }