IOSSL_Api.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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. using System;
  28. using System.Collections;
  29. using OpenSim.Region.ScriptEngine.Interfaces;
  30. using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  31. using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
  32. using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
  33. using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
  34. using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  35. using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
  36. using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
  37. using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  38. namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
  39. {
  40. /// <summary>
  41. /// To permit region owners to enable the extended scripting functionality
  42. /// of OSSL, without allowing malicious scripts to access potentially
  43. /// troublesome functions, each OSSL function is assigned a threat level,
  44. /// and access to the functions is granted or denied based on a default
  45. /// threshold set in OpenSim.ini (which can be overridden for individual
  46. /// functions on a case-by-case basis)
  47. /// </summary>
  48. public enum ThreatLevel
  49. {
  50. // Not documented, presumably means permanently disabled ?
  51. NoAccess = -1,
  52. /// <summary>
  53. /// Function is no threat at all. It doesn't constitute a threat to
  54. /// either users or the system and has no known side effects.
  55. /// </summary>
  56. None = 0,
  57. /// <summary>
  58. /// Abuse of this command can cause a nuisance to the region operator,
  59. /// such as log message spew.
  60. /// </summary>
  61. Nuisance = 1,
  62. /// <summary>
  63. /// Extreme levels of abuse of this function can cause impaired
  64. /// functioning of the region, or very gullible users can be tricked
  65. /// into experiencing harmless effects.
  66. /// </summary>
  67. VeryLow = 2,
  68. /// <summary>
  69. /// Intentional abuse can cause crashes or malfunction under certain
  70. /// circumstances, which can be easily rectified; or certain users can
  71. /// be tricked into certain situations in an avoidable manner.
  72. /// </summary>
  73. Low = 3,
  74. /// <summary>
  75. /// Intentional abuse can cause denial of service and crashes with
  76. /// potential of data or state loss; or trusting users can be tricked
  77. /// into embarrassing or uncomfortable situations.
  78. /// </summary>
  79. Moderate = 4,
  80. /// <summary>
  81. /// Casual abuse can cause impaired functionality or temporary denial
  82. /// of service conditions. Intentional abuse can easily cause crashes
  83. /// with potential data loss, or can be used to trick experienced and
  84. /// cautious users into unwanted situations, or changes global data
  85. /// permanently and without undo ability.
  86. /// </summary>
  87. High = 5,
  88. /// <summary>
  89. /// Even normal use may, depending on the number of instances, or
  90. /// frequency of use, result in severe service impairment or crash
  91. /// with loss of data, or can be used to cause unwanted or harmful
  92. /// effects on users without giving the user a means to avoid it.
  93. /// </summary>
  94. VeryHigh = 6,
  95. /// <summary>
  96. /// Even casual use is a danger to region stability, or function allows
  97. /// console or OS command execution, or function allows taking money
  98. /// without consent, or allows deletion or modification of user data,
  99. /// or allows the compromise of sensitive data by design.
  100. /// </summary>
  101. Severe = 7
  102. };
  103. public interface IOSSL_Api
  104. {
  105. void CheckThreatLevel(ThreatLevel level, string function);
  106. //OpenSim functions
  107. string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer);
  108. string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
  109. int timer, int alpha);
  110. string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams,
  111. bool blend, int disp, int timer, int alpha, int face);
  112. string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer);
  113. string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
  114. int timer, int alpha);
  115. string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams,
  116. bool blend, int disp, int timer, int alpha, int face);
  117. LSL_Float osGetTerrainHeight(int x, int y);
  118. LSL_Float osTerrainGetHeight(int x, int y); // Deprecated
  119. LSL_Integer osSetTerrainHeight(int x, int y, double val);
  120. LSL_Integer osTerrainSetHeight(int x, int y, double val); //Deprecated
  121. void osTerrainFlush();
  122. int osRegionRestart(double seconds);
  123. void osRegionNotice(string msg);
  124. bool osConsoleCommand(string Command);
  125. void osSetParcelMediaURL(string url);
  126. void osSetPrimFloatOnWater(int floatYN);
  127. void osSetParcelSIPAddress(string SIPAddress);
  128. // Avatar Info Commands
  129. string osGetAgentIP(string agent);
  130. LSL_List osGetAgents();
  131. // Teleport commands
  132. void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
  133. void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
  134. void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
  135. void osTeleportOwner(string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
  136. void osTeleportOwner(int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
  137. void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
  138. // Animation commands
  139. void osAvatarPlayAnimation(string avatar, string animation);
  140. void osAvatarStopAnimation(string avatar, string animation);
  141. #region Attachment commands
  142. /// <summary>
  143. /// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH
  144. /// </summary>
  145. /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
  146. void osForceAttachToAvatar(int attachment);
  147. /// <summary>
  148. /// Attach an inventory item in the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH
  149. /// </summary>
  150. /// <remarks>
  151. /// Nothing happens if the owner is not in the region.
  152. /// </remarks>
  153. /// <param name='itemName'>Tha name of the item. If this is not found then a warning is said to the owner</param>
  154. /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
  155. void osForceAttachToAvatarFromInventory(string itemName, int attachment);
  156. /// <summary>
  157. /// Attach an inventory item in the object containing this script to any avatar in the region without asking for PERMISSION_ATTACH
  158. /// </summary>
  159. /// <remarks>
  160. /// Nothing happens if the avatar is not in the region.
  161. /// </remarks>
  162. /// <param name='rawAvatarId'>The UUID of the avatar to which to attach. Nothing happens if this is not a UUID</para>
  163. /// <param name='itemName'>The name of the item. If this is not found then a warning is said to the owner</param>
  164. /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
  165. void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint);
  166. /// <summary>
  167. /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH
  168. /// </summary>
  169. /// <remarks>Nothing happens if the object is not attached.</remarks>
  170. void osForceDetachFromAvatar();
  171. /// <summary>
  172. /// Returns a strided list of the specified attachment points and the number of attachments on those points.
  173. /// </summary>
  174. /// <param name="avatar">avatar UUID</param>
  175. /// <param name="attachmentPoints">list of ATTACH_* constants</param>
  176. /// <returns></returns>
  177. LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints);
  178. /// <summary>
  179. /// Sends a specified message to the specified avatar's attachments on
  180. /// the specified attachment points.
  181. /// </summary>
  182. /// <remarks>
  183. /// Behaves as osMessageObject(), without the sending script needing to know the attachment keys in advance.
  184. /// </remarks>
  185. /// <param name="avatar">avatar UUID</param>
  186. /// <param name="message">message string</param>
  187. /// <param name="attachmentPoints">list of ATTACH_* constants, or -1 for all attachments. If -1 is specified and OS_ATTACH_MSG_INVERT_POINTS is present in flags, no action is taken.</param>
  188. /// <param name="flags">flags further constraining the attachments to deliver the message to.</param>
  189. void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags);
  190. #endregion
  191. //texture draw functions
  192. string osMovePen(string drawList, int x, int y);
  193. string osDrawLine(string drawList, int startX, int startY, int endX, int endY);
  194. string osDrawLine(string drawList, int endX, int endY);
  195. string osDrawText(string drawList, string text);
  196. string osDrawEllipse(string drawList, int width, int height);
  197. string osDrawRectangle(string drawList, int width, int height);
  198. string osDrawFilledRectangle(string drawList, int width, int height);
  199. string osDrawPolygon(string drawList, LSL_List x, LSL_List y);
  200. string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y);
  201. string osSetFontName(string drawList, string fontName);
  202. string osSetFontSize(string drawList, int fontSize);
  203. string osSetPenSize(string drawList, int penSize);
  204. string osSetPenColor(string drawList, string color);
  205. string osSetPenColour(string drawList, string colour); // Deprecated
  206. string osSetPenCap(string drawList, string direction, string type);
  207. string osDrawImage(string drawList, int width, int height, string imageUrl);
  208. vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize);
  209. void osSetStateEvents(int events);
  210. double osList2Double(LSL_Types.list src, int index);
  211. void osSetRegionWaterHeight(double height);
  212. void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour);
  213. void osSetEstateSunSettings(bool sunFixed, double sunHour);
  214. double osGetCurrentSunHour();
  215. double osGetSunParam(string param);
  216. double osSunGetParam(string param); // Deprecated
  217. void osSetSunParam(string param, double value);
  218. void osSunSetParam(string param, double value); // Deprecated
  219. // Wind Module Functions
  220. string osWindActiveModelPluginName();
  221. void osSetWindParam(string plugin, string param, LSL_Float value);
  222. LSL_Float osGetWindParam(string plugin, string param);
  223. // Parcel commands
  224. void osParcelJoin(vector pos1, vector pos2);
  225. void osParcelSubdivide(vector pos1, vector pos2);
  226. void osSetParcelDetails(vector pos, LSL_List rules);
  227. void osParcelSetDetails(vector pos, LSL_List rules); // Deprecated
  228. string osGetScriptEngineName();
  229. string osGetSimulatorVersion();
  230. string osGetPhysicsEngineType();
  231. Object osParseJSONNew(string JSON);
  232. Hashtable osParseJSON(string JSON);
  233. void osMessageObject(key objectUUID,string message);
  234. void osMakeNotecard(string notecardName, LSL_Types.list contents);
  235. string osGetNotecardLine(string name, int line);
  236. string osGetNotecard(string name);
  237. int osGetNumberOfNotecardLines(string name);
  238. string osAvatarName2Key(string firstname, string lastname);
  239. string osKey2Name(string id);
  240. // Grid Info Functions
  241. string osGetGridNick();
  242. string osGetGridName();
  243. string osGetGridLoginURI();
  244. string osGetGridHomeURI();
  245. string osGetGridGatekeeperURI();
  246. string osGetGridCustom(string key);
  247. LSL_String osFormatString(string str, LSL_List strings);
  248. LSL_List osMatchString(string src, string pattern, int start);
  249. LSL_String osReplaceString(string src, string pattern, string replace, int count, int start);
  250. // Information about data loaded into the region
  251. string osLoadedCreationDate();
  252. string osLoadedCreationTime();
  253. string osLoadedCreationID();
  254. LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules);
  255. /// <summary>
  256. /// Identical to llCreateLink() but does not require permission from the owner.
  257. /// </summary>
  258. /// <param name='target'></param>
  259. /// <param name='parent'></param>
  260. void osForceCreateLink(string target, int parent);
  261. /// <summary>
  262. /// Identical to llBreakLink() but does not require permission from the owner.
  263. /// </summary>
  264. /// <param name='linknum'></param>
  265. void osForceBreakLink(int linknum);
  266. /// <summary>
  267. /// Identical to llBreakAllLinks() but does not require permission from the owner.
  268. /// </summary>
  269. void osForceBreakAllLinks();
  270. /// <summary>
  271. /// Check if the given key is an npc
  272. /// </summary>
  273. /// <param name="npc"></param>
  274. /// <returns>TRUE if the key belongs to an npc in the scene. FALSE otherwise.</returns>
  275. LSL_Integer osIsNpc(LSL_Key npc);
  276. key osNpcCreate(string user, string name, vector position, string notecard);
  277. key osNpcCreate(string user, string name, vector position, string notecard, int options);
  278. LSL_Key osNpcSaveAppearance(key npc, string notecard);
  279. void osNpcLoadAppearance(key npc, string notecard);
  280. vector osNpcGetPos(key npc);
  281. void osNpcMoveTo(key npc, vector position);
  282. void osNpcMoveToTarget(key npc, vector target, int options);
  283. /// <summary>
  284. /// Get the owner of the NPC
  285. /// </summary>
  286. /// <param name="npc"></param>
  287. /// <returns>
  288. /// The owner of the NPC for an owned NPC. The NPC's agent id for an unowned NPC. UUID.Zero if the key is not an npc.
  289. /// </returns>
  290. LSL_Key osNpcGetOwner(key npc);
  291. rotation osNpcGetRot(key npc);
  292. void osNpcSetRot(LSL_Key npc, rotation rot);
  293. void osNpcStopMoveToTarget(LSL_Key npc);
  294. void osNpcSay(key npc, string message);
  295. void osNpcSay(key npc, int channel, string message);
  296. void osNpcShout(key npc, int channel, string message);
  297. void osNpcSit(key npc, key target, int options);
  298. void osNpcStand(LSL_Key npc);
  299. void osNpcRemove(key npc);
  300. void osNpcPlayAnimation(LSL_Key npc, string animation);
  301. void osNpcStopAnimation(LSL_Key npc, string animation);
  302. void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num);
  303. void osNpcWhisper(key npc, int channel, string message);
  304. LSL_Key osOwnerSaveAppearance(string notecard);
  305. LSL_Key osAgentSaveAppearance(key agentId, string notecard);
  306. key osGetMapTexture();
  307. key osGetRegionMapTexture(string regionName);
  308. LSL_List osGetRegionStats();
  309. vector osGetRegionSize();
  310. int osGetSimulatorMemory();
  311. void osKickAvatar(string FirstName,string SurName,string alert);
  312. void osSetSpeed(string UUID, LSL_Float SpeedModifier);
  313. LSL_Float osGetHealth(string avatar);
  314. void osCauseHealing(string avatar, double healing);
  315. void osCauseDamage(string avatar, double damage);
  316. void osForceOtherSit(string avatar);
  317. void osForceOtherSit(string avatar, string target);
  318. LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules);
  319. void osSetPrimitiveParams(LSL_Key prim, LSL_List rules);
  320. void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb);
  321. void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb);
  322. LSL_List osGetAvatarList();
  323. LSL_String osUnixTimeToTimestamp(long time);
  324. LSL_String osGetInventoryDesc(string item);
  325. LSL_Integer osInviteToGroup(LSL_Key agentId);
  326. LSL_Integer osEjectFromGroup(LSL_Key agentId);
  327. void osSetTerrainTexture(int level, LSL_Key texture);
  328. void osSetTerrainTextureHeight(int corner, double low, double high);
  329. /// <summary>
  330. /// Checks if thing is a UUID.
  331. /// </summary>
  332. /// <param name="thing"></param>
  333. /// <returns>1 if thing is a valid UUID, 0 otherwise</returns>
  334. LSL_Integer osIsUUID(string thing);
  335. /// <summary>
  336. /// Wraps to Math.Min()
  337. /// </summary>
  338. /// <param name="a"></param>
  339. /// <param name="b"></param>
  340. /// <returns></returns>
  341. LSL_Float osMin(double a, double b);
  342. /// <summary>
  343. /// Wraps to Math.max()
  344. /// </summary>
  345. /// <param name="a"></param>
  346. /// <param name="b"></param>
  347. /// <returns></returns>
  348. LSL_Float osMax(double a, double b);
  349. /// <summary>
  350. /// Get the key of the object that rezzed this object.
  351. /// </summary>
  352. /// <returns>Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.</returns>
  353. LSL_Key osGetRezzingObject();
  354. /// <summary>
  355. /// Sets the response type for an HTTP request/response
  356. /// </summary>
  357. /// <returns></returns>
  358. void osSetContentType(LSL_Key id, string type);
  359. /// <summary>
  360. /// Attempts to drop an attachment to the ground
  361. /// </summary>
  362. void osDropAttachment();
  363. /// <summary>
  364. /// Attempts to drop an attachment to the ground while bypassing the script permissions
  365. /// </summary>
  366. void osForceDropAttachment();
  367. /// <summary>
  368. /// Attempts to drop an attachment at the specified coordinates.
  369. /// </summary>
  370. /// <param name="pos"></param>
  371. /// <param name="rot"></param>
  372. void osDropAttachmentAt(vector pos, rotation rot);
  373. /// <summary>
  374. /// Attempts to drop an attachment at the specified coordinates while bypassing the script permissions
  375. /// </summary>
  376. /// <param name="pos"></param>
  377. /// <param name="rot"></param>
  378. void osForceDropAttachmentAt(vector pos, rotation rot);
  379. /// <summary>
  380. /// Identical to llListen except for a bitfield which indicates which
  381. /// string parameters should be parsed as regex patterns.
  382. /// </summary>
  383. /// <param name="channelID"></param>
  384. /// <param name="name"></param>
  385. /// <param name="ID"></param>
  386. /// <param name="msg"></param>
  387. /// <param name="regexBitfield">
  388. /// OS_LISTEN_REGEX_NAME
  389. /// OS_LISTEN_REGEX_MESSAGE
  390. /// </param>
  391. /// <returns></returns>
  392. LSL_Integer osListenRegex(int channelID, string name, string ID,
  393. string msg, int regexBitfield);
  394. /// <summary>
  395. /// Wraps to bool Regex.IsMatch(string input, string pattern)
  396. /// </summary>
  397. /// <param name="input">string to test for match</param>
  398. /// <param name="regex">string to use as pattern</param>
  399. /// <returns>boolean</returns>
  400. LSL_Integer osRegexIsMatch(string input, string pattern);
  401. }
  402. }