aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs28
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs50
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs38
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs42
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs106
8 files changed, 215 insertions, 71 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 32f4eea..4d70888 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -228,6 +228,16 @@ namespace OpenSim.Region.Framework.Interfaces
228 bool ContainsScripts(); 228 bool ContainsScripts();
229 229
230 /// <summary> 230 /// <summary>
231 /// Returns the count of scripts contained
232 /// </summary></returns>
233 int ScriptCount();
234
235 /// <summary>
236 /// Returns the count of running scripts contained
237 /// </summary></returns>
238 int RunningScriptCount();
239
240 /// <summary>
231 /// Get the uuids of all items in this inventory 241 /// Get the uuids of all items in this inventory
232 /// </summary> 242 /// </summary>
233 /// <returns></returns> 243 /// <returns></returns>
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index ce66100..4f8be10 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -71,6 +71,12 @@ namespace OpenSim.Region.Framework.Interfaces
71 71
72 bool HasScript(UUID itemID, out bool running); 72 bool HasScript(UUID itemID, out bool running);
73 73
74 /// <summary>
75 /// Returns true if a script is running.
76 /// </summary>
77 /// <param name="itemID">The item ID of the script.</param>
78 bool GetScriptState(UUID itemID);
79
74 void SaveAllState(); 80 void SaveAllState();
75 81
76 /// <summary> 82 /// <summary>
@@ -87,4 +93,4 @@ namespace OpenSim.Region.Framework.Interfaces
87 /// </returns> 93 /// </returns>
88 Dictionary<uint, float> GetObjectScriptsExecutionTimes(); 94 Dictionary<uint, float> GetObjectScriptsExecutionTimes();
89 } 95 }
90} \ No newline at end of file 96}
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index b806d91..77e808e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -156,7 +156,9 @@ namespace OpenSim.Region.Framework.Scenes
156 // that the region position is cached or performance will degrade 156 // that the region position is cached or performance will degrade
157 Utils.LongToUInts(regionHandle, out x, out y); 157 Utils.LongToUInts(regionHandle, out x, out y);
158 GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); 158 GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
159// bool v = true; 159 if (dest == null)
160 continue;
161
160 if (!simulatorList.Contains(dest.ServerURI)) 162 if (!simulatorList.Contains(dest.ServerURI))
161 { 163 {
162 // we havent seen this simulator before, add it to the list 164 // we havent seen this simulator before, add it to the list
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 107d9b6..5786f48 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -4017,7 +4017,33 @@ namespace OpenSim.Region.Framework.Scenes
4017 for (int i = 0; i < parts.Length; i++) 4017 for (int i = 0; i < parts.Length; i++)
4018 parts[i].TriggerScriptChangedEvent(val); 4018 parts[i].TriggerScriptChangedEvent(val);
4019 } 4019 }
4020 4020
4021 /// <summary>
4022 /// Returns a count of the number of scripts in this groups parts.
4023 /// </summary>
4024 public int ScriptCount()
4025 {
4026 int count = 0;
4027 SceneObjectPart[] parts = m_parts.GetArray();
4028 for (int i = 0; i < parts.Length; i++)
4029 count += parts[i].Inventory.ScriptCount();
4030
4031 return count;
4032 }
4033
4034 /// <summary>
4035 /// Returns a count of the number of running scripts in this groups parts.
4036 /// </summary>
4037 public int RunningScriptCount()
4038 {
4039 int count = 0;
4040 SceneObjectPart[] parts = m_parts.GetArray();
4041 for (int i = 0; i < parts.Length; i++)
4042 count += parts[i].Inventory.RunningScriptCount();
4043
4044 return count;
4045 }
4046
4021 public override string ToString() 4047 public override string ToString()
4022 { 4048 {
4023 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); 4049 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index a2649ee..7e629c0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1280,9 +1280,59 @@ namespace OpenSim.Region.Framework.Scenes
1280 return true; 1280 return true;
1281 } 1281 }
1282 } 1282 }
1283
1283 return false; 1284 return false;
1284 } 1285 }
1285 1286
1287 /// <summary>
1288 /// Returns the count of scripts in this parts inventory.
1289 /// </summary>
1290 /// <returns></returns>
1291 public int ScriptCount()
1292 {
1293 int count = 0;
1294 lock (m_items)
1295 {
1296 foreach (TaskInventoryItem item in m_items.Values)
1297 {
1298 if (item.InvType == (int)InventoryType.LSL)
1299 {
1300 count++;
1301 }
1302 }
1303 }
1304
1305 return count;
1306 }
1307 /// <summary>
1308 /// Returns the count of running scripts in this parts inventory.
1309 /// </summary>
1310 /// <returns></returns>
1311 public int RunningScriptCount()
1312 {
1313 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1314 if (engines.Length == 0)
1315 return 0;
1316
1317 int count = 0;
1318 List<TaskInventoryItem> scripts = GetInventoryScripts();
1319
1320 foreach (TaskInventoryItem item in scripts)
1321 {
1322 foreach (IScriptModule engine in engines)
1323 {
1324 if (engine != null)
1325 {
1326 if (engine.GetScriptState(item.ItemID))
1327 {
1328 count++;
1329 }
1330 }
1331 }
1332 }
1333 return count;
1334 }
1335
1286 public List<UUID> GetInventoryList() 1336 public List<UUID> GetInventoryList()
1287 { 1337 {
1288 List<UUID> ret = new List<UUID>(); 1338 List<UUID> ret = new List<UUID>();
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index b51d41b..0cb1556 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3521,6 +3521,44 @@ namespace OpenSim.Region.Framework.Scenes
3521 return m_attachments.Count > 0; 3521 return m_attachments.Count > 0;
3522 } 3522 }
3523 3523
3524 /// <summary>
3525 /// Returns the total count of scripts in all parts inventories.
3526 /// </summary>
3527 public int ScriptCount()
3528 {
3529 int count = 0;
3530 lock (m_attachments)
3531 {
3532 foreach (SceneObjectGroup gobj in m_attachments)
3533 {
3534 if (gobj != null)
3535 {
3536 count += gobj.ScriptCount();
3537 }
3538 }
3539 }
3540 return count;
3541 }
3542
3543 /// <summary>
3544 /// Returns the total count of running scripts in all parts.
3545 /// </summary>
3546 public int RunningScriptCount()
3547 {
3548 int count = 0;
3549 lock (m_attachments)
3550 {
3551 foreach (SceneObjectGroup gobj in m_attachments)
3552 {
3553 if (gobj != null)
3554 {
3555 count += gobj.RunningScriptCount();
3556 }
3557 }
3558 }
3559 return count;
3560 }
3561
3524 public bool HasScriptedAttachments() 3562 public bool HasScriptedAttachments()
3525 { 3563 {
3526 lock (m_attachments) 3564 lock (m_attachments)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index e71f027..76106a0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -11167,19 +11167,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11167 break; 11167 break;
11168 // For the following 8 see the Object version below 11168 // For the following 8 see the Object version below
11169 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: 11169 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT:
11170 ret.Add(new LSL_Integer(0)); 11170 ret.Add(new LSL_Integer(av.RunningScriptCount()));
11171 break; 11171 break;
11172 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: 11172 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT:
11173 ret.Add(new LSL_Integer(0)); 11173 ret.Add(new LSL_Integer(av.ScriptCount()));
11174 break; 11174 break;
11175 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: 11175 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY:
11176 ret.Add(new LSL_Integer(0)); 11176 ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384));
11177 break; 11177 break;
11178 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 11178 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
11179 ret.Add(new LSL_Float(0)); 11179 ret.Add(new LSL_Float(0));
11180 break; 11180 break;
11181 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 11181 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
11182 ret.Add(new LSL_Integer(0)); 11182 ret.Add(new LSL_Integer(1));
11183 break; 11183 break;
11184 case ScriptBaseClass.OBJECT_SERVER_COST: 11184 case ScriptBaseClass.OBJECT_SERVER_COST:
11185 ret.Add(new LSL_Float(0)); 11185 ret.Add(new LSL_Float(0));
@@ -11231,24 +11231,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11231 case ScriptBaseClass.OBJECT_CREATOR: 11231 case ScriptBaseClass.OBJECT_CREATOR:
11232 ret.Add(new LSL_String(obj.CreatorID.ToString())); 11232 ret.Add(new LSL_String(obj.CreatorID.ToString()));
11233 break; 11233 break;
11234 // The following 8 I have intentionaly coded to return zero. They are part of
11235 // "Land Impact" calculations. These calculations are probably not applicable
11236 // to OpenSim, required figures (cpu/memory usage) are not currently tracked
11237 // I have intentionally left these all at zero rather than return possibly
11238 // missleading numbers
11239 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: 11234 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT:
11240 // in SL this currently includes crashed scripts 11235 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount()));
11241 ret.Add(new LSL_Integer(0));
11242 break; 11236 break;
11243 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: 11237 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT:
11244 ret.Add(new LSL_Integer(0)); 11238 ret.Add(new LSL_Integer(obj.ParentGroup.ScriptCount()));
11245 break; 11239 break;
11246 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: 11240 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY:
11247 // The value returned in SL for mono scripts is 65536 * number of active scripts 11241 // The value returned in SL for mono scripts is 65536 * number of active scripts
11248 ret.Add(new LSL_Integer(0)); 11242 // and 16384 * number of active scripts for LSO. since llGetFreememory
11243 // is coded to give the LSO value use it here
11244 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384));
11249 break; 11245 break;
11250 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 11246 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
11251 // Average cpu time per simulator frame expended on all scripts in the objetc 11247 // Average cpu time per simulator frame expended on all scripts in the object
11248 // Not currently available at Object level
11252 ret.Add(new LSL_Float(0)); 11249 ret.Add(new LSL_Float(0));
11253 break; 11250 break;
11254 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 11251 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
@@ -11256,18 +11253,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11256 // equivalent of the number of prims in a linkset if it does not 11253 // equivalent of the number of prims in a linkset if it does not
11257 // contain a mesh anywhere in the link set or is not a normal prim 11254 // contain a mesh anywhere in the link set or is not a normal prim
11258 // The value returned in SL for normal prims is prim count 11255 // The value returned in SL for normal prims is prim count
11259 ret.Add(new LSL_Integer(0)); 11256 ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount));
11260 break; 11257 break;
11258 // The following 3 costs I have intentionaly coded to return zero. They are part of
11259 // "Land Impact" calculations. These calculations are probably not applicable
11260 // to OpenSim and are not yet complete in SL
11261 case ScriptBaseClass.OBJECT_SERVER_COST: 11261 case ScriptBaseClass.OBJECT_SERVER_COST:
11262 // The value returned in SL for normal prims is prim count 11262 // The linden calculation is here
11263 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight
11264 // The value returned in SL for normal prims looks like the prim count
11263 ret.Add(new LSL_Float(0)); 11265 ret.Add(new LSL_Float(0));
11264 break; 11266 break;
11265 case ScriptBaseClass.OBJECT_STREAMING_COST: 11267 case ScriptBaseClass.OBJECT_STREAMING_COST:
11266 // The value returned in SL for normal prims is prim count * 0.06 11268 // The linden calculation is here
11269 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost
11270 // The value returned in SL for normal prims looks like the prim count * 0.06
11267 ret.Add(new LSL_Float(0)); 11271 ret.Add(new LSL_Float(0));
11268 break; 11272 break;
11269 case ScriptBaseClass.OBJECT_PHYSICS_COST: 11273 case ScriptBaseClass.OBJECT_PHYSICS_COST:
11270 // The value returned in SL for normal prims is prim count 11274 // The linden calculation is here
11275 // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics
11276 // The value returned in SL for normal prims looks like the prim count
11271 ret.Add(new LSL_Float(0)); 11277 ret.Add(new LSL_Float(0));
11272 break; 11278 break;
11273 default: 11279 default:
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
index b6ec558..53fbea6 100644
--- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -107,9 +107,8 @@ namespace OpenSim.Services.HypergridService
107 public override List<InventoryFolderBase> GetInventorySkeleton(UUID principalID) 107 public override List<InventoryFolderBase> GetInventorySkeleton(UUID principalID)
108 { 108 {
109 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); 109 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
110 XInventoryFolder root = GetRootXFolder(principalID);
111 110
112 List<XInventoryFolder> tree = GetFolderTree(suitcase.folderID); 111 List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID);
113 if (tree == null || (tree != null && tree.Count == 0)) 112 if (tree == null || (tree != null && tree.Count == 0))
114 return null; 113 return null;
115 114
@@ -119,7 +118,7 @@ namespace OpenSim.Services.HypergridService
119 folders.Add(ConvertToOpenSim(x)); 118 folders.Add(ConvertToOpenSim(x));
120 } 119 }
121 120
122 SetAsRootFolder(suitcase, root); 121 SetAsNormalFolder(suitcase);
123 folders.Add(ConvertToOpenSim(suitcase)); 122 folders.Add(ConvertToOpenSim(suitcase));
124 123
125 return folders; 124 return folders;
@@ -134,12 +133,11 @@ namespace OpenSim.Services.HypergridService
134 userInventory.Items = new List<InventoryItemBase>(); 133 userInventory.Items = new List<InventoryItemBase>();
135 134
136 XInventoryFolder suitcase = GetSuitcaseXFolder(userID); 135 XInventoryFolder suitcase = GetSuitcaseXFolder(userID);
137 XInventoryFolder root = GetRootXFolder(userID);
138 136
139 List<XInventoryFolder> tree = GetFolderTree(suitcase.folderID); 137 List<XInventoryFolder> tree = GetFolderTree(userID, suitcase.folderID);
140 if (tree == null || (tree != null && tree.Count == 0)) 138 if (tree == null || (tree != null && tree.Count == 0))
141 { 139 {
142 SetAsRootFolder(suitcase, root); 140 SetAsNormalFolder(suitcase);
143 userInventory.Folders.Add(ConvertToOpenSim(suitcase)); 141 userInventory.Folders.Add(ConvertToOpenSim(suitcase));
144 return userInventory; 142 return userInventory;
145 } 143 }
@@ -164,7 +162,7 @@ namespace OpenSim.Services.HypergridService
164 userInventory.Items.AddRange(items); 162 userInventory.Items.AddRange(items);
165 } 163 }
166 164
167 SetAsRootFolder(suitcase, root); 165 SetAsNormalFolder(suitcase);
168 userInventory.Folders.Add(ConvertToOpenSim(suitcase)); 166 userInventory.Folders.Add(ConvertToOpenSim(suitcase));
169 167
170 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items", 168 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items",
@@ -175,14 +173,13 @@ namespace OpenSim.Services.HypergridService
175 public override InventoryFolderBase GetRootFolder(UUID principalID) 173 public override InventoryFolderBase GetRootFolder(UUID principalID)
176 { 174 {
177 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); 175 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
178 if (m_Database == null)
179 m_log.ErrorFormat("[XXX]: m_Database is NULL!");
180 176
181 // Let's find out the local root folder 177 // Let's find out the local root folder
182 XInventoryFolder root = GetRootXFolder(principalID); ; 178 XInventoryFolder root = GetRootXFolder(principalID); ;
183 if (root == null) 179 if (root == null)
184 { 180 {
185 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID); 181 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID);
182 return null;
186 } 183 }
187 184
188 // Warp! Root folder for travelers is the suitcase folder 185 // Warp! Root folder for travelers is the suitcase folder
@@ -202,7 +199,7 @@ namespace OpenSim.Services.HypergridService
202 CreateSystemFolders(principalID, suitcase.folderID); 199 CreateSystemFolders(principalID, suitcase.folderID);
203 } 200 }
204 201
205 SetAsRootFolder(suitcase, root); 202 SetAsNormalFolder(suitcase);
206 203
207 return ConvertToOpenSim(suitcase); 204 return ConvertToOpenSim(suitcase);
208 } 205 }
@@ -271,9 +268,8 @@ namespace OpenSim.Services.HypergridService
271 public override InventoryCollection GetFolderContent(UUID principalID, UUID folderID) 268 public override InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
272 { 269 {
273 InventoryCollection coll = null; 270 InventoryCollection coll = null;
274 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
275 271
276 if (!IsWithinSuitcaseTree(folderID, suitcase)) 272 if (!IsWithinSuitcaseTree(principalID, folderID))
277 return new InventoryCollection(); 273 return new InventoryCollection();
278 274
279 coll = base.GetFolderContent(principalID, folderID); 275 coll = base.GetFolderContent(principalID, folderID);
@@ -290,9 +286,7 @@ namespace OpenSim.Services.HypergridService
290 { 286 {
291 // Let's do a bit of sanity checking, more than the base service does 287 // Let's do a bit of sanity checking, more than the base service does
292 // make sure the given folder exists under the suitcase tree of this user 288 // make sure the given folder exists under the suitcase tree of this user
293 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); 289 if (!IsWithinSuitcaseTree(principalID, folderID))
294
295 if (!IsWithinSuitcaseTree(folderID, suitcase))
296 return new List<InventoryItemBase>(); 290 return new List<InventoryItemBase>();
297 291
298 return base.GetFolderItems(principalID, folderID); 292 return base.GetFolderItems(principalID, folderID);
@@ -303,21 +297,27 @@ namespace OpenSim.Services.HypergridService
303 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID); 297 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID);
304 // Let's do a bit of sanity checking, more than the base service does 298 // Let's do a bit of sanity checking, more than the base service does
305 // make sure the given folder's parent folder exists under the suitcase tree of this user 299 // make sure the given folder's parent folder exists under the suitcase tree of this user
306 XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner);
307 300
308 if (!IsWithinSuitcaseTree(folder.ParentID, suitcase)) 301 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
309 return false; 302 return false;
310 303
311 // OK, it's legit 304 // OK, it's legit
312 return base.AddFolder(folder); 305 if (base.AddFolder(folder))
306 {
307 List<XInventoryFolder> tree;
308 if (m_SuitcaseTrees.TryGetValue(folder.Owner, out tree))
309 tree.Add(ConvertFromOpenSim(folder));
310
311 return true;
312 }
313
314 return false;
313 } 315 }
314 316
315 public override bool UpdateFolder(InventoryFolderBase folder) 317 public override bool UpdateFolder(InventoryFolderBase folder)
316 { 318 {
317 XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner);
318
319 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); 319 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version);
320 if (!IsWithinSuitcaseTree(folder.ID, suitcase)) 320 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID))
321 { 321 {
322 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name); 322 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name);
323 return false; 323 return false;
@@ -329,9 +329,8 @@ namespace OpenSim.Services.HypergridService
329 329
330 public override bool MoveFolder(InventoryFolderBase folder) 330 public override bool MoveFolder(InventoryFolderBase folder)
331 { 331 {
332 XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner); 332 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID) ||
333 333 !IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
334 if (!IsWithinSuitcaseTree(folder.ID, suitcase) || !IsWithinSuitcaseTree(folder.ParentID, suitcase))
335 return false; 334 return false;
336 335
337 return base.MoveFolder(folder); 336 return base.MoveFolder(folder);
@@ -353,9 +352,7 @@ namespace OpenSim.Services.HypergridService
353 { 352 {
354 // Let's do a bit of sanity checking, more than the base service does 353 // Let's do a bit of sanity checking, more than the base service does
355 // make sure the given folder's parent folder exists under the suitcase tree of this user 354 // make sure the given folder's parent folder exists under the suitcase tree of this user
356 XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner); 355 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
357
358 if (!IsWithinSuitcaseTree(item.Folder, suitcase))
359 return false; 356 return false;
360 357
361 // OK, it's legit 358 // OK, it's legit
@@ -365,9 +362,7 @@ namespace OpenSim.Services.HypergridService
365 362
366 public override bool UpdateItem(InventoryItemBase item) 363 public override bool UpdateItem(InventoryItemBase item)
367 { 364 {
368 XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner); 365 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
369
370 if (!IsWithinSuitcaseTree(item.Folder, suitcase))
371 return false; 366 return false;
372 367
373 return base.UpdateItem(item); 368 return base.UpdateItem(item);
@@ -377,9 +372,7 @@ namespace OpenSim.Services.HypergridService
377 { 372 {
378 // Principal is b0rked. *sigh* 373 // Principal is b0rked. *sigh*
379 374
380 XInventoryFolder suitcase = GetSuitcaseXFolder(items[0].Owner); 375 if (!IsWithinSuitcaseTree(items[0].Owner, items[0].Folder))
381
382 if (!IsWithinSuitcaseTree(items[0].Folder, suitcase))
383 return false; 376 return false;
384 377
385 return base.MoveItems(principalID, items); 378 return base.MoveItems(principalID, items);
@@ -400,15 +393,8 @@ namespace OpenSim.Services.HypergridService
400 item.Name, item.ID, item.Folder); 393 item.Name, item.ID, item.Folder);
401 return null; 394 return null;
402 } 395 }
403 XInventoryFolder suitcase = GetSuitcaseXFolder(it.Owner);
404 if (suitcase == null)
405 {
406 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Root or Suitcase are null for user {0}",
407 it.Owner);
408 return null;
409 }
410 396
411 if (!IsWithinSuitcaseTree(it.Folder, suitcase)) 397 if (!IsWithinSuitcaseTree(it.Owner, it.Folder))
412 { 398 {
413 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", 399 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase",
414 it.Name, it.Folder); 400 it.Name, it.Folder);
@@ -431,9 +417,7 @@ namespace OpenSim.Services.HypergridService
431 417
432 if (f != null) 418 if (f != null)
433 { 419 {
434 XInventoryFolder suitcase = GetSuitcaseXFolder(f.Owner); 420 if (!IsWithinSuitcaseTree(f.Owner, f.ID))
435
436 if (!IsWithinSuitcaseTree(f.ID, suitcase))
437 return null; 421 return null;
438 } 422 }
439 423
@@ -481,22 +465,37 @@ namespace OpenSim.Services.HypergridService
481 465
482 if (folders != null && folders.Length > 0) 466 if (folders != null && folders.Length > 0)
483 return folders[0]; 467 return folders[0];
468
469 // check to see if we have the old Suitcase folder
470 folders = m_Database.GetFolders(
471 new string[] { "agentID", "folderName", "parentFolderID" },
472 new string[] { principalID.ToString(), "My Suitcase", UUID.Zero.ToString() });
473 if (folders != null && folders.Length > 0)
474 {
475 // Move it to under the root folder
476 XInventoryFolder root = GetRootXFolder(principalID);
477 folders[0].parentFolderID = root.folderID;
478 folders[0].type = 100;
479 m_Database.StoreFolder(folders[0]);
480 return folders[0];
481 }
482
484 return null; 483 return null;
485 } 484 }
486 485
487 private void SetAsRootFolder(XInventoryFolder suitcase, XInventoryFolder root) 486 private void SetAsNormalFolder(XInventoryFolder suitcase)
488 { 487 {
489 suitcase.type = (short)AssetType.Folder; 488 suitcase.type = (short)AssetType.Folder;
490 } 489 }
491 490
492 private List<XInventoryFolder> GetFolderTree(UUID folder) 491 private List<XInventoryFolder> GetFolderTree(UUID principalID, UUID folder)
493 { 492 {
494 List<XInventoryFolder> t = null; 493 List<XInventoryFolder> t = null;
495 if (m_SuitcaseTrees.TryGetValue(folder, out t)) 494 if (m_SuitcaseTrees.TryGetValue(principalID, out t))
496 return t; 495 return t;
497 496
498 t = GetFolderTreeRecursive(folder); 497 t = GetFolderTreeRecursive(folder);
499 m_SuitcaseTrees.AddOrUpdate(folder, t, 120); 498 m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes
500 return t; 499 return t;
501 } 500 }
502 501
@@ -528,11 +527,18 @@ namespace OpenSim.Services.HypergridService
528 /// <param name="root"></param> 527 /// <param name="root"></param>
529 /// <param name="suitcase"></param> 528 /// <param name="suitcase"></param>
530 /// <returns></returns> 529 /// <returns></returns>
531 private bool IsWithinSuitcaseTree(UUID folderID, XInventoryFolder suitcase) 530 private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID)
532 { 531 {
532 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
533 if (suitcase == null)
534 {
535 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID);
536 return false;
537 }
538
533 List<XInventoryFolder> tree = new List<XInventoryFolder>(); 539 List<XInventoryFolder> tree = new List<XInventoryFolder>();
534 tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder 540 tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder
535 tree.AddRange(GetFolderTree(suitcase.folderID)); 541 tree.AddRange(GetFolderTree(principalID, suitcase.folderID));
536 XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) 542 XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl)
537 { 543 {
538 if (fl.folderID == folderID) return true; 544 if (fl.folderID == folderID) return true;