diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 5b7a79d..48b4a9f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |||
@@ -39,6 +39,7 @@ using OpenMetaverse.StructuredData; | |||
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Scenes.Scripting; | ||
42 | using System.Collections.Generic; | 43 | using System.Collections.Generic; |
43 | using System.Text.RegularExpressions; | 44 | using System.Text.RegularExpressions; |
44 | 45 | ||
@@ -168,6 +169,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
168 | m_comms.RegisterScriptInvocations(this); | 169 | m_comms.RegisterScriptInvocations(this); |
169 | 170 | ||
170 | // m_comms.RegisterScriptInvocation(this, "JsonCreateStore"); | 171 | // m_comms.RegisterScriptInvocation(this, "JsonCreateStore"); |
172 | // m_comms.RegisterScriptInvocation(this, "JsonAttachObjectStore"); | ||
171 | // m_comms.RegisterScriptInvocation(this, "JsonDestroyStore"); | 173 | // m_comms.RegisterScriptInvocation(this, "JsonDestroyStore"); |
172 | // m_comms.RegisterScriptInvocation(this, "JsonTestStore"); | 174 | // m_comms.RegisterScriptInvocation(this, "JsonTestStore"); |
173 | 175 | ||
@@ -219,6 +221,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
219 | /// </summary> | 221 | /// </summary> |
220 | // ----------------------------------------------------------------- | 222 | // ----------------------------------------------------------------- |
221 | [ScriptInvocation] | 223 | [ScriptInvocation] |
224 | public UUID JsonAttachObjectStore(UUID hostID, UUID scriptID) | ||
225 | { | ||
226 | UUID uuid = UUID.Zero; | ||
227 | if (! m_store.AttachObjectStore(hostID)) | ||
228 | GenerateRuntimeError("Failed to create Json store"); | ||
229 | |||
230 | return hostID; | ||
231 | } | ||
232 | |||
233 | // ----------------------------------------------------------------- | ||
234 | /// <summary> | ||
235 | /// | ||
236 | /// </summary> | ||
237 | // ----------------------------------------------------------------- | ||
238 | [ScriptInvocation] | ||
222 | public UUID JsonCreateStore(UUID hostID, UUID scriptID, string value) | 239 | public UUID JsonCreateStore(UUID hostID, UUID scriptID, string value) |
223 | { | 240 | { |
224 | UUID uuid = UUID.Zero; | 241 | UUID uuid = UUID.Zero; |
@@ -256,10 +273,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
256 | /// </summary> | 273 | /// </summary> |
257 | // ----------------------------------------------------------------- | 274 | // ----------------------------------------------------------------- |
258 | [ScriptInvocation] | 275 | [ScriptInvocation] |
259 | public UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID) | 276 | public UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, string notecardIdentifier) |
260 | { | 277 | { |
261 | UUID reqID = UUID.Random(); | 278 | UUID reqID = UUID.Random(); |
262 | Util.FireAndForget(delegate(object o) { DoJsonReadNotecard(reqID,hostID,scriptID,storeID,path,assetID); }); | 279 | Util.FireAndForget(o => DoJsonReadNotecard(reqID, hostID, scriptID, storeID, path, notecardIdentifier)); |
263 | return reqID; | 280 | return reqID; |
264 | } | 281 | } |
265 | 282 | ||
@@ -463,14 +480,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
463 | /// | 480 | /// |
464 | /// </summary> | 481 | /// </summary> |
465 | // ----------------------------------------------------------------- | 482 | // ----------------------------------------------------------------- |
466 | private void DoJsonReadNotecard(UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID) | 483 | private void DoJsonReadNotecard( |
484 | UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, string notecardIdentifier) | ||
467 | { | 485 | { |
486 | UUID assetID; | ||
487 | |||
488 | if (!UUID.TryParse(notecardIdentifier, out assetID)) | ||
489 | { | ||
490 | SceneObjectPart part = m_scene.GetSceneObjectPart(hostID); | ||
491 | assetID = ScriptUtils.GetAssetIdFromItemName(part, notecardIdentifier, (int)AssetType.Notecard); | ||
492 | } | ||
493 | |||
468 | AssetBase a = m_scene.AssetService.Get(assetID.ToString()); | 494 | AssetBase a = m_scene.AssetService.Get(assetID.ToString()); |
469 | if (a == null) | 495 | if (a == null) |
470 | GenerateRuntimeError(String.Format("Unable to find notecard asset {0}",assetID)); | 496 | GenerateRuntimeError(String.Format("Unable to find notecard asset {0}", assetID)); |
471 | 497 | ||
472 | if (a.Type != (sbyte)AssetType.Notecard) | 498 | if (a.Type != (sbyte)AssetType.Notecard) |
473 | GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID)); | 499 | GenerateRuntimeError(String.Format("Invalid notecard asset {0}", assetID)); |
474 | 500 | ||
475 | m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID); | 501 | m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID); |
476 | 502 | ||
@@ -483,11 +509,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
483 | } | 509 | } |
484 | catch (Exception e) | 510 | catch (Exception e) |
485 | { | 511 | { |
486 | m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}",e.Message); | 512 | m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}", e.Message); |
487 | } | 513 | } |
488 | 514 | ||
489 | GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString())); | 515 | GenerateRuntimeError(String.Format("Json parsing failed for {0}", assetID)); |
490 | m_comms.DispatchReply(scriptID,0,"",reqID.ToString()); | 516 | m_comms.DispatchReply(scriptID, 0, "", reqID.ToString()); |
491 | } | 517 | } |
492 | 518 | ||
493 | // ----------------------------------------------------------------- | 519 | // ----------------------------------------------------------------- |