diff options
author | Melanie | 2010-06-13 21:45:39 +0100 |
---|---|---|
committer | Melanie | 2010-06-13 21:45:39 +0100 |
commit | 14c587bea1e0acfca0ba1842c5a1fa10bdf45548 (patch) | |
tree | b5aca81f7845d897ba05f2fec0beb0f668b53331 /OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |
parent | Added Old Guids=true to all MySql connection strings. (diff) | |
download | opensim-SC-14c587bea1e0acfca0ba1842c5a1fa10bdf45548.zip opensim-SC-14c587bea1e0acfca0ba1842c5a1fa10bdf45548.tar.gz opensim-SC-14c587bea1e0acfca0ba1842c5a1fa10bdf45548.tar.bz2 opensim-SC-14c587bea1e0acfca0ba1842c5a1fa10bdf45548.tar.xz |
Thank you, Snoopy2, for a patch to fix RemoteAdmin. Committed with the following
changes:
- Start location is NOT optional. The signature was defined with it being mandataory and there is no reason to change it
- Adjusted comments to remove misleading or no longer true comments. Default
is neuter, according to the code, not male, as the comment stated.
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 949 |
1 files changed, 608 insertions, 341 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 7ebb5de..b248d11 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -998,35 +998,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
998 | string firstname = (string) requestData["user_firstname"]; | 998 | string firstname = (string) requestData["user_firstname"]; |
999 | string lastname = (string) requestData["user_lastname"]; | 999 | string lastname = (string) requestData["user_lastname"]; |
1000 | string passwd = (string) requestData["user_password"]; | 1000 | string passwd = (string) requestData["user_password"]; |
1001 | uint regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); | 1001 | |
1002 | uint regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); | 1002 | regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); |
1003 | regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); | ||
1003 | 1004 | ||
1004 | string email = ""; // empty string for email | 1005 | string email = ""; // empty string for email |
1005 | if (requestData.Contains("user_email")) | 1006 | if (requestData.Contains("user_email")) |
1006 | email = (string)requestData["user_email"]; | 1007 | email = (string)requestData["user_email"]; |
1007 | 1008 | ||
1008 | UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; | 1009 | Scene scene = m_app.SceneManager.CurrentOrFirstScene; |
1009 | 1010 | UUID scopeID = scene.RegionInfo.ScopeID; | |
1010 | UserAccount account = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, firstname, lastname); | ||
1011 | |||
1012 | if (null != account) | ||
1013 | throw new Exception(String.Format("Account {0} {1} already exists", firstname, lastname)); | ||
1014 | 1011 | ||
1015 | account = new UserAccount(scopeID, firstname, lastname, email); | 1012 | UserAccount account = CreateUser(scopeID, firstname, lastname, passwd, email); |
1016 | 1013 | ||
1017 | bool success = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.StoreUserAccount(account); | 1014 | if (null == account) |
1018 | |||
1019 | if (!success) | ||
1020 | throw new Exception(String.Format("failed to create new user {0} {1}", | 1015 | throw new Exception(String.Format("failed to create new user {0} {1}", |
1021 | firstname, lastname)); | 1016 | firstname, lastname)); |
1022 | 1017 | ||
1023 | // Store the password | 1018 | // Set home position |
1024 | m_app.SceneManager.CurrentOrFirstScene.AuthenticationService.SetPassword(account.PrincipalID, passwd); | ||
1025 | 1019 | ||
1026 | GridRegion home = m_app.SceneManager.CurrentOrFirstScene.GridService.GetRegionByPosition(scopeID, | 1020 | GridRegion home = scene.GridService.GetRegionByPosition(scopeID, |
1027 | (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize)); | 1021 | (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize)); |
1028 | if (home == null) | 1022 | if (null == home) { |
1029 | m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstname, lastname); | 1023 | m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstname, lastname); |
1024 | } else { | ||
1025 | scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
1026 | m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, firstname, lastname); | ||
1027 | } | ||
1030 | 1028 | ||
1031 | // Establish the avatar's initial appearance | 1029 | // Establish the avatar's initial appearance |
1032 | 1030 | ||
@@ -1169,9 +1167,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1169 | /// <item><term>start_region_y</term> | 1167 | /// <item><term>start_region_y</term> |
1170 | /// <description>avatar's start region coordinates, Y | 1168 | /// <description>avatar's start region coordinates, Y |
1171 | /// value (changeable)</description></item> | 1169 | /// value (changeable)</description></item> |
1172 | /// <item><term>about_real_world</term> | 1170 | /// <item><term>about_real_world (not implemented yet)</term> |
1173 | /// <description>"about" text of avatar owner (changeable)</description></item> | 1171 | /// <description>"about" text of avatar owner (changeable)</description></item> |
1174 | /// <item><term>about_virtual_world</term> | 1172 | /// <item><term>about_virtual_world (not implemented yet)</term> |
1175 | /// <description>"about" text of avatar (changeable)</description></item> | 1173 | /// <description>"about" text of avatar (changeable)</description></item> |
1176 | /// </list> | 1174 | /// </list> |
1177 | /// | 1175 | /// |
@@ -1182,6 +1180,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1182 | /// <description>true or false</description></item> | 1180 | /// <description>true or false</description></item> |
1183 | /// <item><term>error</term> | 1181 | /// <item><term>error</term> |
1184 | /// <description>error message if success is false</description></item> | 1182 | /// <description>error message if success is false</description></item> |
1183 | /// <item><term>avatar_uuid</term> | ||
1184 | /// <description>UUID of the updated avatar | ||
1185 | /// account; UUID.Zero if failed. | ||
1186 | /// </description></item> | ||
1185 | /// </list> | 1187 | /// </list> |
1186 | /// </remarks> | 1188 | /// </remarks> |
1187 | 1189 | ||
@@ -1189,31 +1191,34 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1189 | { | 1191 | { |
1190 | m_log.Info("[RADMIN]: UpdateUserAccount: new request"); | 1192 | m_log.Info("[RADMIN]: UpdateUserAccount: new request"); |
1191 | m_log.Warn("[RADMIN]: This method needs update for 0.7"); | 1193 | m_log.Warn("[RADMIN]: This method needs update for 0.7"); |
1194 | |||
1195 | FailIfRemoteAdminDisabled("UpdateUserAccount"); | ||
1196 | |||
1192 | XmlRpcResponse response = new XmlRpcResponse(); | 1197 | XmlRpcResponse response = new XmlRpcResponse(); |
1193 | Hashtable responseData = new Hashtable(); | 1198 | Hashtable responseData = new Hashtable(); |
1194 | 1199 | ||
1195 | //lock (rslock) | 1200 | lock (rslock) |
1196 | //{ | 1201 | { |
1197 | // try | 1202 | try |
1198 | // { | 1203 | { |
1199 | // Hashtable requestData = (Hashtable) request.Params[0]; | 1204 | Hashtable requestData = (Hashtable) request.Params[0]; |
1200 | 1205 | ||
1201 | // // check completeness | 1206 | // check completeness |
1202 | // checkStringParameters(request, new string[] { | 1207 | checkStringParameters(request, new string[] { |
1203 | // "password", "user_firstname", | 1208 | "password", "user_firstname", |
1204 | // "user_lastname"}); | 1209 | "user_lastname"}); |
1205 | 1210 | ||
1206 | // // check password | 1211 | // check password |
1207 | // if (!String.IsNullOrEmpty(m_requiredPassword) && | 1212 | if (!String.IsNullOrEmpty(m_requiredPassword) && |
1208 | // (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password"); | 1213 | (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password"); |
1209 | 1214 | ||
1210 | // // do the job | 1215 | // do the job |
1211 | // string firstname = (string) requestData["user_firstname"]; | 1216 | string firstname = (string) requestData["user_firstname"]; |
1212 | // string lastname = (string) requestData["user_lastname"]; | 1217 | string lastname = (string) requestData["user_lastname"]; |
1213 | 1218 | ||
1214 | // string passwd = String.Empty; | 1219 | string passwd = String.Empty; |
1215 | // uint? regX = null; | 1220 | uint? regX = null; |
1216 | // uint? regY = null; | 1221 | uint? regY = null; |
1217 | // uint? ulaX = null; | 1222 | // uint? ulaX = null; |
1218 | // uint? ulaY = null; | 1223 | // uint? ulaY = null; |
1219 | // uint? ulaZ = null; | 1224 | // uint? ulaZ = null; |
@@ -1223,11 +1228,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1223 | // string aboutFirstLive = String.Empty; | 1228 | // string aboutFirstLive = String.Empty; |
1224 | // string aboutAvatar = String.Empty; | 1229 | // string aboutAvatar = String.Empty; |
1225 | 1230 | ||
1226 | // if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"]; | 1231 | if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"]; |
1227 | // if (requestData.ContainsKey("start_region_x")) | 1232 | if (requestData.ContainsKey("start_region_x")) |
1228 | // regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); | 1233 | regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); |
1229 | // if (requestData.ContainsKey("start_region_y")) | 1234 | if (requestData.ContainsKey("start_region_y")) |
1230 | // regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); | 1235 | regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); |
1231 | 1236 | ||
1232 | // if (requestData.ContainsKey("start_lookat_x")) | 1237 | // if (requestData.ContainsKey("start_lookat_x")) |
1233 | // ulaX = Convert.ToUInt32((Int32) requestData["start_lookat_x"]); | 1238 | // ulaX = Convert.ToUInt32((Int32) requestData["start_lookat_x"]); |
@@ -1247,21 +1252,18 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1247 | // if (requestData.ContainsKey("about_virtual_world")) | 1252 | // if (requestData.ContainsKey("about_virtual_world")) |
1248 | // aboutAvatar = (string)requestData["about_virtual_world"]; | 1253 | // aboutAvatar = (string)requestData["about_virtual_world"]; |
1249 | 1254 | ||
1250 | // UserProfileData userProfile | 1255 | Scene scene = m_app.SceneManager.CurrentOrFirstScene; |
1251 | // = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); | 1256 | UUID scopeID = scene.RegionInfo.ScopeID; |
1252 | 1257 | UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, firstname, lastname); | |
1253 | // if (null == userProfile) | ||
1254 | // throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname)); | ||
1255 | 1258 | ||
1256 | // if (!String.IsNullOrEmpty(passwd)) | 1259 | if (null == account) |
1257 | // { | 1260 | throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname)); |
1258 | // m_log.DebugFormat("[RADMIN]: UpdateUserAccount: updating password for avatar {0} {1}", firstname, lastname); | ||
1259 | // string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty); | ||
1260 | // userProfile.PasswordHash = md5PasswdHash; | ||
1261 | // } | ||
1262 | 1261 | ||
1263 | // if (null != regX) userProfile.HomeRegionX = (uint) regX; | 1262 | if (!String.IsNullOrEmpty(passwd)) |
1264 | // if (null != regY) userProfile.HomeRegionY = (uint) regY; | 1263 | { |
1264 | m_log.DebugFormat("[RADMIN]: UpdateUserAccount: updating password for avatar {0} {1}", firstname, lastname); | ||
1265 | ChangeUserPassword(firstname, lastname, passwd); | ||
1266 | } | ||
1265 | 1267 | ||
1266 | // if (null != usaX) userProfile.HomeLocationX = (uint) usaX; | 1268 | // if (null != usaX) userProfile.HomeLocationX = (uint) usaX; |
1267 | // if (null != usaY) userProfile.HomeLocationY = (uint) usaY; | 1269 | // if (null != usaY) userProfile.HomeLocationY = (uint) usaY; |
@@ -1274,35 +1276,48 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1274 | // if (String.Empty != aboutFirstLive) userProfile.FirstLifeAboutText = aboutFirstLive; | 1276 | // if (String.Empty != aboutFirstLive) userProfile.FirstLifeAboutText = aboutFirstLive; |
1275 | // if (String.Empty != aboutAvatar) userProfile.AboutText = aboutAvatar; | 1277 | // if (String.Empty != aboutAvatar) userProfile.AboutText = aboutAvatar; |
1276 | 1278 | ||
1277 | // // User has been created. Now establish gender and appearance. | 1279 | // Set home position |
1278 | 1280 | ||
1279 | // updateUserAppearance(responseData, requestData, userProfile.ID); | 1281 | if ((null != regX) && (null != regY)) |
1282 | { | ||
1283 | GridRegion home = scene.GridService.GetRegionByPosition(scopeID, | ||
1284 | (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize)); | ||
1285 | if (null == home) { | ||
1286 | m_log.WarnFormat("[RADMIN]: Unable to set home region for updated user account {0} {1}", firstname, lastname); | ||
1287 | } else { | ||
1288 | scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
1289 | m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, firstname, lastname); | ||
1290 | } | ||
1291 | } | ||
1280 | 1292 | ||
1281 | // if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile)) | 1293 | // User has been created. Now establish gender and appearance. |
1282 | // throw new Exception("did not manage to update user profile"); | ||
1283 | 1294 | ||
1284 | // responseData["success"] = true; | 1295 | updateUserAppearance(responseData, requestData, account.PrincipalID); |
1285 | 1296 | ||
1286 | // response.Value = responseData; | 1297 | responseData["success"] = true; |
1298 | responseData["avatar_uuid"] = account.PrincipalID.ToString(); | ||
1287 | 1299 | ||
1288 | // m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", | 1300 | response.Value = responseData; |
1289 | // firstname, lastname, | ||
1290 | // userProfile.ID); | ||
1291 | // } | ||
1292 | // catch (Exception e) | ||
1293 | // { | ||
1294 | // m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message); | ||
1295 | // m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString()); | ||
1296 | 1301 | ||
1297 | // responseData["success"] = false; | 1302 | m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", |
1298 | // responseData["error"] = e.Message; | 1303 | firstname, lastname, |
1304 | account.PrincipalID); | ||
1305 | } | ||
1306 | catch (Exception e) | ||
1307 | { | ||
1299 | 1308 | ||
1300 | // response.Value = responseData; | 1309 | m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message); |
1301 | // } | 1310 | m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString()); |
1302 | //} | ||
1303 | 1311 | ||
1304 | m_log.Info("[RADMIN]: UpdateUserAccount: request complete"); | 1312 | responseData["success"] = false; |
1305 | return response; | 1313 | responseData["avatar_uuid"] = UUID.Zero.ToString(); |
1314 | responseData["error"] = e.Message; | ||
1315 | |||
1316 | response.Value = responseData; | ||
1317 | } | ||
1318 | m_log.Info("[RADMIN]: UpdateUserAccount: request complete"); | ||
1319 | return response; | ||
1320 | } | ||
1306 | } | 1321 | } |
1307 | 1322 | ||
1308 | /// <summary> | 1323 | /// <summary> |
@@ -1316,73 +1331,74 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1316 | private void updateUserAppearance(Hashtable responseData, Hashtable requestData, UUID userid) | 1331 | private void updateUserAppearance(Hashtable responseData, Hashtable requestData, UUID userid) |
1317 | { | 1332 | { |
1318 | m_log.DebugFormat("[RADMIN] updateUserAppearance"); | 1333 | m_log.DebugFormat("[RADMIN] updateUserAppearance"); |
1319 | m_log.Warn("[RADMIN]: This method needs update for 0.7"); | ||
1320 | 1334 | ||
1321 | //string dmale = m_config.GetString("default_male", "Default Male"); | 1335 | string dmale = m_config.GetString("default_male", "Default Male"); |
1322 | //string dfemale = m_config.GetString("default_female", "Default Female"); | 1336 | string dfemale = m_config.GetString("default_female", "Default Female"); |
1323 | //string dneut = m_config.GetString("default_female", "Default Default"); | 1337 | string dneut = m_config.GetString("default_female", "Default Default"); |
1324 | string model = String.Empty; | 1338 | string model = String.Empty; |
1325 | 1339 | ||
1326 | //// Has a gender preference been supplied? | 1340 | // Has a gender preference been supplied? |
1327 | 1341 | ||
1328 | //if (requestData.Contains("gender")) | 1342 | if (requestData.Contains("gender")) |
1329 | //{ | 1343 | { |
1330 | // switch ((string)requestData["gender"]) | 1344 | switch ((string)requestData["gender"]) |
1331 | // { | 1345 | { |
1332 | // case "m" : | 1346 | case "m" : |
1333 | // model = dmale; | 1347 | case "male" : |
1334 | // break; | 1348 | model = dmale; |
1335 | // case "f" : | 1349 | break; |
1336 | // model = dfemale; | 1350 | case "f" : |
1337 | // break; | 1351 | case "female" : |
1338 | // case "n" : | 1352 | model = dfemale; |
1339 | // default : | 1353 | break; |
1340 | // model = dneut; | 1354 | case "n" : |
1341 | // break; | 1355 | case "neutral" : |
1342 | // } | 1356 | default : |
1343 | //} | 1357 | model = dneut; |
1344 | 1358 | break; | |
1345 | //// Has an explicit model been specified? | 1359 | } |
1346 | 1360 | } | |
1347 | //if (requestData.Contains("model")) | 1361 | |
1348 | //{ | 1362 | // Has an explicit model been specified? |
1349 | // model = (string)requestData["model"]; | 1363 | |
1350 | //} | 1364 | if (requestData.Contains("model") && (String.IsNullOrEmpty((string)requestData["gender"]))) |
1351 | 1365 | { | |
1352 | //// No appearance attributes were set | 1366 | model = (string)requestData["model"]; |
1353 | 1367 | } | |
1354 | //if (model == String.Empty) | 1368 | |
1355 | //{ | 1369 | // No appearance attributes were set |
1356 | // m_log.DebugFormat("[RADMIN] Appearance update not requested"); | 1370 | |
1357 | // return; | 1371 | if (String.IsNullOrEmpty(model)) |
1358 | //} | 1372 | { |
1359 | 1373 | m_log.DebugFormat("[RADMIN] Appearance update not requested"); | |
1360 | //m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model {1}", userid, model); | 1374 | return; |
1361 | 1375 | } | |
1362 | //string[] nomens = model.Split(); | 1376 | |
1363 | //if (nomens.Length != 2) | 1377 | m_log.DebugFormat("[RADMIN] Setting appearance for avatar {0}, using model <{1}>", userid, model); |
1364 | //{ | 1378 | |
1365 | // m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", userid, model); | 1379 | string[] nomens = model.Split(); |
1366 | // // nomens = dmodel.Split(); | 1380 | if (nomens.Length != 2) |
1367 | // return; | 1381 | { |
1368 | //} | 1382 | m_log.WarnFormat("[RADMIN] User appearance not set for {0}. Invalid model name : <{1}>", userid, model); |
1369 | 1383 | // nomens = dmodel.Split(); | |
1370 | //UserProfileData mprof = m_app.CommunicationsManager.UserService.GetUserProfile(nomens[0], nomens[1]); | 1384 | return; |
1371 | 1385 | } | |
1372 | //// Is this the first time one of the default models has been used? Create it if that is the case | 1386 | |
1373 | //// otherwise default to male. | 1387 | Scene scene = m_app.SceneManager.CurrentOrFirstScene; |
1374 | 1388 | UUID scopeID = scene.RegionInfo.ScopeID; | |
1375 | //if (mprof == null) | 1389 | UserAccount mprof = scene.UserAccountService.GetUserAccount(scopeID, nomens[0], nomens[1]); |
1376 | //{ | 1390 | |
1377 | // m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Appearance unchanged", model); | 1391 | if (mprof == null) |
1378 | // return; | 1392 | { |
1379 | //} | 1393 | m_log.WarnFormat("[RADMIN] Requested model ({0}) not found. Appearance unchanged", model); |
1380 | 1394 | return; | |
1381 | //// Set current user's appearance. This bit is easy. The appearance structure is populated with | 1395 | } |
1382 | //// actual asset ids, however to complete the magic we need to populate the inventory with the | 1396 | |
1383 | //// assets in question. | 1397 | // Set current user's appearance. This bit is easy. The appearance structure is populated with |
1384 | 1398 | // actual asset ids, however to complete the magic we need to populate the inventory with the | |
1385 | //establishAppearance(userid, mprof.ID); | 1399 | // assets in question. |
1400 | |||
1401 | establishAppearance(userid, mprof.PrincipalID); | ||
1386 | 1402 | ||
1387 | m_log.DebugFormat("[RADMIN] Finished setting appearance for avatar {0}, using model {1}", | 1403 | m_log.DebugFormat("[RADMIN] Finished setting appearance for avatar {0}, using model {1}", |
1388 | userid, model); | 1404 | userid, model); |
@@ -1397,116 +1413,312 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1397 | private void establishAppearance(UUID dest, UUID srca) | 1413 | private void establishAppearance(UUID dest, UUID srca) |
1398 | { | 1414 | { |
1399 | m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", dest, srca); | 1415 | m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", dest, srca); |
1416 | Scene scene = m_app.SceneManager.CurrentOrFirstScene; | ||
1400 | AvatarAppearance ava = null; | 1417 | AvatarAppearance ava = null; |
1401 | AvatarData avatar = m_app.SceneManager.CurrentOrFirstScene.AvatarService.GetAvatar(srca); | 1418 | AvatarData avatar = scene.AvatarService.GetAvatar(srca); |
1402 | if (avatar != null) | 1419 | if (avatar != null) |
1403 | ava = avatar.ToAvatarAppearance(srca); | 1420 | ava = avatar.ToAvatarAppearance(srca); |
1404 | 1421 | ||
1405 | // If the model has no associated appearance we're done. | 1422 | // If the model has no associated appearance we're done. |
1406 | |||
1407 | // if (ava == null) | ||
1408 | // { | ||
1409 | // return new AvatarAppearance(); | ||
1410 | // } | ||
1411 | |||
1412 | if (ava == null) | 1423 | if (ava == null) |
1413 | return; | 1424 | return; |
1414 | 1425 | ||
1415 | UICallback sic = new UICallback(); | 1426 | // Simple appearance copy or copy Clothing and Bodyparts folders? |
1416 | UICallback dic = new UICallback(); | 1427 | bool copyFolders = m_config.GetBoolean("copy_folders", false); |
1417 | IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService; | 1428 | |
1429 | if (!copyFolders) | ||
1430 | { | ||
1431 | // Simple copy of wearables and appearance update | ||
1432 | try | ||
1433 | { | ||
1434 | copyWearablesAndAttachments(dest, srca, ava); | ||
1418 | 1435 | ||
1436 | AvatarData adata = new AvatarData(ava); | ||
1437 | scene.AvatarService.SetAvatar(dest, adata); | ||
1438 | } | ||
1439 | catch (Exception e) | ||
1440 | { | ||
1441 | m_log.WarnFormat("[RADMIN] Error transferring appearance for {0} : {1}", | ||
1442 | dest, e.Message); | ||
1443 | } | ||
1444 | |||
1445 | return; | ||
1446 | } | ||
1447 | |||
1448 | // Copy Clothing and Bodypart folders and appearance update | ||
1419 | try | 1449 | try |
1420 | { | 1450 | { |
1421 | Dictionary<UUID,UUID> imap = new Dictionary<UUID,UUID>(); | 1451 | Dictionary<UUID,UUID> imap = new Dictionary<UUID,UUID>(); |
1452 | copyInventoryFolders(dest, srca, AssetType.Clothing, imap, ava); | ||
1453 | copyInventoryFolders(dest, srca, AssetType.Bodypart, imap, ava); | ||
1422 | 1454 | ||
1423 | iserv.GetUserInventory(dest, dic.callback); | 1455 | AvatarWearable[] wearables = ava.Wearables; |
1424 | iserv.GetUserInventory(srca, sic.callback); | ||
1425 | |||
1426 | dic.GetInventory(); | ||
1427 | sic.GetInventory(); | ||
1428 | 1456 | ||
1429 | if (sic.OK && dic.OK) | 1457 | for (int i=0; i<wearables.Length; i++) |
1430 | { | 1458 | { |
1431 | InventoryFolderImpl efolder; | 1459 | if (imap.ContainsKey(wearables[i].ItemID)) |
1432 | InventoryFolderImpl srcf = sic.root.FindFolderForType(5); | 1460 | { |
1433 | InventoryFolderImpl dstf = dic.root.FindFolderForType(5); | 1461 | AvatarWearable dw = new AvatarWearable(); |
1462 | dw.AssetID = wearables[i].AssetID; | ||
1463 | dw.ItemID = imap[wearables[i].ItemID]; | ||
1464 | ava.SetWearable(i, dw); | ||
1465 | } | ||
1466 | } | ||
1467 | |||
1468 | AvatarData adata = new AvatarData(ava); | ||
1469 | scene.AvatarService.SetAvatar(dest, adata); | ||
1470 | } | ||
1471 | catch (Exception e) | ||
1472 | { | ||
1473 | m_log.WarnFormat("[RADMIN] Error transferring appearance for {0} : {1}", | ||
1474 | dest, e.Message); | ||
1475 | } | ||
1434 | 1476 | ||
1435 | if (srcf == null || dstf == null) | 1477 | return; |
1436 | throw new Exception("Cannot locate clothing folder(s)"); | 1478 | } |
1479 | |||
1480 | /// <summary> | ||
1481 | /// This method is called by establishAppearance to do a copy all inventory items | ||
1482 | /// worn or attached to the Clothing inventory folder of the receiving avatar. | ||
1483 | /// In parallel the avatar wearables and attachments are updated. | ||
1484 | /// </summary> | ||
1485 | |||
1486 | private void copyWearablesAndAttachments(UUID dest, UUID srca, AvatarAppearance ava) | ||
1487 | { | ||
1488 | IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService; | ||
1437 | 1489 | ||
1438 | foreach (InventoryFolderImpl folder in sic.folders) | 1490 | // Get Clothing folder of receiver |
1491 | InventoryFolderBase dstf = iserv.GetFolderForType(dest, AssetType.Clothing); | ||
1492 | |||
1493 | if (dstf == null) | ||
1494 | throw new Exception("Cannot locate folder(s)"); | ||
1495 | |||
1496 | // Missing destination folder? This should *never* be the case | ||
1497 | if (dstf.Type != (short)AssetType.Clothing) | ||
1498 | { | ||
1499 | dstf = new InventoryFolderBase(); | ||
1500 | dstf.ID = UUID.Random(); | ||
1501 | dstf.Name = "Clothing"; | ||
1502 | dstf.Owner = dest; | ||
1503 | dstf.Type = (short)AssetType.Clothing; | ||
1504 | dstf.ParentID = iserv.GetRootFolder(dest).ID; | ||
1505 | dstf.Version = 1; | ||
1506 | iserv.AddFolder(dstf); // store base record | ||
1507 | m_log.ErrorFormat("[RADMIN] Created folder for destination {0}", srca); | ||
1508 | } | ||
1509 | |||
1510 | // Wearables | ||
1511 | AvatarWearable[] wearables = ava.Wearables; | ||
1512 | AvatarWearable wearable; | ||
1513 | |||
1514 | for (int i=0; i<wearables.Length; i++) | ||
1515 | { | ||
1516 | wearable = wearables[i]; | ||
1517 | if (wearable.ItemID != UUID.Zero) | ||
1518 | { | ||
1519 | // Get inventory item and copy it | ||
1520 | InventoryItemBase item = new InventoryItemBase(wearable.ItemID, srca); | ||
1521 | item = iserv.GetItem(item); | ||
1522 | |||
1523 | if (item != null) | ||
1439 | { | 1524 | { |
1440 | if (folder.ParentID == srcf.ID) | 1525 | InventoryItemBase dsti = new InventoryItemBase(UUID.Random(), dest); |
1441 | { | 1526 | dsti.Name = item.Name; |
1442 | efolder = new InventoryFolderImpl(); | 1527 | dsti.Description = item.Description; |
1443 | efolder.ID = UUID.Random(); | 1528 | dsti.InvType = item.InvType; |
1444 | efolder.Name = folder.Name; | 1529 | dsti.CreatorId = item.CreatorId; |
1445 | efolder.Type = folder.Type; | 1530 | dsti.CreatorIdAsUuid = item.CreatorIdAsUuid; |
1446 | efolder.Version = folder.Version; | 1531 | dsti.NextPermissions = item.NextPermissions; |
1447 | efolder.Owner = dest; | 1532 | dsti.CurrentPermissions = item.CurrentPermissions; |
1448 | dstf.AddChildFolder(efolder); | 1533 | dsti.BasePermissions = item.BasePermissions; |
1449 | iserv.AddFolder(efolder); | 1534 | dsti.EveryOnePermissions = item.EveryOnePermissions; |
1450 | m_log.DebugFormat("[RADMIN] Added outfile folder {0} to folder {1}", efolder.ID, srcf.ID); | 1535 | dsti.GroupPermissions = item.GroupPermissions; |
1451 | foreach (InventoryItemBase item in sic.items) | 1536 | dsti.AssetType = item.AssetType; |
1452 | { | 1537 | dsti.AssetID = item.AssetID; |
1453 | if (item.Folder == folder.ID) | 1538 | dsti.GroupID = item.GroupID; |
1454 | { | 1539 | dsti.GroupOwned = item.GroupOwned; |
1455 | InventoryItemBase dsti = new InventoryItemBase(); | 1540 | dsti.SalePrice = item.SalePrice; |
1456 | dsti.ID = UUID.Random(); | 1541 | dsti.SaleType = item.SaleType; |
1457 | dsti.Name = item.Name; | 1542 | dsti.Flags = item.Flags; |
1458 | dsti.Description = item.Description; | 1543 | dsti.CreationDate = item.CreationDate; |
1459 | dsti.InvType = item.InvType; | 1544 | dsti.Folder = dstf.ID; |
1460 | dsti.AssetType = item.AssetType; | 1545 | |
1461 | dsti.Flags = item.Flags; | 1546 | iserv.AddItem(dsti); |
1462 | dsti.AssetID = item.AssetID; | 1547 | m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", dsti.ID, dstf.ID); |
1463 | dsti.Folder = efolder.ID; | 1548 | |
1464 | dsti.Owner = dest; | 1549 | // Wear item |
1465 | dsti.BasePermissions = item.BasePermissions; | 1550 | AvatarWearable dw = new AvatarWearable(); |
1466 | dsti.NextPermissions = item.NextPermissions; | 1551 | dw.AssetID = wearable.AssetID; |
1467 | dsti.CurrentPermissions = item.CurrentPermissions; | 1552 | dw.ItemID = dsti.ID; |
1468 | dsti.GroupPermissions = item.GroupPermissions; | 1553 | ava.SetWearable(i, dw); |
1469 | dsti.EveryOnePermissions = item.EveryOnePermissions; | ||
1470 | iserv.AddItem(dsti); | ||
1471 | imap.Add(item.ID, dsti.ID); | ||
1472 | m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", dsti.ID, efolder.ID); | ||
1473 | } | ||
1474 | } | ||
1475 | } | ||
1476 | } | 1554 | } |
1477 | 1555 | else | |
1478 | // Update appearance tables | ||
1479 | AvatarWearable[] wearables = ava.Wearables; | ||
1480 | for (int i=0; i<wearables.Length; i++) | ||
1481 | { | 1556 | { |
1482 | if (imap.ContainsKey(wearables[i].ItemID)) | 1557 | m_log.WarnFormat("[RADMIN] Error transferring {0} to folder {1}", wearable.ItemID, dstf.ID); |
1483 | { | ||
1484 | AvatarWearable dw = new AvatarWearable(); | ||
1485 | dw.AssetID = wearables[i].AssetID; | ||
1486 | dw.ItemID = imap[wearables[i].ItemID]; | ||
1487 | ava.SetWearable(i, dw); | ||
1488 | } | ||
1489 | } | 1558 | } |
1490 | } | 1559 | } |
1491 | else | 1560 | } |
1561 | |||
1562 | // Attachments | ||
1563 | Dictionary<int, UUID[]> attachments = ava.GetAttachmentDictionary(); | ||
1564 | |||
1565 | foreach (KeyValuePair<int, UUID[]> kvp in attachments) | ||
1566 | { | ||
1567 | int attachpoint = kvp.Key; | ||
1568 | UUID itemID = kvp.Value[0]; | ||
1569 | |||
1570 | if (itemID != UUID.Zero) | ||
1492 | { | 1571 | { |
1493 | throw new Exception("Unable to load both inventories"); | 1572 | // Get inventory item and copy it |
1573 | InventoryItemBase item = new InventoryItemBase(itemID, srca); | ||
1574 | item = iserv.GetItem(item); | ||
1575 | |||
1576 | if (item != null) | ||
1577 | { | ||
1578 | InventoryItemBase dsti = new InventoryItemBase(UUID.Random(), dest); | ||
1579 | dsti.Name = item.Name; | ||
1580 | dsti.Description = item.Description; | ||
1581 | dsti.InvType = item.InvType; | ||
1582 | dsti.CreatorId = item.CreatorId; | ||
1583 | dsti.CreatorIdAsUuid = item.CreatorIdAsUuid; | ||
1584 | dsti.NextPermissions = item.NextPermissions; | ||
1585 | dsti.CurrentPermissions = item.CurrentPermissions; | ||
1586 | dsti.BasePermissions = item.BasePermissions; | ||
1587 | dsti.EveryOnePermissions = item.EveryOnePermissions; | ||
1588 | dsti.GroupPermissions = item.GroupPermissions; | ||
1589 | dsti.AssetType = item.AssetType; | ||
1590 | dsti.AssetID = item.AssetID; | ||
1591 | dsti.GroupID = item.GroupID; | ||
1592 | dsti.GroupOwned = item.GroupOwned; | ||
1593 | dsti.SalePrice = item.SalePrice; | ||
1594 | dsti.SaleType = item.SaleType; | ||
1595 | dsti.Flags = item.Flags; | ||
1596 | dsti.CreationDate = item.CreationDate; | ||
1597 | dsti.Folder = dstf.ID; | ||
1598 | |||
1599 | iserv.AddItem(dsti); | ||
1600 | m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", dsti.ID, dstf.ID); | ||
1601 | |||
1602 | // Attach item | ||
1603 | ava.SetAttachment(attachpoint, dsti.ID, dsti.AssetID); | ||
1604 | m_log.DebugFormat("[RADMIN] Attached {0}", dsti.ID); | ||
1605 | } | ||
1606 | else | ||
1607 | { | ||
1608 | m_log.WarnFormat("[RADMIN] Error transferring {0} to folder {1}", itemID, dstf.ID); | ||
1609 | } | ||
1494 | } | 1610 | } |
1611 | } | ||
1495 | 1612 | ||
1496 | AvatarData adata = new AvatarData(ava); | 1613 | |
1497 | m_app.SceneManager.CurrentOrFirstScene.AvatarService.SetAvatar(dest, adata); | 1614 | } |
1615 | |||
1616 | /// <summary> | ||
1617 | /// This method is called by establishAppearance to copy inventory folders to make | ||
1618 | /// copies of Clothing and Bodyparts inventory folders and attaches worn attachments | ||
1619 | /// </summary> | ||
1620 | |||
1621 | private void copyInventoryFolders(UUID dest, UUID srca, AssetType assettype, Dictionary<UUID,UUID> imap, | ||
1622 | AvatarAppearance ava) | ||
1623 | { | ||
1624 | IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService; | ||
1625 | |||
1626 | InventoryFolderBase srcf = iserv.GetFolderForType(srca, assettype); | ||
1627 | InventoryFolderBase dstf = iserv.GetFolderForType(dest, assettype); | ||
1628 | |||
1629 | if (srcf == null || dstf == null) | ||
1630 | throw new Exception("Cannot locate folder(s)"); | ||
1631 | |||
1632 | // Missing source folder? This should *never* be the case | ||
1633 | if (srcf.Type != (short)assettype) | ||
1634 | { | ||
1635 | srcf = new InventoryFolderBase(); | ||
1636 | srcf.ID = UUID.Random(); | ||
1637 | if (assettype == AssetType.Clothing) { | ||
1638 | srcf.Name = "Clothing"; | ||
1639 | } else { | ||
1640 | srcf.Name = "Body Parts"; | ||
1641 | } | ||
1642 | srcf.Owner = srca; | ||
1643 | srcf.Type = (short)assettype; | ||
1644 | srcf.ParentID = iserv.GetRootFolder(srca).ID; | ||
1645 | srcf.Version = 1; | ||
1646 | iserv.AddFolder(srcf); // store base record | ||
1647 | m_log.ErrorFormat("[RADMIN] Created folder for source {0}", srca); | ||
1498 | } | 1648 | } |
1499 | catch (Exception e) | 1649 | |
1650 | // Missing destination folder? This should *never* be the case | ||
1651 | if (dstf.Type != (short)assettype) | ||
1500 | { | 1652 | { |
1501 | m_log.WarnFormat("[RADMIN] Error transferring inventory for {0} : {1}", | 1653 | dstf = new InventoryFolderBase(); |
1502 | dest, e.Message); | 1654 | dstf.ID = UUID.Random(); |
1503 | return; | 1655 | dstf.Name = assettype.ToString(); |
1656 | dstf.Owner = dest; | ||
1657 | dstf.Type = (short)assettype; | ||
1658 | dstf.ParentID = iserv.GetRootFolder(dest).ID; | ||
1659 | dstf.Version = 1; | ||
1660 | iserv.AddFolder(dstf); // store base record | ||
1661 | m_log.ErrorFormat("[RADMIN] Created folder for destination {0}", srca); | ||
1504 | } | 1662 | } |
1505 | 1663 | ||
1506 | return; | 1664 | InventoryFolderBase efolder; |
1665 | List<InventoryFolderBase> folders = iserv.GetFolderContent(srca, srcf.ID).Folders; | ||
1666 | |||
1667 | foreach (InventoryFolderBase folder in folders) | ||
1668 | { | ||
1669 | |||
1670 | efolder = new InventoryFolderBase(); | ||
1671 | efolder.ID = UUID.Random(); | ||
1672 | efolder.Name = folder.Name; | ||
1673 | efolder.Owner = dest; | ||
1674 | efolder.Type = folder.Type; | ||
1675 | efolder.Version = folder.Version; | ||
1676 | efolder.ParentID = dstf.ID; | ||
1677 | iserv.AddFolder(efolder); | ||
1678 | |||
1679 | m_log.DebugFormat("[RADMIN] Added folder {0} to folder {1}", efolder.ID, srcf.ID); | ||
1680 | |||
1681 | List<InventoryItemBase> items = iserv.GetFolderContent(srca, folder.ID).Items; | ||
1682 | |||
1683 | foreach (InventoryItemBase item in items) | ||
1684 | { | ||
1685 | InventoryItemBase dsti = new InventoryItemBase(UUID.Random(), dest); | ||
1686 | dsti.Name = item.Name; | ||
1687 | dsti.Description = item.Description; | ||
1688 | dsti.InvType = item.InvType; | ||
1689 | dsti.CreatorId = item.CreatorId; | ||
1690 | dsti.CreatorIdAsUuid = item.CreatorIdAsUuid; | ||
1691 | dsti.NextPermissions = item.NextPermissions; | ||
1692 | dsti.CurrentPermissions = item.CurrentPermissions; | ||
1693 | dsti.BasePermissions = item.BasePermissions; | ||
1694 | dsti.EveryOnePermissions = item.EveryOnePermissions; | ||
1695 | dsti.GroupPermissions = item.GroupPermissions; | ||
1696 | dsti.AssetType = item.AssetType; | ||
1697 | dsti.AssetID = item.AssetID; | ||
1698 | dsti.GroupID = item.GroupID; | ||
1699 | dsti.GroupOwned = item.GroupOwned; | ||
1700 | dsti.SalePrice = item.SalePrice; | ||
1701 | dsti.SaleType = item.SaleType; | ||
1702 | dsti.Flags = item.Flags; | ||
1703 | dsti.CreationDate = item.CreationDate; | ||
1704 | dsti.Folder = efolder.ID; | ||
1705 | |||
1706 | iserv.AddItem(dsti); | ||
1707 | imap.Add(item.ID, dsti.ID); | ||
1708 | m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", dsti.ID, efolder.ID); | ||
1709 | |||
1710 | // Attach item, if original is attached | ||
1711 | int attachpoint = ava.GetAttachpoint(item.ID); | ||
1712 | if (attachpoint != 0) | ||
1713 | { | ||
1714 | ava.SetAttachment(attachpoint, dsti.ID, dsti.AssetID); | ||
1715 | m_log.DebugFormat("[RADMIN] Attached {0}", dsti.ID); | ||
1716 | } | ||
1717 | } | ||
1718 | } | ||
1507 | } | 1719 | } |
1508 | 1720 | ||
1509 | ///<summary> | 1721 | /// <summary> |
1510 | /// This method is called if a given model avatar name can not be found. If the external | 1722 | /// This method is called if a given model avatar name can not be found. If the external |
1511 | /// file has already been loaded once, then control returns immediately. If not, then it | 1723 | /// file has already been loaded once, then control returns immediately. If not, then it |
1512 | /// looks for a default appearance file. This file contains XML definitions of zero or more named | 1724 | /// looks for a default appearance file. This file contains XML definitions of zero or more named |
@@ -1557,9 +1769,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1557 | bool include = false; | 1769 | bool include = false; |
1558 | bool select = false; | 1770 | bool select = false; |
1559 | 1771 | ||
1560 | UICallback uic; | 1772 | Scene scene = m_app.SceneManager.CurrentOrFirstScene; |
1561 | IInventoryService iserv = m_app.SceneManager.CurrentOrFirstScene.InventoryService; | 1773 | IInventoryService iserv = scene.InventoryService; |
1562 | IAssetService aserv = m_app.SceneManager.CurrentOrFirstScene.AssetService; | 1774 | IAssetService aserv = scene.AssetService; |
1563 | 1775 | ||
1564 | doc.LoadXml(File.ReadAllText(dafn)); | 1776 | doc.LoadXml(File.ReadAllText(dafn)); |
1565 | 1777 | ||
@@ -1596,29 +1808,31 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1596 | passwd = GetStringAttribute(avatar,"password",passwd); | 1808 | passwd = GetStringAttribute(avatar,"password",passwd); |
1597 | 1809 | ||
1598 | string[] nomens = name.Split(); | 1810 | string[] nomens = name.Split(); |
1599 | UUID scopeID = m_app.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; | 1811 | UUID scopeID = scene.RegionInfo.ScopeID; |
1600 | UserAccount account = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, nomens[0], nomens[1]); | 1812 | UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, nomens[0], nomens[1]); |
1601 | if (null == account) | 1813 | if (null == account) |
1602 | { | 1814 | { |
1603 | account = new UserAccount(scopeID, nomens[0], nomens[1], email); | 1815 | account = CreateUser(scopeID, nomens[0], nomens[1], passwd, email); |
1604 | bool success = m_app.SceneManager.CurrentOrFirstScene.UserAccountService.StoreUserAccount(account); | 1816 | if (null == account) |
1605 | if (!success) | ||
1606 | { | 1817 | { |
1607 | m_log.ErrorFormat("[RADMIN] Avatar {0} {1} was not created", nomens[0], nomens[1]); | 1818 | m_log.ErrorFormat("[RADMIN] Avatar {0} {1} was not created", nomens[0], nomens[1]); |
1608 | return false; | 1819 | return false; |
1609 | } | 1820 | } |
1610 | // !!! REFACTORING PROBLEM: need to set the password | ||
1611 | |||
1612 | GridRegion home = m_app.SceneManager.CurrentOrFirstScene.GridService.GetRegionByPosition(scopeID, | ||
1613 | (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize)); | ||
1614 | if (home != null) | ||
1615 | m_app.SceneManager.CurrentOrFirstScene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
1616 | } | 1821 | } |
1617 | else | 1822 | |
1618 | { | 1823 | // Set home position |
1619 | ID = account.PrincipalID; | 1824 | |
1825 | GridRegion home = scene.GridService.GetRegionByPosition(scopeID, | ||
1826 | (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize)); | ||
1827 | if (null == home) { | ||
1828 | m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", nomens[0], nomens[1]); | ||
1829 | } else { | ||
1830 | scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
1831 | m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, nomens[0], nomens[1]); | ||
1620 | } | 1832 | } |
1621 | 1833 | ||
1834 | ID = account.PrincipalID; | ||
1835 | |||
1622 | m_log.DebugFormat("[RADMIN] User {0}[{1}] created or retrieved", name, ID); | 1836 | m_log.DebugFormat("[RADMIN] User {0}[{1}] created or retrieved", name, ID); |
1623 | include = true; | 1837 | include = true; |
1624 | } | 1838 | } |
@@ -1635,46 +1849,36 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1635 | 1849 | ||
1636 | if (include) | 1850 | if (include) |
1637 | { | 1851 | { |
1638 | uic = new UICallback(); | 1852 | // Setup for appearance processing |
1639 | // Request the inventory | 1853 | AvatarData adata = scene.AvatarService.GetAvatar(ID); |
1640 | iserv.GetUserInventory(ID, uic.callback); | ||
1641 | |||
1642 | // While the inventory is being fetched, setup for appearance processing | ||
1643 | AvatarData adata = m_app.SceneManager.CurrentOrFirstScene.AvatarService.GetAvatar(ID); | ||
1644 | if (adata != null) | 1854 | if (adata != null) |
1645 | mava = adata.ToAvatarAppearance(ID); | 1855 | mava = adata.ToAvatarAppearance(ID); |
1646 | else | 1856 | else |
1647 | mava = new AvatarAppearance(); | 1857 | mava = new AvatarAppearance(); |
1648 | 1858 | ||
1859 | AvatarWearable[] wearables = mava.Wearables; | ||
1860 | for (int i=0; i<wearables.Length; i++) | ||
1649 | { | 1861 | { |
1650 | AvatarWearable[] wearables = mava.Wearables; | 1862 | wearables[i] = new AvatarWearable(); |
1651 | for (int i=0; i<wearables.Length; i++) | ||
1652 | { | ||
1653 | wearables[i] = new AvatarWearable(); | ||
1654 | } | ||
1655 | } | 1863 | } |
1656 | 1864 | ||
1657 | // Wait for the inventory to arrive | ||
1658 | uic.GetInventory(); | ||
1659 | |||
1660 | // We can only get dresssed if an inventory is forthcoming | ||
1661 | if (uic.OK) | ||
1662 | try | 1865 | try |
1663 | { | 1866 | { |
1664 | m_log.DebugFormat("[RADMIN] {0} folders, {1} items in inventory", | 1867 | // m_log.DebugFormat("[RADMIN] {0} folders, {1} items in inventory", |
1665 | uic.folders.Count, uic.items.Count); | 1868 | // uic.folders.Count, uic.items.Count); |
1666 | 1869 | ||
1667 | InventoryFolderImpl cfolder = uic.root.FindFolderForType(5); | 1870 | InventoryFolderBase cfolder = iserv.GetFolderForType(ID, AssetType.Clothing); |
1668 | 1871 | ||
1669 | // This should *never* be the case | 1872 | // This should *never* be the case |
1670 | if (cfolder == null) | 1873 | if (cfolder == null || cfolder.Type != (short)AssetType.Clothing) |
1671 | { | 1874 | { |
1672 | cfolder = new InventoryFolderImpl(); | 1875 | cfolder = new InventoryFolderBase(); |
1876 | cfolder.ID = UUID.Random(); | ||
1673 | cfolder.Name = "Clothing"; | 1877 | cfolder.Name = "Clothing"; |
1674 | cfolder.Type = 5; | ||
1675 | cfolder.Version = 1; | ||
1676 | cfolder.Owner = ID; | 1878 | cfolder.Owner = ID; |
1677 | uic.root.AddChildFolder(cfolder); // make connection | 1879 | cfolder.Type = (short)AssetType.Clothing; |
1880 | cfolder.ParentID = iserv.GetRootFolder(ID).ID; | ||
1881 | cfolder.Version = 1; | ||
1678 | iserv.AddFolder(cfolder); // store base record | 1882 | iserv.AddFolder(cfolder); // store base record |
1679 | m_log.ErrorFormat("[RADMIN] Created clothing folder for {0}/{1}", name, ID); | 1883 | m_log.ErrorFormat("[RADMIN] Created clothing folder for {0}/{1}", name, ID); |
1680 | } | 1884 | } |
@@ -1683,7 +1887,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1683 | // default appearance XMl file. | 1887 | // default appearance XMl file. |
1684 | 1888 | ||
1685 | XmlNodeList outfits = avatar.GetElementsByTagName("Ensemble"); | 1889 | XmlNodeList outfits = avatar.GetElementsByTagName("Ensemble"); |
1686 | InventoryFolderImpl efolder; | 1890 | InventoryFolderBase efolder; |
1687 | string oname; | 1891 | string oname; |
1688 | UUID assetid; | 1892 | UUID assetid; |
1689 | 1893 | ||
@@ -1694,13 +1898,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1694 | 1898 | ||
1695 | oname = GetStringAttribute(outfit,"name",""); | 1899 | oname = GetStringAttribute(outfit,"name",""); |
1696 | select = (GetStringAttribute(outfit,"default","no") == "yes"); | 1900 | select = (GetStringAttribute(outfit,"default","no") == "yes"); |
1697 | efolder = null; | ||
1698 | 1901 | ||
1699 | // If the folder already exists, re-use it. The defaults may | 1902 | // If the folder already exists, re-use it. The defaults may |
1700 | // change over time. Augment only. | 1903 | // change over time. Augment only. |
1701 | foreach (InventoryFolderImpl folder in uic.folders) | 1904 | |
1905 | List<InventoryFolderBase> folders = iserv.GetFolderContent(ID, cfolder.ID).Folders; | ||
1906 | efolder = null; | ||
1907 | |||
1908 | foreach (InventoryFolderBase folder in folders) | ||
1702 | { | 1909 | { |
1703 | if (folder.Name == oname && folder.ParentID == cfolder.ID) | 1910 | if (folder.Name == oname) |
1704 | { | 1911 | { |
1705 | efolder = folder; | 1912 | efolder = folder; |
1706 | break; | 1913 | break; |
@@ -1711,14 +1918,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1711 | if (efolder == null) | 1918 | if (efolder == null) |
1712 | { | 1919 | { |
1713 | m_log.DebugFormat("[RADMIN] Creating outfit folder {0} for {1}", oname, name); | 1920 | m_log.DebugFormat("[RADMIN] Creating outfit folder {0} for {1}", oname, name); |
1714 | efolder = new InventoryFolderImpl(); | 1921 | efolder = new InventoryFolderBase(); |
1715 | efolder.ID = UUID.Random(); | 1922 | efolder.ID = UUID.Random(); |
1716 | efolder.Name = oname; | 1923 | efolder.Name = oname; |
1717 | efolder.Type = 5; | ||
1718 | efolder.Version = 1; | ||
1719 | efolder.Owner = ID; | 1924 | efolder.Owner = ID; |
1720 | cfolder.AddChildFolder(efolder); // make connection | 1925 | efolder.Type = (short)AssetType.Clothing; |
1721 | iserv.AddFolder(efolder); // store base record | 1926 | efolder.Version = 1; |
1927 | efolder.ParentID = cfolder.ID; | ||
1928 | iserv.AddFolder(efolder); | ||
1722 | m_log.DebugFormat("[RADMIN] Adding outfile folder {0} to folder {1}", efolder.ID, cfolder.ID); | 1929 | m_log.DebugFormat("[RADMIN] Adding outfile folder {0} to folder {1}", efolder.ID, cfolder.ID); |
1723 | } | 1930 | } |
1724 | 1931 | ||
@@ -1745,26 +1952,55 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1745 | 1952 | ||
1746 | InventoryItemBase iitem = null; | 1953 | InventoryItemBase iitem = null; |
1747 | 1954 | ||
1748 | if ((iitem = efolder.FindAsset(assetid)) == null) | 1955 | // Check if asset is in inventory already |
1956 | iitem = null; | ||
1957 | List<InventoryItemBase> iitems = iserv.GetFolderContent(ID, efolder.ID).Items; | ||
1958 | |||
1959 | foreach (InventoryItemBase litem in iitems) | ||
1960 | { | ||
1961 | if (litem.AssetID == assetid) | ||
1962 | { | ||
1963 | iitem = litem; | ||
1964 | break; | ||
1965 | } | ||
1966 | } | ||
1967 | |||
1968 | // Create inventory item | ||
1969 | if (iitem == null) | ||
1749 | { | 1970 | { |
1750 | iitem = new InventoryItemBase(); | 1971 | iitem = new InventoryItemBase(UUID.Random(), ID); |
1751 | iitem.ID = UUID.Random(); | ||
1752 | iitem.Name = GetStringAttribute(item,"name",""); | 1972 | iitem.Name = GetStringAttribute(item,"name",""); |
1753 | iitem.Description = GetStringAttribute(item,"desc",""); | 1973 | iitem.Description = GetStringAttribute(item,"desc",""); |
1754 | iitem.InvType = GetIntegerAttribute(item,"invtype",-1); | 1974 | iitem.InvType = GetIntegerAttribute(item,"invtype",-1); |
1755 | iitem.AssetType = GetIntegerAttribute(item,"assettype",-1); | 1975 | iitem.CreatorId = GetStringAttribute(item,"creatorid",""); |
1756 | iitem.Flags = GetUnsignedAttribute(item,"flags",0); | 1976 | iitem.CreatorIdAsUuid = (UUID)GetStringAttribute(item,"creatoruuid",""); |
1757 | iitem.AssetID = assetid; // associated asset | ||
1758 | iitem.Folder = efolder.ID; // Parent folder | ||
1759 | iitem.Owner = ID; // Agent ID | ||
1760 | iitem.BasePermissions = GetUnsignedAttribute(perms,"base",0x7fffffff); | ||
1761 | iitem.NextPermissions = GetUnsignedAttribute(perms,"next",0x7fffffff); | 1977 | iitem.NextPermissions = GetUnsignedAttribute(perms,"next",0x7fffffff); |
1762 | iitem.CurrentPermissions = GetUnsignedAttribute(perms,"current",0x7fffffff); | 1978 | iitem.CurrentPermissions = GetUnsignedAttribute(perms,"current",0x7fffffff); |
1763 | iitem.GroupPermissions = GetUnsignedAttribute(perms,"group",0x7fffffff); | 1979 | iitem.BasePermissions = GetUnsignedAttribute(perms,"base",0x7fffffff); |
1764 | iitem.EveryOnePermissions = GetUnsignedAttribute(perms,"everyone",0x7fffffff); | 1980 | iitem.EveryOnePermissions = GetUnsignedAttribute(perms,"everyone",0x7fffffff); |
1765 | m_log.DebugFormat("[RADMIN] Adding item {0} to folder {1}", iitem.ID, efolder.ID); | 1981 | iitem.GroupPermissions = GetUnsignedAttribute(perms,"group",0x7fffffff); |
1982 | iitem.AssetType = GetIntegerAttribute(item,"assettype",-1); | ||
1983 | iitem.AssetID = assetid; // associated asset | ||
1984 | iitem.GroupID = (UUID)GetStringAttribute(item,"groupid",""); | ||
1985 | iitem.GroupOwned = (GetStringAttribute(item,"groupowned","false") == "true"); | ||
1986 | iitem.SalePrice = GetIntegerAttribute(item,"saleprice",0); | ||
1987 | iitem.SaleType = (byte)GetIntegerAttribute(item,"saletype",0); | ||
1988 | iitem.Flags = GetUnsignedAttribute(item,"flags",0); | ||
1989 | iitem.CreationDate = GetIntegerAttribute(item,"creationdate",Util.UnixTimeSinceEpoch()); | ||
1990 | iitem.Folder = efolder.ID; // Parent folder | ||
1991 | |||
1766 | iserv.AddItem(iitem); | 1992 | iserv.AddItem(iitem); |
1993 | m_log.DebugFormat("[RADMIN] Added item {0} to folder {1}", iitem.ID, efolder.ID); | ||
1994 | } | ||
1995 | |||
1996 | // Attach item, if attachpoint is specified | ||
1997 | int attachpoint = GetIntegerAttribute(item,"attachpoint",0); | ||
1998 | if (attachpoint != 0) | ||
1999 | { | ||
2000 | mava.SetAttachment(attachpoint, iitem.ID, iitem.AssetID); | ||
2001 | m_log.DebugFormat("[RADMIN] Attached {0}", iitem.ID); | ||
1767 | } | 2002 | } |
2003 | |||
1768 | // Record whether or not the item is to be initially worn | 2004 | // Record whether or not the item is to be initially worn |
1769 | try | 2005 | try |
1770 | { | 2006 | { |
@@ -1774,25 +2010,22 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1774 | mava.Wearables[iitem.Flags].AssetID = iitem.AssetID; | 2010 | mava.Wearables[iitem.Flags].AssetID = iitem.AssetID; |
1775 | } | 2011 | } |
1776 | } | 2012 | } |
1777 | catch {} | 2013 | catch (Exception e) |
2014 | { | ||
2015 | m_log.WarnFormat("[RADMIN] Error wearing item {0} : {1}", iitem.ID, e.Message); | ||
2016 | } | ||
1778 | } // foreach item in outfit | 2017 | } // foreach item in outfit |
1779 | m_log.DebugFormat("[RADMIN] Outfit {0} load completed", oname); | 2018 | m_log.DebugFormat("[RADMIN] Outfit {0} load completed", oname); |
1780 | } // foreach outfit | 2019 | } // foreach outfit |
1781 | m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name); | 2020 | m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name); |
1782 | AvatarData adata2 = new AvatarData(mava); | 2021 | AvatarData adata2 = new AvatarData(mava); |
1783 | m_app.SceneManager.CurrentOrFirstScene.AvatarService.SetAvatar(ID, adata2); | 2022 | scene.AvatarService.SetAvatar(ID, adata2); |
1784 | } | 2023 | } |
1785 | catch (Exception e) | 2024 | catch (Exception e) |
1786 | { | 2025 | { |
1787 | m_log.WarnFormat("[RADMIN] Inventory processing incomplete for user {0} : {1}", | 2026 | m_log.WarnFormat("[RADMIN] Inventory processing incomplete for user {0} : {1}", |
1788 | name, e.Message); | 2027 | name, e.Message); |
1789 | } | 2028 | } |
1790 | else | ||
1791 | { | ||
1792 | m_log.WarnFormat("[RADMIN] Unable to retrieve inventory for {0}[{1}]", | ||
1793 | name, ID); | ||
1794 | // continue to next avatar | ||
1795 | } | ||
1796 | } // End of include | 2029 | } // End of include |
1797 | } | 2030 | } |
1798 | m_log.DebugFormat("[RADMIN] Default avatar loading complete"); | 2031 | m_log.DebugFormat("[RADMIN] Default avatar loading complete"); |
@@ -2660,81 +2893,115 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
2660 | public void Dispose() | 2893 | public void Dispose() |
2661 | { | 2894 | { |
2662 | } | 2895 | } |
2663 | } | ||
2664 | |||
2665 | class UICallback | ||
2666 | { | ||
2667 | private Object uilock = new Object(); | ||
2668 | internal InventoryFolderImpl root = null; | ||
2669 | internal List<InventoryFolderImpl> folders; | ||
2670 | internal List<InventoryItemBase> items; | ||
2671 | internal bool OK = false; | ||
2672 | |||
2673 | public void callback(ICollection<InventoryFolderImpl> p_folders, ICollection<InventoryItemBase> p_items) | ||
2674 | { | ||
2675 | lock (uilock) | ||
2676 | { | ||
2677 | folders = (List<InventoryFolderImpl>) p_folders; | ||
2678 | items = (List<InventoryItemBase>) p_items; | ||
2679 | OK = true; | ||
2680 | System.Threading.Monitor.Pulse(uilock); | ||
2681 | } | ||
2682 | } | ||
2683 | 2896 | ||
2684 | public void GetInventory() | 2897 | /// <summary> |
2898 | /// Create a user | ||
2899 | /// </summary> | ||
2900 | /// <param name="scopeID"></param> | ||
2901 | /// <param name="firstName"></param> | ||
2902 | /// <param name="lastName"></param> | ||
2903 | /// <param name="password"></param> | ||
2904 | /// <param name="email"></param> | ||
2905 | private UserAccount CreateUser(UUID scopeID, string firstName, string lastName, string password, string email) | ||
2685 | { | 2906 | { |
2686 | Dictionary<UUID, InventoryFolderImpl> fmap = new Dictionary<UUID, InventoryFolderImpl>(); | 2907 | Scene scene = m_app.SceneManager.CurrentOrFirstScene; |
2687 | 2908 | IUserAccountService m_UserAccountService = scene.UserAccountService; | |
2688 | if (OK == false) | 2909 | IGridService m_GridService = scene.GridService; |
2910 | IAuthenticationService m_AuthenticationService = scene.AuthenticationService; | ||
2911 | IGridUserService m_GridUserService = scene.GridUserService; | ||
2912 | IInventoryService m_InventoryService = scene.InventoryService; | ||
2913 | |||
2914 | UserAccount account = m_UserAccountService.GetUserAccount(scopeID, firstName, lastName); | ||
2915 | if (null == account) | ||
2689 | { | 2916 | { |
2690 | lock (uilock) | 2917 | account = new UserAccount(scopeID, firstName, lastName, email); |
2918 | if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) | ||
2691 | { | 2919 | { |
2692 | if (OK == false) | 2920 | account.ServiceURLs = new Dictionary<string, object>(); |
2693 | System.Threading.Monitor.Wait(uilock); | 2921 | account.ServiceURLs["HomeURI"] = string.Empty; |
2922 | account.ServiceURLs["GatekeeperURI"] = string.Empty; | ||
2923 | account.ServiceURLs["InventoryServerURI"] = string.Empty; | ||
2924 | account.ServiceURLs["AssetServerURI"] = string.Empty; | ||
2694 | } | 2925 | } |
2695 | } | ||
2696 | |||
2697 | // Got the inventory OK. So now merge the content of the default appearance | ||
2698 | // file with whatever we already have in-world. For convenience we initialize | ||
2699 | // the inventory hierarchy. | ||
2700 | 2926 | ||
2701 | // Find root and build an index | 2927 | if (m_UserAccountService.StoreUserAccount(account)) |
2702 | |||
2703 | foreach (InventoryFolderImpl folder in folders) | ||
2704 | { | ||
2705 | if (folder.ParentID == UUID.Zero) | ||
2706 | { | 2928 | { |
2707 | if (root == null) | 2929 | bool success; |
2930 | if (m_AuthenticationService != null) | ||
2708 | { | 2931 | { |
2709 | root = folder; | 2932 | success = m_AuthenticationService.SetPassword(account.PrincipalID, password); |
2933 | if (!success) | ||
2934 | m_log.WarnFormat("[RADMIN]: Unable to set password for account {0} {1}.", | ||
2935 | firstName, lastName); | ||
2936 | } | ||
2937 | |||
2938 | GridRegion home = null; | ||
2939 | if (m_GridService != null) | ||
2940 | { | ||
2941 | List<GridRegion> defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero); | ||
2942 | if (defaultRegions != null && defaultRegions.Count >= 1) | ||
2943 | home = defaultRegions[0]; | ||
2944 | |||
2945 | if (m_GridUserService != null && home != null) | ||
2946 | m_GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
2947 | else | ||
2948 | m_log.WarnFormat("[RADMIN]: Unable to set home for account {0} {1}.", | ||
2949 | firstName, lastName); | ||
2710 | } | 2950 | } |
2711 | else | 2951 | else |
2952 | m_log.WarnFormat("[RADMIN]: Unable to retrieve home region for account {0} {1}.", | ||
2953 | firstName, lastName); | ||
2954 | |||
2955 | if (m_InventoryService != null) | ||
2712 | { | 2956 | { |
2713 | throw new Exception("Multiple root folders found"); | 2957 | success = m_InventoryService.CreateUserInventory(account.PrincipalID); |
2958 | if (!success) | ||
2959 | m_log.WarnFormat("[RADMIN]: Unable to create inventory for account {0} {1}.", | ||
2960 | firstName, lastName); | ||
2714 | } | 2961 | } |
2962 | |||
2963 | m_log.InfoFormat("[RADMIN]: Account {0} {1} created successfully", firstName, lastName); | ||
2964 | return account; | ||
2965 | } else { | ||
2966 | m_log.ErrorFormat("[RADMIN]: Account creation failed for account {0} {1}", firstName, lastName); | ||
2715 | } | 2967 | } |
2716 | fmap.Add(folder.ID, folder); | ||
2717 | } | 2968 | } |
2718 | 2969 | else | |
2719 | // Hard to continue if the root folder is not there | ||
2720 | if (root == null) | ||
2721 | { | 2970 | { |
2722 | throw new Exception("Root folder not found"); | 2971 | m_log.ErrorFormat("[RADMIN]: A user with the name {0} {1} already exists!", firstName, lastName); |
2723 | } | 2972 | } |
2973 | return null; | ||
2974 | } | ||
2724 | 2975 | ||
2725 | // Construct the folder hierarchy | 2976 | /// <summary> |
2726 | foreach (InventoryFolderImpl folder in folders) | 2977 | /// Change password |
2978 | /// </summary> | ||
2979 | /// <param name="firstName"></param> | ||
2980 | /// <param name="lastName"></param> | ||
2981 | /// <param name="password"></param> | ||
2982 | private bool ChangeUserPassword(string firstName, string lastName, string password) | ||
2983 | { | ||
2984 | Scene scene = m_app.SceneManager.CurrentOrFirstScene; | ||
2985 | IUserAccountService m_UserAccountService = scene.UserAccountService; | ||
2986 | IAuthenticationService m_AuthenticationService = scene.AuthenticationService; | ||
2987 | |||
2988 | UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName); | ||
2989 | if (null != account) | ||
2727 | { | 2990 | { |
2728 | if (folder.ID != root.ID) | 2991 | bool success = false; |
2729 | { | 2992 | if (m_AuthenticationService != null) |
2730 | fmap[folder.ParentID].AddChildFolder(folder); | 2993 | success = m_AuthenticationService.SetPassword(account.PrincipalID, password); |
2994 | if (!success) { | ||
2995 | m_log.WarnFormat("[RADMIN]: Unable to set password for account {0} {1}.", | ||
2996 | firstName, lastName); | ||
2997 | return false; | ||
2731 | } | 2998 | } |
2999 | return true; | ||
2732 | } | 3000 | } |
2733 | 3001 | else | |
2734 | // Find a home for every pre-existing item | ||
2735 | foreach (InventoryItemBase item in items) | ||
2736 | { | 3002 | { |
2737 | fmap[item.Folder].Items.Add(item.ID, item); | 3003 | m_log.ErrorFormat("[RADMIN]: No such user"); |
3004 | return false; | ||
2738 | } | 3005 | } |
2739 | } | 3006 | } |
2740 | } | 3007 | } |