From 749c3fef8ad2d3af97fcd9ab9c72740675e46715 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 8 Mar 2012 01:51:37 +0000 Subject: Change "help" to display categories/module list then "help " to display commands in a category. This is to deal with the hundred lines of command splurge when one previously typed "help" Modelled somewhat on the mysql console One can still type help to get per command help at any point. Categories capitalized to avoid conflict with the all-lowercase commands (except for commander system, as of yet). Does not affect command parsing or any other aspects of the console apart from the help system. Backwards compatible with existing modules. --- OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | 4 ++-- .../CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index ffe7718..325067c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -51,12 +51,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog m_scene.RegisterModuleInterface(this); m_scene.AddCommand( - this, "alert", "alert ", + "Users", this, "alert", "alert ", "Send an alert to everyone", HandleAlertConsoleCommand); m_scene.AddCommand( - this, "alert-user", "alert-user ", + "Users", this, "alert-user", "alert-user ", "Send an alert to a user", HandleAlertConsoleCommand); } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 650069a..2154827 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -108,7 +108,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; scene.AddCommand( - this, "load iar", + "Archiving", this, "load iar", "load iar [-m|--merge] []", "Load user inventory archive (IAR).", "-m|--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones" @@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver HandleLoadInvConsoleCommand); scene.AddCommand( - this, "save iar", + "Archiving", this, "save iar", "save iar [-h|--home=] [--noassets] [] [-c|--creators] [-v|--verbose]", "Save user inventory archive (IAR).", " is the user's first name." + Environment.NewLine -- cgit v1.1 From 6e26f17923a912c87052198ac2c220751b954a18 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 10 Mar 2012 02:13:17 +0000 Subject: minor: In IAR save, log when we start adding the control file rather than saying afterwards that we added it. --- .../Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 5238325..a26c73a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -270,12 +270,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_archiveWriter = new TarArchiveWriter(m_saveStream); + m_log.InfoFormat("[INVENTORY ARCHIVER]: Adding control file to archive."); + // Write out control file. This has to be done first so that subsequent loaders will see this file first // XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this // not sure how to fix this though, short of going with a completely different file format. m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile(options)); - m_log.InfoFormat("[INVENTORY ARCHIVER]: Added control file to archive."); - + if (inventoryFolder != null) { m_log.DebugFormat( -- cgit v1.1 From 1e4180fc931b2d07756519403ed4ae18d136906b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 17 Mar 2012 02:54:19 +0000 Subject: Clean up "save iar" help --- .../Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 2154827..ac22c3f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -124,15 +124,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "Archiving", this, "save iar", "save iar [-h|--home=] [--noassets] [] [-c|--creators] [-v|--verbose]", "Save user inventory archive (IAR).", - " is the user's first name." + Environment.NewLine - + " is the user's last name." + Environment.NewLine - + " is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine - + "-h|--home= adds the url of the profile service to the saved user information." + Environment.NewLine - + "-c|--creators preserves information about foreign creators." + Environment.NewLine - + "-v|--verbose extra debug messages." + Environment.NewLine - + "--noassets stops assets being saved to the IAR." + " is the user's first name.\n" + + " is the user's last name.\n" + + " is the path inside the user's inventory for the folder/item to be saved.\n" + " is the filesystem path at which to save the IAR." - + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), + + string.Format(" If this is not given then the filename {0} in the current directory is used.\n", DEFAULT_INV_BACKUP_FILENAME) + + "-h|--home= adds the url of the profile service to the saved user information.\n" + + "-c|--creators preserves information about foreign creators.\n" + + "-v|--verbose extra debug messages.\n" + + "--noassets stops assets being saved to the IAR.", HandleSaveInvConsoleCommand); m_aScene = scene; -- cgit v1.1 From d08ad6459a03a6a5a6a551fd2b275f1c7da94d8e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 20 Mar 2012 17:14:19 -0700 Subject: HG Friends: allow the establishment of HG friendships without requiring co-presence in the same sim. Using avatar picker, users can now search for names such as "first.last@grid.com:9000", find them, and request friendship. Friendship requests are stored if target user is offline. TESTED ON STANDALONE ONLY. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 31 ++- .../CoreModules/Avatar/Friends/HGFriendsModule.cs | 290 +++++++++++++-------- 2 files changed, 202 insertions(+), 119 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index c266fe5..f6a31b5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -550,7 +550,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends UUID principalID = new UUID(im.fromAgentID); UUID friendID = new UUID(im.toAgentID); - m_log.DebugFormat("[FRIENDS]: {0} ({1}) offered friendship to {2}", principalID, im.fromAgentName, friendID); + m_log.DebugFormat("[FRIENDS]: {0} ({1}) offered friendship to {2} ({3})", principalID, client.FirstName + client.LastName, friendID, im.fromAgentName); + + // Check that the friendship doesn't exist yet + FriendInfo[] finfos = GetFriends(principalID); + if (finfos != null) + { + FriendInfo f = GetFriend(finfos, friendID); + if (f != null) + { + client.SendAgentAlertMessage("This person is already your friend. Please delete it first if you want to reestablish the friendship.", false); + return; + } + } // This user wants to be friends with the other user. // Let's add the relation backwards, in case the other is not online @@ -561,7 +573,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } - private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im) + protected virtual bool ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im) { // !!!!!!!! This is a hack so that we don't have to keep state (transactionID/imSessionID) // We stick this agent's ID as imSession, so that it's directly available on the receiving end @@ -570,7 +582,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // Try the local sim if (LocalFriendshipOffered(friendID, im)) - return; + { + m_log.DebugFormat("[XXX]: LocalFriendshipOffered successes"); + return true; + } // The prospective friend is not here [as root]. Let's forward. PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); @@ -581,9 +596,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); + return true; } } // If the prospective friend is not online, he'll get the message upon login. + return false; } protected virtual string GetFriendshipRequesterName(UUID agentID) @@ -592,7 +609,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return (account == null) ? "Unknown" : account.FirstName + " " + account.LastName; } - private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) + protected virtual void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) { m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", client.AgentId, friendID); @@ -603,7 +620,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { StoreFriendships(client.AgentId, friendID); - // Update the local cache + // Update the local cache. RecacheFriends(client); // @@ -756,7 +773,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends #region Local - public bool LocalFriendshipOffered(UUID toID, GridInstantMessage im) + public virtual bool LocalFriendshipOffered(UUID toID, GridInstantMessage im) { IClientAPI friendClient = LocateClientObject(toID); if (friendClient != null) @@ -912,7 +929,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return FriendsService.GetFriends(client.AgentId); } - private void RecacheFriends(IClientAPI client) + protected void RecacheFriends(IClientAPI client) { // FIXME: Ideally, we want to avoid doing this here since it sits the EventManager.OnMakeRootAgent event // is on the critical path for transferring an avatar from one region to another. diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 9c53fc4..0fe1134 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -61,6 +61,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } + protected HGFriendsServicesConnector m_HGFriendsConnector = new HGFriendsServicesConnector(); + #region ISharedRegionModule public override string Name { @@ -94,6 +96,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends #endregion + protected override void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) + { + // Update the local cache. Yes, we need to do it right here + // because the HGFriendsService placed something on the DB + // from under the sim + base.OnApproveFriendRequest(client, agentID, friendID, callingCardFolders); + } + protected override bool CacheFriends(IClientAPI client) { // m_log.DebugFormat("[HGFRIENDS MODULE]: Entered CacheFriends for {0}", client.Name); @@ -183,91 +193,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting GetOnlineFriends for {0}", userID); } - //protected override void GetOnlineFriends(UUID userID, List friendList, /*collector*/ List online) - //{ - // // Let's single out the UUIs - // List localFriends = new List(); - // List foreignFriends = new List(); - // string tmp = string.Empty; - - // foreach (string s in friendList) - // { - // UUID id; - // if (UUID.TryParse(s, out id)) - // localFriends.Add(s); - // else if (Util.ParseUniversalUserIdentifier(s, out id, out tmp, out tmp, out tmp, out tmp)) - // { - // foreignFriends.Add(s); - // // add it here too, who knows maybe the foreign friends happens to be on this grid - // localFriends.Add(id.ToString()); - // } - // } - - // // OK, see who's present on this grid - // List toBeRemoved = new List(); - // PresenceInfo[] presence = PresenceService.GetAgents(localFriends.ToArray()); - // foreach (PresenceInfo pi in presence) - // { - // UUID presenceID; - // if (UUID.TryParse(pi.UserID, out presenceID)) - // { - // online.Add(presenceID); - // foreach (string s in foreignFriends) - // if (s.StartsWith(pi.UserID)) - // toBeRemoved.Add(s); - // } - // } - - // foreach (string s in toBeRemoved) - // foreignFriends.Remove(s); - - // // OK, let's send this up the stack, and leave a closure here - // // collecting online friends in other grids - // Util.FireAndForget(delegate { CollectOnlineFriendsElsewhere(userID, foreignFriends); }); - - //} - - //private void CollectOnlineFriendsElsewhere(UUID userID, List foreignFriends) - //{ - // // let's divide the friends on a per-domain basis - // Dictionary> friendsPerDomain = new Dictionary>(); - // foreach (string friend in foreignFriends) - // { - // UUID friendID; - // if (!UUID.TryParse(friend, out friendID)) - // { - // // it's a foreign friend - // string url = string.Empty, tmp = string.Empty; - // if (Util.ParseUniversalUserIdentifier(friend, out friendID, out url, out tmp, out tmp, out tmp)) - // { - // if (!friendsPerDomain.ContainsKey(url)) - // friendsPerDomain[url] = new List(); - // friendsPerDomain[url].Add(friend); - // } - // } - // } - - // // Now, call those worlds - - // foreach (KeyValuePair> kvp in friendsPerDomain) - // { - // List ids = new List(); - // foreach (string f in kvp.Value) - // ids.Add(f); - // UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key); - // List online = uConn.GetOnlineFriends(userID, ids); - // // Finally send the notifications to the user - // // this whole process may take a while, so let's check at every - // // iteration that the user is still here - // IClientAPI client = LocateClientObject(userID); - // if (client != null) - // client.SendAgentOnline(online.ToArray()); - // else - // break; - // } - - //} - protected override void StatusNotify(List friendList, UUID userID, bool online) { // m_log.DebugFormat("[HGFRIENDS MODULE]: Entering StatusNotify for {0}", userID); @@ -335,12 +260,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return true; // fid is not a UUID... - string url = string.Empty, tmp = string.Empty; - if (Util.ParseUniversalUserIdentifier(fid, out agentID, out url, out first, out last, out tmp)) + string url = string.Empty, tmp = string.Empty, f = string.Empty, l = string.Empty; + m_log.DebugFormat("[YYY]: FID {0}", fid); + if (Util.ParseUniversalUserIdentifier(fid, out agentID, out url, out f, out l, out tmp)) { - IUserManagement userMan = m_Scenes[0].RequestModuleInterface(); - userMan.AddUser(agentID, first, last, url); + m_log.DebugFormat("[YYY]: Adding user {0} {1} {2}", f, l, url); + m_uMan.AddUser(agentID, f, l, url); + string name = m_uMan.GetUserName(agentID); + string[] parts = name.Trim().Split(new char[] {' '}); + if (parts.Length == 2) + { + first = parts[0]; + last = parts[1]; + } + else + { + first = f; + last = l; + } return true; } return false; @@ -348,13 +286,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends protected override string GetFriendshipRequesterName(UUID agentID) { - // For the time being we assume that HG friendship requests can only happen - // when avies are on the same region. - IClientAPI client = LocateClientObject(agentID); - if (client != null) - return client.FirstName + " " + client.LastName; - else - return base.GetFriendshipRequesterName(agentID); + return m_uMan.GetUserName(agentID); } protected override string FriendshipMessage(string friendID) @@ -392,10 +324,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends AgentCircuitData agentClientCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); if (agentClientCircuit != null) { - string agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); + //[XXX] string agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); - finfos = FriendsService.GetFriends(agentUUI); - m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, agentUUI); + finfos = FriendsService.GetFriends(client.AgentId.ToString()); + m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, client.AgentId.ToString()); } // m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting GetFriendsFromService for {0}", client.Name); @@ -454,16 +386,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends friendIsLocal = UserManagementModule.IsLocalGridUser(friendID); } - // Are they both local users? - if (agentIsLocal && friendIsLocal) + // Is the requester a local user? + if (agentIsLocal) { // local grid users - m_log.DebugFormat("[HGFRIENDS MODULE]: Users are both local"); + m_log.DebugFormat("[HGFRIENDS MODULE]: Friendship requester is local. Storing backwards."); + base.StoreBackwards(friendID, agentID); return; } - // no provision for this temporary friendship state + // no provision for this temporary friendship state when user is not local //FriendsService.StoreFriend(friendID.ToString(), agentID.ToString(), 0); } @@ -501,12 +434,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode); agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); agentFriendService = agentClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); + RecacheFriends(agentClient); } if (friendClient != null) { friendClientCircuit = ((Scene)(friendClient.Scene)).AuthenticateHandler.GetAgentCircuitData(friendClient.CircuitCode); friendUUI = Util.ProduceUserUniversalIdentifier(friendClientCircuit); friendFriendService = friendClientCircuit.ServiceURLs["FriendsServerURI"].ToString(); + RecacheFriends(friendClient); } m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", @@ -515,14 +450,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // Generate a random 8-character hex number that will sign this friendship string secret = UUID.Random().ToString().Substring(0, 8); + string theFriendUUID = friendUUI + ";" + secret; + string agentUUID = agentUUI + ";" + secret; + if (agentIsLocal) // agent is local, 'friend' is foreigner { // This may happen when the agent returned home, in which case the friend is not there // We need to look for its information in the friends list itself + FriendInfo[] finfos = null; bool confirming = false; if (friendUUI == string.Empty) { - FriendInfo[] finfos = GetFriends(agentID); + finfos = GetFriends(agentID); foreach (FriendInfo finfo in finfos) { if (finfo.TheirFlags == -1) @@ -530,29 +469,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (finfo.Friend.StartsWith(friendID.ToString())) { friendUUI = finfo.Friend; + theFriendUUID = friendUUI; + UUID utmp = UUID.Zero; String url = String.Empty; String first = String.Empty, last = String.Empty, tmp = String.Empty; + // If it's confirming the friendship, we already have the full UUI with the secret + if (Util.ParseUniversalUserIdentifier(theFriendUUID, out utmp, out url, out first, out last, out secret)) + { + agentUUID = agentUUI + ";" + secret; + m_uMan.AddUser(utmp, first, last, url); + } confirming = true; + break; } } } - } + if (!confirming) + { + friendUUI = m_uMan.GetUserUUI(friendID); + theFriendUUID = friendUUI + ";" + secret; + } + + friendFriendService = m_uMan.GetUserServerURL(friendID, "FriendsServerURI"); - // If it's confirming the friendship, we already have the full friendUUI with the secret - string theFriendUUID = confirming ? friendUUI : friendUUI + ";" + secret; + // m_log.DebugFormat("[HGFRIENDS MODULE] HG Friendship! thisUUI={0}; friendUUI={1}; foreignThisFriendService={2}; foreignFriendFriendService={3}", + // agentUUI, friendUUI, agentFriendService, friendFriendService); + + } + + // Delete any previous friendship relations + DeletePreviousRelations(agentID, friendID); // store in the local friends service a reference to the foreign friend FriendsService.StoreFriend(agentID.ToString(), theFriendUUID, 1); // and also the converse FriendsService.StoreFriend(theFriendUUID, agentID.ToString(), 1); - if (!confirming && friendClientCircuit != null) - { + //if (!confirming) + //{ // store in the foreign friends service a reference to the local agent - HGFriendsServicesConnector friendsConn = new HGFriendsServicesConnector(friendFriendService, friendClientCircuit.SessionID, friendClientCircuit.ServiceSessionID); - friendsConn.NewFriendship(friendID, agentUUI + ";" + secret); - } + HGFriendsServicesConnector friendsConn = null; + if (friendClientCircuit != null) // the friend is here, validate session + friendsConn = new HGFriendsServicesConnector(friendFriendService, friendClientCircuit.SessionID, friendClientCircuit.ServiceSessionID); + else // the friend is not here, he initiated the request in his home world + friendsConn = new HGFriendsServicesConnector(friendFriendService); + + friendsConn.NewFriendship(friendID, agentUUID); + //} } else if (friendIsLocal) // 'friend' is local, agent is foreigner { + // Delete any previous friendship relations + DeletePreviousRelations(agentID, friendID); + // store in the local friends service a reference to the foreign agent FriendsService.StoreFriend(friendID.ToString(), agentUUI + ";" + secret, 1); // and also the converse @@ -582,6 +549,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // my brain hurts now } + private void DeletePreviousRelations(UUID a1, UUID a2) + { + // Delete any previous friendship relations + FriendInfo[] finfos = null; + FriendInfo f = null; + finfos = GetFriends(a1); + if (finfos != null) + { + f = GetFriend(finfos, a2); + if (f != null) + { + FriendsService.Delete(a1, f.Friend); + // and also the converse + FriendsService.Delete(f.Friend, a1.ToString()); + } + } + + finfos = GetFriends(a2); + if (finfos != null) + { + f = GetFriend(finfos, a1); + if (f != null) + { + FriendsService.Delete(a2, f.Friend); + // and also the converse + FriendsService.Delete(f.Friend, a2.ToString()); + } + } + } + protected override bool DeleteFriendship(UUID agentID, UUID exfriendID) { Boolean agentIsLocal = true; @@ -684,5 +681,74 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends friendConn.DeleteFriendship(foreignUser, localUser, secret); } } + + protected override bool ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im) + { + if (base.ForwardFriendshipOffer(agentID, friendID, im)) + return true; + + // OK, that didn't work, so let's try to find this user somewhere + if (!m_uMan.IsLocalGridUser(friendID)) + { + string friendsURL = m_uMan.GetUserServerURL(friendID, "FriendsServerURI"); + if (friendsURL != string.Empty) + { + m_log.DebugFormat("[HGFRIENDS MODULE]: Forwading friendship from {0} to {1} @ {2}", agentID, friendID, friendsURL); + GridRegion region = new GridRegion(); + region.ServerURI = friendsURL; + + string name = im.fromAgentName; + if (m_uMan.IsLocalGridUser(agentID)) + { + IClientAPI agentClient = LocateClientObject(agentID); + AgentCircuitData agentClientCircuit = ((Scene)(agentClient.Scene)).AuthenticateHandler.GetAgentCircuitData(agentClient.CircuitCode); + string agentHomeService = string.Empty; + try + { + agentHomeService = agentClientCircuit.ServiceURLs["HomeURI"].ToString(); + string lastname = "@" + new Uri(agentHomeService).Authority; + string firstname = im.fromAgentName.Replace(" ", "."); + name = firstname + lastname; + } + catch (KeyNotFoundException) + { + m_log.DebugFormat("[HGFRIENDS MODULE]: Key HomeURI not found for user {0}", agentID); + return false; + } + catch (NullReferenceException) + { + m_log.DebugFormat("[HGFRIENDS MODULE]: Null HomeUri for local user {0}", agentID); + return false; + } + catch (UriFormatException) + { + m_log.DebugFormat("[HGFRIENDS MODULE]: Malformed HomeUri {0} for local user {1}", agentHomeService, agentID); + return false; + } + } + + m_HGFriendsConnector.FriendshipOffered(region, agentID, friendID, im.message, name); + + return true; + } + } + + return false; + } + + public override bool LocalFriendshipOffered(UUID toID, GridInstantMessage im) + { + if (base.LocalFriendshipOffered(toID, im)) + { + if (im.fromAgentName.Contains("@")) + { + string[] parts = im.fromAgentName.Split(new char[] { '@' }); + if (parts.Length == 2) + m_uMan.AddUser(new UUID(im.fromAgentID), parts[0], "http://" + parts[1]); + } + return true; + } + return false; + } } } \ No newline at end of file -- cgit v1.1 From d49dd5573b3ba73e0a6065eada827037bb51ff39 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 20 Mar 2012 21:36:02 -0700 Subject: Removed extraneous debug messages. Added a check for UUID.Zero. --- .../CoreModules/Avatar/Friends/HGFriendsModule.cs | 39 +++++++++++++--------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 0fe1134..46b0b84 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -261,25 +261,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // fid is not a UUID... string url = string.Empty, tmp = string.Empty, f = string.Empty, l = string.Empty; - m_log.DebugFormat("[YYY]: FID {0}", fid); if (Util.ParseUniversalUserIdentifier(fid, out agentID, out url, out f, out l, out tmp)) { - m_log.DebugFormat("[YYY]: Adding user {0} {1} {2}", f, l, url); - m_uMan.AddUser(agentID, f, l, url); - - string name = m_uMan.GetUserName(agentID); - string[] parts = name.Trim().Split(new char[] {' '}); - if (parts.Length == 2) - { - first = parts[0]; - last = parts[1]; - } - else + if (!agentID.Equals(UUID.Zero)) { - first = f; - last = l; + m_uMan.AddUser(agentID, f, l, url); + + string name = m_uMan.GetUserName(agentID); + string[] parts = name.Trim().Split(new char[] { ' ' }); + if (parts.Length == 2) + { + first = parts[0]; + last = parts[1]; + } + else + { + first = f; + last = l; + } + return true; } - return true; } return false; } @@ -744,7 +745,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { string[] parts = im.fromAgentName.Split(new char[] { '@' }); if (parts.Length == 2) - m_uMan.AddUser(new UUID(im.fromAgentID), parts[0], "http://" + parts[1]); + { + string[] fl = parts[0].Trim().Split(new char[] { '.' }); + if (fl.Length == 2) + m_uMan.AddUser(new UUID(im.fromAgentID), fl[0], fl[1], "http://" + parts[1]); + else + m_uMan.AddUser(new UUID(im.fromAgentID), fl[0], "", "http://" + parts[1]); + } } return true; } -- cgit v1.1 From 1089e9b842ae359d9dcdae11145d5f329041c75e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 21 Mar 2012 08:08:12 -0700 Subject: Removed extraneous debug message --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index f6a31b5..753c0a3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -582,10 +582,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // Try the local sim if (LocalFriendshipOffered(friendID, im)) - { - m_log.DebugFormat("[XXX]: LocalFriendshipOffered successes"); return true; - } // The prospective friend is not here [as root]. Let's forward. PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); -- cgit v1.1 From d8bcb78b10faf1e4b213a7caa7ee8fcb8d10cf52 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 21 Mar 2012 09:14:17 -0700 Subject: HG Friends: pulled sim-bound notification code to HGStatusNotifier, so that we can better manage this traffic. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 2 +- .../CoreModules/Avatar/Friends/HGFriendsModule.cs | 29 +++++-------- .../CoreModules/Avatar/Friends/HGStatusNotifier.cs | 47 ++++++++++++++++++++++ 3 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 753c0a3..be767c4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -212,7 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends scene.EventManager.OnClientLogin += OnClientLogin; } - public void RegionLoaded(Scene scene) + public virtual void RegionLoaded(Scene scene) { } diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 46b0b84..f50e52b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -62,6 +62,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } protected HGFriendsServicesConnector m_HGFriendsConnector = new HGFriendsServicesConnector(); + protected HGStatusNotifier m_StatusNotifier; #region ISharedRegionModule public override string Name @@ -78,6 +79,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends scene.RegisterModuleInterface(this); } + public override void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + if (m_StatusNotifier == null) + m_StatusNotifier = new HGStatusNotifier(this); + } + #endregion #region IFriendsSimConnector @@ -230,25 +239,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (friendsPerDomain.ContainsKey("local")) base.StatusNotify(friendsPerDomain["local"], userID, online); - foreach (KeyValuePair> kvp in friendsPerDomain) - { - if (kvp.Key != "local") - { - // For the others, call the user agent service - List ids = new List(); - foreach (FriendInfo f in kvp.Value) - ids.Add(f.Friend); - UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key); - List friendsOnline = uConn.StatusNotification(ids, userID, online); - - if (online && friendsOnline.Count > 0) - { - IClientAPI client = LocateClientObject(userID); - if (client != null) - client.SendAgentOnline(friendsOnline.ToArray()); - } - } - } + m_StatusNotifier.Notify(userID, friendsPerDomain, online); // m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting StatusNotify for {0}", userID); } diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs new file mode 100644 index 0000000..62d54e4 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors.Hypergrid; +using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; + +using OpenMetaverse; + +namespace OpenSim.Region.CoreModules.Avatar.Friends +{ + public class HGStatusNotifier + { + private HGFriendsModule m_FriendsModule; + + public HGStatusNotifier(HGFriendsModule friendsModule) + { + m_FriendsModule = friendsModule; + } + + public void Notify(UUID userID, Dictionary> friendsPerDomain, bool online) + { + foreach (KeyValuePair> kvp in friendsPerDomain) + { + if (kvp.Key != "local") + { + // For the others, call the user agent service + List ids = new List(); + foreach (FriendInfo f in kvp.Value) + ids.Add(f.Friend); + UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key); + List friendsOnline = uConn.StatusNotification(ids, userID, online); + + if (online && friendsOnline.Count > 0) + { + IClientAPI client = m_FriendsModule.LocateClientObject(userID); + if (client != null) + client.SendAgentOnline(friendsOnline.ToArray()); + } + } + } + } + } +} -- cgit v1.1 From 4a9ca3ca8ff18f4fcf05c3983db5e6b1d49c97ee Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 21 Mar 2012 10:35:06 -0700 Subject: HG Friends: reroute the status notifications to the HGFriends service, so that they can scale better. They were previously being handled by the UAS; that is still there, but it's now obsolete and will be removed in a future release. --- .../CoreModules/Avatar/Friends/HGFriendsModule.cs | 2 +- .../CoreModules/Avatar/Friends/HGStatusNotifier.cs | 31 +++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index f50e52b..e50a84a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); IUserManagement m_uMan; - IUserManagement UserManagementModule + public IUserManagement UserManagementModule { get { diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs index 62d54e4..61c6a30 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; @@ -10,10 +11,14 @@ using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; using OpenMetaverse; +using log4net; + namespace OpenSim.Region.CoreModules.Avatar.Friends { public class HGStatusNotifier { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private HGFriendsModule m_FriendsModule; public HGStatusNotifier(HGFriendsModule friendsModule) @@ -31,14 +36,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends List ids = new List(); foreach (FriendInfo f in kvp.Value) ids.Add(f.Friend); - UserAgentServiceConnector uConn = new UserAgentServiceConnector(kvp.Key); - List friendsOnline = uConn.StatusNotification(ids, userID, online); - if (online && friendsOnline.Count > 0) + if (ids.Count == 0) + continue; // no one to notify. caller don't do this + + m_log.DebugFormat("[HG STATUS NOTIFIER]: Notifying {0} friends in {1}", ids.Count, kvp.Key); + // ASSUMPTION: we assume that all users for one home domain + // have exactly the same set of service URLs. + // If this is ever not true, we need to change this. + UUID friendID = UUID.Zero; String tmp = String.Empty; + if (Util.ParseUniversalUserIdentifier(ids[0], out friendID, out tmp, out tmp, out tmp, out tmp)) { - IClientAPI client = m_FriendsModule.LocateClientObject(userID); - if (client != null) - client.SendAgentOnline(friendsOnline.ToArray()); + string friendsServerURI = m_FriendsModule.UserManagementModule.GetUserServerURL(friendID, "FriendsServerURI"); + HGFriendsServicesConnector fConn = new HGFriendsServicesConnector(friendsServerURI); + + List friendsOnline = fConn.StatusNotification(ids, userID, online); + + if (online && friendsOnline.Count > 0) + { + IClientAPI client = m_FriendsModule.LocateClientObject(userID); + if (client != null) + client.SendAgentOnline(friendsOnline.ToArray()); + } } } } -- cgit v1.1 From df624c13c98b06d57311c1d93ecbd4790553f3b3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 22 Mar 2012 15:08:57 -0700 Subject: HG Friends: don't notify if the server isn't there. --- .../CoreModules/Avatar/Friends/HGStatusNotifier.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs index 61c6a30..1fa4dd6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGStatusNotifier.cs @@ -48,15 +48,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (Util.ParseUniversalUserIdentifier(ids[0], out friendID, out tmp, out tmp, out tmp, out tmp)) { string friendsServerURI = m_FriendsModule.UserManagementModule.GetUserServerURL(friendID, "FriendsServerURI"); - HGFriendsServicesConnector fConn = new HGFriendsServicesConnector(friendsServerURI); + if (friendsServerURI != string.Empty) + { + HGFriendsServicesConnector fConn = new HGFriendsServicesConnector(friendsServerURI); - List friendsOnline = fConn.StatusNotification(ids, userID, online); + List friendsOnline = fConn.StatusNotification(ids, userID, online); - if (online && friendsOnline.Count > 0) - { - IClientAPI client = m_FriendsModule.LocateClientObject(userID); - if (client != null) - client.SendAgentOnline(friendsOnline.ToArray()); + if (online && friendsOnline.Count > 0) + { + IClientAPI client = m_FriendsModule.LocateClientObject(userID); + if (client != null) + client.SendAgentOnline(friendsOnline.ToArray()); + } } } } -- cgit v1.1