diff options
Diffstat (limited to 'OpenSim/Framework/Communications/InventoryServiceBase.cs')
-rw-r--r-- | OpenSim/Framework/Communications/InventoryServiceBase.cs | 81 |
1 files changed, 34 insertions, 47 deletions
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 06b707b..40701f0 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs | |||
@@ -43,38 +43,25 @@ namespace OpenSim.Framework.Communications | |||
43 | private static readonly ILog m_log | 43 | private static readonly ILog m_log |
44 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | protected Dictionary<string, IInventoryData> m_plugins = new Dictionary<string, IInventoryData>(); | 46 | protected List<IInventoryDataPlugin> m_plugins = new List<IInventoryDataPlugin>(); |
47 | 47 | ||
48 | #region Plugin methods | 48 | #region Plugin methods |
49 | 49 | ||
50 | /// <summary> | 50 | /// <summary> |
51 | /// Adds a new user server plugin - plugins will be requested in the order they were loaded. | 51 | /// Adds a new user server plugin - plugins will be requested in the order they were loaded. |
52 | /// </summary> | 52 | /// </summary> |
53 | /// <param name="FileName">The filename to the user server plugin DLL</param> | 53 | /// <param name="provider">The filename to the user server plugin DLL</param> |
54 | public void AddPlugin(string FileName, string connect) | 54 | public void AddPlugin(string provider, string connect) |
55 | { | 55 | { |
56 | if (!String.IsNullOrEmpty(FileName)) | 56 | PluginLoader<IInventoryDataPlugin> loader = |
57 | { | 57 | new PluginLoader<IInventoryDataPlugin> (new InventoryDataInitialiser (connect)); |
58 | m_log.Info("[AGENT INVENTORY]: Inventory storage: Attempting to load " + FileName); | 58 | |
59 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | 59 | // loader will try to load all providers (MySQL, MSSQL, etc) |
60 | 60 | // unless it is constrainted to the correct "Provider" entry in the addin.xml | |
61 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 61 | loader.Add ("/OpenSim/InventoryData", new PluginProviderFilter (provider)); |
62 | { | 62 | loader.Load(); |
63 | if (!pluginType.IsAbstract) | 63 | |
64 | { | 64 | m_plugins = loader.Plugins; |
65 | Type typeInterface = pluginType.GetInterface("IInventoryData", true); | ||
66 | |||
67 | if (typeInterface != null) | ||
68 | { | ||
69 | IInventoryData plug = | ||
70 | (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
71 | plug.Initialise(connect); | ||
72 | m_plugins.Add(plug.getName(), plug); | ||
73 | m_log.Info("[AGENTINVENTORY]: Added IInventoryData Interface"); | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | } | 65 | } |
79 | 66 | ||
80 | #endregion | 67 | #endregion |
@@ -103,9 +90,9 @@ namespace OpenSim.Framework.Communications | |||
103 | 90 | ||
104 | userFolders.Add(rootFolder); | 91 | userFolders.Add(rootFolder); |
105 | 92 | ||
106 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 93 | foreach (IInventoryDataPlugin plugin in m_plugins) |
107 | { | 94 | { |
108 | IList<InventoryFolderBase> folders = plugin.Value.getFolderHierarchy(rootFolder.ID); | 95 | IList<InventoryFolderBase> folders = plugin.getFolderHierarchy(rootFolder.ID); |
109 | userFolders.AddRange(folders); | 96 | userFolders.AddRange(folders); |
110 | } | 97 | } |
111 | 98 | ||
@@ -127,9 +114,9 @@ namespace OpenSim.Framework.Communications | |||
127 | public InventoryFolderBase RequestRootFolder(LLUUID userID) | 114 | public InventoryFolderBase RequestRootFolder(LLUUID userID) |
128 | { | 115 | { |
129 | // FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin | 116 | // FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin |
130 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 117 | foreach (IInventoryDataPlugin plugin in m_plugins) |
131 | { | 118 | { |
132 | return plugin.Value.getUserRootFolder(userID); | 119 | return plugin.getUserRootFolder(userID); |
133 | } | 120 | } |
134 | return null; | 121 | return null; |
135 | } | 122 | } |
@@ -168,9 +155,9 @@ namespace OpenSim.Framework.Communications | |||
168 | public List<InventoryFolderBase> RequestSubFolders(LLUUID parentFolderID) | 155 | public List<InventoryFolderBase> RequestSubFolders(LLUUID parentFolderID) |
169 | { | 156 | { |
170 | List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>(); | 157 | List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>(); |
171 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 158 | foreach (IInventoryDataPlugin plugin in m_plugins) |
172 | { | 159 | { |
173 | return plugin.Value.getInventoryFolders(parentFolderID); | 160 | return plugin.getInventoryFolders(parentFolderID); |
174 | } | 161 | } |
175 | return inventoryList; | 162 | return inventoryList; |
176 | } | 163 | } |
@@ -178,9 +165,9 @@ namespace OpenSim.Framework.Communications | |||
178 | public List<InventoryItemBase> RequestFolderItems(LLUUID folderID) | 165 | public List<InventoryItemBase> RequestFolderItems(LLUUID folderID) |
179 | { | 166 | { |
180 | List<InventoryItemBase> itemsList = new List<InventoryItemBase>(); | 167 | List<InventoryItemBase> itemsList = new List<InventoryItemBase>(); |
181 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 168 | foreach (IInventoryDataPlugin plugin in m_plugins) |
182 | { | 169 | { |
183 | itemsList = plugin.Value.getInventoryInFolder(folderID); | 170 | itemsList = plugin.getInventoryInFolder(folderID); |
184 | return itemsList; | 171 | return itemsList; |
185 | } | 172 | } |
186 | return itemsList; | 173 | return itemsList; |
@@ -194,9 +181,9 @@ namespace OpenSim.Framework.Communications | |||
194 | m_log.DebugFormat( | 181 | m_log.DebugFormat( |
195 | "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); | 182 | "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); |
196 | 183 | ||
197 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 184 | foreach (IInventoryDataPlugin plugin in m_plugins) |
198 | { | 185 | { |
199 | plugin.Value.addInventoryFolder(folder); | 186 | plugin.addInventoryFolder(folder); |
200 | } | 187 | } |
201 | 188 | ||
202 | // FIXME: Should return false on failure | 189 | // FIXME: Should return false on failure |
@@ -209,9 +196,9 @@ namespace OpenSim.Framework.Communications | |||
209 | m_log.DebugFormat( | 196 | m_log.DebugFormat( |
210 | "[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); | 197 | "[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); |
211 | 198 | ||
212 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 199 | foreach (IInventoryDataPlugin plugin in m_plugins) |
213 | { | 200 | { |
214 | plugin.Value.updateInventoryFolder(folder); | 201 | plugin.updateInventoryFolder(folder); |
215 | } | 202 | } |
216 | 203 | ||
217 | // FIXME: Should return false on failure | 204 | // FIXME: Should return false on failure |
@@ -224,9 +211,9 @@ namespace OpenSim.Framework.Communications | |||
224 | m_log.DebugFormat( | 211 | m_log.DebugFormat( |
225 | "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); | 212 | "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); |
226 | 213 | ||
227 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 214 | foreach (IInventoryDataPlugin plugin in m_plugins) |
228 | { | 215 | { |
229 | plugin.Value.moveInventoryFolder(folder); | 216 | plugin.moveInventoryFolder(folder); |
230 | } | 217 | } |
231 | 218 | ||
232 | // FIXME: Should return false on failure | 219 | // FIXME: Should return false on failure |
@@ -239,9 +226,9 @@ namespace OpenSim.Framework.Communications | |||
239 | m_log.DebugFormat( | 226 | m_log.DebugFormat( |
240 | "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); | 227 | "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); |
241 | 228 | ||
242 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 229 | foreach (IInventoryDataPlugin plugin in m_plugins) |
243 | { | 230 | { |
244 | plugin.Value.addInventoryItem(item); | 231 | plugin.addInventoryItem(item); |
245 | } | 232 | } |
246 | 233 | ||
247 | // FIXME: Should return false on failure | 234 | // FIXME: Should return false on failure |
@@ -254,9 +241,9 @@ namespace OpenSim.Framework.Communications | |||
254 | m_log.InfoFormat( | 241 | m_log.InfoFormat( |
255 | "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); | 242 | "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); |
256 | 243 | ||
257 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 244 | foreach (IInventoryDataPlugin plugin in m_plugins) |
258 | { | 245 | { |
259 | plugin.Value.updateInventoryItem(item); | 246 | plugin.updateInventoryItem(item); |
260 | } | 247 | } |
261 | 248 | ||
262 | // FIXME: Should return false on failure | 249 | // FIXME: Should return false on failure |
@@ -269,9 +256,9 @@ namespace OpenSim.Framework.Communications | |||
269 | m_log.InfoFormat( | 256 | m_log.InfoFormat( |
270 | "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); | 257 | "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); |
271 | 258 | ||
272 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 259 | foreach (IInventoryDataPlugin plugin in m_plugins) |
273 | { | 260 | { |
274 | plugin.Value.deleteInventoryItem(item.ID); | 261 | plugin.deleteInventoryItem(item.ID); |
275 | } | 262 | } |
276 | 263 | ||
277 | // FIXME: Should return false on failure | 264 | // FIXME: Should return false on failure |
@@ -296,9 +283,9 @@ namespace OpenSim.Framework.Communications | |||
296 | { | 283 | { |
297 | // m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID); | 284 | // m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID); |
298 | 285 | ||
299 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 286 | foreach (IInventoryDataPlugin plugin in m_plugins) |
300 | { | 287 | { |
301 | plugin.Value.deleteInventoryFolder(subFolder.ID); | 288 | plugin.deleteInventoryFolder(subFolder.ID); |
302 | } | 289 | } |
303 | } | 290 | } |
304 | 291 | ||