aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer.Modules
diff options
context:
space:
mode:
authorMW2009-05-30 16:13:40 +0000
committerMW2009-05-30 16:13:40 +0000
commite3e7e73db3fe99761ba090910634c86caacd7a3c (patch)
tree27eae2627d04557b78d726d8f7644668d7d2431a /OpenSim/Grid/UserServer.Modules
parentMade it so ( by default) the Clone avatar function, propagates the permission... (diff)
downloadopensim-SC-e3e7e73db3fe99761ba090910634c86caacd7a3c.zip
opensim-SC-e3e7e73db3fe99761ba090910634c86caacd7a3c.tar.gz
opensim-SC-e3e7e73db3fe99761ba090910634c86caacd7a3c.tar.bz2
opensim-SC-e3e7e73db3fe99761ba090910634c86caacd7a3c.tar.xz
Added option (on my default) to the clone avatar function so that the clothes and attachments that the target avatar is wearing, to begin with, are removed. So the end result isn't a merger of those clothes/attachments and the ones the template avatar is wearing.
Added IPAddress ListenIPAddress property to BaseHttpServer so that the listening/binding IP can be set.
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs263
1 files changed, 141 insertions, 122 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs b/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs
index 1bf6049..644dce7 100644
--- a/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs
+++ b/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs
@@ -110,7 +110,7 @@ namespace OpenSim.Grid.UserServer.Modules
110 } 110 }
111 Guid avatar = newAvatar.ID.Guid; 111 Guid avatar = newAvatar.ID.Guid;
112 Guid template = templateAvatar.ID.Guid; 112 Guid template = templateAvatar.ID.Guid;
113 CloneAvatar(avatar, template); 113 CloneAvatar(avatar, template, true, true);
114 114
115 } 115 }
116 catch (Exception e) 116 catch (Exception e)
@@ -121,7 +121,7 @@ namespace OpenSim.Grid.UserServer.Modules
121 } 121 }
122 #region Avatar Appearance Creation 122 #region Avatar Appearance Creation
123 123
124 public bool CloneAvatar(Guid avatarID, Guid templateID) 124 public bool CloneAvatar(Guid avatarID, Guid templateID, bool modifyPermissions, bool removeTargetsClothes)
125 { 125 {
126 m_log.InfoFormat("[AvatarAppearance] Starting to clone avatar {0} inventory to avatar {1}", templateID.ToString(), avatarID.ToString()); 126 m_log.InfoFormat("[AvatarAppearance] Starting to clone avatar {0} inventory to avatar {1}", templateID.ToString(), avatarID.ToString());
127 Guid bodyFolder = Guid.Empty; 127 Guid bodyFolder = Guid.Empty;
@@ -143,6 +143,13 @@ namespace OpenSim.Grid.UserServer.Modules
143 UUID tempOwnID = new UUID(templateID); 143 UUID tempOwnID = new UUID(templateID);
144 AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(tempOwnID); 144 AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(tempOwnID);
145 145
146 if (removeTargetsClothes)
147 {
148 //remove clothes and attachments from target avatar so that the end result isn't a merge of its existing clothes
149 // and the clothes from the template avatar.
150 RemoveClothesAndAttachments(avID);
151 }
152
146 List<InventoryFolderBase> templateInventory = m_inventoryService.GetInventorySkeleton(tempOwnID); 153 List<InventoryFolderBase> templateInventory = m_inventoryService.GetInventorySkeleton(tempOwnID);
147 if ((templateInventory != null) && (templateInventory.Count != 0)) 154 if ((templateInventory != null) && (templateInventory.Count != 0))
148 { 155 {
@@ -150,7 +157,7 @@ namespace OpenSim.Grid.UserServer.Modules
150 { 157 {
151 if (templateInventory[i].ParentID == UUID.Zero) 158 if (templateInventory[i].ParentID == UUID.Zero)
152 { 159 {
153 success = CloneFolder(avatarInventory, avID, UUID.Zero, appearance, templateInventory[i], templateInventory); 160 success = CloneFolder(avatarInventory, avID, UUID.Zero, appearance, templateInventory[i], templateInventory, modifyPermissions);
154 break; 161 break;
155 } 162 }
156 } 163 }
@@ -164,6 +171,121 @@ namespace OpenSim.Grid.UserServer.Modules
164 return success; 171 return success;
165 } 172 }
166 173
174 private bool CloneFolder(List<InventoryFolderBase> avatarInventory, UUID avID, UUID parentFolder, AvatarAppearance appearance, InventoryFolderBase templateFolder, List<InventoryFolderBase> templateFolders, bool modifyPermissions)
175 {
176 bool success = false;
177 UUID templateFolderId = templateFolder.ID;
178 if (templateFolderId != UUID.Zero)
179 {
180 InventoryFolderBase toFolder = FindFolder(templateFolder.Name, parentFolder.Guid, avatarInventory);
181 if (toFolder == null)
182 {
183 //create new folder
184 toFolder = new InventoryFolderBase();
185 toFolder.ID = UUID.Random();
186 toFolder.Name = templateFolder.Name;
187 toFolder.Owner = avID;
188 toFolder.Type = templateFolder.Type;
189 toFolder.Version = 1;
190 toFolder.ParentID = parentFolder;
191 if (!SynchronousRestObjectRequester.MakeRequest<InventoryFolderBase, bool>(
192 "POST", m_inventoryServerUrl + "CreateFolder/", toFolder))
193 {
194 m_log.InfoFormat("[AvatarApperance] Couldn't make new folder {0} in users inventory", toFolder.Name);
195 return false;
196 }
197 else
198 {
199 // m_log.InfoFormat("made new folder {0} in users inventory", toFolder.Name);
200 }
201 }
202
203 List<InventoryItemBase> templateItems = SynchronousRestObjectRequester.MakeRequest<Guid, List<InventoryItemBase>>(
204 "POST", m_inventoryServerUrl + "GetItems/", templateFolderId.Guid);
205 if ((templateItems != null) && (templateItems.Count > 0))
206 {
207 foreach (InventoryItemBase item in templateItems)
208 {
209
210 UUID clonedItemId = CloneInventoryItem(avID, toFolder.ID, item, modifyPermissions);
211 if (clonedItemId != UUID.Zero)
212 {
213 int appearanceType = ItemIsPartOfAppearance(item, appearance);
214 if (appearanceType >= 0)
215 {
216 UpdateAvatarAppearance(avID, appearanceType, clonedItemId, item.AssetID);
217 }
218
219 if (appearance != null)
220 {
221 int attachment = appearance.GetAttachpoint(item.ID);
222 if (attachment > 0)
223 {
224 UpdateAvatarAttachment(avID, attachment, clonedItemId, item.AssetID);
225 }
226 }
227 success = true;
228 }
229 }
230 }
231
232 List<InventoryFolderBase> subFolders = FindSubFolders(templateFolder.ID.Guid, templateFolders);
233 foreach (InventoryFolderBase subFolder in subFolders)
234 {
235 if (subFolder.Name.ToLower() != "trash")
236 {
237 success = CloneFolder(avatarInventory, avID, toFolder.ID, appearance, subFolder, templateFolders, modifyPermissions);
238 }
239 }
240 }
241 else
242 {
243 m_log.Info("[AvatarAppearance] Failed to find the template folder");
244 }
245 return success;
246 }
247
248 private UUID CloneInventoryItem(UUID avatarID, UUID avatarFolder, InventoryItemBase item, bool modifyPerms)
249 {
250 if (avatarFolder != UUID.Zero)
251 {
252 InventoryItemBase clonedItem = new InventoryItemBase();
253 clonedItem.Owner = avatarID;
254 clonedItem.AssetID = item.AssetID;
255 clonedItem.AssetType = item.AssetType;
256 clonedItem.BasePermissions = item.BasePermissions;
257 clonedItem.CreationDate = item.CreationDate;
258 clonedItem.CreatorId = item.CreatorId;
259 clonedItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
260 clonedItem.CurrentPermissions = item.CurrentPermissions;
261 clonedItem.Description = item.Description;
262 clonedItem.EveryOnePermissions = item.EveryOnePermissions;
263 clonedItem.Flags = item.Flags;
264 clonedItem.Folder = avatarFolder;
265 clonedItem.GroupID = item.GroupID;
266 clonedItem.GroupOwned = item.GroupOwned;
267 clonedItem.GroupPermissions = item.GroupPermissions;
268 clonedItem.ID = UUID.Random();
269 clonedItem.InvType = item.InvType;
270 clonedItem.Name = item.Name;
271 clonedItem.NextPermissions = item.NextPermissions;
272 clonedItem.SalePrice = item.SalePrice;
273 clonedItem.SaleType = item.SaleType;
274
275 if (modifyPerms)
276 {
277 ModifyPermissions(ref clonedItem);
278 }
279
280 SynchronousRestObjectRequester.MakeRequest<InventoryItemBase, bool>(
281 "POST", m_inventoryServerUrl + "AddNewItem/", clonedItem);
282
283 return clonedItem.ID;
284 }
285
286 return UUID.Zero;
287 }
288
167 private void UpdateAvatarAppearance(UUID avatarID, int wearableType, UUID itemID, UUID assetID) 289 private void UpdateAvatarAppearance(UUID avatarID, int wearableType, UUID itemID, UUID assetID)
168 { 290 {
169 AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(avatarID); 291 AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(avatarID);
@@ -193,6 +315,20 @@ namespace OpenSim.Grid.UserServer.Modules
193 315
194 } 316 }
195 317
318 private void RemoveClothesAndAttachments(UUID avatarID)
319 {
320 AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(avatarID);
321 if (appearance == null)
322 {
323 appearance = CreateDefaultAppearance(avatarID);
324 }
325
326 appearance.ClearWearables();
327 appearance.ClearAttachments();
328 m_userDataBaseService.UpdateUserAppearance(avatarID, appearance);
329
330 }
331
196 private UUID FindFolderID(string name, List<InventoryFolderBase> folders) 332 private UUID FindFolderID(string name, List<InventoryFolderBase> folders)
197 { 333 {
198 foreach (InventoryFolderBase folder in folders) 334 foreach (InventoryFolderBase folder in folders)
@@ -254,48 +390,6 @@ namespace OpenSim.Grid.UserServer.Modules
254 return subFolders; 390 return subFolders;
255 } 391 }
256 392
257
258 private UUID CloneInventoryItem(UUID avatarID, UUID avatarFolder, InventoryItemBase item, bool modifyPerms)
259 {
260 if (avatarFolder != UUID.Zero)
261 {
262 InventoryItemBase clonedItem = new InventoryItemBase();
263 clonedItem.Owner = avatarID;
264 clonedItem.AssetID = item.AssetID;
265 clonedItem.AssetType = item.AssetType;
266 clonedItem.BasePermissions = item.BasePermissions;
267 clonedItem.CreationDate = item.CreationDate;
268 clonedItem.CreatorId = item.CreatorId;
269 clonedItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
270 clonedItem.CurrentPermissions = item.CurrentPermissions;
271 clonedItem.Description = item.Description;
272 clonedItem.EveryOnePermissions = item.EveryOnePermissions;
273 clonedItem.Flags = item.Flags;
274 clonedItem.Folder = avatarFolder;
275 clonedItem.GroupID = item.GroupID;
276 clonedItem.GroupOwned = item.GroupOwned;
277 clonedItem.GroupPermissions = item.GroupPermissions;
278 clonedItem.ID = UUID.Random();
279 clonedItem.InvType = item.InvType;
280 clonedItem.Name = item.Name;
281 clonedItem.NextPermissions = item.NextPermissions;
282 clonedItem.SalePrice = item.SalePrice;
283 clonedItem.SaleType = item.SaleType;
284
285 if (modifyPerms)
286 {
287 ModifyPermissions(ref clonedItem);
288 }
289
290 SynchronousRestObjectRequester.MakeRequest<InventoryItemBase, bool>(
291 "POST", m_inventoryServerUrl + "AddNewItem/", clonedItem);
292
293 return clonedItem.ID;
294 }
295
296 return UUID.Zero;
297 }
298
299 protected virtual void ModifyPermissions(ref InventoryItemBase item) 393 protected virtual void ModifyPermissions(ref InventoryItemBase item)
300 { 394 {
301 // Propagate Permissions 395 // Propagate Permissions
@@ -354,83 +448,6 @@ namespace OpenSim.Grid.UserServer.Modules
354 } 448 }
355 return visualParams; 449 return visualParams;
356 } 450 }
357 #endregion
358
359
360
361 private bool CloneFolder(List<InventoryFolderBase> avatarInventory, UUID avID, UUID parentFolder, AvatarAppearance appearance, InventoryFolderBase templateFolder, List<InventoryFolderBase> templateFolders)
362 {
363 bool success = false;
364 UUID templateFolderId = templateFolder.ID;
365 if (templateFolderId != UUID.Zero)
366 {
367 InventoryFolderBase toFolder = FindFolder(templateFolder.Name, parentFolder.Guid, avatarInventory);
368 if (toFolder == null)
369 {
370 //create new folder
371 toFolder = new InventoryFolderBase();
372 toFolder.ID = UUID.Random();
373 toFolder.Name = templateFolder.Name;
374 toFolder.Owner = avID;
375 toFolder.Type = templateFolder.Type;
376 toFolder.Version = 1;
377 toFolder.ParentID = parentFolder;
378 if (!SynchronousRestObjectRequester.MakeRequest<InventoryFolderBase, bool>(
379 "POST", m_inventoryServerUrl + "CreateFolder/", toFolder))
380 {
381 m_log.InfoFormat("[AvatarApperance] Couldn't make new folder {0} in users inventory", toFolder.Name);
382 return false;
383 }
384 else
385 {
386 // m_log.InfoFormat("made new folder {0} in users inventory", toFolder.Name);
387 }
388 }
389
390 List<InventoryItemBase> templateItems = SynchronousRestObjectRequester.MakeRequest<Guid, List<InventoryItemBase>>(
391 "POST", m_inventoryServerUrl + "GetItems/", templateFolderId.Guid);
392 if ((templateItems != null) && (templateItems.Count > 0))
393 {
394 foreach (InventoryItemBase item in templateItems)
395 {
396
397 UUID clonedItemId = CloneInventoryItem(avID, toFolder.ID, item, true);
398 if (clonedItemId != UUID.Zero)
399 {
400 int appearanceType = ItemIsPartOfAppearance(item, appearance);
401 if (appearanceType >= 0)
402 {
403 UpdateAvatarAppearance(avID, appearanceType, clonedItemId, item.AssetID);
404 }
405
406 if (appearance != null)
407 {
408 int attachment = appearance.GetAttachpoint(item.ID);
409 if (attachment > 0)
410 {
411 UpdateAvatarAttachment(avID, attachment, clonedItemId, item.AssetID);
412 }
413 }
414 success = true;
415 }
416 }
417 }
418
419 List<InventoryFolderBase> subFolders = FindSubFolders(templateFolder.ID.Guid, templateFolders);
420 foreach (InventoryFolderBase subFolder in subFolders)
421 {
422 if (subFolder.Name.ToLower() != "trash")
423 {
424 success = CloneFolder(avatarInventory, avID, toFolder.ID, appearance, subFolder, templateFolders);
425 }
426 }
427 }
428 else
429 {
430 m_log.Info("[AvatarAppearance] Failed to find the template folder");
431 }
432 return success;
433 }
434 451
435 private int ItemIsPartOfAppearance(InventoryItemBase item, AvatarAppearance appearance) 452 private int ItemIsPartOfAppearance(InventoryItemBase item, AvatarAppearance appearance)
436 { 453 {
@@ -477,6 +494,8 @@ namespace OpenSim.Grid.UserServer.Modules
477 } 494 }
478 return -1; 495 return -1;
479 } 496 }
497 #endregion
498
480 499
481 } 500 }
482 public enum PermissionMask 501 public enum PermissionMask