コード例 #1
0
        public void ObjectBuy(IClientAPI remoteClient, UUID agentID,
                              UUID sessionID, UUID groupID, UUID categoryID,
                              uint localID, byte saleType, int salePrice)
        {
            if (!m_sellEnabled)
            {
                remoteClient.SendBlueBoxMessage(UUID.Zero, "", "Buying is not implemented in this version");
                return;
            }

            if (salePrice != 0)
            {
                remoteClient.SendBlueBoxMessage(UUID.Zero, "", "Buying anything for a price other than zero is not implemented");
                return;
            }

            Scene s = LocateSceneClientIn(remoteClient.AgentId);

            // Implmenting base sale data checking here so the default OpenSimulator implementation isn't useless
            // combined with other implementations.  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..

            // Validate that the object exists in the scene the user is in
            SceneObjectPart part = s.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;
            }

            IBuySellModule module = s.RequestModuleInterface <IBuySellModule>();

            if (module != null)
            {
                module.BuyObject(remoteClient, categoryID, localID, saleType, salePrice);
            }
        }
コード例 #2
0
ファイル: SampleMoneyModule.cs プロジェクト: 4U2NV/opensim
        /// <summary>
        /// XMLRPC handler to send alert message and sound to client
        /// </summary>
        public XmlRpcResponse UserAlert(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            XmlRpcResponse ret         = new XmlRpcResponse();
            Hashtable      retparam    = new Hashtable();
            Hashtable      requestData = (Hashtable)request.Params[0];

            UUID agentId;
            UUID soundId;
            UUID regionId;

            UUID.TryParse((string)requestData["agentId"], out agentId);
            UUID.TryParse((string)requestData["soundId"], out soundId);
            UUID.TryParse((string)requestData["regionId"], out regionId);
            string text   = (string)requestData["text"];
            string secret = (string)requestData["secret"];

            Scene userScene = GetSceneByUUID(regionId);

            if (userScene != null)
            {
                if (userScene.RegionInfo.regionSecret == secret)
                {
                    IClientAPI client = LocateClientObject(agentId);
                    if (client != null)
                    {
                        if (soundId != UUID.Zero)
                        {
                            client.SendPlayAttachedSound(soundId, UUID.Zero, UUID.Zero, 1.0f, 0);
                        }

                        client.SendBlueBoxMessage(UUID.Zero, "", text);

                        retparam.Add("success", true);
                    }
                    else
                    {
                        retparam.Add("success", false);
                    }
                }
                else
                {
                    retparam.Add("success", false);
                }
            }

            ret.Value = retparam;
            return(ret);
        }
コード例 #3
0
        public void ObjectBuy(IClientAPI remoteClient, UUID agentID,
                UUID sessionID, UUID groupID, UUID categoryID,
                uint localID, byte saleType, int salePrice)
        {
            if (!m_sellEnabled)
            {
                remoteClient.SendBlueBoxMessage(UUID.Zero, "", "Buying is not implemented in this version");
                return;
            }

            if (salePrice != 0)
            {
                remoteClient.SendBlueBoxMessage(UUID.Zero, "", "Buying anything for a price other than zero is not implemented");
                return;
            }

            Scene s = LocateSceneClientIn(remoteClient.AgentId);

            // Implmenting base sale data checking here so the default OpenSimulator implementation isn't useless 
            // combined with other implementations.  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..

            // Validate that the object exists in the scene the user is in
            SceneObjectPart part = s.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;
            }

            IBuySellModule module = s.RequestModuleInterface<IBuySellModule>();
            if (module != null)
                module.BuyObject(remoteClient, categoryID, localID, saleType, salePrice);
        }
