diff options
Diffstat (limited to '')
4 files changed, 205 insertions, 97 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 9d7012e..37e6600 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -213,14 +213,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
213 | scene.EventManager.OnClientLogin += OnClientLogin; | 213 | scene.EventManager.OnClientLogin += OnClientLogin; |
214 | } | 214 | } |
215 | 215 | ||
216 | public virtual void RegionLoaded(Scene scene) | 216 | public virtual void RegionLoaded(Scene scene) {} |
217 | { | ||
218 | scene.AddCommand( | ||
219 | "Friends", this, "friends show cache", | ||
220 | "friends show cache [<first-name> <last-name>]", | ||
221 | "Show the friends cache for the given user", | ||
222 | HandleFriendsShowCacheCommand); | ||
223 | } | ||
224 | 217 | ||
225 | public void RemoveRegion(Scene scene) | 218 | public void RemoveRegion(Scene scene) |
226 | { | 219 | { |
@@ -244,7 +237,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
244 | 237 | ||
245 | public virtual int GetRightsGrantedByFriend(UUID principalID, UUID friendID) | 238 | public virtual int GetRightsGrantedByFriend(UUID principalID, UUID friendID) |
246 | { | 239 | { |
247 | FriendInfo[] friends = GetFriends(principalID); | 240 | FriendInfo[] friends = GetFriendsFromCache(principalID); |
248 | FriendInfo finfo = GetFriend(friends, friendID); | 241 | FriendInfo finfo = GetFriend(friends, friendID); |
249 | if (finfo != null) | 242 | if (finfo != null) |
250 | { | 243 | { |
@@ -362,7 +355,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
362 | 355 | ||
363 | // Send outstanding friendship offers | 356 | // Send outstanding friendship offers |
364 | List<string> outstanding = new List<string>(); | 357 | List<string> outstanding = new List<string>(); |
365 | FriendInfo[] friends = GetFriends(agentID); | 358 | FriendInfo[] friends = GetFriendsFromCache(agentID); |
366 | foreach (FriendInfo fi in friends) | 359 | foreach (FriendInfo fi in friends) |
367 | { | 360 | { |
368 | if (fi.TheirFlags == -1) | 361 | if (fi.TheirFlags == -1) |
@@ -419,7 +412,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
419 | { | 412 | { |
420 | List<string> friendList = new List<string>(); | 413 | List<string> friendList = new List<string>(); |
421 | 414 | ||
422 | FriendInfo[] friends = GetFriends(userID); | 415 | FriendInfo[] friends = GetFriendsFromCache(userID); |
423 | foreach (FriendInfo fi in friends) | 416 | foreach (FriendInfo fi in friends) |
424 | { | 417 | { |
425 | if (((fi.TheirFlags & (int)FriendRights.CanSeeOnline) != 0) && (fi.TheirFlags != -1)) | 418 | if (((fi.TheirFlags & (int)FriendRights.CanSeeOnline) != 0) && (fi.TheirFlags != -1)) |
@@ -492,7 +485,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
492 | /// <param name="online"></param> | 485 | /// <param name="online"></param> |
493 | private void StatusChange(UUID agentID, bool online) | 486 | private void StatusChange(UUID agentID, bool online) |
494 | { | 487 | { |
495 | FriendInfo[] friends = GetFriends(agentID); | 488 | FriendInfo[] friends = GetFriendsFromCache(agentID); |
496 | if (friends.Length > 0) | 489 | if (friends.Length > 0) |
497 | { | 490 | { |
498 | List<FriendInfo> friendList = new List<FriendInfo>(); | 491 | List<FriendInfo> friendList = new List<FriendInfo>(); |
@@ -564,7 +557,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
564 | m_log.DebugFormat("[FRIENDS]: {0} ({1}) offered friendship to {2} ({3})", principalID, client.FirstName + client.LastName, friendID, im.fromAgentName); | 557 | m_log.DebugFormat("[FRIENDS]: {0} ({1}) offered friendship to {2} ({3})", principalID, client.FirstName + client.LastName, friendID, im.fromAgentName); |
565 | 558 | ||
566 | // Check that the friendship doesn't exist yet | 559 | // Check that the friendship doesn't exist yet |
567 | FriendInfo[] finfos = GetFriends(principalID); | 560 | FriendInfo[] finfos = GetFriendsFromCache(principalID); |
568 | if (finfos != null) | 561 | if (finfos != null) |
569 | { | 562 | { |
570 | FriendInfo f = GetFriend(finfos, friendID); | 563 | FriendInfo f = GetFriend(finfos, friendID); |
@@ -729,7 +722,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
729 | "[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", | 722 | "[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", |
730 | requester, rights, friendID); | 723 | requester, rights, friendID); |
731 | 724 | ||
732 | FriendInfo[] friends = GetFriends(requester); | 725 | FriendInfo[] friends = GetFriendsFromCache(requester); |
733 | if (friends.Length == 0) | 726 | if (friends.Length == 0) |
734 | { | 727 | { |
735 | return; | 728 | return; |
@@ -915,20 +908,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
915 | #endregion | 908 | #endregion |
916 | 909 | ||
917 | #region Get / Set friends in several flavours | 910 | #region Get / Set friends in several flavours |
918 | /// <summary> | 911 | |
919 | /// Get friends from local cache only | 912 | public FriendInfo[] GetFriendsFromCache(UUID userID) |
920 | /// </summary> | ||
921 | /// <param name="agentID"></param> | ||
922 | /// <returns> | ||
923 | /// An empty array if the user has no friends or friends have not been cached. | ||
924 | /// </returns> | ||
925 | protected FriendInfo[] GetFriends(UUID agentID) | ||
926 | { | 913 | { |
927 | UserFriendData friendsData; | 914 | UserFriendData friendsData; |
928 | 915 | ||
929 | lock (m_Friends) | 916 | lock (m_Friends) |
930 | { | 917 | { |
931 | if (m_Friends.TryGetValue(agentID, out friendsData)) | 918 | if (m_Friends.TryGetValue(userID, out friendsData)) |
932 | return friendsData.Friends; | 919 | return friendsData.Friends; |
933 | } | 920 | } |
934 | 921 | ||
@@ -946,7 +933,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
946 | // Update local cache | 933 | // Update local cache |
947 | lock (m_Friends) | 934 | lock (m_Friends) |
948 | { | 935 | { |
949 | FriendInfo[] friends = GetFriends(friendID); | 936 | FriendInfo[] friends = GetFriendsFromCache(friendID); |
950 | FriendInfo finfo = GetFriend(friends, userID); | 937 | FriendInfo finfo = GetFriend(friends, userID); |
951 | finfo.TheirFlags = rights; | 938 | finfo.TheirFlags = rights; |
952 | } | 939 | } |
@@ -970,12 +957,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
970 | } | 957 | } |
971 | } | 958 | } |
972 | 959 | ||
973 | /// <summary> | 960 | public bool AreFriendsCached(UUID userID) |
974 | /// Are friends cached on this simulator for a particular user? | ||
975 | /// </summary> | ||
976 | /// <param name="userID"></param> | ||
977 | /// <returns></returns> | ||
978 | protected bool AreFriendsCached(UUID userID) | ||
979 | { | 961 | { |
980 | lock (m_Friends) | 962 | lock (m_Friends) |
981 | return m_Friends.ContainsKey(userID); | 963 | return m_Friends.ContainsKey(userID); |
@@ -1006,61 +988,5 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
1006 | } | 988 | } |
1007 | 989 | ||
1008 | #endregion | 990 | #endregion |
1009 | |||
1010 | protected void HandleFriendsShowCacheCommand(string module, string[] cmd) | ||
1011 | { | ||
1012 | if (cmd.Length != 5) | ||
1013 | { | ||
1014 | MainConsole.Instance.OutputFormat("Usage: friends show cache [<first-name> <last-name>]"); | ||
1015 | return; | ||
1016 | } | ||
1017 | |||
1018 | string firstName = cmd[3]; | ||
1019 | string lastName = cmd[4]; | ||
1020 | |||
1021 | IUserManagement umModule = m_Scenes[0].RequestModuleInterface<IUserManagement>(); | ||
1022 | UUID userId = umModule.GetUserIdByName(firstName, lastName); | ||
1023 | |||
1024 | // UserAccount ua | ||
1025 | // = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, firstName, lastName); | ||
1026 | |||
1027 | if (userId == UUID.Zero) | ||
1028 | { | ||
1029 | MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName); | ||
1030 | return; | ||
1031 | } | ||
1032 | |||
1033 | if (!AreFriendsCached(userId)) | ||
1034 | { | ||
1035 | MainConsole.Instance.OutputFormat("No friends cached on this simulator for {0} {1}", firstName, lastName); | ||
1036 | return; | ||
1037 | } | ||
1038 | |||
1039 | MainConsole.Instance.OutputFormat("Cached friends for {0} {1}:", firstName, lastName); | ||
1040 | |||
1041 | MainConsole.Instance.OutputFormat("UUID\n"); | ||
1042 | |||
1043 | FriendInfo[] friends = GetFriends(userId); | ||
1044 | |||
1045 | foreach (FriendInfo friend in friends) | ||
1046 | { | ||
1047 | // MainConsole.Instance.OutputFormat(friend.PrincipalID.ToString()); | ||
1048 | |||
1049 | // string friendFirstName, friendLastName; | ||
1050 | // | ||
1051 | // UserAccount friendUa | ||
1052 | // = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friend.PrincipalID); | ||
1053 | |||
1054 | UUID friendId; | ||
1055 | string friendName; | ||
1056 | |||
1057 | if (UUID.TryParse(friend.Friend, out friendId)) | ||
1058 | friendName = umModule.GetUserName(friendId); | ||
1059 | else | ||
1060 | friendName = friend.Friend; | ||
1061 | |||
1062 | MainConsole.Instance.OutputFormat("{0} {1} {2}", friendName, friend.MyFlags, friend.TheirFlags); | ||
1063 | } | ||
1064 | } | ||
1065 | } | 991 | } |
1066 | } | 992 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index b666dae..d3a3ee4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs | |||
@@ -163,7 +163,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
163 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId); | 163 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId); |
164 | if (account == null) // foreign | 164 | if (account == null) // foreign |
165 | { | 165 | { |
166 | FriendInfo[] friends = GetFriends(client.AgentId); | 166 | FriendInfo[] friends = GetFriendsFromCache(client.AgentId); |
167 | foreach (FriendInfo f in friends) | 167 | foreach (FriendInfo f in friends) |
168 | { | 168 | { |
169 | client.SendChangeUserRights(new UUID(f.Friend), client.AgentId, f.TheirFlags); | 169 | client.SendChangeUserRights(new UUID(f.Friend), client.AgentId, f.TheirFlags); |
@@ -346,7 +346,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
346 | 346 | ||
347 | if (agentIsLocal) // agent is local, friend is foreigner | 347 | if (agentIsLocal) // agent is local, friend is foreigner |
348 | { | 348 | { |
349 | FriendInfo[] finfos = GetFriends(agentID); | 349 | FriendInfo[] finfos = GetFriendsFromCache(agentID); |
350 | FriendInfo finfo = GetFriend(finfos, friendID); | 350 | FriendInfo finfo = GetFriend(finfos, friendID); |
351 | if (finfo != null) | 351 | if (finfo != null) |
352 | { | 352 | { |
@@ -453,7 +453,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
453 | bool confirming = false; | 453 | bool confirming = false; |
454 | if (friendUUI == string.Empty) | 454 | if (friendUUI == string.Empty) |
455 | { | 455 | { |
456 | finfos = GetFriends(agentID); | 456 | finfos = GetFriendsFromCache(agentID); |
457 | foreach (FriendInfo finfo in finfos) | 457 | foreach (FriendInfo finfo in finfos) |
458 | { | 458 | { |
459 | if (finfo.TheirFlags == -1) | 459 | if (finfo.TheirFlags == -1) |
@@ -546,7 +546,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
546 | // Delete any previous friendship relations | 546 | // Delete any previous friendship relations |
547 | FriendInfo[] finfos = null; | 547 | FriendInfo[] finfos = null; |
548 | FriendInfo f = null; | 548 | FriendInfo f = null; |
549 | finfos = GetFriends(a1); | 549 | finfos = GetFriendsFromCache(a1); |
550 | if (finfos != null) | 550 | if (finfos != null) |
551 | { | 551 | { |
552 | f = GetFriend(finfos, a2); | 552 | f = GetFriend(finfos, a2); |
@@ -558,7 +558,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
558 | } | 558 | } |
559 | } | 559 | } |
560 | 560 | ||
561 | finfos = GetFriends(a2); | 561 | finfos = GetFriendsFromCache(a2); |
562 | if (finfos != null) | 562 | if (finfos != null) |
563 | { | 563 | { |
564 | f = GetFriend(finfos, a1); | 564 | f = GetFriend(finfos, a1); |
@@ -595,7 +595,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
595 | if (agentIsLocal) // agent is local, 'friend' is foreigner | 595 | if (agentIsLocal) // agent is local, 'friend' is foreigner |
596 | { | 596 | { |
597 | // We need to look for its information in the friends list itself | 597 | // We need to look for its information in the friends list itself |
598 | FriendInfo[] finfos = GetFriends(agentID); | 598 | FriendInfo[] finfos = GetFriendsFromCache(agentID); |
599 | FriendInfo finfo = GetFriend(finfos, exfriendID); | 599 | FriendInfo finfo = GetFriend(finfos, exfriendID); |
600 | if (finfo != null) | 600 | if (finfo != null) |
601 | { | 601 | { |
@@ -639,7 +639,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
639 | private string GetUUI(UUID localUser, UUID foreignUser) | 639 | private string GetUUI(UUID localUser, UUID foreignUser) |
640 | { | 640 | { |
641 | // Let's see if the user is here by any chance | 641 | // Let's see if the user is here by any chance |
642 | FriendInfo[] finfos = GetFriends(localUser); | 642 | FriendInfo[] finfos = GetFriendsFromCache(localUser); |
643 | if (finfos != EMPTY_FRIENDS) // friend is here, cool | 643 | if (finfos != EMPTY_FRIENDS) // friend is here, cool |
644 | { | 644 | { |
645 | FriendInfo finfo = GetFriend(finfos, foreignUser); | 645 | FriendInfo finfo = GetFriend(finfos, foreignUser); |
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs index 10bef1e..7e87006 100644 --- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs | |||
@@ -25,15 +25,32 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | ||
28 | using OpenMetaverse; | 29 | using OpenMetaverse; |
29 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
30 | using System.Collections.Generic; | 31 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; |
31 | 32 | ||
32 | namespace OpenSim.Region.Framework.Interfaces | 33 | namespace OpenSim.Region.Framework.Interfaces |
33 | { | 34 | { |
34 | public interface IFriendsModule | 35 | public interface IFriendsModule |
35 | { | 36 | { |
36 | /// <summary> | 37 | /// <summary> |
38 | /// Are friends cached on this simulator for a particular user? | ||
39 | /// </summary> | ||
40 | /// <param name="userID"></param> | ||
41 | /// <returns></returns> | ||
42 | bool AreFriendsCached(UUID userID); | ||
43 | |||
44 | /// <summary> | ||
45 | /// Get friends from local cache only | ||
46 | /// </summary> | ||
47 | /// <param name="userID"></param> | ||
48 | /// <returns> | ||
49 | /// An empty array if the user has no friends or friends have not been cached. | ||
50 | /// </returns> | ||
51 | FriendInfo[] GetFriendsFromCache(UUID userID); | ||
52 | |||
53 | /// <summary> | ||
37 | /// Add a friendship between two users. | 54 | /// Add a friendship between two users. |
38 | /// </summary> | 55 | /// </summary> |
39 | /// <remarks> | 56 | /// <remarks> |
@@ -58,10 +75,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
58 | /// <summary> | 75 | /// <summary> |
59 | /// Get permissions granted by a friend. | 76 | /// Get permissions granted by a friend. |
60 | /// </summary> | 77 | /// </summary> |
61 | /// <param name="PrincipalID">The user.</param> | 78 | /// <param name="userID">The user.</param> |
62 | /// <param name="FriendID">The friend that granted.</param> | 79 | /// <param name="friendID">The friend that granted.</param> |
63 | /// <returns>The permissions. These come from the FriendRights enum.</returns> | 80 | /// <returns>The permissions. These come from the FriendRights enum.</returns> |
64 | int GetRightsGrantedByFriend(UUID PrincipalID, UUID FriendID); | 81 | int GetRightsGrantedByFriend(UUID userID, UUID friendID); |
65 | 82 | ||
66 | /// <summary> | 83 | /// <summary> |
67 | /// Grant permissions for a friend. | 84 | /// Grant permissions for a friend. |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs new file mode 100644 index 0000000..2bcb8a7 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs | |||
@@ -0,0 +1,165 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Reflection; | ||
32 | using System.Text; | ||
33 | using log4net; | ||
34 | using Mono.Addins; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Console; | ||
39 | using OpenSim.Framework.Statistics; | ||
40 | using OpenSim.Region.ClientStack.LindenUDP; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; | ||
44 | |||
45 | namespace OpenSim.Region.OptionalModules.Avatar.Friends | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// A module that just holds commands for inspecting avatar appearance. | ||
49 | /// </summary> | ||
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FriendsCommandModule")] | ||
51 | public class FriendsCommandsModule : ISharedRegionModule | ||
52 | { | ||
53 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | |||
55 | private Scene m_scene; | ||
56 | private IFriendsModule m_friendsModule; | ||
57 | private IUserManagement m_userManagementModule; | ||
58 | |||
59 | // private IAvatarFactoryModule m_avatarFactory; | ||
60 | |||
61 | public string Name { get { return "Appearance Information Module"; } } | ||
62 | |||
63 | public Type ReplaceableInterface { get { return null; } } | ||
64 | |||
65 | public void Initialise(IConfigSource source) | ||
66 | { | ||
67 | // m_log.DebugFormat("[FRIENDS COMMAND MODULE]: INITIALIZED MODULE"); | ||
68 | } | ||
69 | |||
70 | public void PostInitialise() | ||
71 | { | ||
72 | // m_log.DebugFormat("[FRIENDS COMMAND MODULE]: POST INITIALIZED MODULE"); | ||
73 | } | ||
74 | |||
75 | public void Close() | ||
76 | { | ||
77 | // m_log.DebugFormat("[FRIENDS COMMAND MODULE]: CLOSED MODULE"); | ||
78 | } | ||
79 | |||
80 | public void AddRegion(Scene scene) | ||
81 | { | ||
82 | // m_log.DebugFormat("[FRIENDS COMMANDO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); | ||
83 | } | ||
84 | |||
85 | public void RemoveRegion(Scene scene) | ||
86 | { | ||
87 | // m_log.DebugFormat("[FRIENDS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | ||
88 | } | ||
89 | |||
90 | public void RegionLoaded(Scene scene) | ||
91 | { | ||
92 | // m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); | ||
93 | |||
94 | if (m_scene == null) | ||
95 | m_scene = scene; | ||
96 | |||
97 | m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | ||
98 | m_userManagementModule = m_scene.RequestModuleInterface<IUserManagement>(); | ||
99 | |||
100 | if (m_friendsModule != null && m_userManagementModule != null) | ||
101 | { | ||
102 | m_scene.AddCommand( | ||
103 | "Friends", this, "friends show cache", | ||
104 | "friends show cache [<first-name> <last-name>]", | ||
105 | "Show the friends cache for the given user", | ||
106 | HandleFriendsShowCacheCommand); | ||
107 | } | ||
108 | } | ||
109 | |||
110 | protected void HandleFriendsShowCacheCommand(string module, string[] cmd) | ||
111 | { | ||
112 | if (cmd.Length != 5) | ||
113 | { | ||
114 | MainConsole.Instance.OutputFormat("Usage: friends show cache [<first-name> <last-name>]"); | ||
115 | return; | ||
116 | } | ||
117 | |||
118 | string firstName = cmd[3]; | ||
119 | string lastName = cmd[4]; | ||
120 | |||
121 | UUID userId = m_userManagementModule.GetUserIdByName(firstName, lastName); | ||
122 | |||
123 | // UserAccount ua | ||
124 | // = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, firstName, lastName); | ||
125 | |||
126 | if (userId == UUID.Zero) | ||
127 | { | ||
128 | MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName); | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | if (m_friendsModule.AreFriendsCached(userId)) | ||
133 | { | ||
134 | MainConsole.Instance.OutputFormat("No friends cached on this simulator for {0} {1}", firstName, lastName); | ||
135 | return; | ||
136 | } | ||
137 | |||
138 | MainConsole.Instance.OutputFormat("Cached friends for {0} {1}:", firstName, lastName); | ||
139 | |||
140 | MainConsole.Instance.OutputFormat("UUID\n"); | ||
141 | |||
142 | FriendInfo[] friends = m_friendsModule.GetFriendsFromCache(userId); | ||
143 | |||
144 | foreach (FriendInfo friend in friends) | ||
145 | { | ||
146 | // MainConsole.Instance.OutputFormat(friend.PrincipalID.ToString()); | ||
147 | |||
148 | // string friendFirstName, friendLastName; | ||
149 | // | ||
150 | // UserAccount friendUa | ||
151 | // = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friend.PrincipalID); | ||
152 | |||
153 | UUID friendId; | ||
154 | string friendName; | ||
155 | |||
156 | if (UUID.TryParse(friend.Friend, out friendId)) | ||
157 | friendName = m_userManagementModule.GetUserName(friendId); | ||
158 | else | ||
159 | friendName = friend.Friend; | ||
160 | |||
161 | MainConsole.Instance.OutputFormat("{0} {1} {2}", friendName, friend.MyFlags, friend.TheirFlags); | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | } \ No newline at end of file | ||