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.cs714
1 files changed, 714 insertions, 0 deletions
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
new file mode 100644
index 0000000..2e19ece
--- /dev/null
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -0,0 +1,714 @@
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Data;
35using OpenSim.Framework;
36using OpenSim.Services.Interfaces;
37using OpenSim.Framework.Console;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using PermissionMask = OpenSim.Framework.PermissionMask;
40
41namespace OpenSim.Services.UserAccountService
42{
43 public class UserAccountService : UserAccountServiceBase, IUserAccountService
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private static UserAccountService m_RootInstance;
47
48 /// <summary>
49 /// Should we create default entries (minimum body parts/clothing, avatar wearable entries) for a new avatar?
50 /// </summary>
51 private bool m_CreateDefaultAvatarEntries;
52
53 protected IGridService m_GridService;
54 protected IAuthenticationService m_AuthenticationService;
55 protected IGridUserService m_GridUserService;
56 protected IInventoryService m_InventoryService;
57 protected IAvatarService m_AvatarService;
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
180 if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null)
181 {
182 string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] { ' ' });
183 u.ServiceURLs = new Dictionary<string, object>();
184
185 foreach (string url in URLs)
186 {
187 string[] parts = url.Split(new char[] { '=' });
188
189 if (parts.Length != 2)
190 continue;
191
192 string name = System.Web.HttpUtility.UrlDecode(parts[0]);
193 string val = System.Web.HttpUtility.UrlDecode(parts[1]);
194
195 u.ServiceURLs[name] = val;
196 }
197 }
198 else
199 u.ServiceURLs = new Dictionary<string, object>();
200
201 return u;
202 }
203
204 public UserAccount GetUserAccount(UUID scopeID, string email)
205 {
206 UserAccountData[] d;
207
208 if (scopeID != UUID.Zero)
209 {
210 d = m_Database.Get(
211 new string[] { "ScopeID", "Email" },
212 new string[] { scopeID.ToString(), email });
213 if (d.Length < 1)
214 {
215 d = m_Database.Get(
216 new string[] { "ScopeID", "Email" },
217 new string[] { UUID.Zero.ToString(), email });
218 }
219 }
220 else
221 {
222 d = m_Database.Get(
223 new string[] { "Email" },
224 new string[] { email });
225 }
226
227 if (d.Length < 1)
228 return null;
229
230 return MakeUserAccount(d[0]);
231 }
232
233 public UserAccount GetUserAccount(UUID scopeID, UUID principalID)
234 {
235 UserAccountData[] d;
236
237 if (scopeID != UUID.Zero)
238 {
239 d = m_Database.Get(
240 new string[] { "ScopeID", "PrincipalID" },
241 new string[] { scopeID.ToString(), principalID.ToString() });
242 if (d.Length < 1)
243 {
244 d = m_Database.Get(
245 new string[] { "ScopeID", "PrincipalID" },
246 new string[] { UUID.Zero.ToString(), principalID.ToString() });
247 }
248 }
249 else
250 {
251 d = m_Database.Get(
252 new string[] { "PrincipalID" },
253 new string[] { principalID.ToString() });
254 }
255
256 if (d.Length < 1)
257 {
258 return null;
259 }
260
261 return MakeUserAccount(d[0]);
262 }
263
264 public void InvalidateCache(UUID userID)
265 {
266 }
267
268 public bool StoreUserAccount(UserAccount data)
269 {
270// m_log.DebugFormat(
271// "[USER ACCOUNT SERVICE]: Storing user account for {0} {1} {2}, scope {3}",
272// data.FirstName, data.LastName, data.PrincipalID, data.ScopeID);
273
274 UserAccountData d = new UserAccountData();
275
276 d.FirstName = data.FirstName;
277 d.LastName = data.LastName;
278 d.PrincipalID = data.PrincipalID;
279 d.ScopeID = data.ScopeID;
280 d.Data = new Dictionary<string, string>();
281 d.Data["Email"] = data.Email;
282 d.Data["Created"] = data.Created.ToString();
283 d.Data["UserLevel"] = data.UserLevel.ToString();
284 d.Data["UserFlags"] = data.UserFlags.ToString();
285 if (data.UserTitle != null)
286 d.Data["UserTitle"] = data.UserTitle.ToString();
287
288 List<string> parts = new List<string>();
289
290 foreach (KeyValuePair<string, object> kvp in data.ServiceURLs)
291 {
292 string key = System.Web.HttpUtility.UrlEncode(kvp.Key);
293 string val = System.Web.HttpUtility.UrlEncode(kvp.Value.ToString());
294 parts.Add(key + "=" + val);
295 }
296
297 d.Data["ServiceURLs"] = string.Join(" ", parts.ToArray());
298
299 return m_Database.Store(d);
300 }
301
302 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
303 {
304 UserAccountData[] d = m_Database.GetUsers(scopeID, query);
305
306 if (d == null)
307 return new List<UserAccount>();
308
309 List<UserAccount> ret = new List<UserAccount>();
310
311 foreach (UserAccountData data in d)
312 ret.Add(MakeUserAccount(data));
313
314 return ret;
315 }
316
317 #endregion
318
319 #region Console commands
320
321 /// <summary>
322 /// Handle the create user command from the console.
323 /// </summary>
324 /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
325 protected void HandleCreateUser(string module, string[] cmdparams)
326 {
327 string firstName;
328 string lastName;
329 string password;
330 string email;
331 string rawPrincipalId;
332
333 List<char> excluded = new List<char>(new char[]{' '});
334
335 if (cmdparams.Length < 3)
336 firstName = MainConsole.Instance.CmdPrompt("First name", "Default", excluded);
337 else firstName = cmdparams[2];
338
339 if (cmdparams.Length < 4)
340 lastName = MainConsole.Instance.CmdPrompt("Last name", "User", excluded);
341 else lastName = cmdparams[3];
342
343 if (cmdparams.Length < 5)
344 password = MainConsole.Instance.PasswdPrompt("Password");
345 else password = cmdparams[4];
346
347 if (cmdparams.Length < 6)
348 email = MainConsole.Instance.CmdPrompt("Email", "");
349 else email = cmdparams[5];
350
351 if (cmdparams.Length < 7)
352 rawPrincipalId = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString());
353 else
354 rawPrincipalId = cmdparams[6];
355
356 UUID principalId = UUID.Zero;
357 if (!UUID.TryParse(rawPrincipalId, out principalId))
358 throw new Exception(string.Format("ID {0} is not a valid UUID", rawPrincipalId));
359
360 CreateUser(UUID.Zero, principalId, firstName, lastName, password, email);
361 }
362
363 protected void HandleShowAccount(string module, string[] cmdparams)
364 {
365 if (cmdparams.Length != 4)
366 {
367 MainConsole.Instance.Output("Usage: show account <first-name> <last-name>");
368 return;
369 }
370
371 string firstName = cmdparams[2];
372 string lastName = cmdparams[3];
373
374 UserAccount ua = GetUserAccount(UUID.Zero, firstName, lastName);
375
376 if (ua == null)
377 {
378 MainConsole.Instance.OutputFormat("No user named {0} {1}", firstName, lastName);
379 return;
380 }
381
382 MainConsole.Instance.OutputFormat("Name: {0}", ua.Name);
383 MainConsole.Instance.OutputFormat("ID: {0}", ua.PrincipalID);
384 MainConsole.Instance.OutputFormat("Title: {0}", ua.UserTitle);
385 MainConsole.Instance.OutputFormat("E-mail: {0}", ua.Email);
386 MainConsole.Instance.OutputFormat("Created: {0}", Utils.UnixTimeToDateTime(ua.Created));
387 MainConsole.Instance.OutputFormat("Level: {0}", ua.UserLevel);
388 MainConsole.Instance.OutputFormat("Flags: {0}", ua.UserFlags);
389 foreach (KeyValuePair<string, Object> kvp in ua.ServiceURLs)
390 MainConsole.Instance.OutputFormat("{0}: {1}", kvp.Key, kvp.Value);
391 }
392
393 protected void HandleResetUserPassword(string module, string[] cmdparams)
394 {
395 string firstName;
396 string lastName;
397 string newPassword;
398
399 if (cmdparams.Length < 4)
400 firstName = MainConsole.Instance.CmdPrompt("First name");
401 else firstName = cmdparams[3];
402
403 if (cmdparams.Length < 5)
404 lastName = MainConsole.Instance.CmdPrompt("Last name");
405 else lastName = cmdparams[4];
406
407 if (cmdparams.Length < 6)
408 newPassword = MainConsole.Instance.PasswdPrompt("New password");
409 else newPassword = cmdparams[5];
410
411 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
412 if (account == null)
413 {
414 MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
415 return;
416 }
417
418 bool success = false;
419 if (m_AuthenticationService != null)
420 success = m_AuthenticationService.SetPassword(account.PrincipalID, newPassword);
421
422 if (!success)
423 MainConsole.Instance.OutputFormat("Unable to reset password for account {0} {1}.", firstName, lastName);
424 else
425 MainConsole.Instance.OutputFormat("Password reset for user {0} {1}", firstName, lastName);
426 }
427
428 protected void HandleResetUserEmail(string module, string[] cmdparams)
429 {
430 string firstName;
431 string lastName;
432 string newEmail;
433
434 if (cmdparams.Length < 4)
435 firstName = MainConsole.Instance.CmdPrompt("First name");
436 else firstName = cmdparams[3];
437
438 if (cmdparams.Length < 5)
439 lastName = MainConsole.Instance.CmdPrompt("Last name");
440 else lastName = cmdparams[4];
441
442 if (cmdparams.Length < 6)
443 newEmail = MainConsole.Instance.PasswdPrompt("New Email");
444 else newEmail = cmdparams[5];
445
446 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
447 if (account == null)
448 {
449 MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
450 return;
451 }
452
453 bool success = false;
454
455 account.Email = newEmail;
456
457 success = StoreUserAccount(account);
458 if (!success)
459 MainConsole.Instance.OutputFormat("Unable to set Email for account {0} {1}.", firstName, lastName);
460 else
461 MainConsole.Instance.OutputFormat("User Email set for user {0} {1} to {2}", firstName, lastName, account.Email);
462 }
463
464
465 protected void HandleSetUserLevel(string module, string[] cmdparams)
466 {
467 string firstName;
468 string lastName;
469 string rawLevel;
470 int level;
471
472 if (cmdparams.Length < 4)
473 firstName = MainConsole.Instance.CmdPrompt("First name");
474 else firstName = cmdparams[3];
475
476 if (cmdparams.Length < 5)
477 lastName = MainConsole.Instance.CmdPrompt("Last name");
478 else lastName = cmdparams[4];
479
480 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
481 if (account == null) {
482 MainConsole.Instance.OutputFormat("No such user");
483 return;
484 }
485
486 if (cmdparams.Length < 6)
487 rawLevel = MainConsole.Instance.CmdPrompt("User level");
488 else rawLevel = cmdparams[5];
489
490 if(int.TryParse(rawLevel, out level) == false) {
491 MainConsole.Instance.OutputFormat("Invalid user level");
492 return;
493 }
494
495 account.UserLevel = level;
496
497 bool success = StoreUserAccount(account);
498 if (!success)
499 MainConsole.Instance.OutputFormat("Unable to set user level for account {0} {1}.", firstName, lastName);
500 else
501 MainConsole.Instance.OutputFormat("User level set for user {0} {1} to {2}", firstName, lastName, level);
502 }
503
504 #endregion
505
506 /// <summary>
507 /// Create a user
508 /// </summary>
509 /// <param name="scopeID">Allows hosting of multiple grids in a single database. Normally left as UUID.Zero</param>
510 /// <param name="principalID">ID of the user</param>
511 /// <param name="firstName"></param>
512 /// <param name="lastName"></param>
513 /// <param name="password"></param>
514 /// <param name="email"></param>
515 public UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email)
516 {
517 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
518 if (null == account)
519 {
520 account = new UserAccount(UUID.Zero, principalID, firstName, lastName, email);
521 if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
522 {
523 account.ServiceURLs = new Dictionary<string, object>();
524 account.ServiceURLs["HomeURI"] = string.Empty;
525 account.ServiceURLs["InventoryServerURI"] = string.Empty;
526 account.ServiceURLs["AssetServerURI"] = string.Empty;
527 }
528
529 if (StoreUserAccount(account))
530 {
531 bool success;
532 if (m_AuthenticationService != null)
533 {
534 success = m_AuthenticationService.SetPassword(account.PrincipalID, password);
535 if (!success)
536 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.",
537 firstName, lastName);
538 }
539
540 GridRegion home = null;
541 if (m_GridService != null)
542 {
543 List<GridRegion> defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero);
544 if (defaultRegions != null && defaultRegions.Count >= 1)
545 home = defaultRegions[0];
546
547 if (m_GridUserService != null && home != null)
548 m_GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
549 else
550 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
551 firstName, lastName);
552 }
553 else
554 {
555 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
556 firstName, lastName);
557 }
558
559 if (m_InventoryService != null)
560 {
561 success = m_InventoryService.CreateUserInventory(account.PrincipalID);
562 if (!success)
563 {
564 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
565 firstName, lastName);
566 }
567 else
568 {
569 m_log.DebugFormat(
570 "[USER ACCOUNT SERVICE]: Created user inventory for {0} {1}", firstName, lastName);
571 }
572
573 if (m_CreateDefaultAvatarEntries)
574 CreateDefaultAppearanceEntries(account.PrincipalID);
575 }
576
577 m_log.InfoFormat(
578 "[USER ACCOUNT SERVICE]: Account {0} {1} {2} created successfully",
579 firstName, lastName, account.PrincipalID);
580 }
581 else
582 {
583 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Account creation failed for account {0} {1}", firstName, lastName);
584 }
585 }
586 else
587 {
588 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName);
589 }
590
591 return account;
592 }
593
594 protected void CreateDefaultAppearanceEntries(UUID principalID)
595 {
596 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID);
597
598 InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, FolderType.BodyPart);
599
600 InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID);
601 eyes.AssetID = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7");
602 eyes.Name = "Default Eyes";
603 eyes.CreatorId = principalID.ToString();
604 eyes.AssetType = (int)AssetType.Bodypart;
605 eyes.InvType = (int)InventoryType.Wearable;
606 eyes.Folder = bodyPartsFolder.ID;
607 eyes.BasePermissions = (uint)PermissionMask.All;
608 eyes.CurrentPermissions = (uint)PermissionMask.All;
609 eyes.EveryOnePermissions = (uint)PermissionMask.All;
610 eyes.GroupPermissions = (uint)PermissionMask.All;
611 eyes.NextPermissions = (uint)PermissionMask.All;
612 eyes.Flags = (uint)WearableType.Eyes;
613 m_InventoryService.AddItem(eyes);
614
615 InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID);
616 shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET;
617 shape.Name = "Default Shape";
618 shape.CreatorId = principalID.ToString();
619 shape.AssetType = (int)AssetType.Bodypart;
620 shape.InvType = (int)InventoryType.Wearable;
621 shape.Folder = bodyPartsFolder.ID;
622 shape.BasePermissions = (uint)PermissionMask.All;
623 shape.CurrentPermissions = (uint)PermissionMask.All;
624 shape.EveryOnePermissions = (uint)PermissionMask.All;
625 shape.GroupPermissions = (uint)PermissionMask.All;
626 shape.NextPermissions = (uint)PermissionMask.All;
627 shape.Flags = (uint)WearableType.Shape;
628 m_InventoryService.AddItem(shape);
629
630 InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID);
631 skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET;
632 skin.Name = "Default Skin";
633 skin.CreatorId = principalID.ToString();
634 skin.AssetType = (int)AssetType.Bodypart;
635 skin.InvType = (int)InventoryType.Wearable;
636 skin.Folder = bodyPartsFolder.ID;
637 skin.BasePermissions = (uint)PermissionMask.All;
638 skin.CurrentPermissions = (uint)PermissionMask.All;
639 skin.EveryOnePermissions = (uint)PermissionMask.All;
640 skin.GroupPermissions = (uint)PermissionMask.All;
641 skin.NextPermissions = (uint)PermissionMask.All;
642 skin.Flags = (uint)WearableType.Skin;
643 m_InventoryService.AddItem(skin);
644
645 InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID);
646 hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET;
647 hair.Name = "Default Hair";
648 hair.CreatorId = principalID.ToString();
649 hair.AssetType = (int)AssetType.Bodypart;
650 hair.InvType = (int)InventoryType.Wearable;
651 hair.Folder = bodyPartsFolder.ID;
652 hair.BasePermissions = (uint)PermissionMask.All;
653 hair.CurrentPermissions = (uint)PermissionMask.All;
654 hair.EveryOnePermissions = (uint)PermissionMask.All;
655 hair.GroupPermissions = (uint)PermissionMask.All;
656 hair.NextPermissions = (uint)PermissionMask.All;
657 hair.Flags = (uint)WearableType.Hair;
658 m_InventoryService.AddItem(hair);
659
660 InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, FolderType.Clothing);
661
662 InventoryItemBase shirt = new InventoryItemBase(UUID.Random(), principalID);
663 shirt.AssetID = AvatarWearable.DEFAULT_SHIRT_ASSET;
664 shirt.Name = "Default Shirt";
665 shirt.CreatorId = principalID.ToString();
666 shirt.AssetType = (int)AssetType.Clothing;
667 shirt.InvType = (int)InventoryType.Wearable;
668 shirt.Folder = clothingFolder.ID;
669 shirt.BasePermissions = (uint)PermissionMask.All;
670 shirt.CurrentPermissions = (uint)PermissionMask.All;
671 shirt.EveryOnePermissions = (uint)PermissionMask.All;
672 shirt.GroupPermissions = (uint)PermissionMask.All;
673 shirt.NextPermissions = (uint)PermissionMask.All;
674 shirt.Flags = (uint)WearableType.Shirt;
675 m_InventoryService.AddItem(shirt);
676
677 InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID);
678 pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET;
679 pants.Name = "Default Pants";
680 pants.CreatorId = principalID.ToString();
681 pants.AssetType = (int)AssetType.Clothing;
682 pants.InvType = (int)InventoryType.Wearable;
683 pants.Folder = clothingFolder.ID;
684 pants.BasePermissions = (uint)PermissionMask.All;
685 pants.CurrentPermissions = (uint)PermissionMask.All;
686 pants.EveryOnePermissions = (uint)PermissionMask.All;
687 pants.GroupPermissions = (uint)PermissionMask.All;
688 pants.NextPermissions = (uint)PermissionMask.All;
689 pants.Flags = (uint)WearableType.Pants;
690 m_InventoryService.AddItem(pants);
691
692 if (m_AvatarService != null)
693 {
694 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default avatar entries for {0}", principalID);
695
696 AvatarWearable[] wearables = new AvatarWearable[6];
697 wearables[AvatarWearable.EYES] = new AvatarWearable(eyes.ID, eyes.AssetID);
698 wearables[AvatarWearable.BODY] = new AvatarWearable(shape.ID, shape.AssetID);
699 wearables[AvatarWearable.SKIN] = new AvatarWearable(skin.ID, skin.AssetID);
700 wearables[AvatarWearable.HAIR] = new AvatarWearable(hair.ID, hair.AssetID);
701 wearables[AvatarWearable.SHIRT] = new AvatarWearable(shirt.ID, shirt.AssetID);
702 wearables[AvatarWearable.PANTS] = new AvatarWearable(pants.ID, pants.AssetID);
703
704 AvatarAppearance ap = new AvatarAppearance();
705 for (int i = 0; i < 6; i++)
706 {
707 ap.SetWearable(i, wearables[i]);
708 }
709
710 m_AvatarService.SetAppearance(principalID, ap);
711 }
712 }
713 }
714}