diff options
author | Mic Bowman | 2013-07-31 15:37:15 -0700 |
---|---|---|
committer | Mic Bowman | 2013-07-31 15:37:15 -0700 |
commit | 12995924052a1804f01dceb80803447fccc1d9fe (patch) | |
tree | 161d718478d91b01c82a44c11c0923d2b50625c0 | |
parent | Add the Simian service config to the GridCommon example (diff) | |
download | opensim-SC_OLD-12995924052a1804f01dceb80803447fccc1d9fe.zip opensim-SC_OLD-12995924052a1804f01dceb80803447fccc1d9fe.tar.gz opensim-SC_OLD-12995924052a1804f01dceb80803447fccc1d9fe.tar.bz2 opensim-SC_OLD-12995924052a1804f01dceb80803447fccc1d9fe.tar.xz |
Experimental comment to eneralize the handling of Linden caps when the
cap is something other than "localhost". A new interface for handling
external caps is supported with an example implemented for Simian. The
only linden cap supporting this interface right now is the GetTexture
cap.
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Interfaces/IExternalCapsModule.cs | 48 | ||||
-rw-r--r-- | OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs | 179 | ||||
-rw-r--r-- | prebuild.xml | 1 |
4 files changed, 233 insertions, 1 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 13415f8..54cf285 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -137,7 +137,11 @@ namespace OpenSim.Region.ClientStack.Linden | |||
137 | else | 137 | else |
138 | { | 138 | { |
139 | // m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); | 139 | // m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); |
140 | caps.RegisterHandler("GetTexture", m_URL); | 140 | IExternalCapsModule handler = m_scene.RequestModuleInterface<IExternalCapsModule>(); |
141 | if (handler != null) | ||
142 | handler.RegisterExternalUserCapsHandler(agentID,caps,"GetTexture",m_URL); | ||
143 | else | ||
144 | caps.RegisterHandler("GetTexture", m_URL); | ||
141 | } | 145 | } |
142 | } | 146 | } |
143 | 147 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IExternalCapsModule.cs b/OpenSim/Region/Framework/Interfaces/IExternalCapsModule.cs new file mode 100644 index 0000000..a730cfd --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IExternalCapsModule.cs | |||
@@ -0,0 +1,48 @@ | |||
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 OpenMetaverse; | ||
30 | using OpenSim.Framework; | ||
31 | using Caps=OpenSim.Framework.Capabilities.Caps; | ||
32 | |||
33 | namespace OpenSim.Region.Framework.Interfaces | ||
34 | { | ||
35 | public interface IExternalCapsModule | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// This function extends the simple URL configuration in the caps handlers | ||
39 | /// to facilitate more interesting computation when an external handler is | ||
40 | /// sent to the viewer. | ||
41 | /// </summary> | ||
42 | /// <param name="agentID">New user UUID</param> | ||
43 | /// <param name="caps">Internal caps registry, where the external handler will be registered</param> | ||
44 | /// <param name="capName">Name of the specific cap we are registering</param> | ||
45 | /// <param name="urlSkel">The skeleton URL provided in the caps configuration</param> | ||
46 | bool RegisterExternalUserCapsHandler(UUID agentID, Caps caps, String capName, String urlSkel); | ||
47 | } | ||
48 | } | ||
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs new file mode 100644 index 0000000..8226705 --- /dev/null +++ b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs | |||
@@ -0,0 +1,179 @@ | |||
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.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Web; | ||
34 | |||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using Mono.Addins; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.StructuredData; | ||
41 | |||
42 | using OpenSim.Framework; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Region.Framework.Scenes; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
47 | |||
48 | namespace OpenSim.Services.Connectors.SimianGrid | ||
49 | { | ||
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")] | ||
51 | public class SimianExternalCapsModule : INonSharedRegionModule, IExternalCapsModule | ||
52 | { | ||
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | |||
55 | private bool m_enabled = true; | ||
56 | private Scene m_scene; | ||
57 | private String m_simianURL; | ||
58 | |||
59 | private IGridUserService m_GridUserService; | ||
60 | |||
61 | #region IRegionModule Members | ||
62 | |||
63 | |||
64 | public string Name | ||
65 | { | ||
66 | get { return this.GetType().Name; } | ||
67 | } | ||
68 | |||
69 | public void Initialise(IConfigSource config) | ||
70 | { | ||
71 | try | ||
72 | { | ||
73 | IConfig m_config; | ||
74 | |||
75 | if ((m_config = config.Configs["SimianExternalCaps"]) != null) | ||
76 | { | ||
77 | m_enabled = m_config.GetBoolean("Enabled", m_enabled); | ||
78 | if ((m_config = config.Configs["SimianGrid"]) != null) | ||
79 | { | ||
80 | m_simianURL = m_config.GetString("SimianServiceURL"); | ||
81 | if (String.IsNullOrEmpty(m_simianURL)) | ||
82 | m_log.ErrorFormat("[SimianGrid] service URL is not defined"); | ||
83 | } | ||
84 | } | ||
85 | else | ||
86 | m_enabled = false; | ||
87 | } | ||
88 | catch (Exception e) | ||
89 | { | ||
90 | m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message); | ||
91 | return; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | public void PostInitialise() { } | ||
96 | public void Close() { } | ||
97 | |||
98 | public void AddRegion(Scene scene) | ||
99 | { | ||
100 | if (! m_enabled) | ||
101 | return; | ||
102 | |||
103 | m_scene = scene; | ||
104 | m_scene.RegisterModuleInterface<IExternalCapsModule>(this); | ||
105 | } | ||
106 | |||
107 | public void RemoveRegion(Scene scene) | ||
108 | { | ||
109 | if (! m_enabled) | ||
110 | return; | ||
111 | |||
112 | m_scene.EventManager.OnRegisterCaps -= RegisterCapsEventHandler; | ||
113 | m_scene.EventManager.OnDeregisterCaps -= DeregisterCapsEventHandler; | ||
114 | } | ||
115 | |||
116 | public void RegionLoaded(Scene scene) | ||
117 | { | ||
118 | if (! m_enabled) | ||
119 | return; | ||
120 | |||
121 | m_scene.EventManager.OnRegisterCaps += RegisterCapsEventHandler; | ||
122 | m_scene.EventManager.OnDeregisterCaps += DeregisterCapsEventHandler; | ||
123 | } | ||
124 | |||
125 | public Type ReplaceableInterface | ||
126 | { | ||
127 | get { return null; } | ||
128 | } | ||
129 | |||
130 | #endregion | ||
131 | |||
132 | #region IExternalCapsModule | ||
133 | // Eg http://grid.sciencesim.com/GridPublic/%CAP%/%OP%/" | ||
134 | public bool RegisterExternalUserCapsHandler(UUID agentID, Caps caps, String capName, String urlSkel) | ||
135 | { | ||
136 | UUID cap = UUID.Random(); | ||
137 | |||
138 | // Call to simian to register the cap we generated | ||
139 | // NameValueCollection requestArgs = new NameValueCollection | ||
140 | // { | ||
141 | // { "RequestMethod", "AddCapability" }, | ||
142 | // { "Resource", "user" }, | ||
143 | // { "Expiration", 0 }, | ||
144 | // { "OwnerID", agentID.ToString() }, | ||
145 | // { "CapabilityID", cap.ToString() } | ||
146 | // }; | ||
147 | |||
148 | // OSDMap response = SimianGrid.PostToService(m_simianURL, requestArgs); | ||
149 | |||
150 | Dictionary<String,String> subs = new Dictionary<String,String>(); | ||
151 | subs["%OP%"] = capName; | ||
152 | subs["%USR%"] = agentID.ToString(); | ||
153 | subs["%CAP%"] = cap.ToString(); | ||
154 | subs["%SIM%"] = m_scene.RegionInfo.RegionID.ToString(); | ||
155 | |||
156 | caps.RegisterHandler(capName,ExpandSkeletonURL(urlSkel,subs)); | ||
157 | return true; | ||
158 | } | ||
159 | |||
160 | #endregion | ||
161 | |||
162 | #region EventHandlers | ||
163 | public void RegisterCapsEventHandler(UUID agentID, Caps caps) { } | ||
164 | public void DeregisterCapsEventHandler(UUID agentID, Caps caps) { } | ||
165 | #endregion | ||
166 | |||
167 | private String ExpandSkeletonURL(String urlSkel, Dictionary<String,String> subs) | ||
168 | { | ||
169 | String result = urlSkel; | ||
170 | |||
171 | foreach (KeyValuePair<String,String> kvp in subs) | ||
172 | { | ||
173 | result = result.Replace(kvp.Key,kvp.Value); | ||
174 | } | ||
175 | |||
176 | return result; | ||
177 | } | ||
178 | } | ||
179 | } \ No newline at end of file | ||
diff --git a/prebuild.xml b/prebuild.xml index 91c326c..b376e86 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -869,6 +869,7 @@ | |||
869 | <Reference name="Mono.Addins" path="../../../bin/"/> | 869 | <Reference name="Mono.Addins" path="../../../bin/"/> |
870 | <Reference name="OpenSim.Data"/> | 870 | <Reference name="OpenSim.Data"/> |
871 | <Reference name="OpenSim.Framework"/> | 871 | <Reference name="OpenSim.Framework"/> |
872 | <Reference name="OpenSim.Capabilities"/> | ||
872 | <Reference name="OpenSim.Framework.Communications"/> | 873 | <Reference name="OpenSim.Framework.Communications"/> |
873 | <Reference name="OpenSim.Framework.Console"/> | 874 | <Reference name="OpenSim.Framework.Console"/> |
874 | <Reference name="OpenSim.Region.Framework"/> | 875 | <Reference name="OpenSim.Region.Framework"/> |