aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications')
-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
4 files changed, 106 insertions, 43 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);