diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 200 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/LoginService.cs | 1 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 7 | ||||
-rw-r--r-- | bin/assets/AssetSets.xml | 11 | ||||
-rw-r--r-- | bin/inventory/Libraries.xml | 17 | ||||
-rw-r--r-- | bin/inventory/README.txt | 27 |
6 files changed, 164 insertions, 99 deletions
diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index cb122df..38cffeb 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | |||
@@ -64,35 +64,9 @@ namespace OpenSim.Framework.Communications.Cache | |||
64 | 64 | ||
65 | libraryFolders.Add(folderID, this); | 65 | libraryFolders.Add(folderID, this); |
66 | 66 | ||
67 | string foldersPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibraryFolders.xml"); | 67 | LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml")); |
68 | if (File.Exists(foldersPath)) | ||
69 | { | ||
70 | try | ||
71 | { | ||
72 | XmlConfigSource source = new XmlConfigSource(foldersPath); | ||
73 | ReadFoldersFromFile(source); | ||
74 | } | ||
75 | catch (XmlException e) | ||
76 | { | ||
77 | MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + foldersPath + ": " + e.ToString()); | ||
78 | } | ||
79 | } | ||
80 | 68 | ||
81 | CreateLibraryItems(); | 69 | CreateLibraryItems(); |
82 | |||
83 | string itemsPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibrary.xml"); | ||
84 | if (File.Exists(itemsPath)) | ||
85 | { | ||
86 | try | ||
87 | { | ||
88 | XmlConfigSource source = new XmlConfigSource(itemsPath); | ||
89 | ReadItemsFromFile(source); | ||
90 | } | ||
91 | catch (XmlException e) | ||
92 | { | ||
93 | MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + itemsPath + ": " + e.ToString()); | ||
94 | } | ||
95 | } | ||
96 | } | 70 | } |
97 | 71 | ||
98 | /// <summary> | 72 | /// <summary> |
@@ -155,84 +129,140 @@ namespace OpenSim.Framework.Communications.Cache | |||
155 | } | 129 | } |
156 | 130 | ||
157 | /// <summary> | 131 | /// <summary> |
158 | /// Read library inventory folders from an external source | 132 | /// Use the asset set information at path to load assets |
133 | /// </summary> | ||
134 | /// <param name="path"></param> | ||
135 | /// <param name="assets"></param> | ||
136 | protected void LoadLibraries(string librariesControlPath) | ||
137 | { | ||
138 | MainLog.Instance.Verbose( | ||
139 | "LIBRARYINVENTORY", "Loading libraries control file {0}", librariesControlPath); | ||
140 | |||
141 | LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig); | ||
142 | } | ||
143 | |||
144 | /// <summary> | ||
145 | /// Read a library set from config | ||
146 | /// </summary> | ||
147 | /// <param name="config"></param> | ||
148 | protected void ReadLibraryFromConfig(IConfig config) | ||
149 | { | ||
150 | string foldersPath | ||
151 | = Path.Combine( | ||
152 | Util.inventoryDir(), config.GetString("foldersFile", "")); | ||
153 | |||
154 | LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig); | ||
155 | |||
156 | string itemsPath | ||
157 | = Path.Combine( | ||
158 | Util.inventoryDir(), config.GetString("itemsFile", "")); | ||
159 | |||
160 | LoadFromFile(itemsPath, "Library items", ReadItemFromConfig); | ||
161 | } | ||
162 | |||
163 | /// <summary> | ||
164 | /// Read a library inventory folder from a loaded configuration | ||
159 | /// </summary> | 165 | /// </summary> |
160 | /// <param name="source"></param> | 166 | /// <param name="source"></param> |
161 | private void ReadFoldersFromFile(IConfigSource source) | 167 | private void ReadFolderFromConfig(IConfig config) |
162 | { | 168 | { |
163 | for (int i = 0; i < source.Configs.Count; i++) | 169 | InventoryFolderImpl folderInfo = new InventoryFolderImpl(); |
164 | { | 170 | |
165 | IConfig config = source.Configs[i]; | 171 | folderInfo.folderID = new LLUUID(config.GetString("folderID", folderID.ToString())); |
166 | 172 | folderInfo.name = config.GetString("name", "unknown"); | |
167 | InventoryFolderImpl folderInfo = new InventoryFolderImpl(); | 173 | folderInfo.parentID = new LLUUID(config.GetString("parentFolderID", folderID.ToString())); |
168 | 174 | folderInfo.type = (short)config.GetInt("type", 8); | |
169 | folderInfo.folderID = new LLUUID(config.GetString("folderID", folderID.ToString())); | 175 | |
170 | folderInfo.name = config.GetString("name", "unknown"); | 176 | folderInfo.agentID = libOwner; |
171 | folderInfo.parentID = new LLUUID(config.GetString("parentFolderID", folderID.ToString())); | 177 | folderInfo.version = 1; |
172 | folderInfo.type = (short)config.GetInt("type", 8); | 178 | |
179 | if (libraryFolders.ContainsKey(folderInfo.parentID)) | ||
180 | { | ||
181 | InventoryFolderImpl parentFolder = libraryFolders[folderInfo.parentID]; | ||
173 | 182 | ||
174 | folderInfo.agentID = libOwner; | 183 | libraryFolders.Add(folderInfo.folderID, folderInfo); |
175 | folderInfo.version = 1; | 184 | parentFolder.SubFolders.Add(folderInfo.folderID, folderInfo); |
176 | 185 | ||
177 | if (libraryFolders.ContainsKey(folderInfo.parentID)) | ||
178 | { | ||
179 | InventoryFolderImpl parentFolder = libraryFolders[folderInfo.parentID]; | ||
180 | |||
181 | libraryFolders.Add(folderInfo.folderID, folderInfo); | ||
182 | parentFolder.SubFolders.Add(folderInfo.folderID, folderInfo); | ||
183 | |||
184 | // MainLog.Instance.Verbose( | 186 | // MainLog.Instance.Verbose( |
185 | // "LIBRARYINVENTORY", "Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); | 187 | // "LIBRARYINVENTORY", "Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); |
186 | } | 188 | } |
187 | else | 189 | else |
188 | { | 190 | { |
189 | MainLog.Instance.Warn( | 191 | MainLog.Instance.Warn( |
190 | "LIBRARYINVENTORY", | 192 | "LIBRARYINVENTORY", |
191 | "Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!", | 193 | "Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!", |
192 | folderInfo.name, folderInfo.folderID, folderInfo.parentID); | 194 | folderInfo.name, folderInfo.folderID, folderInfo.parentID); |
193 | } | ||
194 | } | 195 | } |
195 | } | 196 | } |
196 | 197 | ||
197 | /// <summary> | 198 | /// <summary> |
198 | /// Read library inventory items metadata from an external source | 199 | /// Read a library inventory item metadata from a loaded configuration |
199 | /// </summary> | 200 | /// </summary> |
200 | /// <param name="source"></param> | 201 | /// <param name="source"></param> |
201 | private void ReadItemsFromFile(IConfigSource source) | 202 | private void ReadItemFromConfig(IConfig config) |
202 | { | 203 | { |
203 | for (int i = 0; i < source.Configs.Count; i++) | 204 | InventoryItemBase item = new InventoryItemBase(); |
205 | item.avatarID = libOwner; | ||
206 | item.creatorsID = libOwner; | ||
207 | item.inventoryID = new LLUUID(config.GetString("inventoryID", folderID.ToString())); | ||
208 | item.assetID = new LLUUID(config.GetString("assetID", LLUUID.Random().ToString())); | ||
209 | item.parentFolderID = new LLUUID(config.GetString("folderID", folderID.ToString())); | ||
210 | item.inventoryDescription = config.GetString("description", ""); | ||
211 | item.inventoryName = config.GetString("name", ""); | ||
212 | item.assetType = config.GetInt("assetType", 0); | ||
213 | item.invType = config.GetInt("inventoryType", 0); | ||
214 | item.inventoryCurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF); | ||
215 | item.inventoryNextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF); | ||
216 | item.inventoryEveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF); | ||
217 | item.inventoryBasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF); | ||
218 | |||
219 | if (libraryFolders.ContainsKey(item.parentFolderID)) | ||
204 | { | 220 | { |
205 | InventoryItemBase item = new InventoryItemBase(); | 221 | InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID]; |
206 | item.avatarID = libOwner; | ||
207 | item.creatorsID = libOwner; | ||
208 | item.inventoryID = | ||
209 | new LLUUID(source.Configs[i].GetString("inventoryID", folderID.ToString())); | ||
210 | item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToString())); | ||
211 | item.parentFolderID | ||
212 | = new LLUUID(source.Configs[i].GetString("folderID", folderID.ToString())); | ||
213 | item.inventoryDescription = source.Configs[i].GetString("description", ""); | ||
214 | item.inventoryName = source.Configs[i].GetString("name", ""); | ||
215 | item.assetType = source.Configs[i].GetInt("assetType", 0); | ||
216 | item.invType = source.Configs[i].GetInt("inventoryType", 0); | ||
217 | item.inventoryCurrentPermissions = (uint) source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); | ||
218 | item.inventoryNextPermissions = (uint) source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); | ||
219 | item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); | ||
220 | item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); | ||
221 | 222 | ||
222 | if (libraryFolders.ContainsKey(item.parentFolderID)) | 223 | parentFolder.Items.Add(item.inventoryID, item); |
224 | } | ||
225 | else | ||
226 | { | ||
227 | MainLog.Instance.Warn( | ||
228 | "LIBRARYINVENTORY", | ||
229 | "Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!", | ||
230 | item.inventoryName, item.inventoryID, item.parentFolderID); | ||
231 | } | ||
232 | } | ||
233 | |||
234 | private delegate void ConfigAction(IConfig config); | ||
235 | |||
236 | /// <summary> | ||
237 | /// Load the given configuration at a path and perform an action on each Config contained within it | ||
238 | /// </summary> | ||
239 | /// <param name="path"></param> | ||
240 | /// <param name="fileDescription"></param> | ||
241 | /// <param name="action"></param> | ||
242 | private void LoadFromFile(string path, string fileDescription, ConfigAction action) | ||
243 | { | ||
244 | if (File.Exists(path)) | ||
245 | { | ||
246 | try | ||
223 | { | 247 | { |
224 | InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID]; | 248 | XmlConfigSource source = new XmlConfigSource(path); |
225 | 249 | ||
226 | parentFolder.Items.Add(item.inventoryID, item); | 250 | for (int i = 0; i < source.Configs.Count; i++) |
251 | { | ||
252 | action(source.Configs[i]); | ||
253 | } | ||
227 | } | 254 | } |
228 | else | 255 | catch (XmlException e) |
229 | { | 256 | { |
230 | MainLog.Instance.Warn( | 257 | MainLog.Instance.Error( |
231 | "LIBRARYINVENTORY", | 258 | "LIBRARYINVENTORY", "Error loading {0} : {1}", path, e); |
232 | "Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!", | ||
233 | item.inventoryName, item.inventoryID, item.parentFolderID); | ||
234 | } | 259 | } |
235 | } | 260 | } |
261 | else | ||
262 | { | ||
263 | MainLog.Instance.Error( | ||
264 | "LIBRARYINVENTORY", "{0} file {1} does not exist!", fileDescription, path); | ||
265 | } | ||
236 | } | 266 | } |
237 | 267 | ||
238 | /// <summary> | 268 | /// <summary> |
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index afc6c9a..0531d6a 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs | |||
@@ -280,6 +280,7 @@ namespace OpenSim.Framework.UserManagement | |||
280 | } | 280 | } |
281 | return buddylistreturn; | 281 | return buddylistreturn; |
282 | } | 282 | } |
283 | |||
283 | /// <summary> | 284 | /// <summary> |
284 | /// Converts the inventory library skeleton into the form required by the rpc request. | 285 | /// Converts the inventory library skeleton into the form required by the rpc request. |
285 | /// </summary> | 286 | /// </summary> |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index c742cf3..0f41380 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -321,7 +321,12 @@ namespace OpenSim.Framework | |||
321 | 321 | ||
322 | public static string assetsDir() | 322 | public static string assetsDir() |
323 | { | 323 | { |
324 | return "assets"; | 324 | return Path.Combine(configDir(), "assets"); |
325 | } | ||
326 | |||
327 | public static string inventoryDir() | ||
328 | { | ||
329 | return Path.Combine(configDir(), "inventory"); | ||
325 | } | 330 | } |
326 | 331 | ||
327 | public static string configDir() | 332 | public static string configDir() |
diff --git a/bin/assets/AssetSets.xml b/bin/assets/AssetSets.xml index b827e59..c94cd59 100644 --- a/bin/assets/AssetSets.xml +++ b/bin/assets/AssetSets.xml | |||
@@ -1,13 +1,18 @@ | |||
1 | <Nini> | 1 | <Nini> |
2 | <!-- You probably don't want to remove the OpenSim asset set | 2 | <!-- You probably don't want to remove the OpenSim asset set |
3 | since it contains various default assets which are currently hardcoded --> | 3 | since it contains various default assets which are currently hardcoded |
4 | However, you can remove the corresponding inventory library in bin/inventory if you wish | ||
5 | --> | ||
6 | |||
4 | <Section Name="OpenSim Asset Set"> | 7 | <Section Name="OpenSim Asset Set"> |
5 | <Key Name="file" Value="OpenSimAssetSet/OpenSimAssetSet.xml"/> | 8 | <Key Name="file" Value="OpenSimAssetSet/OpenSimAssetSet.xml"/> |
6 | </Section> | 9 | </Section> |
10 | |||
7 | <!-- New asset sets can be added as shown below --> | 11 | <!-- New asset sets can be added as shown below --> |
8 | <!-- | 12 | |
13 | <!-- | ||
9 | <Section Name="My Asset Set"> | 14 | <Section Name="My Asset Set"> |
10 | <Key Name="file" Value="MyAssetSet/MyAssetSet.xml"/> | 15 | <Key Name="file" Value="MyAssetSet/MyAssetSet.xml"/> |
11 | </Section> | 16 | </Section> |
12 | --> | 17 | --> |
13 | </Nini> | 18 | </Nini> |
diff --git a/bin/inventory/Libraries.xml b/bin/inventory/Libraries.xml new file mode 100644 index 0000000..09270b5 --- /dev/null +++ b/bin/inventory/Libraries.xml | |||
@@ -0,0 +1,17 @@ | |||
1 | <Nini> | ||
2 | <Section Name="OpenSim Standard Library"> | ||
3 | <Key Name="foldersFile" Value="OpenSimLibrary/OpenSimLibraryFolders.xml"/> | ||
4 | <Key Name="itemsFile" Value="OpenSimLibrary/OpenSimLibrary.xml"/> | ||
5 | </Section> | ||
6 | <!-- Additional libraries can be added as shown below. These folders and items can appear underneath | ||
7 | the hardcoded root library folder ("OpenSim Library") | ||
8 | |||
9 | You can also add folders and items to the folders of libraries defined earlier on in this file --> | ||
10 | |||
11 | <!-- | ||
12 | <Section Name="My Site Library"> | ||
13 | <Key Name="foldersFile" Value="MySiteLibrary/MySiteLibraryFolders.xml"/> | ||
14 | <Key Name="itemsFile" Value="MySiteLibrary/MySiteLibraryItems.xml"/> | ||
15 | </Section> | ||
16 | --> | ||
17 | </Nini> | ||
diff --git a/bin/inventory/README.txt b/bin/inventory/README.txt index f32f1aa..ecd81d1 100644 --- a/bin/inventory/README.txt +++ b/bin/inventory/README.txt | |||
@@ -1,14 +1,21 @@ | |||
1 | README | 1 | README |
2 | 2 | ||
3 | The standard common inventory library is configured here. You can add new inventory | 3 | Folders and items which will appear in the standard common library for all |
4 | folders to the standard library by editing OpenSimLibary/OpenSimLibraryFolders.xml | 4 | avatars can be configured here. The root folder (currently called OpenSim |
5 | You can also add new inventory items to OpenSimLibrary/OpenSimLibrary.xml, | 5 | Library) is hardcoded, but you can add your own configuration of folders and |
6 | as long as they have a corresponding asset entry in bin/OpenSimAssetSet.xml. | 6 | items directly beneath this, in addition to (or instead of) the contents of the |
7 | 7 | default OpenSim library. | |
8 | The same set of folders and items must be present in the configuration of both | 8 | |
9 | the grid servers and all the regions. The reasons for this are historical - | 9 | To add a new library, edit Libraries.xml. The entry in here needs to point to |
10 | this restriction will probably be lifted in the future, at which point the | 10 | two further xml files, one which details your library inventory folders and another |
11 | inventory items and folders will only need to be configured on the grid inventory | 11 | which details your library inventory items. Each inventory item will need to be |
12 | server (assuming you are running in grid mode rather than standalone) | 12 | associated with an asset. Assets are configured separately in the bin/assets |
13 | directory. | ||
14 | |||
15 | If you are running in grid mode, any library you add must be present in both | ||
16 | your grid servers installation and in | ||
17 | every region installation, otherwise library items will fail in the regions | ||
18 | where the inventory configuration is not present. The reasons for this are historical | ||
19 | and will probably be lifted in a future revision. | ||
13 | 20 | ||
14 | Files in the attic directory are currently unused. | 21 | Files in the attic directory are currently unused. |