29 using System.Collections.Generic;
31 using System.Reflection;
38 using OpenSim.Framework;
39 using OpenSim.Framework.Console;
40 using OpenSim.Framework.Monitoring;
41 using OpenSim.Region.ClientStack.LindenUDP;
42 using OpenSim.Region.CoreModules.Avatar.Friends;
43 using OpenSim.Region.Framework.Interfaces;
44 using OpenSim.Region.Framework.Scenes;
45 using OpenSim.Services.Interfaces;
53 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"FriendsCommandModule")]
58 private Scene m_scene;
65 public string Name {
get {
return "Appearance Information Module"; } }
67 public Type ReplaceableInterface {
get {
return null; } }
101 m_friendsModule = m_scene.RequestModuleInterface<
IFriendsModule>();
102 m_userManagementModule = m_scene.RequestModuleInterface<
IUserManagement>();
105 if (m_friendsModule != null && m_userManagementModule != null && m_presenceService != null)
108 "Friends",
this,
"friends show",
109 "friends show [--cache] <first-name> <last-name>",
110 "Show the friends for the given user if they exist.",
111 "The --cache option will show locally cached information for that user.",
112 HandleFriendsShowCommand);
118 Dictionary<string, object>
options =
new Dictionary<string, object>();
119 OptionSet optionSet =
new OptionSet().Add(
"c|cache", delegate (
string v) { options[
"cache"] = v != null; });
121 List<string> mainParams = optionSet.Parse(cmd);
123 if (mainParams.Count != 4)
125 MainConsole.Instance.OutputFormat(
"Usage: friends show [--cache] <first-name> <last-name>");
129 string firstName = mainParams[2];
130 string lastName = mainParams[3];
132 UUID userId = m_userManagementModule.GetUserIdByName(firstName, lastName);
137 if (userId ==
UUID.Zero)
139 MainConsole.Instance.OutputFormat(
"No such user as {0} {1}", firstName, lastName);
145 if (options.ContainsKey(
"cache"))
147 if (!m_friendsModule.AreFriendsCached(userId))
149 MainConsole.Instance.OutputFormat(
"No friends cached on this simulator for {0} {1}", firstName, lastName);
154 friends = m_friendsModule.GetFriendsFromCache(userId);
162 friends = ((
FriendsModule)m_friendsModule).FriendsService.GetFriends(userId);
165 MainConsole.Instance.OutputFormat(
"Friends for {0} {1} {2}:", firstName, lastName, userId);
167 MainConsole.Instance.OutputFormat(
168 "{0,-36} {1,-36} {2,-7} {3,7} {4,10}",
"UUID",
"Name",
"Status",
"MyFlags",
"TheirFlags");
183 if (
UUID.TryParse(
friend.Friend, out friendId))
184 friendName = m_userManagementModule.GetUserName(friendId);
186 friendName = friend.Friend;
190 onlineText =
"online";
192 onlineText =
"offline";
194 MainConsole.Instance.OutputFormat(
195 "{0,-36} {1,-36} {2,-7} {3,-7} {4,-10}",
196 friend.Friend, friendName, onlineText, friend.MyFlags, friend.TheirFlags);
void HandleFriendsShowCommand(string module, string[] cmd)
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
A module that just holds commands for inspecting avatar appearance.
Interactive OpenSim region server
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
OpenSim.Services.Interfaces.FriendInfo FriendInfo
This maintains the relationship between a UUID and a user name.
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...