OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
BunchOfCaps.cs
Go to the documentation of this file.
1 /*
2  * Copyright (c) Contributors, http://opensimulator.org/
3  * See CONTRIBUTORS.TXT for a full list of copyright holders.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the OpenSimulator Project nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 using System;
29 using System.Timers;
30 using System.Collections;
31 using System.Collections.Generic;
32 using System.IO;
33 using System.Reflection;
34 using System.Text;
35 
36 using OpenMetaverse;
37 using OpenMetaverse.StructuredData;
38 using Nini.Config;
39 using log4net;
40 
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;
49 
54 
55 namespace OpenSim.Region.ClientStack.Linden
56 {
57  public delegate void UpLoadedAsset(
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);
62 
63  public delegate UUID UpdateItem(UUID itemID, byte[] data);
64 
65  public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors);
66 
67  public delegate void NewInventoryItem(UUID userID, InventoryItemBase item, uint cost);
68 
69  public delegate void NewAsset(AssetBase asset);
70 
71  public delegate UUID ItemUpdatedCallback(UUID userID, UUID itemID, byte[] data);
72 
73  public delegate ArrayList TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID,
74  bool isScriptRunning, byte[] data);
75 
76  public delegate InventoryCollection FetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID,
77  bool fetchFolders, bool fetchItems, int sortOrder, out int version);
78 
84  public delegate IClientAPI GetClientDelegate(UUID agentID);
85 
86  public class BunchOfCaps
87  {
88  private static readonly ILog m_log =
89  LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
90 
91  private Scene m_Scene;
92  private Caps m_HostCapsObj;
93  private ModelCost m_ModelCost;
94 
95  private static readonly string m_requestPath = "0000/";
96  // private static readonly string m_mapLayerPath = "0001/";
97  private static readonly string m_newInventory = "0002/";
98  //private static readonly string m_requestTexture = "0003/";
99  private static readonly string m_notecardUpdatePath = "0004/";
100  private static readonly string m_notecardTaskUpdatePath = "0005/";
101  // private static readonly string m_fetchInventoryPath = "0006/";
102  private static readonly string m_copyFromNotecardPath = "0007/";
103  // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule.
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/";
109 
110  // These are callbacks which will be setup by the scene so that we can update scene data when we
111  // receive capability calls
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;
118 
119  private bool m_persistBakedTextures = false;
120  private IAssetService m_assetService;
121  private bool m_dumpAssetsToFile = false;
122  private string m_regionName;
123 
124  private int m_levelUpload = 0;
125 
126  private bool m_enableFreeTestUpload = false; // allows "TEST-" prefix hack
127  private bool m_ForceFreeTestUpload = false; // forces all uploads to be test
128 
129  private bool m_enableModelUploadTextureToInventory = false; // place uploaded textures also in inventory
130  // may not be visible till relog
131 
132  private bool m_RestrictFreeTestUploadPerms = false; // reduces also the permitions. Needs a creator defined!!
133  private UUID m_testAssetsCreatorID = UUID.Zero;
134 
135  private float m_PrimScaleMin = 0.001f;
136 
137  private enum FileAgentInventoryState : int
138  {
139  idle = 0,
140  processRequest = 1,
141  waitUpload = 2,
142  processUpload = 3
143  }
144  private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle;
145 
146  public BunchOfCaps(Scene scene, Caps caps)
147  {
148  m_Scene = scene;
149  m_HostCapsObj = caps;
150 
151  // create a model upload cost provider
152  m_ModelCost = new ModelCost();
153  // tell it about scene object limits
154  m_ModelCost.NonPhysicalPrimScaleMax = m_Scene.m_maxNonphys;
155  m_ModelCost.PhysicalPrimScaleMax = m_Scene.m_maxPhys;
156  m_ModelCost.ObjectLinkedPartsMax = m_Scene.m_linksetCapacity;
157 
158 // m_ModelCost.ObjectLinkedPartsMax = ??
159 // m_ModelCost.PrimScaleMin = ??
160 
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;
167 
168  IConfigSource config = m_Scene.Config;
169  if (config != null)
170  {
171  IConfig sconfig = config.Configs["Startup"];
172  if (sconfig != null)
173  {
174  m_levelUpload = sconfig.GetInt("LevelUpload", 0);
175  }
176 
177  IConfig appearanceConfig = config.Configs["Appearance"];
178  if (appearanceConfig != null)
179  {
180  m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
181  }
182  // economy for model upload
183  IConfig EconomyConfig = config.Configs["Economy"];
184  if (EconomyConfig != null)
185  {
186  modelUploadFactor = EconomyConfig.GetFloat("MeshModelUploadCostFactor", modelUploadFactor);
187  modelTextureUploadFactor = EconomyConfig.GetFloat("MeshModelUploadTextureCostFactor", modelTextureUploadFactor);
188  modelMinUploadCostFactor = EconomyConfig.GetFloat("MeshModelMinCostFactor", modelMinUploadCostFactor);
189  // next 2 are normalized so final cost is afected by modelUploadFactor above and normal cost
190  modelPrimCreationCost = EconomyConfig.GetFloat("ModelPrimCreationCost", modelPrimCreationCost);
191  modelMeshByteCost = EconomyConfig.GetFloat("ModelMeshByteCost", modelMeshByteCost);
192 
193  m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", m_enableModelUploadTextureToInventory);
194 
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 != "")
200  {
201  UUID id;
202  UUID.TryParse(testcreator, out id);
203  if (id != null)
204  m_testAssetsCreatorID = id;
205  }
206 
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;
212  }
213  }
214 
215  m_assetService = m_Scene.AssetService;
216  m_regionName = m_Scene.RegionInfo.RegionName;
217 
218  RegisterHandlers();
219 
220  AddNewInventoryItem = m_Scene.AddUploadedInventoryItem;
221  ItemUpdatedCall = m_Scene.CapsUpdateInventoryItemAsset;
222  TaskScriptUpdatedCall = m_Scene.CapsUpdateTaskInventoryScriptAsset;
223  GetClient = m_Scene.SceneGraph.GetControllingClient;
224 
225  m_FileAgentInventoryState = FileAgentInventoryState.idle;
226  }
227 
231  public void RegisterHandlers()
232  {
233  string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
234 
235  RegisterRegionServiceHandlers(capsBase);
236  RegisterInventoryServiceHandlers(capsBase);
237  }
238 
239  public void RegisterRegionServiceHandlers(string capsBase)
240  {
241  try
242  {
243  // the root of all evil
244  m_HostCapsObj.RegisterHandler(
245  "SEED", new RestStreamHandler("POST", capsBase + m_requestPath, SeedCapRequest, "SEED", null));
246 
247 // m_log.DebugFormat(
248 // "[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_HostCapsObj.AgentID);
249 
250  //m_capsHandlers["MapLayer"] =
251  // new LLSDStreamhandler<OSDMapRequest, OSDMapLayerResponse>("POST",
252  // capsBase + m_mapLayerPath,
253  // GetMapLayer);
254 
255  IRequestHandler getObjectPhysicsDataHandler
256  = new RestStreamHandler(
257  "POST", capsBase + m_getObjectPhysicsDataPath, GetObjectPhysicsData, "GetObjectPhysicsData", null);
258  m_HostCapsObj.RegisterHandler("GetObjectPhysicsData", getObjectPhysicsDataHandler);
259 
260  IRequestHandler getObjectCostHandler = new RestStreamHandler("POST", capsBase + m_getObjectCostPath, GetObjectCost);
261  m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler);
262  IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected);
263  m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler);
264 
265 
266  IRequestHandler req
267  = new RestStreamHandler(
268  "POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory, "UpdateScript", null);
269 
270  m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req);
271  m_HostCapsObj.RegisterHandler("UpdateScriptTask", req);
272 
273 // IRequestHandler animSetRequestHandler
274 // = new RestStreamHandler(
275 // "POST", capsBase + m_animSetTaskUpdatePath, AnimSetTaskInventory, "UpdateScript", null);
276 
277 // m_HostCapsObj.RegisterHandler("UpdateAnimSetTaskInventory", animSetRequestHandler);
278  }
279  catch (Exception e)
280  {
281  m_log.Error("[CAPS]: " + e.ToString());
282  }
283  }
284 
285  public void RegisterInventoryServiceHandlers(string capsBase)
286  {
287  try
288  {
289  m_HostCapsObj.RegisterHandler(
290  "NewFileAgentInventory",
291  new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>(
292  "POST",
293  capsBase + m_newInventory,
294  NewAgentInventoryRequest,
295  "NewFileAgentInventory",
296  null));
297 
298  IRequestHandler req
299  = new RestStreamHandler(
300  "POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory, "Update*", null);
301 
302  m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req);
303  m_HostCapsObj.RegisterHandler("UpdateAnimSetAgentInventory", req);
304  m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req);
305  m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req);
306 
307 
308 
309  IRequestHandler UpdateAgentInformationHandler
310  = new RestStreamHandler(
311  "POST", capsBase + m_UpdateAgentInformationPath, UpdateAgentInformation, "UpdateAgentInformation", null);
312  m_HostCapsObj.RegisterHandler("UpdateAgentInformation", UpdateAgentInformationHandler);
313 
314  m_HostCapsObj.RegisterHandler(
315  "CopyInventoryFromNotecard",
316  new RestStreamHandler(
317  "POST", capsBase + m_copyFromNotecardPath, CopyInventoryFromNotecard, "CopyInventoryFromNotecard", null));
318 
319  // As of RC 1.22.9 of the Linden client this is
320  // supported
321 
322  //m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest);
323 
324  // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and
325  // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires
326  // enhancements (probably filling out the folder part of the LLSD reply) to our CAPS service,
327  // but when I went on the Linden grid, the
328  // simulators I visited (version 1.21) were, surprisingly, no longer supplying this capability. Instead,
329  // the 1.19.1.4 client appeared to be happily flowing inventory data over UDP
330  //
331  // This is very probably just a temporary measure - once the CAPS service appears again on the Linden grid
332  // we will be
333  // able to get the data we need to implement the necessary part of the protocol to fix the issue above.
334  // m_capsHandlers["FetchInventoryDescendents"] =
335  // new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest);
336 
337  // m_capsHandlers["FetchInventoryDescendents"] =
338  // new LLSDStreamhandler<LLSDFetchInventoryDescendents, LLSDInventoryDescendents>("POST",
339  // capsBase + m_fetchInventory,
340  // FetchInventory));
341  // m_capsHandlers["RequestTextureDownload"] = new RestStreamHandler("POST",
342  // capsBase + m_requestTexture,
343  // RequestTexture);
344  }
345  catch (Exception e)
346  {
347  m_log.Error("[CAPS]: " + e.ToString());
348  }
349  }
350 
360  public string SeedCapRequest(string request, string path, string param,
361  IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
362  {
363  m_log.DebugFormat(
364  "[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, m_HostCapsObj.AgentID);
365 
366  if (!m_HostCapsObj.WaitForActivation())
367  return string.Empty;
368 
369  if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint))
370  {
371  m_log.WarnFormat(
372  "[CAPS]: Unauthorized CAPS client {0} from {1}",
373  m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint);
374 
375  return string.Empty;
376  }
377 
378  OSDArray capsRequested = (OSDArray)OSDParser.DeserializeLLSDXml(request);
379  List<string> validCaps = new List<string>();
380 
381  foreach (OSD c in capsRequested)
382  validCaps.Add(c.AsString());
383 
384  string result = LLSDHelpers.SerialiseLLSDReply(m_HostCapsObj.GetCapsDetails(true, validCaps));
385 
386  //m_log.DebugFormat("[CAPS] CapsRequest {0}", result);
387 
388  return result;
389  }
390 
400  public string ScriptTaskInventory(string request, string path, string param,
401  IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
402  {
403  try
404  {
405 // m_log.Debug("[CAPS]: ScriptTaskInventory Request in region: " + m_regionName);
406  //m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param);
407 
408  Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
409  LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate();
410  LLSDHelpers.DeserialiseOSDMap(hash, llsdUpdateRequest);
411 
412  string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
413  string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
414 
415  TaskInventoryScriptUpdater uploader =
417  llsdUpdateRequest.item_id,
418  llsdUpdateRequest.task_id,
419  llsdUpdateRequest.is_script_running,
420  capsBase + uploaderPath,
421  m_HostCapsObj.HttpListener,
422  m_dumpAssetsToFile);
423  uploader.OnUpLoad += TaskScriptUpdated;
424 
425  m_HostCapsObj.HttpListener.AddStreamHandler(
427  "POST", capsBase + uploaderPath, uploader.uploaderCaps, "TaskInventoryScriptUpdater", null));
428 
429  string protocol = "http://";
430 
431  if (m_HostCapsObj.SSLCaps)
432  protocol = "https://";
433 
434  string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase +
435  uploaderPath;
436 
437  LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
438  uploadResponse.uploader = uploaderURL;
439  uploadResponse.state = "upload";
440 
441  // m_log.InfoFormat("[CAPS]: " +
442  // "ScriptTaskInventory response: {0}",
443  // LLSDHelpers.SerialiseLLSDReply(uploadResponse)));
444 
445  return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
446  }
447  catch (Exception e)
448  {
449  m_log.Error("[CAPS]: " + e.ToString());
450  }
451 
452  return null;
453  }
454 
462  public void TaskScriptUpdated(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors)
463  {
464  if (TaskScriptUpdatedCall != null)
465  {
466  ArrayList e = TaskScriptUpdatedCall(m_HostCapsObj.AgentID, itemID, primID, isScriptRunning, data);
467  foreach (Object item in e)
468  errors.Add(item);
469  }
470  }
471 
478  public UUID ItemUpdated(UUID itemID, byte[] data)
479  {
480  if (ItemUpdatedCall != null)
481  {
482  return ItemUpdatedCall(m_HostCapsObj.AgentID, itemID, data);
483  }
484 
485  return UUID.Zero;
486  }
487 
494  {
495  //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString());
496  //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type);
497 
498  // start by getting the client
499  IClientAPI client = null;
500  m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client);
501 
502  // check current state so we only have one service at a time
503  lock (m_ModelCost)
504  {
505  switch (m_FileAgentInventoryState)
506  {
507  case FileAgentInventoryState.processRequest:
508  case FileAgentInventoryState.processUpload:
509  LLSDAssetUploadError resperror = new LLSDAssetUploadError();
510  resperror.message = "Uploader busy processing previus request";
511  resperror.identifier = UUID.Zero;
512 
513  LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
514  errorResponse.uploader = "";
515  errorResponse.state = "error";
516  errorResponse.error = resperror;
517  return errorResponse;
518  break;
519  case FileAgentInventoryState.waitUpload:
520  // todo stop current uploader server
521  break;
522  case FileAgentInventoryState.idle:
523  default:
524  break;
525  }
526 
527  m_FileAgentInventoryState = FileAgentInventoryState.processRequest;
528  }
529 
530  int cost = 0;
531  int nreqtextures = 0;
532  int nreqmeshs= 0;
533  int nreqinstances = 0;
534  bool IsAtestUpload = false;
535 
536  string assetName = llsdRequest.name;
537 
539 
540  if (llsdRequest.asset_type == "texture" ||
541  llsdRequest.asset_type == "animation" ||
542  llsdRequest.asset_type == "animatn" || // this is the asset name actually used by viewers
543  llsdRequest.asset_type == "mesh" ||
544  llsdRequest.asset_type == "sound")
545  {
546  ScenePresence avatar = null;
547  m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar);
548 
549  // check user level
550  if (avatar != null)
551  {
552  if (avatar.UserLevel < m_levelUpload)
553  {
554  LLSDAssetUploadError resperror = new LLSDAssetUploadError();
555  resperror.message = "Insufficient permissions to upload";
556  resperror.identifier = UUID.Zero;
557 
558  LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
559  errorResponse.uploader = "";
560  errorResponse.state = "error";
561  errorResponse.error = resperror;
562  lock (m_ModelCost)
563  m_FileAgentInventoryState = FileAgentInventoryState.idle;
564  return errorResponse;
565  }
566  }
567 
568  // check test upload and funds
569  if (client != null)
570  {
571  IMoneyModule mm = m_Scene.RequestModuleInterface<IMoneyModule>();
572 
573  int baseCost = 0;
574  if (mm != null)
575  baseCost = mm.UploadCharge;
576 
577  string warning = String.Empty;
578 
579  if (llsdRequest.asset_type == "mesh")
580  {
581  string error;
582  int modelcost;
583 
584 
585  if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost,
586  meshcostdata, out error, ref warning))
587  {
588  LLSDAssetUploadError resperror = new LLSDAssetUploadError();
589  resperror.message = error;
590  resperror.identifier = UUID.Zero;
591 
592  LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
593  errorResponse.uploader = "";
594  errorResponse.state = "error";
595  errorResponse.error = resperror;
596 
597  lock (m_ModelCost)
598  m_FileAgentInventoryState = FileAgentInventoryState.idle;
599  return errorResponse;
600  }
601  cost = modelcost;
602  }
603  else
604  {
605  cost = baseCost;
606  }
607 
608  if (cost > 0 && mm != null)
609  {
610  // check for test upload
611 
612  if (m_ForceFreeTestUpload) // all are test
613  {
614  if (!(assetName.Length > 5 && assetName.StartsWith("TEST-"))) // has normal name lets change it
615  assetName = "TEST-" + assetName;
616 
617  IsAtestUpload = true;
618  }
619 
620  else if (m_enableFreeTestUpload) // only if prefixed with "TEST-"
621  {
622 
623  IsAtestUpload = (assetName.Length > 5 && assetName.StartsWith("TEST-"));
624  }
625 
626 
627  if(IsAtestUpload) // let user know, still showing cost estimation
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";
629 
630  // check funds
631  else
632  {
633  if (!mm.UploadCovered(client.AgentId, (int)cost))
634  {
635  LLSDAssetUploadError resperror = new LLSDAssetUploadError();
636  resperror.message = "Insuficient funds";
637  resperror.identifier = UUID.Zero;
638 
639  LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
640  errorResponse.uploader = "";
641  errorResponse.state = "error";
642  errorResponse.error = resperror;
643  lock (m_ModelCost)
644  m_FileAgentInventoryState = FileAgentInventoryState.idle;
645  return errorResponse;
646  }
647  }
648  }
649 
650  if (client != null && warning != String.Empty)
651  client.SendAgentAlertMessage(warning, true);
652  }
653  }
654 
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;
662 
663  if(!IsAtestUpload && m_enableModelUploadTextureToInventory)
664  texturesFolder = llsdRequest.texture_folder_id;
665 
666  AssetUploader uploader =
667  new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
668  llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost,
669  texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload);
670 
671  m_HostCapsObj.HttpListener.AddStreamHandler(
673  "POST",
674  capsBase + uploaderPath,
675  uploader.uploaderCaps,
676  "NewAgentInventoryRequest",
677  m_HostCapsObj.AgentID.ToString()));
678 
679  string protocol = "http://";
680 
681  if (m_HostCapsObj.SSLCaps)
682  protocol = "https://";
683 
684  string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase +
685  uploaderPath;
686 
687 
688  LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
689  uploadResponse.uploader = uploaderURL;
690  uploadResponse.state = "upload";
691  uploadResponse.upload_price = (int)cost;
692 
693  if (llsdRequest.asset_type == "mesh")
694  {
695  uploadResponse.data = meshcostdata;
696  }
697 
698  uploader.OnUpLoad += UploadCompleteHandler;
699 
700  lock (m_ModelCost)
701  m_FileAgentInventoryState = FileAgentInventoryState.waitUpload;
702 
703  return uploadResponse;
704  }
705 
712  public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
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)
717  {
718 
719  lock (m_ModelCost)
720  m_FileAgentInventoryState = FileAgentInventoryState.processUpload;
721 
722  m_log.DebugFormat(
723  "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}",
724  assetID, inventoryItem, inventoryType, assetType);
725 
726  sbyte assType = 0;
727  sbyte inType = 0;
728 
729  IClientAPI client = null;
730 
731  UUID owner_id = m_HostCapsObj.AgentID;
732  UUID creatorID;
733 
734  bool istest = IsAtestUpload && m_enableFreeTestUpload && (cost > 0);
735 
736  bool restrictPerms = m_RestrictFreeTestUploadPerms && istest;
737 
738  if (istest && m_testAssetsCreatorID != UUID.Zero)
739  creatorID = m_testAssetsCreatorID;
740  else
741  creatorID = owner_id;
742 
743  string creatorIDstr = creatorID.ToString();
744 
745  IMoneyModule mm = m_Scene.RequestModuleInterface<IMoneyModule>();
746  if (mm != null)
747  {
748  // make sure client still has enougth credit
749  if (!mm.UploadCovered(m_HostCapsObj.AgentID, (int)cost))
750  {
751  error = "Insufficient funds.";
752  return;
753  }
754  }
755 
756  // strings to types
757  if (inventoryType == "sound")
758  {
759  inType = (sbyte)InventoryType.Sound;
760  assType = (sbyte)AssetType.Sound;
761  }
762  else if (inventoryType == "snapshot")
763  {
764  inType = (sbyte)InventoryType.Snapshot;
765  }
766  else if (inventoryType == "animation")
767  {
768  inType = (sbyte)InventoryType.Animation;
769  assType = (sbyte)AssetType.Animation;
770  }
771  else if (inventoryType == "animset")
772  {
773  inType = (sbyte)CustomInventoryType.AnimationSet;
774  assType = (sbyte)CustomAssetType.AnimationSet;
775  m_log.Debug("got animset upload request");
776  }
777  else if (inventoryType == "wearable")
778  {
779  inType = (sbyte)InventoryType.Wearable;
780  switch (assetType)
781  {
782  case "bodypart":
783  assType = (sbyte)AssetType.Bodypart;
784  break;
785  case "clothing":
786  assType = (sbyte)AssetType.Clothing;
787  break;
788  }
789  }
790  else if (inventoryType == "object")
791  {
792  if (assetType == "mesh") // this code for now is for mesh models uploads only
793  {
794  inType = (sbyte)InventoryType.Object;
795  assType = (sbyte)AssetType.Object;
796 
797  List<Vector3> positions = new List<Vector3>();
798  List<Quaternion> rotations = new List<Quaternion>();
799  OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data);
800 
801  // compare and get updated information
802 /* does nothing still we do need something to avoid special viewer to upload something diferent from the cost estimation
803  bool mismatchError = true;
804 
805  while (mismatchError)
806  {
807  mismatchError = false;
808  }
809 
810  if (mismatchError)
811  {
812  error = "Upload and fee estimation information don't match";
813  lock (m_ModelCost)
814  m_FileAgentInventoryState = FileAgentInventoryState.idle;
815 
816  return;
817  }
818 */
819  OSDArray instance_list = (OSDArray)request["instance_list"];
820  OSDArray mesh_list = (OSDArray)request["mesh_list"];
821  OSDArray texture_list = (OSDArray)request["texture_list"];
822  SceneObjectGroup grp = null;
823 
824  // create and store texture assets
825  bool doTextInv = (!istest && m_enableModelUploadTextureToInventory &&
826  texturesFolder != UUID.Zero);
827 
828 
829  List<UUID> textures = new List<UUID>();
830 
831 
832 // if (doTextInv)
833  m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client);
834 
835  if(client == null) // don't put textures in inventory if there is no client
836  doTextInv = false;
837 
838  for (int i = 0; i < texture_list.Count; i++)
839  {
840  AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, creatorIDstr);
841  textureAsset.Data = texture_list[i].AsBinary();
842  if (istest)
843  textureAsset.Local = true;
844  m_assetService.Store(textureAsset);
845  textures.Add(textureAsset.FullID);
846 
847  if (doTextInv)
848  {
849  string name = assetName;
850  if (name.Length > 25)
851  name = name.Substring(0, 24);
852  name += "_Texture#" + i.ToString();
853  InventoryItemBase texitem = new InventoryItemBase();
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";
860  texitem.Name = name;
861  texitem.AssetType = (int)AssetType.Texture;
862  texitem.InvType = (int)InventoryType.Texture;
863  texitem.Folder = texturesFolder;
864 
865  texitem.CurrentPermissions
866  = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Export);
867 
868  texitem.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export;
869  texitem.EveryOnePermissions = 0;
870  texitem.NextPermissions = (uint)PermissionMask.All;
871  texitem.CreationDate = Util.UnixTimeSinceEpoch();
872 
873  m_Scene.AddInventoryItem(client, texitem);
874  texitem = null;
875  }
876  }
877 
878  // create and store meshs assets
879  List<UUID> meshAssets = new List<UUID>();
880  List<bool> meshAvatarSkeletons = new List<bool>();
881  List<bool> meshAvatarColliders = new List<bool>();
882 
883  bool curAvSkeleton;
884  bool curAvCollider;
885  for (int i = 0; i < mesh_list.Count; i++)
886  {
887  curAvSkeleton = false;
888  curAvCollider = false;
889 
890  // we do need to parse the mesh now
891  OSD osd = OSDParser.DeserializeLLSDBinary(mesh_list[i]);
892  if (osd is OSDMap)
893  {
894  OSDMap mosd = (OSDMap)osd;
895  if (mosd.ContainsKey("skeleton"))
896  {
897  OSDMap skeleton = (OSDMap)mosd["skeleton"];
898  int sksize = skeleton["size"].AsInteger();
899  if (sksize > 0)
900  curAvSkeleton = true;
901  }
902  }
903 
904  AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr);
905  meshAsset.Data = mesh_list[i].AsBinary();
906  if (istest)
907  meshAsset.Local = true;
908  m_assetService.Store(meshAsset);
909  meshAssets.Add(meshAsset.FullID);
910  meshAvatarSkeletons.Add(curAvSkeleton);
911  meshAvatarColliders.Add(curAvCollider);
912 
913  // test code
914  if (curAvSkeleton && client != null)
915  {
916  string name = assetName;
917  if (name.Length > 25)
918  name = name.Substring(0, 24);
919  name += "_Mesh#" + i.ToString();
920  InventoryItemBase meshitem = new InventoryItemBase();
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;
930  // meshitem.Folder = UUID.Zero; // send to default
931 
932  meshitem.Folder = parentFolder; // dont let it go to folder Meshes that viewers dont show
933 
934  // If we set PermissionMask.All then when we rez the item the next permissions will replace the current
935  // (owner) permissions. This becomes a problem if next permissions are changed.
936  meshitem.CurrentPermissions
937  = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
938 
939  meshitem.BasePermissions = (uint)PermissionMask.All;
940  meshitem.EveryOnePermissions = 0;
941  meshitem.NextPermissions = (uint)PermissionMask.All;
942  meshitem.CreationDate = Util.UnixTimeSinceEpoch();
943 
944  m_Scene.AddInventoryItem(client, meshitem);
945  meshitem = null;
946  }
947  }
948 
949  int skipedMeshs = 0;
950  // build prims from instances
951  for (int i = 0; i < instance_list.Count; i++)
952  {
953  OSDMap inner_instance_list = (OSDMap)instance_list[i];
954 
955  // skip prims that are 2 small
956  Vector3 scale = inner_instance_list["scale"].AsVector3();
957 
958  if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin)
959  {
960  skipedMeshs++;
961  continue;
962  }
963 
964  PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
965 
966  Primitive.TextureEntry textureEntry
967  = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE);
968 
969 
970  OSDArray face_list = (OSDArray)inner_instance_list["face_list"];
971  for (uint face = 0; face < face_list.Count; face++)
972  {
973  OSDMap faceMap = (OSDMap)face_list[(int)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();
979 
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();
986 
987  if (imagerot != 0)
988  f.Rotation = imagerot;
989 
990  if (offsets != 0)
991  f.OffsetU = offsets;
992 
993  if (offsett != 0)
994  f.OffsetV = offsett;
995 
996  if (scales != 0)
997  f.RepeatU = scales;
998 
999  if (scalet != 0)
1000  f.RepeatV = scalet;
1001 
1002  if (textures.Count > textureNum)
1003  f.TextureID = textures[textureNum];
1004  else
1005  f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE;
1006 
1007  textureEntry.FaceTextures[face] = f;
1008  }
1009 
1010  pbs.TextureEntry = textureEntry.GetBytes();
1011 
1012  bool hasmesh = false;
1013  if (inner_instance_list.ContainsKey("mesh")) // seems to happen always but ...
1014  {
1015  int meshindx = inner_instance_list["mesh"].AsInteger();
1016  if (meshAssets.Count > meshindx)
1017  {
1018  pbs.SculptEntry = true;
1019  pbs.SculptType = (byte)SculptType.Mesh;
1020  pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction
1021  // data will be requested from asset on rez (i hope)
1022  hasmesh = true;
1023  }
1024  }
1025 
1026  Vector3 position = inner_instance_list["position"].AsVector3();
1027  Quaternion rotation = inner_instance_list["rotation"].AsQuaternion();
1028 
1029  // for now viwers do send fixed defaults
1030  // but this may change
1031 // int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger();
1032  byte physicsShapeType = (byte)PhysShapeType.convex; // default is simple convex
1033 // int material = inner_instance_list["material"].AsInteger();
1034  byte material = (byte)Material.Wood;
1035 
1036 // no longer used - begin ------------------------
1037 // int mesh = inner_instance_list["mesh"].AsInteger();
1038 
1039 // OSDMap permissions = (OSDMap)inner_instance_list["permissions"];
1040 // int base_mask = permissions["base_mask"].AsInteger();
1041 // int everyone_mask = permissions["everyone_mask"].AsInteger();
1042 // UUID creator_id = permissions["creator_id"].AsUUID();
1043 // UUID group_id = permissions["group_id"].AsUUID();
1044 // int group_mask = permissions["group_mask"].AsInteger();
1045 // bool is_owner_group = permissions["is_owner_group"].AsBoolean();
1046 // UUID last_owner_id = permissions["last_owner_id"].AsUUID();
1047 // int next_owner_mask = permissions["next_owner_mask"].AsInteger();
1048 // UUID owner_id = permissions["owner_id"].AsUUID();
1049 // int owner_mask = permissions["owner_mask"].AsInteger();
1050 // no longer used - end ------------------------
1051 
1052 
1054  = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero);
1055 
1056  prim.Scale = scale;
1057  rotations.Add(rotation);
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();
1065 
1066  if (grp == null)
1067  prim.Name = assetName;
1068  else
1069  prim.Name = assetName + "#" + i.ToString();
1070 
1071  prim.EveryoneMask = 0;
1072  prim.GroupMask = 0;
1073 
1074  if (restrictPerms)
1075  {
1076  prim.BaseMask = (uint)(PermissionMask.Move | PermissionMask.Modify);
1077  prim.OwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify);
1078  prim.NextOwnerMask = 0;
1079  }
1080  else
1081  {
1082  prim.BaseMask = (uint)PermissionMask.All | (uint)PermissionMask.Export;
1083  prim.OwnerMask = (uint)PermissionMask.All | (uint)PermissionMask.Export;
1084  prim.NextOwnerMask = (uint)PermissionMask.Transfer;
1085  }
1086 
1087  if(istest)
1088  prim.Description = "For testing only. Other uses are prohibited";
1089  else
1090  prim.Description = "";
1091 
1092  prim.Material = material;
1093  prim.PhysicsShapeType = physicsShapeType;
1094 
1095 // prim.BaseMask = (uint)base_mask;
1096 // prim.EveryoneMask = (uint)everyone_mask;
1097 // prim.GroupMask = (uint)group_mask;
1098 // prim.NextOwnerMask = (uint)next_owner_mask;
1099 // prim.OwnerMask = (uint)owner_mask;
1100 
1101  if (grp == null)
1102  {
1103  grp = new SceneObjectGroup(prim);
1104  grp.LastOwnerID = creatorID;
1105  }
1106  else
1107  grp.AddPart(prim);
1108  }
1109 
1110  Vector3 rootPos = positions[0];
1111 
1112  if (grp.Parts.Length > 1)
1113  {
1114  // Fix first link number
1115  grp.RootPart.LinkNum++;
1116 
1117  Quaternion rootRotConj = Quaternion.Conjugate(rotations[0]);
1118  Quaternion tmprot;
1119  Vector3 offset;
1120 
1121  // fix children rotations and positions
1122  for (int i = 1; i < rotations.Count; i++)
1123  {
1124  tmprot = rotations[i];
1125  tmprot = rootRotConj * tmprot;
1126 
1127  grp.Parts[i].RotationOffset = tmprot;
1128 
1129  offset = positions[i] - rootPos;
1130 
1131  offset *= rootRotConj;
1132  grp.Parts[i].OffsetPosition = offset;
1133  }
1134 
1135  grp.AbsolutePosition = rootPos;
1136  grp.UpdateGroupRotationR(rotations[0]);
1137  }
1138  else
1139  {
1140  grp.AbsolutePosition = rootPos;
1141  grp.UpdateGroupRotationR(rotations[0]);
1142  }
1143 
1144  data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp));
1145  }
1146 
1147  else // not a mesh model
1148  {
1149  m_log.ErrorFormat("[CAPS Asset Upload] got unsuported assetType for object upload");
1150  return;
1151  }
1152  }
1153 
1154  AssetBase asset;
1155  asset = new AssetBase(assetID, assetName, assType, creatorIDstr);
1156  asset.Data = data;
1157  if (istest)
1158  asset.Local = true;
1159  if (AddNewAsset != null)
1160  AddNewAsset(asset);
1161  else if (m_assetService != null)
1162  m_assetService.Store(asset);
1163 
1164  InventoryItemBase item = new InventoryItemBase();
1165  item.Owner = m_HostCapsObj.AgentID;
1166  item.CreatorId = creatorIDstr;
1167  item.CreatorData = String.Empty;
1168  item.ID = inventoryItem;
1169  item.AssetID = asset.FullID;
1170  if (istest)
1171  {
1172  item.Description = "For testing only. Other uses are prohibited";
1173  item.Flags = (uint) (InventoryItemFlags.SharedSingleReference);
1174  }
1175  else
1176  item.Description = assetDescription;
1177  item.Name = assetName;
1178  item.AssetType = assType;
1179  item.InvType = inType;
1180  item.Folder = parentFolder;
1181 
1182  // If we set PermissionMask.All then when we rez the item the next permissions will replace the current
1183  // (owner) permissions. This becomes a problem if next permissions are changed.
1184 
1185  if (inType == (sbyte)CustomInventoryType.AnimationSet)
1186  {
1187  AnimationSet.setCreateItemPermitions(item);
1188  }
1189 
1190  else if (restrictPerms)
1191  {
1192  item.BasePermissions = (uint)(PermissionMask.Move | PermissionMask.Modify);
1193  item.CurrentPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify);
1194  item.EveryOnePermissions = 0;
1195  item.NextPermissions = 0;
1196  }
1197  else
1198  {
1199  item.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export;
1200  item.CurrentPermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export;
1201  item.EveryOnePermissions = 0;
1202  item.NextPermissions = (uint)PermissionMask.Transfer;
1203  }
1204 
1205  item.CreationDate = Util.UnixTimeSinceEpoch();
1206 
1207  m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client);
1208 
1209  if (AddNewInventoryItem != null)
1210  {
1211  if (istest)
1212  {
1213  m_Scene.AddInventoryItem(client, item);
1214 /*
1215  AddNewInventoryItem(m_HostCapsObj.AgentID, item, 0);
1216  if (client != null)
1217  client.SendAgentAlertMessage("Upload will have no cost, for personal test purposes only. Other uses are forbiden. Items may not work on a another region" , true);
1218  */
1219  }
1220  else
1221  {
1222  AddNewInventoryItem(m_HostCapsObj.AgentID, item, (uint)cost);
1223 // if (client != null)
1224 // {
1225 // // let users see anything.. i don't so far
1226 // string str;
1227 // if (cost > 0)
1228 // // dont remember where is money unit name to put here
1229 // str = "Upload complete. charged " + cost.ToString() + "$";
1230 // else
1231 // str = "Upload complete";
1232 // client.SendAgentAlertMessage(str, true);
1233 // }
1234  }
1235  }
1236 
1237  lock (m_ModelCost)
1238  m_FileAgentInventoryState = FileAgentInventoryState.idle;
1239  }
1240 
1247  {
1248  m_log.Debug("[CAPS]: MapLayer Request in region: " + m_regionName);
1249  LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
1250  mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse());
1251  return mapResponse;
1252  }
1253 
1259  {
1260  OSDMapLayer mapLayer = new OSDMapLayer();
1261  mapLayer.Right = 5000;
1262  mapLayer.Top = 5000;
1263  mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006");
1264 
1265  return mapLayer;
1266  }
1267 
1275  public string RequestTexture(string request, string path, string param)
1276  {
1277  m_log.Debug("texture request " + request);
1278  // Needs implementing (added to remove compiler warning)
1279  return String.Empty;
1280  }
1281 
1282 
1290  public string NoteCardAgentInventory(string request, string path, string param,
1291  IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
1292  {
1293  //m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName + "\n" + request);
1294  //m_log.Debug("[CAPS]: NoteCardAgentInventory Request is: " + request);
1295 
1296  //OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request));
1297  Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
1298  LLSDItemUpdate llsdRequest = new LLSDItemUpdate();
1299  LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest);
1300 
1301  string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
1302  string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
1303 
1304  ItemUpdater uploader =
1305  new ItemUpdater(llsdRequest.item_id, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile);
1306  uploader.OnUpLoad += ItemUpdated;
1307 
1308  m_HostCapsObj.HttpListener.AddStreamHandler(
1309  new BinaryStreamHandler(
1310  "POST", capsBase + uploaderPath, uploader.uploaderCaps, "NoteCardAgentInventory", null));
1311 
1312  string protocol = "http://";
1313 
1314  if (m_HostCapsObj.SSLCaps)
1315  protocol = "https://";
1316 
1317  string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase +
1318  uploaderPath;
1319 
1320  LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
1321  uploadResponse.uploader = uploaderURL;
1322  uploadResponse.state = "upload";
1323 
1324  // m_log.InfoFormat("[CAPS]: " +
1325  // "NoteCardAgentInventory response: {0}",
1326  // LLSDHelpers.SerialiseLLSDReply(uploadResponse)));
1327 
1328  return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
1329  }
1330 
1337  public string CopyInventoryFromNotecard(string request, string path, string param,
1338  IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
1339  {
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"] = "";
1345 
1346  try
1347  {
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();
1353 
1354  // m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, FolderID:{0}, ItemID:{1}, NotecardID:{2}, ObjectID:{3}", folderID, itemID, notecardID, objectID);
1355 
1356  if (objectID != UUID.Zero)
1357  {
1358  SceneObjectPart part = m_Scene.GetSceneObjectPart(objectID);
1359  if (part != null)
1360  {
1361 // TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(notecardID);
1362  if (!m_Scene.Permissions.CanCopyObjectInventory(notecardID, objectID, m_HostCapsObj.AgentID))
1363  {
1364  return LLSDHelpers.SerialiseLLSDReply(response);
1365  }
1366  }
1367  }
1368 
1369  InventoryItemBase item = null;
1370  InventoryItemBase copyItem = null;
1371  IClientAPI client = null;
1372 
1373  m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client);
1374  item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID));
1375  if (item != null)
1376  {
1377  string message;
1378  copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID, out message);
1379  if (copyItem != null && client != null)
1380  {
1381  m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder);
1382  client.SendBulkUpdateInventory(copyItem);
1383  }
1384  }
1385  else
1386  {
1387  m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID);
1388  if (client != null)
1389  client.SendAlertMessage("Failed to retrieve item");
1390  }
1391  }
1392  catch (Exception e)
1393  {
1394  m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard : {0}", e.ToString());
1395  }
1396 
1397  response["int_response_code"] = 200;
1398  return LLSDHelpers.SerialiseLLSDReply(response);
1399  }
1400 
1401  public string GetObjectPhysicsData(string request, string path,
1402  string param, IOSHttpRequest httpRequest,
1403  IOSHttpResponse httpResponse)
1404  {
1405  OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
1406  OSDMap resp = new OSDMap();
1407  OSDArray object_ids = (OSDArray)req["object_ids"];
1408 
1409  for (int i = 0 ; i < object_ids.Count ; i++)
1410  {
1411  UUID uuid = object_ids[i].AsUUID();
1412 
1413  SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid);
1414  if (obj != null)
1415  {
1416  OSDMap object_data = new OSDMap();
1417 
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;
1423 
1424  resp[uuid.ToString()] = object_data;
1425  }
1426  }
1427 
1428  string response = OSDParser.SerializeLLSDXmlString(resp);
1429  return response;
1430  }
1431 
1432  public string GetObjectCost(string request, string path,
1433  string param, IOSHttpRequest httpRequest,
1434  IOSHttpResponse httpResponse)
1435  {
1436  OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
1437  OSDMap resp = new OSDMap();
1438 
1439  OSDArray object_ids = (OSDArray)req["object_ids"];
1440 
1441  for (int i = 0; i < object_ids.Count; i++)
1442  {
1443  UUID uuid = object_ids[i].AsUUID();
1444 
1445  SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid);
1446  SceneObjectGroup grp = null;
1447  if (part != null)
1448  grp = part.ParentGroup;
1449  if (grp != null)
1450  {
1451  float linksetCost;
1452  float linksetPhysCost;
1453  float partCost;
1454  float partPhysCost;
1455 
1456  grp.GetResourcesCosts(part,out linksetCost,out linksetPhysCost,out partCost,out partPhysCost);
1457 
1458  OSDMap object_data = new OSDMap();
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;
1465  }
1466  }
1467  if(resp.Count == 0)
1468  {
1469  OSDMap object_data = new OSDMap();
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;
1475  }
1476  string response = OSDParser.SerializeLLSDXmlString(resp);
1477  return response;
1478  }
1479 
1480  public string ResourceCostSelected(string request, string path,
1481  string param, IOSHttpRequest httpRequest,
1482  IOSHttpResponse httpResponse)
1483  {
1484  OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
1485  OSDMap resp = new OSDMap();
1486 
1487 
1488  float phys=0;
1489  float stream=0;
1490  float simul=0;
1491 
1492  if (req.ContainsKey("selected_roots"))
1493  {
1494  OSDArray object_ids = (OSDArray)req["selected_roots"];
1495 
1496  // should go by SOG suming costs for all parts
1497  // ll v3 works ok with several objects select we get the list and adds ok
1498  // FS calls per object so results are wrong guess fs bug
1499  for (int i = 0; i < object_ids.Count; i++)
1500  {
1501  UUID uuid = object_ids[i].AsUUID();
1502  float Physc;
1503  float simulc;
1504  float streamc;
1505 
1506  SceneObjectGroup grp = m_Scene.GetGroupByPrim(uuid);
1507  if (grp != null)
1508  {
1509  grp.GetSelectedCosts(out Physc, out streamc, out simulc);
1510  phys += Physc;
1511  stream += streamc;
1512  simul += simulc;
1513  }
1514  }
1515  }
1516  else if (req.ContainsKey("selected_prims"))
1517  {
1518  OSDArray object_ids = (OSDArray)req["selected_prims"];
1519 
1520  // don't see in use in any of the 2 viewers
1521  // guess it should be for edit linked but... nothing
1522  // should go to SOP per part
1523  for (int i = 0; i < object_ids.Count; i++)
1524  {
1525  UUID uuid = object_ids[i].AsUUID();
1526 
1527  SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid);
1528  if (part != null)
1529  {
1530  phys += part.PhysicsCost;
1531  stream += part.StreamingCost;
1532  simul += part.SimulationCost;
1533  }
1534  }
1535  }
1536 
1537  OSDMap object_data = new OSDMap();
1538 
1539  object_data["physics"] = phys;
1540  object_data["streaming"] = stream;
1541  object_data["simulation"] = simul;
1542 
1543  resp["selected"] = object_data;
1544 // resp["transaction_id"] = "undef";
1545  string response = OSDParser.SerializeLLSDXmlString(resp);
1546  return response;
1547  }
1548 
1549  public string UpdateAgentInformation(string request, string path,
1550  string param, IOSHttpRequest httpRequest,
1551  IOSHttpResponse httpResponse)
1552  {
1553 // OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
1554  OSDMap resp = new OSDMap();
1555 
1556  OSDMap accessPrefs = new OSDMap();
1557  accessPrefs["max"] = "A";
1558 
1559  resp["access_prefs"] = accessPrefs;
1560 
1561  string response = OSDParser.SerializeLLSDXmlString(resp);
1562  return response;
1563  }
1564  }
1565 
1566  public class AssetUploader
1567  {
1568  private static readonly ILog m_log =
1569  LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
1570 
1571 
1572  public event UpLoadedAsset OnUpLoad;
1573  private UpLoadedAsset handlerUpLoad = null;
1574 
1575  private string uploaderPath = String.Empty;
1576  private UUID newAssetID;
1577  private UUID inventoryItemID;
1578  private UUID parentFolder;
1579  private IHttpServer httpListener;
1580  private bool m_dumpAssetsToFile;
1581  private string m_assetName = String.Empty;
1582  private string m_assetDes = String.Empty;
1583 
1584  private string m_invType = String.Empty;
1585  private string m_assetType = String.Empty;
1586  private int m_cost;
1587  private string m_error = String.Empty;
1588 
1589  private Timer m_timeoutTimer = new Timer();
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;
1595 
1596  public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem,
1597  UUID parentFolderID, string invType, string assetType, string path,
1598  IHttpServer httpServer, bool dumpAssetsToFile,
1599  int totalCost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances,
1600  bool IsAtestUpload)
1601  {
1602  m_assetName = assetName;
1603  m_assetDes = description;
1604  newAssetID = assetID;
1605  inventoryItemID = inventoryItem;
1606  uploaderPath = path;
1607  httpListener = httpServer;
1608  parentFolder = parentFolderID;
1609  m_assetType = assetType;
1610  m_invType = invType;
1611  m_dumpAssetsToFile = dumpAssetsToFile;
1612  m_cost = totalCost;
1613 
1614  m_texturesFolder = texturesFolder;
1615  m_nreqtextures = nreqtextures;
1616  m_nreqmeshs = nreqmeshs;
1617  m_nreqinstances = nreqinstances;
1618  m_IsAtestUpload = IsAtestUpload;
1619 
1620  m_timeoutTimer.Elapsed += TimedOut;
1621  m_timeoutTimer.Interval = 120000;
1622  m_timeoutTimer.AutoReset = false;
1623  m_timeoutTimer.Start();
1624  }
1625 
1633  public string uploaderCaps(byte[] data, string path, string param)
1634  {
1635  UUID inv = inventoryItemID;
1636  string res = String.Empty;
1637  LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
1638 /*
1639  uploadComplete.new_asset = newAssetID.ToString();
1640  uploadComplete.new_inventory_item = inv;
1641  uploadComplete.state = "complete";
1642 
1643  res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
1644 */
1645  m_timeoutTimer.Stop();
1646  httpListener.RemoveStreamHandler("POST", uploaderPath);
1647 
1648  // TODO: probably make this a better set of extensions here
1649  string extension = ".jp2";
1650  if (m_invType != "image")
1651  {
1652  extension = ".dat";
1653  }
1654 
1655  if (m_dumpAssetsToFile)
1656  {
1657  SaveAssetToFile(m_assetName + extension, data);
1658  }
1659  handlerUpLoad = OnUpLoad;
1660  if (handlerUpLoad != null)
1661  {
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,
1664  ref m_error);
1665  }
1666  if (m_IsAtestUpload)
1667  {
1668  LLSDAssetUploadError resperror = new LLSDAssetUploadError();
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;
1671 
1672  uploadComplete.error = resperror;
1673  uploadComplete.state = "Upload4Testing";
1674  }
1675  else
1676  {
1677  if (m_error == String.Empty)
1678  {
1679  uploadComplete.new_asset = newAssetID.ToString();
1680  uploadComplete.new_inventory_item = inv;
1681  // if (m_texturesFolder != UUID.Zero)
1682  // uploadComplete.new_texture_folder_id = m_texturesFolder;
1683  uploadComplete.state = "complete";
1684  }
1685  else
1686  {
1687  LLSDAssetUploadError resperror = new LLSDAssetUploadError();
1688  resperror.message = m_error;
1689  resperror.identifier = inv;
1690 
1691  uploadComplete.error = resperror;
1692  uploadComplete.state = "failed";
1693  }
1694  }
1695 
1696  res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
1697  return res;
1698  }
1699 
1700  private void TimedOut(object sender, ElapsedEventArgs args)
1701  {
1702  m_log.InfoFormat("[CAPS]: Removing URL and handler for timed out mesh upload");
1703  httpListener.RemoveStreamHandler("POST", uploaderPath);
1704  }
1705 
1707  //private void SaveAssetToFile(string filename, byte[] data)
1708  //{
1709  // FileStream fs = File.Create(filename);
1710  // BinaryWriter bw = new BinaryWriter(fs);
1711  // bw.Write(data);
1712  // bw.Close();
1713  // fs.Close();
1714  //}
1715 
1716  private static void SaveAssetToFile(string filename, byte[] data)
1717  {
1718  string assetPath = "UserAssets";
1719  if (!Directory.Exists(assetPath))
1720  {
1721  Directory.CreateDirectory(assetPath);
1722  }
1723  FileStream fs = File.Create(Path.Combine(assetPath, Util.safeFileName(filename)));
1724  BinaryWriter bw = new BinaryWriter(fs);
1725  bw.Write(data);
1726  bw.Close();
1727  fs.Close();
1728  }
1729  }
1730 
1735  public class ItemUpdater
1736  {
1737  public event UpdateItem OnUpLoad;
1738 
1739  private UpdateItem handlerUpdateItem = null;
1740 
1741  private string uploaderPath = String.Empty;
1742  private UUID inventoryItemID;
1743  private IHttpServer httpListener;
1744  private bool m_dumpAssetToFile;
1745 
1746  public ItemUpdater(UUID inventoryItem, string path, IHttpServer httpServer, bool dumpAssetToFile)
1747  {
1748  m_dumpAssetToFile = dumpAssetToFile;
1749 
1750  inventoryItemID = inventoryItem;
1751  uploaderPath = path;
1752  httpListener = httpServer;
1753  }
1754 
1762  public string uploaderCaps(byte[] data, string path, string param)
1763  {
1764  UUID inv = inventoryItemID;
1765  string res = String.Empty;
1766  LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
1767  UUID assetID = UUID.Zero;
1768  handlerUpdateItem = OnUpLoad;
1769  if (handlerUpdateItem != null)
1770  {
1771  assetID = handlerUpdateItem(inv, data);
1772  }
1773 
1774  uploadComplete.new_asset = assetID.ToString();
1775  uploadComplete.new_inventory_item = inv;
1776  uploadComplete.state = "complete";
1777 
1778  res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
1779 
1780  httpListener.RemoveStreamHandler("POST", uploaderPath);
1781 
1782  if (m_dumpAssetToFile)
1783  {
1784  SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data);
1785  }
1786 
1787  return res;
1788  }
1789 
1791  //private void SaveAssetToFile(string filename, byte[] data)
1792  //{
1793  // FileStream fs = File.Create(filename);
1794  // BinaryWriter bw = new BinaryWriter(fs);
1795  // bw.Write(data);
1796  // bw.Close();
1797  // fs.Close();
1798  //}
1799 
1800  private static void SaveAssetToFile(string filename, byte[] data)
1801  {
1802  string assetPath = "UserAssets";
1803  if (!Directory.Exists(assetPath))
1804  {
1805  Directory.CreateDirectory(assetPath);
1806  }
1807  FileStream fs = File.Create(Path.Combine(assetPath, filename));
1808  BinaryWriter bw = new BinaryWriter(fs);
1809  bw.Write(data);
1810  bw.Close();
1811  fs.Close();
1812  }
1813  }
1814 
1820  {
1821  private static readonly ILog m_log =
1822  LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
1823 
1824  public event UpdateTaskScript OnUpLoad;
1825 
1826  private UpdateTaskScript handlerUpdateTaskScript = null;
1827 
1828  private string uploaderPath = String.Empty;
1829  private UUID inventoryItemID;
1830  private UUID primID;
1831  private bool isScriptRunning;
1832  private IHttpServer httpListener;
1833  private bool m_dumpAssetToFile;
1834 
1835  public TaskInventoryScriptUpdater(UUID inventoryItemID, UUID primID, int isScriptRunning,
1836  string path, IHttpServer httpServer, bool dumpAssetToFile)
1837  {
1838  m_dumpAssetToFile = dumpAssetToFile;
1839 
1840  this.inventoryItemID = inventoryItemID;
1841  this.primID = primID;
1842 
1843  // This comes in over the packet as an integer, but actually appears to be treated as a bool
1844  this.isScriptRunning = (0 == isScriptRunning ? false : true);
1845 
1846  uploaderPath = path;
1847  httpListener = httpServer;
1848  }
1849 
1857  public string uploaderCaps(byte[] data, string path, string param)
1858  {
1859  try
1860  {
1861  // m_log.InfoFormat("[CAPS]: " +
1862  // "TaskInventoryScriptUpdater received data: {0}, path: {1}, param: {2}",
1863  // data, path, param));
1864 
1865  string res = String.Empty;
1867 
1868  ArrayList errors = new ArrayList();
1869  handlerUpdateTaskScript = OnUpLoad;
1870  if (handlerUpdateTaskScript != null)
1871  {
1872  handlerUpdateTaskScript(inventoryItemID, primID, isScriptRunning, data, ref errors);
1873  }
1874 
1875  uploadComplete.new_asset = inventoryItemID;
1876  uploadComplete.compiled = errors.Count > 0 ? false : true;
1877  uploadComplete.state = "complete";
1878  uploadComplete.errors = new OpenSim.Framework.Capabilities.OSDArray();
1879  uploadComplete.errors.Array = errors;
1880 
1881  res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
1882 
1883  httpListener.RemoveStreamHandler("POST", uploaderPath);
1884 
1885  if (m_dumpAssetToFile)
1886  {
1887  SaveAssetToFile("updatedtaskscript" + Util.RandomClass.Next(1, 1000) + ".dat", data);
1888  }
1889 
1890  // m_log.InfoFormat("[CAPS]: TaskInventoryScriptUpdater.uploaderCaps res: {0}", res);
1891 
1892  return res;
1893  }
1894  catch (Exception e)
1895  {
1896  m_log.Error("[CAPS]: " + e.ToString());
1897  }
1898 
1899  // XXX Maybe this should be some meaningful error packet
1900  return null;
1901  }
1902 
1904  //private void SaveAssetToFile(string filename, byte[] data)
1905  //{
1906  // FileStream fs = File.Create(filename);
1907  // BinaryWriter bw = new BinaryWriter(fs);
1908  // bw.Write(data);
1909  // bw.Close();
1910  // fs.Close();
1911  //}
1912  private static void SaveAssetToFile(string filename, byte[] data)
1913  {
1914  string assetPath = "UserAssets";
1915  if (!Directory.Exists(assetPath))
1916  {
1917  Directory.CreateDirectory(assetPath);
1918  }
1919  FileStream fs = File.Create(Path.Combine(assetPath, filename));
1920  BinaryWriter bw = new BinaryWriter(fs);
1921  bw.Write(data);
1922  bw.Close();
1923  fs.Close();
1924  }
1925  }
1926 }
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...
Definition: BunchOfCaps.cs:400
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...
TaskInventoryScriptUpdater(UUID inventoryItemID, UUID primID, int isScriptRunning, string path, IHttpServer httpServer, bool dumpAssetToFile)
OpenMetaverse.StructuredData.OSDArray OSDArray
Definition: BunchOfCaps.cs:51
string GetObjectCost(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
UUID item_id
The item containing the script to update
UUID ItemUpdated(UUID itemID, byte[] data)
Called when new asset data for an agent inventory item update has been uploaded.
Definition: BunchOfCaps.cs:478
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)
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
Definition: BunchOfCaps.cs:231
Interface to OpenSimulator's built in HTTP server. Use this to register handlers (http, llsd, xmlrpc, etc.) for given URLs.
Definition: IHttpServer.cs:36
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.
Definition: BunchOfCaps.cs:462
Asset class. All Assets are reference by this class or a class derived from this class ...
Definition: AssetBase.cs:49
OpenSim.Framework.Capabilities.Caps Caps
Definition: BunchOfCaps.cs:50
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
Definition: ICM_Api.cs:32
void RegisterRegionServiceHandlers(string capsBase)
Definition: BunchOfCaps.cs:239
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
Definition: SOPObject.cs:39
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
Definition: BunchOfCaps.cs:53
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.
Definition: BunchOfCaps.cs:712
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)
Definition: BunchOfCaps.cs:285
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.
Definition: BunchOfCaps.cs:360
OpenSim.Region.Framework.Scenes.Animation.AnimationSet AnimationSet
OpenMetaverse.StructuredData.OSDMap OSDMap
Definition: BunchOfCaps.cs:52
LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest)
Definition: BunchOfCaps.cs:493
Used to serialize a whole inventory for transfer over the network.