aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-03-30 01:57:38 +0100
committerJustin Clark-Casey (justincc)2012-03-30 01:57:38 +0100
commit3525c876c8972fb89a9981d4dc3dcb3220adee9e (patch)
tree3dd20361706859391f9a45c1b5e00dff8f94bf02
parentLock NullFriendsData.m_Data for consistency and against concurrent read/write (diff)
downloadopensim-SC_OLD-3525c876c8972fb89a9981d4dc3dcb3220adee9e.zip
opensim-SC_OLD-3525c876c8972fb89a9981d4dc3dcb3220adee9e.tar.gz
opensim-SC_OLD-3525c876c8972fb89a9981d4dc3dcb3220adee9e.tar.bz2
opensim-SC_OLD-3525c876c8972fb89a9981d4dc3dcb3220adee9e.tar.xz
Make default "show friends" console command show friends fetched from the friends service.
There is no a --cache option which will show friends from the local cache if available.
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs3
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs87
-rw-r--r--prebuild.xml1
4 files changed, 87 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 37e6600..f64c161 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -110,7 +110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
110 } 110 }
111 } 111 }
112 112
113 protected IFriendsService FriendsService 113 public IFriendsService FriendsService
114 { 114 {
115 get 115 get
116 { 116 {
@@ -939,7 +939,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
939 } 939 }
940 } 940 }
941 941
942 protected virtual FriendInfo[] GetFriendsFromService(IClientAPI client) 942 public virtual FriendInfo[] GetFriendsFromService(IClientAPI client)
943 { 943 {
944 return FriendsService.GetFriends(client.AgentId); 944 return FriendsService.GetFriends(client.AgentId);
945 } 945 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index d3a3ee4..9a6d277 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -300,8 +300,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
300 return null; 300 return null;
301 } 301 }
302 302
303 303 public override FriendInfo[] GetFriendsFromService(IClientAPI client)
304 protected override FriendInfo[] GetFriendsFromService(IClientAPI client)
305 { 304 {
306// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetFriendsFromService for {0}", client.Name); 305// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetFriendsFromService for {0}", client.Name);
307 Boolean agentIsLocal = true; 306 Boolean agentIsLocal = true;
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
diff --git a/prebuild.xml b/prebuild.xml
index 4ceb137..4f04032 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1669,6 +1669,7 @@
1669 <Reference name="System.Xml"/> 1669 <Reference name="System.Xml"/>
1670 <Reference name="System.Drawing"/> 1670 <Reference name="System.Drawing"/>
1671 <Reference name="System.Web"/> 1671 <Reference name="System.Web"/>
1672 <Reference name="NDesk.Options" path="../../../bin/"/>
1672 <Reference name="OpenMetaverseTypes" path="../../../bin/"/> 1673 <Reference name="OpenMetaverseTypes" path="../../../bin/"/>
1673 <Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/> 1674 <Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
1674 <Reference name="OpenMetaverse" path="../../../bin/"/> 1675 <Reference name="OpenMetaverse" path="../../../bin/"/>