aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs109
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs16
-rw-r--r--OpenSim/Framework/Communications/IInventoryServices.cs19
-rw-r--r--OpenSim/Framework/Communications/InventoryServiceBase.cs5
-rw-r--r--OpenSim/Framework/InventoryCollection.cs3
-rw-r--r--OpenSim/Grid/InventoryServer/GridInventoryService.cs3
-rw-r--r--OpenSim/Region/Communications/Local/LocalInventoryService.cs45
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs40
8 files changed, 151 insertions, 89 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index 1208605..cf701cb 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -118,64 +118,82 @@ namespace OpenSim.Framework.Communications.Cache
118 } 118 }
119 } 119 }
120 } 120 }
121 121
122 /// <summary> 122 /// <summary>
123 /// Callback invoked when a folder is received from an async request to the inventory service. 123 /// Callback invoked when the inventory is received from an async request to the inventory service
124 /// </summary> 124 /// </summary>
125 /// <param name="userID"></param> 125 /// <param name="userID"></param>
126 /// <param name="folderInfo"></param> 126 /// <param name="inventoryCollection"></param>
127 public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) 127 public void InventoryReceive(LLUUID userID, ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items)
128 { 128 {
129 // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these 129 // FIXME: Exceptions thrown upwards never appear on the console. Could fix further up if these
130 // are simply being swallowed 130 // are simply being swallowed
131 try 131 try
132 {
133 foreach (InventoryFolderImpl folder in folders)
134 {
135 FolderReceive(userID, folder);
136 }
137
138 foreach (InventoryItemBase item in items)
139 {
140 ItemReceive(userID, item);
141 }
142 }
143 catch (Exception e)
132 { 144 {
145 m_log.ErrorFormat("[INVENTORY CACHE]: {0}", e);
146 }
147 }
148
149 /// <summary>
150 /// Callback invoked when a folder is received from an async request to the inventory service.
151 /// </summary>
152 /// <param name="userID"></param>
153 /// <param name="folderInfo"></param>
154 private void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo)
155 {
133// m_log.DebugFormat( 156// m_log.DebugFormat(
134// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}", 157// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}",
135// folderInfo.name, folderInfo.folderID, userID); 158// folderInfo.name, folderInfo.folderID, userID);
136 159
137 if (userID == UserProfile.ID) 160 if (userID == UserProfile.ID)
161 {
162 if (RootFolder == null)
138 { 163 {
139 if (RootFolder == null) 164 if (folderInfo.ParentID == LLUUID.Zero)
140 { 165 {
141 if (folderInfo.ParentID == LLUUID.Zero) 166 m_rootFolder = folderInfo;
142 {
143 m_rootFolder = folderInfo;
144 }
145 } 167 }
146 else if (RootFolder.ID == folderInfo.ParentID) 168 }
169 else if (RootFolder.ID == folderInfo.ParentID)
170 {
171 if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID))
147 { 172 {
148 if (!RootFolder.SubFolders.ContainsKey(folderInfo.ID)) 173 RootFolder.SubFolders.Add(folderInfo.ID, folderInfo);
149 {
150 RootFolder.SubFolders.Add(folderInfo.ID, folderInfo);
151 }
152 else
153 {
154 AddPendingFolder(folderInfo);
155 }
156 } 174 }
157 else 175 else
158 { 176 {
159 InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID); 177 AddPendingFolder(folderInfo);
160 if (folder != null) 178 }
161 { 179 }
162 if (!folder.SubFolders.ContainsKey(folderInfo.ID)) 180 else
163 { 181 {
164 folder.SubFolders.Add(folderInfo.ID, folderInfo); 182 InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.ParentID);
165 } 183 if (folder != null)
166 } 184 {
167 else 185 if (!folder.SubFolders.ContainsKey(folderInfo.ID))
168 { 186 {
169 AddPendingFolder(folderInfo); 187 folder.SubFolders.Add(folderInfo.ID, folderInfo);
170 } 188 }
171 } 189 }
172 190 else
173 ResolvePendingFolders(folderInfo); 191 {
192 AddPendingFolder(folderInfo);
193 }
174 } 194 }
175 } 195
176 catch (Exception e) 196 ResolvePendingFolders(folderInfo);
177 {
178 m_log.ErrorFormat("[INVENTORY CACHE] {0}", e);
179 } 197 }
180 } 198 }
181 199
@@ -187,7 +205,7 @@ namespace OpenSim.Framework.Communications.Cache
187 /// </summary> 205 /// </summary>
188 /// <param name="userID"></param> 206 /// <param name="userID"></param>
189 /// <param name="folderInfo"></param> 207 /// <param name="folderInfo"></param>
190 public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) 208 private void ItemReceive(LLUUID userID, InventoryItemBase itemInfo)
191 { 209 {
192 if ((userID == UserProfile.ID) && (RootFolder != null)) 210 if ((userID == UserProfile.ID) && (RootFolder != null))
193 { 211 {
@@ -212,6 +230,11 @@ namespace OpenSim.Framework.Communications.Cache
212 } 230 }
213 } 231 }
214 232
233 /// <summary>
234 /// Add an item to the user's inventory
235 /// </summary>
236 /// <param name="userID"></param>
237 /// <param name="itemInfo"></param>
215 public void AddItem(LLUUID userID, InventoryItemBase itemInfo) 238 public void AddItem(LLUUID userID, InventoryItemBase itemInfo)
216 { 239 {
217 if ((userID == UserProfile.ID) && HasInventory) 240 if ((userID == UserProfile.ID) && HasInventory)
@@ -221,6 +244,11 @@ namespace OpenSim.Framework.Communications.Cache
221 } 244 }
222 } 245 }
223 246
247 /// <summary>
248 /// Update an item in the user's inventory
249 /// </summary>
250 /// <param name="userID"></param>
251 /// <param name="itemInfo"></param>
224 public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) 252 public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo)
225 { 253 {
226 if ((userID == UserProfile.ID) && HasInventory) 254 if ((userID == UserProfile.ID) && HasInventory)
@@ -229,6 +257,12 @@ namespace OpenSim.Framework.Communications.Cache
229 } 257 }
230 } 258 }
231 259
260 /// <summary>
261 /// Delete an item from the user's inventory
262 /// </summary>
263 /// <param name="userID"></param>
264 /// <param name="item"></param>
265 /// <returns></returns>
232 public bool DeleteItem(LLUUID userID, InventoryItemBase item) 266 public bool DeleteItem(LLUUID userID, InventoryItemBase item)
233 { 267 {
234 bool result = false; 268 bool result = false;
@@ -240,6 +274,7 @@ namespace OpenSim.Framework.Communications.Cache
240 m_commsManager.InventoryService.DeleteInventoryItem(userID, item); 274 m_commsManager.InventoryService.DeleteInventoryItem(userID, item);
241 } 275 }
242 } 276 }
277
243 return result; 278 return result;
244 } 279 }
245 } 280 }
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index b924d5c..6b09e01 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -97,7 +97,7 @@ namespace OpenSim.Framework.Communications.Cache
97 CachedUserInfo userInfo = GetUserDetails(userID); 97 CachedUserInfo userInfo = GetUserDetails(userID);
98 if (userInfo != null) 98 if (userInfo != null)
99 { 99 {
100 m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); 100 m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive);
101 } 101 }
102 else 102 else
103 { 103 {
@@ -118,6 +118,14 @@ namespace OpenSim.Framework.Communications.Cache
118 return null; 118 return null;
119 } 119 }
120 120
121 /// <summary>
122 /// Handle an inventory folder creation request from the client.
123 /// </summary>
124 /// <param name="remoteClient"></param>
125 /// <param name="folderID"></param>
126 /// <param name="folderType"></param>
127 /// <param name="folderName"></param>
128 /// <param name="parentID"></param>
121 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, 129 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType,
122 string folderName, LLUUID parentID) 130 string folderName, LLUUID parentID)
123 { 131 {
@@ -189,6 +197,12 @@ namespace OpenSim.Framework.Communications.Cache
189 } 197 }
190 } 198 }
191 199
200 /// <summary>
201 /// Handle an inventory folder move request from the client.
202 /// </summary>
203 /// <param name="remoteClient"></param>
204 /// <param name="folderID"></param>
205 /// <param name="parentID"></param>
192 public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID) 206 public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID)
193 { 207 {
194 CachedUserInfo userProfile; 208 CachedUserInfo userProfile;
diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs
index ecc6c71..40e7ffd 100644
--- a/OpenSim/Framework/Communications/IInventoryServices.cs
+++ b/OpenSim/Framework/Communications/IInventoryServices.cs
@@ -26,21 +26,34 @@
26 */ 26 */
27 27
28using System.Collections.Generic; 28using System.Collections.Generic;
29
29using libsecondlife; 30using libsecondlife;
31
30using OpenSim.Framework.Communications.Cache; 32using OpenSim.Framework.Communications.Cache;
31 33
32namespace OpenSim.Framework.Communications 34namespace OpenSim.Framework.Communications
33{ 35{
34 public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo); 36 /// <summary>
37 /// Callback used when a user's inventory is received from the inventory service
38 /// </summary>
39 public delegate void InventoryReceiptCallback(LLUUID userId, ICollection<InventoryFolderImpl> folders, ICollection<InventoryItemBase> items);
40
41 //public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo);
35 42
36 public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); 43 //public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo);
37 44
38 /// <summary> 45 /// <summary>
39 /// Defines all the operations one can perform on a user's inventory. 46 /// Defines all the operations one can perform on a user's inventory.
40 /// </summary> 47 /// </summary>
41 public interface IInventoryServices 48 public interface IInventoryServices
42 { 49 {
43 void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); 50 /// <summary>
51 /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the
52 /// inventory has been received
53 /// </summary>
54 /// <param name="userID"></param>
55 /// <param name="callback"></param>
56 void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback);
44 57
45 /// <summary> 58 /// <summary>
46 /// Add a new folder to the given user's inventory 59 /// Add a new folder to the given user's inventory
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs
index e50e19e..aedf4b3 100644
--- a/OpenSim/Framework/Communications/InventoryServiceBase.cs
+++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs
@@ -158,8 +158,9 @@ namespace OpenSim.Framework.Communications
158 return false; 158 return false;
159 } 159 }
160 160
161 public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, 161 // See IInventoryServices
162 InventoryItemInfo itemCallBack); 162 public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback);
163
163 public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); 164 public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
164 public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder); 165 public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder);
165 public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); 166 public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
diff --git a/OpenSim/Framework/InventoryCollection.cs b/OpenSim/Framework/InventoryCollection.cs
index c8d8716..e76e1a9 100644
--- a/OpenSim/Framework/InventoryCollection.cs
+++ b/OpenSim/Framework/InventoryCollection.cs
@@ -32,6 +32,9 @@ using libsecondlife;
32 32
33namespace OpenSim.Framework 33namespace OpenSim.Framework
34{ 34{
35 /// <summary>
36 /// Used to serialize a whole inventory for transfer over the network.
37 /// </summary>
35 public class InventoryCollection 38 public class InventoryCollection
36 { 39 {
37 public List<InventoryFolderBase> _folders; 40 public List<InventoryFolderBase> _folders;
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
index 1ae5243..72d43d4 100644
--- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs
+++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
@@ -41,8 +41,7 @@ namespace OpenSim.Grid.InventoryServer
41 { 41 {
42 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, 44 public override void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback)
45 InventoryItemInfo itemCallBack)
46 { 45 {
47 } 46 }
48 47
diff --git a/OpenSim/Region/Communications/Local/LocalInventoryService.cs b/OpenSim/Region/Communications/Local/LocalInventoryService.cs
index bb3db9d..13cb6de 100644
--- a/OpenSim/Region/Communications/Local/LocalInventoryService.cs
+++ b/OpenSim/Region/Communications/Local/LocalInventoryService.cs
@@ -39,32 +39,38 @@ namespace OpenSim.Region.Communications.Local
39 /// </summary> 39 /// </summary>
40 public class LocalInventoryService : InventoryServiceBase 40 public class LocalInventoryService : InventoryServiceBase
41 { 41 {
42 public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, 42 public override void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback)
43 InventoryItemInfo itemCallBack)
44 { 43 {
45 List<InventoryFolderBase> folders = GetInventorySkeleton(userID); 44 List<InventoryFolderBase> skeletonFolders = GetInventorySkeleton(userID);
46
47 InventoryFolderImpl rootFolder = null; 45 InventoryFolderImpl rootFolder = null;
46
47 ICollection<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
48 ICollection<InventoryItemBase> items = new List<InventoryItemBase>();
48 49
49 //need to make sure we send root folder first 50 // Need to retrieve the root folder on the first pass
50 foreach (InventoryFolderBase folder in folders) 51 foreach (InventoryFolderBase folder in skeletonFolders)
51 { 52 {
52 if (folder.ParentID == LLUUID.Zero) 53 if (folder.ParentID == LLUUID.Zero)
53 { 54 {
54 rootFolder = RequestInventoryFolder(userID, folder, folderCallBack, itemCallBack); 55 //rootFolder = RequestInventoryFolder(userID, folder, callback);
56 rootFolder = new InventoryFolderImpl(folder);
57 folders.Add(rootFolder);
55 } 58 }
56 } 59 }
57 60
58 if (rootFolder != null) 61 if (rootFolder != null)
59 { 62 {
60 foreach (InventoryFolderBase folder in folders) 63 foreach (InventoryFolderBase folder in skeletonFolders)
61 { 64 {
62 if (folder.ID != rootFolder.ID) 65 if (folder.ID != rootFolder.ID)
63 { 66 {
64 RequestInventoryFolder(userID, folder, folderCallBack, itemCallBack); 67 //RequestInventoryFolder(userID, folder, callback);
68 folders.Add(new InventoryFolderImpl(folder));
65 } 69 }
66 } 70 }
67 } 71 }
72
73 callback(userID, folders, items);
68 } 74 }
69 75
70 public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder) 76 public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder)
@@ -99,26 +105,5 @@ namespace OpenSim.Region.Communications.Local
99 return true; 105 return true;
100 } 106 }
101 } 107 }
102
103 /// <summary>
104 /// Send the given inventory folder and its item contents back to the requester.
105 /// </summary>
106 /// <param name="userID"></param>
107 /// <param name="folder"></param>
108 private InventoryFolderImpl RequestInventoryFolder(LLUUID userID, InventoryFolderBase folder,
109 InventoryFolderInfo folderCallBack,
110 InventoryItemInfo itemCallBack)
111 {
112 InventoryFolderImpl newFolder = new InventoryFolderImpl(folder);
113 folderCallBack(userID, newFolder);
114
115 List<InventoryItemBase> items = RequestFolderItems(newFolder.ID);
116 foreach (InventoryItemBase item in items)
117 {
118 itemCallBack(userID, item);
119 }
120
121 return newFolder;
122 }
123 } 108 }
124} 109}
diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
index b18c5bf..f31127f 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
@@ -51,12 +51,11 @@ namespace OpenSim.Region.Communications.OGS1
51 #region IInventoryServices Members 51 #region IInventoryServices Members
52 52
53 // See IInventoryServices 53 // See IInventoryServices
54 public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, 54 public void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback)
55 InventoryItemInfo itemCallBack)
56 { 55 {
57 if (!m_RequestingInventory.ContainsKey(userID)) 56 if (!m_RequestingInventory.ContainsKey(userID))
58 { 57 {
59 InventoryRequest request = new InventoryRequest(userID, folderCallBack, itemCallBack); 58 InventoryRequest request = new InventoryRequest(userID, callback);
60 m_RequestingInventory.Add(userID, request); 59 m_RequestingInventory.Add(userID, request);
61 RequestInventory(userID); 60 RequestInventory(userID);
62 } 61 }
@@ -105,13 +104,17 @@ namespace OpenSim.Region.Communications.OGS1
105 104
106 InventoryFolderImpl rootFolder = null; 105 InventoryFolderImpl rootFolder = null;
107 InventoryRequest request = m_RequestingInventory[userID]; 106 InventoryRequest request = m_RequestingInventory[userID];
107
108 ICollection<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
109 ICollection<InventoryItemBase> items = new List<InventoryItemBase>();
110
108 foreach (InventoryFolderBase folder in response.Folders) 111 foreach (InventoryFolderBase folder in response.Folders)
109 { 112 {
110 if (folder.ParentID == LLUUID.Zero) 113 if (folder.ParentID == LLUUID.Zero)
111 { 114 {
112 InventoryFolderImpl newfolder = new InventoryFolderImpl(folder); 115 rootFolder = new InventoryFolderImpl(folder);
113 rootFolder = newfolder; 116 folders.Add(rootFolder);
114 request.FolderCallBack(userID, newfolder); 117 //request.FolderCallBack(userID, newfolder);
115 } 118 }
116 } 119 }
117 120
@@ -121,16 +124,20 @@ namespace OpenSim.Region.Communications.OGS1
121 { 124 {
122 if (folder.ID != rootFolder.ID) 125 if (folder.ID != rootFolder.ID)
123 { 126 {
124 InventoryFolderImpl newfolder = new InventoryFolderImpl(folder); 127 folders.Add(new InventoryFolderImpl(folder));
125 request.FolderCallBack(userID, newfolder); 128 //request.FolderCallBack(userID, newfolder);
126 } 129 }
127 } 130 }
128 131
129 foreach (InventoryItemBase item in response.AllItems) 132 foreach (InventoryItemBase item in response.AllItems)
130 { 133 {
131 request.ItemCallBack(userID, item); 134 items.Add(item);
135 //request.ItemCallBack(userID, item);
132 } 136 }
133 } 137 }
138
139 request.Callback(userID, folders, items);
140
134 m_RequestingInventory.Remove(userID); 141 m_RequestingInventory.Remove(userID);
135 } 142 }
136 else 143 else
@@ -223,17 +230,22 @@ namespace OpenSim.Region.Communications.OGS1
223 230
224 #endregion 231 #endregion
225 232
233 /// <summary>
234 /// Caches a pending inventory request that has yet to be satisfied by the inventory service
235 /// </summary>
226 public class InventoryRequest 236 public class InventoryRequest
227 { 237 {
228 public LLUUID UserID; 238 public LLUUID UserID;
229 public InventoryFolderInfo FolderCallBack; 239 public InventoryReceiptCallback Callback;
230 public InventoryItemInfo ItemCallBack; 240 //public InventoryFolderInfo FolderCallBack;
241 //public InventoryItemInfo ItemCallBack;
231 242
232 public InventoryRequest(LLUUID userId, InventoryFolderInfo folderCall, InventoryItemInfo itemCall) 243 public InventoryRequest(LLUUID userId, InventoryReceiptCallback callback)
233 { 244 {
234 UserID = userId; 245 UserID = userId;
235 FolderCallBack = folderCall; 246 //FolderCallBack = folderCall;
236 ItemCallBack = itemCall; 247 //ItemCallBack = itemCall;
248 Callback = callback;
237 } 249 }
238 } 250 }
239 } 251 }