コード例 #4
0
        /// <summary>
        /// Called when an object is removed from the environment into inventory.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="localID"></param>
        /// <param name="groupID"></param>
        /// <param name="action"></param>
        /// <param name="destinationID"></param>
        public virtual void DeRezObjects(IClientAPI remoteClient, ICollection<uint> objectParts, 
            UUID groupId, DeRezAction action, UUID destinationID)
        {
            //get the intended behavior of this action
            DeRezActionResult intendedResult = this.GetIntendedResult(action);

            //List for collecting found prims
            List<SceneObjectGroup> groupsToDerez = new List<SceneObjectGroup>();
            bool abort = false;
            bool reportErrorForNoGroupsReturned = true;

            using (SceneTransaction transaction = SceneGraph.BeginPrimTransaction(objectParts))
            {
                try
                {
                    //check to make sure each part can meet the intended result
                    //skip with null client
                    if (remoteClient != null)
                    {
                        foreach (uint partInfo in objectParts)
                        {
                            SceneObjectGroup grp = this.FindGroupAppropriateForDeRez(partInfo);
                            if (grp == null) return; //couldn't find groups
                            if (grp.IsAttachment) continue; //none of this should be done on attachments

                            if (this.FindDeRezPermissions(remoteClient, grp, action) != this.GetIntendedResult(action))
                            {
                                //missing permissions for one or more of the objects
                                remoteClient.SendAlertMessage("Insuffient permissions on '" + grp.Name + "'.");
                                return;
                            }
                            else
                            {
                                if (!this.AddToListIfDerezOk(intendedResult, grp, groupsToDerez))
                                {
                                    //could not derez
                                    abort = true;
                                    remoteClient.SendBlueBoxMessage(UUID.Zero, String.Empty, "Could not take/remove '" + grp.Name + "', operation aborted.");
                                    return;
                                }
                            }
                        }
                    }
                    else
                    {
                        //delete called from parcel return
                        foreach (uint partInfo in objectParts)
                        {
                            SceneObjectGroup grp = this.FindGroupAppropriateForDeRez(partInfo);
                            if (grp == null) return; //couldn't find groups
                            if (grp.IsAttachment) continue; //none of this should be done on attachments

                            //protect against a return on the same object happing multiple times
                            if (!this.AddToListIfDerezOk(intendedResult, grp, groupsToDerez))
                            {
                                //could not derez
                                reportErrorForNoGroupsReturned = false;
                                continue;
                            }
                        }
                    }

                    if (groupsToDerez.Count == 0)
                    {
                        //there must've been a problem locating the group(s), inform the user

                        if (reportErrorForNoGroupsReturned)
                        {
                            m_log.ErrorFormat("[Scene.Inventory] No groups found to derez after scene search, Action: {0}", action);
                        }

                        /*
                        if (remoteClient != null)
                        {
                            remoteClient.SendBlueBoxMessage(UUID.Zero, String.Empty, "Could not find objects to derez");
                        }
                        */
                        return;
                    }

                    //if we got here, we can start completing the requested action
                    ForceBulkSceneObjectBackup(groupsToDerez);

                    if (intendedResult == DeRezActionResult.Both || intendedResult == DeRezActionResult.Take)
                    {
                        m_asyncSceneObjectDeleter.DeleteToInventory(
                                action, destinationID, groupsToDerez, remoteClient,
                                intendedResult == DeRezActionResult.Both //also delete?
                                );
                    }
                    else if (intendedResult == DeRezActionResult.Delete)
                    {
                        DeleteSceneObjects(groupsToDerez, false);
                    }
                }
                finally
                {
                    if (abort)
                    {
                        //clean up the derezzed flag 
                        foreach (var group in groupsToDerez)
                        {
                            group.IsBeingDerezzed = false;
                        }
                    }
                }
            }
        }
コード例 #5
0
        public void ObjectBuy(IClientAPI remoteClient, UUID agentID,
                UUID sessionID, UUID groupID, UUID categoryID,
                uint localID, byte saleType, int salePrice)
        {
            if (!m_sellEnabled)
            {
                remoteClient.SendBlueBoxMessage(UUID.Zero, "", "Buying is not implemented in this version");
                return;
            }

            if (salePrice != 0)
            {
                remoteClient.SendBlueBoxMessage(UUID.Zero, "", "Buying anything for a price other than zero is not implemented");
                return;
            }

            Scene s = LocateSceneClientIn(remoteClient.AgentId);
            SceneObjectPart part = s.GetSceneObjectPart(localID);
            if (part == null)
            {
                remoteClient.SendAgentAlertMessage("Unable to buy now. The object was not found.", false);
                return;
            }
            s.PerformObjectBuy(remoteClient, categoryID, localID, saleType);
        }
