30 using System.Collections;
31 using System.Collections.Generic;
33 using System.Reflection;
37 using OpenMetaverse.StructuredData;
41 using OpenSim.Framework;
42 using OpenSim.Framework.Capabilities;
43 using OpenSim.Region.Framework;
44 using OpenSim.Region.Framework.Scenes;
45 using OpenSim.Region.Framework.Scenes.Serialization;
46 using OpenSim.Framework.Servers;
47 using OpenSim.Framework.Servers.HttpServer;
48 using OpenSim.Services.Interfaces;
55 namespace OpenSim.
Region.ClientStack.Linden
58 string assetName,
string description, UUID assetID, UUID inventoryItem, UUID parentFolder,
59 byte[] data,
string inventoryType,
string assetType,
60 int cost, UUID texturesFolder,
int nreqtextures,
int nreqmeshs,
int nreqinstances,
61 bool IsAtestUpload, ref
string error);
63 public delegate UUID
UpdateItem(UUID itemID, byte[] data);
65 public delegate
void UpdateTaskScript(UUID itemID, UUID primID,
bool isScriptRunning, byte[] data, ref ArrayList errors);
74 bool isScriptRunning, byte[] data);
77 bool fetchFolders,
bool fetchItems,
int sortOrder, out
int version);
88 private static readonly ILog m_log =
89 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
91 private Scene m_Scene;
92 private Caps m_HostCapsObj;
95 private static readonly
string m_requestPath =
"0000/";
97 private static readonly
string m_newInventory =
"0002/";
99 private static readonly
string m_notecardUpdatePath =
"0004/";
100 private static readonly
string m_notecardTaskUpdatePath =
"0005/";
102 private static readonly
string m_copyFromNotecardPath =
"0007/";
104 private static readonly
string m_getObjectPhysicsDataPath =
"0101/";
105 private static readonly
string m_getObjectCostPath =
"0102/";
106 private static readonly
string m_ResourceCostSelectedPath =
"0103/";
107 private static readonly
string m_UpdateAgentInformationPath =
"0500/";
108 private static readonly
string m_animSetTaskUpdatePath =
"0260/";
112 public NewInventoryItem AddNewInventoryItem = null;
113 public NewAsset AddNewAsset = null;
114 public ItemUpdatedCallback ItemUpdatedCall = null;
115 public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null;
116 public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null;
117 public GetClientDelegate GetClient = null;
119 private bool m_persistBakedTextures =
false;
121 private bool m_dumpAssetsToFile =
false;
122 private string m_regionName;
124 private int m_levelUpload = 0;
126 private bool m_enableFreeTestUpload =
false;
127 private bool m_ForceFreeTestUpload =
false;
129 private bool m_enableModelUploadTextureToInventory =
false;
132 private bool m_RestrictFreeTestUploadPerms =
false;
133 private UUID m_testAssetsCreatorID = UUID.Zero;
135 private float m_PrimScaleMin = 0.001f;
137 private enum FileAgentInventoryState :
int
144 private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle;
149 m_HostCapsObj = caps;
154 m_ModelCost.NonPhysicalPrimScaleMax = m_Scene.m_maxNonphys;
155 m_ModelCost.PhysicalPrimScaleMax = m_Scene.m_maxPhys;
156 m_ModelCost.ObjectLinkedPartsMax = m_Scene.m_linksetCapacity;
161 m_PrimScaleMin = m_ModelCost.PrimScaleMin;
162 float modelTextureUploadFactor = m_ModelCost.ModelTextureCostFactor;
163 float modelUploadFactor = m_ModelCost.ModelMeshCostFactor;
164 float modelMinUploadCostFactor = m_ModelCost.ModelMinCostFactor;
165 float modelPrimCreationCost = m_ModelCost.primCreationCost;
166 float modelMeshByteCost = m_ModelCost.bytecost;
168 IConfigSource config = m_Scene.Config;
171 IConfig sconfig = config.Configs[
"Startup"];
174 m_levelUpload = sconfig.GetInt(
"LevelUpload", 0);
177 IConfig appearanceConfig = config.Configs[
"Appearance"];
178 if (appearanceConfig != null)
180 m_persistBakedTextures = appearanceConfig.GetBoolean(
"PersistBakedTextures", m_persistBakedTextures);
183 IConfig EconomyConfig = config.Configs[
"Economy"];
184 if (EconomyConfig != null)
186 modelUploadFactor = EconomyConfig.GetFloat(
"MeshModelUploadCostFactor", modelUploadFactor);
187 modelTextureUploadFactor = EconomyConfig.GetFloat(
"MeshModelUploadTextureCostFactor", modelTextureUploadFactor);
188 modelMinUploadCostFactor = EconomyConfig.GetFloat(
"MeshModelMinCostFactor", modelMinUploadCostFactor);
190 modelPrimCreationCost = EconomyConfig.GetFloat(
"ModelPrimCreationCost", modelPrimCreationCost);
191 modelMeshByteCost = EconomyConfig.GetFloat(
"ModelMeshByteCost", modelMeshByteCost);
193 m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean(
"MeshModelAllowTextureToInventory", m_enableModelUploadTextureToInventory);
195 m_RestrictFreeTestUploadPerms = EconomyConfig.GetBoolean(
"m_RestrictFreeTestUploadPerms", m_RestrictFreeTestUploadPerms);
196 m_enableFreeTestUpload = EconomyConfig.GetBoolean(
"AllowFreeTestUpload", m_enableFreeTestUpload);
197 m_ForceFreeTestUpload = EconomyConfig.GetBoolean(
"ForceFreeTestUpload", m_ForceFreeTestUpload);
198 string testcreator = EconomyConfig.GetString(
"TestAssetsCreatorID",
"");
199 if (testcreator !=
"")
202 UUID.TryParse(testcreator, out id);
204 m_testAssetsCreatorID = id;
207 m_ModelCost.ModelMeshCostFactor = modelUploadFactor;
208 m_ModelCost.ModelTextureCostFactor = modelTextureUploadFactor;
209 m_ModelCost.ModelMinCostFactor = modelMinUploadCostFactor;
210 m_ModelCost.primCreationCost = modelPrimCreationCost;
211 m_ModelCost.bytecost = modelMeshByteCost;
215 m_assetService = m_Scene.AssetService;
216 m_regionName = m_Scene.RegionInfo.RegionName;
220 AddNewInventoryItem = m_Scene.AddUploadedInventoryItem;
221 ItemUpdatedCall = m_Scene.CapsUpdateInventoryItemAsset;
222 TaskScriptUpdatedCall = m_Scene.CapsUpdateTaskInventoryScriptAsset;
223 GetClient = m_Scene.SceneGraph.GetControllingClient;
225 m_FileAgentInventoryState = FileAgentInventoryState.idle;
233 string capsBase =
"/CAPS/" + m_HostCapsObj.CapsObjectPath;
235 RegisterRegionServiceHandlers(capsBase);
236 RegisterInventoryServiceHandlers(capsBase);
244 m_HostCapsObj.RegisterHandler(
245 "SEED",
new RestStreamHandler(
"POST", capsBase + m_requestPath, SeedCapRequest,
"SEED", null));
257 "POST", capsBase + m_getObjectPhysicsDataPath, GetObjectPhysicsData,
"GetObjectPhysicsData", null);
258 m_HostCapsObj.RegisterHandler(
"GetObjectPhysicsData", getObjectPhysicsDataHandler);
261 m_HostCapsObj.RegisterHandler(
"GetObjectCost", getObjectCostHandler);
263 m_HostCapsObj.RegisterHandler(
"ResourceCostSelected", ResourceCostSelectedHandler);
268 "POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory,
"UpdateScript", null);
270 m_HostCapsObj.RegisterHandler(
"UpdateScriptTaskInventory", req);
271 m_HostCapsObj.RegisterHandler(
"UpdateScriptTask", req);
281 m_log.Error(
"[CAPS]: " + e.ToString());
289 m_HostCapsObj.RegisterHandler(
290 "NewFileAgentInventory",
291 new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>(
293 capsBase + m_newInventory,
294 NewAgentInventoryRequest,
295 "NewFileAgentInventory",
300 "POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory,
"Update*", null);
302 m_HostCapsObj.RegisterHandler(
"UpdateNotecardAgentInventory", req);
303 m_HostCapsObj.RegisterHandler(
"UpdateAnimSetAgentInventory", req);
304 m_HostCapsObj.RegisterHandler(
"UpdateScriptAgentInventory", req);
305 m_HostCapsObj.RegisterHandler(
"UpdateScriptAgent", req);
311 "POST", capsBase + m_UpdateAgentInformationPath, UpdateAgentInformation,
"UpdateAgentInformation", null);
312 m_HostCapsObj.RegisterHandler(
"UpdateAgentInformation", UpdateAgentInformationHandler);
314 m_HostCapsObj.RegisterHandler(
315 "CopyInventoryFromNotecard",
317 "POST", capsBase + m_copyFromNotecardPath, CopyInventoryFromNotecard,
"CopyInventoryFromNotecard", null));
347 m_log.Error(
"[CAPS]: " + e.ToString());
364 "[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, m_HostCapsObj.AgentID);
366 if (!m_HostCapsObj.WaitForActivation())
369 if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.
RemoteIPEndPoint))
372 "[CAPS]: Unauthorized CAPS client {0} from {1}",
373 m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint);
379 List<string> validCaps =
new List<string>();
381 foreach (
OSD c
in capsRequested)
382 validCaps.Add(c.AsString());
384 string result = LLSDHelpers.SerialiseLLSDReply(m_HostCapsObj.GetCapsDetails(
true, validCaps));
408 Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(
Utils.StringToBytes(request));
410 LLSDHelpers.DeserialiseOSDMap(hash, llsdUpdateRequest);
412 string capsBase =
"/CAPS/" + m_HostCapsObj.CapsObjectPath;
413 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString(
"0000");
420 capsBase + uploaderPath,
421 m_HostCapsObj.HttpListener,
423 uploader.OnUpLoad += TaskScriptUpdated;
425 m_HostCapsObj.HttpListener.AddStreamHandler(
427 "POST", capsBase + uploaderPath, uploader.
uploaderCaps,
"TaskInventoryScriptUpdater", null));
429 string protocol =
"http://";
431 if (m_HostCapsObj.SSLCaps)
432 protocol =
"https://";
434 string uploaderURL = protocol + m_HostCapsObj.HostName +
":" + m_HostCapsObj.Port.ToString() + capsBase +
438 uploadResponse.uploader = uploaderURL;
439 uploadResponse.state =
"upload";
445 return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
449 m_log.Error(
"[CAPS]: " + e.ToString());
462 public void TaskScriptUpdated(UUID itemID, UUID primID,
bool isScriptRunning, byte[] data, ref ArrayList errors)
464 if (TaskScriptUpdatedCall != null)
466 ArrayList e = TaskScriptUpdatedCall(m_HostCapsObj.AgentID, itemID, primID, isScriptRunning, data);
467 foreach (Object item
in e)
480 if (ItemUpdatedCall != null)
482 return ItemUpdatedCall(m_HostCapsObj.AgentID, itemID, data);
500 m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client);
505 switch (m_FileAgentInventoryState)
507 case FileAgentInventoryState.processRequest:
508 case FileAgentInventoryState.processUpload:
510 resperror.message =
"Uploader busy processing previus request";
511 resperror.identifier = UUID.Zero;
514 errorResponse.uploader =
"";
515 errorResponse.state =
"error";
516 errorResponse.error = resperror;
517 return errorResponse;
519 case FileAgentInventoryState.waitUpload:
522 case FileAgentInventoryState.idle:
527 m_FileAgentInventoryState = FileAgentInventoryState.processRequest;
531 int nreqtextures = 0;
533 int nreqinstances = 0;
534 bool IsAtestUpload =
false;
536 string assetName = llsdRequest.name;
547 m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar);
555 resperror.message =
"Insufficient permissions to upload";
556 resperror.identifier = UUID.Zero;
559 errorResponse.uploader =
"";
560 errorResponse.state =
"error";
561 errorResponse.error = resperror;
563 m_FileAgentInventoryState = FileAgentInventoryState.idle;
564 return errorResponse;
575 baseCost = mm.UploadCharge;
577 string warning = String.Empty;
585 if (!m_ModelCost.MeshModelCost(llsdRequest.
asset_resources, baseCost, out modelcost,
586 meshcostdata, out error, ref warning))
589 resperror.message = error;
590 resperror.identifier = UUID.Zero;
593 errorResponse.uploader =
"";
594 errorResponse.state =
"error";
595 errorResponse.error = resperror;
598 m_FileAgentInventoryState = FileAgentInventoryState.idle;
599 return errorResponse;
608 if (cost > 0 && mm != null)
612 if (m_ForceFreeTestUpload)
614 if (!(assetName.Length > 5 && assetName.StartsWith(
"TEST-")))
615 assetName =
"TEST-" + assetName;
617 IsAtestUpload =
true;
620 else if (m_enableFreeTestUpload)
623 IsAtestUpload = (assetName.Length > 5 && assetName.StartsWith(
"TEST-"));
628 warning +=
"Upload will have no cost, for testing purposes only. Other uses are prohibited. Items will not work after 48 hours or on other regions";
636 resperror.message =
"Insuficient funds";
637 resperror.identifier = UUID.Zero;
640 errorResponse.uploader =
"";
641 errorResponse.state =
"error";
642 errorResponse.error = resperror;
644 m_FileAgentInventoryState = FileAgentInventoryState.idle;
645 return errorResponse;
650 if (client != null && warning != String.Empty)
651 client.SendAgentAlertMessage(warning,
true);
655 string assetDes = llsdRequest.description;
656 string capsBase =
"/CAPS/" + m_HostCapsObj.CapsObjectPath;
657 UUID newAsset = UUID.Random();
658 UUID newInvItem = UUID.Random();
659 UUID parentFolder = llsdRequest.folder_id;
660 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString(
"0000");
661 UUID texturesFolder = UUID.Zero;
663 if(!IsAtestUpload && m_enableModelUploadTextureToInventory)
664 texturesFolder = llsdRequest.texture_folder_id;
668 llsdRequest.
asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost,
669 texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload);
671 m_HostCapsObj.HttpListener.AddStreamHandler(
674 capsBase + uploaderPath,
676 "NewAgentInventoryRequest",
677 m_HostCapsObj.AgentID.ToString()));
679 string protocol =
"http://";
681 if (m_HostCapsObj.SSLCaps)
682 protocol =
"https://";
684 string uploaderURL = protocol + m_HostCapsObj.HostName +
":" + m_HostCapsObj.Port.ToString() + capsBase +
689 uploadResponse.uploader = uploaderURL;
690 uploadResponse.state =
"upload";
691 uploadResponse.upload_price = (int)cost;
695 uploadResponse.data = meshcostdata;
698 uploader.OnUpLoad += UploadCompleteHandler;
701 m_FileAgentInventoryState = FileAgentInventoryState.waitUpload;
703 return uploadResponse;
713 UUID inventoryItem, UUID parentFolder, byte[] data,
string inventoryType,
714 string assetType,
int cost,
715 UUID texturesFolder,
int nreqtextures,
int nreqmeshs,
int nreqinstances,
716 bool IsAtestUpload, ref
string error)
720 m_FileAgentInventoryState = FileAgentInventoryState.processUpload;
723 "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}",
724 assetID, inventoryItem, inventoryType, assetType);
731 UUID owner_id = m_HostCapsObj.AgentID;
734 bool istest = IsAtestUpload && m_enableFreeTestUpload && (cost > 0);
736 bool restrictPerms = m_RestrictFreeTestUploadPerms && istest;
738 if (istest && m_testAssetsCreatorID != UUID.Zero)
739 creatorID = m_testAssetsCreatorID;
741 creatorID = owner_id;
743 string creatorIDstr = creatorID.ToString();
749 if (!mm.UploadCovered(m_HostCapsObj.AgentID, (
int)cost))
751 error =
"Insufficient funds.";
757 if (inventoryType ==
"sound")
759 inType = (sbyte)InventoryType.Sound;
760 assType = (sbyte)AssetType.Sound;
762 else if (inventoryType ==
"snapshot")
764 inType = (sbyte)InventoryType.Snapshot;
766 else if (inventoryType ==
"animation")
768 inType = (sbyte)InventoryType.Animation;
771 else if (inventoryType ==
"animset")
775 m_log.Debug(
"got animset upload request");
777 else if (inventoryType ==
"wearable")
779 inType = (sbyte)InventoryType.Wearable;
783 assType = (sbyte)AssetType.Bodypart;
786 assType = (sbyte)AssetType.Clothing;
790 else if (inventoryType ==
"object")
792 if (assetType ==
"mesh")
794 inType = (sbyte)InventoryType.Object;
795 assType = (sbyte)AssetType.Object;
797 List<Vector3> positions =
new List<Vector3>();
798 List<Quaternion> rotations =
new List<Quaternion>();
799 OSDMap request = (
OSDMap)OSDParser.DeserializeLLSDXml(data);
825 bool doTextInv = (!istest && m_enableModelUploadTextureToInventory &&
826 texturesFolder != UUID.Zero);
829 List<UUID> textures =
new List<UUID>();
833 m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client);
838 for (
int i = 0; i < texture_list.Count; i++)
840 AssetBase textureAsset =
new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, creatorIDstr);
841 textureAsset.Data = texture_list[i].AsBinary();
843 textureAsset.Local =
true;
844 m_assetService.Store(textureAsset);
845 textures.Add(textureAsset.FullID);
849 string name = assetName;
850 if (name.Length > 25)
851 name = name.Substring(0, 24);
852 name +=
"_Texture#" + i.ToString();
854 texitem.Owner = m_HostCapsObj.AgentID;
855 texitem.CreatorId = creatorIDstr;
856 texitem.CreatorData = String.Empty;
857 texitem.ID = UUID.Random();
858 texitem.AssetID = textureAsset.FullID;
859 texitem.Description =
"mesh model texture";
861 texitem.AssetType = (int)AssetType.Texture;
862 texitem.InvType = (
int)InventoryType.Texture;
863 texitem.Folder = texturesFolder;
865 texitem.CurrentPermissions
868 texitem.BasePermissions = (uint)
PermissionMask.All | (uint)PermissionMask.Export;
869 texitem.EveryOnePermissions = 0;
871 texitem.CreationDate = Util.UnixTimeSinceEpoch();
873 m_Scene.AddInventoryItem(client, texitem);
879 List<UUID> meshAssets =
new List<UUID>();
880 List<bool> meshAvatarSkeletons =
new List<bool>();
881 List<bool> meshAvatarColliders =
new List<bool>();
885 for (
int i = 0; i < mesh_list.Count; i++)
887 curAvSkeleton =
false;
888 curAvCollider =
false;
891 OSD osd = OSDParser.DeserializeLLSDBinary(mesh_list[i]);
894 OSDMap mosd = (
OSDMap)osd;
895 if (mosd.ContainsKey(
"skeleton"))
897 OSDMap skeleton = (
OSDMap)mosd[
"skeleton"];
898 int sksize = skeleton[
"size"].AsInteger();
900 curAvSkeleton =
true;
904 AssetBase meshAsset =
new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr);
905 meshAsset.Data = mesh_list[i].AsBinary();
907 meshAsset.Local =
true;
908 m_assetService.Store(meshAsset);
909 meshAssets.Add(meshAsset.FullID);
910 meshAvatarSkeletons.Add(curAvSkeleton);
911 meshAvatarColliders.Add(curAvCollider);
914 if (curAvSkeleton && client != null)
916 string name = assetName;
917 if (name.Length > 25)
918 name = name.Substring(0, 24);
919 name +=
"_Mesh#" + i.ToString();
921 meshitem.Owner = m_HostCapsObj.AgentID;
922 meshitem.CreatorId = creatorIDstr;
923 meshitem.CreatorData = String.Empty;
924 meshitem.ID = UUID.Random();
925 meshitem.AssetID = meshAsset.FullID;
926 meshitem.Description =
"mesh ";
927 meshitem.Name = name;
928 meshitem.AssetType = (int)AssetType.Mesh;
929 meshitem.InvType = (
int)InventoryType.Mesh;
932 meshitem.Folder = parentFolder;
936 meshitem.CurrentPermissions
940 meshitem.EveryOnePermissions = 0;
941 meshitem.NextPermissions = (uint)PermissionMask.All;
942 meshitem.CreationDate = Util.UnixTimeSinceEpoch();
944 m_Scene.AddInventoryItem(client, meshitem);
951 for (
int i = 0; i < instance_list.Count; i++)
956 Vector3 scale = inner_instance_list[
"scale"].AsVector3();
958 if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin)
966 Primitive.TextureEntry textureEntry
967 =
new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE);
971 for (uint face = 0; face < face_list.Count; face++)
974 Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face);
975 if (faceMap.ContainsKey(
"fullbright"))
976 f.Fullbright = faceMap[
"fullbright"].AsBoolean();
977 if (faceMap.ContainsKey(
"diffuse_color"))
978 f.RGBA = faceMap[
"diffuse_color"].AsColor4();
980 int textureNum = faceMap[
"image"].AsInteger();
981 float imagerot = faceMap[
"imagerot"].AsInteger();
982 float offsets = (float)faceMap[
"offsets"].AsReal();
983 float offsett = (float)faceMap[
"offsett"].AsReal();
984 float scales = (float)faceMap[
"scales"].AsReal();
985 float scalet = (float)faceMap[
"scalet"].AsReal();
988 f.Rotation = imagerot;
1002 if (textures.Count > textureNum)
1003 f.TextureID = textures[textureNum];
1005 f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE;
1007 textureEntry.FaceTextures[face] = f;
1010 pbs.TextureEntry = textureEntry.GetBytes();
1012 bool hasmesh =
false;
1013 if (inner_instance_list.ContainsKey(
"mesh"))
1015 int meshindx = inner_instance_list[
"mesh"].AsInteger();
1016 if (meshAssets.Count > meshindx)
1018 pbs.SculptEntry =
true;
1026 Vector3 position = inner_instance_list[
"position"].AsVector3();
1027 Quaternion
rotation = inner_instance_list[
"rotation"].AsQuaternion();
1034 byte material = (byte)Material.Wood;
1054 =
new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero);
1058 positions.Add(position);
1059 prim.UUID = UUID.Random();
1060 prim.CreatorID = creatorID;
1061 prim.OwnerID = owner_id;
1062 prim.GroupID = UUID.Zero;
1063 prim.LastOwnerID = creatorID;
1064 prim.CreationDate = Util.UnixTimeSinceEpoch();
1067 prim.Name = assetName;
1069 prim.Name = assetName +
"#" + i.ToString();
1071 prim.EveryoneMask = 0;
1078 prim.NextOwnerMask = 0;
1082 prim.BaseMask = (uint)
PermissionMask.All | (uint)PermissionMask.Export;
1083 prim.OwnerMask = (uint)
PermissionMask.All | (uint)PermissionMask.Export;
1088 prim.Description =
"For testing only. Other uses are prohibited";
1090 prim.Description =
"";
1092 prim.Material = material;
1093 prim.PhysicsShapeType = physicsShapeType;
1104 grp.LastOwnerID = creatorID;
1110 Vector3 rootPos = positions[0];
1112 if (grp.
Parts.Length > 1)
1115 grp.RootPart.LinkNum++;
1117 Quaternion rootRotConj = Quaternion.Conjugate(rotations[0]);
1122 for (
int i = 1; i < rotations.Count; i++)
1124 tmprot = rotations[i];
1125 tmprot = rootRotConj * tmprot;
1127 grp.Parts[i].RotationOffset = tmprot;
1129 offset = positions[i] - rootPos;
1131 offset *= rootRotConj;
1132 grp.Parts[i].OffsetPosition = offset;
1135 grp.AbsolutePosition = rootPos;
1136 grp.UpdateGroupRotationR(rotations[0]);
1140 grp.AbsolutePosition = rootPos;
1141 grp.UpdateGroupRotationR(rotations[0]);
1144 data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp));
1149 m_log.ErrorFormat(
"[CAPS Asset Upload] got unsuported assetType for object upload");
1155 asset =
new AssetBase(assetID, assetName, assType, creatorIDstr);
1159 if (AddNewAsset != null)
1161 else if (m_assetService != null)
1162 m_assetService.Store(asset);
1165 item.Owner = m_HostCapsObj.AgentID;
1166 item.CreatorId = creatorIDstr;
1167 item.CreatorData = String.Empty;
1168 item.ID = inventoryItem;
1169 item.AssetID = asset.FullID;
1172 item.Description =
"For testing only. Other uses are prohibited";
1173 item.Flags = (uint) (InventoryItemFlags.SharedSingleReference);
1176 item.Description = assetDescription;
1177 item.Name = assetName;
1178 item.AssetType = assType;
1179 item.InvType = inType;
1180 item.Folder = parentFolder;
1187 AnimationSet.setCreateItemPermitions(item);
1190 else if (restrictPerms)
1194 item.EveryOnePermissions = 0;
1195 item.NextPermissions = 0;
1199 item.BasePermissions = (uint)
PermissionMask.All | (uint)PermissionMask.Export;
1200 item.CurrentPermissions = (uint)
PermissionMask.All | (uint)PermissionMask.Export;
1201 item.EveryOnePermissions = 0;
1205 item.CreationDate = Util.UnixTimeSinceEpoch();
1207 m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client);
1209 if (AddNewInventoryItem != null)
1213 m_Scene.AddInventoryItem(client, item);
1222 AddNewInventoryItem(m_HostCapsObj.AgentID, item, (uint)cost);
1238 m_FileAgentInventoryState = FileAgentInventoryState.idle;
1248 m_log.Debug(
"[CAPS]: MapLayer Request in region: " + m_regionName);
1250 mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse());
1261 mapLayer.Right = 5000;
1262 mapLayer.Top = 5000;
1263 mapLayer.ImageID =
new UUID(
"00000000-0000-1111-9999-000000000006");
1277 m_log.Debug(
"texture request " + request);
1279 return String.Empty;
1297 Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(
Utils.StringToBytes(request));
1299 LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest);
1301 string capsBase =
"/CAPS/" + m_HostCapsObj.CapsObjectPath;
1302 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString(
"0000");
1305 new ItemUpdater(llsdRequest.
item_id, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile);
1306 uploader.OnUpLoad += ItemUpdated;
1308 m_HostCapsObj.HttpListener.AddStreamHandler(
1310 "POST", capsBase + uploaderPath, uploader.
uploaderCaps,
"NoteCardAgentInventory", null));
1312 string protocol =
"http://";
1314 if (m_HostCapsObj.SSLCaps)
1315 protocol =
"https://";
1317 string uploaderURL = protocol + m_HostCapsObj.HostName +
":" + m_HostCapsObj.Port.ToString() + capsBase +
1321 uploadResponse.uploader = uploaderURL;
1322 uploadResponse.state =
"upload";
1328 return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
1340 Hashtable response =
new Hashtable();
1341 response[
"int_response_code"] = 404;
1342 response[
"content_type"] =
"text/plain";
1343 response[
"keepalive"] =
false;
1344 response[
"str_response_string"] =
"";
1348 OSDMap content = (
OSDMap)OSDParser.DeserializeLLSDXml(request);
1349 UUID objectID = content[
"object-id"].AsUUID();
1350 UUID notecardID = content[
"notecard-id"].AsUUID();
1351 UUID folderID = content[
"folder-id"].AsUUID();
1352 UUID itemID = content[
"item-id"].AsUUID();
1356 if (objectID != UUID.Zero)
1362 if (!m_Scene.Permissions.CanCopyObjectInventory(notecardID, objectID, m_HostCapsObj.AgentID))
1364 return LLSDHelpers.SerialiseLLSDReply(response);
1373 m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client);
1378 copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID, out message);
1379 if (copyItem != null && client != null)
1381 m_log.InfoFormat(
"[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder);
1382 client.SendBulkUpdateInventory(copyItem);
1387 m_log.ErrorFormat(
"[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID);
1389 client.SendAlertMessage(
"Failed to retrieve item");
1394 m_log.ErrorFormat(
"[CAPS]: CopyInventoryFromNotecard : {0}", e.ToString());
1397 response[
"int_response_code"] = 200;
1398 return LLSDHelpers.SerialiseLLSDReply(response);
1405 OSDMap req = (
OSDMap)OSDParser.DeserializeLLSDXml(request);
1409 for (
int i = 0 ; i < object_ids.Count ; i++)
1411 UUID uuid = object_ids[i].AsUUID();
1418 object_data[
"PhysicsShapeType"] = obj.PhysicsShapeType;
1419 object_data[
"Density"] = obj.Density;
1420 object_data[
"Friction"] = obj.Friction;
1421 object_data[
"Restitution"] = obj.Restitution;
1422 object_data[
"GravityMultiplier"] = obj.GravityModifier;
1424 resp[uuid.ToString()] = object_data;
1428 string response = OSDParser.SerializeLLSDXmlString(resp);
1436 OSDMap req = (
OSDMap)OSDParser.DeserializeLLSDXml(request);
1441 for (
int i = 0; i < object_ids.Count; i++)
1443 UUID uuid = object_ids[i].AsUUID();
1448 grp = part.ParentGroup;
1452 float linksetPhysCost;
1456 grp.GetResourcesCosts(part,out linksetCost,out linksetPhysCost,out partCost,out partPhysCost);
1459 object_data[
"linked_set_resource_cost"] = linksetCost;
1460 object_data[
"resource_cost"] = partCost;
1461 object_data[
"physics_cost"] = partPhysCost;
1462 object_data[
"linked_set_physics_cost"] = linksetPhysCost;
1463 object_data[
"resource_limiting_type"] =
"legacy";
1464 resp[uuid.ToString()] = object_data;
1470 object_data[
"linked_set_resource_cost"] = 0;
1471 object_data[
"resource_cost"] = 0;
1472 object_data[
"physics_cost"] = 0;
1473 object_data[
"linked_set_physics_cost"] = 0;
1474 resp[UUID.Zero.ToString()] = object_data;
1476 string response = OSDParser.SerializeLLSDXmlString(resp);
1484 OSDMap req = (
OSDMap)OSDParser.DeserializeLLSDXml(request);
1492 if (req.ContainsKey(
"selected_roots"))
1499 for (
int i = 0; i < object_ids.Count; i++)
1501 UUID uuid = object_ids[i].AsUUID();
1509 grp.GetSelectedCosts(out Physc, out streamc, out simulc);
1516 else if (req.ContainsKey(
"selected_prims"))
1523 for (
int i = 0; i < object_ids.Count; i++)
1525 UUID uuid = object_ids[i].AsUUID();
1530 phys += part.PhysicsCost;
1531 stream += part.StreamingCost;
1532 simul += part.SimulationCost;
1539 object_data[
"physics"] = phys;
1540 object_data[
"streaming"] = stream;
1541 object_data[
"simulation"] = simul;
1543 resp[
"selected"] = object_data;
1545 string response = OSDParser.SerializeLLSDXmlString(resp);
1557 accessPrefs[
"max"] =
"A";
1559 resp[
"access_prefs"] = accessPrefs;
1561 string response = OSDParser.SerializeLLSDXmlString(resp);
1568 private static readonly ILog m_log =
1569 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
1573 private UpLoadedAsset handlerUpLoad = null;
1575 private string uploaderPath = String.Empty;
1576 private UUID newAssetID;
1577 private UUID inventoryItemID;
1578 private UUID parentFolder;
1580 private bool m_dumpAssetsToFile;
1581 private string m_assetName = String.Empty;
1582 private string m_assetDes = String.Empty;
1584 private string m_invType = String.Empty;
1585 private string m_assetType = String.Empty;
1587 private string m_error = String.Empty;
1590 private UUID m_texturesFolder;
1591 private int m_nreqtextures;
1592 private int m_nreqmeshs;
1593 private int m_nreqinstances;
1594 private bool m_IsAtestUpload;
1596 public AssetUploader(
string assetName,
string description, UUID assetID, UUID inventoryItem,
1597 UUID parentFolderID,
string invType,
string assetType,
string path,
1599 int totalCost, UUID texturesFolder,
int nreqtextures,
int nreqmeshs,
int nreqinstances,
1602 m_assetName = assetName;
1603 m_assetDes = description;
1604 newAssetID = assetID;
1605 inventoryItemID = inventoryItem;
1606 uploaderPath = path;
1608 parentFolder = parentFolderID;
1609 m_assetType = assetType;
1610 m_invType = invType;
1611 m_dumpAssetsToFile = dumpAssetsToFile;
1614 m_texturesFolder = texturesFolder;
1615 m_nreqtextures = nreqtextures;
1616 m_nreqmeshs = nreqmeshs;
1617 m_nreqinstances = nreqinstances;
1618 m_IsAtestUpload = IsAtestUpload;
1620 m_timeoutTimer.Elapsed += TimedOut;
1621 m_timeoutTimer.Interval = 120000;
1622 m_timeoutTimer.AutoReset =
false;
1623 m_timeoutTimer.Start();
1635 UUID inv = inventoryItemID;
1636 string res = String.Empty;
1645 m_timeoutTimer.Stop();
1646 httpListener.RemoveStreamHandler(
"POST", uploaderPath);
1649 string extension =
".jp2";
1650 if (m_invType !=
"image")
1655 if (m_dumpAssetsToFile)
1657 SaveAssetToFile(m_assetName + extension, data);
1659 handlerUpLoad = OnUpLoad;
1660 if (handlerUpLoad != null)
1662 handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,
1663 m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload,
1666 if (m_IsAtestUpload)
1669 resperror.message =
"Upload SUCESSEFULL for testing purposes only. Other uses are prohibited. Item will not work after 48 hours or on other regions";
1670 resperror.identifier = inv;
1672 uploadComplete.error = resperror;
1673 uploadComplete.state =
"Upload4Testing";
1677 if (m_error == String.Empty)
1679 uploadComplete.new_asset = newAssetID.ToString();
1680 uploadComplete.new_inventory_item = inv;
1683 uploadComplete.state =
"complete";
1688 resperror.message = m_error;
1689 resperror.identifier = inv;
1691 uploadComplete.error = resperror;
1692 uploadComplete.state =
"failed";
1696 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
1700 private void TimedOut(
object sender, ElapsedEventArgs args)
1702 m_log.InfoFormat(
"[CAPS]: Removing URL and handler for timed out mesh upload");
1703 httpListener.RemoveStreamHandler(
"POST", uploaderPath);
1716 private static void SaveAssetToFile(
string filename, byte[] data)
1718 string assetPath =
"UserAssets";
1719 if (!Directory.Exists(assetPath))
1721 Directory.CreateDirectory(assetPath);
1723 FileStream fs = File.Create(Path.Combine(assetPath, Util.safeFileName(filename)));
1724 BinaryWriter bw =
new BinaryWriter(fs);
1739 private UpdateItem handlerUpdateItem = null;
1741 private string uploaderPath = String.Empty;
1742 private UUID inventoryItemID;
1744 private bool m_dumpAssetToFile;
1748 m_dumpAssetToFile = dumpAssetToFile;
1750 inventoryItemID = inventoryItem;
1751 uploaderPath = path;
1764 UUID inv = inventoryItemID;
1765 string res = String.Empty;
1767 UUID assetID = UUID.Zero;
1768 handlerUpdateItem = OnUpLoad;
1769 if (handlerUpdateItem != null)
1771 assetID = handlerUpdateItem(inv, data);
1774 uploadComplete.new_asset = assetID.ToString();
1775 uploadComplete.new_inventory_item = inv;
1776 uploadComplete.state =
"complete";
1778 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
1780 httpListener.RemoveStreamHandler(
"POST", uploaderPath);
1782 if (m_dumpAssetToFile)
1784 SaveAssetToFile(
"updateditem" + Util.RandomClass.Next(1, 1000) +
".dat", data);
1800 private static void SaveAssetToFile(
string filename, byte[] data)
1802 string assetPath =
"UserAssets";
1803 if (!Directory.Exists(assetPath))
1805 Directory.CreateDirectory(assetPath);
1807 FileStream fs = File.Create(Path.Combine(assetPath, filename));
1808 BinaryWriter bw =
new BinaryWriter(fs);
1821 private static readonly ILog m_log =
1822 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
1826 private UpdateTaskScript handlerUpdateTaskScript = null;
1828 private string uploaderPath = String.Empty;
1829 private UUID inventoryItemID;
1830 private UUID primID;
1831 private bool isScriptRunning;
1833 private bool m_dumpAssetToFile;
1838 m_dumpAssetToFile = dumpAssetToFile;
1840 this.inventoryItemID = inventoryItemID;
1841 this.primID = primID;
1844 this.isScriptRunning = (0 == isScriptRunning ?
false :
true);
1846 uploaderPath = path;
1865 string res = String.Empty;
1868 ArrayList errors =
new ArrayList();
1869 handlerUpdateTaskScript = OnUpLoad;
1870 if (handlerUpdateTaskScript != null)
1872 handlerUpdateTaskScript(inventoryItemID, primID, isScriptRunning, data, ref errors);
1875 uploadComplete.new_asset = inventoryItemID;
1876 uploadComplete.compiled = errors.Count > 0 ?
false :
true;
1877 uploadComplete.state =
"complete";
1879 uploadComplete.errors.Array = errors;
1881 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
1883 httpListener.RemoveStreamHandler(
"POST", uploaderPath);
1885 if (m_dumpAssetToFile)
1887 SaveAssetToFile(
"updatedtaskscript" + Util.RandomClass.Next(1, 1000) +
".dat", data);
1896 m_log.Error(
"[CAPS]: " + e.ToString());
1912 private static void SaveAssetToFile(
string filename, byte[] data)
1914 string assetPath =
"UserAssets";
1915 if (!Directory.Exists(assetPath))
1917 Directory.CreateDirectory(assetPath);
1919 FileStream fs = File.Create(Path.Combine(assetPath, filename));
1920 BinaryWriter bw =
new BinaryWriter(fs);
string ScriptTaskInventory(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
Called by the script task update handler. Provides a URL to which the client can upload a new asset...
delegate UUID UpdateItem(UUID itemID, byte[] data)
OpenSim.Server.Handlers.Simulation.Utils Utils
This class is a callback invoked when a client sends asset data to a task inventory script update url...
IPEndPoint RemoteIPEndPoint
TaskInventoryScriptUpdater(UUID inventoryItemID, UUID primID, int isScriptRunning, string path, IHttpServer httpServer, bool dumpAssetToFile)
OpenMetaverse.StructuredData.OSDArray OSDArray
string GetObjectCost(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
UUID item_id
The item containing the script to update
static OSDMapLayer GetOSDMapLayerResponse()
UUID ItemUpdated(UUID itemID, byte[] data)
Called when new asset data for an agent inventory item update has been uploaded.
int is_script_running
Signals whether the script is currently active
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
bool UploadCovered(UUID agentID, int amount)
LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
delegate ArrayList TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID, bool isScriptRunning, byte[] data)
UpdateTaskScript OnUpLoad
AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolderID, string invType, string assetType, string path, IHttpServer httpServer, bool dumpAssetsToFile, int totalCost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, bool IsAtestUpload)
void RegisterHandlers()
Register a bunch of CAPS http service handlers
LLSDAssetResource asset_resources
Interface to OpenSimulator's built in HTTP server. Use this to register handlers (http, llsd, xmlrpc, etc.) for given URLs.
string uploaderCaps(byte[] data, string path, string param)
Handle raw asset upload data via the capability.
string RequestTexture(string request, string path, string param)
System.Timers.Timer Timer
string uploaderCaps(byte[] data, string path, string param)
void TaskScriptUpdated(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors)
Called when new asset data for an agent inventory item update has been uploaded.
Asset class. All Assets are reference by this class or a class derived from this class ...
OpenSim.Framework.Capabilities.Caps Caps
string ResourceCostSelected(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
string CopyInventoryFromNotecard(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
Called by the CopyInventoryFromNotecard caps handler.
string NoteCardAgentInventory(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
Called by the notecard update handler. Provides a URL to which the client can upload a new asset...
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion rotation
void RegisterRegionServiceHandlers(string capsBase)
string GetObjectPhysicsData(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
This class is a callback invoked when a client sends asset data to an agent inventory notecard update...
Inventory Item - contains all the properties associated with an individual inventory piece...
delegate void NewInventoryItem(UUID userID, InventoryItemBase item, uint cost)
OpenSim.Region.OptionalModules.Scripting.Minimodule.Object.SculptType SculptType
ItemUpdater(UUID inventoryItem, string path, IHttpServer httpServer, bool dumpAssetToFile)
OpenMetaverse.StructuredData.OSD OSD
delegate UUID ItemUpdatedCallback(UUID userID, UUID itemID, byte[] data)
string uploaderCaps(byte[] data, string path, string param)
Handle raw uploaded asset data.
string UpdateAgentInformation(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
OpenSim.Framework.Animation Animation
OpenSim.Framework.PermissionMask PermissionMask
delegate void NewAsset(AssetBase asset)
delegate InventoryCollection FetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder, out int version)
delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors)
void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, string assetType, int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, bool IsAtestUpload, ref string error)
Convert raw uploaded data into the appropriate asset and item.
delegate void UpLoadedAsset(string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, string assetType, int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, bool IsAtestUpload, ref string error)
void RegisterInventoryServiceHandlers(string capsBase)
delegate IClientAPI GetClientDelegate(UUID agentID)
XXX Probably not a particularly nice way of allow us to get the scene presence from the scene (chiefl...
string SeedCapRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
Construct a client response detailing all the capabilities this server can provide.
BunchOfCaps(Scene scene, Caps caps)
OpenSim.Region.Framework.Scenes.Animation.AnimationSet AnimationSet
UUID task_id
The task containing the script
OpenMetaverse.StructuredData.OSDMap OSDMap
LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest)
Used to serialize a whole inventory for transfer over the network.