diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs | 255 |
1 files changed, 0 insertions, 255 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs deleted file mode 100644 index 1d8e70e..0000000 --- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs +++ /dev/null | |||
@@ -1,255 +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 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) | ||
99 | return; | ||
100 | |||
101 | String capsObjectPath = GetCapsPath(agentId); | ||
102 | |||
103 | if (m_capsHandlers.ContainsKey(agentId)) | ||
104 | { | ||
105 | Caps oldCaps = m_capsHandlers[agentId]; | ||
106 | |||
107 | m_log.DebugFormat( | ||
108 | "[CAPS]: Reregistering caps for agent {0}. Old caps path {1}, new caps path {2}. ", | ||
109 | agentId, oldCaps.CapsObjectPath, capsObjectPath); | ||
110 | // This should not happen. The caller code is confused. We need to fix that. | ||
111 | // CAPs can never be reregistered, or the client will be confused. | ||
112 | // Hence this return here. | ||
113 | //return; | ||
114 | } | ||
115 | |||
116 | Caps caps | ||
117 | = new Caps(m_scene, | ||
118 | m_scene.AssetService, MainServer.Instance, m_scene.RegionInfo.ExternalHostName, | ||
119 | (MainServer.Instance == null) ? 0: MainServer.Instance.Port, | ||
120 | capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName); | ||
121 | |||
122 | caps.RegisterHandlers(); | ||
123 | |||
124 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); | ||
125 | |||
126 | caps.AddNewInventoryItem = m_scene.AddUploadedInventoryItem; | ||
127 | caps.ItemUpdatedCall = m_scene.CapsUpdateInventoryItemAsset; | ||
128 | caps.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset; | ||
129 | caps.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS; | ||
130 | caps.GetClient = m_scene.SceneContents.GetControllingClient; | ||
131 | |||
132 | m_capsHandlers[agentId] = caps; | ||
133 | } | ||
134 | |||
135 | public void RemoveCapsHandler(UUID agentId) | ||
136 | { | ||
137 | if (childrenSeeds.ContainsKey(agentId)) | ||
138 | { | ||
139 | childrenSeeds.Remove(agentId); | ||
140 | } | ||
141 | |||
142 | lock (m_capsHandlers) | ||
143 | { | ||
144 | if (m_capsHandlers.ContainsKey(agentId)) | ||
145 | { | ||
146 | m_capsHandlers[agentId].DeregisterHandlers(); | ||
147 | m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]); | ||
148 | m_capsHandlers.Remove(agentId); | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | m_log.WarnFormat( | ||
153 | "[CAPS]: Received request to remove CAPS handler for root agent {0} in {1}, but no such CAPS handler found!", | ||
154 | agentId, m_scene.RegionInfo.RegionName); | ||
155 | } | ||
156 | } | ||
157 | } | ||
158 | |||
159 | public Caps GetCapsHandlerForUser(UUID agentId) | ||
160 | { | ||
161 | lock (m_capsHandlers) | ||
162 | { | ||
163 | if (m_capsHandlers.ContainsKey(agentId)) | ||
164 | { | ||
165 | return m_capsHandlers[agentId]; | ||
166 | } | ||
167 | } | ||
168 | |||
169 | return null; | ||
170 | } | ||
171 | |||
172 | public void NewUserConnection(AgentCircuitData agent) | ||
173 | { | ||
174 | capsPaths[agent.AgentID] = agent.CapsPath; | ||
175 | childrenSeeds[agent.AgentID] | ||
176 | = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); | ||
177 | } | ||
178 | |||
179 | public string GetCapsPath(UUID agentId) | ||
180 | { | ||
181 | if (capsPaths.ContainsKey(agentId)) | ||
182 | { | ||
183 | return capsPaths[agentId]; | ||
184 | } | ||
185 | |||
186 | return null; | ||
187 | } | ||
188 | |||
189 | public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) | ||
190 | { | ||
191 | Dictionary<ulong, string> seeds = null; | ||
192 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | ||
193 | return seeds; | ||
194 | return new Dictionary<ulong, string>(); | ||
195 | } | ||
196 | |||
197 | public void DropChildSeed(UUID agentID, ulong handle) | ||
198 | { | ||
199 | Dictionary<ulong, string> seeds; | ||
200 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | ||
201 | { | ||
202 | seeds.Remove(handle); | ||
203 | } | ||
204 | } | ||
205 | |||
206 | public string GetChildSeed(UUID agentID, ulong handle) | ||
207 | { | ||
208 | Dictionary<ulong, string> seeds; | ||
209 | string returnval; | ||
210 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | ||
211 | { | ||
212 | if (seeds.TryGetValue(handle, out returnval)) | ||
213 | return returnval; | ||
214 | } | ||
215 | return null; | ||
216 | } | ||
217 | |||
218 | public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds) | ||
219 | { | ||
220 | //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count); | ||
221 | childrenSeeds[agentID] = seeds; | ||
222 | } | ||
223 | |||
224 | public void DumpChildrenSeeds(UUID agentID) | ||
225 | { | ||
226 | m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================"); | ||
227 | foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID]) | ||
228 | { | ||
229 | uint x, y; | ||
230 | Utils.LongToUInts(kvp.Key, out x, out y); | ||
231 | x = x / Constants.RegionSize; | ||
232 | y = y / Constants.RegionSize; | ||
233 | m_log.Info(" >> "+x+", "+y+": "+kvp.Value); | ||
234 | } | ||
235 | } | ||
236 | |||
237 | private void CapabilitiesCommand(string module, string[] cmdparams) | ||
238 | { | ||
239 | System.Text.StringBuilder caps = new System.Text.StringBuilder(); | ||
240 | caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); | ||
241 | |||
242 | foreach (KeyValuePair<UUID, Caps> kvp in m_capsHandlers) | ||
243 | { | ||
244 | caps.AppendFormat("** User {0}:\n", kvp.Key); | ||
245 | for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.CapsDetails.GetEnumerator(); kvp2.MoveNext(); ) | ||
246 | { | ||
247 | Uri uri = new Uri(kvp2.Value.ToString()); | ||
248 | caps.AppendFormat(" {0} = {1}\n", kvp2.Key, uri.PathAndQuery); | ||
249 | } | ||
250 | } | ||
251 | |||
252 | MainConsole.Instance.Output(caps.ToString()); | ||
253 | } | ||
254 | } | ||
255 | } | ||