aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache
diff options
context:
space:
mode:
authorJustin Clarke Casey2007-12-31 03:33:21 +0000
committerJustin Clarke Casey2007-12-31 03:33:21 +0000
commit60fa75ac0466101654c6043d0366965da34c35bc (patch)
tree97915b0d42aba2e119025cad6f154a478fab09ca /OpenSim/Framework/Communications/Cache
parent* Added a catch for RemotingErrors on the TCP init (diff)
downloadopensim-SC_OLD-60fa75ac0466101654c6043d0366965da34c35bc.zip
opensim-SC_OLD-60fa75ac0466101654c6043d0366965da34c35bc.tar.gz
opensim-SC_OLD-60fa75ac0466101654c6043d0366965da34c35bc.tar.bz2
opensim-SC_OLD-60fa75ac0466101654c6043d0366965da34c35bc.tar.xz
Standard library folders can now be configued in the xml in inventory/OpenSimLibrary - no hardcoded changes are required. For some reason, all the folders are currently
showing up as texture folders, even though they are configured with the same types as the agent inventory folders. This should be resolved soon.
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r--OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs125
1 files changed, 100 insertions, 25 deletions
diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
index 20ec58a..cb122df 100644
--- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
+++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
@@ -26,10 +26,12 @@
26* 26*
27*/ 27*/
28 28
29using System.Collections.Generic;
29using System.IO; 30using System.IO;
30using System.Xml; 31using System.Xml;
31using libsecondlife; 32using libsecondlife;
32using Nini.Config; 33using Nini.Config;
34
33using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
34 36
35namespace OpenSim.Framework.Communications.Cache 37namespace OpenSim.Framework.Communications.Cache
@@ -41,44 +43,62 @@ namespace OpenSim.Framework.Communications.Cache
41 public class LibraryRootFolder : InventoryFolderImpl 43 public class LibraryRootFolder : InventoryFolderImpl
42 { 44 {
43 private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); 45 private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000");
44 private InventoryFolderImpl m_textureFolder; 46
47 /// <summary>
48 /// Holds the root library folder and all its descendents. This is really only used during inventory
49 /// setup so that we don't have to repeatedly search the tree of library folders.
50 /// </summary>
51 protected Dictionary<LLUUID, InventoryFolderImpl> libraryFolders
52 = new Dictionary<LLUUID, InventoryFolderImpl>();
45 53
46 public LibraryRootFolder() 54 public LibraryRootFolder()
47 { 55 {
56 MainLog.Instance.Verbose("LIBRARYINVENTORY", "Loading library inventory");
57
48 agentID = libOwner; 58 agentID = libOwner;
49 folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); 59 folderID = new LLUUID("00000112-000f-0000-0000-000100bba000");
50 name = "OpenSim Library"; 60 name = "OpenSim Library";
51 parentID = LLUUID.Zero; 61 parentID = LLUUID.Zero;
52 type = (short) -1; 62 type = (short) 8;
53 version = (ushort) 1; 63 version = (ushort) 1;
54 64
55 InventoryFolderImpl folderInfo = new InventoryFolderImpl(); 65 libraryFolders.Add(folderID, this);
56 folderInfo.agentID = libOwner; 66
57 folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001"); 67 string foldersPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibraryFolders.xml");
58 folderInfo.name = "Texture Library"; 68 if (File.Exists(foldersPath))
59 folderInfo.parentID = folderID; 69 {
60 folderInfo.type = -1; 70 try
61 folderInfo.version = 1; 71 {
62 SubFolders.Add(folderInfo.folderID, folderInfo); 72 XmlConfigSource source = new XmlConfigSource(foldersPath);
63 m_textureFolder = folderInfo; 73 ReadFoldersFromFile(source);
74 }
75 catch (XmlException e)
76 {
77 MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + foldersPath + ": " + e.ToString());
78 }
79 }
64 80
65 CreateLibraryItems(); 81 CreateLibraryItems();
66 82
67 string filePath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibrary.xml"); 83 string itemsPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibrary.xml");
68 if (File.Exists(filePath)) 84 if (File.Exists(itemsPath))
69 { 85 {
70 try 86 try
71 { 87 {
72 XmlConfigSource source = new XmlConfigSource(filePath); 88 XmlConfigSource source = new XmlConfigSource(itemsPath);
73 ReadItemsFromFile(source); 89 ReadItemsFromFile(source);
74 } 90 }
75 catch (XmlException e) 91 catch (XmlException e)
76 { 92 {
77 MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + filePath + ": " + e.ToString()); 93 MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + itemsPath + ": " + e.ToString());
78 } 94 }
79 } 95 }
80 } 96 }
81 97
98 /// <summary>
99 /// Hardcoded item creation. Please don't add any more items here - future items should be created
100 /// in the xml in the bin/inventory folder.
101 /// </summary>
82 private void CreateLibraryItems() 102 private void CreateLibraryItems()
83 { 103 {
84 InventoryItemBase item = 104 InventoryItemBase item =
@@ -133,7 +153,51 @@ namespace OpenSim.Framework.Communications.Cache
133 item.inventoryNextPermissions = 0x7FFFFFFF; 153 item.inventoryNextPermissions = 0x7FFFFFFF;
134 return item; 154 return item;
135 } 155 }
156
157 /// <summary>
158 /// Read library inventory folders from an external source
159 /// </summary>
160 /// <param name="source"></param>
161 private void ReadFoldersFromFile(IConfigSource source)
162 {
163 for (int i = 0; i < source.Configs.Count; i++)
164 {
165 IConfig config = source.Configs[i];
166
167 InventoryFolderImpl folderInfo = new InventoryFolderImpl();
168
169 folderInfo.folderID = new LLUUID(config.GetString("folderID", folderID.ToString()));
170 folderInfo.name = config.GetString("name", "unknown");
171 folderInfo.parentID = new LLUUID(config.GetString("parentFolderID", folderID.ToString()));
172 folderInfo.type = (short)config.GetInt("type", 8);
173
174 folderInfo.agentID = libOwner;
175 folderInfo.version = 1;
176
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(
185// "LIBRARYINVENTORY", "Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID);
186 }
187 else
188 {
189 MainLog.Instance.Warn(
190 "LIBRARYINVENTORY",
191 "Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!",
192 folderInfo.name, folderInfo.folderID, folderInfo.parentID);
193 }
194 }
195 }
136 196
197 /// <summary>
198 /// Read library inventory items metadata from an external source
199 /// </summary>
200 /// <param name="source"></param>
137 private void ReadItemsFromFile(IConfigSource source) 201 private void ReadItemsFromFile(IConfigSource source)
138 { 202 {
139 for (int i = 0; i < source.Configs.Count; i++) 203 for (int i = 0; i < source.Configs.Count; i++)
@@ -145,7 +209,7 @@ namespace OpenSim.Framework.Communications.Cache
145 new LLUUID(source.Configs[i].GetString("inventoryID", folderID.ToString())); 209 new LLUUID(source.Configs[i].GetString("inventoryID", folderID.ToString()));
146 item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToString())); 210 item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToString()));
147 item.parentFolderID 211 item.parentFolderID
148 = new LLUUID(source.Configs[i].GetString("folderID", LLUUID.Random().ToString())); 212 = new LLUUID(source.Configs[i].GetString("folderID", folderID.ToString()));
149 item.inventoryDescription = source.Configs[i].GetString("description", ""); 213 item.inventoryDescription = source.Configs[i].GetString("description", "");
150 item.inventoryName = source.Configs[i].GetString("name", ""); 214 item.inventoryName = source.Configs[i].GetString("name", "");
151 item.assetType = source.Configs[i].GetInt("assetType", 0); 215 item.assetType = source.Configs[i].GetInt("assetType", 0);
@@ -155,19 +219,30 @@ namespace OpenSim.Framework.Communications.Cache
155 item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); 219 item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF);
156 item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); 220 item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF);
157 221
158 if (item.parentFolderID == folderID) 222 if (libraryFolders.ContainsKey(item.parentFolderID))
159 { 223 {
160 Items.Add(item.inventoryID, item); 224 InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID];
225
226 parentFolder.Items.Add(item.inventoryID, item);
161 } 227 }
162 else 228 else
163 { 229 {
164 // Very temporary - will only work for immediate child folders 230 MainLog.Instance.Warn(
165 if (SubFolders.ContainsKey(item.parentFolderID)) 231 "LIBRARYINVENTORY",
166 { 232 "Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!",
167 SubFolders[item.parentFolderID].Items.Add(item.inventoryID, item); 233 item.inventoryName, item.inventoryID, item.parentFolderID);
168 } 234 }
169 }
170 } 235 }
171 } 236 }
237
238 /// <summary>
239 /// Looks like a simple getter, but is written like this for some consistency with the other Request
240 /// methods in the superclass
241 /// </summary>
242 /// <returns></returns>
243 public Dictionary<LLUUID, InventoryFolderImpl> RequestSelfAndDescendentFolders()
244 {
245 return libraryFolders;
246 }
172 } 247 }
173} 248}