diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs new file mode 100644 index 0000000..525dda7 --- /dev/null +++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs | |||
@@ -0,0 +1,165 @@ | |||
1 | /** | ||
2 | * Copyright (c) 2008, Contributors. All rights reserved. | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without modification, | ||
6 | * are permitted provided that the following conditions are met: | ||
7 | * | ||
8 | * * Redistributions of source code must retain the above copyright notice, | ||
9 | * this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright notice, | ||
11 | * this list of conditions and the following disclaimer in the documentation | ||
12 | * and/or other materials provided with the distribution. | ||
13 | * * Neither the name of the Organizations nor the names of Individual | ||
14 | * Contributors may be used to endorse or promote products derived from | ||
15 | * this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | ||
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Collections; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using Nini.Config; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Data; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Communications.Cache; | ||
40 | using OpenSim.Framework.Communications.Services; | ||
41 | using Caps = OpenSim.Framework.Communications.Capabilities.Caps; | ||
42 | using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers; | ||
43 | using OpenSim.Framework.Servers; | ||
44 | using OpenSim.Framework.Servers.Interfaces; | ||
45 | using OpenSim.Region.Framework.Interfaces; | ||
46 | using OpenSim.Region.Framework.Scenes; | ||
47 | using OpenSim.Region.CoreModules.Communications.REST; | ||
48 | |||
49 | using OpenMetaverse.StructuredData; | ||
50 | |||
51 | namespace OpenSim.Region.CoreModules.Hypergrid | ||
52 | { | ||
53 | public class HGStandaloneInventoryModule : IRegionModule | ||
54 | { | ||
55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
56 | private static bool initialized = false; | ||
57 | private static bool enabled = false; | ||
58 | |||
59 | private bool m_doLookup = false; | ||
60 | Scene m_scene; | ||
61 | HGInventoryService m_inventoryService; | ||
62 | InventoryServiceBase m_inventoryBase; | ||
63 | |||
64 | public bool DoLookup | ||
65 | { | ||
66 | get { return m_doLookup; } | ||
67 | set { m_doLookup = value; } | ||
68 | } | ||
69 | |||
70 | #region IRegionModule interface | ||
71 | |||
72 | public void Initialise(Scene scene, IConfigSource config) | ||
73 | { | ||
74 | if (!initialized) | ||
75 | { | ||
76 | initialized = true; | ||
77 | m_scene = scene; | ||
78 | |||
79 | // This module is only on for standalones | ||
80 | enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | public void PostInitialise() | ||
85 | { | ||
86 | if (enabled) | ||
87 | { | ||
88 | m_log.Info("[HGStandaloneInvModule]: Starting..."); | ||
89 | //m_inventoryService = new InventoryService(m_scene); | ||
90 | m_inventoryBase = (InventoryServiceBase)m_scene.CommsManager.SecureInventoryService; | ||
91 | |||
92 | m_inventoryService = new HGInventoryService(m_inventoryBase, | ||
93 | ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin, | ||
94 | (UserManagerBase)m_scene.CommsManager.UserService, m_scene.CommsManager.HttpServer, | ||
95 | m_scene.CommsManager.NetworkServersInfo.InventoryURL); | ||
96 | |||
97 | AddHttpHandlers(m_scene.CommsManager.HttpServer); | ||
98 | m_inventoryService.AddHttpHandlers(); | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public void Close() | ||
103 | { | ||
104 | } | ||
105 | |||
106 | public string Name | ||
107 | { | ||
108 | get { return "HGStandaloneInventoryModule"; } | ||
109 | } | ||
110 | |||
111 | public bool IsSharedModule | ||
112 | { | ||
113 | get { return true; } | ||
114 | } | ||
115 | |||
116 | #endregion | ||
117 | |||
118 | public virtual void AddHttpHandlers(IHttpServer httpServer) | ||
119 | { | ||
120 | |||
121 | httpServer.AddStreamHandler( | ||
122 | new RestDeserialiseSecureHandler<Guid, InventoryCollection>( | ||
123 | "POST", "/GetInventory/", m_inventoryService.GetUserInventory, CheckAuthSession)); | ||
124 | |||
125 | httpServer.AddStreamHandler( | ||
126 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
127 | "POST", "/NewFolder/", m_inventoryBase.AddFolder, CheckAuthSession)); | ||
128 | |||
129 | httpServer.AddStreamHandler( | ||
130 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
131 | "POST", "/UpdateFolder/", m_inventoryBase.UpdateFolder, CheckAuthSession)); | ||
132 | |||
133 | httpServer.AddStreamHandler( | ||
134 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
135 | "POST", "/MoveFolder/", m_inventoryBase.MoveFolder, CheckAuthSession)); | ||
136 | |||
137 | httpServer.AddStreamHandler( | ||
138 | new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | ||
139 | "POST", "/PurgeFolder/", m_inventoryBase.PurgeFolder, CheckAuthSession)); | ||
140 | |||
141 | httpServer.AddStreamHandler( | ||
142 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( | ||
143 | "POST", "/NewItem/", m_inventoryBase.AddItem, CheckAuthSession)); | ||
144 | |||
145 | httpServer.AddStreamHandler( | ||
146 | new RestDeserialiseSecureHandler<InventoryItemBase, bool>( | ||
147 | "POST", "/DeleteItem/", m_inventoryBase.DeleteItem, CheckAuthSession)); | ||
148 | |||
149 | } | ||
150 | |||
151 | /// <summary> | ||
152 | /// Check that the source of an inventory request for a particular agent is a current session belonging to | ||
153 | /// that agent. | ||
154 | /// </summary> | ||
155 | /// <param name="session_id"></param> | ||
156 | /// <param name="avatar_id"></param> | ||
157 | /// <returns></returns> | ||
158 | public bool CheckAuthSession(string session_id, string avatar_id) | ||
159 | { | ||
160 | return true; | ||
161 | } | ||
162 | |||
163 | } | ||
164 | |||
165 | } | ||