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