* Patch #1026 - llDialog support -- Thanks Melanie!

0.6.0-stable
Adam Frisby 2008-04-23 12:21:54 +00:00
parent 73d765901e
commit 3370d581e1
4 changed files with 92 additions and 10 deletions

View File

@ -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);

View File

@ -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
/// <summary>
@ -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

View File

@ -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)
{
}
}
}

View File

@ -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);