diff options
author | Dr Scofield | 2009-02-09 09:16:15 +0000 |
---|---|---|
committer | Dr Scofield | 2009-02-09 09:16:15 +0000 |
commit | a89d097355526d4dc52a75a9734c6a02c3008ef4 (patch) | |
tree | f12e2cf5807762e0fbaf2f304e75b618f62b4cf6 /OpenSim/Region/CoreModules/Agent/Capabilities | |
parent | adding bin/ScriptEngines/*/*.{dll,state}, bin/j2kDecodeCache, (diff) | |
download | opensim-SC_OLD-a89d097355526d4dc52a75a9734c6a02c3008ef4.zip opensim-SC_OLD-a89d097355526d4dc52a75a9734c6a02c3008ef4.tar.gz opensim-SC_OLD-a89d097355526d4dc52a75a9734c6a02c3008ef4.tar.bz2 opensim-SC_OLD-a89d097355526d4dc52a75a9734c6a02c3008ef4.tar.xz |
starting phase 2 of the OpenSim.Region.Environment commit: relocating
OpenSim.Region.Environment.Modules.Agent en bloc to OpenSim.Region.CoreModules
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent/Capabilities')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs new file mode 100644 index 0000000..4f7f177 --- /dev/null +++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs | |||
@@ -0,0 +1,210 @@ | |||
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 OpenSim 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.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications.Cache; | ||
36 | using OpenSim.Framework.Communications.Capabilities; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using Caps = OpenSim.Framework.Communications.Capabilities.Caps; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.Agent.Capabilities | ||
42 | { | ||
43 | public class CapabilitiesModule : IRegionModule, 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(Scene scene, IConfigSource source) | ||
59 | { | ||
60 | m_scene = scene; | ||
61 | m_scene.RegisterModuleInterface<ICapabilitiesModule>(this); | ||
62 | } | ||
63 | |||
64 | public void PostInitialise() {} | ||
65 | public void Close() {} | ||
66 | public string Name { get { return "Capabilities Module"; } } | ||
67 | public bool IsSharedModule { get { return false; } } | ||
68 | |||
69 | public void AddCapsHandler(UUID agentId) | ||
70 | { | ||
71 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) | ||
72 | return; | ||
73 | |||
74 | String capsObjectPath = GetCapsPath(agentId); | ||
75 | |||
76 | if (m_capsHandlers.ContainsKey(agentId)) | ||
77 | { | ||
78 | Caps oldCaps = m_capsHandlers[agentId]; | ||
79 | |||
80 | m_log.DebugFormat( | ||
81 | "[CAPS]: Reregistering caps for agent {0}. Old caps path {1}, new caps path {2}. ", | ||
82 | agentId, oldCaps.CapsObjectPath, capsObjectPath); | ||
83 | // This should not happen. The caller code is confused. We need to fix that. | ||
84 | // CAPs can never be reregistered, or the client will be confused. | ||
85 | // Hence this return here. | ||
86 | //return; | ||
87 | } | ||
88 | |||
89 | Caps caps | ||
90 | = new Caps( | ||
91 | m_scene.AssetCache, m_scene.CommsManager.HttpServer, m_scene.RegionInfo.ExternalHostName, | ||
92 | m_scene.CommsManager.HttpServer.Port, | ||
93 | capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName); | ||
94 | |||
95 | caps.RegisterHandlers(); | ||
96 | |||
97 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); | ||
98 | |||
99 | caps.AddNewInventoryItem = m_scene.AddUploadedInventoryItem; | ||
100 | caps.ItemUpdatedCall = m_scene.CapsUpdateInventoryItemAsset; | ||
101 | caps.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset; | ||
102 | caps.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS; | ||
103 | caps.GetClient = m_scene.SceneContents.GetControllingClient; | ||
104 | |||
105 | m_capsHandlers[agentId] = caps; | ||
106 | } | ||
107 | |||
108 | public void RemoveCapsHandler(UUID agentId) | ||
109 | { | ||
110 | if (childrenSeeds.ContainsKey(agentId)) | ||
111 | { | ||
112 | childrenSeeds.Remove(agentId); | ||
113 | } | ||
114 | |||
115 | lock (m_capsHandlers) | ||
116 | { | ||
117 | if (m_capsHandlers.ContainsKey(agentId)) | ||
118 | { | ||
119 | m_capsHandlers[agentId].DeregisterHandlers(); | ||
120 | m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]); | ||
121 | m_capsHandlers.Remove(agentId); | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | m_log.WarnFormat( | ||
126 | "[CAPS]: Received request to remove CAPS handler for root agent {0} in {1}, but no such CAPS handler found!", | ||
127 | agentId, m_scene.RegionInfo.RegionName); | ||
128 | } | ||
129 | } | ||
130 | } | ||
131 | |||
132 | public Caps GetCapsHandlerForUser(UUID agentId) | ||
133 | { | ||
134 | lock (m_capsHandlers) | ||
135 | { | ||
136 | if (m_capsHandlers.ContainsKey(agentId)) | ||
137 | { | ||
138 | return m_capsHandlers[agentId]; | ||
139 | } | ||
140 | } | ||
141 | |||
142 | return null; | ||
143 | } | ||
144 | |||
145 | public void NewUserConnection(AgentCircuitData agent) | ||
146 | { | ||
147 | capsPaths[agent.AgentID] = agent.CapsPath; | ||
148 | childrenSeeds[agent.AgentID] | ||
149 | = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); | ||
150 | } | ||
151 | |||
152 | public string GetCapsPath(UUID agentId) | ||
153 | { | ||
154 | if (capsPaths.ContainsKey(agentId)) | ||
155 | { | ||
156 | return capsPaths[agentId]; | ||
157 | } | ||
158 | |||
159 | return null; | ||
160 | } | ||
161 | |||
162 | public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) | ||
163 | { | ||
164 | Dictionary<ulong, string> seeds = null; | ||
165 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | ||
166 | return seeds; | ||
167 | return new Dictionary<ulong, string>(); | ||
168 | } | ||
169 | |||
170 | public void DropChildSeed(UUID agentID, ulong handle) | ||
171 | { | ||
172 | Dictionary<ulong, string> seeds; | ||
173 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | ||
174 | { | ||
175 | seeds.Remove(handle); | ||
176 | } | ||
177 | } | ||
178 | |||
179 | public string GetChildSeed(UUID agentID, ulong handle) | ||
180 | { | ||
181 | Dictionary<ulong, string> seeds; | ||
182 | string returnval; | ||
183 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | ||
184 | { | ||
185 | if (seeds.TryGetValue(handle, out returnval)) | ||
186 | return returnval; | ||
187 | } | ||
188 | return null; | ||
189 | } | ||
190 | |||
191 | public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds) | ||
192 | { | ||
193 | //Console.WriteLine(" !!! Setting child seeds in {0} to {1}", RegionInfo.RegionName, value.Count); | ||
194 | childrenSeeds[agentID] = seeds; | ||
195 | } | ||
196 | |||
197 | public void DumpChildrenSeeds(UUID agentID) | ||
198 | { | ||
199 | Console.WriteLine("================ ChildrenSeed {0} ================", m_scene.RegionInfo.RegionName); | ||
200 | foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID]) | ||
201 | { | ||
202 | uint x, y; | ||
203 | Utils.LongToUInts(kvp.Key, out x, out y); | ||
204 | x = x / Constants.RegionSize; | ||
205 | y = y / Constants.RegionSize; | ||
206 | Console.WriteLine(" >> {0}, {1}: {2}", x, y, kvp.Value); | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | } \ No newline at end of file | ||