aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs87
1 files changed, 83 insertions, 4 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
index 2bcb8a7..fe73770 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
@@ -32,14 +32,17 @@ using System.Reflection;
32using System.Text; 32using System.Text;
33using log4net; 33using log4net;
34using Mono.Addins; 34using Mono.Addins;
35using NDesk.Options;
35using Nini.Config; 36using Nini.Config;
36using OpenMetaverse; 37using OpenMetaverse;
37using OpenSim.Framework; 38using OpenSim.Framework;
38using OpenSim.Framework.Console; 39using OpenSim.Framework.Console;
39using OpenSim.Framework.Statistics; 40using OpenSim.Framework.Statistics;
40using OpenSim.Region.ClientStack.LindenUDP; 41using OpenSim.Region.ClientStack.LindenUDP;
42using OpenSim.Region.CoreModules.Avatar.Friends;
41using OpenSim.Region.Framework.Interfaces; 43using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 44using OpenSim.Region.Framework.Scenes;
45using OpenSim.Services.Interfaces;
43using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; 46using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
44 47
45namespace OpenSim.Region.OptionalModules.Avatar.Friends 48namespace OpenSim.Region.OptionalModules.Avatar.Friends
@@ -100,10 +103,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
100 if (m_friendsModule != null && m_userManagementModule != null) 103 if (m_friendsModule != null && m_userManagementModule != null)
101 { 104 {
102 m_scene.AddCommand( 105 m_scene.AddCommand(
103 "Friends", this, "friends show cache", 106 "Friends", this, "friends show",
104 "friends show cache [<first-name> <last-name>]", 107 "friends show [--cache] <first-name> <last-name>",
105 "Show the friends cache for the given user", 108 "Show the friends for the given user if they exist.\n",
106 HandleFriendsShowCacheCommand); 109 "The --cache option will show locally cached information for that user.",
110 HandleFriendsShowCommand);
107 } 111 }
108 } 112 }
109 113
@@ -161,5 +165,80 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
161 MainConsole.Instance.OutputFormat("{0} {1} {2}", friendName, friend.MyFlags, friend.TheirFlags); 165 MainConsole.Instance.OutputFormat("{0} {1} {2}", friendName, friend.MyFlags, friend.TheirFlags);
162 } 166 }
163 } 167 }
168
169 protected void HandleFriendsShowCommand(string module, string[] cmd)
170 {
171 Dictionary<string, object> options = new Dictionary<string, object>();
172 OptionSet optionSet = new OptionSet().Add("c|cache", delegate (string v) { options["cache"] = v != null; });
173
174 List<string> mainParams = optionSet.Parse(cmd);
175
176 if (mainParams.Count != 4)
177 {
178 MainConsole.Instance.OutputFormat("Usage: friends show [--cache] <first-name> <last-name>");
179 return;
180 }
181
182 string firstName = mainParams[2];
183 string lastName = mainParams[3];
184
185 UUID userId = m_userManagementModule.GetUserIdByName(firstName, lastName);
186
187// UserAccount ua
188// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, firstName, lastName);
189
190 if (userId == UUID.Zero)
191 {
192 MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
193 return;
194 }
195
196 FriendInfo[] friends;
197
198 if (options.ContainsKey("cache"))
199 {
200 if (!m_friendsModule.AreFriendsCached(userId))
201 {
202 MainConsole.Instance.OutputFormat("No friends cached on this simulator for {0} {1}", firstName, lastName);
203 return;
204 }
205 else
206 {
207 friends = m_friendsModule.GetFriendsFromCache(userId);
208 }
209 }
210 else
211 {
212 // FIXME: We're forced to do this right now because IFriendsService has no region connectors. We can't
213 // just expose FriendsModule.GetFriendsFromService() because it forces an IClientAPI requirement that
214 // can't currently be changed because of HGFriendsModule code that takes the scene from the client.
215 friends = ((FriendsModule)m_friendsModule).FriendsService.GetFriends(userId);
216 }
217
218 MainConsole.Instance.OutputFormat("Friends for {0} {1} {2}:", firstName, lastName, userId);
219
220 MainConsole.Instance.OutputFormat("UUID, Name, MyFlags, TheirFlags");
221
222 foreach (FriendInfo friend in friends)
223 {
224// MainConsole.Instance.OutputFormat(friend.PrincipalID.ToString());
225
226// string friendFirstName, friendLastName;
227//
228// UserAccount friendUa
229// = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friend.PrincipalID);
230
231 UUID friendId;
232 string friendName;
233
234 if (UUID.TryParse(friend.Friend, out friendId))
235 friendName = m_userManagementModule.GetUserName(friendId);
236 else
237 friendName = friend.Friend;
238
239 MainConsole.Instance.OutputFormat(
240 "{0} {1} {2} {3}", friend.Friend, friendName, friend.MyFlags, friend.TheirFlags);
241 }
242 }
164 } 243 }
165} \ No newline at end of file 244} \ No newline at end of file