aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs71
1 files changed, 49 insertions, 22 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
index 1c1d83c..10f43d1 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
@@ -42,18 +42,25 @@ using OpenSim.Capabilities.Handlers;
42 42
43namespace OpenSim.Region.ClientStack.Linden 43namespace OpenSim.Region.ClientStack.Linden
44{ 44{
45 45 /// <summary>
46 /// This module implements both WebFetchInventoryDescendents and FetchInventoryDescendents2 capabilities.
47 /// </summary>
46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 48 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
47 public class WebFetchInvDescModule : INonSharedRegionModule 49 public class WebFetchInvDescModule : INonSharedRegionModule
48 { 50 {
49 private static readonly ILog m_log = 51// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52
51 private Scene m_scene; 53 private Scene m_scene;
52 54
53 private IInventoryService m_InventoryService; 55 private IInventoryService m_InventoryService;
54 private ILibraryService m_LibraryService; 56 private ILibraryService m_LibraryService;
55 private bool m_Enabled = false; 57
56 private string m_URL; 58 private bool m_Enabled;
59
60 private string m_fetchInventoryDescendents2Url;
61 private string m_webFetchInventoryDescendentsUrl;
62
63 private WebFetchInvDescHandler m_webFetchHandler;
57 64
58 #region ISharedRegionModule Members 65 #region ISharedRegionModule Members
59 66
@@ -63,10 +70,13 @@ namespace OpenSim.Region.ClientStack.Linden
63 if (config == null) 70 if (config == null)
64 return; 71 return;
65 72
66 m_URL = config.GetString("Cap_WebFetchInventoryDescendents", string.Empty); 73 m_fetchInventoryDescendents2Url = config.GetString("Cap_FetchInventoryDescendents2", string.Empty);
67 // Cap doesn't exist 74 m_webFetchInventoryDescendentsUrl = config.GetString("Cap_WebFetchInventoryDescendents", string.Empty);
68 if (m_URL != string.Empty) 75
76 if (m_fetchInventoryDescendents2Url != string.Empty || m_webFetchInventoryDescendentsUrl != string.Empty)
77 {
69 m_Enabled = true; 78 m_Enabled = true;
79 }
70 } 80 }
71 81
72 public void AddRegion(Scene s) 82 public void AddRegion(Scene s)
@@ -91,8 +101,13 @@ namespace OpenSim.Region.ClientStack.Linden
91 if (!m_Enabled) 101 if (!m_Enabled)
92 return; 102 return;
93 103
94 m_InventoryService = m_scene.InventoryService; ; 104 m_InventoryService = m_scene.InventoryService;
95 m_LibraryService = m_scene.LibraryService; 105 m_LibraryService = m_scene.LibraryService;
106
107 // We'll reuse the same handler for all requests.
108 if (m_fetchInventoryDescendents2Url == "localhost" || m_webFetchInventoryDescendentsUrl == "localhost")
109 m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService);
110
96 m_scene.EventManager.OnRegisterCaps += RegisterCaps; 111 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
97 } 112 }
98 113
@@ -111,26 +126,38 @@ namespace OpenSim.Region.ClientStack.Linden
111 126
112 #endregion 127 #endregion
113 128
114 public void RegisterCaps(UUID agentID, Caps caps) 129 private void RegisterCaps(UUID agentID, Caps caps)
115 { 130 {
116 UUID capID = UUID.Random(); 131 if (m_webFetchInventoryDescendentsUrl != "")
132 RegisterFetchCap(agentID, caps, "WebFetchInventoryDescendents", m_webFetchInventoryDescendentsUrl);
117 133
118 //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); 134 if (m_fetchInventoryDescendents2Url != "")
119 if (m_URL == "localhost") 135 RegisterFetchCap(agentID, caps, "FetchInventoryDescendents2", m_fetchInventoryDescendents2Url);
136 }
137
138 private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url)
139 {
140 string capUrl;
141
142 if (url == "localhost")
120 { 143 {
121 m_log.InfoFormat("[WEBFETCHINVENTORYDESCENDANTS]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); 144 capUrl = "/CAPS/" + UUID.Random();
122 WebFetchInvDescHandler webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService); 145
123 IRequestHandler reqHandler = new RestStreamHandler("POST", "/CAPS/" + UUID.Random(), webFetchHandler.FetchInventoryDescendentsRequest); 146 IRequestHandler reqHandler
124 caps.RegisterHandler("WebFetchInventoryDescendents", reqHandler); 147 = new RestStreamHandler("POST", capUrl, m_webFetchHandler.FetchInventoryDescendentsRequest);
125// caps.RegisterHandler("FetchInventoryDescendents2", reqHandler); 148
149 caps.RegisterHandler(capName, reqHandler);
126 } 150 }
127 else 151 else
128 { 152 {
129 m_log.InfoFormat("[WEBFETCHINVENTORYDESCENDANTS]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); 153 capUrl = url;
130 caps.RegisterHandler("WebFetchInventoryDescendents", m_URL); 154
131// caps.RegisterHandler("FetchInventoryDescendents2", m_URL); 155 caps.RegisterHandler(capName, capUrl);
132 } 156 }
133 }
134 157
158// m_log.DebugFormat(
159// "[WEB FETCH INV DESC MODULE]: Registered capability {0} at {1} in region {2} for {3}",
160// capName, capUrl, m_scene.RegionInfo.RegionName, agentID);
161 }
135 } 162 }
136} 163}