aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-08-25 02:00:17 +0100
committerJustin Clark-Casey (justincc)2012-08-25 02:00:17 +0100
commita0d178b284050df64d0eb5b9728565fd72615c22 (patch)
tree90ab324ee179ed7cdd0ddc996c30a176ada5957d
parentAllow multiple calling card type inventory folders to be created. (diff)
downloadopensim-SC_OLD-a0d178b284050df64d0eb5b9728565fd72615c22.zip
opensim-SC_OLD-a0d178b284050df64d0eb5b9728565fd72615c22.tar.gz
opensim-SC_OLD-a0d178b284050df64d0eb5b9728565fd72615c22.tar.bz2
opensim-SC_OLD-a0d178b284050df64d0eb5b9728565fd72615c22.tar.xz
Following on from f8a89a79, do not allow more than one 'type' folder (e.g. calling cards) to be created in the base "My Inventory" user folder.
This is to accomodate situations where viewers will create more than one 'type' subfolder (e.g. calling cards) But at the same time to prevent multiple such 'system' folders (those in the base "My Inventory" user folder). This also makes GetFolderForType() only return a folder in the base "My Inventory" folder, if such a type folder exists
-rw-r--r--OpenSim/Services/InventoryService/XInventoryService.cs65
1 files changed, 49 insertions, 16 deletions
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index e10e0be..deacd5a 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -229,10 +229,28 @@ namespace OpenSim.Services.InventoryService
229 public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) 229 public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
230 { 230 {
231// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID); 231// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
232
233 InventoryFolderBase rootFolder = GetRootFolder(principalID);
234
235 if (rootFolder == null)
236 {
237 m_log.WarnFormat(
238 "[XINVENTORY]: Found no root folder for {0} in GetFolderForType() when looking for {1}",
239 principalID, type);
240
241 return null;
242 }
243
244 return GetSystemFolderForType(rootFolder, type);
245 }
246
247 private InventoryFolderBase GetSystemFolderForType(InventoryFolderBase rootFolder, AssetType type)
248 {
249// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
232 250
233 XInventoryFolder[] folders = m_Database.GetFolders( 251 XInventoryFolder[] folders = m_Database.GetFolders(
234 new string[] { "agentID", "type"}, 252 new string[] { "agentID", "parentFolderID", "type"},
235 new string[] { principalID.ToString(), ((int)type).ToString() }); 253 new string[] { rootFolder.Owner.ToString(), rootFolder.ID.ToString(), ((int)type).ToString() });
236 254
237 if (folders.Length == 0) 255 if (folders.Length == 0)
238 { 256 {
@@ -308,23 +326,38 @@ namespace OpenSim.Services.InventoryService
308 if (check != null) 326 if (check != null)
309 return false; 327 return false;
310 328
311 if (folder.Type == (short)AssetType.Folder 329 if (folder.Type != (short)AssetType.Folder || folder.Type != (short)AssetType.Unknown)
312 || folder.Type == (short)AssetType.Unknown
313 || folder.Type == (short)AssetType.OutfitFolder
314 || folder.Type == (short)AssetType.CallingCard
315 || GetFolderForType(folder.Owner, (AssetType)(folder.Type)) == null)
316 {
317 XInventoryFolder xFolder = ConvertFromOpenSim(folder);
318 return m_Database.StoreFolder(xFolder);
319 }
320 else
321 { 330 {
322 m_log.WarnFormat( 331 InventoryFolderBase rootFolder = GetRootFolder(folder.Owner);
323 "[XINVENTORY]: Folder of type {0} already exists when tried to add {1} to {2} for {3}", 332
324 folder.Type, folder.Name, folder.ParentID, folder.Owner); 333 if (rootFolder == null)
334 {
335 m_log.WarnFormat(
336 "[XINVENTORY]: Found no root folder for {0} in AddFolder() when looking for {1}",
337 folder.Owner, folder.Type);
338
339 return false;
340 }
341
342 // Check we're not trying to add this as a system folder.
343 if (folder.ParentID == rootFolder.ID)
344 {
345 InventoryFolderBase existingSystemFolder
346 = GetSystemFolderForType(rootFolder, (AssetType)folder.Type);
347
348 if (existingSystemFolder != null)
349 {
350 m_log.WarnFormat(
351 "[XINVENTORY]: System folder of type {0} already exists when tried to add {1} to {2} for {3}",
352 folder.Type, folder.Name, folder.ParentID, folder.Owner);
353
354 return false;
355 }
356 }
325 } 357 }
326 358
327 return false; 359 XInventoryFolder xFolder = ConvertFromOpenSim(folder);
360 return m_Database.StoreFolder(xFolder);
328 } 361 }
329 362
330 public virtual bool UpdateFolder(InventoryFolderBase folder) 363 public virtual bool UpdateFolder(InventoryFolderBase folder)