aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/UserAccountService/UserAccountService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/UserAccountService/UserAccountService.cs')
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs159
1 files changed, 150 insertions, 9 deletions
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index 8b8a8f9..e071b94 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -28,15 +28,15 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using log4net;
31using Nini.Config; 32using Nini.Config;
33using OpenMetaverse;
32using OpenSim.Data; 34using OpenSim.Data;
35using OpenSim.Framework;
33using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
34using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
35using GridRegion = OpenSim.Services.Interfaces.GridRegion; 38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
36 39
37using OpenMetaverse;
38using log4net;
39
40namespace OpenSim.Services.UserAccountService 40namespace 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
@@ -330,7 +340,7 @@ namespace OpenSim.Services.UserAccountService
330 email = MainConsole.Instance.CmdPrompt("Email", ""); 340 email = MainConsole.Instance.CmdPrompt("Email", "");
331 else email = cmdparams[5]; 341 else email = cmdparams[5];
332 342
333 CreateUser(firstName, lastName, password, email); 343 CreateUser(UUID.Zero, firstName, lastName, password, email);
334 } 344 }
335 345
336 protected void HandleShowAccount(string module, string[] cmdparams) 346 protected void HandleShowAccount(string module, string[] cmdparams)
@@ -442,11 +452,12 @@ namespace OpenSim.Services.UserAccountService
442 /// <summary> 452 /// <summary>
443 /// Create a user 453 /// Create a user
444 /// </summary> 454 /// </summary>
455 /// <param name="scopeID">Allows hosting of multiple grids in a single database. Normally left as UUID.Zero</param>
445 /// <param name="firstName"></param> 456 /// <param name="firstName"></param>
446 /// <param name="lastName"></param> 457 /// <param name="lastName"></param>
447 /// <param name="password"></param> 458 /// <param name="password"></param>
448 /// <param name="email"></param> 459 /// <param name="email"></param>
449 private void CreateUser(string firstName, string lastName, string password, string email) 460 public UserAccount CreateUser(UUID scopeID, string firstName, string lastName, string password, string email)
450 { 461 {
451 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); 462 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
452 if (null == account) 463 if (null == account)
@@ -493,12 +504,20 @@ namespace OpenSim.Services.UserAccountService
493 { 504 {
494 success = m_InventoryService.CreateUserInventory(account.PrincipalID); 505 success = m_InventoryService.CreateUserInventory(account.PrincipalID);
495 if (!success) 506 if (!success)
507 {
496 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", 508 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
497 firstName, lastName); 509 firstName, lastName);
510 }
511 else if (m_CreateDefaultAvatarEntries)
512 {
513 CreateDefaultAppearanceEntries(account.PrincipalID);
514 }
498 } 515 }
499 516
500 m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName); 517 m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName);
501 } else { 518 }
519 else
520 {
502 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Account creation failed for account {0} {1}", firstName, lastName); 521 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Account creation failed for account {0} {1}", firstName, lastName);
503 } 522 }
504 } 523 }
@@ -506,6 +525,128 @@ namespace OpenSim.Services.UserAccountService
506 { 525 {
507 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName); 526 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName);
508 } 527 }
528
529 return account;
530 }
531
532 private void CreateDefaultAppearanceEntries(UUID principalID)
533 {
534 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID);
535
536 InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, AssetType.Bodypart);
537
538 InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID);
539 eyes.AssetID = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7");
540 eyes.Name = "Default Eyes";
541 eyes.CreatorId = principalID.ToString();
542 eyes.AssetType = (int)AssetType.Bodypart;
543 eyes.InvType = (int)InventoryType.Wearable;
544 eyes.Folder = bodyPartsFolder.ID;
545 eyes.BasePermissions = (uint)PermissionMask.All;
546 eyes.CurrentPermissions = (uint)PermissionMask.All;
547 eyes.EveryOnePermissions = (uint)PermissionMask.All;
548 eyes.GroupPermissions = (uint)PermissionMask.All;
549 eyes.NextPermissions = (uint)PermissionMask.All;
550 eyes.Flags = (uint)WearableType.Eyes;
551 m_InventoryService.AddItem(eyes);
552
553 InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID);
554 shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET;
555 shape.Name = "Default Shape";
556 shape.CreatorId = principalID.ToString();
557 shape.AssetType = (int)AssetType.Bodypart;
558 shape.InvType = (int)InventoryType.Wearable;
559 shape.Folder = bodyPartsFolder.ID;
560 shape.BasePermissions = (uint)PermissionMask.All;
561 shape.CurrentPermissions = (uint)PermissionMask.All;
562 shape.EveryOnePermissions = (uint)PermissionMask.All;
563 shape.GroupPermissions = (uint)PermissionMask.All;
564 shape.NextPermissions = (uint)PermissionMask.All;
565 shape.Flags = (uint)WearableType.Shape;
566 m_InventoryService.AddItem(shape);
567
568 InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID);
569 skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET;
570 skin.Name = "Default Skin";
571 skin.CreatorId = principalID.ToString();
572 skin.AssetType = (int)AssetType.Bodypart;
573 skin.InvType = (int)InventoryType.Wearable;
574 skin.Folder = bodyPartsFolder.ID;
575 skin.BasePermissions = (uint)PermissionMask.All;
576 skin.CurrentPermissions = (uint)PermissionMask.All;
577 skin.EveryOnePermissions = (uint)PermissionMask.All;
578 skin.GroupPermissions = (uint)PermissionMask.All;
579 skin.NextPermissions = (uint)PermissionMask.All;
580 skin.Flags = (uint)WearableType.Skin;
581 m_InventoryService.AddItem(skin);
582
583 InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID);
584 hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET;
585 hair.Name = "Default Hair";
586 hair.CreatorId = principalID.ToString();
587 hair.AssetType = (int)AssetType.Bodypart;
588 hair.InvType = (int)InventoryType.Wearable;
589 hair.Folder = bodyPartsFolder.ID;
590 hair.BasePermissions = (uint)PermissionMask.All;
591 hair.CurrentPermissions = (uint)PermissionMask.All;
592 hair.EveryOnePermissions = (uint)PermissionMask.All;
593 hair.GroupPermissions = (uint)PermissionMask.All;
594 hair.NextPermissions = (uint)PermissionMask.All;
595 hair.Flags = (uint)WearableType.Hair;
596 m_InventoryService.AddItem(hair);
597
598 InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, AssetType.Clothing);
599
600 InventoryItemBase shirt = new InventoryItemBase(UUID.Random(), principalID);
601 shirt.AssetID = AvatarWearable.DEFAULT_SHIRT_ASSET;
602 shirt.Name = "Default Shirt";
603 shirt.CreatorId = principalID.ToString();
604 shirt.AssetType = (int)AssetType.Clothing;
605 shirt.InvType = (int)InventoryType.Wearable;
606 shirt.Folder = clothingFolder.ID;
607 shirt.BasePermissions = (uint)PermissionMask.All;
608 shirt.CurrentPermissions = (uint)PermissionMask.All;
609 shirt.EveryOnePermissions = (uint)PermissionMask.All;
610 shirt.GroupPermissions = (uint)PermissionMask.All;
611 shirt.NextPermissions = (uint)PermissionMask.All;
612 shirt.Flags = (uint)WearableType.Shirt;
613 m_InventoryService.AddItem(shirt);
614
615 InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID);
616 pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET;
617 pants.Name = "Default Pants";
618 pants.CreatorId = principalID.ToString();
619 pants.AssetType = (int)AssetType.Clothing;
620 pants.InvType = (int)InventoryType.Wearable;
621 pants.Folder = clothingFolder.ID;
622 pants.BasePermissions = (uint)PermissionMask.All;
623 pants.CurrentPermissions = (uint)PermissionMask.All;
624 pants.EveryOnePermissions = (uint)PermissionMask.All;
625 pants.GroupPermissions = (uint)PermissionMask.All;
626 pants.NextPermissions = (uint)PermissionMask.All;
627 pants.Flags = (uint)WearableType.Pants;
628 m_InventoryService.AddItem(pants);
629
630 if (m_AvatarService != null)
631 {
632 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default avatar entries for {0}", principalID);
633
634 AvatarWearable[] wearables = new AvatarWearable[6];
635 wearables[AvatarWearable.EYES] = new AvatarWearable(eyes.ID, eyes.AssetID);
636 wearables[AvatarWearable.BODY] = new AvatarWearable(shape.ID, shape.AssetID);
637 wearables[AvatarWearable.SKIN] = new AvatarWearable(skin.ID, skin.AssetID);
638 wearables[AvatarWearable.HAIR] = new AvatarWearable(hair.ID, hair.AssetID);
639 wearables[AvatarWearable.SHIRT] = new AvatarWearable(shirt.ID, shirt.AssetID);
640 wearables[AvatarWearable.PANTS] = new AvatarWearable(pants.ID, pants.AssetID);
641
642 AvatarAppearance ap = new AvatarAppearance();
643 for (int i = 0; i < 6; i++)
644 {
645 ap.SetWearable(i, wearables[i]);
646 }
647
648 m_AvatarService.SetAppearance(principalID, ap);
649 }
509 } 650 }
510 } 651 }
511} 652} \ No newline at end of file