Some OSGrid specific changes, please use this or later for OSGrid use

remotes/origin/0.6.7-post-fixes
Melanie 2009-09-15 07:55:29 +01:00
parent 1ad35f65b3
commit 7c925744f6
3 changed files with 45 additions and 24 deletions

View File

@ -91,12 +91,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
scene.AddCommand(
this, "load iar",
"load iar <first> <last> <inventory path> [<archive path>]",
"load iar <first> <last> <inventory path> <password> [<archive path>]",
"Load user inventory archive. EXPERIMENTAL", HandleLoadInvConsoleCommand);
scene.AddCommand(
this, "save iar",
"save iar <first> <last> <inventory path> [<archive path>]",
"save iar <first> <last> <inventory path> <password> [<archive path>]",
"Save user inventory archive. EXPERIMENTAL", HandleSaveInvConsoleCommand);
m_aScene = scene;
@ -121,11 +121,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException);
}
public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream)
public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream)
{
if (m_scenes.Count > 0)
{
CachedUserInfo userInfo = GetUserInfo(firstName, lastName);
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt);
if (userInfo.UserProfile.PasswordHash != md5PasswdHash)
return false;
if (userInfo != null)
{
@ -146,11 +149,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return false;
}
public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath)
public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, string savePath)
{
if (m_scenes.Count > 0)
{
CachedUserInfo userInfo = GetUserInfo(firstName, lastName);
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt);
if (userInfo.UserProfile.PasswordHash != md5PasswdHash)
return false;
if (userInfo != null)
{
@ -171,11 +178,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return false;
}
public bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream)
public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream)
{
if (m_scenes.Count > 0)
{
CachedUserInfo userInfo = GetUserInfo(firstName, lastName);
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt);
if (userInfo.UserProfile.PasswordHash != md5PasswdHash)
return false;
if (userInfo != null)
{
@ -199,11 +210,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return false;
}
public bool DearchiveInventory(string firstName, string lastName, string invPath, string loadPath)
public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, string loadPath)
{
if (m_scenes.Count > 0)
{
CachedUserInfo userInfo = GetUserInfo(firstName, lastName);
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt);
if (userInfo.UserProfile.PasswordHash != md5PasswdHash)
return false;
if (userInfo != null)
{
@ -233,10 +248,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// <param name="cmdparams"></param>
protected void HandleLoadInvConsoleCommand(string module, string[] cmdparams)
{
if (cmdparams.Length < 5)
if (cmdparams.Length < 6)
{
m_log.Error(
"[INVENTORY ARCHIVER]: usage is load iar <first name> <last name> <inventory path> [<load file path>]");
"[INVENTORY ARCHIVER]: usage is load iar <first name> <last name> <inventory path> <password> [<load file path>]");
return;
}
@ -245,13 +260,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
string firstName = cmdparams[2];
string lastName = cmdparams[3];
string invPath = cmdparams[4];
string loadPath = (cmdparams.Length > 5 ? cmdparams[5] : DEFAULT_INV_BACKUP_FILENAME);
string pass = cmdparams[5];
string loadPath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME);
m_log.InfoFormat(
"[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}",
loadPath, invPath, firstName, lastName);
if (DearchiveInventory(firstName, lastName, invPath, loadPath))
if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath))
m_log.InfoFormat(
"[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}",
loadPath, firstName, lastName);
@ -266,7 +282,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (cmdparams.Length < 5)
{
m_log.Error(
"[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> [<save file path>]");
"[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <password> [<save file path>]");
return;
}
@ -275,14 +291,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
string firstName = cmdparams[2];
string lastName = cmdparams[3];
string invPath = cmdparams[4];
string savePath = (cmdparams.Length > 5 ? cmdparams[5] : DEFAULT_INV_BACKUP_FILENAME);
string pass = cmdparams[5];
string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME);
m_log.InfoFormat(
"[INVENTORY ARCHIVER]: Saving archive {0} from inventory path {1} for {2} {3}",
savePath, invPath, firstName, lastName);
Guid id = Guid.NewGuid();
ArchiveInventory(id, firstName, lastName, invPath, savePath);
ArchiveInventory(id, firstName, lastName, invPath, pass, savePath);
lock (m_pendingConsoleSaves)
m_pendingConsoleSaves.Add(id);
@ -373,8 +390,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
foreach (Scene scene in m_scenes.Values)
{
if (scene.GetScenePresence(userId) != null)
ScenePresence p;
if ((p = scene.GetScenePresence(userId)) != null)
{
p.ControllingClient.SendAgentAlertMessage("Inventory operation has been started", false);
return true;
}
}
return false;

View File

@ -143,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
mre.Reset();
archiverModule.ArchiveInventory(
Guid.NewGuid(), userFirstName, userLastName, "Objects", archiveWriteStream);
Guid.NewGuid(), userFirstName, userLastName, "Objects", "troll", archiveWriteStream);
mre.WaitOne(60000, false);
byte[] archive = archiveWriteStream.ToArray();
@ -253,7 +253,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
userItemCreatorFirstName, userItemCreatorLastName, "hampshire",
String.Empty, 1000, 1000, userItemCreatorUuid);
archiverModule.DearchiveInventory(userFirstName, userLastName, "/", archiveReadStream);
archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream);
CachedUserInfo userInfo
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
@ -274,7 +274,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
// Now try loading to a root child folder
UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA");
archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", archiveReadStream);
archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "troll", archiveReadStream);
InventoryItemBase foundItem2
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + itemName);
@ -283,7 +283,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
// Now try loading to a more deeply nested folder
UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC");
archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", archiveReadStream);
archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "troll", archiveReadStream);
InventoryItemBase foundItem3
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + itemName);
@ -343,7 +343,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
userAdminService.AddUser(
userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
archiverModule.DearchiveInventory(userFirstName, userLastName, "/", archiveReadStream);
archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream);
CachedUserInfo userInfo
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
@ -408,7 +408,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
userAdminService.AddUser(
userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
archiverModule.DearchiveInventory(userFirstName, userLastName, "/", archiveReadStream);
archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream);
// Check that a suitable temporary user profile has been created.
UserProfileData user2Profile

View File

@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="invPath">The inventory path in which to place the loaded folders and items</param>
/// <param name="loadStream">The stream from which the inventory archive will be loaded</param>
/// <returns>true if the first stage of the operation succeeded, false otherwise</returns>
bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream);
bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream);
/// <summary>
/// Archive a user's inventory folder to the given stream
@ -69,6 +69,6 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="invPath">The inventory path from which the inventory should be saved.</param>
/// <param name="saveStream">The stream to which the inventory archive will be saved</param>
/// <returns>true if the first stage of the operation succeeded, false otherwise</returns>
bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream);
bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream);
}
}