aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs945
1 files changed, 606 insertions, 339 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index ed43363..03b8e9f 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -1116,6 +1116,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1116 string firstname = (string) requestData["user_firstname"]; 1116 string firstname = (string) requestData["user_firstname"];
1117 string lastname = (string) requestData["user_lastname"]; 1117 string lastname = (string) requestData["user_lastname"];
1118 string passwd = (string) requestData["user_password"]; 1118 string passwd = (string) requestData["user_password"];
1119
1119 uint regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); 1120 uint regX = Convert.ToUInt32((Int32) requestData["start_region_x"]);
1120 uint regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); 1121 uint regY = Convert.ToUInt32((Int32) requestData["start_region_y"]);
1121 1122
@@ -1123,28 +1124,25 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1123 if (requestData.Contains("user_email")) 1124 if (requestData.Contains("user_email"))
1124 email = (string)requestData["user_email"]; 1125 email = (string)requestData["user_email"];
1125 1126
1126 UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; 1127 Scene scene = m_app.SceneManager.CurrentOrFirstScene;
1127 1128 UUID scopeID = scene.RegionInfo.ScopeID;
1128 UserAccount account = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, firstname, lastname);
1129
1130 if (null != account)
1131 throw new Exception(String.Format("Account {0} {1} already exists", firstname, lastname));
1132 1129
1133 account = new UserAccount(scopeID, firstname, lastname, email); 1130 UserAccount account = CreateUser(scopeID, firstname, lastname, passwd, email);
1134 1131
1135 bool success = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.StoreUserAccount(account); 1132 if (null == account)
1136
1137 if (!success)
1138 throw new Exception(String.Format("failed to create new user {0} {1}", 1133 throw new Exception(String.Format("failed to create new user {0} {1}",
1139 firstname, lastname)); 1134 firstname, lastname));
1140 1135
1141 // Store the password 1136 // Set home position
1142 m_app.SceneManager.CurrentOrFirstScene.AuthenticationService.SetPassword(account.PrincipalID, passwd);
1143 1137
1144 GridRegion home = m_app.SceneManager.CurrentOrFirstScene.GridService.GetRegionByPosition(scopeID, 1138 GridRegion home = scene.GridService.GetRegionByPosition(scopeID,
1145 (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize)); 1139 (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize));
1146 if (home == null) 1140 if (null == home) {
1147 m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstname, lastname); 1141 m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstname, lastname);
1142 } else {
1143 scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
1144 m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, firstname, lastname);
1145 }
1148 1146
1149 // Establish the avatar's initial appearance 1147 // Establish the avatar's initial appearance
1150 1148
@@ -1287,9 +1285,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1287 /// <item><term>start_region_y</term> 1285 /// <item><term>start_region_y</term>
1288 /// <description>avatar's start region coordinates, Y 1286 /// <description>avatar's start region coordinates, Y
1289 /// value (changeable)</description></item> 1287 /// value (changeable)</description></item>
1290 /// <item><term>about_real_world</term> 1288 /// <item><term>about_real_world (not implemented yet)</term>
1291 /// <description>"about" text of avatar owner (changeable)</description></item> 1289 /// <description>"about" text of avatar owner (changeable)</description></item>
1292 /// <item><term>about_virtual_world</term> 1290 /// <item><term>about_virtual_world (not implemented yet)</term>
1293 /// <description>"about" text of avatar (changeable)</description></item> 1291 /// <description>"about" text of avatar (changeable)</description></item>
1294 /// </list> 1292 /// </list>
1295 /// 1293 ///
@@ -1300,6 +1298,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1300 /// <description>true or false</description></item> 1298 /// <description>true or false</description></item>
1301 /// <item><term>error</term> 1299 /// <item><term>error</term>
1302 /// <description>error message if success is false</description></item> 1300 /// <description>error message if success is false</description></item>
1301 /// <item><term>avatar_uuid</term>
1302 /// <description>UUID of the updated avatar
1303 /// account; UUID.Zero if failed.
1304 /// </description></item>
1303 /// </list> 1305 /// </list>
1304 /// </remarks> 1306 /// </remarks>
1305 1307
@@ -1307,31 +1309,34 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1307 { 1309 {
1308 m_log.Info("[RADMIN]: UpdateUserAccount: new request"); 1310 m_log.Info("[RADMIN]: UpdateUserAccount: new request");
1309 m_log.Warn("[RADMIN]: This method needs update for 0.7"); 1311 m_log.Warn("[RADMIN]: This method needs update for 0.7");
1312
1313 FailIfRemoteAdminDisabled("UpdateUserAccount");
1314
1310 XmlRpcResponse response = new XmlRpcResponse(); 1315 XmlRpcResponse response = new XmlRpcResponse();
1311 Hashtable responseData = new Hashtable(); 1316 Hashtable responseData = new Hashtable();
1312 1317
1313 //lock (rslock) 1318 lock (rslock)
1314 //{ 1319 {
1315 // try 1320 try
1316 // { 1321 {
1317 // Hashtable requestData = (Hashtable) request.Params[0]; 1322 Hashtable requestData = (Hashtable) request.Params[0];
1318 1323
1319 // // check completeness 1324 // check completeness
1320 // checkStringParameters(request, new string[] { 1325 checkStringParameters(request, new string[] {
1321 // "password", "user_firstname", 1326 "password", "user_firstname",
1322 // "user_lastname"}); 1327 "user_lastname"});
1323 1328
1324 // // check password 1329 // check password
1325 // if (!String.IsNullOrEmpty(m_requiredPassword) && 1330 if (!String.IsNullOrEmpty(m_requiredPassword) &&
1326 // (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password"); 1331 (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password");
1327 1332
1328 // // do the job 1333 // do the job
1329 // string firstname = (string) requestData["user_firstname"]; 1334 string firstname = (string) requestData["user_firstname"];
1330 // string lastname = (string) requestData["user_lastname"]; 1335 string lastname = (string) requestData["user_lastname"];
1331 1336
1332 // string passwd = String.Empty; 1337 string passwd = String.Empty;
1333 // uint? regX = null; 1338 uint? regX = null;
1334 // uint? regY = null; 1339 uint? regY = null;
1335 // uint? ulaX = null; 1340 // uint? ulaX = null;
1336 // uint? ulaY = null; 1341 // uint? ulaY = null;
1337 // uint? ulaZ = null; 1342 // uint? ulaZ = null;
@@ -1341,11 +1346,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1341 // string aboutFirstLive = String.Empty; 1346 // string aboutFirstLive = String.Empty;
1342 // string aboutAvatar = String.Empty; 1347 // string aboutAvatar = String.Empty;
1343 1348
1344 // if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"]; 1349 if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"];
1345 // if (requestData.ContainsKey("start_region_x")) 1350 if (requestData.ContainsKey("start_region_x"))
1346 // regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); 1351 regX = Convert.ToUInt32((Int32) requestData["start_region_x"]);
1347 // if (requestData.ContainsKey("start_region_y")) 1352 if (requestData.ContainsKey("start_region_y"))
1348 // regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); 1353 regY = Convert.ToUInt32((Int32) requestData["start_region_y"]);
1349 1354
1350 // if (requestData.ContainsKey("start_lookat_x")) 1355 // if (requestData.ContainsKey("start_lookat_x"))
1351 // ulaX = Convert.ToUInt32((Int32) requestData["start_lookat_x"]); 1356 // ulaX = Convert.ToUInt32((Int32) requestData["start_lookat_x"]);
@@ -1365,21 +1370,18 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1365 // if (requestData.ContainsKey("about_virtual_world")) 1370 // if (requestData.ContainsKey("about_virtual_world"))
1366 // aboutAvatar = (string)requestData["about_virtual_world"]; 1371 // aboutAvatar = (string)requestData["about_virtual_world"];
1367 1372
1368 // UserProfileData userProfile 1373 Scene scene = m_app.SceneManager.CurrentOrFirstScene;
1369 // = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); 1374 UUID scopeID = scene.RegionInfo.ScopeID;
1370 1375 UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, firstname, lastname);
1371 // if (null == userProfile)
1372 // throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname));
1373 1376
1374 // if (!String.IsNullOrEmpty(passwd)) 1377 if (null == account)
1375 // { 1378 throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname));
1376 // m_log.DebugFormat("[RADMIN]: UpdateUserAccount: updating password for avatar {0} {1}", firstname, lastname);
1377 // string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty);
1378 // userProfile.PasswordHash = md5PasswdHash;
1379 // }
1380 1379
1381 // if (null != regX) userProfile.HomeRegionX = (uint) regX; 1380 if (!String.IsNullOrEmpty(passwd))
1382 // if (null != regY) userProfile.HomeRegionY = (uint) regY; 1381 {
1382 m_log.DebugFormat("[RADMIN]: UpdateUserAccount: updating password for avatar {0} {1}", firstname, lastname);
1383 ChangeUserPassword(firstname, lastname, passwd);
1384 }
1383 1385
1384 // if (null != usaX) userProfile.HomeLocationX = (uint) usaX; 1386 // if (null != usaX) userProfile.HomeLocationX = (uint) usaX;
1385 // if (null != usaY) userProfile.HomeLocationY = (uint) usaY; 1387 // if (null != usaY) userProfile.HomeLocationY = (uint) usaY;
@@ -1392,35 +1394,48 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1392 // if (String.Empty != aboutFirstLive) userProfile.FirstLifeAboutText = aboutFirstLive; 1394 // if (String.Empty != aboutFirstLive) userProfile.FirstLifeAboutText = aboutFirstLive;
1393 // if (String.Empty != aboutAvatar) userProfile.AboutText = aboutAvatar; 1395 // if (String.Empty != aboutAvatar) userProfile.AboutText = aboutAvatar;
1394 1396
1395 // // User has been created. Now establish gender and appearance. 1397 // Set home position
1396 1398
1397 // updateUserAppearance(responseData, requestData, userProfile.ID); 1399 if ((null != regX) && (null != regY))
1400 {
1401 GridRegion home = scene.GridService.GetRegionByPosition(scopeID,
1402 (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize));
1403 if (null == home) {
1404 m_log.WarnFormat("[RADMIN]: Unable to set home region for updated user account {0} {1}", firstname, lastname);
1405 } else {
1406 scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
1407 m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, firstname, lastname);
1408 }
1409 }
1398 1410
1399 // if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile)) 1411 // User has been created. Now establish gender and appearance.
1400 // throw new Exception("did not manage to update user profile");
1401 1412
1402 // responseData["success"] = true; 1413 updateUserAppearance(responseData, requestData, account.PrincipalID);
1403 1414
1404 // response.Value = responseData; 1415 responseData["success"] = true;
1416 responseData["avatar_uuid"] = account.PrincipalID.ToString();
1405 1417
1406 // m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", 1418 response.Value = responseData;
1407 // firstname, lastname,
1408 // userProfile.ID);
1409 // }
1410 // catch (Exception e)
1411 // {
1412 // m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message);
1413 // m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString());
1414 1419
1415 // responseData["success"] = false; 1420 m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}",
1416 // responseData["error"] = e.Message; 1421 firstname, lastname,
1422 account.PrincipalID);
1423 }
1424 catch (Exception e)
1425 {
1417 1426
1418 // response.Value = responseData; 1427 m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message);
1419 // } 1428 m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString());
1420 //}
1421 1429
1422 m_log.Info("[RADMIN]: UpdateUserAccount: request complete"); 1430 responseData["success"] = false;
1423 return response; 1431 responseData["avatar_uuid"] = UUID.Zero.ToString();
1432 responseData["error"] = e.Message;
1433
1434 response.Value = responseData;
1435 }
1436 m_log.Info("[RADMIN]: UpdateUserAccount: request complete");
1437 return response;
1438 }
1424 } 1439 }
1425 1440
1426 /// <summary> 1441 /// <summary>
@@ -1434,73 +1449,74 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1434 private void updateUserAppearance(Hashtable responseData, Hashtable requestData, UUID userid) 1449 private void updateUserAppearance(Hashtable responseData, Hashtable requestData, UUID userid)
1435 { 1450 {
1436 m_log.DebugFormat("[RADMIN] updateUserAppearance"); 1451 m_log.DebugFormat("[RADMIN] updateUserAppearance");
1437 m_log.Warn("[RADMIN]: This method needs update for 0.7");
1438 1452
1439 //string dmale = m_config.GetString("default_male", "Default Male"); 1453 string dmale = m_config.GetString("default_male", "Default Male");
1440 //string dfemale = m_config.GetString("default_female", "Default Female"); 1454 string dfemale = m_config.GetString("default_female", "Default Female");
1441 //string dneut = m_config.GetString("default_female", "Default Default"); 1455 string dneut = m_config.GetString("default_female", "Default Default");
1442 string model = String.Empty; 1456 string model = String.Empty;
1443 1457
1444 //// Has a gender preference been supplied? 1458 // Has a gender preference been supplied?
1445 1459
1446 //if (requestData.Contains("gender")) 1460 if (requestData.Contains("gender"))
1447 //{ 1461 {
1448 // switch ((string)requestData["gender"]) 1462 switch ((string)requestData["gender"])
1449 // { 1463 {
1450 // case "m" : 1464 case "m" :
1451 // model = dmale; 1465 case "male" :
1452 // break; 1466 model = dmale;
1453 // case "f" : 1467 break;
1454 // model = dfemale; 1468 case "f" :
1455 // break; 1469 case "female" :
1456 // case "n" : 1470 model = dfemale;
1457 // default : 1471 break;
1458 // model = dneut; 1472 case "n" :
1459 // break; 1473 case "neutral" :
1460 // } 1474 default :
1461 //} 1475 model = dneut;
1462 1476 break;
1463 //// Has an explicit model been specified? 1477 }
1464 1478 }
1465 //if (requestData.Contains("model")) 1479
1466 //{ 1480 // Has an explicit model been specified?
1467 // model = (string)requestData["model"]; 1481
1468 //} 1482 if (requestData.Contains("model") && (String.IsNullOrEmpty((string)requestData["gender"])))
1469 1483 {
1470 //// No appearance attributes were set 1484 model = (string)requestData["model"];
1471 1485 }
1472 //if (model == String.Empty) 1486
1473 //{ 1487 // No appearance attributes were set
1474 // m_log.DebugFormat("[RADMIN] Appearance update not requested"); 1488
1475 // return; 1489 if (String.IsNullOrEmpty(model))
1476 //} 1490 {
1477 1491 m_log.DebugFormat("[RADMIN] Appearance update not requested");
1478 //m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model {1}", userid, model); 1492 return;
1479 1493 }
1480 //string[] nomens = model.Split(); 1494
1481 //if (nomens.Length != 2) 1495 m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model <{1}>", userid, model);
1482 //{ 1496
1483 // m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", userid, model); 1497 string[] nomens = model.Split();
1484 // // nomens = dmodel.Split(); 1498 if (nomens.Length != 2)
1485 // return; 1499 {
1486 //} 1500 m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", userid, model);
1487 1501 // nomens = dmodel.Split();
1488 //UserProfileData mprof = m_app.CommunicationsManager.UserService.GetUserProfile(nomens[0], nomens[1]); 1502 return;
1489 1503 }
1490 //// Is this the first time one of the default models has been used? Create it if that is the case 1504
1491 //// otherwise default to male. 1505 Scene scene = m_app.SceneManager.CurrentOrFirstScene;
1492 1506 UUID scopeID = scene.RegionInfo.ScopeID;
1493 //if (mprof == null) 1507 UserAccount mprof = scene.UserAccountService.GetUserAccount(scopeID, nomens[0], nomens[1]);
1494 //{ 1508
1495 // m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Appearance unchanged", model); 1509 if (mprof == null)
1496 // return; 1510 {
1497 //} 1511 m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Appearance unchanged", model);
1498 1512 return;
1499 //// Set current user's appearance. This bit is easy. The appearance structure is populated with 1513 }
1500 //// actual asset ids, however to complete the magic we need to populate the inventory with the 1514
1501 //// assets in question. 1515 // Set current user's appearance. This bit is easy. The appearance structure is populated with
1502 1516 // actual asset ids, however to complete the magic we need to populate the inventory with the
1503 //establishAppearance(userid, mprof.ID); 1517 // assets in question.
1518
1519 establishAppearance(userid, mprof.PrincipalID);
1504 1520
1505 m_log.DebugFormat("[RADMIN] Finished setting appearance for avatar {0}, using model {1}", 1521 m_log.DebugFormat("[RADMIN] Finished setting appearance for avatar {0}, using model {1}",
1506 userid, model); 1522 userid, model);
@@ -1515,116 +1531,312 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1515 private void establishAppearance(UUID dest, UUID srca) 1531 private void establishAppearance(UUID dest, UUID srca)
1516 { 1532 {
1517 m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", dest, srca); 1533 m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", dest, srca);
1534 Scene scene = m_app.SceneManager.CurrentOrFirstScene;
1518 AvatarAppearance ava = null; 1535 AvatarAppearance ava = null;
1519 AvatarData avatar = m_app.SceneManager.CurrentOrFirstScene.AvatarService.GetAvatar(srca); 1536 AvatarData avatar = scene.AvatarService.GetAvatar(srca);
1520 if (avatar != null) 1537 if (avatar != null)
1521 ava = avatar.ToAvatarAppearance(srca); 1538 ava = avatar.ToAvatarAppearance(srca);
1522 1539
1523 // If the model has no associated appearance we're done. 1540 // If the model has no associated appearance we're done.
1524
1525 // if (ava == null)
1526 // {
1527 // return new AvatarAppearance();
1528 // }
1529
1530 if (ava == null) 1541 if (ava == null)
1531 return; 1542 return;
1532 1543
1533 UICallback sic = new UICallback(); 1544 // Simple appearance copy or copy Clothing and Bodyparts folders?
1534 UICallback dic = new UICallback(); 1545 bool copyFolders = m_config.GetBoolean("copy_folders", false);
1535 IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService; 1546
1547 if (!copyFolders)
1548 {
1549 // Simple copy of wearables and appearance update
1550 try
1551 {
1552 copyWearablesAndAttachments(dest, srca, ava);
1536 1553
1554 AvatarData adata = new AvatarData(ava);
1555 scene.AvatarService.SetAvatar(dest, adata);
1556 }
1557 catch (Exception e)
1558 {
1559 m_log.WarnFormat("[RADMIN] Error transferring appearance for {0} : {1}",
1560 dest, e.Message);
1561 }
1562
1563 return;
1564 }
1565
1566 // Copy Clothing and Bodypart folders and appearance update
1537 try 1567 try
1538 { 1568 {
1539 Dictionary<UUID,UUID> imap = new Dictionary<UUID,UUID>(); 1569 Dictionary<UUID,UUID> imap = new Dictionary<UUID,UUID>();
1570 copyInventoryFolders(dest, srca, AssetType.Clothing, imap, ava);
1571 copyInventoryFolders(dest, srca, AssetType.Bodypart, imap, ava);
1540 1572
1541 iserv.GetUserInventory(dest, dic.callback); 1573 AvatarWearable[] wearables = ava.Wearables;
1542 iserv.GetUserInventory(srca, sic.callback);
1543
1544 dic.GetInventory();
1545 sic.GetInventory();
1546 1574
1547 if (sic.OK && dic.OK) 1575 for (int i=0; i<wearables.Length; i++)
1548 { 1576 {
1549 InventoryFolderImpl efolder; 1577 if (imap.ContainsKey(wearables[i].ItemID))
1550 InventoryFolderImpl srcf = sic.root.FindFolderForType(5); 1578 {
1551 InventoryFolderImpl dstf = dic.root.FindFolderForType(5); 1579 AvatarWearable dw = new AvatarWearable();
1580 dw.AssetID = wearables[i].AssetID;
1581 dw.ItemID = imap[wearables[i].ItemID];
1582 ava.SetWearable(i, dw);
1583 }
1584 }
1585
1586 AvatarData adata = new AvatarData(ava);
1587 scene.AvatarService.SetAvatar(dest, adata);
1588 }
1589 catch (Exception e)
1590 {
1591 m_log.WarnFormat("[RADMIN] Error transferring appearance for {0} : {1}",
1592 dest, e.Message);
1593 }
1552 1594
1553 if (srcf == null || dstf == null) 1595 return;
1554 throw new Exception("Cannot locate clothing folder(s)"); 1596 }
1597
1598 /// <summary>
1599 /// This method is called by establishAppearance to do a copy all inventory items
1600 /// worn or attached to the Clothing inventory folder of the receiving avatar.
1601 /// In parallel the avatar wearables and attachments are updated.
1602 /// </summary>
1603
1604 private void copyWearablesAndAttachments(UUID dest, UUID srca, AvatarAppearance ava)
1605 {
1606 IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService;
1555 1607
1556 foreach (InventoryFolderImpl folder in sic.folders) 1608 // Get Clothing folder of receiver
1609 InventoryFolderBase dstf = iserv.GetFolderForType(dest, AssetType.Clothing);
1610
1611 if (dstf == null)
1612 throw new Exception("Cannot locate folder(s)");
1613
1614 // Missing destination folder? This should *never* be the case
1615 if (dstf.Type != (short)AssetType.Clothing)
1616 {
1617 dstf = new InventoryFolderBase();
1618 dstf.ID = UUID.Random();
1619 dstf.Name = "Clothing";
1620 dstf.Owner = dest;
1621 dstf.Type = (short)AssetType.Clothing;
1622 dstf.ParentID = iserv.GetRootFolder(dest).ID;
1623 dstf.Version = 1;
1624 iserv.AddFolder(dstf); // store base record
1625 m_log.ErrorFormat("[RADMIN] Created folder for destination {0}", srca);
1626 }
1627
1628 // Wearables
1629 AvatarWearable[] wearables = ava.Wearables;
1630 AvatarWearable wearable;
1631
1632 for (int i=0; i<wearables.Length; i++)
1633 {
1634 wearable = wearables[i];
1635 if (wearable.ItemID != UUID.Zero)
1636 {
1637 // Get inventory item and copy it
1638 InventoryItemBase item = new InventoryItemBase(wearable.ItemID, srca);
1639 item = iserv.GetItem(item);
1640
1641 if (item != null)
1557 { 1642 {
1558 if (folder.ParentID == srcf.ID) 1643 InventoryItemBase dsti = new InventoryItemBase(UUID.Random(), dest);
1559 { 1644 dsti.Name = item.Name;
1560 efolder = new InventoryFolderImpl(); 1645 dsti.Description = item.Description;
1561 efolder.ID = UUID.Random(); 1646 dsti.InvType = item.InvType;
1562 efolder.Name = folder.Name; 1647 dsti.CreatorId = item.CreatorId;
1563 efolder.Type = folder.Type; 1648 dsti.CreatorIdAsUuid = item.CreatorIdAsUuid;
1564 efolder.Version = folder.Version; 1649 dsti.NextPermissions = item.NextPermissions;
1565 efolder.Owner = dest; 1650 dsti.CurrentPermissions = item.CurrentPermissions;
1566 dstf.AddChildFolder(efolder); 1651 dsti.BasePermissions = item.BasePermissions;
1567 iserv.AddFolder(efolder); 1652 dsti.EveryOnePermissions = item.EveryOnePermissions;
1568 m_log.DebugFormat("[RADMIN] Added outfile folder {0} to folder {1}", efolder.ID, srcf.ID); 1653 dsti.GroupPermissions = item.GroupPermissions;
1569 foreach (InventoryItemBase item in sic.items) 1654 dsti.AssetType = item.AssetType;
1570 { 1655 dsti.AssetID = item.AssetID;
1571 if (item.Folder == folder.ID) 1656 dsti.GroupID = item.GroupID;
1572 { 1657 dsti.GroupOwned = item.GroupOwned;
1573 InventoryItemBase dsti = new InventoryItemBase(); 1658 dsti.SalePrice = item.SalePrice;
1574 dsti.ID = UUID.Random(); 1659 dsti.SaleType = item.SaleType;
1575 dsti.Name = item.Name; 1660 dsti.Flags = item.Flags;
1576 dsti.Description = item.Description; 1661 dsti.CreationDate = item.CreationDate;
1577 dsti.InvType = item.InvType; 1662 dsti.Folder = dstf.ID;
1578 dsti.AssetType = item.AssetType; 1663
1579 dsti.Flags = item.Flags; 1664 iserv.AddItem(dsti);
1580 dsti.AssetID = item.AssetID; 1665 m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", dsti.ID, dstf.ID);
1581 dsti.Folder = efolder.ID; 1666
1582 dsti.Owner = dest; 1667 // Wear item
1583 dsti.BasePermissions = item.BasePermissions; 1668 AvatarWearable dw = new AvatarWearable();
1584 dsti.NextPermissions = item.NextPermissions; 1669 dw.AssetID = wearable.AssetID;
1585 dsti.CurrentPermissions = item.CurrentPermissions; 1670 dw.ItemID = dsti.ID;
1586 dsti.GroupPermissions = item.GroupPermissions; 1671 ava.SetWearable(i, dw);
1587 dsti.EveryOnePermissions = item.EveryOnePermissions;
1588 iserv.AddItem(dsti);
1589 imap.Add(item.ID, dsti.ID);
1590 m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", dsti.ID, efolder.ID);
1591 }
1592 }
1593 }
1594 } 1672 }
1595 1673 else
1596 // Update appearance tables
1597 AvatarWearable[] wearables = ava.Wearables;
1598 for (int i=0; i<wearables.Length; i++)
1599 { 1674 {
1600 if (imap.ContainsKey(wearables[i].ItemID)) 1675 m_log.WarnFormat("[RADMIN] Error transferring {0} to folder {1}", wearable.ItemID, dstf.ID);
1601 {
1602 AvatarWearable dw = new AvatarWearable();
1603 dw.AssetID = wearables[i].AssetID;
1604 dw.ItemID = imap[wearables[i].ItemID];
1605 ava.SetWearable(i, dw);
1606 }
1607 } 1676 }
1608 } 1677 }
1609 else 1678 }
1679
1680 // Attachments
1681 Dictionary<int, UUID[]> attachments = ava.GetAttachmentDictionary();
1682
1683 foreach (KeyValuePair<int, UUID[]> kvp in attachments)
1684 {
1685 int attachpoint = kvp.Key;
1686 UUID itemID = kvp.Value[0];
1687
1688 if (itemID != UUID.Zero)
1610 { 1689 {
1611 throw new Exception("Unable to load both inventories"); 1690 // Get inventory item and copy it
1691 InventoryItemBase item = new InventoryItemBase(itemID, srca);
1692 item = iserv.GetItem(item);
1693
1694 if (item != null)
1695 {
1696 InventoryItemBase dsti = new InventoryItemBase(UUID.Random(), dest);
1697 dsti.Name = item.Name;
1698 dsti.Description = item.Description;
1699 dsti.InvType = item.InvType;
1700 dsti.CreatorId = item.CreatorId;
1701 dsti.CreatorIdAsUuid = item.CreatorIdAsUuid;
1702 dsti.NextPermissions = item.NextPermissions;
1703 dsti.CurrentPermissions = item.CurrentPermissions;
1704 dsti.BasePermissions = item.BasePermissions;
1705 dsti.EveryOnePermissions = item.EveryOnePermissions;
1706 dsti.GroupPermissions = item.GroupPermissions;
1707 dsti.AssetType = item.AssetType;
1708 dsti.AssetID = item.AssetID;
1709 dsti.GroupID = item.GroupID;
1710 dsti.GroupOwned = item.GroupOwned;
1711 dsti.SalePrice = item.SalePrice;
1712 dsti.SaleType = item.SaleType;
1713 dsti.Flags = item.Flags;
1714 dsti.CreationDate = item.CreationDate;
1715 dsti.Folder = dstf.ID;
1716
1717 iserv.AddItem(dsti);
1718 m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", dsti.ID, dstf.ID);
1719
1720 // Attach item
1721 ava.SetAttachment(attachpoint, dsti.ID, dsti.AssetID);
1722 m_log.DebugFormat("[RADMIN] Attached {0}", dsti.ID);
1723 }
1724 else
1725 {
1726 m_log.WarnFormat("[RADMIN] Error transferring {0} to folder {1}", itemID, dstf.ID);
1727 }
1612 } 1728 }
1729 }
1613 1730
1614 AvatarData adata = new AvatarData(ava); 1731
1615 m_app.SceneManager.CurrentOrFirstScene.AvatarService.SetAvatar(dest, adata); 1732 }
1733
1734 /// <summary>
1735 /// This method is called by establishAppearance to copy inventory folders to make
1736 /// copies of Clothing and Bodyparts inventory folders and attaches worn attachments
1737 /// </summary>
1738
1739 private void copyInventoryFolders(UUID dest, UUID srca, AssetType assettype, Dictionary<UUID,UUID> imap,
1740 AvatarAppearance ava)
1741 {
1742 IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService;
1743
1744 InventoryFolderBase srcf = iserv.GetFolderForType(srca, assettype);
1745 InventoryFolderBase dstf = iserv.GetFolderForType(dest, assettype);
1746
1747 if (srcf == null || dstf == null)
1748 throw new Exception("Cannot locate folder(s)");
1749
1750 // Missing source folder? This should *never* be the case
1751 if (srcf.Type != (short)assettype)
1752 {
1753 srcf = new InventoryFolderBase();
1754 srcf.ID = UUID.Random();
1755 if (assettype == AssetType.Clothing) {
1756 srcf.Name = "Clothing";
1757 } else {
1758 srcf.Name = "Body Parts";
1759 }
1760 srcf.Owner = srca;
1761 srcf.Type = (short)assettype;
1762 srcf.ParentID = iserv.GetRootFolder(srca).ID;
1763 srcf.Version = 1;
1764 iserv.AddFolder(srcf); // store base record
1765 m_log.ErrorFormat("[RADMIN] Created folder for source {0}", srca);
1616 } 1766 }
1617 catch (Exception e) 1767
1768 // Missing destination folder? This should *never* be the case
1769 if (dstf.Type != (short)assettype)
1618 { 1770 {
1619 m_log.WarnFormat("[RADMIN] Error transferring inventory for {0} : {1}", 1771 dstf = new InventoryFolderBase();
1620 dest, e.Message); 1772 dstf.ID = UUID.Random();
1621 return; 1773 dstf.Name = assettype.ToString();
1774 dstf.Owner = dest;
1775 dstf.Type = (short)assettype;
1776 dstf.ParentID = iserv.GetRootFolder(dest).ID;
1777 dstf.Version = 1;
1778 iserv.AddFolder(dstf); // store base record
1779 m_log.ErrorFormat("[RADMIN] Created folder for destination {0}", srca);
1622 } 1780 }
1623 1781
1624 return; 1782 InventoryFolderBase efolder;
1783 List<InventoryFolderBase> folders = iserv.GetFolderContent(srca, srcf.ID).Folders;
1784
1785 foreach (InventoryFolderBase folder in folders)
1786 {
1787
1788 efolder = new InventoryFolderBase();
1789 efolder.ID = UUID.Random();
1790 efolder.Name = folder.Name;
1791 efolder.Owner = dest;
1792 efolder.Type = folder.Type;
1793 efolder.Version = folder.Version;
1794 efolder.ParentID = dstf.ID;
1795 iserv.AddFolder(efolder);
1796
1797 m_log.DebugFormat("[RADMIN] Added folder {0} to folder {1}", efolder.ID, srcf.ID);
1798
1799 List<InventoryItemBase> items = iserv.GetFolderContent(srca, folder.ID).Items;
1800
1801 foreach (InventoryItemBase item in items)
1802 {
1803 InventoryItemBase dsti = new InventoryItemBase(UUID.Random(), dest);
1804 dsti.Name = item.Name;
1805 dsti.Description = item.Description;
1806 dsti.InvType = item.InvType;
1807 dsti.CreatorId = item.CreatorId;
1808 dsti.CreatorIdAsUuid = item.CreatorIdAsUuid;
1809 dsti.NextPermissions = item.NextPermissions;
1810 dsti.CurrentPermissions = item.CurrentPermissions;
1811 dsti.BasePermissions = item.BasePermissions;
1812 dsti.EveryOnePermissions = item.EveryOnePermissions;
1813 dsti.GroupPermissions = item.GroupPermissions;
1814 dsti.AssetType = item.AssetType;
1815 dsti.AssetID = item.AssetID;
1816 dsti.GroupID = item.GroupID;
1817 dsti.GroupOwned = item.GroupOwned;
1818 dsti.SalePrice = item.SalePrice;
1819 dsti.SaleType = item.SaleType;
1820 dsti.Flags = item.Flags;
1821 dsti.CreationDate = item.CreationDate;
1822 dsti.Folder = efolder.ID;
1823
1824 iserv.AddItem(dsti);
1825 imap.Add(item.ID, dsti.ID);
1826 m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", dsti.ID, efolder.ID);
1827
1828 // Attach item, if original is attached
1829 int attachpoint = ava.GetAttachpoint(item.ID);
1830 if (attachpoint != 0)
1831 {
1832 ava.SetAttachment(attachpoint, dsti.ID, dsti.AssetID);
1833 m_log.DebugFormat("[RADMIN] Attached {0}", dsti.ID);
1834 }
1835 }
1836 }
1625 } 1837 }
1626 1838
1627 ///<summary> 1839 /// <summary>
1628 /// This method is called if a given model avatar name can not be found. If the external 1840 /// This method is called if a given model avatar name can not be found. If the external
1629 /// file has already been loaded once, then control returns immediately. If not, then it 1841 /// file has already been loaded once, then control returns immediately. If not, then it
1630 /// looks for a default appearance file. This file contains XML definitions of zero or more named 1842 /// looks for a default appearance file. This file contains XML definitions of zero or more named
@@ -1675,9 +1887,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1675 bool include = false; 1887 bool include = false;
1676 bool select = false; 1888 bool select = false;
1677 1889
1678 UICallback uic; 1890 Scene scene = m_app.SceneManager.CurrentOrFirstScene;
1679 IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService; 1891 IInventoryService iserv = scene.InventoryService;
1680 IAssetService aserv = m_app.SceneManager.CurrentOrFirstScene.AssetService; 1892 IAssetService aserv = scene.AssetService;
1681 1893
1682 doc.LoadXml(File.ReadAllText(dafn)); 1894 doc.LoadXml(File.ReadAllText(dafn));
1683 1895
@@ -1714,29 +1926,31 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1714 passwd = GetStringAttribute(avatar,"password",passwd); 1926 passwd = GetStringAttribute(avatar,"password",passwd);
1715 1927
1716 string[] nomens = name.Split(); 1928 string[] nomens = name.Split();
1717 UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; 1929 UUID scopeID = scene.RegionInfo.ScopeID;
1718 UserAccount account = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, nomens[0], nomens[1]); 1930 UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, nomens[0], nomens[1]);
1719 if (null == account) 1931 if (null == account)
1720 { 1932 {
1721 account = new UserAccount(scopeID, nomens[0], nomens[1], email); 1933 account = CreateUser(scopeID, nomens[0], nomens[1], passwd, email);
1722 bool success = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.StoreUserAccount(account); 1934 if (null == account)
1723 if (!success)
1724 { 1935 {
1725 m_log.ErrorFormat("[RADMIN] Avatar {0} {1} was not created", nomens[0], nomens[1]); 1936 m_log.ErrorFormat("[RADMIN] Avatar {0} {1} was not created", nomens[0], nomens[1]);
1726 return false; 1937 return false;
1727 } 1938 }
1728 // !!! REFACTORING PROBLEM: need to set the password
1729
1730 GridRegion home = m_app.SceneManager.CurrentOrFirstScene.GridService.GetRegionByPosition(scopeID,
1731 (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize));
1732 if (home != null)
1733 m_app.SceneManager.CurrentOrFirstScene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
1734 } 1939 }
1735 else 1940
1736 { 1941 // Set home position
1737 ID = account.PrincipalID; 1942
1943 GridRegion home = scene.GridService.GetRegionByPosition(scopeID,
1944 (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize));
1945 if (null == home) {
1946 m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", nomens[0], nomens[1]);
1947 } else {
1948 scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
1949 m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, nomens[0], nomens[1]);
1738 } 1950 }
1739 1951
1952 ID = account.PrincipalID;
1953
1740 m_log.DebugFormat("[RADMIN] User {0}[{1}] created or retrieved", name, ID); 1954 m_log.DebugFormat("[RADMIN] User {0}[{1}] created or retrieved", name, ID);
1741 include = true; 1955 include = true;
1742 } 1956 }
@@ -1753,46 +1967,36 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1753 1967
1754 if (include) 1968 if (include)
1755 { 1969 {
1756 uic = new UICallback(); 1970 // Setup for appearance processing
1757 // Request the inventory 1971 AvatarData adata = scene.AvatarService.GetAvatar(ID);
1758 iserv.GetUserInventory(ID, uic.callback);
1759
1760 // While the inventory is being fetched, setup for appearance processing
1761 AvatarData adata = m_app.SceneManager.CurrentOrFirstScene.AvatarService.GetAvatar(ID);
1762 if (adata != null) 1972 if (adata != null)
1763 mava = adata.ToAvatarAppearance(ID); 1973 mava = adata.ToAvatarAppearance(ID);
1764 else 1974 else
1765 mava = new AvatarAppearance(); 1975 mava = new AvatarAppearance();
1766 1976
1977 AvatarWearable[] wearables = mava.Wearables;
1978 for (int i=0; i<wearables.Length; i++)
1767 { 1979 {
1768 AvatarWearable[] wearables = mava.Wearables; 1980 wearables[i] = new AvatarWearable();
1769 for (int i=0; i<wearables.Length; i++)
1770 {
1771 wearables[i] = new AvatarWearable();
1772 }
1773 } 1981 }
1774 1982
1775 // Wait for the inventory to arrive
1776 uic.GetInventory();
1777
1778 // We can only get dresssed if an inventory is forthcoming
1779 if (uic.OK)
1780 try 1983 try
1781 { 1984 {
1782 m_log.DebugFormat("[RADMIN] {0} folders, {1} items in inventory", 1985 // m_log.DebugFormat("[RADMIN] {0} folders, {1} items in inventory",
1783 uic.folders.Count, uic.items.Count); 1986 // uic.folders.Count, uic.items.Count);
1784 1987
1785 InventoryFolderImpl cfolder = uic.root.FindFolderForType(5); 1988 InventoryFolderBase cfolder = iserv.GetFolderForType(ID, AssetType.Clothing);
1786 1989
1787 // This should *never* be the case 1990 // This should *never* be the case
1788 if (cfolder == null) 1991 if (cfolder == null || cfolder.Type != (short)AssetType.Clothing)
1789 { 1992 {
1790 cfolder = new InventoryFolderImpl(); 1993 cfolder = new InventoryFolderBase();
1994 cfolder.ID = UUID.Random();
1791 cfolder.Name = "Clothing"; 1995 cfolder.Name = "Clothing";
1792 cfolder.Type = 5;
1793 cfolder.Version = 1;
1794 cfolder.Owner = ID; 1996 cfolder.Owner = ID;
1795 uic.root.AddChildFolder(cfolder); // make connection 1997 cfolder.Type = (short)AssetType.Clothing;
1998 cfolder.ParentID = iserv.GetRootFolder(ID).ID;
1999 cfolder.Version = 1;
1796 iserv.AddFolder(cfolder); // store base record 2000 iserv.AddFolder(cfolder); // store base record
1797 m_log.ErrorFormat("[RADMIN] Created clothing folder for {0}/{1}", name, ID); 2001 m_log.ErrorFormat("[RADMIN] Created clothing folder for {0}/{1}", name, ID);
1798 } 2002 }
@@ -1801,7 +2005,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1801 // default appearance XMl file. 2005 // default appearance XMl file.
1802 2006
1803 XmlNodeList outfits = avatar.GetElementsByTagName("Ensemble"); 2007 XmlNodeList outfits = avatar.GetElementsByTagName("Ensemble");
1804 InventoryFolderImpl efolder; 2008 InventoryFolderBase efolder;
1805 string oname; 2009 string oname;
1806 UUID assetid; 2010 UUID assetid;
1807 2011
@@ -1812,13 +2016,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1812 2016
1813 oname = GetStringAttribute(outfit,"name",""); 2017 oname = GetStringAttribute(outfit,"name","");
1814 select = (GetStringAttribute(outfit,"default","no") == "yes"); 2018 select = (GetStringAttribute(outfit,"default","no") == "yes");
1815 efolder = null;
1816 2019
1817 // If the folder already exists, re-use it. The defaults may 2020 // If the folder already exists, re-use it. The defaults may
1818 // change over time. Augment only. 2021 // change over time. Augment only.
1819 foreach (InventoryFolderImpl folder in uic.folders) 2022
2023 List<InventoryFolderBase> folders = iserv.GetFolderContent(ID, cfolder.ID).Folders;
2024 efolder = null;
2025
2026 foreach (InventoryFolderBase folder in folders)
1820 { 2027 {
1821 if (folder.Name == oname && folder.ParentID == cfolder.ID) 2028 if (folder.Name == oname)
1822 { 2029 {
1823 efolder = folder; 2030 efolder = folder;
1824 break; 2031 break;
@@ -1829,14 +2036,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1829 if (efolder == null) 2036 if (efolder == null)
1830 { 2037 {
1831 m_log.DebugFormat("[RADMIN] Creating outfit folder {0} for {1}", oname, name); 2038 m_log.DebugFormat("[RADMIN] Creating outfit folder {0} for {1}", oname, name);
1832 efolder = new InventoryFolderImpl(); 2039 efolder = new InventoryFolderBase();
1833 efolder.ID = UUID.Random(); 2040 efolder.ID = UUID.Random();
1834 efolder.Name = oname; 2041 efolder.Name = oname;
1835 efolder.Type = 5;
1836 efolder.Version = 1;
1837 efolder.Owner = ID; 2042 efolder.Owner = ID;
1838 cfolder.AddChildFolder(efolder); // make connection 2043 efolder.Type = (short)AssetType.Clothing;
1839 iserv.AddFolder(efolder); // store base record 2044 efolder.Version = 1;
2045 efolder.ParentID = cfolder.ID;
2046 iserv.AddFolder(efolder);
1840 m_log.DebugFormat("[RADMIN] Adding outfile folder {0} to folder {1}", efolder.ID, cfolder.ID); 2047 m_log.DebugFormat("[RADMIN] Adding outfile folder {0} to folder {1}", efolder.ID, cfolder.ID);
1841 } 2048 }
1842 2049
@@ -1863,26 +2070,55 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1863 2070
1864 InventoryItemBase iitem = null; 2071 InventoryItemBase iitem = null;
1865 2072
1866 if ((iitem = efolder.FindAsset(assetid)) == null) 2073 // Check if asset is in inventory already
2074 iitem = null;
2075 List<InventoryItemBase> iitems = iserv.GetFolderContent(ID, efolder.ID).Items;
2076
2077 foreach (InventoryItemBase litem in iitems)
2078 {
2079 if (litem.AssetID == assetid)
2080 {
2081 iitem = litem;
2082 break;
2083 }
2084 }
2085
2086 // Create inventory item
2087 if (iitem == null)
1867 { 2088 {
1868 iitem = new InventoryItemBase(); 2089 iitem = new InventoryItemBase(UUID.Random(), ID);
1869 iitem.ID = UUID.Random();
1870 iitem.Name = GetStringAttribute(item,"name",""); 2090 iitem.Name = GetStringAttribute(item,"name","");
1871 iitem.Description = GetStringAttribute(item,"desc",""); 2091 iitem.Description = GetStringAttribute(item,"desc","");
1872 iitem.InvType = GetIntegerAttribute(item,"invtype",-1); 2092 iitem.InvType = GetIntegerAttribute(item,"invtype",-1);
1873 iitem.AssetType = GetIntegerAttribute(item,"assettype",-1); 2093 iitem.CreatorId = GetStringAttribute(item,"creatorid","");
1874 iitem.Flags = GetUnsignedAttribute(item,"flags",0); 2094 iitem.CreatorIdAsUuid = (UUID)GetStringAttribute(item,"creatoruuid","");
1875 iitem.AssetID = assetid; // associated asset
1876 iitem.Folder = efolder.ID; // Parent folder
1877 iitem.Owner = ID; // Agent ID
1878 iitem.BasePermissions = GetUnsignedAttribute(perms,"base",0x7fffffff);
1879 iitem.NextPermissions = GetUnsignedAttribute(perms,"next",0x7fffffff); 2095 iitem.NextPermissions = GetUnsignedAttribute(perms,"next",0x7fffffff);
1880 iitem.CurrentPermissions = GetUnsignedAttribute(perms,"current",0x7fffffff); 2096 iitem.CurrentPermissions = GetUnsignedAttribute(perms,"current",0x7fffffff);
1881 iitem.GroupPermissions = GetUnsignedAttribute(perms,"group",0x7fffffff); 2097 iitem.BasePermissions = GetUnsignedAttribute(perms,"base",0x7fffffff);
1882 iitem.EveryOnePermissions = GetUnsignedAttribute(perms,"everyone",0x7fffffff); 2098 iitem.EveryOnePermissions = GetUnsignedAttribute(perms,"everyone",0x7fffffff);
1883 m_log.DebugFormat("[RADMIN] Adding item {0} to folder {1}", iitem.ID, efolder.ID); 2099 iitem.GroupPermissions = GetUnsignedAttribute(perms,"group",0x7fffffff);
2100 iitem.AssetType = GetIntegerAttribute(item,"assettype",-1);
2101 iitem.AssetID = assetid; // associated asset
2102 iitem.GroupID = (UUID)GetStringAttribute(item,"groupid","");
2103 iitem.GroupOwned = (GetStringAttribute(item,"groupowned","false") == "true");
2104 iitem.SalePrice = GetIntegerAttribute(item,"saleprice",0);
2105 iitem.SaleType = (byte)GetIntegerAttribute(item,"saletype",0);
2106 iitem.Flags = GetUnsignedAttribute(item,"flags",0);
2107 iitem.CreationDate = GetIntegerAttribute(item,"creationdate",Util.UnixTimeSinceEpoch());
2108 iitem.Folder = efolder.ID; // Parent folder
2109
1884 iserv.AddItem(iitem); 2110 iserv.AddItem(iitem);
2111 m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", iitem.ID, efolder.ID);
2112 }
2113
2114 // Attach item, if attachpoint is specified
2115 int attachpoint = GetIntegerAttribute(item,"attachpoint",0);
2116 if (attachpoint != 0)
2117 {
2118 mava.SetAttachment(attachpoint, iitem.ID, iitem.AssetID);
2119 m_log.DebugFormat("[RADMIN] Attached {0}", iitem.ID);
1885 } 2120 }
2121
1886 // Record whether or not the item is to be initially worn 2122 // Record whether or not the item is to be initially worn
1887 try 2123 try
1888 { 2124 {
@@ -1892,25 +2128,22 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1892 mava.Wearables[iitem.Flags].AssetID = iitem.AssetID; 2128 mava.Wearables[iitem.Flags].AssetID = iitem.AssetID;
1893 } 2129 }
1894 } 2130 }
1895 catch {} 2131 catch (Exception e)
2132 {
2133 m_log.WarnFormat("[RADMIN] Error wearing item {0} : {1}", iitem.ID, e.Message);
2134 }
1896 } // foreach item in outfit 2135 } // foreach item in outfit
1897 m_log.DebugFormat("[RADMIN] Outfit {0} load completed", oname); 2136 m_log.DebugFormat("[RADMIN] Outfit {0} load completed", oname);
1898 } // foreach outfit 2137 } // foreach outfit
1899 m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name); 2138 m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name);
1900 AvatarData adata2 = new AvatarData(mava); 2139 AvatarData adata2 = new AvatarData(mava);
1901 m_app.SceneManager.CurrentOrFirstScene.AvatarService.SetAvatar(ID, adata2); 2140 scene.AvatarService.SetAvatar(ID, adata2);
1902 } 2141 }
1903 catch (Exception e) 2142 catch (Exception e)
1904 { 2143 {
1905 m_log.WarnFormat("[RADMIN] Inventory processing incomplete for user {0} : {1}", 2144 m_log.WarnFormat("[RADMIN] Inventory processing incomplete for user {0} : {1}",
1906 name, e.Message); 2145 name, e.Message);
1907 } 2146 }
1908 else
1909 {
1910 m_log.WarnFormat("[RADMIN] Unable to retrieve inventory for {0}[{1}]",
1911 name, ID);
1912 // continue to next avatar
1913 }
1914 } // End of include 2147 } // End of include
1915 } 2148 }
1916 m_log.DebugFormat("[RADMIN] Default avatar loading complete"); 2149 m_log.DebugFormat("[RADMIN] Default avatar loading complete");
@@ -2778,81 +3011,115 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2778 public void Dispose() 3011 public void Dispose()
2779 { 3012 {
2780 } 3013 }
2781 }
2782
2783 class UICallback
2784 {
2785 private Object uilock = new Object();
2786 internal InventoryFolderImpl root = null;
2787 internal List<InventoryFolderImpl> folders;
2788 internal List<InventoryItemBase> items;
2789 internal bool OK = false;
2790
2791 public void callback(ICollection<InventoryFolderImpl> p_folders, ICollection<InventoryItemBase> p_items)
2792 {
2793 lock (uilock)
2794 {
2795 folders = (List<InventoryFolderImpl>) p_folders;
2796 items = (List<InventoryItemBase>) p_items;
2797 OK = true;
2798 System.Threading.Monitor.Pulse(uilock);
2799 }
2800 }
2801 3014
2802 public void GetInventory() 3015 /// <summary>
3016 /// Create a user
3017 /// </summary>
3018 /// <param name="scopeID"></param>
3019 /// <param name="firstName"></param>
3020 /// <param name="lastName"></param>
3021 /// <param name="password"></param>
3022 /// <param name="email"></param>
3023 private UserAccount CreateUser(UUID scopeID, string firstName, string lastName, string password, string email)
2803 { 3024 {
2804 Dictionary<UUID, InventoryFolderImpl> fmap = new Dictionary<UUID, InventoryFolderImpl>(); 3025 Scene scene = m_app.SceneManager.CurrentOrFirstScene;
2805 3026 IUserAccountService m_UserAccountService = scene.UserAccountService;
2806 if (OK == false) 3027 IGridService m_GridService = scene.GridService;
3028 IAuthenticationService m_AuthenticationService = scene.AuthenticationService;
3029 IGridUserService m_GridUserService = scene.GridUserService;
3030 IInventoryService m_InventoryService = scene.InventoryService;
3031
3032 UserAccount account = m_UserAccountService.GetUserAccount(scopeID, firstName, lastName);
3033 if (null == account)
2807 { 3034 {
2808 lock (uilock) 3035 account = new UserAccount(scopeID, firstName, lastName, email);
3036 if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
2809 { 3037 {
2810 if (OK == false) 3038 account.ServiceURLs = new Dictionary<string, object>();
2811 System.Threading.Monitor.Wait(uilock); 3039 account.ServiceURLs["HomeURI"] = string.Empty;
3040 account.ServiceURLs["GatekeeperURI"] = string.Empty;
3041 account.ServiceURLs["InventoryServerURI"] = string.Empty;
3042 account.ServiceURLs["AssetServerURI"] = string.Empty;
2812 } 3043 }
2813 }
2814
2815 // Got the inventory OK. So now merge the content of the default appearance
2816 // file with whatever we already have in-world. For convenience we initialize
2817 // the inventory hierarchy.
2818 3044
2819 // Find root and build an index 3045 if (m_UserAccountService.StoreUserAccount(account))
2820
2821 foreach (InventoryFolderImpl folder in folders)
2822 {
2823 if (folder.ParentID == UUID.Zero)
2824 { 3046 {
2825 if (root == null) 3047 bool success;
3048 if (m_AuthenticationService != null)
2826 { 3049 {
2827 root = folder; 3050 success = m_AuthenticationService.SetPassword(account.PrincipalID, password);
3051 if (!success)
3052 m_log.WarnFormat("[RADMIN]: Unable to set password for account {0} {1}.",
3053 firstName, lastName);
3054 }
3055
3056 GridRegion home = null;
3057 if (m_GridService != null)
3058 {
3059 List<GridRegion> defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero);
3060 if (defaultRegions != null && defaultRegions.Count >= 1)
3061 home = defaultRegions[0];
3062
3063 if (m_GridUserService != null && home != null)
3064 m_GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
3065 else
3066 m_log.WarnFormat("[RADMIN]: Unable to set home for account {0} {1}.",
3067 firstName, lastName);
2828 } 3068 }
2829 else 3069 else
3070 m_log.WarnFormat("[RADMIN]: Unable to retrieve home region for account {0} {1}.",
3071 firstName, lastName);
3072
3073 if (m_InventoryService != null)
2830 { 3074 {
2831 throw new Exception("Multiple root folders found"); 3075 success = m_InventoryService.CreateUserInventory(account.PrincipalID);
3076 if (!success)
3077 m_log.WarnFormat("[RADMIN]: Unable to create inventory for account {0} {1}.",
3078 firstName, lastName);
2832 } 3079 }
3080
3081 m_log.InfoFormat("[RADMIN]: Account {0} {1} created successfully", firstName, lastName);
3082 return account;
3083 } else {
3084 m_log.ErrorFormat("[RADMIN]: Account creation failed for account {0} {1}", firstName, lastName);
2833 } 3085 }
2834 fmap.Add(folder.ID, folder);
2835 } 3086 }
2836 3087 else
2837 // Hard to continue if the root folder is not there
2838 if (root == null)
2839 { 3088 {
2840 throw new Exception("Root folder not found"); 3089 m_log.ErrorFormat("[RADMIN]: A user with the name {0} {1} already exists!", firstName, lastName);
2841 } 3090 }
3091 return null;
3092 }
2842 3093
2843 // Construct the folder hierarchy 3094 /// <summary>
2844 foreach (InventoryFolderImpl folder in folders) 3095 /// Change password
3096 /// </summary>
3097 /// <param name="firstName"></param>
3098 /// <param name="lastName"></param>
3099 /// <param name="password"></param>
3100 private bool ChangeUserPassword(string firstName, string lastName, string password)
3101 {
3102 Scene scene = m_app.SceneManager.CurrentOrFirstScene;
3103 IUserAccountService m_UserAccountService = scene.UserAccountService;
3104 IAuthenticationService m_AuthenticationService = scene.AuthenticationService;
3105
3106 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
3107 if (null != account)
2845 { 3108 {
2846 if (folder.ID != root.ID) 3109 bool success = false;
2847 { 3110 if (m_AuthenticationService != null)
2848 fmap[folder.ParentID].AddChildFolder(folder); 3111 success = m_AuthenticationService.SetPassword(account.PrincipalID, password);
3112 if (!success) {
3113 m_log.WarnFormat("[RADMIN]: Unable to set password for account {0} {1}.",
3114 firstName, lastName);
3115 return false;
2849 } 3116 }
3117 return true;
2850 } 3118 }
2851 3119 else
2852 // Find a home for every pre-existing item
2853 foreach (InventoryItemBase item in items)
2854 { 3120 {
2855 fmap[item.Folder].Items.Add(item.ID, item); 3121 m_log.ErrorFormat("[RADMIN]: No such user");
3122 return false;
2856 } 3123 }
2857 } 3124 }
2858 } 3125 }