From b7d33b41de2c57a55009e5b22993bb51aa8b067e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 19 Jun 2022 13:25:06 +0100 Subject: [PATCH] use them on dialog module --- .../CoreModules/Avatar/Dialog/DialogModule.cs | 110 +++++++++--------- .../Framework/Interfaces/IDialogModule.cs | 58 +++++++++ 2 files changed, 110 insertions(+), 58 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 3237e1a434..1affe3f14c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -87,38 +87,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void SendAlertToUser(IClientAPI client, string message) { - SendAlertToUser(client, message, false); + client?.SendAgentAlertMessage(message, false); } - public void SendAlertToUser(IClientAPI client, string message, - bool modal) + public void SendAlertToUser(IClientAPI client, string message, bool modal) { - client.SendAgentAlertMessage(message, modal); + client?.SendAgentAlertMessage(message, modal); } public void SendAlertToUser(UUID agentID, string message) { - SendAlertToUser(agentID, message, false); + ScenePresence sp = m_scene.GetScenePresence(agentID); + sp?.ControllingClient.SendAgentAlertMessage(message, false); } public void SendAlertToUser(UUID agentID, string message, bool modal) { ScenePresence sp = m_scene.GetScenePresence(agentID); - - if (sp != null) - sp.ControllingClient.SendAgentAlertMessage(message, modal); + sp?.ControllingClient.SendAgentAlertMessage(message, modal); } - public void SendAlertToUser(string firstName, string lastName, - string message, bool modal) + public void SendAlertToUser(string firstName, string lastName, string message, bool modal) { - ScenePresence presence = m_scene.GetScenePresence(firstName, - lastName); - if (presence != null) - { - presence.ControllingClient.SendAgentAlertMessage(message, - modal); - } + ScenePresence sp= m_scene.GetScenePresence(firstName, lastName); + sp?.ControllingClient.SendAgentAlertMessage(message, modal); } public void SendGeneralAlert(string message) @@ -129,28 +121,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog }); } - private void GetOwnerName(UUID ownerID, out string ownerFirstName, out string ownerLastName) + private bool GetOwnerName(UUID partID, out string ownerFirstName, out string ownerLastName) { - if(!m_scene.UserManagementModule.GetUserName(ownerID, out ownerFirstName, out ownerLastName)) - { - IGroupsModule groups = m_scene.RequestModuleInterface(); - if (groups != null) - { - GroupRecord grprec = groups.GetGroupRecord(ownerID); - if (grprec != null && !string.IsNullOrEmpty(grprec.GroupName)) - { - ownerLastName = grprec.GroupName; - return; - } - } - } - if(string.IsNullOrEmpty(ownerFirstName)) - { - ownerFirstName = "(unknown)"; - ownerLastName = string.Empty; - } + SceneObjectPart sop = m_scene.GetSceneObjectPart(partID); + if(sop != null) + return sop.GetOwnerName(out ownerFirstName, out ownerLastName); + + ownerFirstName = string.Empty; + ownerLastName = string.Empty; + return false; } + // legacy public void SendDialogToUser(UUID avatarID, string objectName, UUID objectID, UUID ownerID, string message, UUID textureID, int ch, string[] buttonlabels) @@ -158,47 +140,61 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog ScenePresence sp = m_scene.GetScenePresence(avatarID); if (sp != null) { - GetOwnerName(ownerID, out string ownerFirstName, out string ownerLastName); - - sp.ControllingClient.SendDialog(objectName, objectID, ownerID, - ownerFirstName, ownerLastName, message, textureID, ch, - buttonlabels); + if(GetOwnerName(objectID, out string ownerFirstName, out string ownerLastName)) + { + sp.ControllingClient.SendDialog(objectName, objectID, ownerID, + ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels); + } } } + public void SendDialogToUser(UUID avatarID, string objectName, + UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName,string message, UUID textureID, + int ch, string[] buttonlabels) + { + ScenePresence sp = m_scene.GetScenePresence(avatarID); + sp?.ControllingClient.SendDialog(objectName, objectID, ownerID, + ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels); + } + public void SendUrlToUser(UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url) { ScenePresence sp = m_scene.GetScenePresence(avatarID); - if (sp != null) - { - sp.ControllingClient.SendLoadURL(objectName, objectID, + sp?.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url); - } } + // legacy public void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerID) { ScenePresence sp = m_scene.GetScenePresence(avatarid); if (sp != null) { - GetOwnerName(ownerID, out string ownerFirstName, out string ownerLastName); - - sp.ControllingClient.SendTextBoxRequest(message, chatChannel, - name, ownerID, ownerFirstName, ownerLastName, - objectid); + if (GetOwnerName(objectid, out string ownerFirstName, out string ownerLastName)) + { + sp.ControllingClient.SendTextBoxRequest(message, chatChannel, + name, ownerID, ownerFirstName, ownerLastName, objectid); + } } } - public void SendNotificationToUsersInRegion(UUID fromAvatarID, - string fromAvatarName, string message) + public void SendTextBoxToUser(UUID avatarid, string message, + int chatChannel, string name, UUID objectid, string ownerFirstName, string ownerLastName, UUID ownerID) + { + ScenePresence sp = m_scene.GetScenePresence(avatarid); + sp?.ControllingClient.SendTextBoxRequest(message, chatChannel, + name, ownerID, ownerFirstName, ownerLastName, + objectid); + } + + public void SendNotificationToUsersInRegion(UUID fromAvatarID, string fromAvatarName, string message) { m_scene.ForEachRootClient(delegate(IClientAPI client) { - client.SendAgentAlertMessage( - message, false); + client.SendAgentAlertMessage(message, false); }); } @@ -207,11 +203,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog /// /// /// - public void HandleAlertConsoleCommand(string module, - string[] cmdparams) + public void HandleAlertConsoleCommand(string module, string[] cmdparams) { - if (m_scene.ConsoleScene() != null && - m_scene.ConsoleScene() != m_scene) + if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) { return; } diff --git a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs index 4d35c1c856..9aeca47d45 100644 --- a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs @@ -111,6 +111,38 @@ namespace OpenSim.Region.Framework.Interfaces string[] buttonlabels); /// + /// Send a dialog box to a particular user. + /// + /// + /// UUID of the avatar representing the user. + /// + /// + /// Name of the object sending the dialog. + /// + /// + /// UUID of the object sending the dialog. + /// + /// + /// UUID of the user that owns the object. + /// + /// + /// first name of owner of the object, empty if group + /// + /// + /// last name of owner of the object or group name + /// + /// Message text to send to the user. + /// + /// Texture UUID to pass along with the dialog. + /// + /// + /// Channel on which the selected button text should be broadcast. + /// + /// Dialog button text. + void SendDialogToUser(UUID avatarID, string objectName, + UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string message, UUID textureID, + int ch, string[] buttonlabels); + /// /// Send a url to a particular user. /// /// @@ -168,5 +200,31 @@ namespace OpenSim.Region.Framework.Interfaces /// void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid); + + /// + /// Send a textbox entry for the client to respond to + /// + /// + /// UUID of the avatar representing the user. + /// + /// Message text to send to the user. + /// + /// Chat channel that the user's input should be broadcast on. + /// + /// Name of the object sending the dialog. + /// + /// UUID of the object sending the dialog. + /// + /// + /// UUID of the user that owns the object. + /// + /// + /// first name of owner of the object, empty if group + /// + /// + /// last name of owner of the object or group name + /// + void SendTextBoxToUser(UUID avatarid, string message, + int chatChannel, string name, UUID objectid, string ownerFirstName, string ownerLastName, UUID ownerID); } }