aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs')
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs258
1 files changed, 147 insertions, 111 deletions
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
index 784f136..40eb6d4 100644
--- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Services.HypergridService
54 LogManager.GetLogger( 54 LogManager.GetLogger(
55 MethodBase.GetCurrentMethod().DeclaringType); 55 MethodBase.GetCurrentMethod().DeclaringType);
56 56
57 private string m_HomeURL; 57// private string m_HomeURL;
58 private IUserAccountService m_UserAccountService; 58 private IUserAccountService m_UserAccountService;
59 private IAvatarService m_AvatarService; 59 private IAvatarService m_AvatarService;
60 60
@@ -96,8 +96,8 @@ namespace OpenSim.Services.HypergridService
96 if (m_AvatarService == null) 96 if (m_AvatarService == null)
97 throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll)); 97 throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll));
98 98
99 // Preferred 99// m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI",
100 m_HomeURL = invConfig.GetString("HomeURI", m_HomeURL); 100// new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty);
101 101
102// m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); 102// m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
103 } 103 }
@@ -115,8 +115,14 @@ namespace OpenSim.Services.HypergridService
115 { 115 {
116 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); 116 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
117 117
118 if (suitcase == null)
119 {
120 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for inventory skeleton", principalID);
121 return null;
122 }
123
118 List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID); 124 List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID);
119 if (tree == null || (tree != null && tree.Count == 0)) 125 if (tree.Count == 0)
120 return null; 126 return null;
121 127
122 List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); 128 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
@@ -131,58 +137,13 @@ namespace OpenSim.Services.HypergridService
131 return folders; 137 return folders;
132 } 138 }
133 139
134 public override InventoryCollection GetUserInventory(UUID userID)
135 {
136 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Get Suitcase inventory for user {0}", userID);
137 InventoryCollection userInventory = new InventoryCollection();
138 userInventory.UserID = userID;
139 userInventory.Folders = new List<InventoryFolderBase>();
140 userInventory.Items = new List<InventoryItemBase>();
141
142 XInventoryFolder suitcase = GetSuitcaseXFolder(userID);
143
144 List<XInventoryFolder> tree = GetFolderTree(userID, suitcase.folderID);
145 if (tree == null || (tree != null && tree.Count == 0))
146 {
147 SetAsNormalFolder(suitcase);
148 userInventory.Folders.Add(ConvertToOpenSim(suitcase));
149 return userInventory;
150 }
151
152 List<InventoryItemBase> items;
153 foreach (XInventoryFolder f in tree)
154 {
155 // Add the items of this subfolder
156 items = GetFolderItems(userID, f.folderID);
157 if (items != null && items.Count > 0)
158 {
159 userInventory.Items.AddRange(items);
160 }
161
162 // Add the folder itself
163 userInventory.Folders.Add(ConvertToOpenSim(f));
164 }
165
166 items = GetFolderItems(userID, suitcase.folderID);
167 if (items != null && items.Count > 0)
168 {
169 userInventory.Items.AddRange(items);
170 }
171
172 SetAsNormalFolder(suitcase);
173 userInventory.Folders.Add(ConvertToOpenSim(suitcase));
174
175 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items",
176 userID, userInventory.Folders.Count, userInventory.Items.Count);
177 return userInventory;
178 }
179
180 public override InventoryFolderBase GetRootFolder(UUID principalID) 140 public override InventoryFolderBase GetRootFolder(UUID principalID)
181 { 141 {
182 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); 142 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
183 143
184 // Let's find out the local root folder 144 // Let's find out the local root folder
185 XInventoryFolder root = GetRootXFolder(principalID); ; 145 XInventoryFolder root = GetRootXFolder(principalID);
146
186 if (root == null) 147 if (root == null)
187 { 148 {
188 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID); 149 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID);
@@ -195,14 +156,15 @@ namespace OpenSim.Services.HypergridService
195 if (suitcase == null) 156 if (suitcase == null)
196 { 157 {
197 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder. Creating it...", principalID); 158 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder. Creating it...", principalID);
198 // make one, and let's add it to the user's inventory as a direct child of the root folder 159 // Create the My Suitcase folder under the user's root folder.
199 // In the DB we tag it as type 100, but we use -1 (Unknown) outside 160 // In the DB we tag it as type 100, but we use type 8 (Folder) outside, as this affects the sort order.
200 suitcase = CreateFolder(principalID, root.folderID, 100, "My Suitcase"); 161 suitcase = CreateFolder(principalID, root.folderID, (int)FolderType.Suitcase, InventoryFolderBase.SUITCASE_FOLDER_NAME);
201 if (suitcase == null) 162 if (suitcase == null)
163 {
202 m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder"); 164 m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder");
203 m_Database.StoreFolder(suitcase); 165 return null;
166 }
204 167
205 // Create System folders
206 CreateSystemFolders(principalID, suitcase.folderID); 168 CreateSystemFolders(principalID, suitcase.folderID);
207 } 169 }
208 170
@@ -216,45 +178,51 @@ namespace OpenSim.Services.HypergridService
216 m_log.Debug("[HG SUITCASE INVENTORY SERVICE]: Creating System folders under Suitcase..."); 178 m_log.Debug("[HG SUITCASE INVENTORY SERVICE]: Creating System folders under Suitcase...");
217 XInventoryFolder[] sysFolders = GetSystemFolders(principalID, rootID); 179 XInventoryFolder[] sysFolders = GetSystemFolders(principalID, rootID);
218 180
219 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Animation) return true; return false; })) 181 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Animation) return true; return false; }))
220 CreateFolder(principalID, rootID, (int)AssetType.Animation, "Animations"); 182 CreateFolder(principalID, rootID, (int)FolderType.Animation, "Animations");
221 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Bodypart) return true; return false; })) 183 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.BodyPart) return true; return false; }))
222 CreateFolder(principalID, rootID, (int)AssetType.Bodypart, "Body Parts"); 184 CreateFolder(principalID, rootID, (int)FolderType.BodyPart, "Body Parts");
223 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.CallingCard) return true; return false; })) 185 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.CallingCard) return true; return false; }))
224 CreateFolder(principalID, rootID, (int)AssetType.CallingCard, "Calling Cards"); 186 CreateFolder(principalID, rootID, (int)FolderType.CallingCard, "Calling Cards");
225 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Clothing) return true; return false; })) 187 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Clothing) return true; return false; }))
226 CreateFolder(principalID, rootID, (int)AssetType.Clothing, "Clothing"); 188 CreateFolder(principalID, rootID, (int)FolderType.Clothing, "Clothing");
227 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; })) 189 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.CurrentOutfit) return true; return false; }))
228 CreateFolder(principalID, rootID, (int)AssetType.Gesture, "Gestures"); 190 CreateFolder(principalID, rootID, (int)FolderType.CurrentOutfit, "Current Outfit");
229 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Landmark) return true; return false; })) 191 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Favorites) return true; return false; }))
230 CreateFolder(principalID, rootID, (int)AssetType.Landmark, "Landmarks"); 192 CreateFolder(principalID, rootID, (int)FolderType.Favorites, "Favorites");
231 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.LostAndFoundFolder) return true; return false; })) 193 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Gesture) return true; return false; }))
232 CreateFolder(principalID, rootID, (int)AssetType.LostAndFoundFolder, "Lost And Found"); 194 CreateFolder(principalID, rootID, (int)FolderType.Gesture, "Gestures");
233 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Notecard) return true; return false; })) 195 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Landmark) return true; return false; }))
234 CreateFolder(principalID, rootID, (int)AssetType.Notecard, "Notecards"); 196 CreateFolder(principalID, rootID, (int)FolderType.Landmark, "Landmarks");
235 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Object) return true; return false; })) 197 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.LostAndFound) return true; return false; }))
236 CreateFolder(principalID, rootID, (int)AssetType.Object, "Objects"); 198 CreateFolder(principalID, rootID, (int)FolderType.LostAndFound, "Lost And Found");
237 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.SnapshotFolder) return true; return false; })) 199 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Notecard) return true; return false; }))
238 CreateFolder(principalID, rootID, (int)AssetType.SnapshotFolder, "Photo Album"); 200 CreateFolder(principalID, rootID, (int)FolderType.Notecard, "Notecards");
239 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.LSLText) return true; return false; })) 201 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Object) return true; return false; }))
240 CreateFolder(principalID, rootID, (int)AssetType.LSLText, "Scripts"); 202 CreateFolder(principalID, rootID, (int)FolderType.Object, "Objects");
241 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Sound) return true; return false; })) 203 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Snapshot) return true; return false; }))
242 CreateFolder(principalID, rootID, (int)AssetType.Sound, "Sounds"); 204 CreateFolder(principalID, rootID, (int)FolderType.Snapshot, "Photo Album");
243 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Texture) return true; return false; })) 205 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.LSLText) return true; return false; }))
244 CreateFolder(principalID, rootID, (int)AssetType.Texture, "Textures"); 206 CreateFolder(principalID, rootID, (int)FolderType.LSLText, "Scripts");
245 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.TrashFolder) return true; return false; })) 207 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Sound) return true; return false; }))
246 CreateFolder(principalID, rootID, (int)AssetType.TrashFolder, "Trash"); 208 CreateFolder(principalID, rootID, (int)FolderType.Sound, "Sounds");
247 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.FavoriteFolder) return true; return false; })) 209 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Texture) return true; return false; }))
248 CreateFolder(principalID, rootID, (int)AssetType.FavoriteFolder, "Favorites"); 210 CreateFolder(principalID, rootID, (int)FolderType.Texture, "Textures");
249 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.CurrentOutfitFolder) return true; return false; })) 211 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Trash) return true; return false; }))
250 CreateFolder(principalID, rootID, (int)AssetType.CurrentOutfitFolder, "Current Outfit"); 212 CreateFolder(principalID, rootID, (int)FolderType.Trash, "Trash");
251
252 } 213 }
253 214
254 public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) 215 public override InventoryFolderBase GetFolderForType(UUID principalID, FolderType type)
255 { 216 {
256 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type); 217 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type);
257 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); 218 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
219
220 if (suitcase == null)
221 {
222 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for child type folder {1}", principalID, type);
223 return null;
224 }
225
258 XInventoryFolder[] folders = m_Database.GetFolders( 226 XInventoryFolder[] folders = m_Database.GetFolders(
259 new string[] { "agentID", "type", "parentFolderID" }, 227 new string[] { "agentID", "type", "parentFolderID" },
260 new string[] { principalID.ToString(), ((int)type).ToString(), suitcase.folderID.ToString() }); 228 new string[] { principalID.ToString(), ((int)type).ToString(), suitcase.folderID.ToString() });
@@ -277,7 +245,10 @@ namespace OpenSim.Services.HypergridService
277 InventoryCollection coll = null; 245 InventoryCollection coll = null;
278 246
279 if (!IsWithinSuitcaseTree(principalID, folderID)) 247 if (!IsWithinSuitcaseTree(principalID, folderID))
248 {
249 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent: folder {0} (user {1}) is not within Suitcase tree", folderID, principalID);
280 return new InventoryCollection(); 250 return new InventoryCollection();
251 }
281 252
282 coll = base.GetFolderContent(principalID, folderID); 253 coll = base.GetFolderContent(principalID, folderID);
283 254
@@ -294,7 +265,10 @@ namespace OpenSim.Services.HypergridService
294 // Let's do a bit of sanity checking, more than the base service does 265 // Let's do a bit of sanity checking, more than the base service does
295 // make sure the given folder exists under the suitcase tree of this user 266 // make sure the given folder exists under the suitcase tree of this user
296 if (!IsWithinSuitcaseTree(principalID, folderID)) 267 if (!IsWithinSuitcaseTree(principalID, folderID))
268 {
269 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderItems: folder {0} (user {1}) is not within Suitcase tree", folderID, principalID);
297 return new List<InventoryItemBase>(); 270 return new List<InventoryItemBase>();
271 }
298 272
299 return base.GetFolderItems(principalID, folderID); 273 return base.GetFolderItems(principalID, folderID);
300 } 274 }
@@ -306,7 +280,10 @@ namespace OpenSim.Services.HypergridService
306 // make sure the given folder's parent folder exists under the suitcase tree of this user 280 // make sure the given folder's parent folder exists under the suitcase tree of this user
307 281
308 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) 282 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
283 {
284 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner);
309 return false; 285 return false;
286 }
310 287
311 // OK, it's legit 288 // OK, it's legit
312 if (base.AddFolder(folder)) 289 if (base.AddFolder(folder))
@@ -326,7 +303,7 @@ namespace OpenSim.Services.HypergridService
326 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); 303 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version);
327 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID)) 304 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID))
328 { 305 {
329 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name); 306 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateFolder: folder {0}/{1} (user {2}) is not within Suitcase tree", folder.Name, folder.ID, folder.Owner);
330 return false; 307 return false;
331 } 308 }
332 309
@@ -336,9 +313,17 @@ namespace OpenSim.Services.HypergridService
336 313
337 public override bool MoveFolder(InventoryFolderBase folder) 314 public override bool MoveFolder(InventoryFolderBase folder)
338 { 315 {
339 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID) || 316 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID))
340 !IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) 317 {
318 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ID, folder.Owner);
319 return false;
320 }
321
322 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
323 {
324 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner);
341 return false; 325 return false;
326 }
342 327
343 return base.MoveFolder(folder); 328 return base.MoveFolder(folder);
344 } 329 }
@@ -360,7 +345,10 @@ namespace OpenSim.Services.HypergridService
360 // Let's do a bit of sanity checking, more than the base service does 345 // Let's do a bit of sanity checking, more than the base service does
361 // make sure the given folder's parent folder exists under the suitcase tree of this user 346 // make sure the given folder's parent folder exists under the suitcase tree of this user
362 if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) 347 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
348 {
349 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddItem: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
363 return false; 350 return false;
351 }
364 352
365 // OK, it's legit 353 // OK, it's legit
366 return base.AddItem(item); 354 return base.AddItem(item);
@@ -370,7 +358,10 @@ namespace OpenSim.Services.HypergridService
370 public override bool UpdateItem(InventoryItemBase item) 358 public override bool UpdateItem(InventoryItemBase item)
371 { 359 {
372 if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) 360 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
361 {
362 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateItem: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
373 return false; 363 return false;
364 }
374 365
375 return base.UpdateItem(item); 366 return base.UpdateItem(item);
376 } 367 }
@@ -379,11 +370,28 @@ namespace OpenSim.Services.HypergridService
379 { 370 {
380 // Principal is b0rked. *sigh* 371 // Principal is b0rked. *sigh*
381 372
382 if (!IsWithinSuitcaseTree(items[0].Owner, items[0].Folder)) 373 // Check the items' destination folders
383 return false; 374 foreach (InventoryItemBase item in items)
375 {
376 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
377 {
378 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
379 return false;
380 }
381 }
384 382
385 return base.MoveItems(principalID, items); 383 // Check the items' current folders
384 foreach (InventoryItemBase item in items)
385 {
386 InventoryItemBase originalItem = base.GetItem(item);
387 if (!IsWithinSuitcaseTree(originalItem.Owner, originalItem.Folder))
388 {
389 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
390 return false;
391 }
392 }
386 393
394 return base.MoveItems(principalID, items);
387 } 395 }
388 396
389 public override bool DeleteItems(UUID principalID, List<UUID> itemIDs) 397 public override bool DeleteItems(UUID principalID, List<UUID> itemIDs)
@@ -403,8 +411,8 @@ namespace OpenSim.Services.HypergridService
403 411
404 if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID)) 412 if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID))
405 { 413 {
406 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", 414 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetItem: item {0}/{1} (folder {2}) (user {3}) is not within Suitcase tree or Appearance",
407 it.Name, it.Folder); 415 it.Name, it.ID, it.Folder, it.Owner);
408 return null; 416 return null;
409 } 417 }
410 418
@@ -425,7 +433,11 @@ namespace OpenSim.Services.HypergridService
425 if (f != null) 433 if (f != null)
426 { 434 {
427 if (!IsWithinSuitcaseTree(f.Owner, f.ID)) 435 if (!IsWithinSuitcaseTree(f.Owner, f.ID))
436 {
437 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolder: folder {0}/{1} (user {2}) is not within Suitcase tree",
438 f.Name, f.ID, f.Owner);
428 return null; 439 return null;
440 }
429 } 441 }
430 442
431 return f; 443 return f;
@@ -456,7 +468,7 @@ namespace OpenSim.Services.HypergridService
456 { 468 {
457 XInventoryFolder[] folders = m_Database.GetFolders( 469 XInventoryFolder[] folders = m_Database.GetFolders(
458 new string[] { "agentID", "folderName", "type" }, 470 new string[] { "agentID", "folderName", "type" },
459 new string[] { principalID.ToString(), "My Inventory", ((int)AssetType.RootFolder).ToString() }); 471 new string[] { principalID.ToString(), InventoryFolderBase.ROOT_FOLDER_NAME, ((int)FolderType.Root).ToString() });
460 472
461 if (folders != null && folders.Length > 0) 473 if (folders != null && folders.Length > 0)
462 return folders[0]; 474 return folders[0];
@@ -464,7 +476,7 @@ namespace OpenSim.Services.HypergridService
464 // OK, so the RootFolder type didn't work. Let's look for any type with parent UUID.Zero. 476 // OK, so the RootFolder type didn't work. Let's look for any type with parent UUID.Zero.
465 folders = m_Database.GetFolders( 477 folders = m_Database.GetFolders(
466 new string[] { "agentID", "folderName", "parentFolderID" }, 478 new string[] { "agentID", "folderName", "parentFolderID" },
467 new string[] { principalID.ToString(), "My Inventory", UUID.Zero.ToString() }); 479 new string[] { principalID.ToString(), InventoryFolderBase.ROOT_FOLDER_NAME, UUID.Zero.ToString() });
468 480
469 if (folders != null && folders.Length > 0) 481 if (folders != null && folders.Length > 0)
470 return folders[0]; 482 return folders[0];
@@ -472,12 +484,28 @@ namespace OpenSim.Services.HypergridService
472 return null; 484 return null;
473 } 485 }
474 486
487 private XInventoryFolder GetCurrentOutfitXFolder(UUID userID)
488 {
489 XInventoryFolder root = GetRootXFolder(userID);
490 if (root == null)
491 return null;
492
493 XInventoryFolder[] folders = m_Database.GetFolders(
494 new string[] { "agentID", "type", "parentFolderID" },
495 new string[] { userID.ToString(), ((int)FolderType.CurrentOutfit).ToString(), root.folderID.ToString() });
496
497 if (folders.Length == 0)
498 return null;
499
500 return folders[0];
501 }
502
475 private XInventoryFolder GetSuitcaseXFolder(UUID principalID) 503 private XInventoryFolder GetSuitcaseXFolder(UUID principalID)
476 { 504 {
477 // Warp! Root folder for travelers 505 // Warp! Root folder for travelers
478 XInventoryFolder[] folders = m_Database.GetFolders( 506 XInventoryFolder[] folders = m_Database.GetFolders(
479 new string[] { "agentID", "type" }, 507 new string[] { "agentID", "type" },
480 new string[] { principalID.ToString(), "100" }); // This is a special folder type... 508 new string[] { principalID.ToString(), ((int)FolderType.Suitcase).ToString() });
481 509
482 if (folders != null && folders.Length > 0) 510 if (folders != null && folders.Length > 0)
483 return folders[0]; 511 return folders[0];
@@ -485,13 +513,13 @@ namespace OpenSim.Services.HypergridService
485 // check to see if we have the old Suitcase folder 513 // check to see if we have the old Suitcase folder
486 folders = m_Database.GetFolders( 514 folders = m_Database.GetFolders(
487 new string[] { "agentID", "folderName", "parentFolderID" }, 515 new string[] { "agentID", "folderName", "parentFolderID" },
488 new string[] { principalID.ToString(), "My Suitcase", UUID.Zero.ToString() }); 516 new string[] { principalID.ToString(), InventoryFolderBase.SUITCASE_FOLDER_NAME, UUID.Zero.ToString() });
489 if (folders != null && folders.Length > 0) 517 if (folders != null && folders.Length > 0)
490 { 518 {
491 // Move it to under the root folder 519 // Move it to under the root folder
492 XInventoryFolder root = GetRootXFolder(principalID); 520 XInventoryFolder root = GetRootXFolder(principalID);
493 folders[0].parentFolderID = root.folderID; 521 folders[0].parentFolderID = root.folderID;
494 folders[0].type = 100; 522 folders[0].type = (int)FolderType.Suitcase;
495 m_Database.StoreFolder(folders[0]); 523 m_Database.StoreFolder(folders[0]);
496 return folders[0]; 524 return folders[0];
497 } 525 }
@@ -501,17 +529,18 @@ namespace OpenSim.Services.HypergridService
501 529
502 private void SetAsNormalFolder(XInventoryFolder suitcase) 530 private void SetAsNormalFolder(XInventoryFolder suitcase)
503 { 531 {
504 suitcase.type = (short)AssetType.Folder; 532 //suitcase.type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE;
505 } 533 }
506 534
507 private List<XInventoryFolder> GetFolderTree(UUID principalID, UUID folder) 535 private List<XInventoryFolder> GetFolderTree(UUID principalID, UUID folder)
508 { 536 {
509 List<XInventoryFolder> t = null; 537 List<XInventoryFolder> t;
510 if (m_SuitcaseTrees.TryGetValue(principalID, out t)) 538 if (m_SuitcaseTrees.TryGetValue(principalID, out t))
511 return t; 539 return t;
512 540
541 // Get the tree of the suitcase folder
513 t = GetFolderTreeRecursive(folder); 542 t = GetFolderTreeRecursive(folder);
514 m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes 543 m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5 minutes
515 return t; 544 return t;
516 } 545 }
517 546
@@ -522,8 +551,10 @@ namespace OpenSim.Services.HypergridService
522 new string[] { "parentFolderID" }, 551 new string[] { "parentFolderID" },
523 new string[] { root.ToString() }); 552 new string[] { root.ToString() });
524 553
525 if (folders == null || (folders != null && folders.Length == 0)) 554 if (folders == null || folders.Length == 0)
555 {
526 return tree; // empty tree 556 return tree; // empty tree
557 }
527 else 558 else
528 { 559 {
529 foreach (XInventoryFolder f in folders) 560 foreach (XInventoryFolder f in folders)
@@ -546,6 +577,7 @@ namespace OpenSim.Services.HypergridService
546 private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID) 577 private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID)
547 { 578 {
548 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); 579 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
580
549 if (suitcase == null) 581 if (suitcase == null)
550 { 582 {
551 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID); 583 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID);
@@ -555,14 +587,18 @@ namespace OpenSim.Services.HypergridService
555 List<XInventoryFolder> tree = new List<XInventoryFolder>(); 587 List<XInventoryFolder> tree = new List<XInventoryFolder>();
556 tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder 588 tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder
557 tree.AddRange(GetFolderTree(principalID, suitcase.folderID)); 589 tree.AddRange(GetFolderTree(principalID, suitcase.folderID));
590
591 // Also add the Current Outfit folder to the list of available folders
592 XInventoryFolder folder = GetCurrentOutfitXFolder(principalID);
593 if (folder != null)
594 tree.Add(folder);
595
558 XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) 596 XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl)
559 { 597 {
560 if (fl.folderID == folderID) return true; 598 return (fl.folderID == folderID);
561 else return false;
562 }); 599 });
563 600
564 if (f == null) return false; 601 return (f != null);
565 else return true;
566 } 602 }
567 #endregion 603 #endregion
568 604