diff options
author | Melanie | 2011-05-05 09:49:10 +0100 |
---|---|---|
committer | Melanie | 2011-05-05 09:49:10 +0100 |
commit | 4beb0c9b9b402c1e8f70a02c0efa557c1f292f1c (patch) | |
tree | 24e24cb7b424df74b13788d28be9d7588fbd99d0 /OpenSim/Region/CoreModules/Agent | |
parent | Merge branch 'master' into careminster-presence-refactor (diff) | |
parent | Test m_Enabled on RemoveRegion. (diff) | |
download | opensim-SC_OLD-4beb0c9b9b402c1e8f70a02c0efa557c1f292f1c.zip opensim-SC_OLD-4beb0c9b9b402c1e8f70a02c0efa557c1f292f1c.tar.gz opensim-SC_OLD-4beb0c9b9b402c1e8f70a02c0efa557c1f292f1c.tar.bz2 opensim-SC_OLD-4beb0c9b9b402c1e8f70a02c0efa557c1f292f1c.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs | 256 |
1 files changed, 0 insertions, 256 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs deleted file mode 100644 index 7526bd2..0000000 --- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs +++ /dev/null | |||
@@ -1,256 +0,0 @@ | |||
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 copyrightD | ||
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; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Console; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using Caps=OpenSim.Framework.Capabilities.Caps; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.Agent.Capabilities | ||
42 | { | ||
43 | public class CapabilitiesModule : INonSharedRegionModule, ICapabilitiesModule | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | protected Scene m_scene; | ||
48 | |||
49 | /// <summary> | ||
50 | /// Each agent has its own capabilities handler. | ||
51 | /// </summary> | ||
52 | protected Dictionary<UUID, Caps> m_capsHandlers = new Dictionary<UUID, Caps>(); | ||
53 | |||
54 | protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>(); | ||
55 | protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds | ||
56 | = new Dictionary<UUID, Dictionary<ulong, string>>(); | ||
57 | |||
58 | public void Initialise(IConfigSource source) | ||
59 | { | ||
60 | } | ||
61 | |||
62 | public void AddRegion(Scene scene) | ||
63 | { | ||
64 | m_scene = scene; | ||
65 | m_scene.RegisterModuleInterface<ICapabilitiesModule>(this); | ||
66 | MainConsole.Instance.Commands.AddCommand("Capabilities", false, "show caps", | ||
67 | "show capabilities", | ||
68 | "Shows all registered capabilities", CapabilitiesCommand); | ||
69 | } | ||
70 | |||
71 | public void RegionLoaded(Scene scene) | ||
72 | { | ||
73 | } | ||
74 | |||
75 | public void RemoveRegion(Scene scene) | ||
76 | { | ||
77 | m_scene.UnregisterModuleInterface<ICapabilitiesModule>(this); | ||
78 | } | ||
79 | |||
80 | public void PostInitialise() | ||
81 | { | ||
82 | } | ||
83 | |||
84 | public void Close() {} | ||
85 | |||
86 | public string Name | ||
87 | { | ||
88 | get { return "Capabilities Module"; } | ||
89 | } | ||
90 | |||
91 | public Type ReplaceableInterface | ||
92 | { | ||
93 | get { return null; } | ||
94 | } | ||
95 | |||
96 | public void AddCapsHandler(UUID agentId) | ||
97 | { | ||
98 | int flags = m_scene.GetUserFlags(agentId); | ||
99 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags)) | ||
100 | return; | ||
101 | |||
102 | String capsObjectPath = GetCapsPath(agentId); | ||
103 | |||
104 | if (m_capsHandlers.ContainsKey(agentId)) | ||
105 | { | ||
106 | Caps oldCaps = m_capsHandlers[agentId]; | ||
107 | |||
108 | m_log.DebugFormat( | ||
109 | "[CAPS]: Reregistering caps for agent {0}. Old caps path {1}, new caps path {2}. ", | ||
110 | agentId, oldCaps.CapsObjectPath, capsObjectPath); | ||
111 | // This should not happen. The caller code is confused. We need to fix that. | ||
112 | // CAPs can never be reregistered, or the client will be confused. | ||
113 | // Hence this return here. | ||
114 | //return; | ||
115 | } | ||
116 | |||
117 | Caps caps | ||
118 | = new Caps(m_scene, | ||
119 | m_scene.AssetService, MainServer.Instance, m_scene.RegionInfo.ExternalHostName, | ||
120 | (MainServer.Instance == null) ? 0: MainServer.Instance.Port, | ||
121 | capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName); | ||
122 | |||
123 | caps.RegisterHandlers(); | ||
124 | |||
125 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); | ||
126 | |||
127 | caps.AddNewInventoryItem = m_scene.AddUploadedInventoryItem; | ||
128 | caps.ItemUpdatedCall = m_scene.CapsUpdateInventoryItemAsset; | ||
129 | caps.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset; | ||
130 | caps.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS; | ||
131 | caps.GetClient = m_scene.SceneContents.GetControllingClient; | ||
132 | |||
133 | m_capsHandlers[agentId] = caps; | ||
134 | } | ||
135 | |||
136 | public void RemoveCapsHandler(UUID agentId) | ||
137 | { | ||
138 | if (childrenSeeds.ContainsKey(agentId)) | ||
139 | { | ||
140 | childrenSeeds.Remove(agentId); | ||
141 | } | ||
142 | |||
143 | lock (m_capsHandlers) | ||
144 | { | ||
145 | if (m_capsHandlers.ContainsKey(agentId)) | ||
146 | { | ||
147 | m_capsHandlers[agentId].DeregisterHandlers(); | ||
148 | m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]); | ||
149 | m_capsHandlers.Remove(agentId); | ||
150 | } | ||
151 | else | ||
152 | { | ||
153 | m_log.WarnFormat( | ||
154 | "[CAPS]: Received request to remove CAPS handler for root agent {0} in {1}, but no such CAPS handler found!", | ||
155 | agentId, m_scene.RegionInfo.RegionName); | ||
156 | } | ||
157 | } | ||
158 | } | ||
159 | |||
160 | public Caps GetCapsHandlerForUser(UUID agentId) | ||
161 | { | ||
162 | lock (m_capsHandlers) | ||
163 | { | ||
164 | if (m_capsHandlers.ContainsKey(agentId)) | ||
165 | { | ||
166 | return m_capsHandlers[agentId]; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | return null; | ||
171 | } | ||
172 | |||
173 | public void NewUserConnection(AgentCircuitData agent) | ||
174 | { | ||
175 | capsPaths[agent.AgentID] = agent.CapsPath; | ||
176 | childrenSeeds[agent.AgentID] | ||
177 | = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); | ||
178 | } | ||
179 | |||
180 | public string GetCapsPath(UUID agentId) | ||
181 | { | ||
182 | if (capsPaths.ContainsKey(agentId)) | ||
183 | { | ||
184 | return capsPaths[agentId]; | ||
185 | } | ||
186 | |||
187 | return null; | ||
188 | } | ||
189 | |||
190 | public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) | ||
191 | { | ||
192 | Dictionary<ulong, string> seeds = null; | ||
193 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | ||
194 | return seeds; | ||
195 | return new Dictionary<ulong, string>(); | ||
196 | } | ||
197 | |||
198 | public void DropChildSeed(UUID agentID, ulong handle) | ||
199 | { | ||
200 | Dictionary<ulong, string> seeds; | ||
201 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | ||
202 | { | ||
203 | seeds.Remove(handle); | ||
204 | } | ||
205 | } | ||
206 | |||
207 | public string GetChildSeed(UUID agentID, ulong handle) | ||
208 | { | ||
209 | Dictionary<ulong, string> seeds; | ||
210 | string returnval; | ||
211 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | ||
212 | { | ||
213 | if (seeds.TryGetValue(handle, out returnval)) | ||
214 | return returnval; | ||
215 | } | ||
216 | return null; | ||
217 | } | ||
218 | |||
219 | public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds) | ||
220 | { | ||
221 | //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count); | ||
222 | childrenSeeds[agentID] = seeds; | ||
223 | } | ||
224 | |||
225 | public void DumpChildrenSeeds(UUID agentID) | ||
226 | { | ||
227 | m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================"); | ||
228 | foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID]) | ||
229 | { | ||
230 | uint x, y; | ||
231 | Utils.LongToUInts(kvp.Key, out x, out y); | ||
232 | x = x / Constants.RegionSize; | ||
233 | y = y / Constants.RegionSize; | ||
234 | m_log.Info(" >> "+x+", "+y+": "+kvp.Value); | ||
235 | } | ||
236 | } | ||
237 | |||
238 | private void CapabilitiesCommand(string module, string[] cmdparams) | ||
239 | { | ||
240 | System.Text.StringBuilder caps = new System.Text.StringBuilder(); | ||
241 | caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); | ||
242 | |||
243 | foreach (KeyValuePair<UUID, Caps> kvp in m_capsHandlers) | ||
244 | { | ||
245 | caps.AppendFormat("** User {0}:\n", kvp.Key); | ||
246 | for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.CapsDetails.GetEnumerator(); kvp2.MoveNext(); ) | ||
247 | { | ||
248 | Uri uri = new Uri(kvp2.Value.ToString()); | ||
249 | caps.AppendFormat(" {0} = {1}\n", kvp2.Key, uri.PathAndQuery); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | MainConsole.Instance.Output(caps.ToString()); | ||
254 | } | ||
255 | } | ||
256 | } | ||