コード例 #6
0
        private Hashtable userInteract(Hashtable requestData)
        {
            Hashtable rparms = new Hashtable();

            try
            {
                UUID   receiverUUID = UUID.Parse((string)requestData["receiverUUID"]);
                Int32  type         = Int32.Parse((string)requestData["type"]);
                String payloadID    = (string)requestData["payloadID"];

                Dictionary <string, string> d = new Dictionary <string, string>();
                d.Add("method", "getNotificationMessage");
                d.Add("payloadID", payloadID);

                Dictionary <string, string> messageItems = CommunicationHelpers.DoRequest(gatewayURL, d);
                if (messageItems == null)
                {
                    throw new Exception("Could not fetch payload with ID " + payloadID);
                }

                m_log.Debug("[OMECONOMY] userInteract*:");
                foreach (KeyValuePair <string, string> pair in messageItems)
                {
                    m_log.Debug("[OMECONOMY]    " + pair.Key + "  " + pair.Value);
                }

                IClientAPI client = SceneHandler.Instance.LocateClientObject(receiverUUID);
                if (client == null)
                {
                    throw new Exception("Could not locate the specified avatar");
                }

                Scene userScene = SceneHandler.Instance.GetSceneByUUID(client.Scene.RegionInfo.originRegionID);
                if (userScene == null)
                {
                    throw new Exception("Could not locate the specified scene");
                }

                String message = messageItems["message"];

                UUID          senderUUID = UUID.Zero;
                String        senderName = String.Empty;
                IDialogModule dm         = null;
                IClientAPI    sender     = null;

                IUserManagement userManager = SceneHandler.Instance.GetRandomScene().RequestModuleInterface <IUserManagement>();
                if (userManager == null)
                {
                    throw new Exception("Could not locate UserMangement Interface");
                }

                switch (type)
                {
                case (int)NotificationType.LOAD_URL:
                    String url = messageItems["url"];

                    dm = userScene.RequestModuleInterface <IDialogModule>();
                    dm.SendUrlToUser(receiverUUID, "OMEconomy", UUID.Zero, UUID.Zero, false, message, url);
                    break;

                case (int)NotificationType.CHAT_MESSAGE:
                    senderUUID = UUID.Parse(messageItems["senderUUID"]);
                    senderName = userManager.GetUserName(senderUUID);


                    client.SendChatMessage(
                        message, (byte)ChatTypeEnum.Say, Vector3.Zero, senderName,
                        senderUUID, senderUUID, (byte)ChatSourceType.Agent, (byte)ChatAudibleLevel.Fully);

                    sender = SceneHandler.Instance.LocateClientObject(senderUUID);
                    if (sender != null)
                    {
                        sender.SendChatMessage(
                            message, (byte)ChatTypeEnum.Say, Vector3.Zero, senderName,
                            senderUUID, senderUUID, (byte)ChatSourceType.Agent, (byte)ChatAudibleLevel.Fully);
                    }
                    break;

                case (int)NotificationType.ALERT:
                    dm = userScene.RequestModuleInterface <IDialogModule>();
                    dm.SendAlertToUser(receiverUUID, message);
                    break;

                case (int)NotificationType.DIALOG:
                    client.SendBlueBoxMessage(UUID.Zero, "", message);
                    break;

                case (int)NotificationType.GIVE_NOTECARD:
                    break;

                case (int)NotificationType.INSTANT_MESSAGE:
                    senderUUID = UUID.Parse(messageItems["senderUUID"]);
                    UUID sessionUUID = UUID.Parse(messageItems["sessionUUID"]);
                    if (messageItems.ContainsKey("senderName"))
                    {
                        senderName = messageItems["senderName"];
                    }
                    else
                    {
                        senderName = userManager.GetUserName(UUID.Parse((string)messageItems["senderUUID"]));
                    }

                    GridInstantMessage msg = new GridInstantMessage();
                    msg.fromAgentID    = senderUUID.Guid;
                    msg.toAgentID      = receiverUUID.Guid;
                    msg.imSessionID    = sessionUUID.Guid;
                    msg.fromAgentName  = senderName;
                    msg.message        = (message != null && message.Length > 1024) ? msg.message = message.Substring(0, 1024) : message;
                    msg.dialog         = (byte)InstantMessageDialog.MessageFromAgent;
                    msg.fromGroup      = false;
                    msg.offline        = (byte)0;
                    msg.ParentEstateID = 0;
                    msg.Position       = Vector3.Zero;
                    msg.RegionID       = userScene.RegionInfo.RegionID.Guid;


                    client.SendInstantMessage(msg);

                    sender = SceneHandler.Instance.LocateClientObject(senderUUID);
                    if (sender != null)
                    {
                        sender.SendInstantMessage(msg);
                    }
                    break;

                default:
                    break;
                }

                rparms["success"] = true;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[OMECONOMY]: userInteract() Exception: {1} - {2}", Name, e.Message, e.StackTrace);
                rparms["success"] = false;
            }
            return(rparms);
        }