diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 78 |
1 files changed, 76 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 0590716..8e32fcc 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -214,6 +214,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
214 | 214 | ||
215 | public virtual void RegionLoaded(Scene scene) | 215 | public virtual void RegionLoaded(Scene scene) |
216 | { | 216 | { |
217 | scene.AddCommand( | ||
218 | "Friends", this, "friends show cache", | ||
219 | "friends show cache [<first-name> <last-name>]", | ||
220 | "Show the friends cache for the given user", | ||
221 | HandleFriendsShowCacheCommand); | ||
217 | } | 222 | } |
218 | 223 | ||
219 | public void RemoveRegion(Scene scene) | 224 | public void RemoveRegion(Scene scene) |
@@ -903,7 +908,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
903 | /// Get friends from local cache only | 908 | /// Get friends from local cache only |
904 | /// </summary> | 909 | /// </summary> |
905 | /// <param name="agentID"></param> | 910 | /// <param name="agentID"></param> |
906 | /// <returns></returns> | 911 | /// <returns> |
912 | /// An empty array if the user has no friends or friends have not been cached. | ||
913 | /// </returns> | ||
907 | protected FriendInfo[] GetFriends(UUID agentID) | 914 | protected FriendInfo[] GetFriends(UUID agentID) |
908 | { | 915 | { |
909 | UserFriendData friendsData; | 916 | UserFriendData friendsData; |
@@ -952,6 +959,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
952 | } | 959 | } |
953 | } | 960 | } |
954 | 961 | ||
962 | /// <summary> | ||
963 | /// Are friends cached on this simulator for a particular user? | ||
964 | /// </summary> | ||
965 | /// <param name="userID"></param> | ||
966 | /// <returns></returns> | ||
967 | protected bool AreFriendsCached(UUID userID) | ||
968 | { | ||
969 | lock (m_Friends) | ||
970 | return m_Friends.ContainsKey(userID); | ||
971 | } | ||
972 | |||
955 | protected virtual bool StoreRights(UUID agentID, UUID friendID, int rights) | 973 | protected virtual bool StoreRights(UUID agentID, UUID friendID, int rights) |
956 | { | 974 | { |
957 | FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), rights); | 975 | FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), rights); |
@@ -977,5 +995,61 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
977 | } | 995 | } |
978 | 996 | ||
979 | #endregion | 997 | #endregion |
998 | |||
999 | protected void HandleFriendsShowCacheCommand(string module, string[] cmd) | ||
1000 | { | ||
1001 | if (cmd.Length != 5) | ||
1002 | { | ||
1003 | MainConsole.Instance.OutputFormat("Usage: friends show cache [<first-name> <last-name>]"); | ||
1004 | return; | ||
1005 | } | ||
1006 | |||
1007 | string firstName = cmd[3]; | ||
1008 | string lastName = cmd[4]; | ||
1009 | |||
1010 | IUserManagement umModule = m_Scenes[0].RequestModuleInterface<IUserManagement>(); | ||
1011 | UUID userId = umModule.GetUserIdByName(firstName, lastName); | ||
1012 | |||
1013 | // UserAccount ua | ||
1014 | // = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, firstName, lastName); | ||
1015 | |||
1016 | if (userId == UUID.Zero) | ||
1017 | { | ||
1018 | MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName); | ||
1019 | return; | ||
1020 | } | ||
1021 | |||
1022 | if (!AreFriendsCached(userId)) | ||
1023 | { | ||
1024 | MainConsole.Instance.OutputFormat("No friends cached on this simulator for {0} {1}", firstName, lastName); | ||
1025 | return; | ||
1026 | } | ||
1027 | |||
1028 | MainConsole.Instance.OutputFormat("Cached friends for {0} {1}:", firstName, lastName); | ||
1029 | |||
1030 | MainConsole.Instance.OutputFormat("UUID\n"); | ||
1031 | |||
1032 | FriendInfo[] friends = GetFriends(userId); | ||
1033 | |||
1034 | foreach (FriendInfo friend in friends) | ||
1035 | { | ||
1036 | // MainConsole.Instance.OutputFormat(friend.PrincipalID.ToString()); | ||
1037 | |||
1038 | // string friendFirstName, friendLastName; | ||
1039 | // | ||
1040 | // UserAccount friendUa | ||
1041 | // = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friend.PrincipalID); | ||
1042 | |||
1043 | UUID friendId; | ||
1044 | string friendName; | ||
1045 | |||
1046 | if (UUID.TryParse(friend.Friend, out friendId)) | ||
1047 | friendName = umModule.GetUserName(friendId); | ||
1048 | else | ||
1049 | friendName = friend.Friend; | ||
1050 | |||
1051 | MainConsole.Instance.OutputFormat("{0} {1} {2}", friendName, friend.MyFlags, friend.TheirFlags); | ||
1052 | } | ||
1053 | } | ||
980 | } | 1054 | } |
981 | } | 1055 | } \ No newline at end of file |