From 40809775dd24005a114154ba59d487c6dd80c3a7 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 27 May 2011 10:54:31 -0700 Subject: [PATCH] Added IGridDialogModule and GridDialogModule to support dialog in DSG mode. --- .../CoreModules/Avatar/Dialog/DialogModule.cs | 158 +----------------- .../RegionSyncModule/RegionSyncAvatar.cs | 8 +- .../Framework/Interfaces/IDialogModule.cs | 4 - 3 files changed, 4 insertions(+), 166 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 886515868e..3c91ec956b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog HandleAlertConsoleCommand); } - //public void PostInitialise() {} + public void PostInitialise() {} public void Close() {} public string Name { get { return "Dialog Module"; } } public bool IsSharedModule { get { return false; } } @@ -221,161 +221,5 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog return result; } - - #region GridCommunication - private IPresenceService m_PresenceService; - protected IPresenceService PresenceService - { - get - { - if (m_PresenceService == null) - m_PresenceService = m_scene.RequestModuleInterface(); - return m_PresenceService; - } - } - //DSG added to support llDialog with distributed script engine and client manager, - //following the same communication pattern as grid_instant_message - - public virtual void SendGridDialogViaXMLRPCAsync(UUID avatarID, string objectName, UUID objectID, string ownerFirstName, - string ownerLastName, string message, UUID textureID, int ch, string[] buttonlabels, UUID prevRegionID) - { - UUID toAgentID; - PresenceInfo upd = null; - // Non-cached user agent lookup. - PresenceInfo[] presences = PresenceService.GetAgents(new string[] { avatarID.ToString() }); - - if (presences != null && presences.Length > 0) - { - foreach (PresenceInfo p in presences) - { - if (p.RegionID != UUID.Zero) - { - upd = p; - break; - } - } - - if (upd != null) - { - // check if we've tried this before.. - // This is one way to end the recursive loop - // - if (upd.RegionID == prevRegionID) - { - //Dialog content undelivered - m_log.WarnFormat("Couldn't deliver dialog to {0}" + avatarID); - return; - } - } - else - { - //Dialog content undelivered - m_log.WarnFormat("Couldn't deliver dialog to {0}" + toAgentID); - return; - } - } - - if (upd != null) - { - GridRegion reginfo = m_scene.GridService.GetRegionByUUID(m_scene.RegionInfo.ScopeID, - upd.RegionID); - if (reginfo != null) - { - Hashtable msgdata = ConvertGridDialogToXMLRPC(avatarID, objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels); - //= ConvertGridInstantMessageToXMLRPC(im); - // Not actually used anymore, left in for compatibility - // Remove at next interface change - // - msgdata["region_handle"] = 0; - - bool imresult = doDialogSending(reginfo, msgdata); - if (imresult) - { - SendGridDialogViaXMLRPCAsync(avatarID, objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels, prevRegionID); - } - } - } - } - - private Hashtable ConvertGridDialogToXMLRPC(UUID avatarID, string objectName, UUID objectID, string ownerFirstName, string ownerLastName, - string message, UUID textureID, int ch, string[] buttonlabels) - { - Hashtable msgdata = new Hashtable(); - return msgdata; - } - - /// - /// This actually does the XMLRPC Request - /// - /// RegionInfo we pull the data out of to send the request to - /// The Instant Message data Hashtable - /// Bool if the message was successfully delivered at the other side. - protected virtual bool doDialogSending(GridRegion reginfo, Hashtable xmlrpcdata) - { - - ArrayList SendParams = new ArrayList(); - SendParams.Add(xmlrpcdata); - XmlRpcRequest GridReq = new XmlRpcRequest("grid_dialog", SendParams); - try - { - - XmlRpcResponse GridResp = GridReq.Send(reginfo.ServerURI, 3000); - - Hashtable responseData = (Hashtable)GridResp.Value; - - if (responseData.ContainsKey("success")) - { - if ((string)responseData["success"] == "TRUE") - { - return true; - } - else - { - return false; - } - } - else - { - return false; - } - } - catch (WebException e) - { - m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending grid_dialog to {0} the host didn't respond " + e.ToString(), reginfo.ServerURI.ToString()); - } - - return false; - } - - public virtual void PostInitialise() - { - MainServer.Instance.AddXmlRPCHandler( - "grid_dialog", processXMLRPCGridDialog); - } - - /// - /// Process a XMLRPC Grid Instant Message - /// - /// XMLRPC parameters - /// - /// Nothing much - protected virtual XmlRpcResponse processXMLRPCGridDialog(XmlRpcRequest request, IPEndPoint remoteClient) - { - bool successful = false; - - //Send response back to region calling if it was successful - // calling region uses this to know when to look up a user's location again. - XmlRpcResponse resp = new XmlRpcResponse(); - Hashtable respdata = new Hashtable(); - if (successful) - respdata["success"] = "TRUE"; - else - respdata["success"] = "FALSE"; - resp.Value = respdata; - - return resp; - } - -#endregion //GridCommunication } } \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs index 0b3e071548..329e29a26d 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs @@ -617,13 +617,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule public virtual void SendDialog(string objectname, UUID objectID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels) { - IDialogModule dialogModule = m_scene.RequestModuleInterface(); + IGridDialogModule gridDialogModule = m_scene.RequestModuleInterface(); - if (dialogModule != null) + if (gridDialogModule != null) { - //Seems that the two places calling DialogModule.SendDialogToUser, which calls current function, is - //pass (new UUID("00000000-0000-2222-3333-100000001000")) as the ownerID, so we copy that. - dialogModule.SendGridDialogViaXMLRPCAsync(this.AgentId, objectname, objectID, ownerFirstName, ownerLastName, + gridDialogModule.SendGridDialogViaXMLRPCAsync(this.AgentId, objectname, objectID, ownerFirstName, ownerLastName, msg, textureID, ch, buttonlabels, UUID.Zero); } } diff --git a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs index 492bbe87cb..be9764a7ea 100644 --- a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs @@ -123,9 +123,5 @@ namespace OpenSim.Region.Framework.Interfaces /// Send a textbox entry for the client to respond to /// void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid); - - //DSG added - void SendGridDialogViaXMLRPCAsync(UUID avatarID, string objectName, UUID objectID, string ownerFirstName, string ownerLastName, - string message, UUID textureID, int ch, string[] buttonlabels, UUID prevRegionID); } }