diff options
author | John Hurliman | 2010-04-02 13:32:40 -0700 |
---|---|---|
committer | John Hurliman | 2010-04-02 13:32:40 -0700 |
commit | a895de4414fa3a9439500a2bbbb18d4bc24fa624 (patch) | |
tree | 5adccfbbd91fceb4366c82e71a786270a95c1653 /OpenSim | |
parent | * Better logging for Authenticate() failures (diff) | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC-a895de4414fa3a9439500a2bbbb18d4bc24fa624.zip opensim-SC-a895de4414fa3a9439500a2bbbb18d4bc24fa624.tar.gz opensim-SC-a895de4414fa3a9439500a2bbbb18d4bc24fa624.tar.bz2 opensim-SC-a895de4414fa3a9439500a2bbbb18d4bc24fa624.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to '')
34 files changed, 3363 insertions, 408 deletions
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 2dec72d..17bd795 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs | |||
@@ -930,7 +930,7 @@ namespace OpenSim.Client.MXP.ClientStack | |||
930 | // Need to translate to MXP somehow | 930 | // Need to translate to MXP somehow |
931 | } | 931 | } |
932 | 932 | ||
933 | public void SendGenericMessage(string method, List<string> message) | 933 | public void SendGenericMessage(string method, List<byte[]> message) |
934 | { | 934 | { |
935 | // Need to translate to MXP somehow | 935 | // Need to translate to MXP somehow |
936 | } | 936 | } |
diff --git a/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs b/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs index 9cb2172..4ecbaf9 100644 --- a/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs +++ b/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs | |||
@@ -503,7 +503,7 @@ namespace OpenSim.Client.Sirikata.ClientStack | |||
503 | throw new System.NotImplementedException(); | 503 | throw new System.NotImplementedException(); |
504 | } | 504 | } |
505 | 505 | ||
506 | public void SendGenericMessage(string method, List<string> message) | 506 | public void SendGenericMessage(string method, List<byte[]> message) |
507 | { | 507 | { |
508 | throw new System.NotImplementedException(); | 508 | throw new System.NotImplementedException(); |
509 | } | 509 | } |
diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs index a427dd3..1da746a 100644 --- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs +++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs | |||
@@ -509,7 +509,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack | |||
509 | throw new System.NotImplementedException(); | 509 | throw new System.NotImplementedException(); |
510 | } | 510 | } |
511 | 511 | ||
512 | public void SendGenericMessage(string method, List<string> message) | 512 | public void SendGenericMessage(string method, List<byte[]> message) |
513 | { | 513 | { |
514 | throw new System.NotImplementedException(); | 514 | throw new System.NotImplementedException(); |
515 | } | 515 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs index c849f38..d6cb91f 100644 --- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | |||
@@ -691,7 +691,16 @@ VALUES | |||
691 | cmd.ExecuteNonQuery(); | 691 | cmd.ExecuteNonQuery(); |
692 | } | 692 | } |
693 | } | 693 | } |
694 | 694 | public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) | |
695 | { | ||
696 | //This connector doesn't support the windlight module yet | ||
697 | //Return default LL windlight settings | ||
698 | return new RegionLightShareData(); | ||
699 | } | ||
700 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | ||
701 | { | ||
702 | //This connector doesn't support the windlight module yet | ||
703 | } | ||
695 | /// <summary> | 704 | /// <summary> |
696 | /// Loads the settings of a region. | 705 | /// Loads the settings of a region. |
697 | /// </summary> | 706 | /// </summary> |
@@ -718,7 +727,7 @@ VALUES | |||
718 | } | 727 | } |
719 | } | 728 | } |
720 | 729 | ||
721 | //If comes here then there is now region setting for that region | 730 | //If we reach this point then there are new region settings for that region |
722 | regionSettings = new RegionSettings(); | 731 | regionSettings = new RegionSettings(); |
723 | regionSettings.RegionUUID = regionUUID; | 732 | regionSettings.RegionUUID = regionUUID; |
724 | regionSettings.OnSave += StoreRegionSettings; | 733 | regionSettings.OnSave += StoreRegionSettings; |
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index a06eec3..a395ddc 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | |||
@@ -711,6 +711,102 @@ namespace OpenSim.Data.MySQL | |||
711 | } | 711 | } |
712 | } | 712 | } |
713 | 713 | ||
714 | public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) | ||
715 | { | ||
716 | RegionLightShareData nWP = new RegionLightShareData(); | ||
717 | nWP.OnSave += StoreRegionWindlightSettings; | ||
718 | |||
719 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
720 | { | ||
721 | dbcon.Open(); | ||
722 | |||
723 | string command = "select * from `regionwindlight` where region_id = ?regionID"; | ||
724 | |||
725 | using(MySqlCommand cmd = new MySqlCommand(command)) | ||
726 | { | ||
727 | cmd.Connection = dbcon; | ||
728 | |||
729 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); | ||
730 | |||
731 | IDataReader result = ExecuteReader(cmd); | ||
732 | if (!result.Read()) | ||
733 | { | ||
734 | //No result, so store our default windlight profile and return it | ||
735 | nWP.regionID = regionUUID; | ||
736 | StoreRegionWindlightSettings(nWP); | ||
737 | return nWP; | ||
738 | } | ||
739 | else | ||
740 | { | ||
741 | UUID.TryParse(result["region_id"].ToString(), out nWP.regionID); | ||
742 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); | ||
743 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); | ||
744 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); | ||
745 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); | ||
746 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); | ||
747 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); | ||
748 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); | ||
749 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); | ||
750 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); | ||
751 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); | ||
752 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); | ||
753 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); | ||
754 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); | ||
755 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); | ||
756 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); | ||
757 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); | ||
758 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); | ||
759 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); | ||
760 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); | ||
761 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); | ||
762 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); | ||
763 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); | ||
764 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); | ||
765 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); | ||
766 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); | ||
767 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); | ||
768 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); | ||
769 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); | ||
770 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); | ||
771 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); | ||
772 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); | ||
773 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); | ||
774 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); | ||
775 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); | ||
776 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); | ||
777 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); | ||
778 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); | ||
779 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); | ||
780 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); | ||
781 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); | ||
782 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); | ||
783 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); | ||
784 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); | ||
785 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); | ||
786 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); | ||
787 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); | ||
788 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); | ||
789 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); | ||
790 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); | ||
791 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); | ||
792 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); | ||
793 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); | ||
794 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); | ||
795 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); | ||
796 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); | ||
797 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); | ||
798 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); | ||
799 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); | ||
800 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); | ||
801 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); | ||
802 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); | ||
803 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); | ||
804 | } | ||
805 | } | ||
806 | } | ||
807 | return nWP; | ||
808 | } | ||
809 | |||
714 | public RegionSettings LoadRegionSettings(UUID regionUUID) | 810 | public RegionSettings LoadRegionSettings(UUID regionUUID) |
715 | { | 811 | { |
716 | RegionSettings rs = null; | 812 | RegionSettings rs = null; |
@@ -749,6 +845,109 @@ namespace OpenSim.Data.MySQL | |||
749 | return rs; | 845 | return rs; |
750 | } | 846 | } |
751 | 847 | ||
848 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | ||
849 | { | ||
850 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
851 | { | ||
852 | dbcon.Open(); | ||
853 | |||
854 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
855 | { | ||
856 | cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; | ||
857 | cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; | ||
858 | cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; | ||
859 | cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; | ||
860 | cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; | ||
861 | cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; | ||
862 | cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; | ||
863 | cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; | ||
864 | cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; | ||
865 | cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; | ||
866 | cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; | ||
867 | cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; | ||
868 | cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; | ||
869 | cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; | ||
870 | cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; | ||
871 | cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; | ||
872 | cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; | ||
873 | cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; | ||
874 | cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; | ||
875 | cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; | ||
876 | cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; | ||
877 | cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; | ||
878 | cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; | ||
879 | cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; | ||
880 | cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; | ||
881 | |||
882 | cmd.Parameters.AddWithValue("region_id", wl.regionID); | ||
883 | cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); | ||
884 | cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); | ||
885 | cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); | ||
886 | cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); | ||
887 | cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); | ||
888 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); | ||
889 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); | ||
890 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); | ||
891 | cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); | ||
892 | cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); | ||
893 | cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); | ||
894 | cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); | ||
895 | cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); | ||
896 | cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); | ||
897 | cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); | ||
898 | cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); | ||
899 | cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); | ||
900 | cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); | ||
901 | cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); | ||
902 | cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); | ||
903 | cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); | ||
904 | cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); | ||
905 | cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); | ||
906 | cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); | ||
907 | cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); | ||
908 | cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); | ||
909 | cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); | ||
910 | cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); | ||
911 | cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); | ||
912 | cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); | ||
913 | cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); | ||
914 | cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); | ||
915 | cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); | ||
916 | cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); | ||
917 | cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); | ||
918 | cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); | ||
919 | cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); | ||
920 | cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); | ||
921 | cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); | ||
922 | cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); | ||
923 | cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); | ||
924 | cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); | ||
925 | cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); | ||
926 | cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); | ||
927 | cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); | ||
928 | cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); | ||
929 | cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); | ||
930 | cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); | ||
931 | cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); | ||
932 | cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); | ||
933 | cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); | ||
934 | cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); | ||
935 | cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); | ||
936 | cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); | ||
937 | cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); | ||
938 | cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); | ||
939 | cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); | ||
940 | cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); | ||
941 | cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); | ||
942 | cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); | ||
943 | cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); | ||
944 | cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); | ||
945 | |||
946 | ExecuteNonQuery(cmd); | ||
947 | } | ||
948 | } | ||
949 | } | ||
950 | |||
752 | public void StoreRegionSettings(RegionSettings rs) | 951 | public void StoreRegionSettings(RegionSettings rs) |
753 | { | 952 | { |
754 | lock (m_dbLock) | 953 | lock (m_dbLock) |
diff --git a/OpenSim/Data/Null/NullDataStore.cs b/OpenSim/Data/Null/NullDataStore.cs index 427fa0a..3ba44bb 100644 --- a/OpenSim/Data/Null/NullDataStore.cs +++ b/OpenSim/Data/Null/NullDataStore.cs | |||
@@ -50,7 +50,16 @@ namespace OpenSim.Data.Null | |||
50 | public void StoreRegionSettings(RegionSettings rs) | 50 | public void StoreRegionSettings(RegionSettings rs) |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) | |
54 | { | ||
55 | //This connector doesn't support the windlight module yet | ||
56 | //Return default LL windlight settings | ||
57 | return new RegionLightShareData(); | ||
58 | } | ||
59 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | ||
60 | { | ||
61 | //This connector doesn't support the windlight module yet | ||
62 | } | ||
54 | public RegionSettings LoadRegionSettings(UUID regionUUID) | 63 | public RegionSettings LoadRegionSettings(UUID regionUUID) |
55 | { | 64 | { |
56 | return null; | 65 | return null; |
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 5a4ee2a..d2ba9ae 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs | |||
@@ -272,7 +272,16 @@ namespace OpenSim.Data.SQLite | |||
272 | Commit(); | 272 | Commit(); |
273 | } | 273 | } |
274 | } | 274 | } |
275 | 275 | public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) | |
276 | { | ||
277 | //This connector doesn't support the windlight module yet | ||
278 | //Return default LL windlight settings | ||
279 | return new RegionLightShareData(); | ||
280 | } | ||
281 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | ||
282 | { | ||
283 | //This connector doesn't support the windlight module yet | ||
284 | } | ||
276 | public RegionSettings LoadRegionSettings(UUID regionUUID) | 285 | public RegionSettings LoadRegionSettings(UUID regionUUID) |
277 | { | 286 | { |
278 | lock (ds) | 287 | lock (ds) |
@@ -320,7 +329,7 @@ namespace OpenSim.Data.SQLite | |||
320 | { | 329 | { |
321 | foreach (SceneObjectPart prim in obj.Children.Values) | 330 | foreach (SceneObjectPart prim in obj.Children.Values) |
322 | { | 331 | { |
323 | m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); | 332 | // m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); |
324 | addPrim(prim, obj.UUID, regionUUID); | 333 | addPrim(prim, obj.UUID, regionUUID); |
325 | } | 334 | } |
326 | } | 335 | } |
diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index 2e55f53..24ea64d 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs | |||
@@ -139,6 +139,9 @@ namespace OpenSim.Framework.Communications.Osp | |||
139 | /// </returns> | 139 | /// </returns> |
140 | protected static UUID ResolveOspaName(string name, IUserAccountService userService) | 140 | protected static UUID ResolveOspaName(string name, IUserAccountService userService) |
141 | { | 141 | { |
142 | if (userService == null) | ||
143 | return UUID.Zero; | ||
144 | |||
142 | int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); | 145 | int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); |
143 | 146 | ||
144 | if (nameSeparatorIndex < 0) | 147 | if (nameSeparatorIndex < 0) |
@@ -149,7 +152,7 @@ namespace OpenSim.Framework.Communications.Osp | |||
149 | 152 | ||
150 | string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); | 153 | string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); |
151 | string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart(); | 154 | string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart(); |
152 | 155 | ||
153 | UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName); | 156 | UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName); |
154 | if (account != null) | 157 | if (account != null) |
155 | return account.PrincipalID; | 158 | return account.PrincipalID; |
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 4f6f709..4577758 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs | |||
@@ -1150,7 +1150,7 @@ namespace OpenSim.Framework | |||
1150 | 1150 | ||
1151 | void SendInstantMessage(GridInstantMessage im); | 1151 | void SendInstantMessage(GridInstantMessage im); |
1152 | 1152 | ||
1153 | void SendGenericMessage(string method, List<string> message); | 1153 | void SendGenericMessage(string method, List<byte[]> message); |
1154 | 1154 | ||
1155 | void SendLayerData(float[] map); | 1155 | void SendLayerData(float[] map); |
1156 | void SendLayerData(int px, int py, float[] map); | 1156 | void SendLayerData(int px, int py, float[] map); |
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 5d63da7..ad98816 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -36,8 +36,295 @@ using OpenMetaverse; | |||
36 | using OpenMetaverse.StructuredData; | 36 | using OpenMetaverse.StructuredData; |
37 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
38 | 38 | ||
39 | |||
39 | namespace OpenSim.Framework | 40 | namespace OpenSim.Framework |
40 | { | 41 | { |
42 | public class RegionLightShareData : ICloneable | ||
43 | { | ||
44 | public UUID regionID = UUID.Zero; | ||
45 | public Vector3 waterColor = new Vector3(4.0f,38.0f,64.0f); | ||
46 | public float waterFogDensityExponent = 4.0f; | ||
47 | public float underwaterFogModifier = 0.25f; | ||
48 | public Vector3 reflectionWaveletScale = new Vector3(2.0f,2.0f,2.0f); | ||
49 | public float fresnelScale = 0.40f; | ||
50 | public float fresnelOffset = 0.50f; | ||
51 | public float refractScaleAbove = 0.03f; | ||
52 | public float refractScaleBelow = 0.20f; | ||
53 | public float blurMultiplier = 0.040f; | ||
54 | public Vector2 bigWaveDirection = new Vector2(1.05f,-0.42f); | ||
55 | public Vector2 littleWaveDirection = new Vector2(1.11f,-1.16f); | ||
56 | public UUID normalMapTexture = new UUID("822ded49-9a6c-f61c-cb89-6df54f42cdf4"); | ||
57 | public Vector4 horizon = new Vector4(0.25f, 0.25f, 0.32f, 0.32f); | ||
58 | public float hazeHorizon = 0.19f; | ||
59 | public Vector4 blueDensity = new Vector4(0.12f, 0.22f, 0.38f, 0.38f); | ||
60 | public float hazeDensity = 0.70f; | ||
61 | public float densityMultiplier = 0.18f; | ||
62 | public float distanceMultiplier = 0.8f; | ||
63 | public UInt16 maxAltitude = 1605; | ||
64 | public Vector4 sunMoonColor = new Vector4(0.24f, 0.26f, 0.30f, 0.30f); | ||
65 | public float sunMoonPosition = 0.317f; | ||
66 | public Vector4 ambient = new Vector4(0.35f,0.35f,0.35f,0.35f); | ||
67 | public float eastAngle = 0.0f; | ||
68 | public float sunGlowFocus = 0.10f; | ||
69 | public float sunGlowSize = 1.75f; | ||
70 | public float sceneGamma = 1.0f; | ||
71 | public float starBrightness = 0.0f; | ||
72 | public Vector4 cloudColor = new Vector4(0.41f, 0.41f, 0.41f, 0.41f); | ||
73 | public Vector3 cloudXYDensity = new Vector3(1.00f, 0.53f, 1.00f); | ||
74 | public float cloudCoverage = 0.27f; | ||
75 | public float cloudScale = 0.42f; | ||
76 | public Vector3 cloudDetailXYDensity = new Vector3(1.00f, 0.53f, 0.12f); | ||
77 | public float cloudScrollX = 0.20f; | ||
78 | public bool cloudScrollXLock = false; | ||
79 | public float cloudScrollY = 0.01f; | ||
80 | public bool cloudScrollYLock = false; | ||
81 | public bool drawClassicClouds = true; | ||
82 | |||
83 | public delegate void SaveDelegate(RegionLightShareData wl); | ||
84 | public event SaveDelegate OnSave; | ||
85 | public void Save() | ||
86 | { | ||
87 | if (OnSave != null) | ||
88 | OnSave(this); | ||
89 | } | ||
90 | public object Clone() | ||
91 | { | ||
92 | return this.MemberwiseClone(); // call clone method | ||
93 | } | ||
94 | |||
95 | } | ||
96 | |||
97 | [Serializable] | ||
98 | public class SimpleRegionInfo | ||
99 | { | ||
100 | // private static readonly log4net.ILog m_log | ||
101 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
102 | |||
103 | /// <summary> | ||
104 | /// The port by which http communication occurs with the region (most noticeably, CAPS communication) | ||
105 | /// </summary> | ||
106 | public uint HttpPort | ||
107 | { | ||
108 | get { return m_httpPort; } | ||
109 | set { m_httpPort = value; } | ||
110 | } | ||
111 | protected uint m_httpPort; | ||
112 | |||
113 | /// <summary> | ||
114 | /// A well-formed URI for the host region server (namely "http://" + ExternalHostName) | ||
115 | /// </summary> | ||
116 | public string ServerURI | ||
117 | { | ||
118 | get { return m_serverURI; } | ||
119 | set { m_serverURI = value; } | ||
120 | } | ||
121 | protected string m_serverURI; | ||
122 | |||
123 | public string RegionName | ||
124 | { | ||
125 | get { return m_regionName; } | ||
126 | set { m_regionName = value; } | ||
127 | } | ||
128 | protected string m_regionName = String.Empty; | ||
129 | |||
130 | protected bool Allow_Alternate_Ports; | ||
131 | public bool m_allow_alternate_ports; | ||
132 | protected string m_externalHostName; | ||
133 | |||
134 | protected IPEndPoint m_internalEndPoint; | ||
135 | protected uint? m_regionLocX; | ||
136 | protected uint? m_regionLocY; | ||
137 | protected uint m_remotingPort; | ||
138 | public UUID RegionID = UUID.Zero; | ||
139 | public string RemotingAddress; | ||
140 | public UUID ScopeID = UUID.Zero; | ||
141 | |||
142 | public SimpleRegionInfo() | ||
143 | { | ||
144 | } | ||
145 | |||
146 | public SimpleRegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) | ||
147 | { | ||
148 | m_regionLocX = regionLocX; | ||
149 | m_regionLocY = regionLocY; | ||
150 | |||
151 | m_internalEndPoint = internalEndPoint; | ||
152 | m_externalHostName = externalUri; | ||
153 | } | ||
154 | |||
155 | public SimpleRegionInfo(uint regionLocX, uint regionLocY, string externalUri, uint port) | ||
156 | { | ||
157 | m_regionLocX = regionLocX; | ||
158 | m_regionLocY = regionLocY; | ||
159 | |||
160 | m_externalHostName = externalUri; | ||
161 | |||
162 | m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int) port); | ||
163 | } | ||
164 | |||
165 | public SimpleRegionInfo(RegionInfo ConvertFrom) | ||
166 | { | ||
167 | m_regionName = ConvertFrom.RegionName; | ||
168 | m_regionLocX = ConvertFrom.RegionLocX; | ||
169 | m_regionLocY = ConvertFrom.RegionLocY; | ||
170 | m_internalEndPoint = ConvertFrom.InternalEndPoint; | ||
171 | m_externalHostName = ConvertFrom.ExternalHostName; | ||
172 | m_remotingPort = ConvertFrom.RemotingPort; | ||
173 | m_httpPort = ConvertFrom.HttpPort; | ||
174 | m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; | ||
175 | RemotingAddress = ConvertFrom.RemotingAddress; | ||
176 | RegionID = UUID.Zero; | ||
177 | ServerURI = ConvertFrom.ServerURI; | ||
178 | } | ||
179 | |||
180 | public uint RemotingPort | ||
181 | { | ||
182 | get { return m_remotingPort; } | ||
183 | set { m_remotingPort = value; } | ||
184 | } | ||
185 | |||
186 | /// <value> | ||
187 | /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. | ||
188 | /// | ||
189 | /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method? | ||
190 | /// </value> | ||
191 | public IPEndPoint ExternalEndPoint | ||
192 | { | ||
193 | get | ||
194 | { | ||
195 | // Old one defaults to IPv6 | ||
196 | //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port); | ||
197 | |||
198 | IPAddress ia = null; | ||
199 | // If it is already an IP, don't resolve it - just return directly | ||
200 | if (IPAddress.TryParse(m_externalHostName, out ia)) | ||
201 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
202 | |||
203 | // Reset for next check | ||
204 | ia = null; | ||
205 | try | ||
206 | { | ||
207 | foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) | ||
208 | { | ||
209 | if (ia == null) | ||
210 | ia = Adr; | ||
211 | |||
212 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
213 | { | ||
214 | ia = Adr; | ||
215 | break; | ||
216 | } | ||
217 | } | ||
218 | } | ||
219 | catch (SocketException e) | ||
220 | { | ||
221 | throw new Exception( | ||
222 | "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + | ||
223 | e + "' attached to this exception", e); | ||
224 | } | ||
225 | |||
226 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
227 | } | ||
228 | |||
229 | set { m_externalHostName = value.ToString(); } | ||
230 | } | ||
231 | |||
232 | public string ExternalHostName | ||
233 | { | ||
234 | get { return m_externalHostName; } | ||
235 | set { m_externalHostName = value; } | ||
236 | } | ||
237 | |||
238 | public IPEndPoint InternalEndPoint | ||
239 | { | ||
240 | get { return m_internalEndPoint; } | ||
241 | set { m_internalEndPoint = value; } | ||
242 | } | ||
243 | |||
244 | public uint RegionLocX | ||
245 | { | ||
246 | get { return m_regionLocX.Value; } | ||
247 | set { m_regionLocX = value; } | ||
248 | } | ||
249 | |||
250 | public uint RegionLocY | ||
251 | { | ||
252 | get { return m_regionLocY.Value; } | ||
253 | set { m_regionLocY = value; } | ||
254 | } | ||
255 | |||
256 | public ulong RegionHandle | ||
257 | { | ||
258 | get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); } | ||
259 | } | ||
260 | |||
261 | public int getInternalEndPointPort() | ||
262 | { | ||
263 | return m_internalEndPoint.Port; | ||
264 | } | ||
265 | |||
266 | public Dictionary<string, object> ToKeyValuePairs() | ||
267 | { | ||
268 | Dictionary<string, object> kvp = new Dictionary<string, object>(); | ||
269 | kvp["uuid"] = RegionID.ToString(); | ||
270 | kvp["locX"] = RegionLocX.ToString(); | ||
271 | kvp["locY"] = RegionLocY.ToString(); | ||
272 | kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); | ||
273 | kvp["external_port"] = ExternalEndPoint.Port.ToString(); | ||
274 | kvp["external_host_name"] = ExternalHostName; | ||
275 | kvp["http_port"] = HttpPort.ToString(); | ||
276 | kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); | ||
277 | kvp["internal_port"] = InternalEndPoint.Port.ToString(); | ||
278 | kvp["alternate_ports"] = m_allow_alternate_ports.ToString(); | ||
279 | kvp["server_uri"] = ServerURI; | ||
280 | |||
281 | return kvp; | ||
282 | } | ||
283 | |||
284 | public SimpleRegionInfo(Dictionary<string, object> kvp) | ||
285 | { | ||
286 | if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) | ||
287 | { | ||
288 | int port = 0; | ||
289 | Int32.TryParse((string)kvp["external_port"], out port); | ||
290 | IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port); | ||
291 | ExternalEndPoint = ep; | ||
292 | } | ||
293 | else | ||
294 | ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | ||
295 | |||
296 | if (kvp["external_host_name"] != null) | ||
297 | ExternalHostName = (string)kvp["external_host_name"]; | ||
298 | |||
299 | if (kvp["http_port"] != null) | ||
300 | { | ||
301 | UInt32 port = 0; | ||
302 | UInt32.TryParse((string)kvp["http_port"], out port); | ||
303 | HttpPort = port; | ||
304 | } | ||
305 | |||
306 | if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null)) | ||
307 | { | ||
308 | int port = 0; | ||
309 | Int32.TryParse((string)kvp["internal_port"], out port); | ||
310 | IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port); | ||
311 | InternalEndPoint = ep; | ||
312 | } | ||
313 | else | ||
314 | InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | ||
315 | |||
316 | if (kvp["alternate_ports"] != null) | ||
317 | { | ||
318 | bool alts = false; | ||
319 | Boolean.TryParse((string)kvp["alternate_ports"], out alts); | ||
320 | m_allow_alternate_ports = alts; | ||
321 | } | ||
322 | |||
323 | if (kvp["server_uri"] != null) | ||
324 | ServerURI = (string)kvp["server_uri"]; | ||
325 | } | ||
326 | } | ||
327 | |||
41 | public class RegionInfo | 328 | public class RegionInfo |
42 | { | 329 | { |
43 | // private static readonly log4net.ILog m_log | 330 | // private static readonly log4net.ILog m_log |
@@ -69,6 +356,7 @@ namespace OpenSim.Framework | |||
69 | private bool m_clampPrimSize = false; | 356 | private bool m_clampPrimSize = false; |
70 | private int m_objectCapacity = 0; | 357 | private int m_objectCapacity = 0; |
71 | private string m_regionType = String.Empty; | 358 | private string m_regionType = String.Empty; |
359 | private RegionLightShareData m_windlight = new RegionLightShareData(); | ||
72 | protected uint m_httpPort; | 360 | protected uint m_httpPort; |
73 | protected string m_serverURI; | 361 | protected string m_serverURI; |
74 | protected string m_regionName = String.Empty; | 362 | protected string m_regionName = String.Empty; |
@@ -207,6 +495,21 @@ namespace OpenSim.Framework | |||
207 | set { m_regionSettings = value; } | 495 | set { m_regionSettings = value; } |
208 | } | 496 | } |
209 | 497 | ||
498 | public RegionLightShareData WindlightSettings | ||
499 | { | ||
500 | get | ||
501 | { | ||
502 | if (m_windlight == null) | ||
503 | { | ||
504 | m_windlight = new RegionLightShareData(); | ||
505 | } | ||
506 | |||
507 | return m_windlight; | ||
508 | } | ||
509 | |||
510 | set { m_windlight = value; } | ||
511 | } | ||
512 | |||
210 | public int NonphysPrimMax | 513 | public int NonphysPrimMax |
211 | { | 514 | { |
212 | get { return m_nonphysPrimMax; } | 515 | get { return m_nonphysPrimMax; } |
diff --git a/OpenSim/Framework/Serialization/TarArchiveWriter.cs b/OpenSim/Framework/Serialization/TarArchiveWriter.cs index 20d0f7e..0bd639f 100644 --- a/OpenSim/Framework/Serialization/TarArchiveWriter.cs +++ b/OpenSim/Framework/Serialization/TarArchiveWriter.cs | |||
@@ -208,7 +208,9 @@ namespace OpenSim.Framework.Serialization | |||
208 | m_bw.Write(header); | 208 | m_bw.Write(header); |
209 | 209 | ||
210 | // Write out data | 210 | // Write out data |
211 | m_bw.Write(data); | 211 | // An IOException occurs if we try to write out an empty array in Mono 2.6 |
212 | if (data.Length > 0) | ||
213 | m_bw.Write(data); | ||
212 | 214 | ||
213 | if (data.Length % 512 != 0) | 215 | if (data.Length % 512 != 0) |
214 | { | 216 | { |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 18d3889..25f6ef0 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -40,7 +40,6 @@ using OpenMetaverse.Packets; | |||
40 | using OpenMetaverse.StructuredData; | 40 | using OpenMetaverse.StructuredData; |
41 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
42 | using OpenSim.Framework.Client; | 42 | using OpenSim.Framework.Client; |
43 | |||
44 | using OpenSim.Framework.Statistics; | 43 | using OpenSim.Framework.Statistics; |
45 | using OpenSim.Region.Framework.Interfaces; | 44 | using OpenSim.Region.Framework.Interfaces; |
46 | using OpenSim.Region.Framework.Scenes; | 45 | using OpenSim.Region.Framework.Scenes; |
@@ -353,6 +352,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
353 | protected PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates; | 352 | protected PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates; |
354 | private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates; | 353 | private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates; |
355 | private PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates; | 354 | private PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates; |
355 | |||
356 | /// <value> | ||
357 | /// List used in construction of data blocks for an object update packet. This is to stop us having to | ||
358 | /// continually recreate it. | ||
359 | /// </value> | ||
360 | protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder; | ||
361 | |||
362 | /// <value> | ||
363 | /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the | ||
364 | /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an | ||
365 | /// ownerless phantom. | ||
366 | /// | ||
367 | /// All manipulation of this set has to occur under a m_primFullUpdate.SyncRoot lock | ||
368 | /// | ||
369 | /// </value> | ||
370 | protected HashSet<uint> m_killRecord; | ||
371 | |||
356 | private int m_moneyBalance; | 372 | private int m_moneyBalance; |
357 | private int m_animationSequenceNumber = 1; | 373 | private int m_animationSequenceNumber = 1; |
358 | private bool m_SendLogoutPacketWhenClosing = true; | 374 | private bool m_SendLogoutPacketWhenClosing = true; |
@@ -449,6 +465,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
449 | m_avatarTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); | 465 | m_avatarTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); |
450 | m_primTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); | 466 | m_primTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); |
451 | m_primFullUpdates = new PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock>(m_scene.Entities.Count); | 467 | m_primFullUpdates = new PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock>(m_scene.Entities.Count); |
468 | m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>(); | ||
469 | m_killRecord = new HashSet<uint>(); | ||
452 | 470 | ||
453 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); | 471 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); |
454 | m_hyperAssets = m_scene.RequestModuleInterface<IHyperAssetService>(); | 472 | m_hyperAssets = m_scene.RequestModuleInterface<IHyperAssetService>(); |
@@ -827,17 +845,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
827 | } | 845 | } |
828 | } | 846 | } |
829 | 847 | ||
830 | public void SendGenericMessage(string method, List<string> message) | 848 | public void SendGenericMessage(string method, List<byte[]> message) |
831 | { | 849 | { |
832 | GenericMessagePacket gmp = new GenericMessagePacket(); | 850 | GenericMessagePacket gmp = new GenericMessagePacket(); |
833 | gmp.MethodData.Method = Util.StringToBytes256(method); | 851 | gmp.MethodData.Method = Util.StringToBytes256(method); |
834 | gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count]; | 852 | gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count]; |
835 | int i = 0; | 853 | int i = 0; |
836 | foreach (string val in message) | 854 | foreach (byte[] val in message) |
837 | { | 855 | { |
838 | gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock(); | 856 | gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock(); |
839 | gmp.ParamList[i++].Parameter = Util.StringToBytes256(val); | 857 | gmp.ParamList[i++].Parameter = val; |
840 | } | 858 | } |
859 | |||
841 | OutPacket(gmp, ThrottleOutPacketType.Task); | 860 | OutPacket(gmp, ThrottleOutPacketType.Task); |
842 | } | 861 | } |
843 | 862 | ||
@@ -1489,7 +1508,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1489 | kill.ObjectData[0].ID = localID; | 1508 | kill.ObjectData[0].ID = localID; |
1490 | kill.Header.Reliable = true; | 1509 | kill.Header.Reliable = true; |
1491 | kill.Header.Zerocoded = true; | 1510 | kill.Header.Zerocoded = true; |
1492 | OutPacket(kill, ThrottleOutPacketType.State); | 1511 | |
1512 | lock (m_primFullUpdates.SyncRoot) | ||
1513 | { | ||
1514 | m_killRecord.Add(localID); | ||
1515 | OutPacket(kill, ThrottleOutPacketType.State); | ||
1516 | } | ||
1493 | } | 1517 | } |
1494 | 1518 | ||
1495 | /// <summary> | 1519 | /// <summary> |
@@ -3538,21 +3562,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3538 | if (count == 0) | 3562 | if (count == 0) |
3539 | return; | 3563 | return; |
3540 | 3564 | ||
3541 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[count]; | 3565 | m_fullUpdateDataBlocksBuilder.Clear(); |
3566 | |||
3542 | for (int i = 0; i < count; i++) | 3567 | for (int i = 0; i < count; i++) |
3543 | { | 3568 | { |
3544 | outPacket.ObjectData[i] = m_primFullUpdates.Dequeue(); | 3569 | ObjectUpdatePacket.ObjectDataBlock block = m_primFullUpdates.Dequeue(); |
3545 | 3570 | ||
3571 | if (!m_killRecord.Contains(block.ID)) | ||
3572 | { | ||
3573 | m_fullUpdateDataBlocksBuilder.Add(block); | ||
3574 | |||
3546 | // string text = Util.FieldToString(outPacket.ObjectData[i].Text); | 3575 | // string text = Util.FieldToString(outPacket.ObjectData[i].Text); |
3547 | // if (text.IndexOf("\n") >= 0) | 3576 | // if (text.IndexOf("\n") >= 0) |
3548 | // text = text.Remove(text.IndexOf("\n")); | 3577 | // text = text.Remove(text.IndexOf("\n")); |
3549 | // m_log.DebugFormat( | 3578 | // m_log.DebugFormat( |
3550 | // "[CLIENT]: Sending full info about prim {0} text {1} to client {2}", | 3579 | // "[CLIENT]: Sending full info about prim {0} text {1} to client {2}", |
3551 | // outPacket.ObjectData[i].ID, text, Name); | 3580 | // outPacket.ObjectData[i].ID, text, Name); |
3581 | } | ||
3582 | // else | ||
3583 | // { | ||
3584 | // m_log.WarnFormat( | ||
3585 | // "[CLIENT]: Preventing full update for {0} after kill to {1}", block.ID, Name); | ||
3586 | // } | ||
3552 | } | 3587 | } |
3553 | } | ||
3554 | 3588 | ||
3555 | OutPacket(outPacket, ThrottleOutPacketType.State); | 3589 | outPacket.ObjectData = m_fullUpdateDataBlocksBuilder.ToArray(); |
3590 | |||
3591 | OutPacket(outPacket, ThrottleOutPacketType.State); | ||
3592 | } | ||
3556 | } | 3593 | } |
3557 | 3594 | ||
3558 | public void SendPrimTerseUpdate(SendPrimitiveTerseData data) | 3595 | public void SendPrimTerseUpdate(SendPrimitiveTerseData data) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 71b3062..f570999 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -388,7 +388,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
388 | 388 | ||
389 | try | 389 | try |
390 | { | 390 | { |
391 | if (m_aScene.AuthenticationService.Authenticate(account.PrincipalID, pass, 1) != string.Empty) | 391 | string encpass = Util.Md5Hash(pass); |
392 | if (m_aScene.AuthenticationService.Authenticate(account.PrincipalID, encpass, 1) != string.Empty) | ||
392 | { | 393 | { |
393 | return account; | 394 | return account; |
394 | } | 395 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index e37da9f..36dae6b 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | |||
@@ -173,11 +173,11 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
173 | m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName); | 173 | m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName); |
174 | simpleName = GetInventoryPathFromName(simpleName); | 174 | simpleName = GetInventoryPathFromName(simpleName); |
175 | 175 | ||
176 | InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, simpleName, iarFileName); | ||
176 | try | 177 | try |
177 | { | 178 | { |
178 | InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, simpleName, iarFileName); | ||
179 | List<InventoryNodeBase> nodes = archread.Execute(); | 179 | List<InventoryNodeBase> nodes = archread.Execute(); |
180 | if (nodes.Count == 0) | 180 | if (nodes != null && nodes.Count == 0) |
181 | { | 181 | { |
182 | // didn't find the subfolder with the given name; place it on the top | 182 | // didn't find the subfolder with the given name; place it on the top |
183 | m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName); | 183 | m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName); |
@@ -185,16 +185,33 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
185 | archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName); | 185 | archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName); |
186 | archread.Execute(); | 186 | archread.Execute(); |
187 | } | 187 | } |
188 | archread.Close(); | 188 | foreach (InventoryNodeBase node in nodes) |
189 | FixPerms(node); | ||
189 | } | 190 | } |
190 | catch (Exception e) | 191 | catch (Exception e) |
191 | { | 192 | { |
192 | m_log.DebugFormat("[LIBRARY MODULE]: Exception when processing archive {0}: {1}", iarFileName, e.Message); | 193 | m_log.DebugFormat("[LIBRARY MODULE]: Exception when processing archive {0}: {1}", iarFileName, e.StackTrace); |
194 | } | ||
195 | finally | ||
196 | { | ||
197 | archread.Close(); | ||
193 | } | 198 | } |
194 | } | 199 | } |
195 | 200 | ||
196 | } | 201 | } |
197 | 202 | ||
203 | private void FixPerms(InventoryNodeBase node) | ||
204 | { | ||
205 | if (node is InventoryItemBase) | ||
206 | { | ||
207 | InventoryItemBase item = (InventoryItemBase)node; | ||
208 | item.BasePermissions = 0x7FFFFFFF; | ||
209 | item.EveryOnePermissions = 0x7FFFFFFF; | ||
210 | item.CurrentPermissions = 0x7FFFFFFF; | ||
211 | item.NextPermissions = 0x7FFFFFFF; | ||
212 | } | ||
213 | } | ||
214 | |||
198 | private void DumpLibrary() | 215 | private void DumpLibrary() |
199 | { | 216 | { |
200 | InventoryFolderImpl lib = m_Library.LibraryRootFolder; | 217 | InventoryFolderImpl lib = m_Library.LibraryRootFolder; |
diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs new file mode 100644 index 0000000..e6cab1d --- /dev/null +++ b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs | |||
@@ -0,0 +1,293 @@ | |||
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.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using OpenMetaverse; | ||
33 | using log4net; | ||
34 | using Nini.Config; | ||
35 | using OpenSim.Data; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | |||
41 | |||
42 | namespace OpenSim.Region.CoreModules.World.LightShare | ||
43 | { | ||
44 | public class LightShareModule : IRegionModule, ICommandableModule | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | private readonly Commander m_commander = new Commander("windlight"); | ||
48 | private Scene m_scene; | ||
49 | private static bool m_enableWindlight; | ||
50 | |||
51 | #region ICommandableModule Members | ||
52 | |||
53 | public ICommander CommandInterface | ||
54 | { | ||
55 | get { return m_commander; } | ||
56 | } | ||
57 | |||
58 | #endregion | ||
59 | |||
60 | #region IRegionModule Members | ||
61 | |||
62 | public static bool EnableWindlight | ||
63 | { | ||
64 | get | ||
65 | { | ||
66 | return m_enableWindlight; | ||
67 | } | ||
68 | set | ||
69 | { | ||
70 | } | ||
71 | } | ||
72 | |||
73 | public void Initialise(Scene scene, IConfigSource config) | ||
74 | { | ||
75 | m_scene = scene; | ||
76 | m_scene.RegisterModuleInterface<IRegionModule>(this); | ||
77 | m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; | ||
78 | |||
79 | // ini file settings | ||
80 | try | ||
81 | { | ||
82 | m_enableWindlight = config.Configs["LightShare"].GetBoolean("enable_windlight", false); | ||
83 | } | ||
84 | catch (Exception) | ||
85 | { | ||
86 | m_log.Debug("[WINDLIGHT]: ini failure for enable_windlight - using default"); | ||
87 | } | ||
88 | |||
89 | if (m_enableWindlight) | ||
90 | { | ||
91 | m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent; | ||
92 | m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile; | ||
93 | m_scene.EventManager.OnSendNewWindlightProfileTargeted += EventManager_OnSendNewWindlightProfileTargeted; | ||
94 | } | ||
95 | |||
96 | InstallCommands(); | ||
97 | |||
98 | m_log.Debug("[WINDLIGHT]: Initialised windlight module"); | ||
99 | } | ||
100 | |||
101 | private List<byte[]> compileWindlightSettings(RegionLightShareData wl) | ||
102 | { | ||
103 | byte[] mBlock = new Byte[249]; | ||
104 | int pos = 0; | ||
105 | |||
106 | wl.waterColor.ToBytes(mBlock, 0); pos += 12; | ||
107 | Utils.FloatToBytes(wl.waterFogDensityExponent).CopyTo(mBlock, pos); pos += 4; | ||
108 | Utils.FloatToBytes(wl.underwaterFogModifier).CopyTo(mBlock, pos); pos += 4; | ||
109 | wl.reflectionWaveletScale.ToBytes(mBlock, pos); pos += 12; | ||
110 | Utils.FloatToBytes(wl.fresnelScale).CopyTo(mBlock, pos); pos += 4; | ||
111 | Utils.FloatToBytes(wl.fresnelOffset).CopyTo(mBlock, pos); pos += 4; | ||
112 | Utils.FloatToBytes(wl.refractScaleAbove).CopyTo(mBlock, pos); pos += 4; | ||
113 | Utils.FloatToBytes(wl.refractScaleBelow).CopyTo(mBlock, pos); pos += 4; | ||
114 | Utils.FloatToBytes(wl.blurMultiplier).CopyTo(mBlock, pos); pos += 4; | ||
115 | wl.bigWaveDirection.ToBytes(mBlock, pos); pos += 8; | ||
116 | wl.littleWaveDirection.ToBytes(mBlock, pos); pos += 8; | ||
117 | wl.normalMapTexture.ToBytes(mBlock, pos); pos += 16; | ||
118 | wl.horizon.ToBytes(mBlock, pos); pos += 16; | ||
119 | Utils.FloatToBytes(wl.hazeHorizon).CopyTo(mBlock, pos); pos += 4; | ||
120 | wl.blueDensity.ToBytes(mBlock, pos); pos += 16; | ||
121 | Utils.FloatToBytes(wl.hazeDensity).CopyTo(mBlock, pos); pos += 4; | ||
122 | Utils.FloatToBytes(wl.densityMultiplier).CopyTo(mBlock, pos); pos += 4; | ||
123 | Utils.FloatToBytes(wl.distanceMultiplier).CopyTo(mBlock, pos); pos += 4; | ||
124 | wl.sunMoonColor.ToBytes(mBlock, pos); pos += 16; | ||
125 | Utils.FloatToBytes(wl.sunMoonPosition).CopyTo(mBlock, pos); pos += 4; | ||
126 | wl.ambient.ToBytes(mBlock, pos); pos += 16; | ||
127 | Utils.FloatToBytes(wl.eastAngle).CopyTo(mBlock, pos); pos += 4; | ||
128 | Utils.FloatToBytes(wl.sunGlowFocus).CopyTo(mBlock, pos); pos += 4; | ||
129 | Utils.FloatToBytes(wl.sunGlowSize).CopyTo(mBlock, pos); pos += 4; | ||
130 | Utils.FloatToBytes(wl.sceneGamma).CopyTo(mBlock, pos); pos += 4; | ||
131 | Utils.FloatToBytes(wl.starBrightness).CopyTo(mBlock, pos); pos += 4; | ||
132 | wl.cloudColor.ToBytes(mBlock, pos); pos += 16; | ||
133 | wl.cloudXYDensity.ToBytes(mBlock, pos); pos += 12; | ||
134 | Utils.FloatToBytes(wl.cloudCoverage).CopyTo(mBlock, pos); pos += 4; | ||
135 | Utils.FloatToBytes(wl.cloudScale).CopyTo(mBlock, pos); pos += 4; | ||
136 | wl.cloudDetailXYDensity.ToBytes(mBlock, pos); pos += 12; | ||
137 | Utils.FloatToBytes(wl.cloudScrollX).CopyTo(mBlock, pos); pos += 4; | ||
138 | Utils.FloatToBytes(wl.cloudScrollY).CopyTo(mBlock, pos); pos += 4; | ||
139 | Utils.UInt16ToBytes(wl.maxAltitude).CopyTo(mBlock, pos); pos += 2; | ||
140 | mBlock[pos] = Convert.ToByte(wl.cloudScrollXLock); pos++; | ||
141 | mBlock[pos] = Convert.ToByte(wl.cloudScrollYLock); pos++; | ||
142 | mBlock[pos] = Convert.ToByte(wl.drawClassicClouds); pos++; | ||
143 | List<byte[]> param = new List<byte[]>(); | ||
144 | param.Add(mBlock); | ||
145 | return param; | ||
146 | } | ||
147 | public void SendProfileToClient(ScenePresence presence) | ||
148 | { | ||
149 | IClientAPI client = presence.ControllingClient; | ||
150 | if (m_enableWindlight) | ||
151 | { | ||
152 | if (presence.IsChildAgent == false) | ||
153 | { | ||
154 | List<byte[]> param = compileWindlightSettings(m_scene.RegionInfo.WindlightSettings); | ||
155 | client.SendGenericMessage("Windlight", param); | ||
156 | } | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | //We probably don't want to spam chat with this.. probably | ||
161 | //m_log.Debug("[WINDLIGHT]: Module disabled"); | ||
162 | } | ||
163 | } | ||
164 | public void SendProfileToClient(ScenePresence presence, RegionLightShareData wl) | ||
165 | { | ||
166 | IClientAPI client = presence.ControllingClient; | ||
167 | if (m_enableWindlight) | ||
168 | { | ||
169 | if (presence.IsChildAgent == false) | ||
170 | { | ||
171 | List<byte[]> param = compileWindlightSettings(wl); | ||
172 | client.SendGenericMessage("Windlight", param); | ||
173 | } | ||
174 | } | ||
175 | else | ||
176 | { | ||
177 | //We probably don't want to spam chat with this.. probably | ||
178 | //m_log.Debug("[WINDLIGHT]: Module disabled"); | ||
179 | } | ||
180 | } | ||
181 | private void EventManager_OnMakeRootAgent(ScenePresence presence) | ||
182 | { | ||
183 | m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); | ||
184 | SendProfileToClient(presence); | ||
185 | } | ||
186 | private void EventManager_OnSendNewWindlightProfileTargeted(RegionLightShareData wl, UUID pUUID) | ||
187 | { | ||
188 | ScenePresence Sc; | ||
189 | if (m_scene.TryGetScenePresence(pUUID,out Sc)) | ||
190 | { | ||
191 | SendProfileToClient(Sc,wl); | ||
192 | } | ||
193 | } | ||
194 | private void EventManager_OnSaveNewWindlightProfile() | ||
195 | { | ||
196 | m_scene.ForEachScenePresence(SendProfileToClient); | ||
197 | } | ||
198 | |||
199 | public void PostInitialise() | ||
200 | { | ||
201 | |||
202 | } | ||
203 | |||
204 | public void Close() | ||
205 | { | ||
206 | } | ||
207 | |||
208 | public string Name | ||
209 | { | ||
210 | get { return "LightShareModule"; } | ||
211 | } | ||
212 | |||
213 | public bool IsSharedModule | ||
214 | { | ||
215 | get { return false; } | ||
216 | } | ||
217 | |||
218 | #endregion | ||
219 | |||
220 | #region events | ||
221 | |||
222 | #endregion | ||
223 | |||
224 | #region ICommandableModule Members | ||
225 | |||
226 | private void InstallCommands() | ||
227 | { | ||
228 | Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast"); | ||
229 | Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin"); | ||
230 | Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Enable the windlight plugin"); | ||
231 | |||
232 | m_commander.RegisterCommand("load", wlload); | ||
233 | m_commander.RegisterCommand("enable", wlenable); | ||
234 | m_commander.RegisterCommand("disable", wldisable); | ||
235 | |||
236 | m_scene.RegisterModuleCommander(m_commander); | ||
237 | } | ||
238 | |||
239 | private void HandleLoad(Object[] args) | ||
240 | { | ||
241 | if (!m_enableWindlight) | ||
242 | { | ||
243 | m_log.InfoFormat("[WINDLIGHT]: Cannot load windlight profile, module disabled. Use 'windlight enable' first."); | ||
244 | } | ||
245 | else | ||
246 | { | ||
247 | m_log.InfoFormat("[WINDLIGHT]: Loading Windlight profile from database"); | ||
248 | m_scene.LoadWindlightProfile(); | ||
249 | m_log.InfoFormat("[WINDLIGHT]: Load complete"); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | private void HandleDisable(Object[] args) | ||
254 | { | ||
255 | m_log.InfoFormat("[WINDLIGHT]: Plugin now disabled"); | ||
256 | m_enableWindlight=false; | ||
257 | } | ||
258 | |||
259 | private void HandleEnable(Object[] args) | ||
260 | { | ||
261 | m_log.InfoFormat("[WINDLIGHT]: Plugin now enabled"); | ||
262 | m_enableWindlight = true; | ||
263 | } | ||
264 | |||
265 | /// <summary> | ||
266 | /// Processes commandline input. Do not call directly. | ||
267 | /// </summary> | ||
268 | /// <param name="args">Commandline arguments</param> | ||
269 | private void EventManager_OnPluginConsole(string[] args) | ||
270 | { | ||
271 | if (args[0] == "windlight") | ||
272 | { | ||
273 | if (args.Length == 1) | ||
274 | { | ||
275 | m_commander.ProcessConsoleCommand("add", new string[0]); | ||
276 | return; | ||
277 | } | ||
278 | |||
279 | string[] tmpArgs = new string[args.Length - 2]; | ||
280 | int i; | ||
281 | for (i = 2; i < args.Length; i++) | ||
282 | { | ||
283 | tmpArgs[i - 2] = args[i]; | ||
284 | } | ||
285 | |||
286 | m_commander.ProcessConsoleCommand(args[1], tmpArgs); | ||
287 | } | ||
288 | } | ||
289 | #endregion | ||
290 | |||
291 | } | ||
292 | } | ||
293 | |||
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index d052f38..8d27f9c 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs | |||
@@ -460,7 +460,7 @@ namespace OpenSim.Region.Examples.SimpleModule | |||
460 | 460 | ||
461 | } | 461 | } |
462 | 462 | ||
463 | public void SendGenericMessage(string method, List<string> message) | 463 | public void SendGenericMessage(string method, List<byte[]> message) |
464 | { | 464 | { |
465 | 465 | ||
466 | } | 466 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs b/OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs new file mode 100644 index 0000000..f158236 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs | |||
@@ -0,0 +1,73 @@ | |||
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 OpenMetaverse; | ||
29 | using OpenSim.Framework; | ||
30 | |||
31 | namespace OpenSim.Region.Framework.Interfaces | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// Provide mechanisms for messaging groups. | ||
35 | /// </summary> | ||
36 | /// | ||
37 | /// TODO: Provide a mechanism for receiving group messages as well as sending them | ||
38 | /// | ||
39 | public interface IGroupsMessagingModule | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Start a group chat session. | ||
43 | /// </summary> | ||
44 | /// You must call this before calling SendMessageToGroup(). If a chat session for this group is already taking | ||
45 | /// place then the agent will added to that session. | ||
46 | /// <param name="agentID"> | ||
47 | /// A UUID that represents the agent being added. If you are agentless (e.g. you are | ||
48 | /// a region module), then you can use any random ID. | ||
49 | /// </param> | ||
50 | /// <param name="groupID"> | ||
51 | /// The ID for the group to join. Currently, the session ID used is identical to the | ||
52 | /// group ID. | ||
53 | /// </param> | ||
54 | /// <returns> | ||
55 | /// True if the chat session was started successfully, false otherwise. | ||
56 | /// </returns> | ||
57 | bool StartGroupChatSession(UUID agentID, UUID groupID); | ||
58 | |||
59 | /// <summary> | ||
60 | /// Send a message to an entire group. | ||
61 | /// </summary> | ||
62 | /// <param name="im"> | ||
63 | /// The message itself. The fields that must be populated are | ||
64 | /// | ||
65 | /// imSessionID - Populate this with the group ID (session ID and group ID are currently identical) | ||
66 | /// fromAgentName - Populate this with whatever arbitrary name you want to show up in the chat dialog | ||
67 | /// message - The message itself | ||
68 | /// dialog - This must be (byte)InstantMessageDialog.SessionSend | ||
69 | /// </param> | ||
70 | /// <param name="groupID"></param> | ||
71 | void SendMessageToGroup(GridInstantMessage im, UUID groupID); | ||
72 | } | ||
73 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs index 78bd622..3e8e196 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionDataStore.cs | |||
@@ -103,6 +103,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
103 | 103 | ||
104 | void StoreRegionSettings(RegionSettings rs); | 104 | void StoreRegionSettings(RegionSettings rs); |
105 | RegionSettings LoadRegionSettings(UUID regionUUID); | 105 | RegionSettings LoadRegionSettings(UUID regionUUID); |
106 | RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID); | ||
107 | void StoreRegionWindlightSettings(RegionLightShareData wl); | ||
106 | 108 | ||
107 | void Shutdown(); | 109 | void Shutdown(); |
108 | } | 110 | } |
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index dc9ae19..ef125cd 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -206,7 +206,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
206 | public event OnMakeChildAgentDelegate OnMakeChildAgent; | 206 | public event OnMakeChildAgentDelegate OnMakeChildAgent; |
207 | 207 | ||
208 | public delegate void OnMakeRootAgentDelegate(ScenePresence presence); | 208 | public delegate void OnMakeRootAgentDelegate(ScenePresence presence); |
209 | public delegate void OnSaveNewWindlightProfileDelegate(); | ||
210 | public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionLightShareData wl, UUID user); | ||
209 | public event OnMakeRootAgentDelegate OnMakeRootAgent; | 211 | public event OnMakeRootAgentDelegate OnMakeRootAgent; |
212 | public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted; | ||
213 | public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile; | ||
210 | 214 | ||
211 | /// <summary> | 215 | /// <summary> |
212 | /// Triggered when an object or attachment enters a scene | 216 | /// Triggered when an object or attachment enters a scene |
@@ -1216,6 +1220,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1216 | } | 1220 | } |
1217 | } | 1221 | } |
1218 | 1222 | ||
1223 | public void TriggerOnSendNewWindlightProfileTargeted(RegionLightShareData wl, UUID user) | ||
1224 | { | ||
1225 | OnSendNewWindlightProfileTargetedDelegate handlerSendNewWindlightProfileTargeted = OnSendNewWindlightProfileTargeted; | ||
1226 | if (handlerSendNewWindlightProfileTargeted != null) | ||
1227 | { | ||
1228 | handlerSendNewWindlightProfileTargeted(wl, user); | ||
1229 | } | ||
1230 | } | ||
1231 | |||
1232 | public void TriggerOnSaveNewWindlightProfile() | ||
1233 | { | ||
1234 | OnSaveNewWindlightProfileDelegate handlerSaveNewWindlightProfile = OnSaveNewWindlightProfile; | ||
1235 | if (handlerSaveNewWindlightProfile != null) | ||
1236 | { | ||
1237 | handlerSaveNewWindlightProfile(); | ||
1238 | } | ||
1239 | } | ||
1240 | |||
1219 | public void TriggerOnMakeRootAgent(ScenePresence presence) | 1241 | public void TriggerOnMakeRootAgent(ScenePresence presence) |
1220 | { | 1242 | { |
1221 | OnMakeRootAgentDelegate handlerMakeRootAgent = OnMakeRootAgent; | 1243 | OnMakeRootAgentDelegate handlerMakeRootAgent = OnMakeRootAgent; |
@@ -1992,4 +2014,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
1992 | } | 2014 | } |
1993 | } | 2015 | } |
1994 | } | 2016 | } |
1995 | } \ No newline at end of file | 2017 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8a583c1..fc915a3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -635,6 +635,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
635 | 635 | ||
636 | int estateID = estateIDs[0]; | 636 | int estateID = estateIDs[0]; |
637 | 637 | ||
638 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(estateID); | ||
639 | |||
638 | if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID)) | 640 | if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID)) |
639 | break; | 641 | break; |
640 | 642 | ||
@@ -1713,6 +1715,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1713 | m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); | 1715 | m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); |
1714 | } | 1716 | } |
1715 | 1717 | ||
1718 | public void StoreWindlightProfile(RegionLightShareData wl) | ||
1719 | { | ||
1720 | m_regInfo.WindlightSettings = wl; | ||
1721 | m_storageManager.DataStore.StoreRegionWindlightSettings(wl); | ||
1722 | m_eventManager.TriggerOnSaveNewWindlightProfile(); | ||
1723 | } | ||
1724 | |||
1725 | public void LoadWindlightProfile() | ||
1726 | { | ||
1727 | m_regInfo.WindlightSettings = m_storageManager.DataStore.LoadRegionWindlightSettings(RegionInfo.RegionID); | ||
1728 | m_eventManager.TriggerOnSaveNewWindlightProfile(); | ||
1729 | } | ||
1730 | |||
1716 | /// <summary> | 1731 | /// <summary> |
1717 | /// Loads the World heightmap | 1732 | /// Loads the World heightmap |
1718 | /// </summary> | 1733 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index c77220c..8b2d387 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | |||
@@ -101,7 +101,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
101 | { | 101 | { |
102 | throw new NotImplementedException(); | 102 | throw new NotImplementedException(); |
103 | } | 103 | } |
104 | 104 | public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) | |
105 | { | ||
106 | //This connector doesn't support the windlight module yet | ||
107 | //Return default LL windlight settings | ||
108 | return new RegionLightShareData(); | ||
109 | } | ||
110 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | ||
111 | { | ||
112 | //This connector doesn't support the windlight module yet | ||
113 | } | ||
105 | public RegionSettings LoadRegionSettings(UUID regionUUID) | 114 | public RegionSettings LoadRegionSettings(UUID regionUUID) |
106 | { | 115 | { |
107 | return null; | 116 | return null; |
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 1885946..f5b148f 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs | |||
@@ -964,7 +964,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
964 | // TODO | 964 | // TODO |
965 | } | 965 | } |
966 | 966 | ||
967 | public void SendGenericMessage(string method, List<string> message) | 967 | public void SendGenericMessage(string method, List<byte[]> message) |
968 | { | 968 | { |
969 | 969 | ||
970 | } | 970 | } |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index 00fe5df..533815f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | |||
@@ -28,29 +28,23 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | |||
32 | |||
33 | using log4net; | 31 | using log4net; |
34 | using Mono.Addins; | 32 | using Mono.Addins; |
35 | using Nini.Config; | 33 | using Nini.Config; |
36 | |||
37 | using OpenMetaverse; | 34 | using OpenMetaverse; |
38 | using OpenMetaverse.StructuredData; | 35 | using OpenMetaverse.StructuredData; |
39 | |||
40 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
41 | using OpenSim.Region.CoreModules.Framework.EventQueue; | 37 | using OpenSim.Region.CoreModules.Framework.EventQueue; |
42 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
44 | 40 | ||
45 | |||
46 | using Caps = OpenSim.Framework.Capabilities.Caps; | 41 | using Caps = OpenSim.Framework.Capabilities.Caps; |
47 | 42 | ||
48 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | 43 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups |
49 | { | 44 | { |
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
51 | public class GroupsMessagingModule : ISharedRegionModule | 46 | public class GroupsMessagingModule : ISharedRegionModule, IGroupsMessagingModule |
52 | { | 47 | { |
53 | |||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 49 | ||
56 | private List<Scene> m_sceneList = new List<Scene>(); | 50 | private List<Scene> m_sceneList = new List<Scene>(); |
@@ -108,8 +102,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
108 | 102 | ||
109 | public void AddRegion(Scene scene) | 103 | public void AddRegion(Scene scene) |
110 | { | 104 | { |
111 | // NoOp | 105 | if (!m_groupMessagingEnabled) |
106 | return; | ||
107 | |||
108 | scene.RegisterModuleInterface<IGroupsMessagingModule>(this); | ||
112 | } | 109 | } |
110 | |||
113 | public void RegionLoaded(Scene scene) | 111 | public void RegionLoaded(Scene scene) |
114 | { | 112 | { |
115 | if (!m_groupMessagingEnabled) | 113 | if (!m_groupMessagingEnabled) |
@@ -197,6 +195,73 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
197 | 195 | ||
198 | #endregion | 196 | #endregion |
199 | 197 | ||
198 | public bool StartGroupChatSession(UUID agentID, UUID groupID) | ||
199 | { | ||
200 | if (m_debugEnabled) | ||
201 | m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
202 | |||
203 | GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID); | ||
204 | |||
205 | if (groupInfo != null) | ||
206 | { | ||
207 | AddAgentToGroupSession(agentID.Guid, groupID.Guid); | ||
208 | return true; | ||
209 | } | ||
210 | else | ||
211 | { | ||
212 | return false; | ||
213 | } | ||
214 | } | ||
215 | |||
216 | public void SendMessageToGroup(GridInstantMessage im, UUID groupID) | ||
217 | { | ||
218 | if (m_debugEnabled) | ||
219 | m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
220 | |||
221 | foreach (GroupMembersData member in m_groupsModule.GroupMembersRequest(null, groupID)) | ||
222 | { | ||
223 | if (!m_agentsDroppedSession.ContainsKey(im.imSessionID) || m_agentsDroppedSession[im.imSessionID].Contains(member.AgentID.Guid)) | ||
224 | { | ||
225 | // Don't deliver messages to people who have dropped this session | ||
226 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID); | ||
227 | continue; | ||
228 | } | ||
229 | |||
230 | // Copy Message | ||
231 | GridInstantMessage msg = new GridInstantMessage(); | ||
232 | msg.imSessionID = im.imSessionID; | ||
233 | msg.fromAgentName = im.fromAgentName; | ||
234 | msg.message = im.message; | ||
235 | msg.dialog = im.dialog; | ||
236 | msg.offline = im.offline; | ||
237 | msg.ParentEstateID = im.ParentEstateID; | ||
238 | msg.Position = im.Position; | ||
239 | msg.RegionID = im.RegionID; | ||
240 | msg.binaryBucket = im.binaryBucket; | ||
241 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
242 | |||
243 | // Updat Pertinate fields to make it a "group message" | ||
244 | msg.fromAgentID = groupID.Guid; | ||
245 | msg.fromGroup = true; | ||
246 | |||
247 | msg.toAgentID = member.AgentID.Guid; | ||
248 | |||
249 | IClientAPI client = GetActiveClient(member.AgentID); | ||
250 | if (client == null) | ||
251 | { | ||
252 | // If they're not local, forward across the grid | ||
253 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID); | ||
254 | m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); | ||
255 | } | ||
256 | else | ||
257 | { | ||
258 | // Deliver locally, directly | ||
259 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); | ||
260 | ProcessMessageFromGroupSession(msg); | ||
261 | } | ||
262 | } | ||
263 | } | ||
264 | |||
200 | #region SimGridEventHandlers | 265 | #region SimGridEventHandlers |
201 | 266 | ||
202 | private void OnNewClient(IClientAPI client) | 267 | private void OnNewClient(IClientAPI client) |
@@ -370,7 +435,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
370 | m_agentsDroppedSession.Add(sessionID, new List<Guid>()); | 435 | m_agentsDroppedSession.Add(sessionID, new List<Guid>()); |
371 | } | 436 | } |
372 | } | 437 | } |
373 | 438 | ||
374 | private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) | 439 | private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) |
375 | { | 440 | { |
376 | if (m_debugEnabled) | 441 | if (m_debugEnabled) |
@@ -384,13 +449,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
384 | if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) | 449 | if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) |
385 | { | 450 | { |
386 | UUID groupID = new UUID(im.toAgentID); | 451 | UUID groupID = new UUID(im.toAgentID); |
387 | |||
388 | GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID); | 452 | GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID); |
453 | |||
389 | if (groupInfo != null) | 454 | if (groupInfo != null) |
390 | { | 455 | { |
391 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Start Group Session for {0}", groupInfo.GroupName); | 456 | AddAgentToGroupSession(im.fromAgentID, groupInfo.GroupID.Guid); |
392 | |||
393 | AddAgentToGroupSession(im.fromAgentID, im.imSessionID); | ||
394 | 457 | ||
395 | ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, groupID); | 458 | ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, groupID); |
396 | 459 | ||
@@ -411,7 +474,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
411 | { | 474 | { |
412 | UUID groupID = new UUID(im.toAgentID); | 475 | UUID groupID = new UUID(im.toAgentID); |
413 | 476 | ||
414 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", groupID, im.imSessionID.ToString()); | 477 | if (m_debugEnabled) |
478 | m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", groupID, im.imSessionID.ToString()); | ||
415 | 479 | ||
416 | SendMessageToGroup(im, groupID); | 480 | SendMessageToGroup(im, groupID); |
417 | } | 481 | } |
@@ -419,54 +483,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
419 | 483 | ||
420 | #endregion | 484 | #endregion |
421 | 485 | ||
422 | private void SendMessageToGroup(GridInstantMessage im, UUID groupID) | ||
423 | { | ||
424 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
425 | |||
426 | foreach (GroupMembersData member in m_groupsModule.GroupMembersRequest(null, groupID)) | ||
427 | { | ||
428 | if (!m_agentsDroppedSession.ContainsKey(im.imSessionID) || m_agentsDroppedSession[im.imSessionID].Contains(member.AgentID.Guid)) | ||
429 | { | ||
430 | // Don't deliver messages to people who have dropped this session | ||
431 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID); | ||
432 | continue; | ||
433 | } | ||
434 | |||
435 | // Copy Message | ||
436 | GridInstantMessage msg = new GridInstantMessage(); | ||
437 | msg.imSessionID = im.imSessionID; | ||
438 | msg.fromAgentName = im.fromAgentName; | ||
439 | msg.message = im.message; | ||
440 | msg.dialog = im.dialog; | ||
441 | msg.offline = im.offline; | ||
442 | msg.ParentEstateID = im.ParentEstateID; | ||
443 | msg.Position = im.Position; | ||
444 | msg.RegionID = im.RegionID; | ||
445 | msg.binaryBucket = im.binaryBucket; | ||
446 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
447 | |||
448 | // Updat Pertinate fields to make it a "group message" | ||
449 | msg.fromAgentID = groupID.Guid; | ||
450 | msg.fromGroup = true; | ||
451 | |||
452 | msg.toAgentID = member.AgentID.Guid; | ||
453 | |||
454 | IClientAPI client = GetActiveClient(member.AgentID); | ||
455 | if (client == null) | ||
456 | { | ||
457 | // If they're not local, forward across the grid | ||
458 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID); | ||
459 | m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); | ||
460 | } | ||
461 | else | ||
462 | { | ||
463 | // Deliver locally, directly | ||
464 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); | ||
465 | ProcessMessageFromGroupSession(msg); | ||
466 | } | ||
467 | } | ||
468 | } | ||
469 | |||
470 | void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID) | 486 | void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID) |
471 | { | 487 | { |
472 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 488 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index eb630de..6b942cb 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | |||
@@ -89,16 +89,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
89 | 89 | ||
90 | private IGroupsServicesConnector m_groupData = null; | 90 | private IGroupsServicesConnector m_groupData = null; |
91 | 91 | ||
92 | class GroupRequestIDInfo | ||
93 | { | ||
94 | public GroupRequestID RequestID = new GroupRequestID(); | ||
95 | public DateTime LastUsedTMStamp = DateTime.MinValue; | ||
96 | } | ||
97 | private Dictionary<UUID, GroupRequestIDInfo> m_clientRequestIDInfo = new Dictionary<UUID, GroupRequestIDInfo>(); | ||
98 | private const int m_clientRequestIDFlushTimeOut = 300000; // Every 5 minutes | ||
99 | private Timer m_clientRequestIDFlushTimer; | ||
100 | |||
101 | |||
102 | // Configuration settings | 92 | // Configuration settings |
103 | private bool m_groupsEnabled = false; | 93 | private bool m_groupsEnabled = false; |
104 | private bool m_groupNoticesEnabled = true; | 94 | private bool m_groupNoticesEnabled = true; |
@@ -135,30 +125,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
135 | m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); | 125 | m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); |
136 | m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); | 126 | m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); |
137 | 127 | ||
138 | m_clientRequestIDFlushTimer = new Timer(); | ||
139 | m_clientRequestIDFlushTimer.Interval = m_clientRequestIDFlushTimeOut; | ||
140 | m_clientRequestIDFlushTimer.Elapsed += FlushClientRequestIDInfoCache; | ||
141 | m_clientRequestIDFlushTimer.AutoReset = true; | ||
142 | m_clientRequestIDFlushTimer.Start(); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | void FlushClientRequestIDInfoCache(object sender, ElapsedEventArgs e) | ||
147 | { | ||
148 | lock (m_clientRequestIDInfo) | ||
149 | { | ||
150 | TimeSpan cacheTimeout = new TimeSpan(0,0, m_clientRequestIDFlushTimeOut / 1000); | ||
151 | UUID[] CurrentKeys = new UUID[m_clientRequestIDInfo.Count]; | ||
152 | foreach (UUID key in CurrentKeys) | ||
153 | { | ||
154 | if (m_clientRequestIDInfo.ContainsKey(key)) | ||
155 | { | ||
156 | if (DateTime.Now - m_clientRequestIDInfo[key].LastUsedTMStamp > cacheTimeout) | ||
157 | { | ||
158 | m_clientRequestIDInfo.Remove(key); | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | } | 128 | } |
163 | } | 129 | } |
164 | 130 | ||
@@ -236,8 +202,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
236 | return; | 202 | return; |
237 | 203 | ||
238 | if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); | 204 | if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); |
239 | |||
240 | m_clientRequestIDFlushTimer.Stop(); | ||
241 | } | 205 | } |
242 | 206 | ||
243 | public Type ReplaceableInterface | 207 | public Type ReplaceableInterface |
@@ -274,14 +238,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
274 | // Used for Notices and Group Invites/Accept/Reject | 238 | // Used for Notices and Group Invites/Accept/Reject |
275 | client.OnInstantMessage += OnInstantMessage; | 239 | client.OnInstantMessage += OnInstantMessage; |
276 | 240 | ||
277 | lock (m_clientRequestIDInfo) | 241 | // Send client thier groups information. |
278 | { | ||
279 | if (m_clientRequestIDInfo.ContainsKey(client.AgentId)) | ||
280 | { | ||
281 | // flush any old RequestID information | ||
282 | m_clientRequestIDInfo.Remove(client.AgentId); | ||
283 | } | ||
284 | } | ||
285 | SendAgentGroupDataUpdate(client, client.AgentId); | 242 | SendAgentGroupDataUpdate(client, client.AgentId); |
286 | } | 243 | } |
287 | 244 | ||
@@ -289,7 +246,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
289 | { | 246 | { |
290 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 247 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
291 | 248 | ||
292 | //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), avatarID).ToArray(); | 249 | //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray(); |
293 | GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); | 250 | GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); |
294 | remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); | 251 | remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); |
295 | } | 252 | } |
@@ -338,9 +295,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
338 | System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); | 295 | System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); |
339 | 296 | ||
340 | // TODO: This currently ignores pretty much all the query flags including Mature and sort order | 297 | // TODO: This currently ignores pretty much all the query flags including Mature and sort order |
341 | remoteClient.SendDirGroupsReply( | 298 | remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray()); |
342 | queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray()); | 299 | } |
343 | } | 300 | |
344 | } | 301 | } |
345 | 302 | ||
346 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) | 303 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) |
@@ -352,7 +309,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
352 | string activeGroupName = string.Empty; | 309 | string activeGroupName = string.Empty; |
353 | ulong activeGroupPowers = (ulong)GroupPowers.None; | 310 | ulong activeGroupPowers = (ulong)GroupPowers.None; |
354 | 311 | ||
355 | GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetClientGroupRequestID(remoteClient), dataForAgentID); | 312 | GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID); |
356 | if (membership != null) | 313 | if (membership != null) |
357 | { | 314 | { |
358 | activeGroupID = membership.GroupID; | 315 | activeGroupID = membership.GroupID; |
@@ -371,7 +328,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
371 | 328 | ||
372 | string GroupName; | 329 | string GroupName; |
373 | 330 | ||
374 | GroupRecord group = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null); | 331 | GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null); |
375 | if (group != null) | 332 | if (group != null) |
376 | { | 333 | { |
377 | GroupName = group.GroupName; | 334 | GroupName = group.GroupName; |
@@ -392,7 +349,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
392 | if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) | 349 | if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) |
393 | { | 350 | { |
394 | UUID inviteID = new UUID(im.imSessionID); | 351 | UUID inviteID = new UUID(im.imSessionID); |
395 | GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); | 352 | GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); |
396 | 353 | ||
397 | if (inviteInfo == null) | 354 | if (inviteInfo == null) |
398 | { | 355 | { |
@@ -411,7 +368,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
411 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); | 368 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); |
412 | 369 | ||
413 | // and the sessionid is the role | 370 | // and the sessionid is the role |
414 | m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); | 371 | m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); |
415 | 372 | ||
416 | GridInstantMessage msg = new GridInstantMessage(); | 373 | GridInstantMessage msg = new GridInstantMessage(); |
417 | msg.imSessionID = UUID.Zero.Guid; | 374 | msg.imSessionID = UUID.Zero.Guid; |
@@ -435,14 +392,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
435 | // TODO: If the inviter is still online, they need an agent dataupdate | 392 | // TODO: If the inviter is still online, they need an agent dataupdate |
436 | // and maybe group membership updates for the invitee | 393 | // and maybe group membership updates for the invitee |
437 | 394 | ||
438 | m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); | 395 | m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); |
439 | } | 396 | } |
440 | 397 | ||
441 | // Reject | 398 | // Reject |
442 | if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) | 399 | if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) |
443 | { | 400 | { |
444 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); | 401 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); |
445 | m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); | 402 | m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); |
446 | } | 403 | } |
447 | } | 404 | } |
448 | } | 405 | } |
@@ -456,7 +413,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
456 | } | 413 | } |
457 | 414 | ||
458 | UUID GroupID = new UUID(im.toAgentID); | 415 | UUID GroupID = new UUID(im.toAgentID); |
459 | if (m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null) != null) | 416 | if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null) != null) |
460 | { | 417 | { |
461 | UUID NoticeID = UUID.Random(); | 418 | UUID NoticeID = UUID.Random(); |
462 | string Subject = im.message.Substring(0, im.message.IndexOf('|')); | 419 | string Subject = im.message.Substring(0, im.message.IndexOf('|')); |
@@ -500,14 +457,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
500 | } | 457 | } |
501 | 458 | ||
502 | 459 | ||
503 | m_groupData.AddGroupNotice(GetClientGroupRequestID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); | 460 | m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); |
504 | if (OnNewGroupNotice != null) | 461 | if (OnNewGroupNotice != null) |
505 | { | 462 | { |
506 | OnNewGroupNotice(GroupID, NoticeID); | 463 | OnNewGroupNotice(GroupID, NoticeID); |
507 | } | 464 | } |
508 | 465 | ||
509 | // Send notice out to everyone that wants notices | 466 | // Send notice out to everyone that wants notices |
510 | foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), GroupID)) | 467 | foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), GroupID)) |
511 | { | 468 | { |
512 | if (m_debugEnabled) | 469 | if (m_debugEnabled) |
513 | { | 470 | { |
@@ -592,45 +549,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
592 | 549 | ||
593 | public GroupRecord GetGroupRecord(UUID GroupID) | 550 | public GroupRecord GetGroupRecord(UUID GroupID) |
594 | { | 551 | { |
595 | return m_groupData.GetGroupRecord(null, GroupID, null); | 552 | return m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); |
596 | } | 553 | } |
597 | 554 | ||
598 | public GroupRecord GetGroupRecord(string name) | 555 | public GroupRecord GetGroupRecord(string name) |
599 | { | 556 | { |
600 | if (m_debugEnabled) | 557 | return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name); |
601 | m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
602 | |||
603 | // XXX: Two call implementation. This could be done in a single call if the server itself were to | ||
604 | // implement the code below. | ||
605 | |||
606 | List<DirGroupsReplyData> groups = m_groupData.FindGroups(null, name); | ||
607 | |||
608 | DirGroupsReplyData? foundGroup = null; | ||
609 | |||
610 | foreach (DirGroupsReplyData group in groups) | ||
611 | { | ||
612 | // We must have an exact match - I believe FindGroups will return partial matches | ||
613 | if (group.groupName == name) | ||
614 | foundGroup = group; | ||
615 | } | ||
616 | |||
617 | if (null == foundGroup) | ||
618 | return null; | ||
619 | |||
620 | return GetGroupRecord(((DirGroupsReplyData)foundGroup).groupID); | ||
621 | } | 558 | } |
622 | 559 | ||
623 | public void ActivateGroup(IClientAPI remoteClient, UUID groupID) | 560 | public void ActivateGroup(IClientAPI remoteClient, UUID groupID) |
624 | { | 561 | { |
625 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 562 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
626 | 563 | ||
627 | m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); | 564 | m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
628 | 565 | ||
629 | // Changing active group changes title, active powers, all kinds of things | 566 | // Changing active group changes title, active powers, all kinds of things |
630 | // anyone who is in any region that can see this client, should probably be | 567 | // anyone who is in any region that can see this client, should probably be |
631 | // updated with new group info. At a minimum, they should get ScenePresence | 568 | // updated with new group info. At a minimum, they should get ScenePresence |
632 | // updated with new title. | 569 | // updated with new title. |
633 | UpdateAllClientsWithGroupInfo(remoteClient.AgentId); | 570 | UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); |
634 | } | 571 | } |
635 | 572 | ||
636 | /// <summary> | 573 | /// <summary> |
@@ -640,10 +577,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
640 | { | 577 | { |
641 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 578 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
642 | 579 | ||
643 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
644 | 580 | ||
645 | List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID); | 581 | List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
646 | GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); | 582 | GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
647 | 583 | ||
648 | List<GroupTitlesData> titles = new List<GroupTitlesData>(); | 584 | List<GroupTitlesData> titles = new List<GroupTitlesData>(); |
649 | foreach (GroupRolesData role in agentRoles) | 585 | foreach (GroupRolesData role in agentRoles) |
@@ -665,8 +601,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
665 | public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) | 601 | public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) |
666 | { | 602 | { |
667 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 603 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
668 | 604 | List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID); | |
669 | List<GroupMembersData> data = m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), groupID); | 605 | |
606 | if (m_debugEnabled) | ||
607 | { | ||
608 | foreach (GroupMembersData member in data) | ||
609 | { | ||
610 | m_log.DebugFormat("[GROUPS]: Member({0}) - IsOwner({1})", member.AgentID, member.IsOwner); | ||
611 | } | ||
612 | } | ||
670 | 613 | ||
671 | return data; | 614 | return data; |
672 | 615 | ||
@@ -676,7 +619,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
676 | { | 619 | { |
677 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 620 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
678 | 621 | ||
679 | List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID); | 622 | List<GroupRolesData> data = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID); |
680 | 623 | ||
681 | return data; | 624 | return data; |
682 | } | 625 | } |
@@ -685,8 +628,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
685 | { | 628 | { |
686 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 629 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
687 | 630 | ||
688 | List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID); | 631 | List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetRequestingAgentID(remoteClient), groupID); |
689 | 632 | ||
633 | if (m_debugEnabled) | ||
634 | { | ||
635 | foreach (GroupRoleMembersData member in data) | ||
636 | { | ||
637 | m_log.DebugFormat("[GROUPS]: Member({0}) - Role({1})", member.MemberID, member.RoleID); | ||
638 | } | ||
639 | } | ||
690 | return data; | 640 | return data; |
691 | } | 641 | } |
692 | 642 | ||
@@ -696,17 +646,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
696 | 646 | ||
697 | GroupProfileData profile = new GroupProfileData(); | 647 | GroupProfileData profile = new GroupProfileData(); |
698 | 648 | ||
699 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
700 | 649 | ||
701 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null); | 650 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); |
702 | if (groupInfo != null) | 651 | if (groupInfo != null) |
703 | { | 652 | { |
704 | profile.AllowPublish = groupInfo.AllowPublish; | 653 | profile.AllowPublish = groupInfo.AllowPublish; |
705 | profile.Charter = groupInfo.Charter; | 654 | profile.Charter = groupInfo.Charter; |
706 | profile.FounderID = groupInfo.FounderID; | 655 | profile.FounderID = groupInfo.FounderID; |
707 | profile.GroupID = groupID; | 656 | profile.GroupID = groupID; |
708 | profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count; | 657 | profile.GroupMembershipCount = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID).Count; |
709 | profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count; | 658 | profile.GroupRolesCount = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID).Count; |
710 | profile.InsigniaID = groupInfo.GroupPicture; | 659 | profile.InsigniaID = groupInfo.GroupPicture; |
711 | profile.MaturePublish = groupInfo.MaturePublish; | 660 | profile.MaturePublish = groupInfo.MaturePublish; |
712 | profile.MembershipFee = groupInfo.MembershipFee; | 661 | profile.MembershipFee = groupInfo.MembershipFee; |
@@ -717,7 +666,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
717 | profile.ShowInList = groupInfo.ShowInList; | 666 | profile.ShowInList = groupInfo.ShowInList; |
718 | } | 667 | } |
719 | 668 | ||
720 | GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); | 669 | GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
721 | if (memberInfo != null) | 670 | if (memberInfo != null) |
722 | { | 671 | { |
723 | profile.MemberTitle = memberInfo.GroupTitle; | 672 | profile.MemberTitle = memberInfo.GroupTitle; |
@@ -731,7 +680,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
731 | { | 680 | { |
732 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 681 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
733 | 682 | ||
734 | return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray(); | 683 | return m_groupData.GetAgentGroupMemberships(UUID.Zero, agentID).ToArray(); |
735 | } | 684 | } |
736 | 685 | ||
737 | public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) | 686 | public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) |
@@ -741,33 +690,30 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
741 | "[GROUPS]: {0} called with groupID={1}, agentID={2}", | 690 | "[GROUPS]: {0} called with groupID={1}, agentID={2}", |
742 | System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID); | 691 | System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID); |
743 | 692 | ||
744 | return m_groupData.GetAgentGroupMembership(null, agentID, groupID); | 693 | return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID); |
745 | } | 694 | } |
746 | 695 | ||
747 | public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) | 696 | public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) |
748 | { | 697 | { |
749 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 698 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
750 | 699 | ||
751 | // TODO: Security Check? | 700 | // Note: Permissions checking for modification rights is handled by the Groups Server/Service |
752 | 701 | m_groupData.UpdateGroup(GetRequestingAgentID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish); | |
753 | m_groupData.UpdateGroup(GetClientGroupRequestID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish); | ||
754 | } | 702 | } |
755 | 703 | ||
756 | public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) | 704 | public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) |
757 | { | 705 | { |
758 | // TODO: Security Check? | 706 | // Note: Permissions checking for modification rights is handled by the Groups Server/Service |
759 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 707 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
760 | 708 | ||
761 | m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile); | 709 | m_groupData.SetAgentGroupInfo(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, acceptNotices, listInProfile); |
762 | } | 710 | } |
763 | 711 | ||
764 | public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) | 712 | public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) |
765 | { | 713 | { |
766 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 714 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
767 | 715 | ||
768 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | 716 | if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name) != null) |
769 | |||
770 | if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null) | ||
771 | { | 717 | { |
772 | remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); | 718 | remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); |
773 | return UUID.Zero; | 719 | return UUID.Zero; |
@@ -781,14 +727,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
781 | remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); | 727 | remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); |
782 | return UUID.Zero; | 728 | return UUID.Zero; |
783 | } | 729 | } |
784 | money.ApplyGroupCreationCharge(remoteClient.AgentId); | 730 | money.ApplyGroupCreationCharge(GetRequestingAgentID(remoteClient)); |
785 | } | 731 | } |
786 | UUID groupID = m_groupData.CreateGroup(grID, name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId); | 732 | UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient)); |
787 | 733 | ||
788 | remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); | 734 | remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); |
789 | 735 | ||
790 | // Update the founder with new group information. | 736 | // Update the founder with new group information. |
791 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 737 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
792 | 738 | ||
793 | return groupID; | 739 | return groupID; |
794 | } | 740 | } |
@@ -799,7 +745,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
799 | 745 | ||
800 | // ToDo: check if agent is a member of group and is allowed to see notices? | 746 | // ToDo: check if agent is a member of group and is allowed to see notices? |
801 | 747 | ||
802 | return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray(); | 748 | return m_groupData.GetGroupNotices(GetRequestingAgentID(remoteClient), groupID).ToArray(); |
803 | } | 749 | } |
804 | 750 | ||
805 | /// <summary> | 751 | /// <summary> |
@@ -809,7 +755,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
809 | { | 755 | { |
810 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 756 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
811 | 757 | ||
812 | GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID); | 758 | GroupMembershipData membership = m_groupData.GetAgentActiveMembership(UUID.Zero, avatarID); |
813 | if (membership != null) | 759 | if (membership != null) |
814 | { | 760 | { |
815 | return membership.GroupTitle; | 761 | return membership.GroupTitle; |
@@ -824,13 +770,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
824 | { | 770 | { |
825 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 771 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
826 | 772 | ||
827 | m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID); | 773 | m_groupData.SetAgentActiveGroupRole(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, titleRoleID); |
828 | 774 | ||
829 | // TODO: Not sure what all is needed here, but if the active group role change is for the group | 775 | // TODO: Not sure what all is needed here, but if the active group role change is for the group |
830 | // the client currently has set active, then we need to do a scene presence update too | 776 | // the client currently has set active, then we need to do a scene presence update too |
831 | // if (m_groupData.GetAgentActiveMembership(remoteClient.AgentId).GroupID == GroupID) | 777 | // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID) |
832 | 778 | ||
833 | UpdateAllClientsWithGroupInfo(remoteClient.AgentId); | 779 | UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient)); |
834 | } | 780 | } |
835 | 781 | ||
836 | 782 | ||
@@ -840,16 +786,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
840 | 786 | ||
841 | // Security Checks are handled in the Groups Service. | 787 | // Security Checks are handled in the Groups Service. |
842 | 788 | ||
843 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
844 | |||
845 | switch ((OpenMetaverse.GroupRoleUpdate)updateType) | 789 | switch ((OpenMetaverse.GroupRoleUpdate)updateType) |
846 | { | 790 | { |
847 | case OpenMetaverse.GroupRoleUpdate.Create: | 791 | case OpenMetaverse.GroupRoleUpdate.Create: |
848 | m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers); | 792 | m_groupData.AddGroupRole(GetRequestingAgentID(remoteClient), groupID, UUID.Random(), name, description, title, powers); |
849 | break; | 793 | break; |
850 | 794 | ||
851 | case OpenMetaverse.GroupRoleUpdate.Delete: | 795 | case OpenMetaverse.GroupRoleUpdate.Delete: |
852 | m_groupData.RemoveGroupRole(grID, groupID, roleID); | 796 | m_groupData.RemoveGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID); |
853 | break; | 797 | break; |
854 | 798 | ||
855 | case OpenMetaverse.GroupRoleUpdate.UpdateAll: | 799 | case OpenMetaverse.GroupRoleUpdate.UpdateAll: |
@@ -860,7 +804,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
860 | GroupPowers gp = (GroupPowers)powers; | 804 | GroupPowers gp = (GroupPowers)powers; |
861 | m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString()); | 805 | m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString()); |
862 | } | 806 | } |
863 | m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers); | 807 | m_groupData.UpdateGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID, name, description, title, powers); |
864 | break; | 808 | break; |
865 | 809 | ||
866 | case OpenMetaverse.GroupRoleUpdate.NoUpdate: | 810 | case OpenMetaverse.GroupRoleUpdate.NoUpdate: |
@@ -871,7 +815,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
871 | } | 815 | } |
872 | 816 | ||
873 | // TODO: This update really should send out updates for everyone in the role that just got changed. | 817 | // TODO: This update really should send out updates for everyone in the role that just got changed. |
874 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 818 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
875 | } | 819 | } |
876 | 820 | ||
877 | public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) | 821 | public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) |
@@ -879,18 +823,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
879 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 823 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
880 | // Todo: Security check | 824 | // Todo: Security check |
881 | 825 | ||
882 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
883 | |||
884 | switch (changes) | 826 | switch (changes) |
885 | { | 827 | { |
886 | case 0: | 828 | case 0: |
887 | // Add | 829 | // Add |
888 | m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID); | 830 | m_groupData.AddAgentToGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID); |
889 | 831 | ||
890 | break; | 832 | break; |
891 | case 1: | 833 | case 1: |
892 | // Remove | 834 | // Remove |
893 | m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID); | 835 | m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID); |
894 | 836 | ||
895 | break; | 837 | break; |
896 | default: | 838 | default: |
@@ -899,25 +841,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
899 | } | 841 | } |
900 | 842 | ||
901 | // TODO: This update really should send out updates for everyone in the role that just got changed. | 843 | // TODO: This update really should send out updates for everyone in the role that just got changed. |
902 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 844 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
903 | } | 845 | } |
904 | 846 | ||
905 | public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) | 847 | public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) |
906 | { | 848 | { |
907 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 849 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
908 | 850 | ||
909 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | 851 | GroupNoticeInfo data = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), groupNoticeID); |
910 | |||
911 | GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID); | ||
912 | 852 | ||
913 | if (data != null) | 853 | if (data != null) |
914 | { | 854 | { |
915 | GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null); | 855 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null); |
916 | 856 | ||
917 | GridInstantMessage msg = new GridInstantMessage(); | 857 | GridInstantMessage msg = new GridInstantMessage(); |
918 | msg.imSessionID = UUID.Zero.Guid; | 858 | msg.imSessionID = UUID.Zero.Guid; |
919 | msg.fromAgentID = data.GroupID.Guid; | 859 | msg.fromAgentID = data.GroupID.Guid; |
920 | msg.toAgentID = remoteClient.AgentId.Guid; | 860 | msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; |
921 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | 861 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); |
922 | msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; | 862 | msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; |
923 | msg.message = data.noticeData.Subject + "|" + data.Message; | 863 | msg.message = data.noticeData.Subject + "|" + data.Message; |
@@ -929,7 +869,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
929 | msg.RegionID = UUID.Zero.Guid; | 869 | msg.RegionID = UUID.Zero.Guid; |
930 | msg.binaryBucket = data.BinaryBucket; | 870 | msg.binaryBucket = data.BinaryBucket; |
931 | 871 | ||
932 | OutgoingInstantMessage(msg, remoteClient.AgentId); | 872 | OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); |
933 | } | 873 | } |
934 | 874 | ||
935 | } | 875 | } |
@@ -949,7 +889,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
949 | msg.Position = Vector3.Zero; | 889 | msg.Position = Vector3.Zero; |
950 | msg.RegionID = UUID.Zero.Guid; | 890 | msg.RegionID = UUID.Zero.Guid; |
951 | 891 | ||
952 | GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID); | 892 | GroupNoticeInfo info = m_groupData.GetGroupNotice(agentID, groupNoticeID); |
953 | if (info != null) | 893 | if (info != null) |
954 | { | 894 | { |
955 | msg.fromAgentID = info.GroupID.Guid; | 895 | msg.fromAgentID = info.GroupID.Guid; |
@@ -976,7 +916,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
976 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 916 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
977 | 917 | ||
978 | // Send agent information about his groups | 918 | // Send agent information about his groups |
979 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 919 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
980 | } | 920 | } |
981 | 921 | ||
982 | public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) | 922 | public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) |
@@ -984,19 +924,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
984 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 924 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
985 | 925 | ||
986 | // Should check to see if OpenEnrollment, or if there's an outstanding invitation | 926 | // Should check to see if OpenEnrollment, or if there's an outstanding invitation |
987 | m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero); | 927 | m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero); |
988 | 928 | ||
989 | remoteClient.SendJoinGroupReply(groupID, true); | 929 | remoteClient.SendJoinGroupReply(groupID, true); |
990 | 930 | ||
991 | // Should this send updates to everyone in the group? | 931 | // Should this send updates to everyone in the group? |
992 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 932 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
993 | } | 933 | } |
994 | 934 | ||
995 | public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) | 935 | public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) |
996 | { | 936 | { |
997 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 937 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
998 | 938 | ||
999 | m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); | 939 | m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); |
1000 | 940 | ||
1001 | remoteClient.SendLeaveGroupReply(groupID, true); | 941 | remoteClient.SendLeaveGroupReply(groupID, true); |
1002 | 942 | ||
@@ -1004,33 +944,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1004 | 944 | ||
1005 | // SL sends out notifcations to the group messaging session that the person has left | 945 | // SL sends out notifcations to the group messaging session that the person has left |
1006 | // Should this also update everyone who is in the group? | 946 | // Should this also update everyone who is in the group? |
1007 | SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); | 947 | SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); |
1008 | } | 948 | } |
1009 | 949 | ||
1010 | public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) | 950 | public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) |
1011 | { | 951 | { |
1012 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 952 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
1013 | 953 | ||
1014 | GroupRequestID grID = GetClientGroupRequestID(remoteClient); | ||
1015 | 954 | ||
1016 | // Todo: Security check? | 955 | // Todo: Security check? |
1017 | m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID); | 956 | m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID); |
1018 | 957 | ||
1019 | remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); | 958 | remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true); |
959 | |||
960 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); | ||
1020 | 961 | ||
1021 | GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null); | ||
1022 | UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID); | 962 | UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID); |
1023 | if ((groupInfo == null) || (account == null)) | 963 | if ((groupInfo == null) || (account == null)) |
1024 | { | 964 | { |
1025 | return; | 965 | return; |
1026 | } | 966 | } |
1027 | |||
1028 | 967 | ||
1029 | // Send Message to Ejectee | 968 | // Send Message to Ejectee |
1030 | GridInstantMessage msg = new GridInstantMessage(); | 969 | GridInstantMessage msg = new GridInstantMessage(); |
1031 | 970 | ||
1032 | msg.imSessionID = UUID.Zero.Guid; | 971 | msg.imSessionID = UUID.Zero.Guid; |
1033 | msg.fromAgentID = remoteClient.AgentId.Guid; | 972 | msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; |
1034 | // msg.fromAgentID = info.GroupID; | 973 | // msg.fromAgentID = info.GroupID; |
1035 | msg.toAgentID = ejecteeID.Guid; | 974 | msg.toAgentID = ejecteeID.Guid; |
1036 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | 975 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); |
@@ -1056,8 +995,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1056 | 995 | ||
1057 | msg = new GridInstantMessage(); | 996 | msg = new GridInstantMessage(); |
1058 | msg.imSessionID = UUID.Zero.Guid; | 997 | msg.imSessionID = UUID.Zero.Guid; |
1059 | msg.fromAgentID = remoteClient.AgentId.Guid; | 998 | msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; |
1060 | msg.toAgentID = remoteClient.AgentId.Guid; | 999 | msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; |
1061 | msg.timestamp = 0; | 1000 | msg.timestamp = 0; |
1062 | msg.fromAgentName = remoteClient.Name; | 1001 | msg.fromAgentName = remoteClient.Name; |
1063 | if (account != null) | 1002 | if (account != null) |
@@ -1075,7 +1014,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1075 | msg.Position = Vector3.Zero; | 1014 | msg.Position = Vector3.Zero; |
1076 | msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; | 1015 | msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; |
1077 | msg.binaryBucket = new byte[0]; | 1016 | msg.binaryBucket = new byte[0]; |
1078 | OutgoingInstantMessage(msg, remoteClient.AgentId); | 1017 | OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); |
1079 | 1018 | ||
1080 | 1019 | ||
1081 | // SL sends out messages to everyone in the group | 1020 | // SL sends out messages to everyone in the group |
@@ -1089,13 +1028,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1089 | 1028 | ||
1090 | // Todo: Security check, probably also want to send some kind of notification | 1029 | // Todo: Security check, probably also want to send some kind of notification |
1091 | UUID InviteID = UUID.Random(); | 1030 | UUID InviteID = UUID.Random(); |
1092 | GroupRequestID grid = GetClientGroupRequestID(remoteClient); | ||
1093 | 1031 | ||
1094 | m_groupData.AddAgentToGroupInvite(grid, InviteID, groupID, roleID, invitedAgentID); | 1032 | m_groupData.AddAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID, groupID, roleID, invitedAgentID); |
1095 | 1033 | ||
1096 | // Check to see if the invite went through, if it did not then it's possible | 1034 | // Check to see if the invite went through, if it did not then it's possible |
1097 | // the remoteClient did not validate or did not have permission to invite. | 1035 | // the remoteClient did not validate or did not have permission to invite. |
1098 | GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(grid, InviteID); | 1036 | GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID); |
1099 | 1037 | ||
1100 | if (inviteInfo != null) | 1038 | if (inviteInfo != null) |
1101 | { | 1039 | { |
@@ -1107,7 +1045,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1107 | 1045 | ||
1108 | msg.imSessionID = inviteUUID; | 1046 | msg.imSessionID = inviteUUID; |
1109 | 1047 | ||
1110 | // msg.fromAgentID = remoteClient.AgentId.Guid; | 1048 | // msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; |
1111 | msg.fromAgentID = groupID.Guid; | 1049 | msg.fromAgentID = groupID.Guid; |
1112 | msg.toAgentID = invitedAgentID.Guid; | 1050 | msg.toAgentID = invitedAgentID.Guid; |
1113 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | 1051 | //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); |
@@ -1160,57 +1098,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1160 | return child; | 1098 | return child; |
1161 | } | 1099 | } |
1162 | 1100 | ||
1163 | private GroupRequestID GetClientGroupRequestID(IClientAPI client) | ||
1164 | { | ||
1165 | if (client == null) | ||
1166 | { | ||
1167 | return new GroupRequestID(); | ||
1168 | } | ||
1169 | |||
1170 | lock (m_clientRequestIDInfo) | ||
1171 | { | ||
1172 | if (!m_clientRequestIDInfo.ContainsKey(client.AgentId)) | ||
1173 | { | ||
1174 | GroupRequestIDInfo info = new GroupRequestIDInfo(); | ||
1175 | info.RequestID.AgentID = client.AgentId; | ||
1176 | info.RequestID.SessionID = client.SessionId; | ||
1177 | |||
1178 | //UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId); | ||
1179 | UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId); | ||
1180 | if (account == null) | ||
1181 | { | ||
1182 | // This should be impossible. If I've been passed a reference to a client | ||
1183 | // that client should be registered with the UserService. So something | ||
1184 | // is horribly wrong somewhere. | ||
1185 | |||
1186 | m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId); | ||
1187 | |||
1188 | // Default to local user service and hope for the best? | ||
1189 | // REFACTORING PROBLEM | ||
1190 | //info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL; | ||
1191 | |||
1192 | } | ||
1193 | else | ||
1194 | { | ||
1195 | string domain = string.Empty; //m_sceneList[0].CommsManager.NetworkServersInfo.UserURL; | ||
1196 | object homeUriObj; | ||
1197 | if (account.ServiceURLs.TryGetValue("HomeURI", out homeUriObj) && homeUriObj != null) | ||
1198 | domain = homeUriObj.ToString(); | ||
1199 | // They're a local user, use this: | ||
1200 | info.RequestID.UserServiceURL = domain; | ||
1201 | } | ||
1202 | |||
1203 | m_clientRequestIDInfo.Add(client.AgentId, info); | ||
1204 | } | ||
1205 | |||
1206 | m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now; | ||
1207 | |||
1208 | return m_clientRequestIDInfo[client.AgentId].RequestID; | ||
1209 | } | ||
1210 | // Unreachable code! | ||
1211 | // return new GroupRequestID(); | ||
1212 | } | ||
1213 | |||
1214 | /// <summary> | 1101 | /// <summary> |
1215 | /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. | 1102 | /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. |
1216 | /// </summary> | 1103 | /// </summary> |
@@ -1229,7 +1116,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1229 | 1116 | ||
1230 | foreach (GroupMembershipData membership in data) | 1117 | foreach (GroupMembershipData membership in data) |
1231 | { | 1118 | { |
1232 | if (remoteClient.AgentId != dataForAgentID) | 1119 | if (GetRequestingAgentID(remoteClient) != dataForAgentID) |
1233 | { | 1120 | { |
1234 | if (!membership.ListInProfile) | 1121 | if (!membership.ListInProfile) |
1235 | { | 1122 | { |
@@ -1257,13 +1144,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1257 | OSDMap llDataStruct = new OSDMap(3); | 1144 | OSDMap llDataStruct = new OSDMap(3); |
1258 | llDataStruct.Add("AgentData", AgentData); | 1145 | llDataStruct.Add("AgentData", AgentData); |
1259 | llDataStruct.Add("GroupData", GroupData); | 1146 | llDataStruct.Add("GroupData", GroupData); |
1260 | llDataStruct.Add("NewGroupData", NewGroupData); | 1147 | llDataStruct.Add("NewGroupData", NewGroupData); |
1148 | |||
1149 | if (m_debugEnabled) | ||
1150 | { | ||
1151 | m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct)); | ||
1152 | } | ||
1261 | 1153 | ||
1262 | IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); | 1154 | IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); |
1263 | 1155 | ||
1264 | if (queue != null) | 1156 | if (queue != null) |
1265 | { | 1157 | { |
1266 | queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), remoteClient.AgentId); | 1158 | queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient)); |
1267 | } | 1159 | } |
1268 | 1160 | ||
1269 | } | 1161 | } |
@@ -1336,7 +1228,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1336 | /// <returns></returns> | 1228 | /// <returns></returns> |
1337 | private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) | 1229 | private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) |
1338 | { | 1230 | { |
1339 | List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(requestingClient), dataForAgentID); | 1231 | List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(requestingClient.AgentId, dataForAgentID); |
1340 | GroupMembershipData[] membershipArray; | 1232 | GroupMembershipData[] membershipArray; |
1341 | 1233 | ||
1342 | if (requestingClient.AgentId != dataForAgentID) | 1234 | if (requestingClient.AgentId != dataForAgentID) |
@@ -1358,7 +1250,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1358 | m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); | 1250 | m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); |
1359 | foreach (GroupMembershipData membership in membershipArray) | 1251 | foreach (GroupMembershipData membership in membershipArray) |
1360 | { | 1252 | { |
1361 | m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2}", dataForAgentID, membership.GroupName, membership.GroupTitle); | 1253 | m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2} - {3}", dataForAgentID, membership.GroupName, membership.GroupTitle, membership.GroupPowers); |
1362 | } | 1254 | } |
1363 | } | 1255 | } |
1364 | 1256 | ||
@@ -1416,7 +1308,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1416 | // | 1308 | // |
1417 | } | 1309 | } |
1418 | 1310 | ||
1419 | #endregion | 1311 | #endregion |
1312 | |||
1313 | private UUID GetRequestingAgentID(IClientAPI client) | ||
1314 | { | ||
1315 | UUID requestingAgentID = UUID.Zero; | ||
1316 | if (client != null) | ||
1317 | { | ||
1318 | requestingAgentID = client.AgentId; | ||
1319 | } | ||
1320 | return requestingAgentID; | ||
1321 | } | ||
1420 | } | 1322 | } |
1421 | 1323 | ||
1324 | public class GroupNoticeInfo | ||
1325 | { | ||
1326 | public GroupNoticeData noticeData = new GroupNoticeData(); | ||
1327 | public UUID GroupID = UUID.Zero; | ||
1328 | public string Message = string.Empty; | ||
1329 | public byte[] BinaryBucket = new byte[0]; | ||
1330 | } | ||
1422 | } | 1331 | } |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs index 621ab28..6487967 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs | |||
@@ -36,41 +36,41 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
36 | { | 36 | { |
37 | interface IGroupsServicesConnector | 37 | interface IGroupsServicesConnector |
38 | { | 38 | { |
39 | UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID); | 39 | UUID CreateGroup(UUID RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID); |
40 | void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); | 40 | void UpdateGroup(UUID RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); |
41 | GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName); | 41 | GroupRecord GetGroupRecord(UUID RequestingAgentID, UUID GroupID, string GroupName); |
42 | List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search); | 42 | List<DirGroupsReplyData> FindGroups(UUID RequestingAgentID, string search); |
43 | List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID); | 43 | List<GroupMembersData> GetGroupMembers(UUID RequestingAgentID, UUID GroupID); |
44 | 44 | ||
45 | void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); | 45 | void AddGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); |
46 | void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); | 46 | void UpdateGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); |
47 | void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID); | 47 | void RemoveGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID); |
48 | List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID); | 48 | List<GroupRolesData> GetGroupRoles(UUID RequestingAgentID, UUID GroupID); |
49 | List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID); | 49 | List<GroupRoleMembersData> GetGroupRoleMembers(UUID RequestingAgentID, UUID GroupID); |
50 | 50 | ||
51 | void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); | 51 | void AddAgentToGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID); |
52 | void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID); | 52 | void RemoveAgentFromGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID); |
53 | 53 | ||
54 | void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID); | 54 | void AddAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID); |
55 | GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID); | 55 | GroupInviteInfo GetAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID); |
56 | void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID); | 56 | void RemoveAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID); |
57 | 57 | ||
58 | void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); | 58 | void AddAgentToGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID); |
59 | void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); | 59 | void RemoveAgentFromGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID); |
60 | List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID); | 60 | List<GroupRolesData> GetAgentGroupRoles(UUID RequestingAgentID, UUID AgentID, UUID GroupID); |
61 | 61 | ||
62 | void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID); | 62 | void SetAgentActiveGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID); |
63 | GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID); | 63 | GroupMembershipData GetAgentActiveMembership(UUID RequestingAgentID, UUID AgentID); |
64 | 64 | ||
65 | void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); | 65 | void SetAgentActiveGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID); |
66 | void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile); | 66 | void SetAgentGroupInfo(UUID RequestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile); |
67 | 67 | ||
68 | GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID); | 68 | GroupMembershipData GetAgentGroupMembership(UUID RequestingAgentID, UUID AgentID, UUID GroupID); |
69 | List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID); | 69 | List<GroupMembershipData> GetAgentGroupMemberships(UUID RequestingAgentID, UUID AgentID); |
70 | 70 | ||
71 | void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); | 71 | void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); |
72 | GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID); | 72 | GroupNoticeInfo GetGroupNotice(UUID RequestingAgentID, UUID noticeID); |
73 | List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID); | 73 | List<GroupNoticeData> GetGroupNotices(UUID RequestingAgentID, UUID GroupID); |
74 | } | 74 | } |
75 | 75 | ||
76 | public class GroupInviteInfo | 76 | public class GroupInviteInfo |
@@ -80,11 +80,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
80 | public UUID AgentID = UUID.Zero; | 80 | public UUID AgentID = UUID.Zero; |
81 | public UUID InviteID = UUID.Zero; | 81 | public UUID InviteID = UUID.Zero; |
82 | } | 82 | } |
83 | |||
84 | public class GroupRequestID | ||
85 | { | ||
86 | public UUID AgentID = UUID.Zero; | ||
87 | public string UserServiceURL = string.Empty; | ||
88 | public UUID SessionID = UUID.Zero; | ||
89 | } | ||
90 | } | 83 | } |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs new file mode 100644 index 0000000..590753e --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs | |||
@@ -0,0 +1,1278 @@ | |||
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.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Collections.Specialized; | ||
32 | using System.Reflection; | ||
33 | |||
34 | using Nwc.XmlRpc; | ||
35 | |||
36 | using log4net; | ||
37 | using Mono.Addins; | ||
38 | using Nini.Config; | ||
39 | |||
40 | using OpenMetaverse; | ||
41 | using OpenMetaverse.StructuredData; | ||
42 | |||
43 | using OpenSim.Framework; | ||
44 | using OpenSim.Framework.Communications; | ||
45 | using OpenSim.Region.Framework.Interfaces; | ||
46 | using OpenSim.Services.Interfaces; | ||
47 | |||
48 | /*************************************************************************** | ||
49 | * Simian Data Map | ||
50 | * =============== | ||
51 | * | ||
52 | * OwnerID -> Type -> Key | ||
53 | * ----------------------- | ||
54 | * | ||
55 | * UserID -> Group -> ActiveGroup | ||
56 | * + GroupID | ||
57 | * | ||
58 | * UserID -> GroupMember -> GroupID | ||
59 | * + SelectedRoleID [UUID] | ||
60 | * + AcceptNotices [bool] | ||
61 | * + ListInProfile [bool] | ||
62 | * + Contribution [int] | ||
63 | * | ||
64 | * UserID -> GroupRole[GroupID] -> RoleID | ||
65 | * | ||
66 | * GroupID -> Group -> GroupName | ||
67 | * + Charter | ||
68 | * + ShowInList | ||
69 | * + InsigniaID | ||
70 | * + MembershipFee | ||
71 | * + OpenEnrollment | ||
72 | * + AllowPublish | ||
73 | * + MaturePublish | ||
74 | * + FounderID | ||
75 | * + EveryonePowers | ||
76 | * + OwnerRoleID | ||
77 | * + OwnersPowers | ||
78 | * | ||
79 | * GroupID -> GroupRole -> RoleID | ||
80 | * + Name | ||
81 | * + Description | ||
82 | * + Title | ||
83 | * + Powers | ||
84 | * | ||
85 | * GroupID -> GroupMemberInvite -> InviteID | ||
86 | * + AgentID | ||
87 | * + RoleID | ||
88 | * | ||
89 | * GroupID -> GroupNotice -> NoticeID | ||
90 | * + TimeStamp [uint] | ||
91 | * + FromName [string] | ||
92 | * + Subject [string] | ||
93 | * + Message [string] | ||
94 | * + BinaryBucket [byte[]] | ||
95 | * | ||
96 | * */ | ||
97 | |||
98 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | ||
99 | { | ||
100 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
101 | public class SimianGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector | ||
102 | { | ||
103 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
104 | |||
105 | public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | | ||
106 | GroupPowers.Accountable | | ||
107 | GroupPowers.JoinChat | | ||
108 | GroupPowers.AllowVoiceChat | | ||
109 | GroupPowers.ReceiveNotices | | ||
110 | GroupPowers.StartProposal | | ||
111 | GroupPowers.VoteOnProposal; | ||
112 | |||
113 | // Would this be cleaner as (GroupPowers)ulong.MaxValue; | ||
114 | public const GroupPowers m_DefaultOwnerPowers = GroupPowers.Accountable | ||
115 | | GroupPowers.AllowEditLand | ||
116 | | GroupPowers.AllowFly | ||
117 | | GroupPowers.AllowLandmark | ||
118 | | GroupPowers.AllowRez | ||
119 | | GroupPowers.AllowSetHome | ||
120 | | GroupPowers.AllowVoiceChat | ||
121 | | GroupPowers.AssignMember | ||
122 | | GroupPowers.AssignMemberLimited | ||
123 | | GroupPowers.ChangeActions | ||
124 | | GroupPowers.ChangeIdentity | ||
125 | | GroupPowers.ChangeMedia | ||
126 | | GroupPowers.ChangeOptions | ||
127 | | GroupPowers.CreateRole | ||
128 | | GroupPowers.DeedObject | ||
129 | | GroupPowers.DeleteRole | ||
130 | | GroupPowers.Eject | ||
131 | | GroupPowers.FindPlaces | ||
132 | | GroupPowers.Invite | ||
133 | | GroupPowers.JoinChat | ||
134 | | GroupPowers.LandChangeIdentity | ||
135 | | GroupPowers.LandDeed | ||
136 | | GroupPowers.LandDivideJoin | ||
137 | | GroupPowers.LandEdit | ||
138 | | GroupPowers.LandEjectAndFreeze | ||
139 | | GroupPowers.LandGardening | ||
140 | | GroupPowers.LandManageAllowed | ||
141 | | GroupPowers.LandManageBanned | ||
142 | | GroupPowers.LandManagePasses | ||
143 | | GroupPowers.LandOptions | ||
144 | | GroupPowers.LandRelease | ||
145 | | GroupPowers.LandSetSale | ||
146 | | GroupPowers.ModerateChat | ||
147 | | GroupPowers.ObjectManipulate | ||
148 | | GroupPowers.ObjectSetForSale | ||
149 | | GroupPowers.ReceiveNotices | ||
150 | | GroupPowers.RemoveMember | ||
151 | | GroupPowers.ReturnGroupOwned | ||
152 | | GroupPowers.ReturnGroupSet | ||
153 | | GroupPowers.ReturnNonGroup | ||
154 | | GroupPowers.RoleProperties | ||
155 | | GroupPowers.SendNotices | ||
156 | | GroupPowers.SetLandingPoint | ||
157 | | GroupPowers.StartProposal | ||
158 | | GroupPowers.VoteOnProposal; | ||
159 | |||
160 | private bool m_connectorEnabled = false; | ||
161 | |||
162 | private string m_serviceURL = string.Empty; | ||
163 | |||
164 | private bool m_debugEnabled = false; | ||
165 | |||
166 | // private IUserAccountService m_accountService = null; | ||
167 | |||
168 | |||
169 | #region IRegionModuleBase Members | ||
170 | |||
171 | public string Name | ||
172 | { | ||
173 | get { return "SimianGroupsServicesConnector"; } | ||
174 | } | ||
175 | |||
176 | // this module is not intended to be replaced, but there should only be 1 of them. | ||
177 | public Type ReplaceableInterface | ||
178 | { | ||
179 | get { return null; } | ||
180 | } | ||
181 | |||
182 | public void Initialise(IConfigSource config) | ||
183 | { | ||
184 | IConfig groupsConfig = config.Configs["Groups"]; | ||
185 | |||
186 | if (groupsConfig == null) | ||
187 | { | ||
188 | // Do not run this module by default. | ||
189 | return; | ||
190 | } | ||
191 | else | ||
192 | { | ||
193 | // if groups aren't enabled, we're not needed. | ||
194 | // if we're not specified as the connector to use, then we're not wanted | ||
195 | if ((groupsConfig.GetBoolean("Enabled", false) == false) | ||
196 | || (groupsConfig.GetString("ServicesConnectorModule", "Default") != Name)) | ||
197 | { | ||
198 | m_connectorEnabled = false; | ||
199 | return; | ||
200 | } | ||
201 | |||
202 | m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); | ||
203 | |||
204 | m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty); | ||
205 | if ((m_serviceURL == null) || | ||
206 | (m_serviceURL == string.Empty)) | ||
207 | { | ||
208 | m_log.ErrorFormat("Please specify a valid Simian Server URL for XmlRpcServiceURL in OpenSim.ini, [Groups]"); | ||
209 | m_connectorEnabled = false; | ||
210 | return; | ||
211 | } | ||
212 | |||
213 | // If we got all the config options we need, lets start'er'up | ||
214 | m_connectorEnabled = true; | ||
215 | |||
216 | m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); | ||
217 | |||
218 | } | ||
219 | } | ||
220 | |||
221 | public void Close() | ||
222 | { | ||
223 | m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name); | ||
224 | } | ||
225 | |||
226 | public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) | ||
227 | { | ||
228 | if (m_connectorEnabled) | ||
229 | { | ||
230 | scene.RegisterModuleInterface<IGroupsServicesConnector>(this); | ||
231 | } | ||
232 | } | ||
233 | |||
234 | public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene) | ||
235 | { | ||
236 | if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this) | ||
237 | { | ||
238 | scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); | ||
239 | } | ||
240 | } | ||
241 | |||
242 | public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene) | ||
243 | { | ||
244 | // TODO: May want to consider listenning for Agent Connections so we can pre-cache group info | ||
245 | // scene.EventManager.OnNewClient += OnNewClient; | ||
246 | } | ||
247 | |||
248 | #endregion | ||
249 | |||
250 | #region ISharedRegionModule Members | ||
251 | |||
252 | public void PostInitialise() | ||
253 | { | ||
254 | // NoOp | ||
255 | } | ||
256 | |||
257 | #endregion | ||
258 | |||
259 | |||
260 | |||
261 | |||
262 | #region IGroupsServicesConnector Members | ||
263 | |||
264 | /// <summary> | ||
265 | /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role. | ||
266 | /// </summary> | ||
267 | public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID, | ||
268 | int membershipFee, bool openEnrollment, bool allowPublish, | ||
269 | bool maturePublish, UUID founderID) | ||
270 | { | ||
271 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
272 | |||
273 | UUID GroupID = UUID.Random(); | ||
274 | UUID OwnerRoleID = UUID.Random(); | ||
275 | |||
276 | OSDMap GroupInfoMap = new OSDMap(); | ||
277 | GroupInfoMap["Charter"] = OSD.FromString(charter); | ||
278 | GroupInfoMap["ShowInList"] = OSD.FromBoolean(showInList); | ||
279 | GroupInfoMap["InsigniaID"] = OSD.FromUUID(insigniaID); | ||
280 | GroupInfoMap["MembershipFee"] = OSD.FromInteger(0); | ||
281 | GroupInfoMap["OpenEnrollment"] = OSD.FromBoolean(openEnrollment); | ||
282 | GroupInfoMap["AllowPublish"] = OSD.FromBoolean(allowPublish); | ||
283 | GroupInfoMap["MaturePublish"] = OSD.FromBoolean(maturePublish); | ||
284 | GroupInfoMap["FounderID"] = OSD.FromUUID(founderID); | ||
285 | GroupInfoMap["EveryonePowers"] = OSD.FromULong((ulong)m_DefaultEveryonePowers); | ||
286 | GroupInfoMap["OwnerRoleID"] = OSD.FromUUID(OwnerRoleID); | ||
287 | GroupInfoMap["OwnersPowers"] = OSD.FromULong((ulong)m_DefaultOwnerPowers); | ||
288 | |||
289 | if(SimianAddGeneric(GroupID, "Group", name, GroupInfoMap)) | ||
290 | { | ||
291 | AddGroupRole(requestingAgentID, GroupID, UUID.Zero, "Everyone", "Members of " + name, "Member of " + name, (ulong)m_DefaultEveryonePowers); | ||
292 | AddGroupRole(requestingAgentID, GroupID, OwnerRoleID, "Owners", "Owners of " + name, "Owner of " + name, (ulong)m_DefaultOwnerPowers); | ||
293 | |||
294 | AddAgentToGroup(requestingAgentID, requestingAgentID, GroupID, OwnerRoleID); | ||
295 | |||
296 | return GroupID; | ||
297 | } | ||
298 | else | ||
299 | { | ||
300 | return UUID.Zero; | ||
301 | } | ||
302 | } | ||
303 | |||
304 | |||
305 | public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, | ||
306 | UUID insigniaID, int membershipFee, bool openEnrollment, | ||
307 | bool allowPublish, bool maturePublish) | ||
308 | { | ||
309 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
310 | // TODO: Check to make sure requestingAgentID has permission to update group | ||
311 | |||
312 | string GroupName; | ||
313 | OSDMap GroupInfoMap; | ||
314 | if( SimianGetFirstGenericEntry(groupID, "GroupInfo", out GroupName, out GroupInfoMap) ) | ||
315 | { | ||
316 | GroupInfoMap["Charter"] = OSD.FromString(charter); | ||
317 | GroupInfoMap["ShowInList"] = OSD.FromBoolean(showInList); | ||
318 | GroupInfoMap["InsigniaID"] = OSD.FromUUID(insigniaID); | ||
319 | GroupInfoMap["MembershipFee"] = OSD.FromInteger(0); | ||
320 | GroupInfoMap["OpenEnrollment"] = OSD.FromBoolean(openEnrollment); | ||
321 | GroupInfoMap["AllowPublish"] = OSD.FromBoolean(allowPublish); | ||
322 | GroupInfoMap["MaturePublish"] = OSD.FromBoolean(maturePublish); | ||
323 | |||
324 | SimianAddGeneric(groupID, "Group", GroupName, GroupInfoMap); | ||
325 | } | ||
326 | |||
327 | } | ||
328 | |||
329 | |||
330 | public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, | ||
331 | string title, ulong powers) | ||
332 | { | ||
333 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
334 | |||
335 | OSDMap GroupRoleInfo = new OSDMap(); | ||
336 | GroupRoleInfo["Name"] = OSD.FromString(name); | ||
337 | GroupRoleInfo["Description"] = OSD.FromString(description); | ||
338 | GroupRoleInfo["Title"] = OSD.FromString(title); | ||
339 | GroupRoleInfo["Powers"] = OSD.FromULong((ulong)powers); | ||
340 | |||
341 | // TODO: Add security, make sure that requestingAgentID has permision to add roles | ||
342 | SimianAddGeneric(groupID, "GroupRole", roleID.ToString(), GroupRoleInfo); | ||
343 | } | ||
344 | |||
345 | public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID) | ||
346 | { | ||
347 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
348 | |||
349 | // TODO: Add security | ||
350 | |||
351 | // Can't delete the Everyone Role | ||
352 | if (roleID != UUID.Zero) | ||
353 | { | ||
354 | // Remove all GroupRole Members from Role | ||
355 | Dictionary<UUID, OSDMap> GroupRoleMembers; | ||
356 | string GroupRoleMemberType = "GroupRole" + groupID.ToString(); | ||
357 | if (SimianGetGenericEntries(GroupRoleMemberType, roleID.ToString(), out GroupRoleMembers)) | ||
358 | { | ||
359 | foreach(UUID UserID in GroupRoleMembers.Keys) | ||
360 | { | ||
361 | EnsureRoleNotSelectedByMember(groupID, roleID, UserID); | ||
362 | |||
363 | SimianRemoveGenericEntry(UserID, GroupRoleMemberType, roleID.ToString()); | ||
364 | } | ||
365 | } | ||
366 | |||
367 | // Remove role | ||
368 | SimianRemoveGenericEntry(groupID, "GroupRole", roleID.ToString()); | ||
369 | } | ||
370 | } | ||
371 | |||
372 | |||
373 | public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, | ||
374 | string title, ulong powers) | ||
375 | { | ||
376 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
377 | |||
378 | // TODO: Security, check that requestingAgentID is allowed to update group roles | ||
379 | |||
380 | OSDMap GroupRoleInfo; | ||
381 | if (SimianGetGenericEntry(groupID, "GroupRole", roleID.ToString(), out GroupRoleInfo)) | ||
382 | { | ||
383 | if (name != null) | ||
384 | { | ||
385 | GroupRoleInfo["Name"] = OSD.FromString(name); | ||
386 | } | ||
387 | if (description != null) | ||
388 | { | ||
389 | GroupRoleInfo["Description"] = OSD.FromString(description); | ||
390 | } | ||
391 | if (title != null) | ||
392 | { | ||
393 | GroupRoleInfo["Title"] = OSD.FromString(title); | ||
394 | } | ||
395 | GroupRoleInfo["Powers"] = OSD.FromULong((ulong)powers); | ||
396 | |||
397 | } | ||
398 | |||
399 | |||
400 | SimianAddGeneric(groupID, "GroupRole", roleID.ToString(), GroupRoleInfo); | ||
401 | } | ||
402 | |||
403 | public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName) | ||
404 | { | ||
405 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
406 | |||
407 | OSDMap GroupInfoMap = null; | ||
408 | if (groupID != UUID.Zero) | ||
409 | { | ||
410 | if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out GroupInfoMap)) | ||
411 | { | ||
412 | return null; | ||
413 | } | ||
414 | } | ||
415 | else if ((groupName != null) && (groupName != string.Empty)) | ||
416 | { | ||
417 | if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap)) | ||
418 | { | ||
419 | return null; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | GroupRecord GroupInfo = new GroupRecord(); | ||
424 | |||
425 | GroupInfo.GroupID = groupID; | ||
426 | GroupInfo.GroupName = groupName; | ||
427 | GroupInfo.Charter = GroupInfoMap["Charter"].AsString(); | ||
428 | GroupInfo.ShowInList = GroupInfoMap["ShowInList"].AsBoolean(); | ||
429 | GroupInfo.GroupPicture = GroupInfoMap["InsigniaID"].AsUUID(); | ||
430 | GroupInfo.MembershipFee = GroupInfoMap["MembershipFee"].AsInteger(); | ||
431 | GroupInfo.OpenEnrollment = GroupInfoMap["OpenEnrollment"].AsBoolean(); | ||
432 | GroupInfo.AllowPublish = GroupInfoMap["AllowPublish"].AsBoolean(); | ||
433 | GroupInfo.MaturePublish = GroupInfoMap["MaturePublish"].AsBoolean(); | ||
434 | GroupInfo.FounderID = GroupInfoMap["FounderID"].AsUUID(); | ||
435 | GroupInfo.OwnerRoleID = GroupInfoMap["OwnerRoleID"].AsUUID(); | ||
436 | |||
437 | return GroupInfo; | ||
438 | |||
439 | } | ||
440 | |||
441 | public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID groupID, UUID memberID) | ||
442 | { | ||
443 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
444 | |||
445 | OSDMap groupProfile; | ||
446 | string groupName; | ||
447 | if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out groupProfile)) | ||
448 | { | ||
449 | // GroupProfileData is not nullable | ||
450 | return new GroupProfileData(); | ||
451 | } | ||
452 | |||
453 | GroupProfileData MemberGroupProfile = new GroupProfileData(); | ||
454 | MemberGroupProfile.GroupID = groupID; | ||
455 | MemberGroupProfile.Name = groupName; | ||
456 | |||
457 | if (groupProfile["Charter"] != null) | ||
458 | { | ||
459 | MemberGroupProfile.Charter = groupProfile["Charter"].AsString(); | ||
460 | } | ||
461 | |||
462 | MemberGroupProfile.ShowInList = groupProfile["ShowInList"].AsString() == "1"; | ||
463 | MemberGroupProfile.InsigniaID = groupProfile["InsigniaID"].AsUUID(); | ||
464 | MemberGroupProfile.MembershipFee = groupProfile["MembershipFee"].AsInteger(); | ||
465 | MemberGroupProfile.OpenEnrollment = groupProfile["OpenEnrollment"].AsBoolean(); | ||
466 | MemberGroupProfile.AllowPublish = groupProfile["AllowPublish"].AsBoolean(); | ||
467 | MemberGroupProfile.MaturePublish = groupProfile["MaturePublish"].AsBoolean(); | ||
468 | MemberGroupProfile.FounderID = groupProfile["FounderID"].AsUUID();; | ||
469 | MemberGroupProfile.OwnerRole = groupProfile["OwnerRoleID"].AsUUID(); | ||
470 | |||
471 | Dictionary<UUID, OSDMap> Members; | ||
472 | if (SimianGetGenericEntries("GroupMember",groupID.ToString(), out Members)) | ||
473 | { | ||
474 | MemberGroupProfile.GroupMembershipCount = Members.Count; | ||
475 | } | ||
476 | |||
477 | Dictionary<string, OSDMap> Roles; | ||
478 | if (SimianGetGenericEntries(groupID, "GroupRole", out Roles)) | ||
479 | { | ||
480 | MemberGroupProfile.GroupRolesCount = Roles.Count; | ||
481 | } | ||
482 | |||
483 | // TODO: Get Group Money balance from somewhere | ||
484 | // group.Money = 0; | ||
485 | |||
486 | GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, memberID, groupID); | ||
487 | |||
488 | MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; | ||
489 | MemberGroupProfile.PowersMask = MemberInfo.GroupPowers; | ||
490 | |||
491 | return MemberGroupProfile; | ||
492 | } | ||
493 | |||
494 | public void SetAgentActiveGroup(UUID requestingAgentID, UUID agentID, UUID groupID) | ||
495 | { | ||
496 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
497 | |||
498 | OSDMap ActiveGroup = new OSDMap(); | ||
499 | ActiveGroup.Add("GroupID", OSD.FromUUID(groupID)); | ||
500 | SimianAddGeneric(agentID, "Group", "ActiveGroup", ActiveGroup); | ||
501 | } | ||
502 | |||
503 | public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID) | ||
504 | { | ||
505 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
506 | |||
507 | OSDMap GroupMemberInfo; | ||
508 | if (!SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out GroupMemberInfo)) | ||
509 | { | ||
510 | GroupMemberInfo = new OSDMap(); | ||
511 | } | ||
512 | |||
513 | GroupMemberInfo["SelectedRoleID"] = OSD.FromUUID(roleID); | ||
514 | SimianAddGeneric(agentID, "GroupMember", groupID.ToString(), GroupMemberInfo); | ||
515 | } | ||
516 | |||
517 | public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile) | ||
518 | { | ||
519 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
520 | |||
521 | OSDMap GroupMemberInfo; | ||
522 | if (!SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out GroupMemberInfo)) | ||
523 | { | ||
524 | GroupMemberInfo = new OSDMap(); | ||
525 | } | ||
526 | |||
527 | GroupMemberInfo["AcceptNotices"] = OSD.FromBoolean(acceptNotices); | ||
528 | GroupMemberInfo["ListInProfile"] = OSD.FromBoolean(listInProfile); | ||
529 | GroupMemberInfo["Contribution"] = OSD.FromInteger(0); | ||
530 | GroupMemberInfo["SelectedRole"] = OSD.FromUUID(UUID.Zero); | ||
531 | SimianAddGeneric(agentID, "GroupMember", groupID.ToString(), GroupMemberInfo); | ||
532 | } | ||
533 | |||
534 | public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) | ||
535 | { | ||
536 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
537 | |||
538 | OSDMap Invite = new OSDMap(); | ||
539 | Invite["AgentID"] = OSD.FromUUID(agentID); | ||
540 | Invite["RoleID"] = OSD.FromUUID(roleID); | ||
541 | |||
542 | SimianAddGeneric(groupID, "GroupMemberInvite", inviteID.ToString(), Invite); | ||
543 | } | ||
544 | |||
545 | public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID) | ||
546 | { | ||
547 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
548 | |||
549 | OSDMap GroupMemberInvite; | ||
550 | UUID GroupID; | ||
551 | if (!SimianGetFirstGenericEntry("GroupMemberInvite", inviteID.ToString(), out GroupID, out GroupMemberInvite)) | ||
552 | { | ||
553 | return null; | ||
554 | } | ||
555 | |||
556 | GroupInviteInfo inviteInfo = new GroupInviteInfo(); | ||
557 | inviteInfo.InviteID = inviteID; | ||
558 | inviteInfo.GroupID = GroupID; | ||
559 | inviteInfo.AgentID = GroupMemberInvite["AgentID"].AsUUID(); | ||
560 | inviteInfo.RoleID = GroupMemberInvite["RoleID"].AsUUID(); | ||
561 | |||
562 | return inviteInfo; | ||
563 | } | ||
564 | |||
565 | public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID) | ||
566 | { | ||
567 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
568 | |||
569 | GroupInviteInfo invite = GetAgentToGroupInvite(requestingAgentID, inviteID); | ||
570 | SimianRemoveGenericEntry(invite.GroupID, "GroupMemberInvite", inviteID.ToString()); | ||
571 | } | ||
572 | |||
573 | public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) | ||
574 | { | ||
575 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
576 | |||
577 | // Setup Agent/Group information | ||
578 | SetAgentGroupInfo(requestingAgentID, AgentID, GroupID, true, true); | ||
579 | |||
580 | // Add agent to Everyone Group | ||
581 | AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, UUID.Zero); | ||
582 | |||
583 | // Add agent to Specified Role | ||
584 | AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, RoleID); | ||
585 | |||
586 | // Set selected role in this group to specified role | ||
587 | SetAgentActiveGroupRole(requestingAgentID, AgentID, GroupID, RoleID); | ||
588 | } | ||
589 | |||
590 | public void RemoveAgentFromGroup(UUID requestingAgentID, UUID agentID, UUID groupID) | ||
591 | { | ||
592 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
593 | |||
594 | // If current active group is the group the agent is being removed from, change their group to UUID.Zero | ||
595 | GroupMembershipData memberActiveMembership = GetAgentActiveMembership(requestingAgentID, agentID); | ||
596 | if (memberActiveMembership.GroupID == groupID) | ||
597 | { | ||
598 | SetAgentActiveGroup(agentID, agentID, UUID.Zero); | ||
599 | } | ||
600 | |||
601 | // Remove Group Member information for this group | ||
602 | SimianRemoveGenericEntry(agentID, "GroupMember", groupID.ToString()); | ||
603 | |||
604 | // By using a Simian Generics Type consisting of a prefix and a groupID, | ||
605 | // combined with RoleID as key allows us to get a list of roles a particular member | ||
606 | // of a group is assigned to. | ||
607 | string GroupRoleMemberType = "GroupRole" + groupID.ToString(); | ||
608 | |||
609 | // Take Agent out of all other group roles | ||
610 | Dictionary<string, OSDMap> GroupRoles; | ||
611 | if (SimianGetGenericEntries(agentID, GroupRoleMemberType, out GroupRoles)) | ||
612 | { | ||
613 | foreach (string roleID in GroupRoles.Keys) | ||
614 | { | ||
615 | SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID); | ||
616 | } | ||
617 | } | ||
618 | } | ||
619 | |||
620 | public void AddAgentToGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID) | ||
621 | { | ||
622 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
623 | |||
624 | SimianAddGeneric(agentID, "GroupRole" + groupID.ToString(), roleID.ToString(), new OSDMap()); | ||
625 | } | ||
626 | |||
627 | public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID) | ||
628 | { | ||
629 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
630 | |||
631 | // Cannot remove members from the Everyone Role | ||
632 | if (roleID != UUID.Zero) | ||
633 | { | ||
634 | EnsureRoleNotSelectedByMember(groupID, roleID, agentID); | ||
635 | |||
636 | string GroupRoleMemberType = "GroupRole" + groupID.ToString(); | ||
637 | SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID.ToString()); | ||
638 | } | ||
639 | } | ||
640 | |||
641 | public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search) | ||
642 | { | ||
643 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
644 | |||
645 | List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>(); | ||
646 | |||
647 | NameValueCollection requestArgs = new NameValueCollection | ||
648 | { | ||
649 | { "RequestMethod", "GetGenerics" }, | ||
650 | { "Type", "Group" }, | ||
651 | { "Key", search }, | ||
652 | { "Fuzzy", "1" } | ||
653 | }; | ||
654 | |||
655 | |||
656 | OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs); | ||
657 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | ||
658 | { | ||
659 | OSDArray entryArray = (OSDArray)response["Entries"]; | ||
660 | foreach (OSDMap entryMap in entryArray) | ||
661 | { | ||
662 | DirGroupsReplyData data = new DirGroupsReplyData(); | ||
663 | data.groupID = entryMap["OwnerID"].AsUUID(); | ||
664 | data.groupName = entryMap["Key"].AsString(); | ||
665 | |||
666 | // TODO: is there a better way to do this? | ||
667 | Dictionary<UUID, OSDMap> Members; | ||
668 | if (SimianGetGenericEntries("GroupMember", data.groupID.ToString(), out Members)) | ||
669 | { | ||
670 | data.members = Members.Count; | ||
671 | } | ||
672 | else | ||
673 | { | ||
674 | data.members = 0; | ||
675 | } | ||
676 | |||
677 | // TODO: sort results? | ||
678 | // data.searchOrder = order; | ||
679 | |||
680 | findings.Add(data); | ||
681 | } | ||
682 | } | ||
683 | |||
684 | |||
685 | return findings; | ||
686 | } | ||
687 | |||
688 | public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID agentID, UUID groupID) | ||
689 | { | ||
690 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
691 | |||
692 | GroupMembershipData data = new GroupMembershipData(); | ||
693 | |||
694 | /////////////////////////////// | ||
695 | // Agent Specific Information: | ||
696 | // | ||
697 | OSDMap UserActiveGroup; | ||
698 | if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup)) | ||
699 | { | ||
700 | data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID); | ||
701 | } | ||
702 | |||
703 | OSDMap UserGroupMemberInfo; | ||
704 | if( SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo) ) | ||
705 | { | ||
706 | data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean(); | ||
707 | data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger(); | ||
708 | data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean(); | ||
709 | data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID(); | ||
710 | |||
711 | /////////////////////////////// | ||
712 | // Role Specific Information: | ||
713 | // | ||
714 | |||
715 | OSDMap GroupRoleInfo; | ||
716 | if( SimianGetGenericEntry(groupID, "GroupRole", data.ActiveRole.ToString(), out GroupRoleInfo) ) | ||
717 | { | ||
718 | data.GroupTitle = GroupRoleInfo["Title"].AsString(); | ||
719 | data.GroupPowers = GroupRoleInfo["Powers"].AsULong(); | ||
720 | } | ||
721 | } | ||
722 | |||
723 | /////////////////////////////// | ||
724 | // Group Specific Information: | ||
725 | // | ||
726 | OSDMap GroupInfo; | ||
727 | string GroupName; | ||
728 | if( SimianGetFirstGenericEntry(groupID, "Group", out GroupName, out GroupInfo) ) | ||
729 | { | ||
730 | data.GroupID = groupID; | ||
731 | data.AllowPublish = GroupInfo["AllowPublish"].AsBoolean(); | ||
732 | data.Charter = GroupInfo["Charter"].AsString(); | ||
733 | data.FounderID = GroupInfo["FounderID"].AsUUID(); | ||
734 | data.GroupName = GroupName; | ||
735 | data.GroupPicture = GroupInfo["InsigniaID"].AsUUID(); | ||
736 | data.MaturePublish = GroupInfo["MaturePublish"].AsBoolean(); | ||
737 | data.MembershipFee = GroupInfo["MembershipFee"].AsInteger(); | ||
738 | data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean(); | ||
739 | data.ShowInList = GroupInfo["ShowInList"].AsBoolean(); | ||
740 | } | ||
741 | |||
742 | return data; | ||
743 | } | ||
744 | |||
745 | public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID agentID) | ||
746 | { | ||
747 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
748 | |||
749 | UUID GroupID = UUID.Zero; | ||
750 | OSDMap UserActiveGroup; | ||
751 | if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup)) | ||
752 | { | ||
753 | GroupID = UserActiveGroup["GroupID"].AsUUID(); | ||
754 | } | ||
755 | |||
756 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Active GroupID : {0}", GroupID.ToString()); | ||
757 | return GetAgentGroupMembership(requestingAgentID, agentID, GroupID); | ||
758 | } | ||
759 | |||
760 | public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID agentID) | ||
761 | { | ||
762 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
763 | |||
764 | List<GroupMembershipData> memberships = new List<GroupMembershipData>(); | ||
765 | |||
766 | Dictionary<string,OSDMap> GroupMemberShips; | ||
767 | if (SimianGetGenericEntries(agentID, "GroupMember", out GroupMemberShips)) | ||
768 | { | ||
769 | foreach (string key in GroupMemberShips.Keys) | ||
770 | { | ||
771 | memberships.Add(GetAgentGroupMembership(requestingAgentID, agentID, UUID.Parse(key))); | ||
772 | } | ||
773 | } | ||
774 | |||
775 | return memberships; | ||
776 | } | ||
777 | |||
778 | public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID agentID, UUID groupID) | ||
779 | { | ||
780 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
781 | |||
782 | List<GroupRolesData> Roles = new List<GroupRolesData>(); | ||
783 | |||
784 | Dictionary<string, OSDMap> GroupRoles; | ||
785 | if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles)) | ||
786 | { | ||
787 | Dictionary<string, OSDMap> MemberRoles; | ||
788 | if (SimianGetGenericEntries(agentID, "GroupRole" + groupID.ToString(), out MemberRoles)) | ||
789 | { | ||
790 | foreach (KeyValuePair<string, OSDMap> kvp in MemberRoles) | ||
791 | { | ||
792 | GroupRolesData data = new GroupRolesData(); | ||
793 | data.RoleID = UUID.Parse(kvp.Key); | ||
794 | data.Name = GroupRoles[kvp.Key]["Name"].AsString(); | ||
795 | data.Description = GroupRoles[kvp.Key]["Description"].AsString(); | ||
796 | data.Title = GroupRoles[kvp.Key]["Title"].AsString(); | ||
797 | data.Powers = GroupRoles[kvp.Key]["Powers"].AsULong(); | ||
798 | |||
799 | Roles.Add(data); | ||
800 | } | ||
801 | } | ||
802 | } | ||
803 | return Roles; | ||
804 | } | ||
805 | |||
806 | public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID groupID) | ||
807 | { | ||
808 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
809 | |||
810 | List<GroupRolesData> Roles = new List<GroupRolesData>(); | ||
811 | |||
812 | Dictionary<string, OSDMap> GroupRoles; | ||
813 | if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles)) | ||
814 | { | ||
815 | foreach (KeyValuePair<string, OSDMap> role in GroupRoles) | ||
816 | { | ||
817 | GroupRolesData data = new GroupRolesData(); | ||
818 | |||
819 | data.RoleID = UUID.Parse(role.Key); | ||
820 | |||
821 | data.Name = role.Value["Name"].AsString(); | ||
822 | data.Description = role.Value["Description"].AsString(); | ||
823 | data.Title = role.Value["Title"].AsString(); | ||
824 | data.Powers = role.Value["Powers"].AsULong(); | ||
825 | |||
826 | Dictionary<UUID, OSDMap> GroupRoleMembers; | ||
827 | if (SimianGetGenericEntries("GroupRole" + groupID.ToString(), role.Key, out GroupRoleMembers)) | ||
828 | { | ||
829 | data.Members = GroupRoleMembers.Count; | ||
830 | } | ||
831 | else | ||
832 | { | ||
833 | data.Members = 0; | ||
834 | } | ||
835 | |||
836 | Roles.Add(data); | ||
837 | } | ||
838 | } | ||
839 | |||
840 | return Roles; | ||
841 | |||
842 | } | ||
843 | |||
844 | |||
845 | |||
846 | public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID) | ||
847 | { | ||
848 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
849 | |||
850 | List<GroupMembersData> members = new List<GroupMembersData>(); | ||
851 | |||
852 | OSDMap GroupInfo; | ||
853 | string GroupName; | ||
854 | UUID GroupOwnerRoleID = UUID.Zero; | ||
855 | if (!SimianGetFirstGenericEntry(GroupID, "Group", out GroupName, out GroupInfo)) | ||
856 | { | ||
857 | return members; | ||
858 | } | ||
859 | GroupOwnerRoleID = GroupInfo["OwnerRoleID"].AsUUID(); | ||
860 | |||
861 | // Locally cache group roles, since we'll be needing this data for each member | ||
862 | Dictionary<string,OSDMap> GroupRoles; | ||
863 | SimianGetGenericEntries(GroupID, "GroupRole", out GroupRoles); | ||
864 | |||
865 | // Locally cache list of group owners | ||
866 | Dictionary<UUID, OSDMap> GroupOwners; | ||
867 | SimianGetGenericEntries("GroupRole" + GroupID.ToString(), GroupOwnerRoleID.ToString(), out GroupOwners); | ||
868 | |||
869 | |||
870 | Dictionary<UUID, OSDMap> GroupMembers; | ||
871 | if (SimianGetGenericEntries("GroupMember", GroupID.ToString(), out GroupMembers)) | ||
872 | { | ||
873 | foreach (KeyValuePair<UUID, OSDMap> member in GroupMembers) | ||
874 | { | ||
875 | GroupMembersData data = new GroupMembersData(); | ||
876 | |||
877 | data.AgentID = member.Key; | ||
878 | |||
879 | UUID SelectedRoleID = member.Value["SelectedRoleID"].AsUUID(); | ||
880 | |||
881 | data.AcceptNotices = member.Value["AcceptNotices"].AsBoolean(); | ||
882 | data.ListInProfile = member.Value["ListInProfile"].AsBoolean(); | ||
883 | data.Contribution = member.Value["Contribution"].AsInteger(); | ||
884 | |||
885 | data.IsOwner = GroupOwners.ContainsKey(member.Key); | ||
886 | |||
887 | OSDMap GroupRoleInfo = GroupRoles[SelectedRoleID.ToString()]; | ||
888 | data.Title = GroupRoleInfo["Title"].AsString(); | ||
889 | data.AgentPowers = GroupRoleInfo["Powers"].AsULong(); | ||
890 | |||
891 | members.Add(data); | ||
892 | } | ||
893 | } | ||
894 | |||
895 | return members; | ||
896 | |||
897 | } | ||
898 | |||
899 | public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID groupID) | ||
900 | { | ||
901 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
902 | |||
903 | List<GroupRoleMembersData> members = new List<GroupRoleMembersData>(); | ||
904 | |||
905 | Dictionary<string, OSDMap> GroupRoles; | ||
906 | if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles)) | ||
907 | { | ||
908 | foreach( KeyValuePair<string, OSDMap> Role in GroupRoles ) | ||
909 | { | ||
910 | Dictionary<UUID, OSDMap> GroupRoleMembers; | ||
911 | if( SimianGetGenericEntries("GroupRole"+groupID.ToString(), Role.Key, out GroupRoleMembers) ) | ||
912 | { | ||
913 | foreach( KeyValuePair<UUID, OSDMap> GroupRoleMember in GroupRoleMembers ) | ||
914 | { | ||
915 | GroupRoleMembersData data = new GroupRoleMembersData(); | ||
916 | |||
917 | data.MemberID = GroupRoleMember.Key; | ||
918 | data.RoleID = UUID.Parse(Role.Key); | ||
919 | |||
920 | members.Add(data); | ||
921 | } | ||
922 | } | ||
923 | } | ||
924 | } | ||
925 | |||
926 | return members; | ||
927 | } | ||
928 | |||
929 | public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID) | ||
930 | { | ||
931 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
932 | |||
933 | List<GroupNoticeData> values = new List<GroupNoticeData>(); | ||
934 | |||
935 | Dictionary<string, OSDMap> Notices; | ||
936 | if (SimianGetGenericEntries(GroupID, "GroupNotice", out Notices)) | ||
937 | { | ||
938 | foreach (KeyValuePair<string, OSDMap> Notice in Notices) | ||
939 | { | ||
940 | GroupNoticeData data = new GroupNoticeData(); | ||
941 | data.NoticeID = UUID.Parse(Notice.Key); | ||
942 | data.Timestamp = Notice.Value["TimeStamp"].AsUInteger(); | ||
943 | data.FromName = Notice.Value["FromName"].AsString(); | ||
944 | data.Subject = Notice.Value["Subject"].AsString(); | ||
945 | data.HasAttachment = Notice.Value["BinaryBucket"].AsBinary().Length > 0; | ||
946 | |||
947 | //TODO: Figure out how to get this | ||
948 | data.AssetType = 0; | ||
949 | |||
950 | values.Add(data); | ||
951 | } | ||
952 | } | ||
953 | |||
954 | return values; | ||
955 | |||
956 | } | ||
957 | public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) | ||
958 | { | ||
959 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
960 | |||
961 | OSDMap GroupNotice; | ||
962 | UUID GroupID; | ||
963 | if (SimianGetFirstGenericEntry("GroupNotice", noticeID.ToString(), out GroupID, out GroupNotice)) | ||
964 | { | ||
965 | GroupNoticeInfo data = new GroupNoticeInfo(); | ||
966 | data.GroupID = GroupID; | ||
967 | data.Message = GroupNotice["Message"].AsString(); | ||
968 | data.BinaryBucket = GroupNotice["BinaryBucket"].AsBinary(); | ||
969 | data.noticeData.NoticeID = noticeID; | ||
970 | data.noticeData.Timestamp = GroupNotice["TimeStamp"].AsUInteger(); | ||
971 | data.noticeData.FromName = GroupNotice["FromName"].AsString(); | ||
972 | data.noticeData.Subject = GroupNotice["Subject"].AsString(); | ||
973 | data.noticeData.HasAttachment = data.BinaryBucket.Length > 0; | ||
974 | data.noticeData.AssetType = 0; | ||
975 | |||
976 | if (data.Message == null) | ||
977 | { | ||
978 | data.Message = string.Empty; | ||
979 | } | ||
980 | |||
981 | return data; | ||
982 | } | ||
983 | return null; | ||
984 | } | ||
985 | public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) | ||
986 | { | ||
987 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
988 | |||
989 | OSDMap Notice = new OSDMap(); | ||
990 | Notice["TimeStamp"] = OSD.FromUInteger((uint)Util.UnixTimeSinceEpoch()); | ||
991 | Notice["FromName"] = OSD.FromString(fromName); | ||
992 | Notice["Subject"] = OSD.FromString(subject); | ||
993 | Notice["Message"] = OSD.FromString(message); | ||
994 | Notice["BinaryBucket"] = OSD.FromBinary(binaryBucket); | ||
995 | |||
996 | SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice); | ||
997 | |||
998 | } | ||
999 | #endregion | ||
1000 | |||
1001 | |||
1002 | private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID) | ||
1003 | { | ||
1004 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
1005 | |||
1006 | // If member's SelectedRole is roleID, change their selected role to Everyone | ||
1007 | // before removing them from the role | ||
1008 | OSDMap UserGroupInfo; | ||
1009 | if (SimianGetGenericEntry(userID, "GroupMember", groupID.ToString(), out UserGroupInfo)) | ||
1010 | { | ||
1011 | if (UserGroupInfo["SelectedRoleID"].AsUUID() == roleID) | ||
1012 | { | ||
1013 | UserGroupInfo["SelectedRoleID"] = OSD.FromUUID(UUID.Zero); | ||
1014 | } | ||
1015 | SimianAddGeneric(userID, "GroupMember", groupID.ToString(), UserGroupInfo); | ||
1016 | } | ||
1017 | } | ||
1018 | |||
1019 | |||
1020 | #region Simian Util Methods | ||
1021 | private bool SimianAddGeneric(UUID ownerID, string type, string key, OSDMap map) | ||
1022 | { | ||
1023 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key); | ||
1024 | |||
1025 | string value = OSDParser.SerializeJsonString(map); | ||
1026 | |||
1027 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] value: {0}", value); | ||
1028 | |||
1029 | NameValueCollection RequestArgs = new NameValueCollection | ||
1030 | { | ||
1031 | { "RequestMethod", "AddGeneric" }, | ||
1032 | { "OwnerID", ownerID.ToString() }, | ||
1033 | { "Type", type }, | ||
1034 | { "Key", key }, | ||
1035 | { "Value", value} | ||
1036 | }; | ||
1037 | |||
1038 | |||
1039 | OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs); | ||
1040 | if (Response["Success"].AsBoolean()) | ||
1041 | { | ||
1042 | return true; | ||
1043 | } | ||
1044 | else | ||
1045 | { | ||
1046 | m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, Response["Message"]); | ||
1047 | return false; | ||
1048 | } | ||
1049 | } | ||
1050 | |||
1051 | /// <summary> | ||
1052 | /// Returns the first of possibly many entries for Owner/Type pair | ||
1053 | /// </summary> | ||
1054 | private bool SimianGetFirstGenericEntry(UUID ownerID, string type, out string key, out OSDMap map) | ||
1055 | { | ||
1056 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type); | ||
1057 | |||
1058 | NameValueCollection RequestArgs = new NameValueCollection | ||
1059 | { | ||
1060 | { "RequestMethod", "GetGenerics" }, | ||
1061 | { "OwnerID", ownerID.ToString() }, | ||
1062 | { "Type", type } | ||
1063 | }; | ||
1064 | |||
1065 | |||
1066 | OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs); | ||
1067 | if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) | ||
1068 | { | ||
1069 | OSDArray entryArray = (OSDArray)Response["Entries"]; | ||
1070 | if (entryArray.Count >= 1) | ||
1071 | { | ||
1072 | OSDMap entryMap = entryArray[0] as OSDMap; | ||
1073 | key = entryMap["Key"].AsString(); | ||
1074 | map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()); | ||
1075 | |||
1076 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | ||
1077 | |||
1078 | return true; | ||
1079 | } | ||
1080 | else | ||
1081 | { | ||
1082 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | ||
1083 | } | ||
1084 | } | ||
1085 | else | ||
1086 | { | ||
1087 | m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]); | ||
1088 | } | ||
1089 | key = null; | ||
1090 | map = null; | ||
1091 | return false; | ||
1092 | } | ||
1093 | private bool SimianGetFirstGenericEntry(string type, string key, out UUID ownerID, out OSDMap map) | ||
1094 | { | ||
1095 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key); | ||
1096 | |||
1097 | |||
1098 | NameValueCollection RequestArgs = new NameValueCollection | ||
1099 | { | ||
1100 | { "RequestMethod", "GetGenerics" }, | ||
1101 | { "Type", type }, | ||
1102 | { "Key", key} | ||
1103 | }; | ||
1104 | |||
1105 | |||
1106 | OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs); | ||
1107 | if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) | ||
1108 | { | ||
1109 | OSDArray entryArray = (OSDArray)Response["Entries"]; | ||
1110 | if (entryArray.Count >= 1) | ||
1111 | { | ||
1112 | OSDMap entryMap = entryArray[0] as OSDMap; | ||
1113 | ownerID = entryMap["OwnerID"].AsUUID(); | ||
1114 | map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()); | ||
1115 | |||
1116 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | ||
1117 | |||
1118 | return true; | ||
1119 | } | ||
1120 | else | ||
1121 | { | ||
1122 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | ||
1123 | } | ||
1124 | } | ||
1125 | else | ||
1126 | { | ||
1127 | m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]); | ||
1128 | } | ||
1129 | ownerID = UUID.Zero; | ||
1130 | map = null; | ||
1131 | return false; | ||
1132 | } | ||
1133 | |||
1134 | private bool SimianGetGenericEntry(UUID ownerID, string type, string key, out OSDMap map) | ||
1135 | { | ||
1136 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key); | ||
1137 | |||
1138 | NameValueCollection RequestArgs = new NameValueCollection | ||
1139 | { | ||
1140 | { "RequestMethod", "GetGenerics" }, | ||
1141 | { "OwnerID", ownerID.ToString() }, | ||
1142 | { "Type", type }, | ||
1143 | { "Key", key} | ||
1144 | }; | ||
1145 | |||
1146 | |||
1147 | OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs); | ||
1148 | if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) | ||
1149 | { | ||
1150 | OSDArray entryArray = (OSDArray)Response["Entries"]; | ||
1151 | if (entryArray.Count == 1) | ||
1152 | { | ||
1153 | OSDMap entryMap = entryArray[0] as OSDMap; | ||
1154 | key = entryMap["Key"].AsString(); | ||
1155 | map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()); | ||
1156 | |||
1157 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | ||
1158 | |||
1159 | return true; | ||
1160 | } | ||
1161 | else | ||
1162 | { | ||
1163 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | ||
1164 | } | ||
1165 | } | ||
1166 | else | ||
1167 | { | ||
1168 | m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]); | ||
1169 | } | ||
1170 | map = null; | ||
1171 | return false; | ||
1172 | } | ||
1173 | |||
1174 | private bool SimianGetGenericEntries(UUID ownerID, string type, out Dictionary<string, OSDMap> maps) | ||
1175 | { | ||
1176 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name,ownerID, type); | ||
1177 | |||
1178 | NameValueCollection requestArgs = new NameValueCollection | ||
1179 | { | ||
1180 | { "RequestMethod", "GetGenerics" }, | ||
1181 | { "OwnerID", ownerID.ToString() }, | ||
1182 | { "Type", type } | ||
1183 | }; | ||
1184 | |||
1185 | |||
1186 | |||
1187 | OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs); | ||
1188 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | ||
1189 | { | ||
1190 | maps = new Dictionary<string, OSDMap>(); | ||
1191 | |||
1192 | OSDArray entryArray = (OSDArray)response["Entries"]; | ||
1193 | foreach (OSDMap entryMap in entryArray) | ||
1194 | { | ||
1195 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | ||
1196 | maps.Add(entryMap["Key"].AsString(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString())); | ||
1197 | } | ||
1198 | if(maps.Count == 0) | ||
1199 | { | ||
1200 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | ||
1201 | } | ||
1202 | |||
1203 | return true; | ||
1204 | } | ||
1205 | else | ||
1206 | { | ||
1207 | maps = null; | ||
1208 | m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", response["Message"]); | ||
1209 | } | ||
1210 | return false; | ||
1211 | } | ||
1212 | private bool SimianGetGenericEntries(string type, string key, out Dictionary<UUID, OSDMap> maps) | ||
1213 | { | ||
1214 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key); | ||
1215 | |||
1216 | NameValueCollection requestArgs = new NameValueCollection | ||
1217 | { | ||
1218 | { "RequestMethod", "GetGenerics" }, | ||
1219 | { "Type", type }, | ||
1220 | { "Key", key } | ||
1221 | }; | ||
1222 | |||
1223 | |||
1224 | |||
1225 | OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs); | ||
1226 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | ||
1227 | { | ||
1228 | maps = new Dictionary<UUID, OSDMap>(); | ||
1229 | |||
1230 | OSDArray entryArray = (OSDArray)response["Entries"]; | ||
1231 | foreach (OSDMap entryMap in entryArray) | ||
1232 | { | ||
1233 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString()); | ||
1234 | maps.Add(entryMap["OwnerID"].AsUUID(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString())); | ||
1235 | } | ||
1236 | if (maps.Count == 0) | ||
1237 | { | ||
1238 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results"); | ||
1239 | } | ||
1240 | return true; | ||
1241 | } | ||
1242 | else | ||
1243 | { | ||
1244 | maps = null; | ||
1245 | m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR]: Error retrieving group info ({0})", response["Message"]); | ||
1246 | } | ||
1247 | return false; | ||
1248 | } | ||
1249 | |||
1250 | private bool SimianRemoveGenericEntry(UUID ownerID, string type, string key) | ||
1251 | { | ||
1252 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key); | ||
1253 | |||
1254 | NameValueCollection requestArgs = new NameValueCollection | ||
1255 | { | ||
1256 | { "RequestMethod", "RemoveGeneric" }, | ||
1257 | { "OwnerID", ownerID.ToString() }, | ||
1258 | { "Type", type }, | ||
1259 | { "Key", key } | ||
1260 | }; | ||
1261 | |||
1262 | |||
1263 | OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs); | ||
1264 | if (response["Success"].AsBoolean()) | ||
1265 | { | ||
1266 | return true; | ||
1267 | } | ||
1268 | else | ||
1269 | { | ||
1270 | m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, response["Message"]); | ||
1271 | return false; | ||
1272 | } | ||
1273 | } | ||
1274 | #endregion | ||
1275 | } | ||
1276 | |||
1277 | } | ||
1278 | |||
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index 24ae4f7..ab343c8 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs | |||
@@ -40,7 +40,9 @@ using OpenMetaverse; | |||
40 | using OpenMetaverse.StructuredData; | 40 | using OpenMetaverse.StructuredData; |
41 | 41 | ||
42 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
43 | using OpenSim.Framework.Communications; | ||
43 | using OpenSim.Region.Framework.Interfaces; | 44 | using OpenSim.Region.Framework.Interfaces; |
45 | using OpenSim.Services.Interfaces; | ||
44 | 46 | ||
45 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | 47 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups |
46 | { | 48 | { |
@@ -66,6 +68,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
66 | private string m_groupReadKey = string.Empty; | 68 | private string m_groupReadKey = string.Empty; |
67 | private string m_groupWriteKey = string.Empty; | 69 | private string m_groupWriteKey = string.Empty; |
68 | 70 | ||
71 | private IUserAccountService m_accountService = null; | ||
72 | |||
69 | 73 | ||
70 | #region IRegionModuleBase Members | 74 | #region IRegionModuleBase Members |
71 | 75 | ||
@@ -116,6 +120,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
116 | m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); | 120 | m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); |
117 | m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); | 121 | m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); |
118 | 122 | ||
123 | |||
124 | |||
125 | |||
119 | // If we got all the config options we need, lets start'er'up | 126 | // If we got all the config options we need, lets start'er'up |
120 | m_connectorEnabled = true; | 127 | m_connectorEnabled = true; |
121 | } | 128 | } |
@@ -129,13 +136,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
129 | public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) | 136 | public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) |
130 | { | 137 | { |
131 | if (m_connectorEnabled) | 138 | if (m_connectorEnabled) |
139 | { | ||
140 | |||
141 | if (m_accountService == null) | ||
142 | { | ||
143 | m_accountService = scene.UserAccountService; | ||
144 | } | ||
145 | |||
146 | |||
132 | scene.RegisterModuleInterface<IGroupsServicesConnector>(this); | 147 | scene.RegisterModuleInterface<IGroupsServicesConnector>(this); |
148 | } | ||
133 | } | 149 | } |
134 | 150 | ||
135 | public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene) | 151 | public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene) |
136 | { | 152 | { |
137 | if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this) | 153 | if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this) |
154 | { | ||
138 | scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); | 155 | scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); |
156 | } | ||
139 | } | 157 | } |
140 | 158 | ||
141 | public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene) | 159 | public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene) |
@@ -155,14 +173,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
155 | 173 | ||
156 | #endregion | 174 | #endregion |
157 | 175 | ||
158 | |||
159 | |||
160 | #region IGroupsServicesConnector Members | 176 | #region IGroupsServicesConnector Members |
161 | 177 | ||
162 | /// <summary> | 178 | /// <summary> |
163 | /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role. | 179 | /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role. |
164 | /// </summary> | 180 | /// </summary> |
165 | public UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, | 181 | public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID, |
166 | int membershipFee, bool openEnrollment, bool allowPublish, | 182 | int membershipFee, bool openEnrollment, bool allowPublish, |
167 | bool maturePublish, UUID founderID) | 183 | bool maturePublish, UUID founderID) |
168 | { | 184 | { |
@@ -234,7 +250,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
234 | 250 | ||
235 | 251 | ||
236 | 252 | ||
237 | Hashtable respData = XmlRpcCall(requestID, "groups.createGroup", param); | 253 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.createGroup", param); |
238 | 254 | ||
239 | if (respData.Contains("error")) | 255 | if (respData.Contains("error")) |
240 | { | 256 | { |
@@ -246,7 +262,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
246 | return UUID.Parse((string)respData["GroupID"]); | 262 | return UUID.Parse((string)respData["GroupID"]); |
247 | } | 263 | } |
248 | 264 | ||
249 | public void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, | 265 | public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, |
250 | UUID insigniaID, int membershipFee, bool openEnrollment, | 266 | UUID insigniaID, int membershipFee, bool openEnrollment, |
251 | bool allowPublish, bool maturePublish) | 267 | bool allowPublish, bool maturePublish) |
252 | { | 268 | { |
@@ -260,10 +276,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
260 | param["AllowPublish"] = allowPublish == true ? 1 : 0; | 276 | param["AllowPublish"] = allowPublish == true ? 1 : 0; |
261 | param["MaturePublish"] = maturePublish == true ? 1 : 0; | 277 | param["MaturePublish"] = maturePublish == true ? 1 : 0; |
262 | 278 | ||
263 | XmlRpcCall(requestID, "groups.updateGroup", param); | 279 | XmlRpcCall(requestingAgentID, "groups.updateGroup", param); |
264 | } | 280 | } |
265 | 281 | ||
266 | public void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, | 282 | public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, |
267 | string title, ulong powers) | 283 | string title, ulong powers) |
268 | { | 284 | { |
269 | Hashtable param = new Hashtable(); | 285 | Hashtable param = new Hashtable(); |
@@ -274,19 +290,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
274 | param["Title"] = title; | 290 | param["Title"] = title; |
275 | param["Powers"] = powers.ToString(); | 291 | param["Powers"] = powers.ToString(); |
276 | 292 | ||
277 | XmlRpcCall(requestID, "groups.addRoleToGroup", param); | 293 | XmlRpcCall(requestingAgentID, "groups.addRoleToGroup", param); |
278 | } | 294 | } |
279 | 295 | ||
280 | public void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID) | 296 | public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID) |
281 | { | 297 | { |
282 | Hashtable param = new Hashtable(); | 298 | Hashtable param = new Hashtable(); |
283 | param["GroupID"] = groupID.ToString(); | 299 | param["GroupID"] = groupID.ToString(); |
284 | param["RoleID"] = roleID.ToString(); | 300 | param["RoleID"] = roleID.ToString(); |
285 | 301 | ||
286 | XmlRpcCall(requestID, "groups.removeRoleFromGroup", param); | 302 | XmlRpcCall(requestingAgentID, "groups.removeRoleFromGroup", param); |
287 | } | 303 | } |
288 | 304 | ||
289 | public void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, | 305 | public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, |
290 | string title, ulong powers) | 306 | string title, ulong powers) |
291 | { | 307 | { |
292 | Hashtable param = new Hashtable(); | 308 | Hashtable param = new Hashtable(); |
@@ -306,10 +322,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
306 | } | 322 | } |
307 | param["Powers"] = powers.ToString(); | 323 | param["Powers"] = powers.ToString(); |
308 | 324 | ||
309 | XmlRpcCall(requestID, "groups.updateGroupRole", param); | 325 | XmlRpcCall(requestingAgentID, "groups.updateGroupRole", param); |
310 | } | 326 | } |
311 | 327 | ||
312 | public GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName) | 328 | public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName) |
313 | { | 329 | { |
314 | Hashtable param = new Hashtable(); | 330 | Hashtable param = new Hashtable(); |
315 | if (GroupID != UUID.Zero) | 331 | if (GroupID != UUID.Zero) |
@@ -321,7 +337,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
321 | param["Name"] = GroupName.ToString(); | 337 | param["Name"] = GroupName.ToString(); |
322 | } | 338 | } |
323 | 339 | ||
324 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param); | 340 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param); |
325 | 341 | ||
326 | if (respData.Contains("error")) | 342 | if (respData.Contains("error")) |
327 | { | 343 | { |
@@ -332,12 +348,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
332 | 348 | ||
333 | } | 349 | } |
334 | 350 | ||
335 | public GroupProfileData GetMemberGroupProfile(GroupRequestID requestID, UUID GroupID, UUID AgentID) | 351 | public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID) |
336 | { | 352 | { |
337 | Hashtable param = new Hashtable(); | 353 | Hashtable param = new Hashtable(); |
338 | param["GroupID"] = GroupID.ToString(); | 354 | param["GroupID"] = GroupID.ToString(); |
339 | 355 | ||
340 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param); | 356 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param); |
341 | 357 | ||
342 | if (respData.Contains("error")) | 358 | if (respData.Contains("error")) |
343 | { | 359 | { |
@@ -345,7 +361,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
345 | return new GroupProfileData(); | 361 | return new GroupProfileData(); |
346 | } | 362 | } |
347 | 363 | ||
348 | GroupMembershipData MemberInfo = GetAgentGroupMembership(requestID, AgentID, GroupID); | 364 | GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, AgentID, GroupID); |
349 | GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData); | 365 | GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData); |
350 | 366 | ||
351 | MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; | 367 | MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; |
@@ -354,26 +370,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
354 | return MemberGroupProfile; | 370 | return MemberGroupProfile; |
355 | } | 371 | } |
356 | 372 | ||
357 | public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID) | 373 | public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) |
358 | { | 374 | { |
359 | Hashtable param = new Hashtable(); | 375 | Hashtable param = new Hashtable(); |
360 | param["AgentID"] = AgentID.ToString(); | 376 | param["AgentID"] = AgentID.ToString(); |
361 | param["GroupID"] = GroupID.ToString(); | 377 | param["GroupID"] = GroupID.ToString(); |
362 | 378 | ||
363 | XmlRpcCall(requestID, "groups.setAgentActiveGroup", param); | 379 | XmlRpcCall(requestingAgentID, "groups.setAgentActiveGroup", param); |
364 | } | 380 | } |
365 | 381 | ||
366 | public void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) | 382 | public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) |
367 | { | 383 | { |
368 | Hashtable param = new Hashtable(); | 384 | Hashtable param = new Hashtable(); |
369 | param["AgentID"] = AgentID.ToString(); | 385 | param["AgentID"] = AgentID.ToString(); |
370 | param["GroupID"] = GroupID.ToString(); | 386 | param["GroupID"] = GroupID.ToString(); |
371 | param["SelectedRoleID"] = RoleID.ToString(); | 387 | param["SelectedRoleID"] = RoleID.ToString(); |
372 | 388 | ||
373 | XmlRpcCall(requestID, "groups.setAgentGroupInfo", param); | 389 | XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param); |
374 | } | 390 | } |
375 | 391 | ||
376 | public void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) | 392 | public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) |
377 | { | 393 | { |
378 | Hashtable param = new Hashtable(); | 394 | Hashtable param = new Hashtable(); |
379 | param["AgentID"] = AgentID.ToString(); | 395 | param["AgentID"] = AgentID.ToString(); |
@@ -381,11 +397,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
381 | param["AcceptNotices"] = AcceptNotices ? "1" : "0"; | 397 | param["AcceptNotices"] = AcceptNotices ? "1" : "0"; |
382 | param["ListInProfile"] = ListInProfile ? "1" : "0"; | 398 | param["ListInProfile"] = ListInProfile ? "1" : "0"; |
383 | 399 | ||
384 | XmlRpcCall(requestID, "groups.setAgentGroupInfo", param); | 400 | XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param); |
385 | 401 | ||
386 | } | 402 | } |
387 | 403 | ||
388 | public void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) | 404 | public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) |
389 | { | 405 | { |
390 | Hashtable param = new Hashtable(); | 406 | Hashtable param = new Hashtable(); |
391 | param["InviteID"] = inviteID.ToString(); | 407 | param["InviteID"] = inviteID.ToString(); |
@@ -393,16 +409,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
393 | param["RoleID"] = roleID.ToString(); | 409 | param["RoleID"] = roleID.ToString(); |
394 | param["GroupID"] = groupID.ToString(); | 410 | param["GroupID"] = groupID.ToString(); |
395 | 411 | ||
396 | XmlRpcCall(requestID, "groups.addAgentToGroupInvite", param); | 412 | XmlRpcCall(requestingAgentID, "groups.addAgentToGroupInvite", param); |
397 | 413 | ||
398 | } | 414 | } |
399 | 415 | ||
400 | public GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID) | 416 | public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID) |
401 | { | 417 | { |
402 | Hashtable param = new Hashtable(); | 418 | Hashtable param = new Hashtable(); |
403 | param["InviteID"] = inviteID.ToString(); | 419 | param["InviteID"] = inviteID.ToString(); |
404 | 420 | ||
405 | Hashtable respData = XmlRpcCall(requestID, "groups.getAgentToGroupInvite", param); | 421 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentToGroupInvite", param); |
406 | 422 | ||
407 | if (respData.Contains("error")) | 423 | if (respData.Contains("error")) |
408 | { | 424 | { |
@@ -418,59 +434,59 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
418 | return inviteInfo; | 434 | return inviteInfo; |
419 | } | 435 | } |
420 | 436 | ||
421 | public void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID) | 437 | public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID) |
422 | { | 438 | { |
423 | Hashtable param = new Hashtable(); | 439 | Hashtable param = new Hashtable(); |
424 | param["InviteID"] = inviteID.ToString(); | 440 | param["InviteID"] = inviteID.ToString(); |
425 | 441 | ||
426 | XmlRpcCall(requestID, "groups.removeAgentToGroupInvite", param); | 442 | XmlRpcCall(requestingAgentID, "groups.removeAgentToGroupInvite", param); |
427 | } | 443 | } |
428 | 444 | ||
429 | public void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) | 445 | public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) |
430 | { | 446 | { |
431 | Hashtable param = new Hashtable(); | 447 | Hashtable param = new Hashtable(); |
432 | param["AgentID"] = AgentID.ToString(); | 448 | param["AgentID"] = AgentID.ToString(); |
433 | param["GroupID"] = GroupID.ToString(); | 449 | param["GroupID"] = GroupID.ToString(); |
434 | param["RoleID"] = RoleID.ToString(); | 450 | param["RoleID"] = RoleID.ToString(); |
435 | 451 | ||
436 | XmlRpcCall(requestID, "groups.addAgentToGroup", param); | 452 | XmlRpcCall(requestingAgentID, "groups.addAgentToGroup", param); |
437 | } | 453 | } |
438 | 454 | ||
439 | public void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID) | 455 | public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID) |
440 | { | 456 | { |
441 | Hashtable param = new Hashtable(); | 457 | Hashtable param = new Hashtable(); |
442 | param["AgentID"] = AgentID.ToString(); | 458 | param["AgentID"] = AgentID.ToString(); |
443 | param["GroupID"] = GroupID.ToString(); | 459 | param["GroupID"] = GroupID.ToString(); |
444 | 460 | ||
445 | XmlRpcCall(requestID, "groups.removeAgentFromGroup", param); | 461 | XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroup", param); |
446 | } | 462 | } |
447 | 463 | ||
448 | public void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) | 464 | public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) |
449 | { | 465 | { |
450 | Hashtable param = new Hashtable(); | 466 | Hashtable param = new Hashtable(); |
451 | param["AgentID"] = AgentID.ToString(); | 467 | param["AgentID"] = AgentID.ToString(); |
452 | param["GroupID"] = GroupID.ToString(); | 468 | param["GroupID"] = GroupID.ToString(); |
453 | param["RoleID"] = RoleID.ToString(); | 469 | param["RoleID"] = RoleID.ToString(); |
454 | 470 | ||
455 | XmlRpcCall(requestID, "groups.addAgentToGroupRole", param); | 471 | XmlRpcCall(requestingAgentID, "groups.addAgentToGroupRole", param); |
456 | } | 472 | } |
457 | 473 | ||
458 | public void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) | 474 | public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID) |
459 | { | 475 | { |
460 | Hashtable param = new Hashtable(); | 476 | Hashtable param = new Hashtable(); |
461 | param["AgentID"] = AgentID.ToString(); | 477 | param["AgentID"] = AgentID.ToString(); |
462 | param["GroupID"] = GroupID.ToString(); | 478 | param["GroupID"] = GroupID.ToString(); |
463 | param["RoleID"] = RoleID.ToString(); | 479 | param["RoleID"] = RoleID.ToString(); |
464 | 480 | ||
465 | XmlRpcCall(requestID, "groups.removeAgentFromGroupRole", param); | 481 | XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroupRole", param); |
466 | } | 482 | } |
467 | 483 | ||
468 | public List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search) | 484 | public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search) |
469 | { | 485 | { |
470 | Hashtable param = new Hashtable(); | 486 | Hashtable param = new Hashtable(); |
471 | param["Search"] = search; | 487 | param["Search"] = search; |
472 | 488 | ||
473 | Hashtable respData = XmlRpcCall(requestID, "groups.findGroups", param); | 489 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.findGroups", param); |
474 | 490 | ||
475 | List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>(); | 491 | List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>(); |
476 | 492 | ||
@@ -492,13 +508,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
492 | return findings; | 508 | return findings; |
493 | } | 509 | } |
494 | 510 | ||
495 | public GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID) | 511 | public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID) |
496 | { | 512 | { |
497 | Hashtable param = new Hashtable(); | 513 | Hashtable param = new Hashtable(); |
498 | param["AgentID"] = AgentID.ToString(); | 514 | param["AgentID"] = AgentID.ToString(); |
499 | param["GroupID"] = GroupID.ToString(); | 515 | param["GroupID"] = GroupID.ToString(); |
500 | 516 | ||
501 | Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMembership", param); | 517 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMembership", param); |
502 | 518 | ||
503 | if (respData.Contains("error")) | 519 | if (respData.Contains("error")) |
504 | { | 520 | { |
@@ -510,12 +526,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
510 | return data; | 526 | return data; |
511 | } | 527 | } |
512 | 528 | ||
513 | public GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID) | 529 | public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID) |
514 | { | 530 | { |
515 | Hashtable param = new Hashtable(); | 531 | Hashtable param = new Hashtable(); |
516 | param["AgentID"] = AgentID.ToString(); | 532 | param["AgentID"] = AgentID.ToString(); |
517 | 533 | ||
518 | Hashtable respData = XmlRpcCall(requestID, "groups.getAgentActiveMembership", param); | 534 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentActiveMembership", param); |
519 | 535 | ||
520 | if (respData.Contains("error")) | 536 | if (respData.Contains("error")) |
521 | { | 537 | { |
@@ -525,12 +541,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
525 | return HashTableToGroupMembershipData(respData); | 541 | return HashTableToGroupMembershipData(respData); |
526 | } | 542 | } |
527 | 543 | ||
528 | public List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID) | 544 | public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID) |
529 | { | 545 | { |
530 | Hashtable param = new Hashtable(); | 546 | Hashtable param = new Hashtable(); |
531 | param["AgentID"] = AgentID.ToString(); | 547 | param["AgentID"] = AgentID.ToString(); |
532 | 548 | ||
533 | Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMemberships", param); | 549 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMemberships", param); |
534 | 550 | ||
535 | List<GroupMembershipData> memberships = new List<GroupMembershipData>(); | 551 | List<GroupMembershipData> memberships = new List<GroupMembershipData>(); |
536 | 552 | ||
@@ -545,13 +561,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
545 | return memberships; | 561 | return memberships; |
546 | } | 562 | } |
547 | 563 | ||
548 | public List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID) | 564 | public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID) |
549 | { | 565 | { |
550 | Hashtable param = new Hashtable(); | 566 | Hashtable param = new Hashtable(); |
551 | param["AgentID"] = AgentID.ToString(); | 567 | param["AgentID"] = AgentID.ToString(); |
552 | param["GroupID"] = GroupID.ToString(); | 568 | param["GroupID"] = GroupID.ToString(); |
553 | 569 | ||
554 | Hashtable respData = XmlRpcCall(requestID, "groups.getAgentRoles", param); | 570 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentRoles", param); |
555 | 571 | ||
556 | List<GroupRolesData> Roles = new List<GroupRolesData>(); | 572 | List<GroupRolesData> Roles = new List<GroupRolesData>(); |
557 | 573 | ||
@@ -577,12 +593,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
577 | 593 | ||
578 | } | 594 | } |
579 | 595 | ||
580 | public List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID) | 596 | public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID) |
581 | { | 597 | { |
582 | Hashtable param = new Hashtable(); | 598 | Hashtable param = new Hashtable(); |
583 | param["GroupID"] = GroupID.ToString(); | 599 | param["GroupID"] = GroupID.ToString(); |
584 | 600 | ||
585 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoles", param); | 601 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoles", param); |
586 | 602 | ||
587 | List<GroupRolesData> Roles = new List<GroupRolesData>(); | 603 | List<GroupRolesData> Roles = new List<GroupRolesData>(); |
588 | 604 | ||
@@ -610,12 +626,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
610 | 626 | ||
611 | 627 | ||
612 | 628 | ||
613 | public List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID) | 629 | public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID) |
614 | { | 630 | { |
615 | Hashtable param = new Hashtable(); | 631 | Hashtable param = new Hashtable(); |
616 | param["GroupID"] = GroupID.ToString(); | 632 | param["GroupID"] = GroupID.ToString(); |
617 | 633 | ||
618 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroupMembers", param); | 634 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupMembers", param); |
619 | 635 | ||
620 | List<GroupMembersData> members = new List<GroupMembersData>(); | 636 | List<GroupMembersData> members = new List<GroupMembersData>(); |
621 | 637 | ||
@@ -643,12 +659,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
643 | 659 | ||
644 | } | 660 | } |
645 | 661 | ||
646 | public List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID) | 662 | public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID) |
647 | { | 663 | { |
648 | Hashtable param = new Hashtable(); | 664 | Hashtable param = new Hashtable(); |
649 | param["GroupID"] = GroupID.ToString(); | 665 | param["GroupID"] = GroupID.ToString(); |
650 | 666 | ||
651 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoleMembers", param); | 667 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoleMembers", param); |
652 | 668 | ||
653 | List<GroupRoleMembersData> members = new List<GroupRoleMembersData>(); | 669 | List<GroupRoleMembersData> members = new List<GroupRoleMembersData>(); |
654 | 670 | ||
@@ -667,12 +683,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
667 | return members; | 683 | return members; |
668 | } | 684 | } |
669 | 685 | ||
670 | public List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID) | 686 | public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID) |
671 | { | 687 | { |
672 | Hashtable param = new Hashtable(); | 688 | Hashtable param = new Hashtable(); |
673 | param["GroupID"] = GroupID.ToString(); | 689 | param["GroupID"] = GroupID.ToString(); |
674 | 690 | ||
675 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotices", param); | 691 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotices", param); |
676 | 692 | ||
677 | List<GroupNoticeData> values = new List<GroupNoticeData>(); | 693 | List<GroupNoticeData> values = new List<GroupNoticeData>(); |
678 | 694 | ||
@@ -694,12 +710,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
694 | return values; | 710 | return values; |
695 | 711 | ||
696 | } | 712 | } |
697 | public GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID) | 713 | public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) |
698 | { | 714 | { |
699 | Hashtable param = new Hashtable(); | 715 | Hashtable param = new Hashtable(); |
700 | param["NoticeID"] = noticeID.ToString(); | 716 | param["NoticeID"] = noticeID.ToString(); |
701 | 717 | ||
702 | Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotice", param); | 718 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotice", param); |
703 | 719 | ||
704 | 720 | ||
705 | if (respData.Contains("error")) | 721 | if (respData.Contains("error")) |
@@ -725,7 +741,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
725 | 741 | ||
726 | return data; | 742 | return data; |
727 | } | 743 | } |
728 | public void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) | 744 | public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) |
729 | { | 745 | { |
730 | string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, ""); | 746 | string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, ""); |
731 | 747 | ||
@@ -738,7 +754,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
738 | param["BinaryBucket"] = binBucket; | 754 | param["BinaryBucket"] = binBucket; |
739 | param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString(); | 755 | param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString(); |
740 | 756 | ||
741 | XmlRpcCall(requestID, "groups.addGroupNotice", param); | 757 | XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param); |
742 | } | 758 | } |
743 | #endregion | 759 | #endregion |
744 | 760 | ||
@@ -831,15 +847,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
831 | /// <summary> | 847 | /// <summary> |
832 | /// Encapsulate the XmlRpc call to standardize security and error handling. | 848 | /// Encapsulate the XmlRpc call to standardize security and error handling. |
833 | /// </summary> | 849 | /// </summary> |
834 | private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param) | 850 | private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param) |
835 | { | 851 | { |
836 | if (requestID == null) | 852 | string UserService; |
837 | { | 853 | UUID SessionID; |
838 | requestID = new GroupRequestID(); | 854 | GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID); |
839 | } | 855 | param.Add("requestingAgentID", requestingAgentID.ToString()); |
840 | param.Add("RequestingAgentID", requestID.AgentID.ToString()); | 856 | param.Add("RequestingAgentUserService", UserService); |
841 | param.Add("RequestingAgentUserService", requestID.UserServiceURL); | 857 | param.Add("RequestingSessionID", SessionID.ToString()); |
842 | param.Add("RequestingSessionID", requestID.SessionID.ToString()); | ||
843 | 858 | ||
844 | 859 | ||
845 | param.Add("ReadKey", m_groupReadKey); | 860 | param.Add("ReadKey", m_groupReadKey); |
@@ -930,15 +945,49 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
930 | } | 945 | } |
931 | } | 946 | } |
932 | 947 | ||
948 | |||
949 | /// <summary> | ||
950 | /// Group Request Tokens are an attempt to allow the groups service to authenticate | ||
951 | /// requests. Currently uses UserService, AgentID, and SessionID | ||
952 | /// TODO: Find a better way to do this. | ||
953 | /// </summary> | ||
954 | /// <param name="client"></param> | ||
955 | /// <returns></returns> | ||
956 | private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID) | ||
957 | { | ||
958 | UserServiceURL = ""; | ||
959 | SessionID = UUID.Zero; | ||
933 | 960 | ||
934 | } | ||
935 | 961 | ||
936 | public class GroupNoticeInfo | 962 | // Need to rework this based on changes to User Services |
937 | { | 963 | /* |
938 | public GroupNoticeData noticeData = new GroupNoticeData(); | 964 | UserAccount userAccount = m_accountService.GetUserAccount(UUID.Zero,AgentID); |
939 | public UUID GroupID = UUID.Zero; | 965 | if (userAccount == null) |
940 | public string Message = string.Empty; | 966 | { |
941 | public byte[] BinaryBucket = new byte[0]; | 967 | // This should be impossible. If I've been passed a reference to a client |
968 | // that client should be registered with the UserService. So something | ||
969 | // is horribly wrong somewhere. | ||
970 | |||
971 | m_log.WarnFormat("[GROUPS]: Could not find a UserServiceURL for {0}", AgentID); | ||
972 | |||
973 | } | ||
974 | else if (userProfile is ForeignUserProfileData) | ||
975 | { | ||
976 | // They aren't from around here | ||
977 | ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile; | ||
978 | UserServiceURL = fupd.UserServerURI; | ||
979 | SessionID = fupd.CurrentAgent.SessionID; | ||
980 | |||
981 | } | ||
982 | else | ||
983 | { | ||
984 | // They're a local user, use this: | ||
985 | UserServiceURL = m_commManager.NetworkServersInfo.UserURL; | ||
986 | SessionID = userProfile.CurrentAgent.SessionID; | ||
987 | } | ||
988 | */ | ||
989 | } | ||
990 | |||
942 | } | 991 | } |
943 | } | 992 | } |
944 | 993 | ||
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 77958eb..338c04b 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -550,7 +550,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
550 | 550 | ||
551 | } | 551 | } |
552 | 552 | ||
553 | public void SendGenericMessage(string method, List<string> message) | 553 | public void SendGenericMessage(string method, List<byte[]> message) |
554 | { | 554 | { |
555 | 555 | ||
556 | } | 556 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs new file mode 100644 index 0000000..880ca1b --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -0,0 +1,504 @@ | |||
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.Reflection; | ||
30 | using System.Collections; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Runtime.Remoting.Lifetime; | ||
33 | using OpenMetaverse; | ||
34 | using Nini.Config; | ||
35 | using OpenSim; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.CoreModules.World.LightShare; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Region.ScriptEngine.Shared; | ||
41 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
42 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
43 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
44 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
45 | |||
46 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
47 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
48 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
49 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
50 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
51 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
52 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
53 | |||
54 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
55 | { | ||
56 | [Serializable] | ||
57 | public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi | ||
58 | { | ||
59 | internal IScriptEngine m_ScriptEngine; | ||
60 | internal SceneObjectPart m_host; | ||
61 | internal uint m_localID; | ||
62 | internal UUID m_itemID; | ||
63 | internal bool m_CMFunctionsEnabled = false; | ||
64 | internal IScriptModuleComms m_comms = null; | ||
65 | |||
66 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | ||
67 | { | ||
68 | m_ScriptEngine = ScriptEngine; | ||
69 | m_host = host; | ||
70 | m_localID = localID; | ||
71 | m_itemID = itemID; | ||
72 | |||
73 | if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) | ||
74 | m_CMFunctionsEnabled = true; | ||
75 | |||
76 | m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); | ||
77 | if (m_comms == null) | ||
78 | m_CMFunctionsEnabled = false; | ||
79 | } | ||
80 | |||
81 | public override Object InitializeLifetimeService() | ||
82 | { | ||
83 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
84 | |||
85 | if (lease.CurrentState == LeaseState.Initial) | ||
86 | { | ||
87 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); | ||
88 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
89 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
90 | } | ||
91 | return lease; | ||
92 | } | ||
93 | |||
94 | public Scene World | ||
95 | { | ||
96 | get { return m_ScriptEngine.World; } | ||
97 | } | ||
98 | |||
99 | // | ||
100 | //Dumps an error message on the debug console. | ||
101 | // | ||
102 | |||
103 | internal void CMShoutError(string message) | ||
104 | { | ||
105 | if (message.Length > 1023) | ||
106 | message = message.Substring(0, 1023); | ||
107 | |||
108 | World.SimChat(Utils.StringToBytes(message), | ||
109 | ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); | ||
110 | |||
111 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
112 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | ||
113 | } | ||
114 | |||
115 | /// <summary> | ||
116 | /// Get the current Windlight scene | ||
117 | /// </summary> | ||
118 | /// <returns>List of windlight parameters</returns> | ||
119 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
120 | { | ||
121 | if (!m_CMFunctionsEnabled) | ||
122 | { | ||
123 | CMShoutError("Careminster functions are not enabled."); | ||
124 | return new LSL_List(); | ||
125 | } | ||
126 | m_host.AddScriptLPS(1); | ||
127 | RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; | ||
128 | |||
129 | LSL_List values = new LSL_List(); | ||
130 | int idx = 0; | ||
131 | while (idx < rules.Length) | ||
132 | { | ||
133 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | ||
134 | LSL_List toadd = new LSL_List(); | ||
135 | |||
136 | switch (rule) | ||
137 | { | ||
138 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
139 | toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W)); | ||
140 | break; | ||
141 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
142 | toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f)); | ||
143 | break; | ||
144 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
145 | toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W)); | ||
146 | break; | ||
147 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
148 | toadd.Add(new LSL_Float(wl.blurMultiplier)); | ||
149 | break; | ||
150 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
151 | toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W)); | ||
152 | break; | ||
153 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
154 | toadd.Add(new LSL_Float(wl.cloudCoverage)); | ||
155 | break; | ||
156 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
157 | toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z)); | ||
158 | break; | ||
159 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
160 | toadd.Add(new LSL_Float(wl.cloudScale)); | ||
161 | break; | ||
162 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
163 | toadd.Add(new LSL_Float(wl.cloudScrollX)); | ||
164 | break; | ||
165 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
166 | toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0)); | ||
167 | break; | ||
168 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
169 | toadd.Add(new LSL_Float(wl.cloudScrollY)); | ||
170 | break; | ||
171 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
172 | toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0)); | ||
173 | break; | ||
174 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
175 | toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z)); | ||
176 | break; | ||
177 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
178 | toadd.Add(new LSL_Float(wl.densityMultiplier)); | ||
179 | break; | ||
180 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
181 | toadd.Add(new LSL_Float(wl.distanceMultiplier)); | ||
182 | break; | ||
183 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
184 | toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0)); | ||
185 | break; | ||
186 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
187 | toadd.Add(new LSL_Float(wl.eastAngle)); | ||
188 | break; | ||
189 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
190 | toadd.Add(new LSL_Float(wl.fresnelOffset)); | ||
191 | break; | ||
192 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
193 | toadd.Add(new LSL_Float(wl.fresnelScale)); | ||
194 | break; | ||
195 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
196 | toadd.Add(new LSL_Float(wl.hazeDensity)); | ||
197 | break; | ||
198 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
199 | toadd.Add(new LSL_Float(wl.hazeHorizon)); | ||
200 | break; | ||
201 | case (int)ScriptBaseClass.WL_HORIZON: | ||
202 | toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W)); | ||
203 | break; | ||
204 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
205 | toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f)); | ||
206 | break; | ||
207 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
208 | toadd.Add(new LSL_Integer(wl.maxAltitude)); | ||
209 | break; | ||
210 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
211 | toadd.Add(new LSL_Key(wl.normalMapTexture.ToString())); | ||
212 | break; | ||
213 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
214 | toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z)); | ||
215 | break; | ||
216 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
217 | toadd.Add(new LSL_Float(wl.refractScaleAbove)); | ||
218 | break; | ||
219 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
220 | toadd.Add(new LSL_Float(wl.refractScaleBelow)); | ||
221 | break; | ||
222 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
223 | toadd.Add(new LSL_Float(wl.sceneGamma)); | ||
224 | break; | ||
225 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
226 | toadd.Add(new LSL_Float(wl.starBrightness)); | ||
227 | break; | ||
228 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
229 | toadd.Add(new LSL_Float(wl.sunGlowFocus)); | ||
230 | break; | ||
231 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
232 | toadd.Add(new LSL_Float(wl.sunGlowSize)); | ||
233 | break; | ||
234 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
235 | toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W)); | ||
236 | break; | ||
237 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
238 | toadd.Add(new LSL_Float(wl.underwaterFogModifier)); | ||
239 | break; | ||
240 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
241 | toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z)); | ||
242 | break; | ||
243 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
244 | toadd.Add(new LSL_Float(wl.waterFogDensityExponent)); | ||
245 | break; | ||
246 | } | ||
247 | |||
248 | if (toadd.Length > 0) | ||
249 | { | ||
250 | values.Add(rule); | ||
251 | values.Add(toadd.Data[0]); | ||
252 | } | ||
253 | idx++; | ||
254 | } | ||
255 | |||
256 | |||
257 | return values; | ||
258 | |||
259 | } | ||
260 | |||
261 | private RegionLightShareData getWindlightProfileFromRules(LSL_List rules) | ||
262 | { | ||
263 | RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); | ||
264 | |||
265 | LSL_List values = new LSL_List(); | ||
266 | int idx = 0; | ||
267 | while (idx < rules.Length) | ||
268 | { | ||
269 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | ||
270 | LSL_Types.Quaternion iQ; | ||
271 | LSL_Types.Vector3 iV; | ||
272 | switch (rule) | ||
273 | { | ||
274 | case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: | ||
275 | idx++; | ||
276 | wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); | ||
277 | break; | ||
278 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
279 | idx++; | ||
280 | iQ = rules.GetQuaternionItem(idx); | ||
281 | wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
282 | break; | ||
283 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
284 | idx++; | ||
285 | iV = rules.GetVector3Item(idx); | ||
286 | wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
287 | break; | ||
288 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
289 | idx++; | ||
290 | iQ = rules.GetQuaternionItem(idx); | ||
291 | wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
292 | break; | ||
293 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
294 | idx++; | ||
295 | wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
296 | break; | ||
297 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
298 | idx++; | ||
299 | iQ = rules.GetQuaternionItem(idx); | ||
300 | wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
301 | break; | ||
302 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
303 | idx++; | ||
304 | wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); | ||
305 | break; | ||
306 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
307 | idx++; | ||
308 | iV = rules.GetVector3Item(idx); | ||
309 | wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
310 | break; | ||
311 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
312 | idx++; | ||
313 | wl.cloudScale = (float)rules.GetLSLFloatItem(idx); | ||
314 | break; | ||
315 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
316 | idx++; | ||
317 | wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); | ||
318 | break; | ||
319 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
320 | idx++; | ||
321 | wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
322 | break; | ||
323 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
324 | idx++; | ||
325 | wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); | ||
326 | break; | ||
327 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
328 | idx++; | ||
329 | wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
330 | break; | ||
331 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
332 | idx++; | ||
333 | iV = rules.GetVector3Item(idx); | ||
334 | wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
335 | break; | ||
336 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
337 | idx++; | ||
338 | wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
339 | break; | ||
340 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
341 | idx++; | ||
342 | wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
343 | break; | ||
344 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
345 | idx++; | ||
346 | wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
347 | break; | ||
348 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
349 | idx++; | ||
350 | wl.eastAngle = (float)rules.GetLSLFloatItem(idx); | ||
351 | break; | ||
352 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
353 | idx++; | ||
354 | wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); | ||
355 | break; | ||
356 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
357 | idx++; | ||
358 | wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); | ||
359 | break; | ||
360 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
361 | idx++; | ||
362 | wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); | ||
363 | break; | ||
364 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
365 | idx++; | ||
366 | wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); | ||
367 | break; | ||
368 | case (int)ScriptBaseClass.WL_HORIZON: | ||
369 | idx++; | ||
370 | iQ = rules.GetQuaternionItem(idx); | ||
371 | wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
372 | break; | ||
373 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
374 | idx++; | ||
375 | iV = rules.GetVector3Item(idx); | ||
376 | wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
377 | break; | ||
378 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
379 | idx++; | ||
380 | wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; | ||
381 | break; | ||
382 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
383 | idx++; | ||
384 | wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); | ||
385 | break; | ||
386 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
387 | idx++; | ||
388 | iV = rules.GetVector3Item(idx); | ||
389 | wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
390 | break; | ||
391 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
392 | idx++; | ||
393 | wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); | ||
394 | break; | ||
395 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
396 | idx++; | ||
397 | wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); | ||
398 | break; | ||
399 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
400 | idx++; | ||
401 | wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); | ||
402 | break; | ||
403 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
404 | idx++; | ||
405 | wl.starBrightness = (float)rules.GetLSLFloatItem(idx); | ||
406 | break; | ||
407 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
408 | idx++; | ||
409 | wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); | ||
410 | break; | ||
411 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
412 | idx++; | ||
413 | wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); | ||
414 | break; | ||
415 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
416 | idx++; | ||
417 | iQ = rules.GetQuaternionItem(idx); | ||
418 | wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
419 | break; | ||
420 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
421 | idx++; | ||
422 | wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); | ||
423 | break; | ||
424 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
425 | idx++; | ||
426 | iV = rules.GetVector3Item(idx); | ||
427 | wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
428 | break; | ||
429 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
430 | idx++; | ||
431 | wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); | ||
432 | break; | ||
433 | } | ||
434 | idx++; | ||
435 | } | ||
436 | return wl; | ||
437 | } | ||
438 | /// <summary> | ||
439 | /// Set the current Windlight scene | ||
440 | /// </summary> | ||
441 | /// <param name="rules"></param> | ||
442 | /// <returns>success: true or false</returns> | ||
443 | public int cmSetWindlightScene(LSL_List rules) | ||
444 | { | ||
445 | if (!m_CMFunctionsEnabled) | ||
446 | { | ||
447 | CMShoutError("Careminster functions are not enabled."); | ||
448 | return 0; | ||
449 | } | ||
450 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
451 | { | ||
452 | CMShoutError("cmSetWindlightScene can only be used by estate managers or owners."); | ||
453 | return 0; | ||
454 | } | ||
455 | int success = 0; | ||
456 | m_host.AddScriptLPS(1); | ||
457 | if (LightShareModule.EnableWindlight) | ||
458 | { | ||
459 | RegionLightShareData wl = getWindlightProfileFromRules(rules); | ||
460 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); | ||
461 | success = 1; | ||
462 | } | ||
463 | else | ||
464 | { | ||
465 | CMShoutError("Windlight module is disabled"); | ||
466 | return 0; | ||
467 | } | ||
468 | return success; | ||
469 | } | ||
470 | /// <summary> | ||
471 | /// Set the current Windlight scene to a target avatar | ||
472 | /// </summary> | ||
473 | /// <param name="rules"></param> | ||
474 | /// <returns>success: true or false</returns> | ||
475 | public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target) | ||
476 | { | ||
477 | if (!m_CMFunctionsEnabled) | ||
478 | { | ||
479 | CMShoutError("Careminster functions are not enabled."); | ||
480 | return 0; | ||
481 | } | ||
482 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
483 | { | ||
484 | CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners."); | ||
485 | return 0; | ||
486 | } | ||
487 | int success = 0; | ||
488 | m_host.AddScriptLPS(1); | ||
489 | if (LightShareModule.EnableWindlight) | ||
490 | { | ||
491 | RegionLightShareData wl = getWindlightProfileFromRules(rules); | ||
492 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); | ||
493 | success = 1; | ||
494 | } | ||
495 | else | ||
496 | { | ||
497 | CMShoutError("Windlight module is disabled"); | ||
498 | return 0; | ||
499 | } | ||
500 | return success; | ||
501 | } | ||
502 | |||
503 | } | ||
504 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs new file mode 100644 index 0000000..f13b6e5 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs | |||
@@ -0,0 +1,48 @@ | |||
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.Collections; | ||
29 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
30 | |||
31 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
32 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
33 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
34 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
35 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
36 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
37 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
38 | |||
39 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | ||
40 | { | ||
41 | public interface ICM_Api | ||
42 | { | ||
43 | // Windlight Functions | ||
44 | LSL_List cmGetWindlightScene(LSL_List rules); | ||
45 | int cmSetWindlightScene(LSL_List rules); | ||
46 | int cmSetWindlightSceneTargeted(LSL_List rules, key target); | ||
47 | } | ||
48 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs new file mode 100644 index 0000000..f94ef4a --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs | |||
@@ -0,0 +1,77 @@ | |||
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 vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
30 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
31 | using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
32 | |||
33 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
34 | { | ||
35 | public partial class ScriptBaseClass | ||
36 | { | ||
37 | // Constants for cmWindlight* | ||
38 | public const int WL_WATER_COLOR = 0; | ||
39 | public const int WL_WATER_FOG_DENSITY_EXPONENT = 1; | ||
40 | public const int WL_UNDERWATER_FOG_MODIFIER = 2; | ||
41 | public const int WL_REFLECTION_WAVELET_SCALE = 3; | ||
42 | public const int WL_FRESNEL_SCALE = 4; | ||
43 | public const int WL_FRESNEL_OFFSET = 5; | ||
44 | public const int WL_REFRACT_SCALE_ABOVE = 6; | ||
45 | public const int WL_REFRACT_SCALE_BELOW = 7; | ||
46 | public const int WL_BLUR_MULTIPLIER = 8; | ||
47 | public const int WL_BIG_WAVE_DIRECTION = 9; | ||
48 | public const int WL_LITTLE_WAVE_DIRECTION = 10; | ||
49 | public const int WL_NORMAL_MAP_TEXTURE = 11; | ||
50 | public const int WL_HORIZON = 12; | ||
51 | public const int WL_HAZE_HORIZON = 13; | ||
52 | public const int WL_BLUE_DENSITY = 14; | ||
53 | public const int WL_HAZE_DENSITY = 15; | ||
54 | public const int WL_DENSITY_MULTIPLIER = 16; | ||
55 | public const int WL_DISTANCE_MULTIPLIER = 17; | ||
56 | public const int WL_MAX_ALTITUDE = 18; | ||
57 | public const int WL_SUN_MOON_COLOR = 19; | ||
58 | public const int WL_AMBIENT = 20; | ||
59 | public const int WL_EAST_ANGLE = 21; | ||
60 | public const int WL_SUN_GLOW_FOCUS = 22; | ||
61 | public const int WL_SUN_GLOW_SIZE = 23; | ||
62 | public const int WL_SCENE_GAMMA = 24; | ||
63 | public const int WL_STAR_BRIGHTNESS = 25; | ||
64 | public const int WL_CLOUD_COLOR = 26; | ||
65 | public const int WL_CLOUD_XY_DENSITY = 27; | ||
66 | public const int WL_CLOUD_COVERAGE = 28; | ||
67 | public const int WL_CLOUD_SCALE = 29; | ||
68 | public const int WL_CLOUD_DETAIL_XY_DENSITY = 30; | ||
69 | public const int WL_CLOUD_SCROLL_X = 31; | ||
70 | public const int WL_CLOUD_SCROLL_Y = 32; | ||
71 | public const int WL_CLOUD_SCROLL_Y_LOCK = 33; | ||
72 | public const int WL_CLOUD_SCROLL_X_LOCK = 34; | ||
73 | public const int WL_DRAW_CLASSIC_CLOUDS = 35; | ||
74 | public const int WL_SUN_MOON_POSITION = 36; | ||
75 | |||
76 | } | ||
77 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs new file mode 100644 index 0000000..c0edaae --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | |||
@@ -0,0 +1,76 @@ | |||
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.Runtime.Remoting.Lifetime; | ||
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
38 | using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
42 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
43 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
44 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
45 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
46 | |||
47 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
48 | { | ||
49 | public partial class ScriptBaseClass : MarshalByRefObject | ||
50 | { | ||
51 | public ICM_Api m_CM_Functions; | ||
52 | |||
53 | public void ApiTypeCM(IScriptApi api) | ||
54 | { | ||
55 | if (!(api is ICM_Api)) | ||
56 | return; | ||
57 | |||
58 | m_CM_Functions = (ICM_Api)api; | ||
59 | } | ||
60 | |||
61 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
62 | { | ||
63 | return m_CM_Functions.cmGetWindlightScene(rules); | ||
64 | } | ||
65 | |||
66 | public int cmSetWindlightScene(LSL_List rules) | ||
67 | { | ||
68 | return m_CM_Functions.cmSetWindlightScene(rules); | ||
69 | } | ||
70 | |||
71 | public int cmSetWindlightSceneTargeted(LSL_List rules, key target) | ||
72 | { | ||
73 | return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target); | ||
74 | } | ||
75 | } | ||
76 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp index 98bbc68..23138ef 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp | |||
@@ -17,6 +17,8 @@ | |||
17 | <excludeFiles /> | 17 | <excludeFiles /> |
18 | </DeploymentInformation> | 18 | </DeploymentInformation> |
19 | <Contents> | 19 | <Contents> |
20 | <File name="./CM_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | ||
21 | <File name="./CM_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | ||
20 | <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 22 | <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
21 | <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 23 | <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
22 | <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 24 | <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 5fff279..f015db2 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs | |||
@@ -518,7 +518,7 @@ namespace OpenSim.Tests.Common.Mock | |||
518 | 518 | ||
519 | } | 519 | } |
520 | 520 | ||
521 | public void SendGenericMessage(string method, List<string> message) | 521 | public void SendGenericMessage(string method, List<byte[]> message) |
522 | { | 522 | { |
523 | 523 | ||
524 | } | 524 | } |