aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDr Scofield2008-09-24 11:39:08 +0000
committerDr Scofield2008-09-24 11:39:08 +0000
commit201805172fe71b125391700529035835cef340a1 (patch)
treec60bf25591a5af8ce2897366b28ea68dbf4ef98a /OpenSim
parentMantis #2250 (diff)
downloadopensim-SC_OLD-201805172fe71b125391700529035835cef340a1.zip
opensim-SC_OLD-201805172fe71b125391700529035835cef340a1.tar.gz
opensim-SC_OLD-201805172fe71b125391700529035835cef340a1.tar.bz2
opensim-SC_OLD-201805172fe71b125391700529035835cef340a1.tar.xz
cleanups, fixing REST appearance services.
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs2
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs236
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs2
3 files changed, 128 insertions, 112 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs
index 972d840..12caf81 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs
@@ -1103,7 +1103,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
1103 // Respond to the client's request, tag the response (for the 1103 // Respond to the client's request, tag the response (for the
1104 // benefit of trace) to indicate the reason. 1104 // benefit of trace) to indicate the reason.
1105 1105
1106 Respond(String.Format("Failure response: ({0}) : {1}", 1106 Respond(String.Format("Failure response: ({0}) : {1} ",
1107 code, Rest.HttpStatusDesc[code])); 1107 code, Rest.HttpStatusDesc[code]));
1108 1108
1109 // Finally initialize and the throw a RestException. All of the 1109 // Finally initialize and the throw a RestException. All of the
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
index 82c0c2b..c375ade 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
@@ -42,9 +42,12 @@ using Nini.Config;
42 42
43namespace OpenSim.ApplicationPlugins.Rest.Inventory 43namespace OpenSim.ApplicationPlugins.Rest.Inventory
44{ 44{
45
45 public class RestAppearanceServices : IRest 46 public class RestAppearanceServices : IRest
46 { 47 {
48
47 private static readonly int PARM_USERID = 0; 49 private static readonly int PARM_USERID = 0;
50
48 // private static readonly int PARM_PATH = 1; 51 // private static readonly int PARM_PATH = 1;
49 52
50 private bool enabled = false; 53 private bool enabled = false;
@@ -139,6 +142,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
139 142
140 private void DoAppearance(RequestData hdata) 143 private void DoAppearance(RequestData hdata)
141 { 144 {
145
142 AppearanceRequestData rdata = (AppearanceRequestData) hdata; 146 AppearanceRequestData rdata = (AppearanceRequestData) hdata;
143 147
144 Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId); 148 Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId);
@@ -207,7 +211,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
207 // inventory. 211 // inventory.
208 // 212 //
209 213
210
211 // Do we have at least a user agent name? 214 // Do we have at least a user agent name?
212 215
213 if (rdata.Parameters.Length < 1) 216 if (rdata.Parameters.Length < 1)
@@ -306,7 +309,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
306 309
307 if (rdata.userAppearance == null) 310 if (rdata.userAppearance == null)
308 { 311 {
309 rdata.Fail(Rest.HttpStatusCodeNoContent,"appearance data not found"); 312 rdata.Fail(Rest.HttpStatusCodeNoContent,
313 String.Format("appearance data not found for user {0} {1}",
314 rdata.userProfile.FirstName, rdata.userProfile.SurName));
310 } 315 }
311 316
312 rdata.initXmlWriter(); 317 rdata.initXmlWriter();
@@ -331,26 +336,34 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
331 336
332 private void DoExtend(AppearanceRequestData rdata) 337 private void DoExtend(AppearanceRequestData rdata)
333 { 338 {
339
334 bool created = false; 340 bool created = false;
335 bool modified = false; 341 bool modified = false;
336 string newnode = String.Empty; 342 string newnode = String.Empty;
337 343
344 Rest.Log.DebugFormat("{0} POST ENTRY", MsgId);
345
338 AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID); 346 AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
347
339 rdata.userAppearance = new AvatarAppearance(); 348 rdata.userAppearance = new AvatarAppearance();
340 349
341 rdata.userAppearance.Owner = old.Owner; 350 // Although the following behavior is admitted by HTTP I am becoming
342 rdata.userAppearance.Serial = old.Serial; 351 // increasingly doubtful that it is appropriate for REST. If I attempt to
352 // add a new record, and it already exists, then it seems to me that the
353 // attempt should fail, rather than update the existing record.
343 354
344 if (GetUserAppearance(rdata)) 355 if (GetUserAppearance(rdata))
345 { 356 {
346 modified = rdata.userAppearance != null; 357 modified = rdata.userAppearance != null;
347 created = !modified; 358 created = !modified;
348 Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); 359 Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
360 // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
349 } 361 }
350 else 362 else
351 { 363 {
352 created = true; 364 created = true;
353 Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); 365 Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
366 // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
354 } 367 }
355 368
356 if (created) 369 if (created)
@@ -358,9 +371,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
358 newnode = String.Format("{0} {1}", rdata.userProfile.FirstName, 371 newnode = String.Format("{0} {1}", rdata.userProfile.FirstName,
359 rdata.userProfile.SurName); 372 rdata.userProfile.SurName);
360 // Must include a location header with a URI that identifies the new resource. 373 // Must include a location header with a URI that identifies the new resource.
374
361 rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}{3}{4}", 375 rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}{3}{4}",
362 rdata.hostname,rdata.port,rdata.path,Rest.UrlPathSeparator, newnode)); 376 rdata.hostname,rdata.port,rdata.path,Rest.UrlPathSeparator, newnode));
363 rdata.Complete(Rest.HttpStatusCodeCreated); 377 rdata.Complete(Rest.HttpStatusCodeCreated);
378
364 } 379 }
365 else 380 else
366 { 381 {
@@ -399,6 +414,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
399 { 414 {
400 modified = true; 415 modified = true;
401 Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); 416 Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
417 Rest.UserServices.UpdateUserProfile(rdata.userProfile);
402 } 418 }
403 419
404 if (created) 420 if (created)
@@ -703,121 +719,123 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
703 719
704 } 720 }
705 721
706 private void FormatUserAppearance(AppearanceRequestData rdata) 722 private void FormatPart(AppearanceRequestData rdata, string part, UUID item, UUID asset)
707 { 723 {
708 724 if(item != UUID.Zero || asset != UUID.Zero)
709 rdata.writer.WriteStartElement("Appearance");
710 rdata.writer.WriteAttributeString("Height", rdata.userAppearance.AvatarHeight.ToString());
711 rdata.writer.WriteAttributeString("Owner", rdata.userAppearance.Owner.ToString());
712 rdata.writer.WriteAttributeString("Serial", rdata.userAppearance.Serial.ToString());
713
714 rdata.writer.WriteStartElement("Body");
715 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.BodyItem.ToString());
716 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.BodyAsset.ToString());
717 rdata.writer.WriteEndElement();
718
719 rdata.writer.WriteStartElement("Skin");
720 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.SkinItem.ToString());
721 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.SkinAsset.ToString());
722 rdata.writer.WriteEndElement();
723
724 rdata.writer.WriteStartElement("Hair");
725 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.HairItem.ToString());
726 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.HairAsset.ToString());
727 rdata.writer.WriteEndElement();
728
729 rdata.writer.WriteStartElement("Eyes");
730 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.EyesItem.ToString());
731 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.EyesAsset.ToString());
732 rdata.writer.WriteEndElement();
733
734 rdata.writer.WriteStartElement("Shirt");
735 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.ShirtItem.ToString());
736 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.ShirtAsset.ToString());
737 rdata.writer.WriteEndElement();
738
739 rdata.writer.WriteStartElement("Pants");
740 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.PantsItem.ToString());
741 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.PantsAsset.ToString());
742 rdata.writer.WriteEndElement();
743
744 rdata.writer.WriteStartElement("Shoes");
745 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.ShoesItem.ToString());
746 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.ShoesAsset.ToString());
747 rdata.writer.WriteEndElement();
748
749 rdata.writer.WriteStartElement("Socks");
750 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.SocksItem.ToString());
751 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.SocksAsset.ToString());
752 rdata.writer.WriteEndElement();
753
754 rdata.writer.WriteStartElement("Jacket");
755 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.JacketItem.ToString());
756 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.JacketAsset.ToString());
757 rdata.writer.WriteEndElement();
758
759 rdata.writer.WriteStartElement("Gloves");
760 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.GlovesItem.ToString());
761 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.GlovesAsset.ToString());
762 rdata.writer.WriteEndElement();
763
764 rdata.writer.WriteStartElement("UnderShirt");
765 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.UnderShirtItem.ToString());
766 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.UnderShirtAsset.ToString());
767 rdata.writer.WriteEndElement();
768
769 rdata.writer.WriteStartElement("UnderPants");
770 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.UnderPantsItem.ToString());
771 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.UnderPantsAsset.ToString());
772 rdata.writer.WriteEndElement();
773
774 rdata.writer.WriteStartElement("Skirt");
775 rdata.writer.WriteAttributeString("Item",rdata.userAppearance.SkirtItem.ToString());
776 rdata.writer.WriteAttributeString("Asset",rdata.userAppearance.SkirtAsset.ToString());
777 rdata.writer.WriteEndElement();
778
779 Hashtable attachments = rdata.userAppearance.GetAttachments();
780
781 rdata.writer.WriteStartElement("Attachments");
782
783 for (int i=0; i<attachments.Count;i++)
784 { 725 {
785 Hashtable attachment = attachments[i] as Hashtable; 726 rdata.writer.WriteStartElement(part);
786 rdata.writer.WriteStartElement("Attachment"); 727 if(item != UUID.Zero)
787 rdata.writer.WriteAttributeString("AtPoint", i.ToString()); 728 {
788 rdata.writer.WriteAttributeString("Item", (string) attachment["item"]); 729 rdata.writer.WriteAttributeString("Item",item.ToString());
789 rdata.writer.WriteAttributeString("Asset", (string) attachment["asset"]); 730 }
790 rdata.writer.WriteEndElement(); 731 if(asset != UUID.Zero)
732 {
733 rdata.writer.WriteAttributeString("Item",asset.ToString());
734 }
735 rdata.writer.WriteEndElement();
791 } 736 }
737 }
792 738
793 rdata.writer.WriteEndElement(); 739 private void FormatUserAppearance(AppearanceRequestData rdata)
794 740 {
795 741
796 Primitive.TextureEntry texture = rdata.userAppearance.Texture; 742 Rest.Log.DebugFormat("{0} FormatUserAppearance", MsgId);
797 743
798 if (texture != null) 744 if(rdata.userAppearance != null)
799 { 745 {
800 rdata.writer.WriteStartElement("Texture");
801 rdata.writer.WriteAttributeString("Default",
802 rdata.userAppearance.Texture.DefaultTexture.TextureID.ToString());
803
804 for (int i=0; i<Primitive.TextureEntry.MAX_FACES;i++)
805 {
806 rdata.writer.WriteStartElement("Face");
807 rdata.writer.WriteAttributeString("Index", i.ToString());
808 rdata.writer.WriteAttributeString("Id",
809 rdata.userAppearance.Texture.FaceTextures[i].TextureID.ToString());
810 rdata.writer.WriteEndElement();
811 }
812 746
813 rdata.writer.WriteEndElement(); 747 Rest.Log.DebugFormat("{0} FormatUserAppearance: appearance object exists", MsgId);
748 rdata.writer.WriteStartElement("Appearance");
749
750 rdata.writer.WriteAttributeString("Height", rdata.userAppearance.AvatarHeight.ToString());
751 if(rdata.userAppearance.Owner != null)
752 rdata.writer.WriteAttributeString("Owner", rdata.userAppearance.Owner.ToString());
753 rdata.writer.WriteAttributeString("Serial", rdata.userAppearance.Serial.ToString());
754
755 FormatPart(rdata, "Body", rdata.userAppearance.BodyItem, rdata.userAppearance.BodyAsset);
756 FormatPart(rdata, "Skin", rdata.userAppearance.SkinItem, rdata.userAppearance.SkinAsset);
757 FormatPart(rdata, "Hair", rdata.userAppearance.HairItem, rdata.userAppearance.HairAsset);
758 FormatPart(rdata, "Eyes", rdata.userAppearance.EyesItem, rdata.userAppearance.EyesAsset);
759
760 FormatPart(rdata, "Shirt", rdata.userAppearance.ShirtItem, rdata.userAppearance.ShirtAsset);
761 FormatPart(rdata, "Pants", rdata.userAppearance.PantsItem, rdata.userAppearance.PantsAsset);
762 FormatPart(rdata, "Skirt", rdata.userAppearance.SkirtItem, rdata.userAppearance.SkirtAsset);
763 FormatPart(rdata, "Shoes", rdata.userAppearance.ShoesItem, rdata.userAppearance.ShoesAsset);
764 FormatPart(rdata, "Socks", rdata.userAppearance.SocksItem, rdata.userAppearance.SocksAsset);
765
766 FormatPart(rdata, "Jacket", rdata.userAppearance.JacketItem, rdata.userAppearance.JacketAsset);
767 FormatPart(rdata, "Gloves", rdata.userAppearance.GlovesItem, rdata.userAppearance.GlovesAsset);
768
769 FormatPart(rdata, "UnderShirt", rdata.userAppearance.UnderShirtItem, rdata.userAppearance.UnderShirtAsset);
770 FormatPart(rdata, "UnderPants", rdata.userAppearance.UnderPantsItem, rdata.userAppearance.UnderPantsAsset);
771
772 Hashtable attachments = rdata.userAppearance.GetAttachments();
773
774 if(attachments != null)
775 {
776
777 Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting attachments", MsgId);
778
779 rdata.writer.WriteStartElement("Attachments");
780 for (int i=0; i<attachments.Count;i++)
781 {
782 Hashtable attachment = attachments[i] as Hashtable;
783 rdata.writer.WriteStartElement("Attachment");
784 rdata.writer.WriteAttributeString("AtPoint", i.ToString());
785 rdata.writer.WriteAttributeString("Item", (string) attachment["item"]);
786 rdata.writer.WriteAttributeString("Asset", (string) attachment["asset"]);
787 rdata.writer.WriteEndElement();
788 }
789 rdata.writer.WriteEndElement();
790 }
791
792 Primitive.TextureEntry texture = rdata.userAppearance.Texture;
793
794 if (texture != null && (texture.DefaultTexture != null || texture.FaceTextures != null))
795 {
796
797 Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting textures", MsgId);
798
799 rdata.writer.WriteStartElement("Texture");
800
801 if(texture.DefaultTexture != null)
802 {
803 Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting default texture", MsgId);
804 rdata.writer.WriteAttributeString("Default",
805 texture.DefaultTexture.TextureID.ToString());
806 }
807
808 if(texture.FaceTextures != null)
809 {
810
811 Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting face textures", MsgId);
812
813 for (int i=0; i<texture.FaceTextures.Length;i++)
814 {
815 if (texture.FaceTextures[i] != null)
816 {
817 rdata.writer.WriteStartElement("Face");
818 rdata.writer.WriteAttributeString("Index", i.ToString());
819 rdata.writer.WriteAttributeString("Id",
820 texture.FaceTextures[i].TextureID.ToString());
821 rdata.writer.WriteEndElement();
822 }
823 }
824 }
825
826 rdata.writer.WriteEndElement();
827 }
828
829 Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting visual parameters", MsgId);
830
831 rdata.writer.WriteStartElement("VisualParameters");
832 rdata.writer.WriteBase64(rdata.userAppearance.VisualParams,0,
833 rdata.userAppearance.VisualParams.Length);
834 rdata.writer.WriteEndElement();
835 rdata.writer.WriteFullEndElement();
814 } 836 }
815 837
816 rdata.writer.WriteStartElement("VisualParameters"); 838 Rest.Log.DebugFormat("{0} FormatUserAppearance: completed", MsgId);
817 rdata.writer.WriteBase64(rdata.userAppearance.VisualParams,0,
818 rdata.userAppearance.VisualParams.Length);
819 rdata.writer.WriteEndElement();
820 rdata.writer.WriteFullEndElement();
821 839
822 return; 840 return;
823 } 841 }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 27e2e5c..f1dc20e 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -5219,7 +5219,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5219 } 5219 }
5220 break; 5220 break;
5221 case PacketType.UpdateTaskInventory: 5221 case PacketType.UpdateTaskInventory:
5222 m_log.DebugFormat("[AMW] UpdateTaskInventory request");
5223 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; 5222 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
5224 if (OnUpdateTaskInventory != null) 5223 if (OnUpdateTaskInventory != null)
5225 { 5224 {
@@ -5286,7 +5285,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5286 break; 5285 break;
5287 5286
5288 case PacketType.RezScript: 5287 case PacketType.RezScript:
5289 m_log.DebugFormat("[AMW] RezScript");
5290 //Console.WriteLine(Pack.ToString()); 5288 //Console.WriteLine(Pack.ToString());
5291 RezScriptPacket rezScriptx = (RezScriptPacket)Pack; 5289 RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
5292 5290