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.cs687
1 files changed, 687 insertions, 0 deletions
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
new file mode 100644
index 0000000..ad06300
--- /dev/null
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -0,0 +1,687 @@
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;
39
40namespace OpenSim.Services.UserAccountService
41{
42 public class UserAccountService : UserAccountServiceBase, IUserAccountService
43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 private static UserAccountService m_RootInstance;
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
52 protected IGridService m_GridService;
53 protected IAuthenticationService m_AuthenticationService;
54 protected IGridUserService m_GridUserService;
55 protected IInventoryService m_InventoryService;
56 protected IAvatarService m_AvatarService;
57
58 public UserAccountService(IConfigSource config)
59 : base(config)
60 {
61 IConfig userConfig = config.Configs["UserAccountService"];
62 if (userConfig == null)
63 throw new Exception("No UserAccountService configuration");
64
65 string gridServiceDll = userConfig.GetString("GridService", string.Empty);
66 if (gridServiceDll != string.Empty)
67 m_GridService = LoadPlugin<IGridService>(gridServiceDll, new Object[] { config });
68
69 string authServiceDll = userConfig.GetString("AuthenticationService", string.Empty);
70 if (authServiceDll != string.Empty)
71 m_AuthenticationService = LoadPlugin<IAuthenticationService>(authServiceDll, new Object[] { config });
72
73 string presenceServiceDll = userConfig.GetString("GridUserService", string.Empty);
74 if (presenceServiceDll != string.Empty)
75 m_GridUserService = LoadPlugin<IGridUserService>(presenceServiceDll, new Object[] { config });
76
77 string invServiceDll = userConfig.GetString("InventoryService", string.Empty);
78 if (invServiceDll != string.Empty)
79 m_InventoryService = LoadPlugin<IInventoryService>(invServiceDll, new Object[] { config });
80
81 string avatarServiceDll = userConfig.GetString("AvatarService", string.Empty);
82 if (avatarServiceDll != string.Empty)
83 m_AvatarService = LoadPlugin<IAvatarService>(avatarServiceDll, new Object[] { config });
84
85 m_CreateDefaultAvatarEntries = userConfig.GetBoolean("CreateDefaultAvatarEntries", false);
86
87 // In case there are several instances of this class in the same process,
88 // the console commands are only registered for the root instance
89 if (m_RootInstance == null && MainConsole.Instance != null)
90 {
91 m_RootInstance = this;
92 MainConsole.Instance.Commands.AddCommand("UserService", false,
93 "create user",
94 "create user [<first> [<last> [<pass> [<email> [<user id>]]]]]",
95 "Create a new user", HandleCreateUser);
96
97 MainConsole.Instance.Commands.AddCommand("UserService", false,
98 "reset user password",
99 "reset user password [<first> [<last> [<password>]]]",
100 "Reset a user password", HandleResetUserPassword);
101
102 MainConsole.Instance.Commands.AddCommand("UserService", false,
103 "set user level",
104 "set user level [<first> [<last> [<level>]]]",
105 "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, "
106 + "this account will be treated as god-moded. "
107 + "It will also affect the 'login level' command. ",
108 HandleSetUserLevel);
109
110 MainConsole.Instance.Commands.AddCommand("UserService", false,
111 "show account",
112 "show account <first> <last>",
113 "Show account details for the given user", HandleShowAccount);
114 }
115 }
116
117 #region IUserAccountService
118
119 public UserAccount GetUserAccount(UUID scopeID, string firstName,
120 string lastName)
121 {
122// m_log.DebugFormat(
123// "[USER ACCOUNT SERVICE]: Retrieving account by username for {0} {1}, scope {2}",
124// firstName, lastName, scopeID);
125
126 UserAccountData[] d;
127
128 if (scopeID != UUID.Zero)
129 {
130 d = m_Database.Get(
131 new string[] { "ScopeID", "FirstName", "LastName" },
132 new string[] { scopeID.ToString(), firstName, lastName });
133 if (d.Length < 1)
134 {
135 d = m_Database.Get(
136 new string[] { "ScopeID", "FirstName", "LastName" },
137 new string[] { UUID.Zero.ToString(), firstName, lastName });
138 }
139 }
140 else
141 {
142 d = m_Database.Get(
143 new string[] { "FirstName", "LastName" },
144 new string[] { firstName, lastName });
145 }
146
147 if (d.Length < 1)
148 return null;
149
150 return MakeUserAccount(d[0]);
151 }
152
153 private UserAccount MakeUserAccount(UserAccountData d)
154 {
155 UserAccount u = new UserAccount();
156 u.FirstName = d.FirstName;
157 u.LastName = d.LastName;
158 u.PrincipalID = d.PrincipalID;
159 u.ScopeID = d.ScopeID;
160 if (d.Data.ContainsKey("Email") && d.Data["Email"] != null)
161 u.Email = d.Data["Email"].ToString();
162 else
163 u.Email = string.Empty;
164 u.Created = Convert.ToInt32(d.Data["Created"].ToString());
165 if (d.Data.ContainsKey("UserTitle") && d.Data["UserTitle"] != null)
166 u.UserTitle = d.Data["UserTitle"].ToString();
167 else
168 u.UserTitle = string.Empty;
169 if (d.Data.ContainsKey("UserLevel") && d.Data["UserLevel"] != null)
170 Int32.TryParse(d.Data["UserLevel"], out u.UserLevel);
171 if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null)
172 Int32.TryParse(d.Data["UserFlags"], out u.UserFlags);
173 if (d.Data.ContainsKey("UserCountry") && d.Data["UserCountry"] != null)
174 u.UserCountry = d.Data["UserCountry"].ToString();
175 else
176 u.UserTitle = string.Empty;
177
178 if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null)
179 {
180 string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] { ' ' });
181 u.ServiceURLs = new Dictionary<string, object>();
182
183 foreach (string url in URLs)
184 {
185 string[] parts = url.Split(new char[] { '=' });
186
187 if (parts.Length != 2)
188 continue;
189
190 string name = System.Web.HttpUtility.UrlDecode(parts[0]);
191 string val = System.Web.HttpUtility.UrlDecode(parts[1]);
192
193 u.ServiceURLs[name] = val;
194 }
195 }
196 else
197 u.ServiceURLs = new Dictionary<string, object>();
198
199 return u;
200 }
201
202 public UserAccount GetUserAccount(UUID scopeID, string email)
203 {
204 UserAccountData[] d;
205
206 if (scopeID != UUID.Zero)
207 {
208 d = m_Database.Get(
209 new string[] { "ScopeID", "Email" },
210 new string[] { scopeID.ToString(), email });
211 if (d.Length < 1)
212 {
213 d = m_Database.Get(
214 new string[] { "ScopeID", "Email" },
215 new string[] { UUID.Zero.ToString(), email });
216 }
217 }
218 else
219 {
220 d = m_Database.Get(
221 new string[] { "Email" },
222 new string[] { email });
223 }
224
225 if (d.Length < 1)
226 return null;
227
228 return MakeUserAccount(d[0]);
229 }
230
231 public UserAccount GetUserAccount(UUID scopeID, UUID principalID)
232 {
233 UserAccountData[] d;
234
235 if (scopeID != UUID.Zero)
236 {
237 d = m_Database.Get(
238 new string[] { "ScopeID", "PrincipalID" },
239 new string[] { scopeID.ToString(), principalID.ToString() });
240 if (d.Length < 1)
241 {
242 d = m_Database.Get(
243 new string[] { "ScopeID", "PrincipalID" },
244 new string[] { UUID.Zero.ToString(), principalID.ToString() });
245 }
246 }
247 else
248 {
249 d = m_Database.Get(
250 new string[] { "PrincipalID" },
251 new string[] { principalID.ToString() });
252 }
253
254 if (d.Length < 1)
255 {
256 return null;
257 }
258
259 return MakeUserAccount(d[0]);
260 }
261
262 public bool StoreUserAccount(UserAccount data)
263 {
264// m_log.DebugFormat(
265// "[USER ACCOUNT SERVICE]: Storing user account for {0} {1} {2}, scope {3}",
266// data.FirstName, data.LastName, data.PrincipalID, data.ScopeID);
267
268 UserAccountData d = new UserAccountData();
269
270 d.FirstName = data.FirstName;
271 d.LastName = data.LastName;
272 d.PrincipalID = data.PrincipalID;
273 d.ScopeID = data.ScopeID;
274 d.Data = new Dictionary<string, string>();
275 d.Data["Email"] = data.Email;
276 d.Data["Created"] = data.Created.ToString();
277 d.Data["UserLevel"] = data.UserLevel.ToString();
278 d.Data["UserFlags"] = data.UserFlags.ToString();
279 if (data.UserTitle != null)
280 d.Data["UserTitle"] = data.UserTitle.ToString();
281
282 List<string> parts = new List<string>();
283
284 foreach (KeyValuePair<string, object> kvp in data.ServiceURLs)
285 {
286 string key = System.Web.HttpUtility.UrlEncode(kvp.Key);
287 string val = System.Web.HttpUtility.UrlEncode(kvp.Value.ToString());
288 parts.Add(key + "=" + val);
289 }
290
291 d.Data["ServiceURLs"] = string.Join(" ", parts.ToArray());
292
293 return m_Database.Store(d);
294 }
295
296 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
297 {
298 UserAccountData[] d = m_Database.GetUsers(scopeID, query.Trim());
299
300 if (d == null)
301 return new List<UserAccount>();
302
303 List<UserAccount> ret = new List<UserAccount>();
304
305 foreach (UserAccountData data in d)
306 ret.Add(MakeUserAccount(data));
307
308 return ret;
309 }
310
311 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where)
312 {
313 UserAccountData[] d = m_Database.GetUsersWhere(scopeID, where);
314
315 if (d == null)
316 return new List<UserAccount>();
317
318 List<UserAccount> ret = new List<UserAccount>();
319
320 foreach (UserAccountData data in d)
321 ret.Add(MakeUserAccount(data));
322
323 return ret;
324 }
325
326 #endregion
327
328 #region Console commands
329
330 /// <summary>
331 /// Handle the create user command from the console.
332 /// </summary>
333 /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
334 protected void HandleCreateUser(string module, string[] cmdparams)
335 {
336 string firstName;
337 string lastName;
338 string password;
339 string email;
340 string rawPrincipalId;
341
342 List<char> excluded = new List<char>(new char[]{' '});
343
344 if (cmdparams.Length < 3)
345 firstName = MainConsole.Instance.CmdPrompt("First name", "Default", excluded);
346 else firstName = cmdparams[2];
347
348 if (cmdparams.Length < 4)
349 lastName = MainConsole.Instance.CmdPrompt("Last name", "User", excluded);
350 else lastName = cmdparams[3];
351
352 if (cmdparams.Length < 5)
353 password = MainConsole.Instance.PasswdPrompt("Password");
354 else password = cmdparams[4];
355
356 if (cmdparams.Length < 6)
357 email = MainConsole.Instance.CmdPrompt("Email", "");
358 else email = cmdparams[5];
359
360 if (cmdparams.Length < 7)
361 rawPrincipalId = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString());
362 else
363 rawPrincipalId = cmdparams[6];
364
365 UUID principalId = UUID.Zero;
366 if (!UUID.TryParse(rawPrincipalId, out principalId))
367 throw new Exception(string.Format("ID {0} is not a valid UUID", rawPrincipalId));
368
369 CreateUser(UUID.Zero, principalId, firstName, lastName, password, email);
370 }
371
372 protected void HandleShowAccount(string module, string[] cmdparams)
373 {
374 if (cmdparams.Length != 4)
375 {
376 MainConsole.Instance.Output("Usage: show account <first-name> <last-name>");
377 return;
378 }
379
380 string firstName = cmdparams[2];
381 string lastName = cmdparams[3];
382
383 UserAccount ua = GetUserAccount(UUID.Zero, firstName, lastName);
384
385 if (ua == null)
386 {
387 MainConsole.Instance.OutputFormat("No user named {0} {1}", firstName, lastName);
388 return;
389 }
390
391 MainConsole.Instance.OutputFormat("Name: {0}", ua.Name);
392 MainConsole.Instance.OutputFormat("ID: {0}", ua.PrincipalID);
393 MainConsole.Instance.OutputFormat("Title: {0}", ua.UserTitle);
394 MainConsole.Instance.OutputFormat("E-mail: {0}", ua.Email);
395 MainConsole.Instance.OutputFormat("Created: {0}", Utils.UnixTimeToDateTime(ua.Created));
396 MainConsole.Instance.OutputFormat("Level: {0}", ua.UserLevel);
397 MainConsole.Instance.OutputFormat("Flags: {0}", ua.UserFlags);
398 foreach (KeyValuePair<string, Object> kvp in ua.ServiceURLs)
399 MainConsole.Instance.OutputFormat("{0}: {1}", kvp.Key, kvp.Value);
400 }
401
402 protected void HandleResetUserPassword(string module, string[] cmdparams)
403 {
404 string firstName;
405 string lastName;
406 string newPassword;
407
408 if (cmdparams.Length < 4)
409 firstName = MainConsole.Instance.CmdPrompt("First name");
410 else firstName = cmdparams[3];
411
412 if (cmdparams.Length < 5)
413 lastName = MainConsole.Instance.CmdPrompt("Last name");
414 else lastName = cmdparams[4];
415
416 if (cmdparams.Length < 6)
417 newPassword = MainConsole.Instance.PasswdPrompt("New password");
418 else newPassword = cmdparams[5];
419
420 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
421 if (account == null)
422 {
423 MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
424 return;
425 }
426
427 bool success = false;
428 if (m_AuthenticationService != null)
429 success = m_AuthenticationService.SetPassword(account.PrincipalID, newPassword);
430
431 if (!success)
432 MainConsole.Instance.OutputFormat("Unable to reset password for account {0} {1}.", firstName, lastName);
433 else
434 MainConsole.Instance.OutputFormat("Password reset for user {0} {1}", firstName, lastName);
435 }
436
437 protected void HandleSetUserLevel(string module, string[] cmdparams)
438 {
439 string firstName;
440 string lastName;
441 string rawLevel;
442 int level;
443
444 if (cmdparams.Length < 4)
445 firstName = MainConsole.Instance.CmdPrompt("First name");
446 else firstName = cmdparams[3];
447
448 if (cmdparams.Length < 5)
449 lastName = MainConsole.Instance.CmdPrompt("Last name");
450 else lastName = cmdparams[4];
451
452 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
453 if (account == null) {
454 MainConsole.Instance.OutputFormat("No such user");
455 return;
456 }
457
458 if (cmdparams.Length < 6)
459 rawLevel = MainConsole.Instance.CmdPrompt("User level");
460 else rawLevel = cmdparams[5];
461
462 if(int.TryParse(rawLevel, out level) == false) {
463 MainConsole.Instance.OutputFormat("Invalid user level");
464 return;
465 }
466
467 account.UserLevel = level;
468
469 bool success = StoreUserAccount(account);
470 if (!success)
471 MainConsole.Instance.OutputFormat("Unable to set user level for account {0} {1}.", firstName, lastName);
472 else
473 MainConsole.Instance.OutputFormat("User level set for user {0} {1} to {2}", firstName, lastName, level);
474 }
475
476 #endregion
477
478 /// <summary>
479 /// Create a user
480 /// </summary>
481 /// <param name="scopeID">Allows hosting of multiple grids in a single database. Normally left as UUID.Zero</param>
482 /// <param name="principalID">ID of the user</param>
483 /// <param name="firstName"></param>
484 /// <param name="lastName"></param>
485 /// <param name="password"></param>
486 /// <param name="email"></param>
487 public UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email)
488 {
489 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
490 if (null == account)
491 {
492 account = new UserAccount(UUID.Zero, principalID, firstName, lastName, email);
493 if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
494 {
495 account.ServiceURLs = new Dictionary<string, object>();
496 account.ServiceURLs["HomeURI"] = string.Empty;
497 account.ServiceURLs["GatekeeperURI"] = string.Empty;
498 account.ServiceURLs["InventoryServerURI"] = string.Empty;
499 account.ServiceURLs["AssetServerURI"] = string.Empty;
500 }
501
502 if (StoreUserAccount(account))
503 {
504 bool success;
505 if (m_AuthenticationService != null)
506 {
507 success = m_AuthenticationService.SetPassword(account.PrincipalID, password);
508 if (!success)
509 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.",
510 firstName, lastName);
511 }
512
513 GridRegion home = null;
514 if (m_GridService != null)
515 {
516 List<GridRegion> defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero);
517 if (defaultRegions != null && defaultRegions.Count >= 1)
518 home = defaultRegions[0];
519
520 if (m_GridUserService != null && home != null)
521 m_GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
522 else
523 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
524 firstName, lastName);
525 }
526 else
527 {
528 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
529 firstName, lastName);
530 }
531
532 if (m_InventoryService != null)
533 {
534 success = m_InventoryService.CreateUserInventory(account.PrincipalID);
535 if (!success)
536 {
537 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
538 firstName, lastName);
539 }
540 else
541 {
542 m_log.DebugFormat(
543 "[USER ACCOUNT SERVICE]; Created user inventory for {0} {1}", firstName, lastName);
544 }
545
546 if (m_CreateDefaultAvatarEntries)
547 CreateDefaultAppearanceEntries(account.PrincipalID);
548 }
549
550 m_log.InfoFormat(
551 "[USER ACCOUNT SERVICE]: Account {0} {1} {2} created successfully",
552 firstName, lastName, account.PrincipalID);
553 }
554 else
555 {
556 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Account creation failed for account {0} {1}", firstName, lastName);
557 }
558 }
559 else
560 {
561 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName);
562 }
563
564 return account;
565 }
566
567 private void CreateDefaultAppearanceEntries(UUID principalID)
568 {
569 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID);
570
571 InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, AssetType.Bodypart);
572
573 InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID);
574 eyes.AssetID = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7");
575 eyes.Name = "Default Eyes";
576 eyes.CreatorId = principalID.ToString();
577 eyes.AssetType = (int)AssetType.Bodypart;
578 eyes.InvType = (int)InventoryType.Wearable;
579 eyes.Folder = bodyPartsFolder.ID;
580 eyes.BasePermissions = (uint)PermissionMask.All;
581 eyes.CurrentPermissions = (uint)PermissionMask.All;
582 eyes.EveryOnePermissions = (uint)PermissionMask.All;
583 eyes.GroupPermissions = (uint)PermissionMask.All;
584 eyes.NextPermissions = (uint)PermissionMask.All;
585 eyes.Flags = (uint)WearableType.Eyes;
586 m_InventoryService.AddItem(eyes);
587
588 InventoryItemBase shape = new InventoryItemBase(UUID.Random(), principalID);
589 shape.AssetID = AvatarWearable.DEFAULT_BODY_ASSET;
590 shape.Name = "Default Shape";
591 shape.CreatorId = principalID.ToString();
592 shape.AssetType = (int)AssetType.Bodypart;
593 shape.InvType = (int)InventoryType.Wearable;
594 shape.Folder = bodyPartsFolder.ID;
595 shape.BasePermissions = (uint)PermissionMask.All;
596 shape.CurrentPermissions = (uint)PermissionMask.All;
597 shape.EveryOnePermissions = (uint)PermissionMask.All;
598 shape.GroupPermissions = (uint)PermissionMask.All;
599 shape.NextPermissions = (uint)PermissionMask.All;
600 shape.Flags = (uint)WearableType.Shape;
601 m_InventoryService.AddItem(shape);
602
603 InventoryItemBase skin = new InventoryItemBase(UUID.Random(), principalID);
604 skin.AssetID = AvatarWearable.DEFAULT_SKIN_ASSET;
605 skin.Name = "Default Skin";
606 skin.CreatorId = principalID.ToString();
607 skin.AssetType = (int)AssetType.Bodypart;
608 skin.InvType = (int)InventoryType.Wearable;
609 skin.Folder = bodyPartsFolder.ID;
610 skin.BasePermissions = (uint)PermissionMask.All;
611 skin.CurrentPermissions = (uint)PermissionMask.All;
612 skin.EveryOnePermissions = (uint)PermissionMask.All;
613 skin.GroupPermissions = (uint)PermissionMask.All;
614 skin.NextPermissions = (uint)PermissionMask.All;
615 skin.Flags = (uint)WearableType.Skin;
616 m_InventoryService.AddItem(skin);
617
618 InventoryItemBase hair = new InventoryItemBase(UUID.Random(), principalID);
619 hair.AssetID = AvatarWearable.DEFAULT_HAIR_ASSET;
620 hair.Name = "Default Hair";
621 hair.CreatorId = principalID.ToString();
622 hair.AssetType = (int)AssetType.Bodypart;
623 hair.InvType = (int)InventoryType.Wearable;
624 hair.Folder = bodyPartsFolder.ID;
625 hair.BasePermissions = (uint)PermissionMask.All;
626 hair.CurrentPermissions = (uint)PermissionMask.All;
627 hair.EveryOnePermissions = (uint)PermissionMask.All;
628 hair.GroupPermissions = (uint)PermissionMask.All;
629 hair.NextPermissions = (uint)PermissionMask.All;
630 hair.Flags = (uint)WearableType.Hair;
631 m_InventoryService.AddItem(hair);
632
633 InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, AssetType.Clothing);
634
635 InventoryItemBase shirt = new InventoryItemBase(UUID.Random(), principalID);
636 shirt.AssetID = AvatarWearable.DEFAULT_SHIRT_ASSET;
637 shirt.Name = "Default Shirt";
638 shirt.CreatorId = principalID.ToString();
639 shirt.AssetType = (int)AssetType.Clothing;
640 shirt.InvType = (int)InventoryType.Wearable;
641 shirt.Folder = clothingFolder.ID;
642 shirt.BasePermissions = (uint)PermissionMask.All;
643 shirt.CurrentPermissions = (uint)PermissionMask.All;
644 shirt.EveryOnePermissions = (uint)PermissionMask.All;
645 shirt.GroupPermissions = (uint)PermissionMask.All;
646 shirt.NextPermissions = (uint)PermissionMask.All;
647 shirt.Flags = (uint)WearableType.Shirt;
648 m_InventoryService.AddItem(shirt);
649
650 InventoryItemBase pants = new InventoryItemBase(UUID.Random(), principalID);
651 pants.AssetID = AvatarWearable.DEFAULT_PANTS_ASSET;
652 pants.Name = "Default Pants";
653 pants.CreatorId = principalID.ToString();
654 pants.AssetType = (int)AssetType.Clothing;
655 pants.InvType = (int)InventoryType.Wearable;
656 pants.Folder = clothingFolder.ID;
657 pants.BasePermissions = (uint)PermissionMask.All;
658 pants.CurrentPermissions = (uint)PermissionMask.All;
659 pants.EveryOnePermissions = (uint)PermissionMask.All;
660 pants.GroupPermissions = (uint)PermissionMask.All;
661 pants.NextPermissions = (uint)PermissionMask.All;
662 pants.Flags = (uint)WearableType.Pants;
663 m_InventoryService.AddItem(pants);
664
665 if (m_AvatarService != null)
666 {
667 m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default avatar entries for {0}", principalID);
668
669 AvatarWearable[] wearables = new AvatarWearable[6];
670 wearables[AvatarWearable.EYES] = new AvatarWearable(eyes.ID, eyes.AssetID);
671 wearables[AvatarWearable.BODY] = new AvatarWearable(shape.ID, shape.AssetID);
672 wearables[AvatarWearable.SKIN] = new AvatarWearable(skin.ID, skin.AssetID);
673 wearables[AvatarWearable.HAIR] = new AvatarWearable(hair.ID, hair.AssetID);
674 wearables[AvatarWearable.SHIRT] = new AvatarWearable(shirt.ID, shirt.AssetID);
675 wearables[AvatarWearable.PANTS] = new AvatarWearable(pants.ID, pants.AssetID);
676
677 AvatarAppearance ap = new AvatarAppearance();
678 for (int i = 0; i < 6; i++)
679 {
680 ap.SetWearable(i, wearables[i]);
681 }
682
683 m_AvatarService.SetAppearance(principalID, ap);
684 }
685 }
686 }
687} \ No newline at end of file