diff options
author | lbsa71 | 2007-09-24 07:30:30 +0000 |
---|---|---|
committer | lbsa71 | 2007-09-24 07:30:30 +0000 |
commit | 1302ef44e3c632159378bc4042c753bcf36e9c63 (patch) | |
tree | 6b6295ac233ecb05afe6432a903ec616e4fa079a /OpenSim/Framework/Communications/InventoryServiceBase.cs | |
parent | * Trying to streamline CommunicationsManager (diff) | |
download | opensim-SC-1302ef44e3c632159378bc4042c753bcf36e9c63.zip opensim-SC-1302ef44e3c632159378bc4042c753bcf36e9c63.tar.gz opensim-SC-1302ef44e3c632159378bc4042c753bcf36e9c63.tar.bz2 opensim-SC-1302ef44e3c632159378bc4042c753bcf36e9c63.tar.xz |
* Started major restructusing of comms to prepare for better grid and region functionality
* Working towards one shared set of services
* Killed off two projects with very little functionality
Diffstat (limited to 'OpenSim/Framework/Communications/InventoryServiceBase.cs')
-rw-r--r-- | OpenSim/Framework/Communications/InventoryServiceBase.cs | 211 |
1 files changed, 211 insertions, 0 deletions
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs new file mode 100644 index 0000000..da7a0ce --- /dev/null +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs | |||
@@ -0,0 +1,211 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Reflection; | ||
4 | using libsecondlife; | ||
5 | using OpenSim.Framework.Communications; | ||
6 | using OpenSim.Framework.Console; | ||
7 | using OpenSim.Framework.Data; | ||
8 | using InventoryFolder=OpenSim.Framework.Communications.Caches.InventoryFolder; | ||
9 | |||
10 | namespace OpenSim.Framework.Communications | ||
11 | { | ||
12 | public abstract class InventoryServiceBase : IInventoryServices | ||
13 | { | ||
14 | protected Dictionary<string, IInventoryData> m_plugins = new Dictionary<string, IInventoryData>(); | ||
15 | //protected IAssetServer m_assetServer; | ||
16 | |||
17 | public InventoryServiceBase() | ||
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 | if (!String.IsNullOrEmpty(FileName)) | ||
29 | { | ||
30 | MainLog.Instance.Verbose("Inventory", "Inventorystorage: Attempting to load " + FileName); | ||
31 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | ||
32 | |||
33 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
34 | { | ||
35 | if (!pluginType.IsAbstract) | ||
36 | { | ||
37 | Type typeInterface = pluginType.GetInterface("IInventoryData", true); | ||
38 | |||
39 | if (typeInterface != null) | ||
40 | { | ||
41 | IInventoryData plug = | ||
42 | (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
43 | plug.Initialise(); | ||
44 | this.m_plugins.Add(plug.getName(), plug); | ||
45 | MainLog.Instance.Verbose("Inventorystorage: Added IInventoryData Interface"); | ||
46 | } | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | } | ||
51 | |||
52 | /// <summary> | ||
53 | /// Returns the root folder plus any folders in root (so down one level in the Inventory folders tree) | ||
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 | public void AddFolder(InventoryFolderBase folder) | ||
112 | { | ||
113 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | ||
114 | { | ||
115 | plugin.Value.addInventoryFolder(folder); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | public void AddItem(InventoryItemBase item) | ||
120 | { | ||
121 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | ||
122 | { | ||
123 | plugin.Value.addInventoryItem(item); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | public void deleteItem(InventoryItemBase item) | ||
128 | { | ||
129 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | ||
130 | { | ||
131 | plugin.Value.deleteInventoryItem(item); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | /// <summary> | ||
136 | /// | ||
137 | /// </summary> | ||
138 | /// <param name="inventory"></param> | ||
139 | public void AddNewInventorySet(UsersInventory inventory) | ||
140 | { | ||
141 | foreach (InventoryFolderBase folder in inventory.Folders.Values) | ||
142 | { | ||
143 | this.AddFolder(folder); | ||
144 | } | ||
145 | } | ||
146 | |||
147 | public void CreateNewUserInventory(LLUUID user) | ||
148 | { | ||
149 | UsersInventory inven = new UsersInventory(); | ||
150 | inven.CreateNewInventorySet(user); | ||
151 | this.AddNewInventorySet(inven); | ||
152 | } | ||
153 | |||
154 | public class UsersInventory | ||
155 | { | ||
156 | public Dictionary<LLUUID, InventoryFolderBase> Folders = new Dictionary<LLUUID, InventoryFolderBase>(); | ||
157 | public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>(); | ||
158 | |||
159 | public UsersInventory() | ||
160 | { | ||
161 | |||
162 | } | ||
163 | |||
164 | public virtual void CreateNewInventorySet(LLUUID user) | ||
165 | { | ||
166 | InventoryFolderBase folder = new InventoryFolderBase(); | ||
167 | folder.parentID = LLUUID.Zero; | ||
168 | folder.agentID = user; | ||
169 | folder.folderID = LLUUID.Random(); | ||
170 | folder.name = "My Inventory"; | ||
171 | folder.type = 8; | ||
172 | folder.version = 1; | ||
173 | Folders.Add(folder.folderID, folder); | ||
174 | |||
175 | LLUUID rootFolder = folder.folderID; | ||
176 | |||
177 | folder = new InventoryFolderBase(); | ||
178 | folder.parentID = rootFolder; | ||
179 | folder.agentID = user; | ||
180 | folder.folderID = LLUUID.Random(); | ||
181 | folder.name = "Textures"; | ||
182 | folder.type = 0; | ||
183 | folder.version = 1; | ||
184 | Folders.Add(folder.folderID, folder); | ||
185 | |||
186 | folder = new InventoryFolderBase(); | ||
187 | folder.parentID = rootFolder; | ||
188 | folder.agentID = user; | ||
189 | folder.folderID = LLUUID.Random(); | ||
190 | folder.name = "Objects"; | ||
191 | folder.type = 6; | ||
192 | folder.version = 1; | ||
193 | Folders.Add(folder.folderID, folder); | ||
194 | |||
195 | folder = new InventoryFolderBase(); | ||
196 | folder.parentID = rootFolder; | ||
197 | folder.agentID = user; | ||
198 | folder.folderID = LLUUID.Random(); | ||
199 | folder.name = "Clothes"; | ||
200 | folder.type = 5; | ||
201 | folder.version = 1; | ||
202 | Folders.Add(folder.folderID, folder); | ||
203 | } | ||
204 | } | ||
205 | |||
206 | public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); | ||
207 | public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolder folder); | ||
208 | public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); | ||
209 | public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); | ||
210 | } | ||
211 | } \ No newline at end of file | ||