From f11a97f12d328af8bb39b92fec5cb5780983b66a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 7 Jan 2010 15:53:55 -0800 Subject: * Finished SimulationServiceConnector * Started rerouting calls to UserService. * Compiles. May run. --- .../Avatar/InstantMessage/MessageTransferModule.cs | 60 ++++++++++++++-------- .../Inventory/Archiver/InventoryArchiverModule.cs | 2 +- .../Avatar/Profiles/AvatarProfilesModule.cs | 43 ++++++++-------- .../RemoteAuthorizationServiceConnector.cs | 6 +-- .../Presence/RemotePresenceServiceConnector.cs | 2 +- .../Simulation/LocalSimulationConnector.cs | 19 ++++--- .../Simulation/RemoteSimulationConnector.cs | 11 ++-- 7 files changed, 83 insertions(+), 60 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 2d4b421..c0d3f31 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -37,6 +37,8 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { @@ -46,10 +48,21 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage private bool m_Enabled = false; protected List m_Scenes = new List(); - protected Dictionary m_UserRegionMap = new Dictionary(); + protected Dictionary m_UserRegionMap = new Dictionary(); public event UndeliveredMessage OnUndeliveredMessage; + private IPresenceService m_PresenceService; + protected IPresenceService PresenceService + { + get + { + if (m_PresenceService == null) + m_PresenceService = m_Scenes[0].RequestModuleInterface(); + return m_PresenceService; + } + } + public virtual void Initialise(IConfigSource config) { IConfig cnf = config.Configs["Messaging"]; @@ -416,7 +429,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// /// delegate for sending a grid instant message asynchronously /// - public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle); + public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID); protected virtual void GridInstantMessageCompleted(IAsyncResult iar) { @@ -430,7 +443,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; - d.BeginInvoke(im, result, 0, GridInstantMessageCompleted, d); + d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); } /// @@ -445,11 +458,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// Pass in 0 the first time this method is called. It will be called recursively with the last /// regionhandle tried /// - protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle) + protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) { UUID toAgentID = new UUID(im.toAgentID); - UserAgentData upd = null; + PresenceInfo upd = null; bool lookupAgent = false; @@ -457,13 +470,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { if (m_UserRegionMap.ContainsKey(toAgentID)) { - upd = new UserAgentData(); - upd.AgentOnline = true; - upd.Handle = m_UserRegionMap[toAgentID]; + upd = new PresenceInfo(); + upd.Online = true; + upd.RegionID = m_UserRegionMap[toAgentID]; // We need to compare the current regionhandle with the previous region handle // or the recursive loop will never end because it will never try to lookup the agent again - if (prevRegionHandle == upd.Handle) + if (prevRegionID == upd.RegionID) { lookupAgent = true; } @@ -479,14 +492,23 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (lookupAgent) { // Non-cached user agent lookup. - upd = m_Scenes[0].CommsManager.UserService.GetAgentByUUID(toAgentID); + PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); + if (presences != null) + { + foreach (PresenceInfo p in presences) + if (p.Online) + { + upd = presences[0]; + break; + } + } if (upd != null) { // check if we've tried this before.. // This is one way to end the recursive loop // - if (upd.Handle == prevRegionHandle) + if (upd.RegionID == prevRegionID) { m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); HandleUndeliveredMessage(im, result); @@ -503,12 +525,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (upd != null) { - if (upd.AgentOnline) + if (upd.Online) { - uint x = 0, y = 0; - Utils.LongToUInts(upd.Handle, out x, out y); - GridRegion reginfo = m_Scenes[0].GridService.GetRegionByPosition(m_Scenes[0].RegionInfo.ScopeID, - (int)x, (int)y); + GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, + upd.RegionID); if (reginfo != null) { Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); @@ -524,11 +544,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { if (m_UserRegionMap.ContainsKey(toAgentID)) { - m_UserRegionMap[toAgentID] = upd.Handle; + m_UserRegionMap[toAgentID] = upd.RegionID; } else { - m_UserRegionMap.Add(toAgentID, upd.Handle); + m_UserRegionMap.Add(toAgentID, upd.RegionID); } } result(true); @@ -543,12 +563,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // This is recursive!!!!! SendGridInstantMessageViaXMLRPCAsync(im, result, - upd.Handle); + upd.RegionID); } } else { - m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.Handle); + m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); HandleUndeliveredMessage(im, result); } } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index ecd60bd..6da43a8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -335,7 +335,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver try { - if (m_aScene.CommsManager.UserService.AuthenticateUserByPassword(userInfo.UserProfile.ID, pass)) + if (m_aScene.AuthenticationService.Authenticate(userInfo.UserProfile.ID, pass, 1) != string.Empty) { return userInfo; } diff --git a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs index 8cf58c6..718ee2f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs @@ -110,7 +110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles public void RequestAvatarProperty(IClientAPI remoteClient, UUID avatarID) { // FIXME: finish adding fields such as url, masking, etc. - UserProfileData profile = m_scene.CommsManager.UserService.GetUserProfile(avatarID); + UserProfileData profile = null; // m_scene.CommsManager.UserService.GetUserProfile(avatarID); if (null != profile) { Byte[] charterMember; @@ -143,26 +143,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles public void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData newProfile) { - UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID); - - // if it's the profile of the user requesting the update, then we change only a few things. - if (remoteClient.AgentId.CompareTo(Profile.ID) == 0) - { - Profile.Image = newProfile.Image; - Profile.FirstLifeImage = newProfile.FirstLifeImage; - Profile.AboutText = newProfile.AboutText; - Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText; - Profile.ProfileUrl = newProfile.ProfileUrl; - } - else - { - return; - } - - if (m_scene.CommsManager.UserService.UpdateUserProfile(Profile)) - { - RequestAvatarProperty(remoteClient, newProfile.ID); - } + return; + //UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID); + + //// if it's the profile of the user requesting the update, then we change only a few things. + //if (remoteClient.AgentId.CompareTo(Profile.ID) == 0) + //{ + // Profile.Image = newProfile.Image; + // Profile.FirstLifeImage = newProfile.FirstLifeImage; + // Profile.AboutText = newProfile.AboutText; + // Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText; + // Profile.ProfileUrl = newProfile.ProfileUrl; + //} + //else + //{ + // return; + //} + + //if (m_scene.CommsManager.UserService.UpdateUserProfile(Profile)) + //{ + // RequestAvatarProperty(remoteClient, newProfile.ID); + //} } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs index 68499f3..01a2615 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs @@ -139,9 +139,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization if (scene != null) { - UserProfileData profile = scene.CommsManager.UserService.GetUserProfile(new UUID(userID)); - isAuthorized = IsAuthorizedForRegion(userID, profile.FirstName, profile.SurName, - profile.Email, scene.RegionInfo.RegionName, regionID, out message); + UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, userID); + isAuthorized = IsAuthorizedForRegion(userID, account.FirstName, account.LastName, + account.Email, scene.RegionInfo.RegionName, regionID, out message); } else { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index e8e140a..6c69570 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence public string Name { - get { return "RemotePresenceServiceConnector"; } + get { return "RemotePresenceServicesConnector"; } } public void Initialise(IConfigSource source) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 074bfb5..c6c6af0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -172,12 +172,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation { if (s.RegionInfo.RegionHandle == destination.RegionHandle) { -// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); + m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", destination.RegionName); return s.NewUserConnection(aCircuit, teleportFlags, out reason); } } -// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); + m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", destination.RegionName); reason = "Did not find region " + destination.RegionName; return false; } @@ -241,14 +241,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - public bool ReleaseAgent(GridRegion destination, UUID id, string uri) + public bool ReleaseAgent(UUID origin, UUID id, string uri) { - if (destination == null) - return false; - foreach (Scene s in m_sceneList) { - if (s.RegionInfo.RegionHandle == destination.RegionHandle) + if (s.RegionInfo.RegionID == origin) { //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); return s.IncomingReleaseAgent(id); @@ -334,6 +331,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } + public bool IsLocalRegion(UUID id) + { + foreach (Scene s in m_sceneList) + if (s.RegionInfo.RegionID == id) + return true; + return false; + } + #endregion } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index c9cc368..f485cd1 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -245,18 +245,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation } - public bool ReleaseAgent(GridRegion destination, UUID id, string uri) + public bool ReleaseAgent(UUID origin, UUID id, string uri) { - if (destination == null) - return false; - // Try local first - if (m_localBackend.ReleaseAgent(destination, id, uri)) + if (m_localBackend.ReleaseAgent(origin, id, uri)) return true; // else do the remote thing - if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) - return m_remoteConnector.ReleaseAgent(destination, id, uri); + if (!m_localBackend.IsLocalRegion(origin)) + return m_remoteConnector.ReleaseAgent(origin, id, uri); return false; } -- cgit v1.1