diff options
Merge commit 'c4efb97d49dec736151dfa3fa102efe6a5f6fbab' into bigmerge
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/UserAccountService/UserAccountService.cs | 152 |
1 files changed, 145 insertions, 7 deletions
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 7a46165..5f388a4 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs | |||
@@ -28,15 +28,15 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | ||
31 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | ||
32 | using OpenSim.Data; | 34 | using OpenSim.Data; |
35 | using OpenSim.Framework; | ||
33 | using OpenSim.Services.Interfaces; | 36 | using OpenSim.Services.Interfaces; |
34 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
35 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
36 | 39 | ||
37 | using OpenMetaverse; | ||
38 | using log4net; | ||
39 | |||
40 | namespace OpenSim.Services.UserAccountService | 40 | namespace OpenSim.Services.UserAccountService |
41 | { | 41 | { |
42 | public class UserAccountService : UserAccountServiceBase, IUserAccountService | 42 | public class UserAccountService : UserAccountServiceBase, IUserAccountService |
@@ -44,10 +44,16 @@ namespace OpenSim.Services.UserAccountService | |||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | private static UserAccountService m_RootInstance; | 45 | private static UserAccountService m_RootInstance; |
46 | 46 | ||
47 | /// <summary> | ||
48 | /// Should we create default entries (minimum body parts/clothing, avatar wearable entries) for a new avatar? | ||
49 | /// </summary> | ||
50 | private bool m_CreateDefaultAvatarEntries; | ||
51 | |||
47 | protected IGridService m_GridService; | 52 | protected IGridService m_GridService; |
48 | protected IAuthenticationService m_AuthenticationService; | 53 | protected IAuthenticationService m_AuthenticationService; |
49 | protected IGridUserService m_GridUserService; | 54 | protected IGridUserService m_GridUserService; |
50 | protected IInventoryService m_InventoryService; | 55 | protected IInventoryService m_InventoryService; |
56 | protected IAvatarService m_AvatarService; | ||
51 | 57 | ||
52 | public UserAccountService(IConfigSource config) | 58 | public UserAccountService(IConfigSource config) |
53 | : base(config) | 59 | : base(config) |
@@ -77,6 +83,12 @@ namespace OpenSim.Services.UserAccountService | |||
77 | if (invServiceDll != string.Empty) | 83 | if (invServiceDll != string.Empty) |
78 | m_InventoryService = LoadPlugin<IInventoryService>(invServiceDll, new Object[] { config }); | 84 | m_InventoryService = LoadPlugin<IInventoryService>(invServiceDll, new Object[] { config }); |
79 | 85 | ||
86 | string avatarServiceDll = userConfig.GetString("AvatarService", string.Empty); | ||
87 | if (avatarServiceDll != string.Empty) | ||
88 | m_AvatarService = LoadPlugin<IAvatarService>(avatarServiceDll, new Object[] { config }); | ||
89 | |||
90 | m_CreateDefaultAvatarEntries = userConfig.GetBoolean("CreateDefaultAvatarEntries", false); | ||
91 | |||
80 | if (MainConsole.Instance != null) | 92 | if (MainConsole.Instance != null) |
81 | { | 93 | { |
82 | MainConsole.Instance.Commands.AddCommand("UserService", false, | 94 | MainConsole.Instance.Commands.AddCommand("UserService", false, |
@@ -102,9 +114,7 @@ namespace OpenSim.Services.UserAccountService | |||
102 | "show account <first> <last>", | 114 | "show account <first> <last>", |
103 | "Show account details for the given user", HandleShowAccount); | 115 | "Show account details for the given user", HandleShowAccount); |
104 | } | 116 | } |
105 | |||
106 | } | 117 | } |
107 | |||
108 | } | 118 | } |
109 | 119 | ||
110 | #region IUserAccountService | 120 | #region IUserAccountService |
@@ -512,12 +522,20 @@ namespace OpenSim.Services.UserAccountService | |||
512 | { | 522 | { |
513 | success = m_InventoryService.CreateUserInventory(account.PrincipalID); | 523 | success = m_InventoryService.CreateUserInventory(account.PrincipalID); |
514 | if (!success) | 524 | if (!success) |
525 | { | ||
515 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", | 526 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", |
516 | firstName, lastName); | 527 | firstName, lastName); |
528 | } | ||
529 | else if (m_CreateDefaultAvatarEntries) | ||
530 | { | ||
531 | CreateDefaultAppearanceEntries(account.PrincipalID); | ||
532 | } | ||
517 | } | 533 | } |
518 | 534 | ||
519 | m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName); | 535 | m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName); |
520 | } else { | 536 | } |
537 | else | ||
538 | { | ||
521 | m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Account creation failed for account {0} {1}", firstName, lastName); | 539 | m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Account creation failed for account {0} {1}", firstName, lastName); |
522 | } | 540 | } |
523 | } | 541 | } |
@@ -526,5 +544,125 @@ namespace OpenSim.Services.UserAccountService | |||
526 | m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName); | 544 | m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName); |
527 | } | 545 | } |
528 | } | 546 | } |
547 | |||
548 | private void CreateDefaultAppearanceEntries(UUID principalID) | ||
549 | { | ||
550 | m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID); | ||
551 | |||
552 | InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, AssetType.Bodypart); | ||
553 | |||
554 | InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID); | ||
555 | eyes.AssetID = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7"); | ||
556 | eyes.Name = "Default Eyes"; | ||
557 | eyes.CreatorId = principalID.ToString(); | ||
558 | eyes.AssetType = (int)AssetType.Bodypart; | ||
559 | eyes.InvType = (int)InventoryType.Wearable; | ||
560 | eyes.Folder = bodyPartsFolder.ID; | ||
561 | eyes.BasePermissions = (uint)PermissionMask.All; | ||
562 | eyes.CurrentPermissions = (uint)PermissionMask.All; | ||
563 | eyes.EveryOnePermissions = (uint)PermissionMask.All; | ||
564 | eyes.GroupPermissions = (uint)PermissionMask.All; | ||
565 | eyes.NextPermissions = (uint)PermissionMask.All; | ||
566 | eyes.Flags = (uint)WearableType.Eyes; | ||
567 | m_InventoryService.AddItem(eyes); | ||
568 | |||
569 | InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID); | ||
570 | shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET; | ||
571 | shape.Name = "Default Shape"; | ||
572 | shape.CreatorId = principalID.ToString(); | ||
573 | shape.AssetType = (int)AssetType.Bodypart; | ||
574 | shape.InvType = (int)InventoryType.Wearable; | ||
575 | shape.Folder = bodyPartsFolder.ID; | ||
576 | shape.BasePermissions = (uint)PermissionMask.All; | ||
577 | shape.CurrentPermissions = (uint)PermissionMask.All; | ||
578 | shape.EveryOnePermissions = (uint)PermissionMask.All; | ||
579 | shape.GroupPermissions = (uint)PermissionMask.All; | ||
580 | shape.NextPermissions = (uint)PermissionMask.All; | ||
581 | shape.Flags = (uint)WearableType.Shape; | ||
582 | m_InventoryService.AddItem(shape); | ||
583 | |||
584 | InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID); | ||
585 | skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET; | ||
586 | skin.Name = "Default Skin"; | ||
587 | skin.CreatorId = principalID.ToString(); | ||
588 | skin.AssetType = (int)AssetType.Bodypart; | ||
589 | skin.InvType = (int)InventoryType.Wearable; | ||
590 | skin.Folder = bodyPartsFolder.ID; | ||
591 | skin.BasePermissions = (uint)PermissionMask.All; | ||
592 | skin.CurrentPermissions = (uint)PermissionMask.All; | ||
593 | skin.EveryOnePermissions = (uint)PermissionMask.All; | ||
594 | skin.GroupPermissions = (uint)PermissionMask.All; | ||
595 | skin.NextPermissions = (uint)PermissionMask.All; | ||
596 | skin.Flags = (uint)WearableType.Skin; | ||
597 | m_InventoryService.AddItem(skin); | ||
598 | |||
599 | InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID); | ||
600 | hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET; | ||
601 | hair.Name = "Default Hair"; | ||
602 | hair.CreatorId = principalID.ToString(); | ||
603 | hair.AssetType = (int)AssetType.Bodypart; | ||
604 | hair.InvType = (int)InventoryType.Wearable; | ||
605 | hair.Folder = bodyPartsFolder.ID; | ||
606 | hair.BasePermissions = (uint)PermissionMask.All; | ||
607 | hair.CurrentPermissions = (uint)PermissionMask.All; | ||
608 | hair.EveryOnePermissions = (uint)PermissionMask.All; | ||
609 | hair.GroupPermissions = (uint)PermissionMask.All; | ||
610 | hair.NextPermissions = (uint)PermissionMask.All; | ||
611 | hair.Flags = (uint)WearableType.Hair; | ||
612 | m_InventoryService.AddItem(hair); | ||
613 | |||
614 | InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, AssetType.Clothing); | ||
615 | |||
616 | InventoryItemBase shirt = new InventoryItemBase(UUID.Random(), principalID); | ||
617 | shirt.AssetID = AvatarWearable.DEFAULT_SHIRT_ASSET; | ||
618 | shirt.Name = "Default Shirt"; | ||
619 | shirt.CreatorId = principalID.ToString(); | ||
620 | shirt.AssetType = (int)AssetType.Clothing; | ||
621 | shirt.InvType = (int)InventoryType.Wearable; | ||
622 | shirt.Folder = clothingFolder.ID; | ||
623 | shirt.BasePermissions = (uint)PermissionMask.All; | ||
624 | shirt.CurrentPermissions = (uint)PermissionMask.All; | ||
625 | shirt.EveryOnePermissions = (uint)PermissionMask.All; | ||
626 | shirt.GroupPermissions = (uint)PermissionMask.All; | ||
627 | shirt.NextPermissions = (uint)PermissionMask.All; | ||
628 | shirt.Flags = (uint)WearableType.Shirt; | ||
629 | m_InventoryService.AddItem(shirt); | ||
630 | |||
631 | InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID); | ||
632 | pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET; | ||
633 | pants.Name = "Default Pants"; | ||
634 | pants.CreatorId = principalID.ToString(); | ||
635 | pants.AssetType = (int)AssetType.Clothing; | ||
636 | pants.InvType = (int)InventoryType.Wearable; | ||
637 | pants.Folder = clothingFolder.ID; | ||
638 | pants.BasePermissions = (uint)PermissionMask.All; | ||
639 | pants.CurrentPermissions = (uint)PermissionMask.All; | ||
640 | pants.EveryOnePermissions = (uint)PermissionMask.All; | ||
641 | pants.GroupPermissions = (uint)PermissionMask.All; | ||
642 | pants.NextPermissions = (uint)PermissionMask.All; | ||
643 | pants.Flags = (uint)WearableType.Pants; | ||
644 | m_InventoryService.AddItem(pants); | ||
645 | |||
646 | if (m_AvatarService != null) | ||
647 | { | ||
648 | m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default avatar entries for {0}", principalID); | ||
649 | |||
650 | AvatarWearable[] wearables = new AvatarWearable[6]; | ||
651 | wearables[AvatarWearable.EYES] = new AvatarWearable(eyes.ID, eyes.AssetID); | ||
652 | wearables[AvatarWearable.BODY] = new AvatarWearable(shape.ID, shape.AssetID); | ||
653 | wearables[AvatarWearable.SKIN] = new AvatarWearable(skin.ID, skin.AssetID); | ||
654 | wearables[AvatarWearable.HAIR] = new AvatarWearable(hair.ID, hair.AssetID); | ||
655 | wearables[AvatarWearable.SHIRT] = new AvatarWearable(shirt.ID, shirt.AssetID); | ||
656 | wearables[AvatarWearable.PANTS] = new AvatarWearable(pants.ID, pants.AssetID); | ||
657 | |||
658 | AvatarAppearance ap = new AvatarAppearance(); | ||
659 | for (int i = 0; i < 6; i++) | ||
660 | { | ||
661 | ap.SetWearable(i, wearables[i]); | ||
662 | } | ||
663 | |||
664 | m_AvatarService.SetAppearance(principalID, ap); | ||
665 | } | ||
666 | } | ||
529 | } | 667 | } |
530 | } | 668 | } \ No newline at end of file |