aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorMike Mazur2009-02-04 00:01:36 +0000
committerMike Mazur2009-02-04 00:01:36 +0000
commit0c03a48fb2060eda4d288e2d2ca4e650ce000b4b (patch)
treea90465075960c92367b0a5e62db3121e4e3a139d /OpenSim/Region/ScriptEngine/Shared
parent* Add another object to the existing save oar test (diff)
downloadopensim-SC_OLD-0c03a48fb2060eda4d288e2d2ca4e650ce000b4b.zip
opensim-SC_OLD-0c03a48fb2060eda4d288e2d2ca4e650ce000b4b.tar.gz
opensim-SC_OLD-0c03a48fb2060eda4d288e2d2ca4e650ce000b4b.tar.bz2
opensim-SC_OLD-0c03a48fb2060eda4d288e2d2ca4e650ce000b4b.tar.xz
- add OpenSim.Framework.AssetMetadata class. AssetBase is now composed of it
- trim trailing whitespace
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs124
1 files changed, 62 insertions, 62 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 3e7ffab..734b3ef 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -37,8 +37,8 @@ using OpenSim.Framework;
37using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
38using OpenSim.Region.Environment.Interfaces; 38using OpenSim.Region.Environment.Interfaces;
39using OpenSim.Region.Environment.Scenes; 39using OpenSim.Region.Environment.Scenes;
40using OpenSim.Region.ScriptEngine.Shared; 40using OpenSim.Region.ScriptEngine.Shared;
41using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; 41using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
42using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 42using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
43using OpenSim.Region.ScriptEngine.Interfaces; 43using OpenSim.Region.ScriptEngine.Interfaces;
44using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; 44using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
@@ -117,7 +117,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
117 m_host = host; 117 m_host = host;
118 m_localID = localID; 118 m_localID = localID;
119 m_itemID = itemID; 119 m_itemID = itemID;
120 120
121 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 121 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
122 m_OSFunctionsEnabled = true; 122 m_OSFunctionsEnabled = true;
123 123
@@ -328,9 +328,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
328 CheckThreatLevel(ThreatLevel.VeryHigh, "osRegionNotice"); 328 CheckThreatLevel(ThreatLevel.VeryHigh, "osRegionNotice");
329 329
330 m_host.AddScriptLPS(1); 330 m_host.AddScriptLPS(1);
331 331
332 IDialogModule dm = World.RequestModuleInterface<IDialogModule>(); 332 IDialogModule dm = World.RequestModuleInterface<IDialogModule>();
333 333
334 if (dm != null) 334 if (dm != null)
335 dm.SendGeneralAlert(msg); 335 dm.SendGeneralAlert(msg);
336 } 336 }
@@ -776,7 +776,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
776 return String.Empty; 776 return String.Empty;
777 } 777 }
778 } 778 }
779 779
780 public string osGetSimulatorVersion() 780 public string osGetSimulatorVersion()
781 { 781 {
782 // High because it can be used to target attacks to known weaknesses 782 // High because it can be used to target attacks to known weaknesses
@@ -802,37 +802,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
802 802
803 World.ParcelMediaSetTime((float)time); 803 World.ParcelMediaSetTime((float)time);
804 } 804 }
805 805
806 public Hashtable osParseJSON(string JSON) 806 public Hashtable osParseJSON(string JSON)
807 { 807 {
808 CheckThreatLevel(ThreatLevel.None, "osParseJSON"); 808 CheckThreatLevel(ThreatLevel.None, "osParseJSON");
809 809
810 m_host.AddScriptLPS(1); 810 m_host.AddScriptLPS(1);
811 811
812 // see http://www.json.org/ for more details on JSON 812 // see http://www.json.org/ for more details on JSON
813 813
814 string currentKey=null; 814 string currentKey=null;
815 Stack objectStack = new Stack(); // objects in JSON can be nested so we need to keep a track of this 815 Stack objectStack = new Stack(); // objects in JSON can be nested so we need to keep a track of this
816 Hashtable jsondata = new Hashtable(); // the hashtable to be returned 816 Hashtable jsondata = new Hashtable(); // the hashtable to be returned
817 int i=0; 817 int i=0;
818 try 818 try
819 { 819 {
820 820
821 // iterate through the serialised stream of tokens and store at the right depth in the hashtable 821 // iterate through the serialised stream of tokens and store at the right depth in the hashtable
822 // the top level hashtable may contain more nested hashtables within it each containing an objects representation 822 // the top level hashtable may contain more nested hashtables within it each containing an objects representation
823 for (i=0;i<JSON.Length; i++) 823 for (i=0;i<JSON.Length; i++)
824 { 824 {
825 825
826 // Console.WriteLine(""+JSON[i]); 826 // Console.WriteLine(""+JSON[i]);
827 switch (JSON[i]) 827 switch (JSON[i])
828 { 828 {
829 case '{': 829 case '{':
830 // create hashtable and add it to the stack or array if we are populating one, we can have a lot of nested objects in JSON 830 // create hashtable and add it to the stack or array if we are populating one, we can have a lot of nested objects in JSON
831 831
832 Hashtable currentObject = new Hashtable(); 832 Hashtable currentObject = new Hashtable();
833 if (objectStack.Count==0) // the stack should only be empty for the first outer object 833 if (objectStack.Count==0) // the stack should only be empty for the first outer object
834 { 834 {
835 835
836 objectStack.Push(jsondata); 836 objectStack.Push(jsondata);
837 } 837 }
838 else if (objectStack.Peek().ToString()=="System.Collections.ArrayList") 838 else if (objectStack.Peek().ToString()=="System.Collections.ArrayList")
@@ -842,12 +842,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
842 objectStack.Push(currentObject); 842 objectStack.Push(currentObject);
843 } 843 }
844 else 844 else
845 { 845 {
846 // add it to the parent hashtable 846 // add it to the parent hashtable
847 ((Hashtable)objectStack.Peek()).Add(currentKey,currentObject); 847 ((Hashtable)objectStack.Peek()).Add(currentKey,currentObject);
848 objectStack.Push(currentObject); 848 objectStack.Push(currentObject);
849 } 849 }
850 850
851 // clear the key 851 // clear the key
852 currentKey=null; 852 currentKey=null;
853 break; 853 break;
@@ -856,25 +856,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
856 objectStack.Pop(); 856 objectStack.Pop();
857 break; 857 break;
858 case '"':// string boundary 858 case '"':// string boundary
859 859
860 string tokenValue=""; 860 string tokenValue="";
861 i++; // move to next char 861 i++; // move to next char
862 862
863 // just loop through until the next quote mark storing the string, ignore quotes with pre-ceding \ 863 // just loop through until the next quote mark storing the string, ignore quotes with pre-ceding \
864 while (JSON[i]!='"') 864 while (JSON[i]!='"')
865 { 865 {
866 tokenValue+=JSON[i]; 866 tokenValue+=JSON[i];
867 867
868 // handle escaped double quotes \" 868 // handle escaped double quotes \"
869 if (JSON[i]=='\\' && JSON[i+1]=='"') 869 if (JSON[i]=='\\' && JSON[i+1]=='"')
870 { 870 {
871 tokenValue+=JSON[i+1]; 871 tokenValue+=JSON[i+1];
872 i++; 872 i++;
873 } 873 }
874 i++; 874 i++;
875 875
876 } 876 }
877 877
878 // ok we've got a string, if we've got an array on the top of the stack then we store it 878 // ok we've got a string, if we've got an array on the top of the stack then we store it
879 if (objectStack.Peek().ToString()=="System.Collections.ArrayList") 879 if (objectStack.Peek().ToString()=="System.Collections.ArrayList")
880 { 880 {
@@ -884,14 +884,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
884 { 884 {
885 currentKey = tokenValue; 885 currentKey = tokenValue;
886 } 886 }
887 else 887 else
888 { 888 {
889 // we have a key so lets store this value 889 // we have a key so lets store this value
890 ((Hashtable)objectStack.Peek()).Add(currentKey,tokenValue); 890 ((Hashtable)objectStack.Peek()).Add(currentKey,tokenValue);
891 // now lets clear the key, we're done with it and moving on 891 // now lets clear the key, we're done with it and moving on
892 currentKey=null; 892 currentKey=null;
893 } 893 }
894 894
895 break; 895 break;
896 case ':':// key : value separator 896 case ':':// key : value separator
897 // just ignore 897 // just ignore
@@ -900,20 +900,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
900 // just ignore 900 // just ignore
901 break; 901 break;
902 case '[': // array start 902 case '[': // array start
903 ArrayList currentArray = new ArrayList(); 903 ArrayList currentArray = new ArrayList();
904 904
905 if (objectStack.Peek().ToString()=="System.Collections.ArrayList") 905 if (objectStack.Peek().ToString()=="System.Collections.ArrayList")
906 { 906 {
907 ((ArrayList)objectStack.Peek()).Add(currentArray); 907 ((ArrayList)objectStack.Peek()).Add(currentArray);
908 } 908 }
909 else 909 else
910 { 910 {
911 ((Hashtable)objectStack.Peek()).Add(currentKey,currentArray); 911 ((Hashtable)objectStack.Peek()).Add(currentKey,currentArray);
912 // clear the key 912 // clear the key
913 currentKey=null; 913 currentKey=null;
914 } 914 }
915 objectStack.Push(currentArray); 915 objectStack.Push(currentArray);
916 916
917 break; 917 break;
918 case ',':// seperator 918 case ',':// seperator
919 // just ignore 919 // just ignore
@@ -923,24 +923,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
923 objectStack.Pop(); 923 objectStack.Pop();
924 break; 924 break;
925 case 't': // we've found a character start not in quotes, it must be a boolean true 925 case 't': // we've found a character start not in quotes, it must be a boolean true
926 926
927 if (objectStack.Peek().ToString()=="System.Collections.ArrayList") 927 if (objectStack.Peek().ToString()=="System.Collections.ArrayList")
928 { 928 {
929 ((ArrayList)objectStack.Peek()).Add(true); 929 ((ArrayList)objectStack.Peek()).Add(true);
930 } 930 }
931 else 931 else
932 { 932 {
933 ((Hashtable)objectStack.Peek()).Add(currentKey,true); 933 ((Hashtable)objectStack.Peek()).Add(currentKey,true);
934 currentKey=null; 934 currentKey=null;
935 } 935 }
936 936
937 //advance the counter to the letter 'e' 937 //advance the counter to the letter 'e'
938 i = i+3; 938 i = i+3;
939 break; 939 break;
940 case 'f': // we've found a character start not in quotes, it must be a boolean false 940 case 'f': // we've found a character start not in quotes, it must be a boolean false
941 941
942 if (objectStack.Peek().ToString()=="System.Collections.ArrayList") 942 if (objectStack.Peek().ToString()=="System.Collections.ArrayList")
943 { 943 {
944 ((ArrayList)objectStack.Peek()).Add(false); 944 ((ArrayList)objectStack.Peek()).Add(false);
945 } 945 }
946 else 946 else
@@ -960,53 +960,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
960 default: 960 default:
961 // ok here we're catching all numeric types int,double,long we might want to spit these up mr accurately 961 // ok here we're catching all numeric types int,double,long we might want to spit these up mr accurately
962 // but for now we'll just do them as strings 962 // but for now we'll just do them as strings
963 963
964 string numberValue=""; 964 string numberValue="";
965 965
966 // just loop through until the next known marker quote mark storing the string 966 // just loop through until the next known marker quote mark storing the string
967 while (JSON[i] != '"' && JSON[i] != ',' && JSON[i] != ']' && JSON[i] != '}' && JSON[i] != ' ') 967 while (JSON[i] != '"' && JSON[i] != ',' && JSON[i] != ']' && JSON[i] != '}' && JSON[i] != ' ')
968 { 968 {
969 numberValue+=""+JSON[i++]; 969 numberValue+=""+JSON[i++];
970 } 970 }
971 971
972 i--; // we want to process this caracter that marked the end of this string in the main loop 972 i--; // we want to process this caracter that marked the end of this string in the main loop
973 973
974 // ok we've got a string, if we've got an array on the top of the stack then we store it 974 // ok we've got a string, if we've got an array on the top of the stack then we store it
975 if (objectStack.Peek().ToString()=="System.Collections.ArrayList") 975 if (objectStack.Peek().ToString()=="System.Collections.ArrayList")
976 { 976 {
977 ((ArrayList)objectStack.Peek()).Add(numberValue); 977 ((ArrayList)objectStack.Peek()).Add(numberValue);
978 } 978 }
979 else 979 else
980 { 980 {
981 // we have a key so lets store this value 981 // we have a key so lets store this value
982 ((Hashtable)objectStack.Peek()).Add(currentKey,numberValue); 982 ((Hashtable)objectStack.Peek()).Add(currentKey,numberValue);
983 // now lets clear the key, we're done with it and moving on 983 // now lets clear the key, we're done with it and moving on
984 currentKey=null; 984 currentKey=null;
985 } 985 }
986 986
987 break; 987 break;
988 } 988 }
989 } 989 }
990 } 990 }
991 catch(Exception) 991 catch(Exception)
992 { 992 {
993 OSSLError("osParseJSON: The JSON string is not valid " + JSON) ; 993 OSSLError("osParseJSON: The JSON string is not valid " + JSON) ;
994 } 994 }
995 995
996 return jsondata; 996 return jsondata;
997 } 997 }
998 998
999 // send a message to to object identified by the given UUID, a script in the object must implement the dataserver function 999 // send a message to to object identified by the given UUID, a script in the object must implement the dataserver function
1000 // the dataserver function is passed the ID of the calling function and a string message 1000 // the dataserver function is passed the ID of the calling function and a string message
1001 public void osMessageObject(LSL_Key objectUUID, string message) 1001 public void osMessageObject(LSL_Key objectUUID, string message)
1002 { 1002 {
1003 CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); 1003 CheckThreatLevel(ThreatLevel.Low, "osMessageObject");
1004 m_host.AddScriptLPS(1); 1004 m_host.AddScriptLPS(1);
1005 1005
1006 object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) }; 1006 object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) };
1007 1007
1008 SceneObjectPart sceneOP = World.GetSceneObjectPart(new UUID(objectUUID)); 1008 SceneObjectPart sceneOP = World.GetSceneObjectPart(new UUID(objectUUID));
1009 1009
1010 m_ScriptEngine.PostObjectEvent( 1010 m_ScriptEngine.PostObjectEvent(
1011 sceneOP.LocalId, new EventParams( 1011 sceneOP.LocalId, new EventParams(
1012 "dataserver", resobj, new DetectParams[0])); 1012 "dataserver", resobj, new DetectParams[0]));
@@ -1024,10 +1024,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1024 1024
1025 // Create new asset 1025 // Create new asset
1026 AssetBase asset = new AssetBase(); 1026 AssetBase asset = new AssetBase();
1027 asset.Name = notecardName; 1027 asset.Metadata.Name = notecardName;
1028 asset.Description = "Script Generated Notecard"; 1028 asset.Metadata.Description = "Script Generated Notecard";
1029 asset.Type = 7; 1029 asset.Metadata.Type = 7;
1030 asset.FullID = UUID.Random(); 1030 asset.Metadata.FullID = UUID.Random();
1031 string notecardData = ""; 1031 string notecardData = "";
1032 1032
1033 for (int i = 0; i < contents.Length; i++) { 1033 for (int i = 0; i < contents.Length; i++) {
@@ -1035,7 +1035,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1035 } 1035 }
1036 1036
1037 int textLength = notecardData.Length; 1037 int textLength = notecardData.Length;
1038 notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " 1038 notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length "
1039 + textLength.ToString() + "\n" + notecardData + "}\n"; 1039 + textLength.ToString() + "\n" + notecardData + "}\n";
1040 1040
1041 asset.Data = Encoding.ASCII.GetBytes(notecardData); 1041 asset.Data = Encoding.ASCII.GetBytes(notecardData);
@@ -1047,8 +1047,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1047 taskItem.ResetIDs(m_host.UUID); 1047 taskItem.ResetIDs(m_host.UUID);
1048 taskItem.ParentID = m_host.UUID; 1048 taskItem.ParentID = m_host.UUID;
1049 taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch(); 1049 taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch();
1050 taskItem.Name = asset.Name; 1050 taskItem.Name = asset.Metadata.Name;
1051 taskItem.Description = asset.Description; 1051 taskItem.Description = asset.Metadata.Description;
1052 taskItem.Type = 7; 1052 taskItem.Type = 7;
1053 taskItem.InvType = 7; 1053 taskItem.InvType = 7;
1054 taskItem.OwnerID = m_host.OwnerID; 1054 taskItem.OwnerID = m_host.OwnerID;
@@ -1062,7 +1062,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1062 taskItem.Flags = 0; 1062 taskItem.Flags = 0;
1063 taskItem.PermsGranter = UUID.Zero; 1063 taskItem.PermsGranter = UUID.Zero;
1064 taskItem.PermsMask = 0; 1064 taskItem.PermsMask = 0;
1065 taskItem.AssetID = asset.FullID; 1065 taskItem.AssetID = asset.Metadata.FullID;
1066 1066
1067 m_host.Inventory.AddInventoryItem(taskItem, false); 1067 m_host.Inventory.AddInventoryItem(taskItem, false);
1068 } 1068 }