diff options
author | Melanie | 2012-03-31 02:18:02 +0100 |
---|---|---|
committer | Melanie | 2012-03-31 02:18:02 +0100 |
commit | f3132c45d98af7bb38251ad95013c433b5eda9e5 (patch) | |
tree | efc3d6c0529678c0a56f5a505a52944012ea607a /OpenSim/Region/OptionalModules | |
parent | Merge branch 'master' into careminster (diff) | |
parent | refactor: Rename SOG.GetChildPart() to GetPart() since it can also return the... (diff) | |
download | opensim-SC_OLD-f3132c45d98af7bb38251ad95013c433b5eda9e5.zip opensim-SC_OLD-f3132c45d98af7bb38251ad95013c433b5eda9e5.tar.gz opensim-SC_OLD-f3132c45d98af7bb38251ad95013c433b5eda9e5.tar.bz2 opensim-SC_OLD-f3132c45d98af7bb38251ad95013c433b5eda9e5.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
OpenSim/Tests/Common/Mock/TestClient.cs
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs | 189 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs | 2 |
2 files changed, 190 insertions, 1 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs new file mode 100644 index 0000000..e68f9d0 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs | |||
@@ -0,0 +1,189 @@ | |||
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 NDesk.Options; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Console; | ||
40 | using OpenSim.Framework.Statistics; | ||
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; | ||
46 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; | ||
47 | |||
48 | namespace OpenSim.Region.OptionalModules.Avatar.Friends | ||
49 | { | ||
50 | /// <summary> | ||
51 | /// A module that just holds commands for inspecting avatar appearance. | ||
52 | /// </summary> | ||
53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FriendsCommandModule")] | ||
54 | public class FriendsCommandsModule : ISharedRegionModule | ||
55 | { | ||
56 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
57 | |||
58 | private Scene m_scene; | ||
59 | private IFriendsModule m_friendsModule; | ||
60 | private IUserManagement m_userManagementModule; | ||
61 | |||
62 | // private IAvatarFactoryModule m_avatarFactory; | ||
63 | |||
64 | public string Name { get { return "Appearance Information Module"; } } | ||
65 | |||
66 | public Type ReplaceableInterface { get { return null; } } | ||
67 | |||
68 | public void Initialise(IConfigSource source) | ||
69 | { | ||
70 | // m_log.DebugFormat("[FRIENDS COMMAND MODULE]: INITIALIZED MODULE"); | ||
71 | } | ||
72 | |||
73 | public void PostInitialise() | ||
74 | { | ||
75 | // m_log.DebugFormat("[FRIENDS COMMAND MODULE]: POST INITIALIZED MODULE"); | ||
76 | } | ||
77 | |||
78 | public void Close() | ||
79 | { | ||
80 | // m_log.DebugFormat("[FRIENDS COMMAND MODULE]: CLOSED MODULE"); | ||
81 | } | ||
82 | |||
83 | public void AddRegion(Scene scene) | ||
84 | { | ||
85 | // m_log.DebugFormat("[FRIENDS COMMANDO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); | ||
86 | } | ||
87 | |||
88 | public void RemoveRegion(Scene scene) | ||
89 | { | ||
90 | // m_log.DebugFormat("[FRIENDS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | ||
91 | } | ||
92 | |||
93 | public void RegionLoaded(Scene scene) | ||
94 | { | ||
95 | // m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); | ||
96 | |||
97 | if (m_scene == null) | ||
98 | m_scene = scene; | ||
99 | |||
100 | m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | ||
101 | m_userManagementModule = m_scene.RequestModuleInterface<IUserManagement>(); | ||
102 | |||
103 | if (m_friendsModule != null && m_userManagementModule != null) | ||
104 | { | ||
105 | m_scene.AddCommand( | ||
106 | "Friends", this, "friends show", | ||
107 | "friends show [--cache] <first-name> <last-name>", | ||
108 | "Show the friends for the given user if they exist.\n", | ||
109 | "The --cache option will show locally cached information for that user.", | ||
110 | HandleFriendsShowCommand); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | protected void HandleFriendsShowCommand(string module, string[] cmd) | ||
115 | { | ||
116 | Dictionary<string, object> options = new Dictionary<string, object>(); | ||
117 | OptionSet optionSet = new OptionSet().Add("c|cache", delegate (string v) { options["cache"] = v != null; }); | ||
118 | |||
119 | List<string> mainParams = optionSet.Parse(cmd); | ||
120 | |||
121 | if (mainParams.Count != 4) | ||
122 | { | ||
123 | MainConsole.Instance.OutputFormat("Usage: friends show [--cache] <first-name> <last-name>"); | ||
124 | return; | ||
125 | } | ||
126 | |||
127 | string firstName = mainParams[2]; | ||
128 | string lastName = mainParams[3]; | ||
129 | |||
130 | UUID userId = m_userManagementModule.GetUserIdByName(firstName, lastName); | ||
131 | |||
132 | // UserAccount ua | ||
133 | // = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, firstName, lastName); | ||
134 | |||
135 | if (userId == UUID.Zero) | ||
136 | { | ||
137 | MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName); | ||
138 | return; | ||
139 | } | ||
140 | |||
141 | FriendInfo[] friends; | ||
142 | |||
143 | if (options.ContainsKey("cache")) | ||
144 | { | ||
145 | if (!m_friendsModule.AreFriendsCached(userId)) | ||
146 | { | ||
147 | MainConsole.Instance.OutputFormat("No friends cached on this simulator for {0} {1}", firstName, lastName); | ||
148 | return; | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | friends = m_friendsModule.GetFriendsFromCache(userId); | ||
153 | } | ||
154 | } | ||
155 | else | ||
156 | { | ||
157 | // FIXME: We're forced to do this right now because IFriendsService has no region connectors. We can't | ||
158 | // just expose FriendsModule.GetFriendsFromService() because it forces an IClientAPI requirement that | ||
159 | // can't currently be changed because of HGFriendsModule code that takes the scene from the client. | ||
160 | friends = ((FriendsModule)m_friendsModule).FriendsService.GetFriends(userId); | ||
161 | } | ||
162 | |||
163 | MainConsole.Instance.OutputFormat("Friends for {0} {1} {2}:", firstName, lastName, userId); | ||
164 | |||
165 | MainConsole.Instance.OutputFormat("UUID, Name, MyFlags, TheirFlags"); | ||
166 | |||
167 | foreach (FriendInfo friend in friends) | ||
168 | { | ||
169 | // MainConsole.Instance.OutputFormat(friend.PrincipalID.ToString()); | ||
170 | |||
171 | // string friendFirstName, friendLastName; | ||
172 | // | ||
173 | // UserAccount friendUa | ||
174 | // = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, friend.PrincipalID); | ||
175 | |||
176 | UUID friendId; | ||
177 | string friendName; | ||
178 | |||
179 | if (UUID.TryParse(friend.Friend, out friendId)) | ||
180 | friendName = m_userManagementModule.GetUserName(friendId); | ||
181 | else | ||
182 | friendName = friend.Friend; | ||
183 | |||
184 | MainConsole.Instance.OutputFormat( | ||
185 | "{0} {1} {2} {3}", friend.Friend, friendName, friend.MyFlags, friend.TheirFlags); | ||
186 | } | ||
187 | } | ||
188 | } | ||
189 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs index a17eb41..51b0592 100644 --- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs +++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs | |||
@@ -510,7 +510,7 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator | |||
510 | } | 510 | } |
511 | 511 | ||
512 | SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape); | 512 | SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape); |
513 | SceneObjectPart rootPart = sceneObject.GetChildPart(sceneObject.UUID); | 513 | SceneObjectPart rootPart = sceneObject.GetPart(sceneObject.UUID); |
514 | 514 | ||
515 | rootPart.AddFlag(PrimFlags.Phantom); | 515 | rootPart.AddFlag(PrimFlags.Phantom); |
516 | 516 | ||