aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDiva Canto2012-03-27 19:09:03 -0700
committerDiva Canto2012-03-27 19:09:03 -0700
commit4007f62158601a0441977bc89a9e5a1469b782ce (patch)
tree841d0e0704eb48aa0c7b723ea888c41d5b16baf0 /OpenSim/Region
parentHG: Switch root folders from under the viewer. Towards HG 2.0. This is guarde... (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-4007f62158601a0441977bc89a9e5a1469b782ce.zip
opensim-SC-4007f62158601a0441977bc89a9e5a1469b782ce.tar.gz
opensim-SC-4007f62158601a0441977bc89a9e5a1469b782ce.tar.bz2
opensim-SC-4007f62158601a0441977bc89a9e5a1469b782ce.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs78
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs29
-rw-r--r--OpenSim/Region/Framework/Interfaces/IUserManagement.cs15
3 files changed, 120 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index be767c4..d1a1af0 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)
@@ -890,7 +895,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
890 /// Get friends from local cache only 895 /// Get friends from local cache only
891 /// </summary> 896 /// </summary>
892 /// <param name="agentID"></param> 897 /// <param name="agentID"></param>
893 /// <returns></returns> 898 /// <returns>
899 /// An empty array if the user has no friends or friends have not been cached.
900 /// </returns>
894 protected FriendInfo[] GetFriends(UUID agentID) 901 protected FriendInfo[] GetFriends(UUID agentID)
895 { 902 {
896 UserFriendData friendsData; 903 UserFriendData friendsData;
@@ -939,6 +946,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
939 } 946 }
940 } 947 }
941 948
949 /// <summary>
950 /// Are friends cached on this simulator for a particular user?
951 /// </summary>
952 /// <param name="userID"></param>
953 /// <returns></returns>
954 protected bool AreFriendsCached(UUID userID)
955 {
956 lock (m_Friends)
957 return m_Friends.ContainsKey(userID);
958 }
959
942 protected virtual bool StoreRights(UUID agentID, UUID friendID, int rights) 960 protected virtual bool StoreRights(UUID agentID, UUID friendID, int rights)
943 { 961 {
944 FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), rights); 962 FriendsService.StoreFriend(agentID.ToString(), friendID.ToString(), rights);
@@ -964,5 +982,61 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
964 } 982 }
965 983
966 #endregion 984 #endregion
985
986 protected void HandleFriendsShowCacheCommand(string module, string[] cmd)
987 {
988 if (cmd.Length != 5)
989 {
990 MainConsole.Instance.OutputFormat("Usage: friends show cache [<first-name> <last-name>]");
991 return;
992 }
993
994 string firstName = cmd[3];
995 string lastName = cmd[4];
996
997 IUserManagement umModule = m_Scenes[0].RequestModuleInterface<IUserManagement>();
998 UUID userId = umModule.GetUserIdByName(firstName, lastName);
999
1000// UserAccount ua
1001// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, firstName, lastName);
1002
1003 if (userId == UUID.Zero)
1004 {
1005 MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
1006 return;
1007 }
1008
1009 if (!AreFriendsCached(userId))
1010 {
1011 MainConsole.Instance.OutputFormat("No friends cached on this simulator for {0} {1}", firstName, lastName);
1012 return;
1013 }
1014
1015 MainConsole.Instance.OutputFormat("Cached friends for {0} {1}:", firstName, lastName);
1016
1017 MainConsole.Instance.OutputFormat("UUID\n");
1018
1019 FriendInfo[] friends = GetFriends(userId);
1020
1021 foreach (FriendInfo friend in friends)
1022 {
1023// MainConsole.Instance.OutputFormat(friend.PrincipalID.ToString());
1024
1025// string friendFirstName, friendLastName;
1026//
1027// UserAccount friendUa
1028// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friend.PrincipalID);
1029
1030 UUID friendId;
1031 string friendName;
1032
1033 if (UUID.TryParse(friend.Friend, out friendId))
1034 friendName = umModule.GetUserName(friendId);
1035 else
1036 friendName = friend.Friend;
1037
1038 MainConsole.Instance.OutputFormat("{0} {1} {2}", friendName, friend.MyFlags, friend.TheirFlags);
1039 }
1040 }
967 } 1041 }
968} 1042} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 0397478..f4ed67b 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -297,6 +297,35 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
297 297
298 #region IUserManagement 298 #region IUserManagement
299 299
300 public UUID GetUserIdByName(string name)
301 {
302 string[] parts = name.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
303 if (parts.Length < 2)
304 throw new Exception("Name must have 2 components");
305
306 return GetUserIdByName(parts[0], parts[1]);
307 }
308
309 public UUID GetUserIdByName(string firstName, string lastName)
310 {
311 // TODO: Optimize for reverse lookup if this gets used by non-console commands.
312 lock (m_UserCache)
313 {
314 foreach (UserData user in m_UserCache.Values)
315 {
316 if (user.FirstName == firstName && user.LastName == lastName)
317 return user.Id;
318 }
319 }
320
321 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
322
323 if (account != null)
324 return account.PrincipalID;
325
326 return UUID.Zero;
327 }
328
300 public string GetUserName(UUID uuid) 329 public string GetUserName(UUID uuid)
301 { 330 {
302 string[] names = GetUserNames(uuid); 331 string[] names = GetUserNames(uuid);
diff --git a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs
index bfb8369..24cd069 100644
--- a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs
+++ b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs
@@ -16,6 +16,21 @@ namespace OpenSim.Region.Framework.Interfaces
16 string GetUserServerURL(UUID uuid, string serverType); 16 string GetUserServerURL(UUID uuid, string serverType);
17 17
18 /// <summary> 18 /// <summary>
19 /// Get user ID by the given name.
20 /// </summary>
21 /// <param name="name"></param>
22 /// <returns>UUID.Zero if no user with that name is found or if the name is "Unknown User"</returns>
23 UUID GetUserIdByName(string name);
24
25 /// <summary>
26 /// Get user ID by the given name.
27 /// </summary>
28 /// <param name="firstName"></param>
29 /// <param name="lastName"></param>
30 /// <returns>UUID.Zero if no user with that name is found or if the name is "Unknown User"</returns>
31 UUID GetUserIdByName(string firstName, string lastName);
32
33 /// <summary>
19 /// Add a user. 34 /// Add a user.
20 /// </summary> 35 /// </summary>
21 /// <remarks> 36 /// <remarks>