diff options
Renamed Region/CoreModules/ServiceConnectors to Region/CoreModules/ServiceConnectorsOut. No functional changes.
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectors/Inventory')
3 files changed, 0 insertions, 966 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/HGInventoryBroker.cs deleted file mode 100644 index ac2eaed..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/HGInventoryBroker.cs +++ /dev/null | |||
@@ -1,401 +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 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 log4net; | ||
29 | using Nini.Config; | ||
30 | using System; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Reflection; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using OpenSim.Services.Connectors; | ||
40 | using OpenMetaverse; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory | ||
43 | { | ||
44 | public class HGInventoryBroker : ISharedRegionModule, IInventoryService | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger( | ||
48 | MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private bool m_Enabled = false; | ||
51 | private bool m_Initialized = false; | ||
52 | private Scene m_Scene; | ||
53 | private UserProfileCacheService m_UserProfileService; // This should change to IUserProfileService | ||
54 | |||
55 | private IInventoryService m_GridService; | ||
56 | private ISessionAuthInventoryService m_HGService; | ||
57 | |||
58 | private string m_LocalGridInventoryURI = string.Empty; | ||
59 | public string Name | ||
60 | { | ||
61 | get { return "HGInventoryBroker"; } | ||
62 | } | ||
63 | |||
64 | public void Initialise(IConfigSource source) | ||
65 | { | ||
66 | IConfig moduleConfig = source.Configs["Modules"]; | ||
67 | if (moduleConfig != null) | ||
68 | { | ||
69 | string name = moduleConfig.GetString("InventoryServices", ""); | ||
70 | if (name == Name) | ||
71 | { | ||
72 | IConfig inventoryConfig = source.Configs["InventoryService"]; | ||
73 | if (inventoryConfig == null) | ||
74 | { | ||
75 | m_log.Error("[HG INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini"); | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | string localDll = inventoryConfig.GetString("LocalGridInventoryService", | ||
80 | String.Empty); | ||
81 | string HGDll = inventoryConfig.GetString("HypergridInventoryService", | ||
82 | String.Empty); | ||
83 | |||
84 | if (localDll == String.Empty) | ||
85 | { | ||
86 | m_log.Error("[HG INVENTORY CONNECTOR]: No LocalGridInventoryService named in section InventoryService"); | ||
87 | //return; | ||
88 | throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); | ||
89 | } | ||
90 | |||
91 | if (HGDll == String.Empty) | ||
92 | { | ||
93 | m_log.Error("[HG INVENTORY CONNECTOR]: No HypergridInventoryService named in section InventoryService"); | ||
94 | //return; | ||
95 | throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); | ||
96 | } | ||
97 | |||
98 | Object[] args = new Object[] { source }; | ||
99 | m_GridService = | ||
100 | ServerUtils.LoadPlugin<IInventoryService>(localDll, | ||
101 | args); | ||
102 | |||
103 | m_HGService = | ||
104 | ServerUtils.LoadPlugin<ISessionAuthInventoryService>(HGDll, | ||
105 | args); | ||
106 | |||
107 | if (m_GridService == null) | ||
108 | { | ||
109 | m_log.Error("[HG INVENTORY CONNECTOR]: Can't load local inventory service"); | ||
110 | return; | ||
111 | } | ||
112 | if (m_HGService == null) | ||
113 | { | ||
114 | m_log.Error("[HG INVENTORY CONNECTOR]: Can't load hypergrid inventory service"); | ||
115 | return; | ||
116 | } | ||
117 | |||
118 | m_LocalGridInventoryURI = inventoryConfig.GetString("InventoryServerURI", string.Empty); | ||
119 | |||
120 | m_Enabled = true; | ||
121 | m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled"); | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | |||
126 | public void PostInitialise() | ||
127 | { | ||
128 | } | ||
129 | |||
130 | public void Close() | ||
131 | { | ||
132 | } | ||
133 | |||
134 | public void AddRegion(Scene scene) | ||
135 | { | ||
136 | if (!m_Enabled) | ||
137 | return; | ||
138 | |||
139 | if (!m_Initialized) | ||
140 | { | ||
141 | m_Scene = scene; | ||
142 | // HACK for now. Ugh! | ||
143 | m_UserProfileService = m_Scene.CommsManager.UserProfileCacheService; | ||
144 | // ugh! | ||
145 | m_UserProfileService.SetInventoryService(this); | ||
146 | scene.CommsManager.UserService.SetInventoryService(this); | ||
147 | |||
148 | m_Initialized = true; | ||
149 | } | ||
150 | |||
151 | scene.RegisterModuleInterface<IInventoryService>(this); | ||
152 | } | ||
153 | |||
154 | public void RemoveRegion(Scene scene) | ||
155 | { | ||
156 | } | ||
157 | |||
158 | public void RegionLoaded(Scene scene) | ||
159 | { | ||
160 | if (!m_Enabled) | ||
161 | return; | ||
162 | |||
163 | m_log.InfoFormat("[INVENTORY CONNECTOR]: Enabled HG inventory for region {0}", scene.RegionInfo.RegionName); | ||
164 | |||
165 | } | ||
166 | |||
167 | #region IInventoryService | ||
168 | |||
169 | public bool CreateUserInventory(UUID userID) | ||
170 | { | ||
171 | return m_GridService.CreateUserInventory(userID); | ||
172 | } | ||
173 | |||
174 | public List<InventoryFolderBase> GetInventorySkeleton(UUID userId) | ||
175 | { | ||
176 | return m_GridService.GetInventorySkeleton(userId); | ||
177 | } | ||
178 | |||
179 | public InventoryCollection GetUserInventory(UUID userID) | ||
180 | { | ||
181 | if (IsLocalGridUser(userID)) | ||
182 | return m_GridService.GetUserInventory(userID); | ||
183 | else | ||
184 | return null; | ||
185 | } | ||
186 | |||
187 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) | ||
188 | { | ||
189 | if (IsLocalGridUser(userID)) | ||
190 | m_GridService.GetUserInventory(userID, callback); | ||
191 | else | ||
192 | { | ||
193 | UUID sessionID = GetSessionID(userID); | ||
194 | string uri = GetUserInventoryURI(userID) + "/" + userID.ToString(); | ||
195 | m_HGService.GetUserInventory(uri, sessionID, callback); | ||
196 | } | ||
197 | } | ||
198 | |||
199 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) | ||
200 | { | ||
201 | return new List<InventoryItemBase>(); | ||
202 | } | ||
203 | |||
204 | public bool AddFolder(InventoryFolderBase folder) | ||
205 | { | ||
206 | if (folder == null) | ||
207 | return false; | ||
208 | |||
209 | if (IsLocalGridUser(folder.Owner)) | ||
210 | return m_GridService.AddFolder(folder); | ||
211 | else | ||
212 | { | ||
213 | UUID sessionID = GetSessionID(folder.Owner); | ||
214 | string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); | ||
215 | return m_HGService.AddFolder(uri, folder, sessionID); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | public bool UpdateFolder(InventoryFolderBase folder) | ||
220 | { | ||
221 | if (folder == null) | ||
222 | return false; | ||
223 | |||
224 | if (IsLocalGridUser(folder.Owner)) | ||
225 | return m_GridService.UpdateFolder(folder); | ||
226 | else | ||
227 | { | ||
228 | UUID sessionID = GetSessionID(folder.Owner); | ||
229 | string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); | ||
230 | return m_HGService.UpdateFolder(uri, folder, sessionID); | ||
231 | } | ||
232 | } | ||
233 | |||
234 | public bool MoveFolder(InventoryFolderBase folder) | ||
235 | { | ||
236 | if (folder == null) | ||
237 | return false; | ||
238 | |||
239 | if (IsLocalGridUser(folder.Owner)) | ||
240 | return m_GridService.MoveFolder(folder); | ||
241 | else | ||
242 | { | ||
243 | UUID sessionID = GetSessionID(folder.Owner); | ||
244 | string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); | ||
245 | return m_HGService.MoveFolder(uri, folder, sessionID); | ||
246 | } | ||
247 | } | ||
248 | |||
249 | public bool PurgeFolder(InventoryFolderBase folder) | ||
250 | { | ||
251 | if (folder == null) | ||
252 | return false; | ||
253 | |||
254 | if (IsLocalGridUser(folder.Owner)) | ||
255 | return m_GridService.PurgeFolder(folder); | ||
256 | else | ||
257 | { | ||
258 | UUID sessionID = GetSessionID(folder.Owner); | ||
259 | string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); | ||
260 | return m_HGService.PurgeFolder(uri, folder, sessionID); | ||
261 | } | ||
262 | } | ||
263 | |||
264 | public bool AddItem(InventoryItemBase item) | ||
265 | { | ||
266 | if (item == null) | ||
267 | return false; | ||
268 | |||
269 | if (IsLocalGridUser(item.Owner)) | ||
270 | return m_GridService.AddItem(item); | ||
271 | else | ||
272 | { | ||
273 | UUID sessionID = GetSessionID(item.Owner); | ||
274 | string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); | ||
275 | return m_HGService.AddItem(uri, item, sessionID); | ||
276 | } | ||
277 | } | ||
278 | |||
279 | public bool UpdateItem(InventoryItemBase item) | ||
280 | { | ||
281 | if (item == null) | ||
282 | return false; | ||
283 | |||
284 | if (IsLocalGridUser(item.Owner)) | ||
285 | return m_GridService.UpdateItem(item); | ||
286 | else | ||
287 | { | ||
288 | UUID sessionID = GetSessionID(item.Owner); | ||
289 | string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); | ||
290 | return m_HGService.UpdateItem(uri, item, sessionID); | ||
291 | } | ||
292 | } | ||
293 | |||
294 | public bool DeleteItem(InventoryItemBase item) | ||
295 | { | ||
296 | if (item == null) | ||
297 | return false; | ||
298 | |||
299 | if (IsLocalGridUser(item.Owner)) | ||
300 | return m_GridService.DeleteItem(item); | ||
301 | else | ||
302 | { | ||
303 | UUID sessionID = GetSessionID(item.Owner); | ||
304 | string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); | ||
305 | return m_HGService.DeleteItem(uri, item, sessionID); | ||
306 | } | ||
307 | } | ||
308 | |||
309 | public InventoryItemBase QueryItem(InventoryItemBase item) | ||
310 | { | ||
311 | if (item == null) | ||
312 | return null; | ||
313 | |||
314 | if (IsLocalGridUser(item.Owner)) | ||
315 | return m_GridService.QueryItem(item); | ||
316 | else | ||
317 | { | ||
318 | UUID sessionID = GetSessionID(item.Owner); | ||
319 | string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); | ||
320 | return m_HGService.QueryItem(uri, item, sessionID); | ||
321 | } | ||
322 | } | ||
323 | |||
324 | public InventoryFolderBase QueryFolder(InventoryFolderBase folder) | ||
325 | { | ||
326 | if (folder == null) | ||
327 | return null; | ||
328 | |||
329 | if (IsLocalGridUser(folder.Owner)) | ||
330 | return m_GridService.QueryFolder(folder); | ||
331 | else | ||
332 | { | ||
333 | UUID sessionID = GetSessionID(folder.Owner); | ||
334 | string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); | ||
335 | return m_HGService.QueryFolder(uri, folder, sessionID); | ||
336 | } | ||
337 | } | ||
338 | |||
339 | public bool HasInventoryForUser(UUID userID) | ||
340 | { | ||
341 | return false; | ||
342 | } | ||
343 | |||
344 | public InventoryFolderBase RequestRootFolder(UUID userID) | ||
345 | { | ||
346 | return null; | ||
347 | } | ||
348 | |||
349 | public List<InventoryItemBase> GetActiveGestures(UUID userId) | ||
350 | { | ||
351 | return new List<InventoryItemBase>(); | ||
352 | } | ||
353 | |||
354 | #endregion | ||
355 | |||
356 | private UUID GetSessionID(UUID userID) | ||
357 | { | ||
358 | ScenePresence sp = m_Scene.GetScenePresence(userID); | ||
359 | if (sp != null) | ||
360 | return sp.ControllingClient.SessionId; | ||
361 | |||
362 | return UUID.Zero; | ||
363 | } | ||
364 | |||
365 | private bool IsLocalGridUser(UUID userID) | ||
366 | { | ||
367 | if (m_UserProfileService == null) | ||
368 | return false; | ||
369 | |||
370 | CachedUserInfo uinfo = m_UserProfileService.GetUserDetails(userID); | ||
371 | if (uinfo == null) | ||
372 | return true; | ||
373 | |||
374 | string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); | ||
375 | |||
376 | if ((userInventoryServerURI == m_LocalGridInventoryURI) || (userInventoryServerURI == "")) | ||
377 | { | ||
378 | return true; | ||
379 | } | ||
380 | return false; | ||
381 | } | ||
382 | |||
383 | private string GetUserInventoryURI(UUID userID) | ||
384 | { | ||
385 | string invURI = m_LocalGridInventoryURI; | ||
386 | |||
387 | CachedUserInfo uinfo = m_UserProfileService.GetUserDetails(userID); | ||
388 | if ((uinfo == null) || (uinfo.UserProfile == null)) | ||
389 | return invURI; | ||
390 | |||
391 | string userInventoryServerURI = HGNetworkServersInfo.ServerURI(uinfo.UserProfile.UserInventoryURI); | ||
392 | |||
393 | if ((userInventoryServerURI != null) && | ||
394 | (userInventoryServerURI != "")) | ||
395 | invURI = userInventoryServerURI; | ||
396 | return invURI; | ||
397 | } | ||
398 | |||
399 | |||
400 | } | ||
401 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/LocalInventoryServiceConnector.cs deleted file mode 100644 index 750f1cb..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/LocalInventoryServiceConnector.cs +++ /dev/null | |||
@@ -1,286 +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 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 log4net; | ||
29 | using Nini.Config; | ||
30 | |||
31 | using System; | ||
32 | using System.Collections.Generic; | ||
33 | using System.Reflection; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Data; | ||
36 | using OpenSim.Server.Base; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using OpenMetaverse; | ||
41 | |||
42 | |||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory | ||
44 | { | ||
45 | public class LocalInventoryServicesConnector : ISharedRegionModule, IInventoryService | ||
46 | { | ||
47 | private static readonly ILog m_log = | ||
48 | LogManager.GetLogger( | ||
49 | MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private IInventoryService m_InventoryService; | ||
52 | |||
53 | private bool m_Enabled = false; | ||
54 | private bool m_Initialized = false; | ||
55 | |||
56 | public string Name | ||
57 | { | ||
58 | get { return "LocalInventoryServicesConnector"; } | ||
59 | } | ||
60 | |||
61 | public void Initialise(IConfigSource source) | ||
62 | { | ||
63 | IConfig moduleConfig = source.Configs["Modules"]; | ||
64 | if (moduleConfig != null) | ||
65 | { | ||
66 | string name = moduleConfig.GetString("InventoryServices", ""); | ||
67 | if (name == Name) | ||
68 | { | ||
69 | IConfig inventoryConfig = source.Configs["InventoryService"]; | ||
70 | if (inventoryConfig == null) | ||
71 | { | ||
72 | m_log.Error("[INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini"); | ||
73 | return; | ||
74 | } | ||
75 | |||
76 | string serviceDll = inventoryConfig.GetString("LocalServiceModule", String.Empty); | ||
77 | |||
78 | if (serviceDll == String.Empty) | ||
79 | { | ||
80 | m_log.Error("[INVENTORY CONNECTOR]: No LocalServiceModule named in section InventoryService"); | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | Object[] args = new Object[] { source }; | ||
85 | m_log.DebugFormat("[INVENTORY CONNECTOR]: Service dll = {0}", serviceDll); | ||
86 | |||
87 | m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(serviceDll, args); | ||
88 | |||
89 | if (m_InventoryService == null) | ||
90 | { | ||
91 | m_log.Error("[INVENTORY CONNECTOR]: Can't load inventory service"); | ||
92 | //return; | ||
93 | throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); | ||
94 | } | ||
95 | |||
96 | //List<IInventoryDataPlugin> plugins | ||
97 | // = DataPluginFactory.LoadDataPlugins<IInventoryDataPlugin>( | ||
98 | // configSettings.StandaloneInventoryPlugin, | ||
99 | // configSettings.StandaloneInventorySource); | ||
100 | |||
101 | //foreach (IInventoryDataPlugin plugin in plugins) | ||
102 | //{ | ||
103 | // // Using the OSP wrapper plugin for database plugins should be made configurable at some point | ||
104 | // m_InventoryService.AddPlugin(new OspInventoryWrapperPlugin(plugin, this)); | ||
105 | //} | ||
106 | |||
107 | m_Enabled = true; | ||
108 | m_log.Info("[INVENTORY CONNECTOR]: Local inventory connector enabled"); | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | |||
113 | public void PostInitialise() | ||
114 | { | ||
115 | } | ||
116 | |||
117 | public void Close() | ||
118 | { | ||
119 | } | ||
120 | |||
121 | public void AddRegion(Scene scene) | ||
122 | { | ||
123 | if (!m_Enabled) | ||
124 | return; | ||
125 | |||
126 | if (!m_Initialized) | ||
127 | { | ||
128 | // ugh! | ||
129 | scene.CommsManager.UserProfileCacheService.SetInventoryService(this); | ||
130 | scene.CommsManager.UserService.SetInventoryService(this); | ||
131 | m_Initialized = true; | ||
132 | } | ||
133 | |||
134 | // m_log.DebugFormat( | ||
135 | // "[INVENTORY CONNECTOR]: Registering IInventoryService to scene {0}", scene.RegionInfo.RegionName); | ||
136 | |||
137 | scene.RegisterModuleInterface<IInventoryService>(this); | ||
138 | } | ||
139 | |||
140 | public void RemoveRegion(Scene scene) | ||
141 | { | ||
142 | } | ||
143 | |||
144 | public void RegionLoaded(Scene scene) | ||
145 | { | ||
146 | if (!m_Enabled) | ||
147 | return; | ||
148 | |||
149 | m_log.InfoFormat( | ||
150 | "[INVENTORY CONNECTOR]: Enabled local invnetory for region {0}", scene.RegionInfo.RegionName); | ||
151 | } | ||
152 | |||
153 | #region IInventoryService | ||
154 | |||
155 | public bool CreateUserInventory(UUID user) | ||
156 | { | ||
157 | return m_InventoryService.CreateUserInventory(user); | ||
158 | } | ||
159 | |||
160 | public List<InventoryFolderBase> GetInventorySkeleton(UUID userId) | ||
161 | { | ||
162 | return m_InventoryService.GetInventorySkeleton(userId); | ||
163 | } | ||
164 | |||
165 | public InventoryCollection GetUserInventory(UUID id) | ||
166 | { | ||
167 | return m_InventoryService.GetUserInventory(id); | ||
168 | } | ||
169 | |||
170 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) | ||
171 | { | ||
172 | m_InventoryService.GetUserInventory(userID, callback); | ||
173 | } | ||
174 | |||
175 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) | ||
176 | { | ||
177 | return m_InventoryService.GetFolderItems(userID, folderID); | ||
178 | } | ||
179 | |||
180 | /// <summary> | ||
181 | /// Add a new folder to the user's inventory | ||
182 | /// </summary> | ||
183 | /// <param name="folder"></param> | ||
184 | /// <returns>true if the folder was successfully added</returns> | ||
185 | public bool AddFolder(InventoryFolderBase folder) | ||
186 | { | ||
187 | return m_InventoryService.AddFolder(folder); | ||
188 | } | ||
189 | |||
190 | /// <summary> | ||
191 | /// Update a folder in the user's inventory | ||
192 | /// </summary> | ||
193 | /// <param name="folder"></param> | ||
194 | /// <returns>true if the folder was successfully updated</returns> | ||
195 | public bool UpdateFolder(InventoryFolderBase folder) | ||
196 | { | ||
197 | return m_InventoryService.UpdateFolder(folder); | ||
198 | } | ||
199 | |||
200 | /// <summary> | ||
201 | /// Move an inventory folder to a new location | ||
202 | /// </summary> | ||
203 | /// <param name="folder">A folder containing the details of the new location</param> | ||
204 | /// <returns>true if the folder was successfully moved</returns> | ||
205 | public bool MoveFolder(InventoryFolderBase folder) | ||
206 | { | ||
207 | return m_InventoryService.MoveFolder(folder); | ||
208 | } | ||
209 | |||
210 | /// <summary> | ||
211 | /// Purge an inventory folder of all its items and subfolders. | ||
212 | /// </summary> | ||
213 | /// <param name="folder"></param> | ||
214 | /// <returns>true if the folder was successfully purged</returns> | ||
215 | public bool PurgeFolder(InventoryFolderBase folder) | ||
216 | { | ||
217 | return m_InventoryService.PurgeFolder(folder); | ||
218 | } | ||
219 | |||
220 | /// <summary> | ||
221 | /// Add a new item to the user's inventory | ||
222 | /// </summary> | ||
223 | /// <param name="item"></param> | ||
224 | /// <returns>true if the item was successfully added</returns> | ||
225 | public bool AddItem(InventoryItemBase item) | ||
226 | { | ||
227 | return m_InventoryService.AddItem(item); | ||
228 | } | ||
229 | |||
230 | /// <summary> | ||
231 | /// Update an item in the user's inventory | ||
232 | /// </summary> | ||
233 | /// <param name="item"></param> | ||
234 | /// <returns>true if the item was successfully updated</returns> | ||
235 | public bool UpdateItem(InventoryItemBase item) | ||
236 | { | ||
237 | return m_InventoryService.UpdateItem(item); | ||
238 | } | ||
239 | |||
240 | /// <summary> | ||
241 | /// Delete an item from the user's inventory | ||
242 | /// </summary> | ||
243 | /// <param name="item"></param> | ||
244 | /// <returns>true if the item was successfully deleted</returns> | ||
245 | public bool DeleteItem(InventoryItemBase item) | ||
246 | { | ||
247 | return m_InventoryService.DeleteItem(item); | ||
248 | } | ||
249 | |||
250 | public InventoryItemBase QueryItem(InventoryItemBase item) | ||
251 | { | ||
252 | return m_InventoryService.QueryItem(item); | ||
253 | } | ||
254 | |||
255 | public InventoryFolderBase QueryFolder(InventoryFolderBase folder) | ||
256 | { | ||
257 | return m_InventoryService.QueryFolder(folder); | ||
258 | } | ||
259 | |||
260 | /// <summary> | ||
261 | /// Does the given user have an inventory structure? | ||
262 | /// </summary> | ||
263 | /// <param name="userID"></param> | ||
264 | /// <returns></returns> | ||
265 | public bool HasInventoryForUser(UUID userID) | ||
266 | { | ||
267 | return m_InventoryService.HasInventoryForUser(userID); | ||
268 | } | ||
269 | |||
270 | /// <summary> | ||
271 | /// Retrieve the root inventory folder for the given user. | ||
272 | /// </summary> | ||
273 | /// <param name="userID"></param> | ||
274 | /// <returns>null if no root folder was found</returns> | ||
275 | public InventoryFolderBase RequestRootFolder(UUID userID) | ||
276 | { | ||
277 | return m_InventoryService.RequestRootFolder(userID); | ||
278 | } | ||
279 | |||
280 | public List<InventoryItemBase> GetActiveGestures(UUID userId) | ||
281 | { | ||
282 | return m_InventoryService.GetActiveGestures(userId); | ||
283 | } | ||
284 | #endregion IInventoryService | ||
285 | } | ||
286 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/RemoteInventoryServiceConnector.cs deleted file mode 100644 index 5a31f23..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/RemoteInventoryServiceConnector.cs +++ /dev/null | |||
@@ -1,279 +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 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 log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Statistics; | ||
35 | using OpenSim.Services.Connectors; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using OpenMetaverse; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory | ||
42 | { | ||
43 | public class RemoteInventoryServicesConnector : ISharedRegionModule, IInventoryService | ||
44 | { | ||
45 | private static readonly ILog m_log = | ||
46 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private bool m_Enabled = false; | ||
49 | private bool m_Initialized = false; | ||
50 | private Scene m_Scene; | ||
51 | private InventoryServicesConnector m_RemoteConnector; | ||
52 | |||
53 | public string Name | ||
54 | { | ||
55 | get { return "RemoteInventoryServicesConnector"; } | ||
56 | } | ||
57 | |||
58 | public RemoteInventoryServicesConnector() | ||
59 | { | ||
60 | } | ||
61 | |||
62 | public RemoteInventoryServicesConnector(IConfigSource source) | ||
63 | { | ||
64 | Init(source); | ||
65 | } | ||
66 | |||
67 | private void Init(IConfigSource source) | ||
68 | { | ||
69 | m_RemoteConnector = new InventoryServicesConnector(source); | ||
70 | } | ||
71 | |||
72 | |||
73 | #region ISharedRegionModule | ||
74 | |||
75 | public void Initialise(IConfigSource source) | ||
76 | { | ||
77 | IConfig moduleConfig = source.Configs["Modules"]; | ||
78 | if (moduleConfig != null) | ||
79 | { | ||
80 | string name = moduleConfig.GetString("InventoryServices", ""); | ||
81 | if (name == Name) | ||
82 | { | ||
83 | Init(source); | ||
84 | m_Enabled = true; | ||
85 | |||
86 | m_log.Info("[INVENTORY CONNECTOR]: Remote inventory enabled"); | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 | public void PostInitialise() | ||
92 | { | ||
93 | } | ||
94 | |||
95 | public void Close() | ||
96 | { | ||
97 | } | ||
98 | |||
99 | public void AddRegion(Scene scene) | ||
100 | { | ||
101 | if (!m_Enabled) | ||
102 | return; | ||
103 | |||
104 | if (!m_Initialized) | ||
105 | { | ||
106 | m_Scene = scene; | ||
107 | // ugh! | ||
108 | scene.CommsManager.UserProfileCacheService.SetInventoryService(this); | ||
109 | scene.CommsManager.UserService.SetInventoryService(this); | ||
110 | m_Initialized = true; | ||
111 | } | ||
112 | |||
113 | scene.RegisterModuleInterface<IInventoryService>(this); | ||
114 | } | ||
115 | |||
116 | public void RemoveRegion(Scene scene) | ||
117 | { | ||
118 | } | ||
119 | |||
120 | public void RegionLoaded(Scene scene) | ||
121 | { | ||
122 | if (!m_Enabled) | ||
123 | return; | ||
124 | |||
125 | m_log.InfoFormat("[INVENTORY CONNECTOR]: Enabled remote inventory for region {0}", scene.RegionInfo.RegionName); | ||
126 | |||
127 | } | ||
128 | |||
129 | #endregion ISharedRegionModule | ||
130 | |||
131 | #region IInventoryService | ||
132 | |||
133 | public bool CreateUserInventory(UUID user) | ||
134 | { | ||
135 | return false; | ||
136 | } | ||
137 | |||
138 | public List<InventoryFolderBase> GetInventorySkeleton(UUID userId) | ||
139 | { | ||
140 | return new List<InventoryFolderBase>(); | ||
141 | } | ||
142 | |||
143 | public InventoryCollection GetUserInventory(UUID userID) | ||
144 | { | ||
145 | return null; | ||
146 | } | ||
147 | |||
148 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) | ||
149 | { | ||
150 | UUID sessionID = GetSessionID(userID); | ||
151 | try | ||
152 | { | ||
153 | m_RemoteConnector.GetUserInventory(userID.ToString(), sessionID, callback); | ||
154 | } | ||
155 | catch (Exception e) | ||
156 | { | ||
157 | if (StatsManager.SimExtraStats != null) | ||
158 | StatsManager.SimExtraStats.AddInventoryServiceRetrievalFailure(); | ||
159 | |||
160 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: Request inventory operation failed, {0} {1}", | ||
161 | e.Source, e.Message); | ||
162 | } | ||
163 | |||
164 | } | ||
165 | |||
166 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) | ||
167 | { | ||
168 | return new List<InventoryItemBase>(); | ||
169 | } | ||
170 | |||
171 | public bool AddFolder(InventoryFolderBase folder) | ||
172 | { | ||
173 | if (folder == null) | ||
174 | return false; | ||
175 | |||
176 | UUID sessionID = GetSessionID(folder.Owner); | ||
177 | return m_RemoteConnector.AddFolder(folder.Owner.ToString(), folder, sessionID); | ||
178 | } | ||
179 | |||
180 | public bool UpdateFolder(InventoryFolderBase folder) | ||
181 | { | ||
182 | if (folder == null) | ||
183 | return false; | ||
184 | |||
185 | UUID sessionID = GetSessionID(folder.Owner); | ||
186 | return m_RemoteConnector.UpdateFolder(folder.Owner.ToString(), folder, sessionID); | ||
187 | } | ||
188 | |||
189 | public bool MoveFolder(InventoryFolderBase folder) | ||
190 | { | ||
191 | if (folder == null) | ||
192 | return false; | ||
193 | |||
194 | UUID sessionID = GetSessionID(folder.Owner); | ||
195 | return m_RemoteConnector.MoveFolder(folder.Owner.ToString(), folder, sessionID); | ||
196 | } | ||
197 | |||
198 | public bool PurgeFolder(InventoryFolderBase folder) | ||
199 | { | ||
200 | if (folder == null) | ||
201 | return false; | ||
202 | |||
203 | UUID sessionID = GetSessionID(folder.Owner); | ||
204 | return m_RemoteConnector.PurgeFolder(folder.Owner.ToString(), folder, sessionID); | ||
205 | } | ||
206 | |||
207 | public bool AddItem(InventoryItemBase item) | ||
208 | { | ||
209 | if (item == null) | ||
210 | return false; | ||
211 | |||
212 | UUID sessionID = GetSessionID(item.Owner); | ||
213 | return m_RemoteConnector.AddItem(item.Owner.ToString(), item, sessionID); | ||
214 | } | ||
215 | |||
216 | public bool UpdateItem(InventoryItemBase item) | ||
217 | { | ||
218 | if (item == null) | ||
219 | return false; | ||
220 | |||
221 | UUID sessionID = GetSessionID(item.Owner); | ||
222 | return m_RemoteConnector.UpdateItem(item.Owner.ToString(), item, sessionID); | ||
223 | } | ||
224 | |||
225 | public bool DeleteItem(InventoryItemBase item) | ||
226 | { | ||
227 | if (item == null) | ||
228 | return false; | ||
229 | |||
230 | UUID sessionID = GetSessionID(item.Owner); | ||
231 | return m_RemoteConnector.DeleteItem(item.Owner.ToString(), item, sessionID); | ||
232 | } | ||
233 | |||
234 | public InventoryItemBase QueryItem(InventoryItemBase item) | ||
235 | { | ||
236 | if (item == null) | ||
237 | return null; | ||
238 | |||
239 | UUID sessionID = GetSessionID(item.Owner); | ||
240 | return m_RemoteConnector.QueryItem(item.Owner.ToString(), item, sessionID); | ||
241 | } | ||
242 | |||
243 | public InventoryFolderBase QueryFolder(InventoryFolderBase folder) | ||
244 | { | ||
245 | if (folder == null) | ||
246 | return null; | ||
247 | |||
248 | UUID sessionID = GetSessionID(folder.Owner); | ||
249 | return m_RemoteConnector.QueryFolder(folder.Owner.ToString(), folder, sessionID); | ||
250 | } | ||
251 | |||
252 | public bool HasInventoryForUser(UUID userID) | ||
253 | { | ||
254 | return false; | ||
255 | } | ||
256 | |||
257 | public InventoryFolderBase RequestRootFolder(UUID userID) | ||
258 | { | ||
259 | return null; | ||
260 | } | ||
261 | |||
262 | public List<InventoryItemBase> GetActiveGestures(UUID userId) | ||
263 | { | ||
264 | return new List<InventoryItemBase>(); | ||
265 | } | ||
266 | |||
267 | #endregion | ||
268 | |||
269 | private UUID GetSessionID(UUID userID) | ||
270 | { | ||
271 | ScenePresence sp = m_Scene.GetScenePresence(userID); | ||
272 | if (sp != null) | ||
273 | return sp.ControllingClient.SessionId; | ||
274 | |||
275 | return UUID.Zero; | ||
276 | } | ||
277 | |||
278 | } | ||
279 | } | ||