diff options
author | Justin Clark-Casey (justincc) | 2012-01-06 20:20:11 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-01-06 21:07:34 +0000 |
commit | 7661a0b2a913a7637cb8ba8310be370594901485 (patch) | |
tree | f1698bb15eef27766fe35c8dafba1092511eb17d /OpenSim/Region/ClientStack/Linden | |
parent | If dragging a script that is no copy from prim inventory into agent (diff) | |
download | opensim-SC_OLD-7661a0b2a913a7637cb8ba8310be370594901485.zip opensim-SC_OLD-7661a0b2a913a7637cb8ba8310be370594901485.tar.gz opensim-SC_OLD-7661a0b2a913a7637cb8ba8310be370594901485.tar.bz2 opensim-SC_OLD-7661a0b2a913a7637cb8ba8310be370594901485.tar.xz |
Implement the FetchInventory2 capability. This accompanies the existing FetchInventoryDescendents2 capability.
Not yet enabled by default. You can enable this by setting Cap_FetchInventory2 = "localhost" in the [ClientStack.LindenCaps] section of OpenSim.ini
Enabling both FetchInventory2 and FetchInventoryDescendents2 improves the situation with properly fetching attachments and hud objects
Probably because viewers are never expecting the odd situation where FetchInventoryDescendents2 is present but not FetchInventory2
However, for some reason attachments and hud objects occasionally fail to appear, though their status is correct in inventory
For attachments, focussing on the avatar makes them appear. Hud objects have to be reattached.
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs b/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs new file mode 100644 index 0000000..14501c7 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs | |||
@@ -0,0 +1,151 @@ | |||
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; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using Mono.Addins; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
41 | using OpenSim.Capabilities.Handlers; | ||
42 | |||
43 | namespace OpenSim.Region.ClientStack.Linden | ||
44 | { | ||
45 | /// <summary> | ||
46 | /// This module implements both WebFetchInventoryDescendents and FetchInventoryDescendents2 capabilities. | ||
47 | /// </summary> | ||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
49 | public class FetchInventory2Module : INonSharedRegionModule | ||
50 | { | ||
51 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | public bool Enabled { get; private set; } | ||
54 | |||
55 | private Scene m_scene; | ||
56 | |||
57 | private IInventoryService m_inventoryService; | ||
58 | |||
59 | private string m_fetchInventory2Url; | ||
60 | |||
61 | private FetchInventory2Handler m_fetchHandler; | ||
62 | |||
63 | #region ISharedRegionModule Members | ||
64 | |||
65 | public void Initialise(IConfigSource source) | ||
66 | { | ||
67 | IConfig config = source.Configs["ClientStack.LindenCaps"]; | ||
68 | if (config == null) | ||
69 | return; | ||
70 | |||
71 | m_fetchInventory2Url = config.GetString("Cap_FetchInventory2", string.Empty); | ||
72 | |||
73 | if (m_fetchInventory2Url != string.Empty) | ||
74 | Enabled = true; | ||
75 | } | ||
76 | |||
77 | public void AddRegion(Scene s) | ||
78 | { | ||
79 | if (!Enabled) | ||
80 | return; | ||
81 | |||
82 | m_scene = s; | ||
83 | } | ||
84 | |||
85 | public void RemoveRegion(Scene s) | ||
86 | { | ||
87 | if (!Enabled) | ||
88 | return; | ||
89 | |||
90 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
91 | m_scene = null; | ||
92 | } | ||
93 | |||
94 | public void RegionLoaded(Scene s) | ||
95 | { | ||
96 | if (!Enabled) | ||
97 | return; | ||
98 | |||
99 | m_inventoryService = m_scene.InventoryService; | ||
100 | |||
101 | // We'll reuse the same handler for all requests. | ||
102 | if (m_fetchInventory2Url == "localhost") | ||
103 | m_fetchHandler = new FetchInventory2Handler(m_inventoryService); | ||
104 | |||
105 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
106 | } | ||
107 | |||
108 | public void PostInitialise() {} | ||
109 | |||
110 | public void Close() {} | ||
111 | |||
112 | public string Name { get { return "FetchInventory2Module"; } } | ||
113 | |||
114 | public Type ReplaceableInterface | ||
115 | { | ||
116 | get { return null; } | ||
117 | } | ||
118 | |||
119 | #endregion | ||
120 | |||
121 | private void RegisterCaps(UUID agentID, Caps caps) | ||
122 | { | ||
123 | RegisterFetchCap(agentID, caps, "FetchInventory2", m_fetchInventory2Url); | ||
124 | } | ||
125 | |||
126 | private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url) | ||
127 | { | ||
128 | string capUrl; | ||
129 | |||
130 | if (url == "localhost") | ||
131 | { | ||
132 | capUrl = "/CAPS/" + UUID.Random(); | ||
133 | |||
134 | IRequestHandler reqHandler | ||
135 | = new RestStreamHandler("POST", capUrl, m_fetchHandler.FetchInventoryRequest); | ||
136 | |||
137 | caps.RegisterHandler(capName, reqHandler); | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | capUrl = url; | ||
142 | |||
143 | caps.RegisterHandler(capName, capUrl); | ||
144 | } | ||
145 | |||
146 | // m_log.DebugFormat( | ||
147 | // "[FETCH INVENTORY2 MODULE]: Registered capability {0} at {1} in region {2} for {3}", | ||
148 | // capName, capUrl, m_scene.RegionInfo.RegionName, agentID); | ||
149 | } | ||
150 | } | ||
151 | } | ||