diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectors/Inventory/LocalInventoryServiceConnector.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectors/Inventory/LocalInventoryServiceConnector.cs | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/LocalInventoryServiceConnector.cs new file mode 100644 index 0000000..3db08eb --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/LocalInventoryServiceConnector.cs | |||
@@ -0,0 +1,246 @@ | |||
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.Data; | ||
35 | using OpenSim.Server.Base; | ||
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 LocalInventoryServicesConnector : | ||
44 | ISharedRegionModule, IInventoryService | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger( | ||
48 | MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private IInventoryService m_InventoryService; | ||
51 | |||
52 | private bool m_Enabled = false; | ||
53 | |||
54 | public string Name | ||
55 | { | ||
56 | get { return "LocalInventoryServicesConnector"; } | ||
57 | } | ||
58 | |||
59 | public void Initialise(IConfigSource source) | ||
60 | { | ||
61 | IConfig moduleConfig = source.Configs["Modules"]; | ||
62 | if (moduleConfig != null) | ||
63 | { | ||
64 | string name = moduleConfig.GetString("InventoryServices", ""); | ||
65 | if (name == Name) | ||
66 | { | ||
67 | IConfig assetConfig = source.Configs["InventoryService"]; | ||
68 | if (assetConfig == null) | ||
69 | { | ||
70 | m_log.Error("[INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini"); | ||
71 | return; | ||
72 | } | ||
73 | |||
74 | string serviceDll = assetConfig.GetString("LocalServiceModule", | ||
75 | String.Empty); | ||
76 | |||
77 | if (serviceDll == String.Empty) | ||
78 | { | ||
79 | m_log.Error("[INVENTORY CONNECTOR]: No LocalServiceModule named in section InventoryService"); | ||
80 | return; | ||
81 | } | ||
82 | |||
83 | Object[] args = new Object[] { source }; | ||
84 | m_InventoryService = | ||
85 | ServerUtils.LoadPlugin<IInventoryService>(serviceDll, | ||
86 | args); | ||
87 | |||
88 | if (m_InventoryService == null) | ||
89 | { | ||
90 | m_log.Error("[INVENTORY CONNECTOR]: Can't load asset service"); | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | //List<IInventoryDataPlugin> plugins | ||
95 | // = DataPluginFactory.LoadDataPlugins<IInventoryDataPlugin>( | ||
96 | // configSettings.StandaloneInventoryPlugin, | ||
97 | // configSettings.StandaloneInventorySource); | ||
98 | |||
99 | //foreach (IInventoryDataPlugin plugin in plugins) | ||
100 | //{ | ||
101 | // // Using the OSP wrapper plugin for database plugins should be made configurable at some point | ||
102 | // m_InventoryService.AddPlugin(new OspInventoryWrapperPlugin(plugin, this)); | ||
103 | //} | ||
104 | |||
105 | m_Enabled = true; | ||
106 | m_log.Info("[INVENTORY CONNECTOR]: Local asset connector enabled"); | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | |||
111 | public void PostInitialise() | ||
112 | { | ||
113 | } | ||
114 | |||
115 | public void Close() | ||
116 | { | ||
117 | } | ||
118 | |||
119 | public void AddRegion(Scene scene) | ||
120 | { | ||
121 | if (!m_Enabled) | ||
122 | return; | ||
123 | |||
124 | scene.RegisterModuleInterface<IInventoryService>(this); | ||
125 | } | ||
126 | |||
127 | public void RemoveRegion(Scene scene) | ||
128 | { | ||
129 | } | ||
130 | |||
131 | public void RegionLoaded(Scene scene) | ||
132 | { | ||
133 | if (!m_Enabled) | ||
134 | return; | ||
135 | |||
136 | m_log.InfoFormat("[INVENTORY CONNECTOR]: Enabled local assets for region {0}", scene.RegionInfo.RegionName); | ||
137 | |||
138 | } | ||
139 | |||
140 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) | ||
141 | { | ||
142 | m_InventoryService.GetUserInventory(userID, callback); | ||
143 | } | ||
144 | |||
145 | /// <summary> | ||
146 | /// Add a new folder to the user's inventory | ||
147 | /// </summary> | ||
148 | /// <param name="folder"></param> | ||
149 | /// <returns>true if the folder was successfully added</returns> | ||
150 | public bool AddFolder(InventoryFolderBase folder) | ||
151 | { | ||
152 | return m_InventoryService.AddFolder(folder); | ||
153 | } | ||
154 | |||
155 | /// <summary> | ||
156 | /// Update a folder in the user's inventory | ||
157 | /// </summary> | ||
158 | /// <param name="folder"></param> | ||
159 | /// <returns>true if the folder was successfully updated</returns> | ||
160 | public bool UpdateFolder(InventoryFolderBase folder) | ||
161 | { | ||
162 | return m_InventoryService.UpdateFolder(folder); | ||
163 | } | ||
164 | |||
165 | /// <summary> | ||
166 | /// Move an inventory folder to a new location | ||
167 | /// </summary> | ||
168 | /// <param name="folder">A folder containing the details of the new location</param> | ||
169 | /// <returns>true if the folder was successfully moved</returns> | ||
170 | public bool MoveFolder(InventoryFolderBase folder) | ||
171 | { | ||
172 | return m_InventoryService.MoveFolder(folder); | ||
173 | } | ||
174 | |||
175 | /// <summary> | ||
176 | /// Purge an inventory folder of all its items and subfolders. | ||
177 | /// </summary> | ||
178 | /// <param name="folder"></param> | ||
179 | /// <returns>true if the folder was successfully purged</returns> | ||
180 | public bool PurgeFolder(InventoryFolderBase folder) | ||
181 | { | ||
182 | return m_InventoryService.PurgeFolder(folder); | ||
183 | } | ||
184 | |||
185 | /// <summary> | ||
186 | /// Add a new item to the user's inventory | ||
187 | /// </summary> | ||
188 | /// <param name="item"></param> | ||
189 | /// <returns>true if the item was successfully added</returns> | ||
190 | public bool AddItem(InventoryItemBase item) | ||
191 | { | ||
192 | return m_InventoryService.AddItem(item); | ||
193 | } | ||
194 | |||
195 | /// <summary> | ||
196 | /// Update an item in the user's inventory | ||
197 | /// </summary> | ||
198 | /// <param name="item"></param> | ||
199 | /// <returns>true if the item was successfully updated</returns> | ||
200 | public bool UpdateItem(InventoryItemBase item) | ||
201 | { | ||
202 | return m_InventoryService.UpdateItem(item); | ||
203 | } | ||
204 | |||
205 | /// <summary> | ||
206 | /// Delete an item from the user's inventory | ||
207 | /// </summary> | ||
208 | /// <param name="item"></param> | ||
209 | /// <returns>true if the item was successfully deleted</returns> | ||
210 | public bool DeleteItem(InventoryItemBase item) | ||
211 | { | ||
212 | return m_InventoryService.DeleteItem(item); | ||
213 | } | ||
214 | |||
215 | public InventoryItemBase QueryItem(InventoryItemBase item) | ||
216 | { | ||
217 | return m_InventoryService.QueryItem(item); | ||
218 | } | ||
219 | |||
220 | public InventoryFolderBase QueryFolder(InventoryFolderBase folder) | ||
221 | { | ||
222 | return m_InventoryService.QueryFolder(folder); | ||
223 | } | ||
224 | |||
225 | /// <summary> | ||
226 | /// Does the given user have an inventory structure? | ||
227 | /// </summary> | ||
228 | /// <param name="userID"></param> | ||
229 | /// <returns></returns> | ||
230 | public bool HasInventoryForUser(UUID userID) | ||
231 | { | ||
232 | return m_InventoryService.HasInventoryForUser(userID); | ||
233 | } | ||
234 | |||
235 | /// <summary> | ||
236 | /// Retrieve the root inventory folder for the given user. | ||
237 | /// </summary> | ||
238 | /// <param name="userID"></param> | ||
239 | /// <returns>null if no root folder was found</returns> | ||
240 | public InventoryFolderBase RequestRootFolder(UUID userID) | ||
241 | { | ||
242 | return m_InventoryService.RequestRootFolder(userID); | ||
243 | } | ||
244 | |||
245 | } | ||
246 | } | ||