IOSSL_Api.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. /// Check if the given key is an npc
  257. /// </summary>
  258. /// <param name="npc"></param>
  259. /// <returns>TRUE if the key belongs to an npc in the scene. FALSE otherwise.</returns>
  260. LSL_Integer osIsNpc(LSL_Key npc);
  261. key osNpcCreate(string user, string name, vector position, string notecard);
  262. key osNpcCreate(string user, string name, vector position, string notecard, int options);
  263. LSL_Key osNpcSaveAppearance(key npc, string notecard);
  264. void osNpcLoadAppearance(key npc, string notecard);
  265. vector osNpcGetPos(key npc);
  266. void osNpcMoveTo(key npc, vector position);
  267. void osNpcMoveToTarget(key npc, vector target, int options);
  268. /// <summary>
  269. /// Get the owner of the NPC
  270. /// </summary>
  271. /// <param name="npc"></param>
  272. /// <returns>
  273. /// 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.
  274. /// </returns>
  275. LSL_Key osNpcGetOwner(key npc);
  276. rotation osNpcGetRot(key npc);
  277. void osNpcSetRot(LSL_Key npc, rotation rot);
  278. void osNpcStopMoveToTarget(LSL_Key npc);
  279. void osNpcSay(key npc, string message);
  280. void osNpcSay(key npc, int channel, string message);
  281. void osNpcShout(key npc, int channel, string message);
  282. void osNpcSit(key npc, key target, int options);
  283. void osNpcStand(LSL_Key npc);
  284. void osNpcRemove(key npc);
  285. void osNpcPlayAnimation(LSL_Key npc, string animation);
  286. void osNpcStopAnimation(LSL_Key npc, string animation);
  287. void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num);
  288. void osNpcWhisper(key npc, int channel, string message);
  289. LSL_Key osOwnerSaveAppearance(string notecard);
  290. LSL_Key osAgentSaveAppearance(key agentId, string notecard);
  291. key osGetMapTexture();
  292. key osGetRegionMapTexture(string regionName);
  293. LSL_List osGetRegionStats();
  294. int osGetSimulatorMemory();
  295. void osKickAvatar(string FirstName,string SurName,string alert);
  296. void osSetSpeed(string UUID, LSL_Float SpeedModifier);
  297. LSL_Float osGetHealth(string avatar);
  298. void osCauseHealing(string avatar, double healing);
  299. void osCauseDamage(string avatar, double damage);
  300. LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules);
  301. void osSetPrimitiveParams(LSL_Key prim, LSL_List rules);
  302. void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb);
  303. void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb);
  304. LSL_List osGetAvatarList();
  305. LSL_String osUnixTimeToTimestamp(long time);
  306. LSL_String osGetInventoryDesc(string item);
  307. LSL_Integer osInviteToGroup(LSL_Key agentId);
  308. LSL_Integer osEjectFromGroup(LSL_Key agentId);
  309. void osSetTerrainTexture(int level, LSL_Key texture);
  310. void osSetTerrainTextureHeight(int corner, double low, double high);
  311. /// <summary>
  312. /// Checks if thing is a UUID.
  313. /// </summary>
  314. /// <param name="thing"></param>
  315. /// <returns>1 if thing is a valid UUID, 0 otherwise</returns>
  316. LSL_Integer osIsUUID(string thing);
  317. /// <summary>
  318. /// Wraps to Math.Min()
  319. /// </summary>
  320. /// <param name="a"></param>
  321. /// <param name="b"></param>
  322. /// <returns></returns>
  323. LSL_Float osMin(double a, double b);
  324. /// <summary>
  325. /// Wraps to Math.max()
  326. /// </summary>
  327. /// <param name="a"></param>
  328. /// <param name="b"></param>
  329. /// <returns></returns>
  330. LSL_Float osMax(double a, double b);
  331. /// <summary>
  332. /// Get the key of the object that rezzed this object.
  333. /// </summary>
  334. /// <returns>Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.</returns>
  335. LSL_Key osGetRezzingObject();
  336. /// <summary>
  337. /// Sets the response type for an HTTP request/response
  338. /// </summary>
  339. /// <returns></returns>
  340. void osSetContentType(LSL_Key id, string type);
  341. /// <summary>
  342. /// Attempts to drop an attachment to the ground
  343. /// </summary>
  344. void osDropAttachment();
  345. /// <summary>
  346. /// Attempts to drop an attachment to the ground while bypassing the script permissions
  347. /// </summary>
  348. void osForceDropAttachment();
  349. /// <summary>
  350. /// Attempts to drop an attachment at the specified coordinates.
  351. /// </summary>
  352. /// <param name="pos"></param>
  353. /// <param name="rot"></param>
  354. void osDropAttachmentAt(vector pos, rotation rot);
  355. /// <summary>
  356. /// Attempts to drop an attachment at the specified coordinates while bypassing the script permissions
  357. /// </summary>
  358. /// <param name="pos"></param>
  359. /// <param name="rot"></param>
  360. void osForceDropAttachmentAt(vector pos, rotation rot);
  361. /// <summary>
  362. /// Identical to llListen except for a bitfield which indicates which
  363. /// string parameters should be parsed as regex patterns.
  364. /// </summary>
  365. /// <param name="channelID"></param>
  366. /// <param name="name"></param>
  367. /// <param name="ID"></param>
  368. /// <param name="msg"></param>
  369. /// <param name="regexBitfield">
  370. /// OS_LISTEN_REGEX_NAME
  371. /// OS_LISTEN_REGEX_MESSAGE
  372. /// </param>
  373. /// <returns></returns>
  374. LSL_Integer osListenRegex(int channelID, string name, string ID,
  375. string msg, int regexBitfield);
  376. /// <summary>
  377. /// Wraps to bool Regex.IsMatch(string input, string pattern)
  378. /// </summary>
  379. /// <param name="input">string to test for match</param>
  380. /// <param name="regex">string to use as pattern</param>
  381. /// <returns>boolean</returns>
  382. LSL_Integer osRegexIsMatch(string input, string pattern);
  383. }
  384. }