diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 53c75b007c..fce18c7ece 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -440,6 +440,8 @@ namespace OpenSim.Framework public delegate void ObjectIncludeInSearch(IClientAPI remoteClient, bool IncludeInSearch, uint localID); + public delegate void ScriptAnswer(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID, int answer); + public interface IClientAPI { event ImprovedInstantMessage OnInstantMessage; @@ -559,7 +561,8 @@ namespace OpenSim.Framework event ObjectIncludeInSearch OnObjectIncludeInSearch; event UUIDNameRequest OnTeleportHomeRequest; - + + event ScriptAnswer OnScriptAnswer; LLVector3 StartPos { get; set; } @@ -695,6 +698,7 @@ namespace OpenSim.Framework void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID); + void SendScriptQuestion(LLUUID taskID, string taskName, string ownerName, LLUUID itemID, int question); byte[] GetThrottlesPacked(float multiplier); diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index a58f88fedb..9e8830fd51 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -233,6 +233,7 @@ namespace OpenSim.Region.ClientStack private RequestAsset handlerRequestAsset = null; // OnRequestAsset; private UUIDNameRequest handlerTeleportHomeRequest = null; + private ScriptAnswer handlerScriptAnswer = null; /* Properties */ @@ -789,6 +790,8 @@ namespace OpenSim.Region.ClientStack public event UUIDNameRequest OnTeleportHomeRequest; + public event ScriptAnswer OnScriptAnswer; + #region Scene/Avatar to Client /// @@ -2484,6 +2487,20 @@ namespace OpenSim.Region.ClientStack return true; } + public void SendScriptQuestion(LLUUID taskID, string taskName, string ownerName, LLUUID itemID, int question) + { + ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion); + scriptQuestion.Data = new ScriptQuestionPacket.DataBlock(); + // TODO: don't create new blocks if recycling an old packet + scriptQuestion.Data.TaskID = taskID; + scriptQuestion.Data.ItemID = itemID; + scriptQuestion.Data.Questions = question; + scriptQuestion.Data.ObjectName = Helpers.StringToField(taskName); + scriptQuestion.Data.ObjectOwner = Helpers.StringToField(ownerName); + + OutPacket(scriptQuestion, ThrottleOutPacketType.Task); + } + protected virtual bool Logout(IClientAPI client, Packet packet) { m_log.Info("[CLIENT]: Got a logout request"); @@ -3838,6 +3855,16 @@ namespace OpenSim.Region.ClientStack handlerObjectIncludeInSearch(this, inSearch, localID); } } + break; + + case PacketType.ScriptAnswerYes: + ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack; + + handlerScriptAnswer = OnScriptAnswer; + if (handlerScriptAnswer != null) + { + handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions); + } break; #endregion diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 199653dba9..4f9024cfcf 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -166,6 +166,8 @@ namespace OpenSim.Region.Examples.SimpleModule public event ObjectIncludeInSearch OnObjectIncludeInSearch; public event UUIDNameRequest OnTeleportHomeRequest; + public event ScriptAnswer OnScriptAnswer; + #pragma warning restore 67 @@ -593,5 +595,9 @@ namespace OpenSim.Region.Examples.SimpleModule public void SetClientInfo(ClientInfo info) { } + + public void SendScriptQuestion(LLUUID objectID, string taskName, string ownerName, LLUUID itemID, int question) + { + } } } diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index a8eb824d31..3dff98f78f 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -69,6 +69,8 @@ namespace OpenSim.Region.ScriptEngine.Common private DateTime m_timer = DateTime.Now; private string m_state = "default"; + private bool m_waitingForScriptAnswer=false; + public string State { @@ -1950,11 +1952,6 @@ namespace OpenSim.Region.ScriptEngine.Common m_host.AddScriptLPS(1); - // Cannot combine debit with anything else since the new debit perms dialog has been introduced. - if((perm & BuiltIn_Commands_BaseClass.PERMISSION_DEBIT) != 0 && - perm != BuiltIn_Commands_BaseClass.PERMISSION_DEBIT) - perm &= ~BuiltIn_Commands_BaseClass.PERMISSION_DEBIT;// Silently ignore debit request - bool attachment=false; // Attachments not implemented yet. TODO: reflect real attachemnt state if(attachment && agent == m_host.OwnerID) @@ -1993,15 +1990,48 @@ namespace OpenSim.Region.ScriptEngine.Common } } - // TODO: Implement perms dialog sending + if (World.m_innerScene.ScenePresences.ContainsKey(agentID)) + { + string ownerName=resolveName(m_host.ParentGroup.RootPart.OwnerID); + if(ownerName == String.Empty) + ownerName="(hippos)"; - // Refuse perms for now + ScenePresence presence = World.m_innerScene.ScenePresences[agentID]; + if(!m_waitingForScriptAnswer) + { + m_host.TaskInventory[invItemID].PermsGranter=agentID; + m_host.TaskInventory[invItemID].PermsMask=0; + presence.ControllingClient.OnScriptAnswer+=handleScriptAnswer; + m_waitingForScriptAnswer=true; + } + + presence.ControllingClient.SendScriptQuestion(m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); + return; + } + + // Requested agent is not in range, refuse perms m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)0}); - - NotImplemented("llRequestPermissions"); } + void handleScriptAnswer(IClientAPI client, LLUUID taskID, LLUUID itemID, int answer) + { + if(taskID != m_host.UUID) + return; + + LLUUID invItemID=InventorySelf(); + + if(invItemID == LLUUID.Zero) + return; + + client.OnScriptAnswer-=handleScriptAnswer; + m_waitingForScriptAnswer=false; + + m_host.TaskInventory[invItemID].PermsMask=answer; + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( + m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)answer}); + } + public string llGetPermissionsKey() { m_host.AddScriptLPS(1); @@ -3924,9 +3954,24 @@ namespace OpenSim.Region.ScriptEngine.Common LSLError("First parameter to llDialog needs to be a key"); return; } + if(buttons.Length > 12) + { + LSLError("No more than 12 buttons can be shown"); + return; + } string[] buts = new string[buttons.Length]; for(int i = 0; i < buttons.Length; i++) { + if(buttons.Data[i].ToString() == String.Empty) + { + LSLError("button label cannot be blank"); + return; + } + if(buttons.Data[i].ToString().Length > 24) + { + LSLError("button label cannot be longer than 24 characters"); + return; + } buts[i] = buttons.Data[i].ToString(); } World.SendDialogToUser(av, m_host.Name, m_host.UUID, m_host.OwnerID, message, new LLUUID("00000000-0000-2222-3333-100000001000"), chat_channel, buts);