aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
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
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')
-rw-r--r--OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs125
-rw-r--r--OpenSim/Framework/Communications/LoginService.cs50
2 files changed, 129 insertions, 46 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}
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index bef20f7..a9d5d8b 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -28,9 +28,12 @@
28 28
29using System; 29using System;
30using System.Collections; 30using System.Collections;
31using System.Collections.Generic;
31using System.Threading; 32using System.Threading;
32using libsecondlife; 33using libsecondlife;
33using Nwc.XmlRpc; 34using Nwc.XmlRpc;
35
36using OpenSim.Framework.Communications.Cache;
34using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
35 38
36namespace OpenSim.Framework.UserManagement 39namespace OpenSim.Framework.UserManagement
@@ -40,10 +43,18 @@ namespace OpenSim.Framework.UserManagement
40 protected string m_welcomeMessage = "Welcome to OpenSim"; 43 protected string m_welcomeMessage = "Welcome to OpenSim";
41 protected UserManagerBase m_userManager = null; 44 protected UserManagerBase m_userManager = null;
42 protected Mutex m_loginMutex = new Mutex(false); 45 protected Mutex m_loginMutex = new Mutex(false);
46
47 /// <summary>
48 /// Used during login to send the skeleton of the OpenSim Library to the client.
49 /// </summary>
50 protected LibraryRootFolder m_libraryRootFolder;
43 51
44 public LoginService(UserManagerBase userManager, string welcomeMess) 52 public LoginService(
53 UserManagerBase userManager, LibraryRootFolder libraryRootFolder, string welcomeMess)
45 { 54 {
46 m_userManager = userManager; 55 m_userManager = userManager;
56 m_libraryRootFolder = libraryRootFolder;
57
47 if (welcomeMess != "") 58 if (welcomeMess != "")
48 { 59 {
49 m_welcomeMessage = welcomeMess; 60 m_welcomeMessage = welcomeMess;
@@ -255,30 +266,27 @@ namespace OpenSim.Framework.UserManagement
255 } 266 }
256 267
257 /// <summary> 268 /// <summary>
258 /// 269 /// Converts the inventory library skeleton into the form required by the rpc request.
259 /// </summary> 270 /// </summary>
260 /// <returns></returns> 271 /// <returns></returns>
261 protected virtual ArrayList GetInventoryLibrary() 272 protected virtual ArrayList GetInventoryLibrary()
262 { 273 {
263 //return new ArrayList(); 274 Dictionary<LLUUID, InventoryFolderImpl> rootFolders
264 Hashtable TempHash = new Hashtable(); 275 = m_libraryRootFolder.RequestSelfAndDescendentFolders();
265 TempHash["name"] = "OpenSim Library"; 276 ArrayList folderHashes = new ArrayList();
266 TempHash["parent_id"] = LLUUID.Zero.ToString(); 277
267 TempHash["version"] = 1; 278 foreach (InventoryFolderBase folder in rootFolders.Values)
268 TempHash["type_default"] = -1; 279 {
269 TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; 280 Hashtable TempHash = new Hashtable();
270 ArrayList temp = new ArrayList(); 281 TempHash["name"] = folder.name;
271 temp.Add(TempHash); 282 TempHash["parent_id"] = folder.parentID.ToString();
272 283 TempHash["version"] = folder.version;
273 TempHash = new Hashtable(); 284 TempHash["type_default"] = folder.type;
274 TempHash["name"] = "Texture Library"; 285 TempHash["folder_id"] = folder.folderID.ToString();
275 TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; 286 folderHashes.Add(TempHash);
276 TempHash["version"] = 1; 287 }
277 TempHash["type_default"] = -1; 288
278 TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; 289 return folderHashes;
279 temp.Add(TempHash);
280
281 return temp;
282 } 290 }
283 291
284 /// <summary> 292 /// <summary>