diff options
author | Diva Canto | 2011-05-02 14:33:34 -0700 |
---|---|---|
committer | Diva Canto | 2011-05-02 14:33:34 -0700 |
commit | 883f21dd026cbed55f2e12af491e2f9902b80d4a (patch) | |
tree | 86b9a1c11775b8834076fe2628d122f9a40ed84e /OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | |
parent | Merge branch 'master' into caps (diff) | |
download | opensim-SC-883f21dd026cbed55f2e12af491e2f9902b80d4a.zip opensim-SC-883f21dd026cbed55f2e12af491e2f9902b80d4a.tar.gz opensim-SC-883f21dd026cbed55f2e12af491e2f9902b80d4a.tar.bz2 opensim-SC-883f21dd026cbed55f2e12af491e2f9902b80d4a.tar.xz |
WebFetchInventoryDescendents working. Tested with robust.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs new file mode 100644 index 0000000..55f220d --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | |||
@@ -0,0 +1,131 @@ | |||
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 | |||
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
47 | public class WebFetchInvDescModule : INonSharedRegionModule | ||
48 | { | ||
49 | private static readonly ILog m_log = | ||
50 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | private Scene m_scene; | ||
52 | |||
53 | private IInventoryService m_InventoryService; | ||
54 | private ILibraryService m_LibraryService; | ||
55 | private bool m_Enabled = false; | ||
56 | private string m_URL; | ||
57 | |||
58 | #region ISharedRegionModule Members | ||
59 | |||
60 | public void Initialise(IConfigSource source) | ||
61 | { | ||
62 | IConfig config = source.Configs["ClientStack.LindenCaps"]; | ||
63 | if (config == null) | ||
64 | return; | ||
65 | |||
66 | m_URL = config.GetString("Cap_WebFetchInventoryDescendents", string.Empty); | ||
67 | // Cap doesn't exist | ||
68 | if (m_URL != string.Empty) | ||
69 | m_Enabled = true; | ||
70 | } | ||
71 | |||
72 | public void AddRegion(Scene s) | ||
73 | { | ||
74 | if (!m_Enabled) | ||
75 | return; | ||
76 | |||
77 | m_scene = s; | ||
78 | } | ||
79 | |||
80 | public void RemoveRegion(Scene s) | ||
81 | { | ||
82 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
83 | m_scene = null; | ||
84 | } | ||
85 | |||
86 | public void RegionLoaded(Scene s) | ||
87 | { | ||
88 | if (!m_Enabled) | ||
89 | return; | ||
90 | |||
91 | m_InventoryService = m_scene.InventoryService; ; | ||
92 | m_LibraryService = m_scene.LibraryService; | ||
93 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
94 | } | ||
95 | |||
96 | public void PostInitialise() | ||
97 | { | ||
98 | } | ||
99 | |||
100 | public void Close() { } | ||
101 | |||
102 | public string Name { get { return "WebFetchInvDescModule"; } } | ||
103 | |||
104 | public Type ReplaceableInterface | ||
105 | { | ||
106 | get { return null; } | ||
107 | } | ||
108 | |||
109 | #endregion | ||
110 | |||
111 | public void RegisterCaps(UUID agentID, Caps caps) | ||
112 | { | ||
113 | UUID capID = UUID.Random(); | ||
114 | |||
115 | //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); | ||
116 | if (m_URL == "localhost") | ||
117 | { | ||
118 | m_log.InfoFormat("[WEBFETCHINVENTORYDESCENDANTS]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); | ||
119 | WebFetchInvDescHandler webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService); | ||
120 | IRequestHandler reqHandler = new RestStreamHandler("POST", "/CAPS/" + UUID.Random(), webFetchHandler.FetchInventoryDescendentsRequest); | ||
121 | caps.RegisterHandler("WebFetchInventoryDescendents", reqHandler); | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | m_log.InfoFormat("[WEBFETCHINVENTORYDESCENDANTS]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); | ||
126 | caps.RegisterHandler("WebFetchInventoryDescendents", m_URL); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | } | ||
131 | } | ||