OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
UserAccountService.cs
Go to the documentation of this file.
1 /*
2  * Copyright (c) Contributors, http://opensimulator.org/
3  * See CONTRIBUTORS.TXT for a full list of copyright holders.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the OpenSimulator Project nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 using System;
29 using System.Collections.Generic;
30 using System.Reflection;
31 using log4net;
32 using Nini.Config;
33 using OpenMetaverse;
34 using OpenSim.Data;
35 using OpenSim.Framework;
36 using OpenSim.Services.Interfaces;
37 using OpenSim.Framework.Console;
40 
41 namespace OpenSim.Services.UserAccountService
42 {
44  {
45  private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46  private static UserAccountService m_RootInstance;
47 
51  private bool m_CreateDefaultAvatarEntries;
52 
58 
59  public UserAccountService(IConfigSource config)
60  : base(config)
61  {
62  IConfig userConfig = config.Configs["UserAccountService"];
63  if (userConfig == null)
64  throw new Exception("No UserAccountService configuration");
65 
66  string gridServiceDll = userConfig.GetString("GridService", string.Empty);
67  if (gridServiceDll != string.Empty)
68  m_GridService = LoadPlugin<IGridService>(gridServiceDll, new Object[] { config });
69 
70  string authServiceDll = userConfig.GetString("AuthenticationService", string.Empty);
71  if (authServiceDll != string.Empty)
72  m_AuthenticationService = LoadPlugin<IAuthenticationService>(authServiceDll, new Object[] { config });
73 
74  string presenceServiceDll = userConfig.GetString("GridUserService", string.Empty);
75  if (presenceServiceDll != string.Empty)
76  m_GridUserService = LoadPlugin<IGridUserService>(presenceServiceDll, new Object[] { config });
77 
78  string invServiceDll = userConfig.GetString("InventoryService", string.Empty);
79  if (invServiceDll != string.Empty)
80  m_InventoryService = LoadPlugin<IInventoryService>(invServiceDll, new Object[] { config });
81 
82  string avatarServiceDll = userConfig.GetString("AvatarService", string.Empty);
83  if (avatarServiceDll != string.Empty)
84  m_AvatarService = LoadPlugin<IAvatarService>(avatarServiceDll, new Object[] { config });
85 
86  m_CreateDefaultAvatarEntries = userConfig.GetBoolean("CreateDefaultAvatarEntries", false);
87 
88  // In case there are several instances of this class in the same process,
89  // the console commands are only registered for the root instance
90  if (m_RootInstance == null && MainConsole.Instance != null)
91  {
92  m_RootInstance = this;
93  MainConsole.Instance.Commands.AddCommand("Users", false,
94  "create user",
95  "create user [<first> [<last> [<pass> [<email> [<user id>]]]]]",
96  "Create a new user", HandleCreateUser);
97 
98  MainConsole.Instance.Commands.AddCommand("Users", false,
99  "reset user password",
100  "reset user password [<first> [<last> [<password>]]]",
101  "Reset a user password", HandleResetUserPassword);
102 
103  MainConsole.Instance.Commands.AddCommand("Users", false,
104  "reset user email",
105  "reset user email [<first> [<last> [<email>]]]",
106  "Reset a user email address", HandleResetUserEmail);
107 
108  MainConsole.Instance.Commands.AddCommand("Users", false,
109  "set user level",
110  "set user level [<first> [<last> [<level>]]]",
111  "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, "
112  + "this account will be treated as god-moded. "
113  + "It will also affect the 'login level' command. ",
114  HandleSetUserLevel);
115 
116  MainConsole.Instance.Commands.AddCommand("Users", false,
117  "show account",
118  "show account <first> <last>",
119  "Show account details for the given user", HandleShowAccount);
120  }
121  }
122 
123  #region IUserAccountService
124 
125  public UserAccount GetUserAccount(UUID scopeID, string firstName,
126  string lastName)
127  {
128 // m_log.DebugFormat(
129 // "[USER ACCOUNT SERVICE]: Retrieving account by username for {0} {1}, scope {2}",
130 // firstName, lastName, scopeID);
131 
132  UserAccountData[] d;
133 
134  if (scopeID != UUID.Zero)
135  {
136  d = m_Database.Get(
137  new string[] { "ScopeID", "FirstName", "LastName" },
138  new string[] { scopeID.ToString(), firstName, lastName });
139  if (d.Length < 1)
140  {
141  d = m_Database.Get(
142  new string[] { "ScopeID", "FirstName", "LastName" },
143  new string[] { UUID.Zero.ToString(), firstName, lastName });
144  }
145  }
146  else
147  {
148  d = m_Database.Get(
149  new string[] { "FirstName", "LastName" },
150  new string[] { firstName, lastName });
151  }
152 
153  if (d.Length < 1)
154  return null;
155 
156  return MakeUserAccount(d[0]);
157  }
158 
159  private UserAccount MakeUserAccount(UserAccountData d)
160  {
161  UserAccount u = new UserAccount();
162  u.FirstName = d.FirstName;
163  u.LastName = d.LastName;
164  u.PrincipalID = d.PrincipalID;
165  u.ScopeID = d.ScopeID;
166  if (d.Data.ContainsKey("Email") && d.Data["Email"] != null)
167  u.Email = d.Data["Email"].ToString();
168  else
169  u.Email = string.Empty;
170  u.Created = Convert.ToInt32(d.Data["Created"].ToString());
171  if (d.Data.ContainsKey("UserTitle") && d.Data["UserTitle"] != null)
172  u.UserTitle = d.Data["UserTitle"].ToString();
173  else
174  u.UserTitle = string.Empty;
175  if (d.Data.ContainsKey("UserLevel") && d.Data["UserLevel"] != null)
176  Int32.TryParse(d.Data["UserLevel"], out u.UserLevel);
177  if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null)
178  Int32.TryParse(d.Data["UserFlags"], out u.UserFlags);
179  if (d.Data.ContainsKey("UserCountry") && d.Data["UserCountry"] != null)
180  u.UserCountry = d.Data["UserCountry"].ToString();
181  else
182  u.UserTitle = string.Empty;
183 
184  if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null)
185  {
186  string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] { ' ' });
187  u.ServiceURLs = new Dictionary<string, object>();
188 
189  foreach (string url in URLs)
190  {
191  string[] parts = url.Split(new char[] { '=' });
192 
193  if (parts.Length != 2)
194  continue;
195 
196  string name = System.Web.HttpUtility.UrlDecode(parts[0]);
197  string val = System.Web.HttpUtility.UrlDecode(parts[1]);
198 
199  u.ServiceURLs[name] = val;
200  }
201  }
202  else
203  u.ServiceURLs = new Dictionary<string, object>();
204 
205  return u;
206  }
207 
208  public UserAccount GetUserAccount(UUID scopeID, string email)
209  {
210  UserAccountData[] d;
211 
212  if (scopeID != UUID.Zero)
213  {
214  d = m_Database.Get(
215  new string[] { "ScopeID", "Email" },
216  new string[] { scopeID.ToString(), email });
217  if (d.Length < 1)
218  {
219  d = m_Database.Get(
220  new string[] { "ScopeID", "Email" },
221  new string[] { UUID.Zero.ToString(), email });
222  }
223  }
224  else
225  {
226  d = m_Database.Get(
227  new string[] { "Email" },
228  new string[] { email });
229  }
230 
231  if (d.Length < 1)
232  return null;
233 
234  return MakeUserAccount(d[0]);
235  }
236 
237  public UserAccount GetUserAccount(UUID scopeID, UUID principalID)
238  {
239  UserAccountData[] d;
240 
241  if (scopeID != UUID.Zero)
242  {
243  d = m_Database.Get(
244  new string[] { "ScopeID", "PrincipalID" },
245  new string[] { scopeID.ToString(), principalID.ToString() });
246  if (d.Length < 1)
247  {
248  d = m_Database.Get(
249  new string[] { "ScopeID", "PrincipalID" },
250  new string[] { UUID.Zero.ToString(), principalID.ToString() });
251  }
252  }
253  else
254  {
255  d = m_Database.Get(
256  new string[] { "PrincipalID" },
257  new string[] { principalID.ToString() });
258  }
259 
260  if (d.Length < 1)
261  {
262  return null;
263  }
264 
265  return MakeUserAccount(d[0]);
266  }
267 
268  public void InvalidateCache(UUID userID)
269  {
270  }
271 
272  public bool StoreUserAccount(UserAccount data)
273  {
274 // m_log.DebugFormat(
275 // "[USER ACCOUNT SERVICE]: Storing user account for {0} {1} {2}, scope {3}",
276 // data.FirstName, data.LastName, data.PrincipalID, data.ScopeID);
277 
279 
280  d.FirstName = data.FirstName;
281  d.LastName = data.LastName;
282  d.PrincipalID = data.PrincipalID;
283  d.ScopeID = data.ScopeID;
284  d.Data = new Dictionary<string, string>();
285  d.Data["Email"] = data.Email;
286  d.Data["Created"] = data.Created.ToString();
287  d.Data["UserLevel"] = data.UserLevel.ToString();
288  d.Data["UserFlags"] = data.UserFlags.ToString();
289  if (data.UserTitle != null)
290  d.Data["UserTitle"] = data.UserTitle.ToString();
291 
292  List<string> parts = new List<string>();
293 
294  foreach (KeyValuePair<string, object> kvp in data.ServiceURLs)
295  {
296  string key = System.Web.HttpUtility.UrlEncode(kvp.Key);
297  string val = System.Web.HttpUtility.UrlEncode(kvp.Value.ToString());
298  parts.Add(key + "=" + val);
299  }
300 
301  d.Data["ServiceURLs"] = string.Join(" ", parts.ToArray());
302 
303  return m_Database.Store(d);
304  }
305 
306  public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
307  {
308  UserAccountData[] d = m_Database.GetUsers(scopeID, query.Trim());
309 
310  if (d == null)
311  return new List<UserAccount>();
312 
313  List<UserAccount> ret = new List<UserAccount>();
314 
315  foreach (UserAccountData data in d)
316  ret.Add(MakeUserAccount(data));
317 
318  return ret;
319  }
320 
321  public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where)
322  {
323  UserAccountData[] d = m_Database.GetUsersWhere(scopeID, where);
324 
325  if (d == null)
326  return new List<UserAccount>();
327 
328  List<UserAccount> ret = new List<UserAccount>();
329 
330  foreach (UserAccountData data in d)
331  ret.Add(MakeUserAccount(data));
332 
333  return ret;
334  }
335 
336  #endregion
337 
338  #region Console commands
339 
344  protected void HandleCreateUser(string module, string[] cmdparams)
345  {
346  string firstName;
347  string lastName;
348  string password;
349  string email;
350  string rawPrincipalId;
351 
352  List<char> excluded = new List<char>(new char[]{' '});
353 
354  if (cmdparams.Length < 3)
355  firstName = MainConsole.Instance.CmdPrompt("First name", "Default", excluded);
356  else firstName = cmdparams[2];
357 
358  if (cmdparams.Length < 4)
359  lastName = MainConsole.Instance.CmdPrompt("Last name", "User", excluded);
360  else lastName = cmdparams[3];
361 
362  if (cmdparams.Length < 5)
363  password = MainConsole.Instance.PasswdPrompt("Password");
364  else password = cmdparams[4];
365 
366  if (cmdparams.Length < 6)
367  email = MainConsole.Instance.CmdPrompt("Email", "");
368  else email = cmdparams[5];
369 
370  if (cmdparams.Length < 7)
371  rawPrincipalId = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString());
372  else
373  rawPrincipalId = cmdparams[6];
374 
375  UUID principalId = UUID.Zero;
376  if (!UUID.TryParse(rawPrincipalId, out principalId))
377  throw new Exception(string.Format("ID {0} is not a valid UUID", rawPrincipalId));
378 
379  CreateUser(UUID.Zero, principalId, firstName, lastName, password, email);
380  }
381 
382  protected void HandleShowAccount(string module, string[] cmdparams)
383  {
384  if (cmdparams.Length != 4)
385  {
386  MainConsole.Instance.Output("Usage: show account <first-name> <last-name>");
387  return;
388  }
389 
390  string firstName = cmdparams[2];
391  string lastName = cmdparams[3];
392 
393  UserAccount ua = GetUserAccount(UUID.Zero, firstName, lastName);
394 
395  if (ua == null)
396  {
397  MainConsole.Instance.OutputFormat("No user named {0} {1}", firstName, lastName);
398  return;
399  }
400 
401  MainConsole.Instance.OutputFormat("Name: {0}", ua.Name);
402  MainConsole.Instance.OutputFormat("ID: {0}", ua.PrincipalID);
403  MainConsole.Instance.OutputFormat("Title: {0}", ua.UserTitle);
404  MainConsole.Instance.OutputFormat("E-mail: {0}", ua.Email);
405  MainConsole.Instance.OutputFormat("Created: {0}", Utils.UnixTimeToDateTime(ua.Created));
406  MainConsole.Instance.OutputFormat("Level: {0}", ua.UserLevel);
407  MainConsole.Instance.OutputFormat("Flags: {0}", ua.UserFlags);
408  foreach (KeyValuePair<string, Object> kvp in ua.ServiceURLs)
409  MainConsole.Instance.OutputFormat("{0}: {1}", kvp.Key, kvp.Value);
410  }
411 
412  protected void HandleResetUserPassword(string module, string[] cmdparams)
413  {
414  string firstName;
415  string lastName;
416  string newPassword;
417 
418  if (cmdparams.Length < 4)
419  firstName = MainConsole.Instance.CmdPrompt("First name");
420  else firstName = cmdparams[3];
421 
422  if (cmdparams.Length < 5)
423  lastName = MainConsole.Instance.CmdPrompt("Last name");
424  else lastName = cmdparams[4];
425 
426  if (cmdparams.Length < 6)
427  newPassword = MainConsole.Instance.PasswdPrompt("New password");
428  else newPassword = cmdparams[5];
429 
430  UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
431  if (account == null)
432  {
433  MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
434  return;
435  }
436 
437  bool success = false;
438  if (m_AuthenticationService != null)
439  success = m_AuthenticationService.SetPassword(account.PrincipalID, newPassword);
440 
441  if (!success)
442  MainConsole.Instance.OutputFormat("Unable to reset password for account {0} {1}.", firstName, lastName);
443  else
444  MainConsole.Instance.OutputFormat("Password reset for user {0} {1}", firstName, lastName);
445  }
446 
447  protected void HandleResetUserEmail(string module, string[] cmdparams)
448  {
449  string firstName;
450  string lastName;
451  string newEmail;
452 
453  if (cmdparams.Length < 4)
454  firstName = MainConsole.Instance.CmdPrompt("First name");
455  else firstName = cmdparams[3];
456 
457  if (cmdparams.Length < 5)
458  lastName = MainConsole.Instance.CmdPrompt("Last name");
459  else lastName = cmdparams[4];
460 
461  if (cmdparams.Length < 6)
462  newEmail = MainConsole.Instance.PasswdPrompt("New Email");
463  else newEmail = cmdparams[5];
464 
465  UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
466  if (account == null)
467  {
468  MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
469  return;
470  }
471 
472  bool success = false;
473 
474  account.Email = newEmail;
475 
476  success = StoreUserAccount(account);
477  if (!success)
478  MainConsole.Instance.OutputFormat("Unable to set Email for account {0} {1}.", firstName, lastName);
479  else
480  MainConsole.Instance.OutputFormat("User Email set for user {0} {1} to {2}", firstName, lastName, account.Email);
481  }
482 
483 
484  protected void HandleSetUserLevel(string module, string[] cmdparams)
485  {
486  string firstName;
487  string lastName;
488  string rawLevel;
489  int level;
490 
491  if (cmdparams.Length < 4)
492  firstName = MainConsole.Instance.CmdPrompt("First name");
493  else firstName = cmdparams[3];
494 
495  if (cmdparams.Length < 5)
496  lastName = MainConsole.Instance.CmdPrompt("Last name");
497  else lastName = cmdparams[4];
498 
499  UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
500  if (account == null) {
501  MainConsole.Instance.OutputFormat("No such user");
502  return;
503  }
504 
505  if (cmdparams.Length < 6)
506  rawLevel = MainConsole.Instance.CmdPrompt("User level");
507  else rawLevel = cmdparams[5];
508 
509  if(int.TryParse(rawLevel, out level) == false) {
510  MainConsole.Instance.OutputFormat("Invalid user level");
511  return;
512  }
513 
514  account.UserLevel = level;
515 
516  bool success = StoreUserAccount(account);
517  if (!success)
518  MainConsole.Instance.OutputFormat("Unable to set user level for account {0} {1}.", firstName, lastName);
519  else
520  MainConsole.Instance.OutputFormat("User level set for user {0} {1} to {2}", firstName, lastName, level);
521  }
522 
523  #endregion
524 
534  public UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email)
535  {
536  UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
537  if (null == account)
538  {
539  account = new UserAccount(UUID.Zero, principalID, firstName, lastName, email);
540  if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
541  {
542  account.ServiceURLs = new Dictionary<string, object>();
543  account.ServiceURLs["HomeURI"] = string.Empty;
544  account.ServiceURLs["InventoryServerURI"] = string.Empty;
545  account.ServiceURLs["AssetServerURI"] = string.Empty;
546  }
547 
548  if (StoreUserAccount(account))
549  {
550  bool success;
551  if (m_AuthenticationService != null)
552  {
553  success = m_AuthenticationService.SetPassword(account.PrincipalID, password);
554  if (!success)
555  m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.",
556  firstName, lastName);
557  }
558 
559  GridRegion home = null;
560  if (m_GridService != null)
561  {
562  List<GridRegion> defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero);
563  if (defaultRegions != null && defaultRegions.Count >= 1)
564  home = defaultRegions[0];
565 
566  if (m_GridUserService != null && home != null)
567  m_GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
568  else
569  m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
570  firstName, lastName);
571  }
572  else
573  {
574  m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
575  firstName, lastName);
576  }
577 
578  if (m_InventoryService != null)
579  {
580  success = m_InventoryService.CreateUserInventory(account.PrincipalID);
581  if (!success)
582  {
583  m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
584  firstName, lastName);
585  }
586  else
587  {
588  m_log.DebugFormat(
589  "[USER ACCOUNT SERVICE]: Created user inventory for {0} {1}", firstName, lastName);
590  }
591 
592  if (m_CreateDefaultAvatarEntries)
593  CreateDefaultAppearanceEntries(account.PrincipalID);
594  }
595 
596  m_log.InfoFormat(
597  "[USER ACCOUNT SERVICE]: Account {0} {1} {2} created successfully",
598  firstName, lastName, account.PrincipalID);
599  }
600  else
601  {
602  m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Account creation failed for account {0} {1}", firstName, lastName);
603  }
604  }
605  else
606  {
607  m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName);
608  }
609 
610  return account;
611  }
612 
613  protected void CreateDefaultAppearanceEntries(UUID principalID)
614  {
615  m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID);
616 
617  InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, FolderType.BodyPart);
618 
619  InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID);
620  eyes.AssetID = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7");
621  eyes.Name = "Default Eyes";
622  eyes.CreatorId = principalID.ToString();
623  eyes.AssetType = (int)AssetType.Bodypart;
624  eyes.InvType = (int)InventoryType.Wearable;
625  eyes.Folder = bodyPartsFolder.ID;
626  eyes.BasePermissions = (uint)PermissionMask.All;
627  eyes.CurrentPermissions = (uint)PermissionMask.All;
628  eyes.EveryOnePermissions = (uint)PermissionMask.All;
629  eyes.GroupPermissions = (uint)PermissionMask.All;
630  eyes.NextPermissions = (uint)PermissionMask.All;
631  eyes.Flags = (uint)WearableType.Eyes;
632  m_InventoryService.AddItem(eyes);
633 
634  InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID);
635  shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET;
636  shape.Name = "Default Shape";
637  shape.CreatorId = principalID.ToString();
638  shape.AssetType = (int)AssetType.Bodypart;
639  shape.InvType = (int)InventoryType.Wearable;
640  shape.Folder = bodyPartsFolder.ID;
641  shape.BasePermissions = (uint)PermissionMask.All;
642  shape.CurrentPermissions = (uint)PermissionMask.All;
643  shape.EveryOnePermissions = (uint)PermissionMask.All;
644  shape.GroupPermissions = (uint)PermissionMask.All;
645  shape.NextPermissions = (uint)PermissionMask.All;
646  shape.Flags = (uint)WearableType.Shape;
647  m_InventoryService.AddItem(shape);
648 
649  InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID);
650  skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET;
651  skin.Name = "Default Skin";
652  skin.CreatorId = principalID.ToString();
653  skin.AssetType = (int)AssetType.Bodypart;
654  skin.InvType = (int)InventoryType.Wearable;
655  skin.Folder = bodyPartsFolder.ID;
656  skin.BasePermissions = (uint)PermissionMask.All;
657  skin.CurrentPermissions = (uint)PermissionMask.All;
658  skin.EveryOnePermissions = (uint)PermissionMask.All;
659  skin.GroupPermissions = (uint)PermissionMask.All;
660  skin.NextPermissions = (uint)PermissionMask.All;
661  skin.Flags = (uint)WearableType.Skin;
662  m_InventoryService.AddItem(skin);
663 
664  InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID);
665  hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET;
666  hair.Name = "Default Hair";
667  hair.CreatorId = principalID.ToString();
668  hair.AssetType = (int)AssetType.Bodypart;
669  hair.InvType = (int)InventoryType.Wearable;
670  hair.Folder = bodyPartsFolder.ID;
671  hair.BasePermissions = (uint)PermissionMask.All;
672  hair.CurrentPermissions = (uint)PermissionMask.All;
673  hair.EveryOnePermissions = (uint)PermissionMask.All;
674  hair.GroupPermissions = (uint)PermissionMask.All;
675  hair.NextPermissions = (uint)PermissionMask.All;
676  hair.Flags = (uint)WearableType.Hair;
677  m_InventoryService.AddItem(hair);
678 
679  InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, FolderType.Clothing);
680 
681  InventoryItemBase shirt = new InventoryItemBase(UUID.Random(), principalID);
682  shirt.AssetID = AvatarWearable.DEFAULT_SHIRT_ASSET;
683  shirt.Name = "Default Shirt";
684  shirt.CreatorId = principalID.ToString();
685  shirt.AssetType = (int)AssetType.Clothing;
686  shirt.InvType = (int)InventoryType.Wearable;
687  shirt.Folder = clothingFolder.ID;
688  shirt.BasePermissions = (uint)PermissionMask.All;
689  shirt.CurrentPermissions = (uint)PermissionMask.All;
690  shirt.EveryOnePermissions = (uint)PermissionMask.All;
691  shirt.GroupPermissions = (uint)PermissionMask.All;
692  shirt.NextPermissions = (uint)PermissionMask.All;
693  shirt.Flags = (uint)WearableType.Shirt;
694  m_InventoryService.AddItem(shirt);
695 
696  InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID);
697  pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET;
698  pants.Name = "Default Pants";
699  pants.CreatorId = principalID.ToString();
700  pants.AssetType = (int)AssetType.Clothing;
701  pants.InvType = (int)InventoryType.Wearable;
702  pants.Folder = clothingFolder.ID;
703  pants.BasePermissions = (uint)PermissionMask.All;
704  pants.CurrentPermissions = (uint)PermissionMask.All;
705  pants.EveryOnePermissions = (uint)PermissionMask.All;
706  pants.GroupPermissions = (uint)PermissionMask.All;
707  pants.NextPermissions = (uint)PermissionMask.All;
708  pants.Flags = (uint)WearableType.Pants;
709  m_InventoryService.AddItem(pants);
710 
711  if (m_AvatarService != null)
712  {
713  m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default avatar entries for {0}", principalID);
714 
715  AvatarWearable[] wearables = new AvatarWearable[6];
716  wearables[AvatarWearable.EYES] = new AvatarWearable(eyes.ID, eyes.AssetID);
717  wearables[AvatarWearable.BODY] = new AvatarWearable(shape.ID, shape.AssetID);
718  wearables[AvatarWearable.SKIN] = new AvatarWearable(skin.ID, skin.AssetID);
719  wearables[AvatarWearable.HAIR] = new AvatarWearable(hair.ID, hair.AssetID);
720  wearables[AvatarWearable.SHIRT] = new AvatarWearable(shirt.ID, shirt.AssetID);
721  wearables[AvatarWearable.PANTS] = new AvatarWearable(pants.ID, pants.AssetID);
722 
724  for (int i = 0; i < 6; i++)
725  {
726  ap.SetWearable(i, wearables[i]);
727  }
728 
729  m_AvatarService.SetAppearance(principalID, ap);
730  }
731  }
732  }
733 }
OpenSim.Services.Interfaces.GridRegion GridRegion
List< UserAccount > GetUserAccountsWhere(UUID scopeID, string where)
OpenSim.Framework.PermissionMask PermissionMask
List< UserAccount > GetUserAccounts(UUID scopeID, string query)
Returns the list of avatars that matches both the search criterion and the scope ID passed ...
Contains the Avatar's Appearance and methods to manipulate the appearance.
UserAccount GetUserAccount(UUID scopeID, UUID principalID)
UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email)
Create a user
void HandleResetUserEmail(string module, string[] cmdparams)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString key
Definition: ICM_Api.cs:31
Dictionary< string, string > Data
void HandleResetUserPassword(string module, string[] cmdparams)
Inventory Item - contains all the properties associated with an individual inventory piece...
static ICommandConsole Instance
Definition: MainConsole.cs:35
bool StoreUserAccount(UserAccount data)
Store the data given, wich replaces the stored data, therefore must be complete.
void HandleShowAccount(string module, string[] cmdparams)
UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName)
UserAccount GetUserAccount(UUID scopeID, string email)
Dictionary< string, object > ServiceURLs
void HandleCreateUser(string module, string[] cmdparams)
Handle the create user command from the console.
void HandleSetUserLevel(string module, string[] cmdparams)