From 7def786ef4d62c2ffad8cea0cba7db033f8f0d27 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Mon, 22 Sep 2008 11:20:09 +0000 Subject: cleanups in inventory REST code. also, disables digest authentications for inventory REST calls for the time being, as firefox, curl, and also python's urllib2 cannot authenticate using digest auth. fix permission checking for prim inventory to be the same as for normal edit ops. --- .../Rest/Inventory/RestAppearanceServices.cs | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs') diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs index 18a0baf..8db3fde 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs @@ -45,7 +45,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory public class RestAppearanceServices : IRest { private static readonly int PARM_USERID = 0; - //private static readonly int PARM_PATH = 1; + // private static readonly int PARM_PATH = 1; private bool enabled = false; private string qPrefix = "appearance"; @@ -166,6 +166,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory try { + // digest scheme seems borked: disable it for the time + // being + rdata.scheme = Rest.AS_BASIC; if (!rdata.IsAuthenticated) { rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName)); @@ -335,7 +338,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID); rdata.userAppearance = new AvatarAppearance(); - rdata.userAppearance.Owner = old.Owner; + rdata.userAppearance.Owner = old.Owner; + rdata.userAppearance.Serial = old.Serial; if (GetUserAppearance(rdata)) { @@ -343,6 +347,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory created = !modified; Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); } + else + { + created = true; + Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); + } if (created) { @@ -383,11 +392,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID); - if (GetUserAppearance(rdata)) + // If the user exists then this is considered a modification regardless + // of what may, or may not be, specified in the payload. + + if (rdata.userAppearance != null) { - modified = rdata.userAppearance != null; - created = !modified; - Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); + modified = true; + Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); } if (created) @@ -465,6 +476,16 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory rdata.userAppearance.AvatarHeight = (float) Convert.ToDouble(xml.Value); indata = true; } + if (xml.MoveToAttribute("Owner")) + { + rdata.userAppearance.Owner = xml.Value; + indata = true; + } + if (xml.MoveToAttribute("Serial")) + { + rdata.userAppearance.Serial = Convert.ToInt32(xml.Value); + indata = true; + } break; case "Body" : if (xml.MoveToAttribute("Item")) @@ -687,6 +708,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory rdata.writer.WriteStartElement("Appearance"); rdata.writer.WriteAttributeString("Height", rdata.userAppearance.AvatarHeight.ToString()); + rdata.writer.WriteAttributeString("Owner", rdata.userAppearance.Owner.ToString()); + rdata.writer.WriteAttributeString("Serial", rdata.userAppearance.Serial.ToString()); rdata.writer.WriteStartElement("Body"); rdata.writer.WriteAttributeString("Item",rdata.userAppearance.BodyItem.ToString()); -- cgit v1.1