aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs')
-rw-r--r--OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs136
1 files changed, 136 insertions, 0 deletions
diff --git a/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs b/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs
new file mode 100644
index 0000000..d407cdb
--- /dev/null
+++ b/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs
@@ -0,0 +1,136 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4using System.Text;
5using libsecondlife;
6using OpenSim.Framework.Console;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Data;
9
10namespace OpenSim.Framework.InventoryServiceBase
11{
12 public class InventoryServiceBase
13 {
14 protected Dictionary<string, IInventoryData> m_plugins = new Dictionary<string, IInventoryData>();
15 protected IAssetServer m_assetServer;
16
17 public InventoryServiceBase(IAssetServer assetServer)
18 {
19 m_assetServer = assetServer;
20 }
21
22 /// <summary>
23 /// Adds a new user server plugin - plugins will be requested in the order they were loaded.
24 /// </summary>
25 /// <param name="FileName">The filename to the user server plugin DLL</param>
26 public void AddPlugin(string FileName)
27 {
28 MainLog.Instance.Verbose("Inventorytorage: Attempting to load " + FileName);
29 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
30
31 foreach (Type pluginType in pluginAssembly.GetTypes())
32 {
33 if (!pluginType.IsAbstract)
34 {
35 Type typeInterface = pluginType.GetInterface("IInventoryData", true);
36
37 if (typeInterface != null)
38 {
39 IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
40 plug.Initialise();
41 this.m_plugins.Add(plug.getName(), plug);
42 MainLog.Instance.Verbose("Inventorystorage: Added IInventoryData Interface");
43 }
44
45 typeInterface = null;
46 }
47 }
48
49 pluginAssembly = null;
50 }
51
52 /// <summary>
53 ///
54 /// </summary>
55 /// <param name="userID"></param>
56 /// <returns></returns>
57 public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID)
58 {
59 List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
60 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
61 {
62 InventoryFolderBase rootFolder = plugin.Value.getUserRootFolder(userID);
63 if (rootFolder != null)
64 {
65 inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID);
66 inventoryList.Insert(0, rootFolder);
67 return inventoryList;
68 }
69 }
70 return inventoryList;
71 }
72
73 /// <summary>
74 ///
75 /// </summary>
76 public InventoryFolderBase RequestUsersRoot(LLUUID userID)
77 {
78 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
79 {
80 return plugin.Value.getUserRootFolder(userID);
81 }
82 return null;
83 }
84
85 /// <summary>
86 ///
87 /// </summary>
88 /// <param name="parentFolderID"></param>
89 /// <returns></returns>
90 public List<InventoryFolderBase> RequestSubFolders(LLUUID parentFolderID)
91 {
92 List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
93 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
94 {
95 return plugin.Value.getInventoryFolders(parentFolderID);
96 }
97 return inventoryList;
98 }
99
100 public List<InventoryItemBase> RequestFolderItems(LLUUID folderID)
101 {
102 List<InventoryItemBase> itemsList = new List<InventoryItemBase>();
103 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
104 {
105 itemsList = plugin.Value.getInventoryInFolder(folderID);
106 return itemsList;
107 }
108 return itemsList;
109 }
110
111 /// <summary>
112 ///
113 /// </summary>
114 /// <param name="inventory"></param>
115 public void AddNewInventorySet(UsersInventory inventory)
116 {
117
118 }
119
120 public class UsersInventory
121 {
122 public Dictionary<LLUUID, InventoryFolderBase> Folders = new Dictionary<LLUUID, InventoryFolderBase>();
123 public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>();
124
125 public UsersInventory()
126 {
127
128 }
129
130 protected virtual void CreateNewInventorySet()
131 {
132
133 }
134 }
135 }
136}