mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
Merge branch 'master' into careminster-presence-refactor
This commit is contained in:
@@ -109,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
|
||||
|
||||
// Try to parse the texture ID from the request URL
|
||||
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
|
||||
string textureStr = GetOne(query, "texture_id");
|
||||
string textureStr = query.GetOne("texture_id");
|
||||
|
||||
if (m_assetService == null)
|
||||
{
|
||||
@@ -166,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
|
||||
|
||||
private void SendTexture(OSHttpRequest request, OSHttpResponse response, AssetBase texture)
|
||||
{
|
||||
string range = GetOne(request.Headers, "Range");
|
||||
string range = request.Headers.GetOne("Range");
|
||||
if (!String.IsNullOrEmpty(range))
|
||||
{
|
||||
// Range request
|
||||
@@ -216,14 +216,5 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
|
||||
start = end = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static string GetOne(NameValueCollection collection, string key)
|
||||
{
|
||||
string[] values = collection.GetValues(key);
|
||||
if (values != null && values.Length > 0)
|
||||
return values[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ using System.Reflection;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
@@ -169,6 +170,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RezMultipleAttachmentsFromInventory(
|
||||
IClientAPI remoteClient,
|
||||
RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
|
||||
RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects)
|
||||
{
|
||||
foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects)
|
||||
{
|
||||
RezSingleAttachmentFromInventory(remoteClient, obj.ItemID, obj.AttachmentPt);
|
||||
}
|
||||
}
|
||||
|
||||
public UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
|
||||
{
|
||||
m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name);
|
||||
@@ -238,6 +250,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
itemID, remoteClient.Name, AttachmentPt);
|
||||
}
|
||||
|
||||
objatt.ResumeScripts();
|
||||
return objatt;
|
||||
}
|
||||
|
||||
@@ -311,6 +324,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
}
|
||||
}
|
||||
|
||||
public void DetachObject(uint objectLocalID, IClientAPI remoteClient)
|
||||
{
|
||||
SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID);
|
||||
if (group != null)
|
||||
{
|
||||
//group.DetachToGround();
|
||||
ShowDetachInUserInventory(group.GetFromItemID(), remoteClient);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient)
|
||||
{
|
||||
ScenePresence presence;
|
||||
@@ -329,6 +352,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
DetachSingleAttachmentToInv(itemID, remoteClient);
|
||||
}
|
||||
|
||||
public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient)
|
||||
{
|
||||
SceneObjectPart part = m_scene.GetSceneObjectPart(itemID);
|
||||
if (part == null || part.ParentGroup == null)
|
||||
return;
|
||||
|
||||
UUID inventoryID = part.ParentGroup.GetFromItemID();
|
||||
|
||||
ScenePresence presence;
|
||||
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
|
||||
{
|
||||
if (!m_scene.Permissions.CanRezObject(
|
||||
part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition))
|
||||
return;
|
||||
|
||||
presence.Appearance.DetachAttachment(itemID);
|
||||
|
||||
if (m_scene.AvatarFactory != null)
|
||||
{
|
||||
m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
part.ParentGroup.DetachToGround();
|
||||
|
||||
List<UUID> uuids = new List<UUID>();
|
||||
uuids.Add(inventoryID);
|
||||
m_scene.InventoryService.DeleteItems(remoteClient.AgentId, uuids);
|
||||
remoteClient.SendRemoveInventoryItem(inventoryID);
|
||||
}
|
||||
|
||||
m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero);
|
||||
}
|
||||
|
||||
// What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
|
||||
// To LocalId or UUID, *THAT* is the question. How now Brown UUID??
|
||||
protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
|
||||
@@ -359,4 +414,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -621,6 +621,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
}
|
||||
}
|
||||
|
||||
rootPart.ParentGroup.ResumeScripts();
|
||||
return rootPart.ParentGroup;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,10 +311,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||
{
|
||||
// m_log.DebugFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Requesting inventory item {0}", item.ID);
|
||||
|
||||
UUID requestedItemId = item.ID;
|
||||
|
||||
item = m_InventoryService.GetItem(item);
|
||||
|
||||
if (null == item)
|
||||
m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", item.ID);
|
||||
m_log.ErrorFormat(
|
||||
"[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", requestedItemId);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -53,25 +53,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
|
||||
private static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
|
||||
|
||||
private Scene m_scene;
|
||||
private Stream m_loadStream;
|
||||
private Guid m_requestId;
|
||||
private string m_errorMessage;
|
||||
protected Scene m_scene;
|
||||
protected Stream m_loadStream;
|
||||
protected Guid m_requestId;
|
||||
protected string m_errorMessage;
|
||||
|
||||
/// <value>
|
||||
/// Should the archive being loaded be merged with what is already on the region?
|
||||
/// </value>
|
||||
private bool m_merge;
|
||||
protected bool m_merge;
|
||||
|
||||
/// <value>
|
||||
/// Should we ignore any assets when reloading the archive?
|
||||
/// </value>
|
||||
protected bool m_skipAssets;
|
||||
|
||||
/// <summary>
|
||||
/// Used to cache lookups for valid uuids.
|
||||
/// </summary>
|
||||
private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>();
|
||||
|
||||
public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId)
|
||||
public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId)
|
||||
{
|
||||
m_scene = scene;
|
||||
|
||||
@@ -89,14 +91,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
m_errorMessage = String.Empty;
|
||||
m_merge = merge;
|
||||
m_skipAssets = skipAssets;
|
||||
m_requestId = requestId;
|
||||
}
|
||||
|
||||
public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, Guid requestId)
|
||||
public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_loadStream = loadStream;
|
||||
m_merge = merge;
|
||||
m_skipAssets = skipAssets;
|
||||
m_requestId = requestId;
|
||||
}
|
||||
|
||||
@@ -133,9 +137,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
|
||||
{
|
||||
serialisedSceneObjects.Add(m_utf8Encoding.GetString(data));
|
||||
serialisedSceneObjects.Add(Encoding.UTF8.GetString(data));
|
||||
}
|
||||
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
|
||||
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH) && !m_skipAssets)
|
||||
{
|
||||
if (LoadAsset(filePath, data))
|
||||
successfulAssetRestores++;
|
||||
@@ -155,7 +159,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
}
|
||||
else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH))
|
||||
{
|
||||
serialisedParcels.Add(m_utf8Encoding.GetString(data));
|
||||
serialisedParcels.Add(Encoding.UTF8.GetString(data));
|
||||
}
|
||||
else if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
|
||||
{
|
||||
@@ -178,12 +182,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
archive.Close();
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
|
||||
|
||||
if (failedAssetRestores > 0)
|
||||
if (!m_skipAssets)
|
||||
{
|
||||
m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
|
||||
m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
|
||||
m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
|
||||
|
||||
if (failedAssetRestores > 0)
|
||||
{
|
||||
m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
|
||||
m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_merge)
|
||||
@@ -279,6 +286,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
{
|
||||
sceneObjectsLoadedCount++;
|
||||
sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0);
|
||||
sceneObject.ResumeScripts();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,7 +551,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
|
||||
|
||||
XmlTextReader xtr
|
||||
= new XmlTextReader(m_asciiEncoding.GetString(data), XmlNodeType.Document, context);
|
||||
= new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context);
|
||||
|
||||
RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings;
|
||||
|
||||
|
||||
@@ -94,8 +94,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
public void HandleLoadOarConsoleCommand(string module, string[] cmdparams)
|
||||
{
|
||||
bool mergeOar = false;
|
||||
bool skipAssets = false;
|
||||
|
||||
OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; });
|
||||
options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; });
|
||||
|
||||
List<string> mainParams = options.Parse(cmdparams);
|
||||
|
||||
// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar);
|
||||
@@ -105,11 +108,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
if (mainParams.Count > 2)
|
||||
{
|
||||
DearchiveRegion(mainParams[2], mergeOar, Guid.Empty);
|
||||
DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, Guid.Empty);
|
||||
DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, Guid.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,25 +157,25 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
public void DearchiveRegion(string loadPath)
|
||||
{
|
||||
DearchiveRegion(loadPath, false, Guid.Empty);
|
||||
DearchiveRegion(loadPath, false, false, Guid.Empty);
|
||||
}
|
||||
|
||||
public void DearchiveRegion(string loadPath, bool merge, Guid requestId)
|
||||
public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath);
|
||||
|
||||
new ArchiveReadRequest(m_scene, loadPath, merge, requestId).DearchiveRegion();
|
||||
new ArchiveReadRequest(m_scene, loadPath, merge, skipAssets, requestId).DearchiveRegion();
|
||||
}
|
||||
|
||||
public void DearchiveRegion(Stream loadStream)
|
||||
{
|
||||
DearchiveRegion(loadStream, false, Guid.Empty);
|
||||
DearchiveRegion(loadStream, false, false, Guid.Empty);
|
||||
}
|
||||
|
||||
public void DearchiveRegion(Stream loadStream, bool merge, Guid requestId)
|
||||
public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId)
|
||||
{
|
||||
new ArchiveReadRequest(m_scene, loadStream, merge, requestId).DearchiveRegion();
|
||||
new ArchiveReadRequest(m_scene, loadStream, merge, skipAssets, requestId).DearchiveRegion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
|
||||
byte[] archive = archiveWriteStream.ToArray();
|
||||
MemoryStream archiveReadStream = new MemoryStream(archive);
|
||||
|
||||
m_archiverModule.DearchiveRegion(archiveReadStream, true, Guid.Empty);
|
||||
m_archiverModule.DearchiveRegion(archiveReadStream, true, false, Guid.Empty);
|
||||
|
||||
SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
|
||||
Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");
|
||||
|
||||
@@ -162,7 +162,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
||||
private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>();
|
||||
private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>();
|
||||
private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>();
|
||||
private IFriendsModule m_friendsModule = null;
|
||||
private IFriendsModule m_friendsModule;
|
||||
private IGroupsModule m_groupsModule;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -386,9 +387,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
||||
m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
|
||||
|
||||
if (m_friendsModule == null)
|
||||
m_log.Error("[PERMISSIONS]: Friends module not found, friend permissions will not work");
|
||||
else
|
||||
m_log.Info("[PERMISSIONS]: Friends module found, friend permissions enabled");
|
||||
m_log.Warn("[PERMISSIONS]: Friends module not found, friend permissions will not work");
|
||||
|
||||
m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
|
||||
|
||||
if (m_groupsModule == null)
|
||||
m_log.Warn("[PERMISSIONS]: Groups module not found, group permissions will not work");
|
||||
}
|
||||
|
||||
public void Close()
|
||||
@@ -423,14 +427,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
||||
// with the powers requested (powers = 0 for no powers check)
|
||||
protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers)
|
||||
{
|
||||
ScenePresence sp = m_scene.GetScenePresence(userID);
|
||||
if (sp != null)
|
||||
{
|
||||
IClientAPI client = sp.ControllingClient;
|
||||
if (null == m_groupsModule)
|
||||
return false;
|
||||
|
||||
return ((groupID == client.ActiveGroupId) && (client.ActiveGroupPowers != 0) &&
|
||||
((powers == 0) || ((client.ActiveGroupPowers & powers) == powers)));
|
||||
GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID);
|
||||
|
||||
if (gmd != null)
|
||||
{
|
||||
if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -721,8 +728,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
||||
permission = false;
|
||||
}
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[PERMISSIONS]: group.GroupID = {0}, part.GroupMask = {1}, isGroupMember = {2} for {3}",
|
||||
// group.GroupID,
|
||||
// m_scene.GetSceneObjectPart(objId).GroupMask,
|
||||
// IsGroupMember(group.GroupID, currentUser, 0),
|
||||
// currentUser);
|
||||
|
||||
// Group members should be able to edit group objects
|
||||
if ((group.GroupID != UUID.Zero) && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0) && IsGroupMember(group.GroupID, currentUser, 0))
|
||||
if ((group.GroupID != UUID.Zero)
|
||||
&& ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0)
|
||||
&& IsGroupMember(group.GroupID, currentUser, 0))
|
||||
{
|
||||
// Return immediately, so that the administrator can shares group objects
|
||||
return true;
|
||||
@@ -957,7 +973,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
||||
DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
|
||||
if (m_bypassPermissions) return m_bypassPermissionsValue;
|
||||
|
||||
|
||||
return GenericObjectPermission(editorID, objectID, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user